mongodb-dynamic-api 2.1.2 → 2.1.4

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/package.json +1 -1
  3. package/src/dtos/delete.presenter.d.ts +3 -0
  4. package/src/{routes/delete-one/delete-one.presenter.js → dtos/delete.presenter.js} +4 -4
  5. package/src/dtos/index.d.ts +1 -0
  6. package/src/dtos/index.js +1 -0
  7. package/src/helpers/controller-mixin.helper.d.ts +66 -0
  8. package/src/helpers/controller-mixin.helper.js +159 -0
  9. package/src/routes/create-many/create-many-controller.mixin.d.ts +1 -1
  10. package/src/routes/create-many/create-many-controller.mixin.js +6 -50
  11. package/src/routes/create-one/create-one-controller.mixin.d.ts +1 -1
  12. package/src/routes/create-one/create-one-controller.mixin.js +6 -31
  13. package/src/routes/delete-many/base-delete-many.service.d.ts +2 -2
  14. package/src/routes/delete-many/base-delete-many.service.js +2 -2
  15. package/src/routes/delete-many/delete-many-controller.mixin.d.ts +1 -1
  16. package/src/routes/delete-many/delete-many-controller.mixin.js +4 -26
  17. package/src/routes/delete-many/index.d.ts +0 -1
  18. package/src/routes/delete-many/index.js +0 -1
  19. package/src/routes/delete-one/base-delete-one.service.d.ts +2 -2
  20. package/src/routes/delete-one/base-delete-one.service.js +2 -2
  21. package/src/routes/delete-one/delete-one-controller.mixin.d.ts +1 -1
  22. package/src/routes/delete-one/delete-one-controller.mixin.js +5 -31
  23. package/src/routes/delete-one/index.d.ts +0 -1
  24. package/src/routes/delete-one/index.js +0 -1
  25. package/src/routes/duplicate-many/duplicate-many-controller.mixin.d.ts +1 -1
  26. package/src/routes/duplicate-many/duplicate-many-controller.mixin.js +6 -31
  27. package/src/routes/duplicate-one/duplicate-one-controller.mixin.d.ts +1 -1
  28. package/src/routes/duplicate-one/duplicate-one-controller.mixin.js +5 -33
  29. package/src/routes/get-many/get-many-controller.mixin.d.ts +1 -1
  30. package/src/routes/get-many/get-many-controller.mixin.js +5 -31
  31. package/src/routes/get-one/get-one-controller.mixin.d.ts +1 -1
  32. package/src/routes/get-one/get-one-controller.mixin.js +4 -33
  33. package/src/routes/replace-one/replace-one-controller.mixin.d.ts +1 -1
  34. package/src/routes/replace-one/replace-one-controller.mixin.js +6 -35
  35. package/src/routes/update-many/update-many-controller.mixin.d.ts +1 -1
  36. package/src/routes/update-many/update-many-controller.mixin.js +5 -30
  37. package/src/routes/update-one/update-one-controller.mixin.d.ts +1 -1
  38. package/src/routes/update-one/update-one-controller.mixin.js +6 -37
  39. package/src/version.json +1 -1
  40. package/tsconfig.tsbuildinfo +1 -1
  41. package/src/routes/delete-one/delete-one.presenter.d.ts +0 -3
@@ -1,7 +1,6 @@
1
1
  export * from './base-delete-one.service';
2
2
  export * from './delete-one.helper';
3
3
  export * from './delete-one.module';
4
- export * from './delete-one.presenter';
5
4
  export * from './delete-one-controller.interface';
6
5
  export * from './delete-one-controller.mixin';
7
6
  export * from './delete-one-service.interface';
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./base-delete-one.service"), exports);
18
18
  __exportStar(require("./delete-one.helper"), exports);
19
19
  __exportStar(require("./delete-one.module"), exports);
20
- __exportStar(require("./delete-one.presenter"), exports);
21
20
  __exportStar(require("./delete-one-controller.interface"), exports);
22
21
  __exportStar(require("./delete-one-controller.mixin"), exports);
23
22
  __exportStar(require("./delete-one-service.interface"), exports);
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { DuplicateManyControllerConstructor } from './duplicate-many-controller.interface';
5
- declare function DuplicateManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): DuplicateManyControllerConstructor<Entity>;
5
+ declare function DuplicateManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): DuplicateManyControllerConstructor<Entity>;
6
6
  export { DuplicateManyControllerMixin };
