Skip to content

Commit 3a86531

Browse files
committed
Feature: type manager 8 support
1 parent 776ddba commit 3a86531

File tree

10 files changed

+1238
-5330
lines changed

10 files changed

+1238
-5330
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Setup Node
1212
uses: actions/setup-node@v2
1313
with:
14-
node-version: '16.x'
14+
node-version: '22.x'
1515
registry-url: 'https://registry.npmjs.org'
1616
- name: Install dependencies
1717
run: npm install

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.0] - 2025-06-09
9+
10+
### Added
11+
12+
- Type manager 8 support.
13+
814
## [2.4.1] - 2024-07-01
915

1016
### Added

package-lock.json

Lines changed: 1219 additions & 5248 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22
"author": "DipScope authors and contributors",
33
"description": "Json api entity provider for entity store.",
44
"dependencies": {
5-
"tslib": "^2.0.1",
6-
"cross-fetch": "^3.1.5"
5+
"tslib": "^2.0.1"
76
},
87
"peerDependencies": {
98
"lodash": "^4.17.0",
10-
"@dipscope/type-manager": "^7.2.1",
11-
"@dipscope/entity-store": "^2.0.4"
9+
"@dipscope/type-manager": "^8.2.1",
10+
"@dipscope/entity-store": "^3.0.0"
1211
},
1312
"devDependencies": {
1413
"@types/jasmine": "^3.6.3",
1514
"@types/lodash": "^4.14.182",
16-
"@types/node": "^18.7.3",
1715
"@typescript-eslint/eslint-plugin": "^4.14.2",
1816
"@typescript-eslint/parser": "^4.14.2",
1917
"circular-dependency-plugin": "^5.2.2",
@@ -39,7 +37,6 @@
3937
],
4038
"license": "Apache-2.0",
4139
"main": "./dist/umd/index.js",
42-
"browser": "./dist/umd/index.browser.js",
4340
"module": "./dist/es5/index.js",
4441
"es2015": "./dist/es2015/index.js",
4542
"types": "./dist/types/index.d.ts",

spec/entity-store.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fetch from 'cross-fetch';
21
import { EntityCollection, EntitySet, EntityStore } from '@dipscope/entity-store';
32
import { Inject, Property, Type, TypeConfiguration, TypeManager, TypeMetadata } from '@dipscope/type-manager';
43
import { JsonApiEntityProvider, JsonApiNetFilterExpressionVisitor, JsonApiNetMetadataExtractor, JsonApiNetPaginateExpressionVisitor, JsonApiResource, JsonApiResourceMetadata } from '../src';

src/json-api-adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ export class JsonApiAdapter
528528

