@klerick/json-api-nestjs 10.0.0-beta.10 → 10.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +29 -2
- package/package.json +3 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/lib/json-api.module.js +3 -2
- package/src/lib/json-api.module.js.map +1 -1
- package/src/lib/modules/atomic-operation/atomic-operation.module.d.ts +1 -2
- package/src/lib/modules/atomic-operation/atomic-operation.module.js +6 -5
- package/src/lib/modules/atomic-operation/atomic-operation.module.js.map +1 -1
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.d.ts +1 -2
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.js +8 -7
- package/src/lib/modules/atomic-operation/factory/map-controller-entity.js.map +1 -1
- package/src/lib/modules/mixin/decorators/index.d.ts +1 -0
- package/src/lib/modules/mixin/decorators/index.js +1 -0
- package/src/lib/modules/mixin/decorators/index.js.map +1 -1
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.d.ts +19 -0
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.js +35 -0
- package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.js.map +1 -0
- package/src/lib/modules/mixin/swagger/error-response-model.d.ts +49 -0
- package/src/lib/modules/mixin/swagger/error-response-model.js +125 -0
- package/src/lib/modules/mixin/swagger/error-response-model.js.map +1 -0
- package/src/lib/modules/mixin/swagger/method/delete-one.js +3 -3
- package/src/lib/modules/mixin/swagger/method/delete-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/delete-relationship.js +4 -4
- package/src/lib/modules/mixin/swagger/method/delete-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-all.js +2 -1
- package/src/lib/modules/mixin/swagger/method/get-all.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-one.js +3 -2
- package/src/lib/modules/mixin/swagger/method/get-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/get-relationship.js +4 -3
- package/src/lib/modules/mixin/swagger/method/get-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/patch-one.js +3 -2
- package/src/lib/modules/mixin/swagger/method/patch-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/patch-relationship.js +4 -3
- package/src/lib/modules/mixin/swagger/method/patch-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/post-one.js +3 -2
- package/src/lib/modules/mixin/swagger/method/post-one.js.map +1 -1
- package/src/lib/modules/mixin/swagger/method/post-relationship.js +4 -3
- package/src/lib/modules/mixin/swagger/method/post-relationship.js.map +1 -1
- package/src/lib/modules/mixin/swagger/swagger-bind.service.d.ts +1 -0
- package/src/lib/modules/mixin/swagger/swagger-bind.service.js +38 -0
- package/src/lib/modules/mixin/swagger/swagger-bind.service.js.map +1 -1
- package/src/lib/modules/mixin/swagger/utils.d.ts +0 -38
- package/src/lib/modules/mixin/swagger/utils.js +1 -39
- package/src/lib/modules/mixin/swagger/utils.js.map +1 -1
- package/src/lib/modules/mixin/zod/zod-input-query-schema/filter.d.ts +4 -4
- package/src/lib/modules/mixin/zod/zod-input-query-schema/index.d.ts +4 -4
- package/src/lib/modules/mixin/zod/zod-query-schema/include.d.ts +9 -2
- package/src/lib/modules/mixin/zod/zod-query-schema/include.js +2 -1
- package/src/lib/modules/mixin/zod/zod-query-schema/include.js.map +1 -1
- package/src/lib/types/module-options.types.d.ts +1 -0
- package/src/lib/utils/module-helper.js +1 -0
- package/src/lib/utils/module-helper.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
## 10.0.0-beta.12 (2026-01-23)
|
|
2
|
+
|
|
3
|
+
### 🚀 Features
|
|
4
|
+
|
|
5
|
+
- **json-api-nestjs:** enhance ZodIncludeQuery with improved type definitions and utility functions ([c4a5856](https://github.com/klerick/nestjs-json-api/commit/c4a5856))
|
|
6
|
+
- **json-api-nestjs:** add JsonApiResponseFrom decorator for reusing response schemas across methods ([f1f49c1](https://github.com/klerick/nestjs-json-api/commit/f1f49c1))
|
|
7
|
+
- **json-api-nestjs:** replace `errorSchema` with `JsonApiErrorResponseModel`, update response schema handling across Swagger methods ([4e7f481](https://github.com/klerick/nestjs-json-api/commit/4e7f481))
|
|
8
|
+
|
|
9
|
+
### 🧱 Updated Dependencies
|
|
10
|
+
|
|
11
|
+
- Updated json-api-nestjs-shared to 1.0.0-beta.5
|
|
12
|
+
|
|
13
|
+
### ❤️ Thank You
|
|
14
|
+
|
|
15
|
+
- Alex H
|
|
16
|
+
|
|
17
|
+
## 10.0.0-beta.11 (2026-01-22)
|
|
18
|
+
|
|
19
|
+
### 🚀 Features
|
|
20
|
+
|
|
21
|
+
- **json-api-nestjs:** add support for excluding controllers during module initialization ([5e2de06](https://github.com/klerick/nestjs-json-api/commit/5e2de06))
|
|
22
|
+
|
|
23
|
+
### ❤️ Thank You
|
|
24
|
+
|
|
25
|
+
- Alex H
|
|
26
|
+
|
|
1
27
|
## 10.0.0-beta.10 (2026-01-21)
|
|
2
28
|
|
|
3
29
|
### 🚀 Features
|
package/README.md
CHANGED
|
@@ -79,8 +79,9 @@ The following interface is using for the configuration:
|
|
|
79
79
|
```typescript
|
|
80
80
|
export interface ModuleOptions {
|
|
81
81
|
entities: Entity[]; // List of typeOrm Entity
|
|
82
|
+
excludeControllers?: Entity[]; // List of entities to exclude from automatic controller generation
|
|
82
83
|
controllers?: NestController[]; // List of controller, if you need extend default present
|
|
83
|
-
connectionName?: string; // Type orm connection name: "default" is default name
|
|
84
|
+
connectionName?: string; // Type orm connection name: "default" is default name
|
|
84
85
|
providers?: NestProvider[]; // List of addition provider for useing in custom controller
|
|
85
86
|
imports?: NestImport[]; // List of addition module for useing in custom controller
|
|
86
87
|
options?: {
|
|
@@ -88,11 +89,37 @@ export interface ModuleOptions {
|
|
|
88
89
|
debug?: boolean; // Debug info in result object, like error message
|
|
89
90
|
pipeForId?: Type<PipeTransform> // Nestjs pipe for validate id params, by default ParseIntPipe
|
|
90
91
|
operationUrl?: string // Url for atomic operation https://jsonapi.org/ext/atomic/
|
|
91
|
-
// You can add params for MicroOrm or TypeOrm adapter
|
|
92
|
+
// You can add params for MicroOrm or TypeOrm adapter
|
|
92
93
|
} ;
|
|
93
94
|
}
|
|
94
95
|
```
|
|
95
96
|
|
|
97
|
+
### Excluding Controllers
|
|
98
|
+
|
|
99
|
+
If you need to register entities for relationships but don't want automatic controller generation for some of them, use `excludeControllers`:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import {Module} from '@nestjs/common';
|
|
103
|
+
import {JsonApiModule} from '@klerick/json-api-nestjs';
|
|
104
|
+
import {TypeOrmJsonApiModule} from '@klerick/json-api-nestjs-typeorm';
|
|
105
|
+
import {Users, Roles, AuditLog} from 'database';
|
|
106
|
+
|
|
107
|
+
@Module({
|
|
108
|
+
imports: [
|
|
109
|
+
JsonApiModule.forRoot(TypeOrmJsonApiModule, {
|
|
110
|
+
entities: [Users, Roles, AuditLog],
|
|
111
|
+
excludeControllers: [AuditLog], // AuditLog entity will not have auto-generated controller
|
|
112
|
+
}),
|
|
113
|
+
],
|
|
114
|
+
})
|
|
115
|
+
export class AppModule {}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This is useful when:
|
|
119
|
+
- You want to manage certain entities only through relationships
|
|
120
|
+
- You need custom controller implementation without the auto-generated one
|
|
121
|
+
- Some entities should be internal and not exposed via REST API
|
|
122
|
+
|
|
96
123
|
You can extend the default controller:
|
|
97
124
|
|
|
98
125
|
```typescript
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klerick/json-api-nestjs",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.12",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "JsonApi Plugin for NestJs",
|
|
6
6
|
"keywords": [
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"tslib": ">2.3.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@klerick/json-api-nestjs-shared": "^1.0.0-beta.
|
|
24
|
+
"@klerick/json-api-nestjs-shared": "^1.0.0-beta.5",
|
|
25
|
+
"ts-toolbelt": "^9.6.0",
|
|
25
26
|
"zod": "^4.1.0",
|
|
26
27
|
"zod-validation-error": "^4.0.0"
|
|
27
28
|
},
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { JsonApiModule } from './lib/json-api.module';
|
|
2
2
|
export { JsonBaseController } from './lib/modules/mixin/controllers/json-base.controller';
|
|
3
|
-
export { JsonApi, InjectService, JsonApiReadOnly, JsonApiImmutable } from './lib/modules/mixin/decorators';
|
|
3
|
+
export { JsonApi, InjectService, JsonApiReadOnly, JsonApiImmutable, JsonApiResponseFrom } from './lib/modules/mixin/decorators';
|
|
4
4
|
export { entityForClass, excludeMethod, patchInputData, } from './lib/modules/mixin/helpers/utils';
|
|
5
5
|
export { PrepareParams, NestProvider, ValidateQueryError, UnionToTuple, EntityParam, TypeField, Params, JsonApiReadOnlyField, JsonApiImmutableField, } from './lib/types';
|
|
6
6
|
export { JsonApiTransformerService, ErrorFormatService, EntityParamMapService } from './lib/modules/mixin/service';
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.METHOD_NAME = exports.CURRENT_ENTITY = exports.DEFAULT_QUERY_PAGE = exports.DEFAULT_PAGE_SIZE = exports.ENTITY_PARAM_MAP = exports.ORM_SERVICE = exports.RUN_IN_TRANSACTION_FUNCTION = exports.CHECK_RELATION_NAME = exports.FIND_ONE_ROW_ENTITY = exports.DESC = exports.ASC = exports.CONTROLLER_OPTIONS_TOKEN = exports.MODULE_OPTIONS_TOKEN = exports.EntityParamMapService = exports.ErrorFormatService = exports.JsonApiTransformerService = exports.TypeField = exports.patchInputData = exports.excludeMethod = exports.entityForClass = exports.JsonApiImmutable = exports.JsonApiReadOnly = exports.InjectService = exports.JsonApi = exports.JsonBaseController = exports.JsonApiModule = void 0;
|
|
3
|
+
exports.METHOD_NAME = exports.CURRENT_ENTITY = exports.DEFAULT_QUERY_PAGE = exports.DEFAULT_PAGE_SIZE = exports.ENTITY_PARAM_MAP = exports.ORM_SERVICE = exports.RUN_IN_TRANSACTION_FUNCTION = exports.CHECK_RELATION_NAME = exports.FIND_ONE_ROW_ENTITY = exports.DESC = exports.ASC = exports.CONTROLLER_OPTIONS_TOKEN = exports.MODULE_OPTIONS_TOKEN = exports.EntityParamMapService = exports.ErrorFormatService = exports.JsonApiTransformerService = exports.TypeField = exports.patchInputData = exports.excludeMethod = exports.entityForClass = exports.JsonApiResponseFrom = exports.JsonApiImmutable = exports.JsonApiReadOnly = exports.InjectService = exports.JsonApi = exports.JsonBaseController = exports.JsonApiModule = void 0;
|
|
4
4
|
var json_api_module_1 = require("./lib/json-api.module");
|
|
5
5
|
Object.defineProperty(exports, "JsonApiModule", { enumerable: true, get: function () { return json_api_module_1.JsonApiModule; } });
|
|
6
6
|
var json_base_controller_1 = require("./lib/modules/mixin/controllers/json-base.controller");
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "JsonApi", { enumerable: true, get: function () {
|
|
|
10
10
|
Object.defineProperty(exports, "InjectService", { enumerable: true, get: function () { return decorators_1.InjectService; } });
|
|
11
11
|
Object.defineProperty(exports, "JsonApiReadOnly", { enumerable: true, get: function () { return decorators_1.JsonApiReadOnly; } });
|
|
12
12
|
Object.defineProperty(exports, "JsonApiImmutable", { enumerable: true, get: function () { return decorators_1.JsonApiImmutable; } });
|
|
13
|
+
Object.defineProperty(exports, "JsonApiResponseFrom", { enumerable: true, get: function () { return decorators_1.JsonApiResponseFrom; } });
|
|
13
14
|
var utils_1 = require("./lib/modules/mixin/helpers/utils");
|
|
14
15
|
Object.defineProperty(exports, "entityForClass", { enumerable: true, get: function () { return utils_1.entityForClass; } });
|
|
15
16
|
Object.defineProperty(exports, "excludeMethod", { enumerable: true, get: function () { return utils_1.excludeMethod; } });
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/json-api/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AAEtB,6FAA0F;AAAjF,0HAAA,kBAAkB,OAAA;AAC3B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/json-api/json-api-nestjs/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAA7C,gHAAA,aAAa,OAAA;AAEtB,6FAA0F;AAAjF,0HAAA,kBAAkB,OAAA;AAC3B,6DAAgI;AAAvH,qGAAA,OAAO,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,8GAAA,gBAAgB,OAAA;AAAE,iHAAA,mBAAmB,OAAA;AACvF,2DAI2C;AAHzC,uGAAA,cAAc,OAAA;AACd,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AAEhB,qCAUqB;AAJnB,kGAAA,SAAS,OAAA;AAKX,uDAIqC;AAHnC,oHAAA,yBAAyB,OAAA;AACzB,6GAAA,kBAAkB,OAAA;AAClB,gHAAA,qBAAqB,OAAA;AAEvB,6CAcyB;AAbvB,iHAAA,oBAAoB,OAAA;AACpB,qHAAA,wBAAwB,OAAA;AACxB,gGAAA,GAAG,OAAA;AACH,iGAAA,IAAI,OAAA;AACJ,gHAAA,mBAAmB,OAAA;AACnB,gHAAA,mBAAmB,OAAA;AACnB,wHAAA,2BAA2B,OAAA;AAC3B,wGAAA,WAAW,OAAA;AACX,6GAAA,gBAAgB,OAAA;AAChB,8GAAA,iBAAiB,OAAA;AACjB,+GAAA,kBAAkB,OAAA;AAClB,2GAAA,cAAc,OAAA;AACd,wGAAA,WAAW,OAAA"}
|
|
@@ -17,7 +17,8 @@ let JsonApiModule = JsonApiModule_1 = class JsonApiModule {
|
|
|
17
17
|
if (!commonOrmModule.providers ||
|
|
18
18
|
!commonOrmModule.providers.find((i) => 'provide' in i && i.provide === constants_1.ENTITY_PARAM_MAP))
|
|
19
19
|
throw new Error(`The module ${module.name} should be provide ${constants_1.ENTITY_PARAM_MAP.description}`);
|
|
20
|
-
const
|
|
20
|
+
const entitiesForControllers = prepareOptions.entities.filter((entity) => !prepareOptions.excludeControllers.includes(entity));
|
|
21
|
+
const entitiesModules = entitiesForControllers.map((entityItem) => modules_1.MixinModule.forRoot({
|
|
21
22
|
entity: entityItem,
|
|
22
23
|
imports: [commonOrmModule, ...prepareOptions.imports],
|
|
23
24
|
ormModule: module,
|
|
@@ -25,7 +26,7 @@ let JsonApiModule = JsonApiModule_1 = class JsonApiModule {
|
|
|
25
26
|
config: prepareOptions,
|
|
26
27
|
}));
|
|
27
28
|
const atomicOperation = prepareOptions.options.operationUrl
|
|
28
|
-
? modules_1.AtomicOperationModule.forRoot(prepareOptions.options.operationUrl,
|
|
29
|
+
? modules_1.AtomicOperationModule.forRoot(prepareOptions.options.operationUrl, entitiesModules, commonOrmModule)
|
|
29
30
|
: [];
|
|
30
31
|
return {
|
|
31
32
|
module: JsonApiModule_1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-api.module.js","sourceRoot":"","sources":["../../../../../../libs/json-api/json-api-nestjs/src/lib/json-api.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AAEvD,mCAAuD;AACvD,2CAA+C;AAC/C,uCAA+D;AAC/D,+DAGsC;AACtC,qDAA6D;AAGtD,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACjB,MAAM,CAAC,OAAO,CACnB,MAAS,EACT,OAAwB;QAExB,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QAC9C,cAAc,CAAC,SAAS,CAAC,IAAI,CAC3B,gCAAiB,EACjB,4BAAkB,EAClB,kCAAmB,CACpB,CAAC;QACF,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEvD,IACE,CAAC,eAAe,CAAC,SAAS;YAC1B,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,4BAAgB,CACxD;YAED,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,CAAC,IAAI,sBAAsB,4BAAgB,CAAC,WAAW,EAAE,CAC9E,CAAC;QAEJ,MAAM,
|
|
1
|
+
{"version":3,"file":"json-api.module.js","sourceRoot":"","sources":["../../../../../../libs/json-api/json-api-nestjs/src/lib/json-api.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AAEvD,mCAAuD;AACvD,2CAA+C;AAC/C,uCAA+D;AAC/D,+DAGsC;AACtC,qDAA6D;AAGtD,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACjB,MAAM,CAAC,OAAO,CACnB,MAAS,EACT,OAAwB;QAExB,MAAM,cAAc,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QAC9C,cAAc,CAAC,SAAS,CAAC,IAAI,CAC3B,gCAAiB,EACjB,4BAAkB,EAClB,kCAAmB,CACpB,CAAC;QACF,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEvD,IACE,CAAC,eAAe,CAAC,SAAS;YAC1B,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,4BAAgB,CACxD;YAED,MAAM,IAAI,KAAK,CACb,cAAc,MAAM,CAAC,IAAI,sBAAsB,4BAAgB,CAAC,WAAW,EAAE,CAC9E,CAAC;QAEJ,MAAM,sBAAsB,GAAG,cAAc,CAAC,QAAQ,CAAC,MAAM,CAC3D,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAChE,CAAC;QAEF,MAAM,eAAe,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAChE,qBAAW,CAAC,OAAO,CAAC;YAClB,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,CAAC,eAAe,EAAE,GAAG,cAAc,CAAC,OAAO,CAAC;YACrD,SAAS,EAAE,MAAM;YACjB,UAAU,EAAE,IAAA,qBAAa,EAAC,UAAU,EAAE,cAAc,CAAC,WAAW,CAAC;YACjE,MAAM,EAAE,cAAc;SACvB,CAAC,CACH,CAAC;QAEF,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY;YACzD,CAAC,CAAC,+BAAqB,CAAC,OAAO,CAC3B,cAAc,CAAC,OAAO,CAAC,YAAY,EACnC,eAAe,EACf,eAAe,CAChB;YACH,CAAC,CAAC,EAAE,CAAC;QAEP,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,OAAO,EAAE,CAAC,GAAG,eAAe,EAAE,GAAG,eAAe,CAAC;SAClD,CAAC;IACJ,CAAC;CACF,CAAA;AAlDY,sCAAa;wBAAb,aAAa;IADzB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,aAAa,CAkDzB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, MiddlewareConsumer, NestModule } from '@nestjs/common';
|
|
2
|
-
import { AnyEntity, EntityClass } from '@klerick/json-api-nestjs-shared';
|
|
3
2
|
export declare class AtomicOperationModule implements NestModule {
|
|
4
|
-
static forRoot(operationUrl: string,
|
|
3
|
+
static forRoot(operationUrl: string, entityModules: DynamicModule[], commonModule: DynamicModule): DynamicModule[];
|
|
5
4
|
private static factoryModule;
|
|
6
5
|
private readonly als;
|
|
7
6
|
configure(consumer: MiddlewareConsumer): void;
|
|
@@ -12,9 +12,9 @@ const factory_1 = require("./factory");
|
|
|
12
12
|
const constants_1 = require("./constants");
|
|
13
13
|
const service_2 = require("../../modules/mixin/service");
|
|
14
14
|
let AtomicOperationModule = AtomicOperationModule_1 = class AtomicOperationModule {
|
|
15
|
-
static forRoot(operationUrl,
|
|
15
|
+
static forRoot(operationUrl, entityModules, commonModule) {
|
|
16
16
|
return [
|
|
17
|
-
AtomicOperationModule_1.factoryModule(
|
|
17
|
+
AtomicOperationModule_1.factoryModule(entityModules, commonModule),
|
|
18
18
|
core_1.RouterModule.register([
|
|
19
19
|
{
|
|
20
20
|
module: AtomicOperationModule_1,
|
|
@@ -23,11 +23,12 @@ let AtomicOperationModule = AtomicOperationModule_1 = class AtomicOperationModul
|
|
|
23
23
|
]),
|
|
24
24
|
];
|
|
25
25
|
}
|
|
26
|
-
static factoryModule(
|
|
26
|
+
static factoryModule(entityModules, commonModule) {
|
|
27
27
|
const errorFormat = (commonModule.providers || []).find(i => 'provide' in i && i.provide === service_2.ErrorFormatService);
|
|
28
28
|
if (!errorFormat) {
|
|
29
29
|
throw new Error('ErrorFormatService not found, should be provide in common orm module');
|
|
30
30
|
}
|
|
31
|
+
const mapControllerEntityProvider = (0, factory_1.MapControllerEntity)(entityModules);
|
|
31
32
|
return {
|
|
32
33
|
module: AtomicOperationModule_1,
|
|
33
34
|
controllers: [controllers_1.OperationController],
|
|
@@ -37,8 +38,8 @@ let AtomicOperationModule = AtomicOperationModule_1 = class AtomicOperationModul
|
|
|
37
38
|
service_1.ExecuteService,
|
|
38
39
|
service_1.SwaggerService,
|
|
39
40
|
factory_1.AsyncIterate,
|
|
40
|
-
|
|
41
|
-
(0, factory_1.MapEntityNameToEntity)(
|
|
41
|
+
mapControllerEntityProvider,
|
|
42
|
+
(0, factory_1.MapEntityNameToEntity)([...mapControllerEntityProvider.useValue.keys()]),
|
|
42
43
|
(0, factory_1.ZodInputOperation)(),
|
|
43
44
|
{
|
|
44
45
|
provide: constants_1.MAP_CONTROLLER_INTERCEPTORS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"atomic-operation.module.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/atomic-operation/atomic-operation.module.ts"],"names":[],"mappings":";;;;;AAAA,6CAAgD;AAChD,2CAMwB;AACxB,uCAA6D;
|
|
1
|
+
{"version":3,"file":"atomic-operation.module.js","sourceRoot":"","sources":["../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/atomic-operation/atomic-operation.module.ts"],"names":[],"mappings":";;;;;AAAA,6CAAgD;AAChD,2CAMwB;AACxB,uCAA6D;AAE7D,+CAAoD;AACpD,uCAA4E;AAE5E,uCAKmB;AACnB,2CAA0D;AAC1D,yDAAiE;AAG1D,IAAM,qBAAqB,6BAA3B,MAAM,qBAAqB;IAChC,MAAM,CAAC,OAAO,CACZ,YAAoB,EACpB,aAA8B,EAC9B,YAA2B;QAE3B,OAAO;YACL,uBAAqB,CAAC,aAAa,CACjC,aAAa,EACb,YAAY,CACb;YACD,mBAAY,CAAC,QAAQ,CAAC;gBACpB;oBACE,MAAM,EAAE,uBAAqB;oBAC7B,IAAI,EAAE,YAAY;iBACnB;aACF,CAAC;SACH,CAAC;IACJ,CAAC;IAEO,MAAM,CAAC,aAAa,CAC1B,aAA8B,EAC9B,YAA2B;QAG3B,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,KAAK,4BAAkB,CAAE,CAAA;QACjH,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAA;QACzF,CAAC;QACD,MAAM,2BAA2B,GAAG,IAAA,6BAAmB,EAAC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ick/json-api-nestjs-shared';
|
|
3
2
|
import { MapController } from '../types';
|
|
4
|
-
export declare function MapControllerEntity(
|
|
3
|
+
export declare function MapControllerEntity(entityModules: DynamicModule[]): ValueProvider<MapController>;
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MapControllerEntity = MapControllerEntity;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const helpers_1 = require("../../mixin/helpers");
|
|
6
|
+
function MapControllerEntity(entityModules) {
|
|
7
|
+
const mapController = entityModules
|
|
8
|
+
.reduce((acum, entityModule) => {
|
|
9
|
+
const controller = entityModule.controllers?.at(0);
|
|
10
|
+
if (controller) {
|
|
11
|
+
const entity = (0, helpers_1.entityForClass)(controller);
|
|
12
|
+
acum.set(entity, controller);
|
|
12
13
|
}
|
|
13
14
|
return acum;
|
|
14
15
|
}, new Map());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-controller-entity.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/atomic-operation/factory/map-controller-entity.ts"],"names":[],"mappings":";;AAMA,kDAkBC;
|
|
1
|
+
{"version":3,"file":"map-controller-entity.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/atomic-operation/factory/map-controller-entity.ts"],"names":[],"mappings":";;AAMA,kDAkBC;AArBD,4CAAqD;AACrD,iDAAqD;AAErD,SAAgB,mBAAmB,CACjC,aAA8B;IAG9B,MAAM,aAAa,GAAG,aAAa;SAChC,MAAM,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,EAAE;QAC/B,MAAM,UAAU,GAAG,YAAY,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,MAAM,GAAG,IAAA,wBAAc,EAAC,UAAU,CAAC,CAAC;YAC1C,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,IAAI,GAAG,EAAqC,CAAC,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,iCAAqB;QAC9B,QAAQ,EAAE,aAAa;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -4,4 +4,5 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
tslib_1.__exportStar(require("./json-api/json-api.decorator"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./inject-service/inject-service.decorator"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./json-api-read-only/json-api-read-only.decorator"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./json-api-response-from/json-api-response-from.decorator"), exports);
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/decorators/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,oFAA0D;AAC1D,4FAAkE"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/decorators/index.ts"],"names":[],"mappings":";;;AAAA,wEAA8C;AAC9C,oFAA0D;AAC1D,4FAAkE;AAClE,oGAA0E"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MethodName } from '../../types';
|
|
2
|
+
export declare const JSON_API_RESPONSE_FROM = "JSON_API_RESPONSE_FROM";
|
|
3
|
+
export interface StatusMapping {
|
|
4
|
+
fromStatus: number;
|
|
5
|
+
toStatus: number;
|
|
6
|
+
}
|
|
7
|
+
export type SourceMethodStatuses = {
|
|
8
|
+
[K in MethodName]?: StatusMapping[];
|
|
9
|
+
};
|
|
10
|
+
export type JsonApiResponseFromMeta = {
|
|
11
|
+
[targetMethod: string]: SourceMethodStatuses;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Decorator to copy response schema from another JSON API method
|
|
15
|
+
* @param sourceMethod - name of the source method (e.g., 'getOne', 'getAll')
|
|
16
|
+
* @param fromStatus - HTTP status code to copy from source method
|
|
17
|
+
* @param toStatus - HTTP status code to apply to target method (defaults to fromStatus)
|
|
18
|
+
*/
|
|
19
|
+
export declare function JsonApiResponseFrom(sourceMethod: MethodName, fromStatus: number, toStatus?: number): MethodDecorator;
|
package/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSON_API_RESPONSE_FROM = void 0;
|
|
4
|
+
exports.JsonApiResponseFrom = JsonApiResponseFrom;
|
|
5
|
+
exports.JSON_API_RESPONSE_FROM = 'JSON_API_RESPONSE_FROM';
|
|
6
|
+
/**
|
|
7
|
+
* Decorator to copy response schema from another JSON API method
|
|
8
|
+
* @param sourceMethod - name of the source method (e.g., 'getOne', 'getAll')
|
|
9
|
+
* @param fromStatus - HTTP status code to copy from source method
|
|
10
|
+
* @param toStatus - HTTP status code to apply to target method (defaults to fromStatus)
|
|
11
|
+
*/
|
|
12
|
+
function JsonApiResponseFrom(sourceMethod, fromStatus, toStatus) {
|
|
13
|
+
return (target, propertyKey, descriptor) => {
|
|
14
|
+
const targetMethod = String(propertyKey);
|
|
15
|
+
const existingMeta = Reflect.getMetadata(exports.JSON_API_RESPONSE_FROM, target.constructor) || {};
|
|
16
|
+
if (!existingMeta[targetMethod]) {
|
|
17
|
+
existingMeta[targetMethod] = {};
|
|
18
|
+
}
|
|
19
|
+
if (!existingMeta[targetMethod][sourceMethod]) {
|
|
20
|
+
existingMeta[targetMethod][sourceMethod] = [];
|
|
21
|
+
}
|
|
22
|
+
const currentSourceArray = existingMeta[targetMethod][sourceMethod];
|
|
23
|
+
const mapping = {
|
|
24
|
+
fromStatus,
|
|
25
|
+
toStatus: toStatus ?? fromStatus,
|
|
26
|
+
};
|
|
27
|
+
const exists = currentSourceArray.some((m) => m.fromStatus === mapping.fromStatus && m.toStatus === mapping.toStatus);
|
|
28
|
+
if (!exists) {
|
|
29
|
+
currentSourceArray.push(mapping);
|
|
30
|
+
}
|
|
31
|
+
Reflect.defineMetadata(exports.JSON_API_RESPONSE_FROM, existingMeta, target.constructor);
|
|
32
|
+
return descriptor;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=json-api-response-from.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-api-response-from.decorator.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/decorators/json-api-response-from/json-api-response-from.decorator.ts"],"names":[],"mappings":";;;AAmBA,kDAyCC;AA1DY,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAW/D;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,YAAwB,EACxB,UAAkB,EAClB,QAAiB;IAEjB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;QACzC,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QACzC,MAAM,YAAY,GAChB,OAAO,CAAC,WAAW,CAAC,8BAAsB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QAExE,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,YAAY,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QAClC,CAAC;QAED,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9C,YAAY,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC;QAChD,CAAC;QACD,MAAM,kBAAkB,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC,YAAY,CAAC,CAAC;QAEpE,MAAM,OAAO,GAAkB;YAC7B,UAAU;YACV,QAAQ,EAAE,QAAQ,IAAI,UAAU;SACjC,CAAC;QAEF,MAAM,MAAM,GAAG,kBAAkB,CAAC,IAAI,CACpC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,UAAU,KAAK,OAAO,CAAC,UAAU,IAAI,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,CACzE,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,CAAC,cAAc,CACpB,8BAAsB,EACtB,YAAY,EACZ,MAAM,CAAC,WAAW,CACnB,CAAC;QAEF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export declare const errorSchema: {
|
|
2
|
+
type: string;
|
|
3
|
+
properties: {
|
|
4
|
+
statusCode: {
|
|
5
|
+
type: string;
|
|
6
|
+
};
|
|
7
|
+
error: {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
message: {
|
|
11
|
+
type: string;
|
|
12
|
+
items: {
|
|
13
|
+
type: string;
|
|
14
|
+
properties: {
|
|
15
|
+
code: {
|
|
16
|
+
type: string;
|
|
17
|
+
};
|
|
18
|
+
message: {
|
|
19
|
+
type: string;
|
|
20
|
+
};
|
|
21
|
+
path: {
|
|
22
|
+
type: string;
|
|
23
|
+
items: {
|
|
24
|
+
type: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
keys: {
|
|
28
|
+
type: string;
|
|
29
|
+
items: {
|
|
30
|
+
type: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare class JsonApiErrorMessageItem {
|
|
40
|
+
code: string;
|
|
41
|
+
message: string;
|
|
42
|
+
path: string[];
|
|
43
|
+
keys?: string[];
|
|
44
|
+
}
|
|
45
|
+
export declare class JsonApiErrorResponseModel {
|
|
46
|
+
statusCode: number;
|
|
47
|
+
error: string;
|
|
48
|
+
message: JsonApiErrorMessageItem[];
|
|
49
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonApiErrorResponseModel = exports.JsonApiErrorMessageItem = exports.errorSchema = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
exports.errorSchema = {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
statusCode: {
|
|
10
|
+
type: 'number',
|
|
11
|
+
},
|
|
12
|
+
error: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
},
|
|
15
|
+
message: {
|
|
16
|
+
type: 'array',
|
|
17
|
+
items: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
code: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
},
|
|
23
|
+
message: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
},
|
|
26
|
+
path: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
items: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
keys: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
required: ['code', 'message', 'path'],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
const ErrorMessageItemSchema = {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
code: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
},
|
|
50
|
+
message: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
},
|
|
53
|
+
path: {
|
|
54
|
+
type: 'array',
|
|
55
|
+
items: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
keys: {
|
|
60
|
+
type: 'array',
|
|
61
|
+
items: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
required: ['code', 'message', 'path'],
|
|
67
|
+
};
|
|
68
|
+
class JsonApiErrorMessageItem {
|
|
69
|
+
code;
|
|
70
|
+
message;
|
|
71
|
+
path;
|
|
72
|
+
keys;
|
|
73
|
+
}
|
|
74
|
+
exports.JsonApiErrorMessageItem = JsonApiErrorMessageItem;
|
|
75
|
+
tslib_1.__decorate([
|
|
76
|
+
(0, swagger_1.ApiProperty)({ type: 'string', title: 'Error code' }),
|
|
77
|
+
tslib_1.__metadata("design:type", String)
|
|
78
|
+
], JsonApiErrorMessageItem.prototype, "code", void 0);
|
|
79
|
+
tslib_1.__decorate([
|
|
80
|
+
(0, swagger_1.ApiProperty)({ type: 'string', title: 'Error message' }),
|
|
81
|
+
tslib_1.__metadata("design:type", String)
|
|
82
|
+
], JsonApiErrorMessageItem.prototype, "message", void 0);
|
|
83
|
+
tslib_1.__decorate([
|
|
84
|
+
(0, swagger_1.ApiProperty)({
|
|
85
|
+
type: 'array',
|
|
86
|
+
items: { type: 'string' },
|
|
87
|
+
title: 'Path to the error field',
|
|
88
|
+
}),
|
|
89
|
+
tslib_1.__metadata("design:type", Array)
|
|
90
|
+
], JsonApiErrorMessageItem.prototype, "path", void 0);
|
|
91
|
+
tslib_1.__decorate([
|
|
92
|
+
(0, swagger_1.ApiProperty)({
|
|
93
|
+
type: 'array',
|
|
94
|
+
items: { type: 'string' },
|
|
95
|
+
required: false,
|
|
96
|
+
title: 'Additional keys',
|
|
97
|
+
}),
|
|
98
|
+
tslib_1.__metadata("design:type", Array)
|
|
99
|
+
], JsonApiErrorMessageItem.prototype, "keys", void 0);
|
|
100
|
+
let JsonApiErrorResponseModel = class JsonApiErrorResponseModel {
|
|
101
|
+
statusCode;
|
|
102
|
+
error;
|
|
103
|
+
message;
|
|
104
|
+
};
|
|
105
|
+
exports.JsonApiErrorResponseModel = JsonApiErrorResponseModel;
|
|
106
|
+
tslib_1.__decorate([
|
|
107
|
+
(0, swagger_1.ApiProperty)({ type: 'number', title: 'HTTP status code' }),
|
|
108
|
+
tslib_1.__metadata("design:type", Number)
|
|
109
|
+
], JsonApiErrorResponseModel.prototype, "statusCode", void 0);
|
|
110
|
+
tslib_1.__decorate([
|
|
111
|
+
(0, swagger_1.ApiProperty)({ type: 'string', title: 'Error type' }),
|
|
112
|
+
tslib_1.__metadata("design:type", String)
|
|
113
|
+
], JsonApiErrorResponseModel.prototype, "error", void 0);
|
|
114
|
+
tslib_1.__decorate([
|
|
115
|
+
(0, swagger_1.ApiProperty)({
|
|
116
|
+
type: 'array',
|
|
117
|
+
items: { $ref: (0, swagger_1.getSchemaPath)(JsonApiErrorMessageItem) },
|
|
118
|
+
title: 'Error details',
|
|
119
|
+
}),
|
|
120
|
+
tslib_1.__metadata("design:type", Array)
|
|
121
|
+
], JsonApiErrorResponseModel.prototype, "message", void 0);
|
|
122
|
+
exports.JsonApiErrorResponseModel = JsonApiErrorResponseModel = tslib_1.__decorate([
|
|
123
|
+
(0, swagger_1.ApiExtraModels)(JsonApiErrorMessageItem)
|
|
124
|
+
], JsonApiErrorResponseModel);
|
|
125
|
+
//# sourceMappingURL=error-response-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-response-model.js","sourceRoot":"","sources":["../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/error-response-model.ts"],"names":[],"mappings":";;;;AAAA,6CAA6E;AAIhE,QAAA,WAAW,GA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AAK,EAAE,YAAY,EAAE,CAAC;;qDACvC;AAGd;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC;;wDACvC;AAOjB;IALC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,KAAK,EAAE,yBAAyB;KACjC,CAAC;;qDACc;AAQhB;IANC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,iBAAiB;KACzB,CAAC;;qDACc;AAIX,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IAEpC,UAAU,CAAU;IAGpB,KAAK,CAAU;IAOf,OAAO,CAA6B;CACrC,CAAA;AAbY,8DAAyB;AAEpC;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;;6DACvC;AAGpB;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;;wDACtC;AAOf;IALC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,uBAAuB,CAAC,EAAE;QACvD,KAAK,EAAE,eAAe;KACvB,CAAC;;0DACkC;oCAZzB,yBAAyB;IADrC,IAAA,wBAAc,EAAC,uBAAuB,CAAC;GAC3B,yBAAyB,CAarC"}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deleteOne = deleteOne;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
5
|
const types_1 = require("../../../../types");
|
|
6
|
-
const
|
|
6
|
+
const error_response_model_1 = require("../error-response-model");
|
|
7
7
|
function deleteOne(controller, descriptor, entity, mapEntity, methodName) {
|
|
8
8
|
const entityName = entity.name;
|
|
9
9
|
const { primaryColumnType } = mapEntity.getParamMap(entity);
|
|
@@ -20,7 +20,7 @@ function deleteOne(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
20
20
|
(0, swagger_1.ApiResponse)({
|
|
21
21
|
status: 404,
|
|
22
22
|
description: `Item of resource "${entityName}" not found`,
|
|
23
|
-
schema:
|
|
23
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
24
24
|
})(controller, methodName, descriptor);
|
|
25
25
|
(0, swagger_1.ApiResponse)({
|
|
26
26
|
status: 204,
|
|
@@ -29,7 +29,7 @@ function deleteOne(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
29
29
|
(0, swagger_1.ApiResponse)({
|
|
30
30
|
status: 400,
|
|
31
31
|
description: 'Wrong query parameters',
|
|
32
|
-
schema:
|
|
32
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
33
33
|
})(controller, methodName, descriptor);
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=delete-one.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-one.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/delete-one.ts"],"names":[],"mappings":";;AAQA,8BAuCC;AA9CD,
|
|
1
|
+
{"version":3,"file":"delete-one.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/delete-one.ts"],"names":[],"mappings":";;AAQA,8BAuCC;AA9CD,6CAAqF;AAGrF,6CAA8C;AAE9C,kEAAoE;AAEpE,SAAgB,SAAS,CACvB,UAAqB,EACrB,UAA8B,EAC9B,MAAsB,EACtB,SAA0C,EAC1C,UAAkB;IAElB,MAAM,UAA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");
|
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
6
|
const types_1 = require("../../../../types");
|
|
7
7
|
const zod_2 = require("../../zod");
|
|
8
|
-
const
|
|
8
|
+
const error_response_model_1 = require("../error-response-model");
|
|
9
9
|
function deleteRelationship(controller, descriptor, entity, mapEntity, methodName) {
|
|
10
10
|
const entityName = entity.name;
|
|
11
11
|
const { relations, primaryColumnType } = mapEntity.getParamMap(entity);
|
|
@@ -34,17 +34,17 @@ function deleteRelationship(controller, descriptor, entity, mapEntity, methodNam
|
|
|
34
34
|
(0, swagger_1.ApiResponse)({
|
|
35
35
|
status: 400,
|
|
36
36
|
description: 'Wrong url parameters',
|
|
37
|
-
schema:
|
|
37
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
38
38
|
})(controller, methodName, descriptor);
|
|
39
39
|
(0, swagger_1.ApiResponse)({
|
|
40
40
|
status: 422,
|
|
41
41
|
description: 'Incorrect type for relation',
|
|
42
|
-
schema:
|
|
42
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
43
43
|
})(controller, methodName, descriptor);
|
|
44
44
|
(0, swagger_1.ApiResponse)({
|
|
45
45
|
status: 404,
|
|
46
46
|
description: 'Resource not found ',
|
|
47
|
-
schema:
|
|
47
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
48
48
|
})(controller, methodName, descriptor);
|
|
49
49
|
(0, swagger_1.ApiResponse)({
|
|
50
50
|
status: 204,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delete-relationship.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/mixin/swagger/method/delete-relationship.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"delete-relationship.js","sourceRoot":"","sources":["../../../../../../../../../../libs/json-api/json-api-nestjs/src/lib/modules/m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AE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,sBAAsB;QACnC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,gDAAyB,CAAC,EAAE;KAC3D,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,6BAA6B;QAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,gDAAyB,CAAC,EAAE;KAC3D,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,qBAAqB;QAClC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAA,uBAAa,EAAC,gDAAyB,CAAC,EAAE;KAC3D,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;IAEvC,IAAA,qBAAW,EAAC;QACV,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,2BAA2B,UAAU,oBAAoB;KACvE,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -5,6 +5,7 @@ const swagger_1 = require("@nestjs/swagger");
|
|
|
5
5
|
const json_api_nestjs_shared_1 = require("@klerick/json-api-nestjs-shared");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
7
|
const constants_1 = require("../../../../constants");
|
|
8
|
+
const error_response_model_1 = require("../error-response-model");
|
|
8
9
|
function getAll(controller, descriptor, entity, mapEntity, methodName) {
|
|
9
10
|
const { props, relations, relationProperty, primaryColumnName } = mapEntity.getParamMap(entity);
|
|
10
11
|
(0, utils_1.assertIsKeysOfObject)(entity, props);
|
|
@@ -230,7 +231,7 @@ function getAll(controller, descriptor, entity, mapEntity, methodName) {
|
|
|
230
231
|
(0, swagger_1.ApiResponse)({
|
|
231
232
|
status: 400,
|
|
232
233
|
description: 'Wrong query parameters',
|
|
233
|
-
schema:
|
|
234
|
+
schema: { $ref: (0, swagger_1.getSchemaPath)(error_response_model_1.JsonApiErrorResponseModel) },
|
|
234
235
|
})(controller, methodName, descriptor);
|
|
235
236
|
(0, swagger_1.ApiResponse)({
|
|
236
237
|
status: 200,
|