@@ -17,40 +17,15 @@ const common_1 = require("@nestjs/common");
17
17
  const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
19
  const helpers_1 = require("../../helpers");
20
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
20
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
21
21
  const mixins_1 = require("../../mixins");
22
- function DuplicateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
23
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
24
- const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
25
- let isPublic;
26
- if (typeof isPublicRoute === 'boolean') {
27
- isPublic = isPublicRoute;
28
- }
29
- else if (typeof isPublicController === 'boolean') {
30
- isPublic = isPublicController;
31
- }
32
- else {
33
- isPublic = false;
34
- }
35
- class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
36
- }
37
- Object.defineProperty(RouteBody, 'name', {
38
- value: CustomBody ? CustomBody.name : `DuplicateMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
39
- writable: false,
40
- });
41
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
42
- }
43
- Object.defineProperty(RoutePresenter, 'name', {
44
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
45
- writable: false,
46
- });
47
- const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateMany', entity, version, description, isPublic, {
48
- param: undefined,
49
- query: undefined,
22
+ function DuplicateManyControllerMixin(entity, controllerOptions, routeConfig, version) {
23
+ var _a;
24
+ const { routeType, description, isPublic, RouteBody, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
25
+ const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
50
26
  body: RouteBody,
51
27
  presenter: RoutePresenter,
52
28
  });
53
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
54
29
  class DuplicateManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
55
30
  }
56
31
  class BaseDuplicateManyController {
@@ -69,7 +44,7 @@ function DuplicateManyControllerMixin(entity, { path, apiTag, isPublic: isPublic
69
44
  __param(0, (0, common_1.Query)('ids')),
70
45
  __param(1, (0, common_1.Body)()),
71
46
  __metadata("design:type", Function),
72
- __metadata("design:paramtypes", [Array, RouteBody]),
47
+ __metadata("design:paramtypes", [Array, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
73
48
  __metadata("design:returntype", Promise)
74
49
  ], BaseDuplicateManyController.prototype, "duplicateMany", null);
75
50
  Object.defineProperty(BaseDuplicateManyController, 'name', {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { DuplicateOneControllerConstructor } from './duplicate-one-controller.interface';
5
- declare function DuplicateOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): DuplicateOneControllerConstructor<Entity>;
5
+ declare function DuplicateOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): DuplicateOneControllerConstructor<Entity>;
6
6
  export { DuplicateOneControllerMixin };
@@ -18,44 +18,16 @@ const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
19
  const dtos_1 = require("../../dtos");
20
20
  const helpers_1 = require("../../helpers");
21
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
21
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
22
22
  const mixins_1 = require("../../mixins");
23
- function DuplicateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
24
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
25
- const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
26
- let isPublic;
27
- if (typeof isPublicRoute === 'boolean') {
28
- isPublic = isPublicRoute;
29
- }
30
- else if (typeof isPublicController === 'boolean') {
31
- isPublic = isPublicController;
32
- }
33
- else {
34
- isPublic = false;
35
- }
36
- Object.defineProperty(dtos_1.EntityParam, 'name', {
37
- value: `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
38
- writable: false,
39
- });
40
- class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
41
- }
42
- Object.defineProperty(RouteBody, 'name', {
43
- value: CustomBody ? CustomBody.name : `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
44
- writable: false,
45
- });
46
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
47
- }
48
- Object.defineProperty(RoutePresenter, 'name', {
49
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
50
- writable: false,
51
- });
23
+ function DuplicateOneControllerMixin(entity, controllerOptions, routeConfig, version) {
24
+ var _a;
25
+ const { routeType, description, isPublic, RouteBody, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
52
26
  const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateOne', entity, version, description, isPublic, {
53
27
  param: dtos_1.EntityParam,
54
- query: undefined,
55
28
  body: RouteBody,
56
29
  presenter: RoutePresenter,
57
30
  });
58
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
59
31
  class DuplicateOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
60
32
  }
61
33
  class BaseDuplicateOneController {
@@ -74,7 +46,7 @@ function DuplicateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicC
74
46
  __param(0, (0, common_1.Param)('id')),
75
47
  __param(1, (0, common_1.Body)()),
76
48
  __metadata("design:type", Function),
77
- __metadata("design:paramtypes", [String, RouteBody]),
49
+ __metadata("design:paramtypes", [String, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
78
50
  __metadata("design:returntype", Promise)
79
51
  ], BaseDuplicateOneController.prototype, "duplicateOne", null);
80
52
  Object.defineProperty(BaseDuplicateOneController, 'name', {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { GetManyControllerConstructor } from './get-many-controller.interface';
5
- declare function GetManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): GetManyControllerConstructor<Entity>;
5
+ declare function GetManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): GetManyControllerConstructor<Entity>;
6
6
  export { GetManyControllerMixin };
@@ -16,42 +16,16 @@ exports.GetManyControllerMixin = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
- const dtos_1 = require("../../dtos");
20
19
  const helpers_1 = require("../../helpers");
21
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
20
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
22
21
  const mixins_1 = require("../../mixins");
23
- function GetManyControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
24
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
25
- const { query: CustomQuery, presenter: CustomPresenter } = dTOs ?? {};
26
- let isPublic;
27
- if (typeof isPublicRoute === 'boolean') {
28
- isPublic = isPublicRoute;
29
- }
30
- else if (typeof isPublicController === 'boolean') {
31
- isPublic = isPublicController;
32
- }
33
- else {
34
- isPublic = false;
35
- }
36
- class RouteQuery extends (CustomQuery ?? dtos_1.EntityQuery) {
37
- }
38
- Object.defineProperty(RouteQuery, 'name', {
39
- value: CustomQuery ? CustomQuery.name : `${routeType}${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
40
- writable: false,
41
- });
42
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
43
- }
44
- Object.defineProperty(RoutePresenter, 'name', {
45
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
46
- writable: false,
47
- });
22
+ function GetManyControllerMixin(entity, controllerOptions, routeConfig, version) {
23
+ var _a;
24
+ const { routeType, description, isPublic, RouteQuery, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
48
25
  const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
49
- param: undefined,
50
26
  query: RouteQuery,
51
- body: undefined,
52
27
  presenter: RoutePresenter,
53
28
  });