529529
for (const propertyMetadata of serializerContext.typeMetadata.propertyMetadataMap.values())
530530
{
531-
if (propertyMetadata.serializationConfigured && !propertyMetadata.serializable)
531+
if (!propertyMetadata.serializable)
532532
{
533533
continue;
534534
}
@@ -823,7 +823,7 @@ export class JsonApiAdapter
823823

824824
for (const propertyMetadata of serializerContext.typeMetadata.propertyMetadataMap.values())
825825
{
826-
if (propertyMetadata.serializationConfigured && !propertyMetadata.deserializable)
826+
if (!propertyMetadata.deserializable)
827827
{
828828
continue;
829829
}

src/json-api-connection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Headers, Request } from 'cross-fetch';
21
import { isEmpty, isObject, isString } from 'lodash';
32
import { ConflictJsonApiError } from './errors/conflict-json-api-error';
43
import { ForbiddenJsonApiError } from './errors/forbidden-json-api-error';

src/json-api-entity-provider.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import fetch from 'cross-fetch';
21
import { first, isNil, merge, toString } from 'lodash';
32
import { AddCommand, BatchRemoveCommand, BatchUpdateCommand, CommandNotSupportedError, EntitySet } from '@dipscope/entity-store';
43
import { IncludeClause, IncludeCollectionClause, PaginatedEntityCollection } from '@dipscope/entity-store';
@@ -47,7 +46,7 @@ export class JsonApiEntityProvider implements EntityProvider
4746
{
4847
const defaultJsonApiRequestInterceptor = (request: Request) => request;
4948
const defaultJsonApiResponseInterceptor = (response: Response) => response;
50-
const defaultJsonApiFetchInterceptor = fetch;
49+
const defaultJsonApiFetchInterceptor = (request: Request) => fetch(request);
5150
const jsonApiRequestInterceptor = jsonApiEntityProviderOptions.jsonApiRequestInterceptor ?? defaultJsonApiRequestInterceptor;
5251
const jsonApiResponseInterceptor = jsonApiEntityProviderOptions.jsonApiResponseInterceptor ?? defaultJsonApiResponseInterceptor;
5352
const jsonApiFetchInterceptor = jsonApiEntityProviderOptions.jsonApiFetchInterceptor ?? defaultJsonApiFetchInterceptor;

src/json-api-resource-metadata.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class JsonApiResourceMetadata<TEntity extends Entity> extends TypeExtensi
3333
*/
3434
public get type(): string
3535
{
36-
return this.typeMetadata.extractCustomOption(jsonApiResourceTypeKey) ?? this.typeMetadata.typeName;
36+
return this.typeMetadata.extractCustomValue(jsonApiResourceTypeKey) ?? this.typeMetadata.typeName;
3737
}
3838

3939
/**
@@ -43,7 +43,7 @@ export class JsonApiResourceMetadata<TEntity extends Entity> extends TypeExtensi
4343
*/
4444
public get route(): string
4545
{
46-
return this.typeMetadata.extractCustomOption(jsonApiResourceRouteKey) ?? this.type;
46+
return this.typeMetadata.extractCustomValue(jsonApiResourceRouteKey) ?? this.type;
4747
}
4848

4949
/**
@@ -55,7 +55,7 @@ export class JsonApiResourceMetadata<TEntity extends Entity> extends TypeExtensi
5555
*/
5656
public hasType(type: string | undefined): this
5757
{
58-
this.typeMetadata.hasCustomOption(jsonApiResourceTypeKey, type)
58+
this.typeMetadata.hasCustomValue(jsonApiResourceTypeKey, type)
5959
.hasDiscriminator(jsonApiResourceType)
6060
.hasDiscriminant(this.type)
6161
.shouldPreserveDiscriminator();
@@ -72,7 +72,7 @@ export class JsonApiResourceMetadata<TEntity extends Entity> extends TypeExtensi
7272
*/
7373
public hasRoute(route: string | undefined): this
7474
{
75-
this.typeMetadata.hasCustomOption(jsonApiResourceRouteKey, route);
75+
this.typeMetadata.hasCustomValue(jsonApiResourceRouteKey, route);
7676

7777
return this;
7878
}

webpack.config.js

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
const Path = require('path');
22
const CircularDependencyPlugin = require('circular-dependency-plugin');
33

4-
module.exports = [{
4+
module.exports = {
55
mode: 'production',
66
devtool: 'source-map',
7-
target: 'node',
87
entry: {
98
index: './src/index.ts'
109
},
@@ -63,66 +62,4 @@ module.exports = [{
6362
resolve: {
6463
extensions: ['.tsx', '.ts', '.js']
6564
}
66-
}, {
67-
mode: 'production',
68-
devtool: 'source-map',
69-
target: 'web',
70-
entry: {
71-
index: './src/index.ts'
72-
},
73-
output: {
74-
path: Path.resolve(__dirname, 'dist/umd'),
75-
filename: '[name].browser.js',
76-
library: '$DSJsonApiEntityProvider',
77-
libraryTarget: 'umd',
78-
globalObject: 'this',
79-
umdNamedDefine: true
80-
},
81-
externals: {
82-
'lodash': {
83-
commonjs: 'lodash',
84-
commonjs2: 'lodash',
85-
amd: 'lodash',
86-
root: '_'
87-
},
88-
'@dipscope/type-manager': {
89-
commonjs: '@dipscope/type-manager',
90-
commonjs2: '@dipscope/type-manager',
91-
amd: '@dipscope/type-manager',
92-
root: '$DSTypeManager'
93-
},
94-
'@dipscope/entity-store': {
95-
commonjs: '@dipscope/entity-store',
96-
commonjs2: '@dipscope/entity-store',
97-
amd: '@dipscope/entity-store',
98-
root: '$DSEntityStore'
99-
}
100-
},
101-
plugins: [
102-
new CircularDependencyPlugin({
103-
exclude: /node_modules/,
104-
include: /src/,
105-
failOnError: true,
106-
allowAsyncCycles: false,
107-
cwd: process.cwd()
108-
})
109-
],
110-
module: {
111-
rules: [{
112-
test: /\.tsx?$/,
113-
use: [{
114-
loader: 'ts-loader',
115-
options: {
116-
configFile: 'tsconfig/tsconfig.umd.json'
117-
}
118-
}],
119-
exclude: /node_modules/,
120-
include: [
121-
Path.resolve(__dirname, 'src')
122-
],
123-
}]
124-
},
125-
resolve: {
126-
extensions: ['.tsx', '.ts', '.js']
127-
}
128-
}];
65+
};

0 commit comments

Comments
 (0)