54
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
55
29
  class GetManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
56
30
  }
57
31
  class BaseGetManyController {
@@ -69,7 +43,7 @@ function GetManyControllerMixin(entity, { path, apiTag, isPublic: isPublicContro
69
43
  (0, decorators_1.CheckPolicies)((ability) => ability.can(routeType, entity)),
70
44
  __param(0, (0, common_1.Query)()),
71
45
  __metadata("design:type", Function),
72
- __metadata("design:paramtypes", [RouteQuery]),
46
+ __metadata("design:paramtypes", [typeof (_a = typeof RouteQuery !== "undefined" && RouteQuery) === "function" ? _a : Object]),
73
47
  __metadata("design:returntype", Promise)
74
48
  ], BaseGetManyController.prototype, "getMany", null);
75
49
  Object.defineProperty(BaseGetManyController, 'name', {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { GetOneControllerConstructor } from './get-one-controller.interface';
5
- declare function GetOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): GetOneControllerConstructor<Entity>;
5
+ declare function GetOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): GetOneControllerConstructor<Entity>;
6
6
  export { GetOneControllerMixin };
@@ -18,44 +18,15 @@ const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
19
  const dtos_1 = require("../../dtos");
20
20
  const helpers_1 = require("../../helpers");
21
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
21
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
22
22
  const mixins_1 = require("../../mixins");
23
- function GetOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
24
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
25
- const { query: CustomQuery, presenter: CustomPresenter, } = dTOs ?? {};
26
- let isPublic;
27
- if (typeof isPublicRoute === 'boolean') {
28
- isPublic = isPublicRoute;
29
- }
30
- else if (typeof isPublicController === 'boolean') {
31
- isPublic = isPublicController;
32
- }
33
- else {
34
- isPublic = false;
35
- }
36
- Object.defineProperty(dtos_1.EntityParam, 'name', {
37
- value: `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
38
- writable: false,
39
- });
40
- class RouteQuery extends (CustomQuery ?? dtos_1.EntityQuery) {
41
- }
42
- Object.defineProperty(RouteQuery, 'name', {
43
- value: CustomQuery ? CustomQuery.name : `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
44
- writable: false,
45
- });
46
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
47
- }
48
- Object.defineProperty(RoutePresenter, 'name', {
49
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
50
- writable: false,
51
- });
52
- const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('GetOne', entity, version, description, isPublic, {
23
+ function GetOneControllerMixin(entity, controllerOptions, routeConfig, version) {
24
+ const { routeType, description, isPublic, RouteQuery, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
25
+ const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
53
26
  param: dtos_1.EntityParam,
54
27
  query: RouteQuery,
55
- body: undefined,
56
28
  presenter: RoutePresenter,
57
29
  });
58
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
59
30
  class GetOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
60
31
  }
61
32
  class BaseGetOneController {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { ReplaceOneControllerConstructor } from './replace-one-controller.interface';
5
- declare function ReplaceOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): ReplaceOneControllerConstructor<Entity>;
5
+ declare function ReplaceOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): ReplaceOneControllerConstructor<Entity>;
6
6
  export { ReplaceOneControllerMixin };
@@ -16,46 +16,17 @@ exports.ReplaceOneControllerMixin = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
- const dtos_1 = require("../../dtos");
20
19
  const helpers_1 = require("../../helpers");
21
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
20
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
22
21
  const mixins_1 = require("../../mixins");
23
- function ReplaceOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
24
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
25
- const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
26
- let isPublic;
27
- if (typeof isPublicRoute === 'boolean') {
28
- isPublic = isPublicRoute;
29
- }
30
- else if (typeof isPublicController === 'boolean') {
31
- isPublic = isPublicController;
32
- }
33
- else {
34
- isPublic = false;
35
- }
36
- Object.defineProperty(dtos_1.EntityParam, 'name', {
37
- value: `ReplaceOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
38
- writable: false,
39
- });
40
- class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity)) {
41
- }
42
- Object.defineProperty(RouteBody, 'name', {
43
- value: CustomBody ? CustomBody.name : `ReplaceOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
44
- writable: false,
45
- });
46
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
47
- }
48
- Object.defineProperty(RoutePresenter, 'name', {
49
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
50
- writable: false,
51
- });
22
+ function ReplaceOneControllerMixin(entity, controllerOptions, routeConfig, version) {
23
+ var _a;
24
+ const { routeType, description, isPublic, EntityParam, RouteBody, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
52
25
  const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('ReplaceOne', entity, version, description, isPublic, {
53
- param: dtos_1.EntityParam,
54
- query: undefined,
26
+ param: EntityParam,
55
27
  body: RouteBody,
56
28
  presenter: RoutePresenter,
57
29
  });
58
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
59
30
  class ReplaceOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
60
31
  }
61
32
  class BaseReplaceOneController {
@@ -74,7 +45,7 @@ function ReplaceOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
74
45
  __param(0, (0, common_1.Param)('id')),
75
46
  __param(1, (0, common_1.Body)()),
76
47
  __metadata("design:type", Function),
77
- __metadata("design:paramtypes", [String, RouteBody]),
48
+ __metadata("design:paramtypes", [String, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
78
49
  __metadata("design:returntype", Promise)
79
50
  ], BaseReplaceOneController.prototype, "replaceOne", null);
80
51
  Object.defineProperty(BaseReplaceOneController, 'name', {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { UpdateManyControllerConstructor } from './update-many-controller.interface';
5
- declare function UpdateManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): UpdateManyControllerConstructor<Entity>;
5
+ declare function UpdateManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): UpdateManyControllerConstructor<Entity>;
6
6
  export { UpdateManyControllerMixin };
@@ -17,40 +17,15 @@ const common_1 = require("@nestjs/common");
17
17
  const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
19
  const helpers_1 = require("../../helpers");
20
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
20
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
21
21
  const mixins_1 = require("../../mixins");
22
- function UpdateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
23
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
24
- const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
25
- let isPublic;
26
- if (typeof isPublicRoute === 'boolean') {
27
- isPublic = isPublicRoute;
28
- }
29
- else if (typeof isPublicController === 'boolean') {
30
- isPublic = isPublicController;
31
- }
32
- else {
33
- isPublic = false;
34
- }
35
- class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
36
- }
37
- Object.defineProperty(RouteBody, 'name', {
38
- value: CustomBody ? CustomBody.name : `UpdateMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
39
- writable: false,
40
- });
41
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
42
- }
43
- Object.defineProperty(RoutePresenter, 'name', {
44
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
45
- writable: false,
46
- });
22
+ function UpdateManyControllerMixin(entity, controllerOptions, routeConfig, version) {
23
+ var _a;
24
+ const { routeType, description, isPublic, RouteBody, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
47
25
  const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('UpdateMany', entity, version, description, isPublic, {
48
- param: undefined,
49
- query: undefined,
50
26
  body: RouteBody,
51
27
  presenter: RoutePresenter,
52
28
  });
53
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
54
29
  class UpdateManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
55
30
  }
56
31
  class BaseUpdateManyController {
@@ -69,7 +44,7 @@ function UpdateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
69
44
  __param(0, (0, common_1.Query)('ids')),
70
45
  __param(1, (0, common_1.Body)()),
71
46
  __metadata("design:type", Function),
72
- __metadata("design:paramtypes", [Array, RouteBody]),
47
+ __metadata("design:paramtypes", [Array, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
73
48
  __metadata("design:returntype", Promise)
74
49
  ], BaseUpdateManyController.prototype, "updateMany", null);
75
50
  Object.defineProperty(BaseUpdateManyController, 'name', {
@@ -2,5 +2,5 @@ import { Type } from '@nestjs/common';
2
2
  import { DynamicApiControllerOptions, DynamicAPIRouteConfig } from '../../interfaces';
3
3
  import { BaseEntity } from '../../models';
4
4
  import { UpdateOneControllerConstructor } from './update-one-controller.interface';
5
- declare function UpdateOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }: DynamicApiControllerOptions<Entity>, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }: DynamicAPIRouteConfig<Entity>, version?: string): UpdateOneControllerConstructor<Entity>;
5
+ declare function UpdateOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): UpdateOneControllerConstructor<Entity>;
6
6
  export { UpdateOneControllerMixin };
@@ -16,48 +16,17 @@ exports.UpdateOneControllerMixin = void 0;
16
16
  const common_1 = require("@nestjs/common");
17
17
  const builders_1 = require("../../builders");
18
18
  const decorators_1 = require("../../decorators");
19
- const dtos_1 = require("../../dtos");
20
19
  const helpers_1 = require("../../helpers");
21
- const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
20
+ const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
22
21
  const mixins_1 = require("../../mixins");
23
- function UpdateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
24
- const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
25
- const { body: CustomBody, param: CustomParam, presenter: CustomPresenter, } = dTOs ?? {};
26
- let isPublic;
27
- if (typeof isPublicRoute === 'boolean') {
28
- isPublic = isPublicRoute;
29
- }
30
- else if (typeof isPublicController === 'boolean') {
31
- isPublic = isPublicController;
32
- }
33
- else {
34
- isPublic = false;
35
- }
36
- class RouteParam extends (CustomParam ?? dtos_1.EntityParam) {
37
- }
38
- Object.defineProperty(RouteParam, 'name', {
39
- value: CustomParam ? CustomParam.name : `UpdateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
40
- writable: false,
41
- });
42
- class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
43
- }
44
- Object.defineProperty(RouteBody, 'name', {
45
- value: CustomBody ? CustomBody.name : `UpdateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
46
- writable: false,
47
- });
48
- class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
49
- }
50
- Object.defineProperty(RoutePresenter, 'name', {
51
- value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
52
- writable: false,
53
- });
22
+ function UpdateOneControllerMixin(entity, controllerOptions, routeConfig, version) {
23
+ var _a;
24
+ const { routeType, description, isPublic, EntityParam, RouteBody, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
54
25
  const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('UpdateOne', entity, version, description, isPublic, {
55
- param: RouteParam,
56
- query: undefined,
26
+ param: EntityParam,
57
27
  body: RouteBody,
58
28
  presenter: RoutePresenter,
59
29
  });
60
- const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
61
30
  class UpdateOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
62
31
  }
63
32
  class BaseUpdateOneController {
@@ -76,7 +45,7 @@ function UpdateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCont
76
45
  __param(0, (0, common_1.Param)('id')),
77
46
  __param(1, (0, common_1.Body)()),
78
47
  __metadata("design:type", Function),
79
- __metadata("design:paramtypes", [String, RouteBody]),
48
+ __metadata("design:paramtypes", [String, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
80
49
  __metadata("design:returntype", Promise)
81
50
  ], BaseUpdateOneController.prototype, "updateOne", null);
82
51
  Object.defineProperty(BaseUpdateOneController, 'name', {
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "2.1.2"
2
+ "version": "2.1.4"
3
3
  }