mongodb-dynamic-api 2.1.1 → 2.1.3
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 +7 -0
- package/package.json +1 -1
- package/src/builders/casl/casl-ability.builder.d.ts +2 -2
- package/src/builders/casl/casl-ability.builder.js +7 -4
- package/src/dtos/delete.presenter.d.ts +3 -0
- package/src/{routes/delete-one/delete-one.presenter.js → dtos/delete.presenter.js} +4 -4
- package/src/dtos/index.d.ts +1 -0
- package/src/dtos/index.js +1 -0
- package/src/guards/base-policies.guard.d.ts +2 -2
- package/src/helpers/controller-ability-predicates.helper.d.ts +2 -2
- package/src/helpers/controller-mixin.helper.d.ts +66 -0
- package/src/helpers/controller-mixin.helper.js +159 -0
- package/src/helpers/format.helper.d.ts +1 -0
- package/src/helpers/format.helper.js +5 -1
- package/src/interfaces/dynamic-api-casl-ability.interface.d.ts +8 -5
- package/src/interfaces/dynamic-api-casl-ability.interface.js +3 -0
- package/src/interfaces/dynamic-api-controller-options.interface.d.ts +2 -2
- package/src/interfaces/dynamic-api-policy-handler.interface.d.ts +3 -5
- package/src/interfaces/dynamic-api-route-config.interface.d.ts +2 -2
- package/src/mixins/create-policies-guard.mixin.d.ts +2 -2
- package/src/modules/auth/interfaces/auth-options.interface.d.ts +2 -2
- package/src/modules/auth/mixins/auth-register-policies-guard.mixin.d.ts +2 -2
- package/src/modules/auth/services/base-auth.service.d.ts +1 -0
- package/src/modules/auth/services/base-auth.service.js +7 -4
- package/src/routes/create-many/create-many-controller.mixin.d.ts +1 -1
- package/src/routes/create-many/create-many-controller.mixin.js +6 -54
- package/src/routes/create-one/create-one-controller.mixin.d.ts +1 -1
- package/src/routes/create-one/create-one-controller.mixin.js +6 -35
- package/src/routes/delete-many/base-delete-many.service.d.ts +2 -2
- package/src/routes/delete-many/base-delete-many.service.js +2 -2
- package/src/routes/delete-many/delete-many-controller.mixin.d.ts +1 -1
- package/src/routes/delete-many/delete-many-controller.mixin.js +4 -28
- package/src/routes/delete-many/index.d.ts +0 -1
- package/src/routes/delete-many/index.js +0 -1
- package/src/routes/delete-one/base-delete-one.service.d.ts +2 -2
- package/src/routes/delete-one/base-delete-one.service.js +2 -2
- package/src/routes/delete-one/delete-one-controller.mixin.d.ts +1 -1
- package/src/routes/delete-one/delete-one-controller.mixin.js +5 -37
- package/src/routes/delete-one/index.d.ts +0 -1
- package/src/routes/delete-one/index.js +0 -1
- package/src/routes/duplicate-many/duplicate-many-controller.mixin.d.ts +1 -1
- package/src/routes/duplicate-many/duplicate-many-controller.mixin.js +6 -35
- package/src/routes/duplicate-one/duplicate-one-controller.mixin.d.ts +1 -1
- package/src/routes/duplicate-one/duplicate-one-controller.mixin.js +6 -42
- package/src/routes/get-many/get-many-controller.mixin.d.ts +1 -1
- package/src/routes/get-many/get-many-controller.mixin.js +5 -35
- package/src/routes/get-one/get-one-controller.mixin.d.ts +1 -1
- package/src/routes/get-one/get-one-controller.mixin.js +5 -42
- package/src/routes/replace-one/replace-one-controller.mixin.d.ts +1 -1
- package/src/routes/replace-one/replace-one-controller.mixin.js +6 -43
- package/src/routes/update-many/update-many-controller.mixin.d.ts +1 -1
- package/src/routes/update-many/update-many-controller.mixin.js +5 -34
- package/src/routes/update-one/update-one-controller.mixin.d.ts +1 -1
- package/src/routes/update-one/update-one-controller.mixin.js +6 -43
- package/src/version.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/routes/delete-one/delete-one.presenter.d.ts +0 -3
|
@@ -17,44 +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
|
|
20
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
|
-
function CreateOneControllerMixin(entity,
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
|
|
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)) {
|
|
36
|
-
}
|
|
37
|
-
if (!CustomBody) {
|
|
38
|
-
Object.defineProperty(RouteBody, 'name', {
|
|
39
|
-
value: `CreateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
40
|
-
writable: false,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
44
|
-
}
|
|
45
|
-
if (!CustomPresenter) {
|
|
46
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
47
|
-
value: `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
48
|
-
writable: false,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('CreateOne', entity, version, description, isPublic, {
|
|
52
|
-
param: undefined,
|
|
53
|
-
query: undefined,
|
|
22
|
+
function CreateOneControllerMixin(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, {
|
|
54
26
|
body: RouteBody,
|
|
55
27
|
presenter: RoutePresenter,
|
|
56
28
|
});
|
|
57
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
58
29
|
class CreateOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
59
30
|
}
|
|
60
31
|
class BaseCreateOneController {
|
|
@@ -72,7 +43,7 @@ function CreateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCont
|
|
|
72
43
|
(0, decorators_1.CheckPolicies)((ability) => ability.can(routeType, entity)),
|
|
73
44
|
__param(0, (0, common_1.Body)()),
|
|
74
45
|
__metadata("design:type", Function),
|
|
75
|
-
__metadata("design:paramtypes", [RouteBody]),
|
|
46
|
+
__metadata("design:paramtypes", [typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
|
|
76
47
|
__metadata("design:returntype", Promise)
|
|
77
48
|
], BaseCreateOneController.prototype, "createOne", null);
|
|
78
49
|
Object.defineProperty(BaseCreateOneController, 'name', {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { Model } from 'mongoose';
|
|
26
|
+
import { DeletePresenter } from '../../dtos';
|
|
26
27
|
import { BaseEntity } from '../../models';
|
|
27
28
|
import { BaseService } from '../../services';
|
|
28
29
|
import { DeleteManyService } from './delete-many-service.interface';
|
|
29
|
-
import { DeleteManyPresenter } from './delete-many.presenter';
|
|
30
30
|
export declare abstract class BaseDeleteManyService<Entity extends BaseEntity> extends BaseService<Entity> implements DeleteManyService<Entity> {
|
|
31
31
|
protected readonly model: Model<Entity>;
|
|
32
32
|
protected constructor(model: Model<Entity>);
|
|
33
|
-
deleteMany(ids: string[]): Promise<
|
|
33
|
+
deleteMany(ids: string[]): Promise<DeletePresenter>;
|
|
34
34
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseDeleteManyService = void 0;
|
|
4
4
|
const builder_pattern_1 = require("builder-pattern");
|
|
5
|
+
const dtos_1 = require("../../dtos");
|
|
5
6
|
const services_1 = require("../../services");
|
|
6
|
-
const delete_many_presenter_1 = require("./delete-many.presenter");
|
|
7
7
|
class BaseDeleteManyService extends services_1.BaseService {
|
|
8
8
|
constructor(model) {
|
|
9
9
|
super(model);
|
|
@@ -23,7 +23,7 @@ class BaseDeleteManyService extends services_1.BaseService {
|
|
|
23
23
|
else {
|
|
24
24
|
op = await this.model.deleteMany({ _id: { $in: ids } }).exec();
|
|
25
25
|
}
|
|
26
|
-
return (0, builder_pattern_1.Builder)(
|
|
26
|
+
return (0, builder_pattern_1.Builder)(dtos_1.DeletePresenter).deletedCount(op.deletedCount).build();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.BaseDeleteManyService = BaseDeleteManyService;
|
|
@@ -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 { DeleteManyControllerConstructor } from './delete-many-controller.interface';
|
|
5
|
-
declare function DeleteManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>,
|
|
5
|
+
declare function DeleteManyControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): DeleteManyControllerConstructor<Entity>;
|
|
6
6
|
export { DeleteManyControllerMixin };
|
|
@@ -17,37 +17,13 @@ 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
|
|
20
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const { 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 RoutePresenter extends (CustomPresenter ?? delete_many_presenter_1.DeleteManyPresenter) {
|
|
37
|
-
}
|
|
38
|
-
if (!CustomPresenter) {
|
|
39
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
40
|
-
value: `DeleteMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DeleteMany', entity, version, description, isPublic, {
|
|
45
|
-
param: undefined,
|
|
46
|
-
query: undefined,
|
|
47
|
-
body: undefined,
|
|
22
|
+
function DeleteManyControllerMixin(entity, controllerOptions, routeConfig, version) {
|
|
23
|
+
const { routeType, description, isPublic, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
|
|
24
|
+
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
|
|
48
25
|
presenter: RoutePresenter,
|
|
49
26
|
});
|
|
50
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
51
27
|
class DeleteManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
52
28
|
}
|
|
53
29
|
class BaseDeleteManyController {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './base-delete-many.service';
|
|
2
2
|
export * from './delete-many.helper';
|
|
3
3
|
export * from './delete-many.module';
|
|
4
|
-
export * from './delete-many.presenter';
|
|
5
4
|
export * from './delete-many-controller.interface';
|
|
6
5
|
export * from './delete-many-controller.mixin';
|
|
7
6
|
export * from './delete-many-service.interface';
|
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./base-delete-many.service"), exports);
|
|
18
18
|
__exportStar(require("./delete-many.helper"), exports);
|
|
19
19
|
__exportStar(require("./delete-many.module"), exports);
|
|
20
|
-
__exportStar(require("./delete-many.presenter"), exports);
|
|
21
20
|
__exportStar(require("./delete-many-controller.interface"), exports);
|
|
22
21
|
__exportStar(require("./delete-many-controller.mixin"), exports);
|
|
23
22
|
__exportStar(require("./delete-many-service.interface"), exports);
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import { Model } from 'mongoose';
|
|
26
|
+
import { DeletePresenter } from '../../dtos';
|
|
26
27
|
import { BaseEntity } from '../../models';
|
|
27
28
|
import { BaseService } from '../../services';
|
|
28
29
|
import { DeleteOneService } from './delete-one-service.interface';
|
|
29
|
-
import { DeleteOnePresenter } from './delete-one.presenter';
|
|
30
30
|
export declare abstract class BaseDeleteOneService<Entity extends BaseEntity> extends BaseService<Entity> implements DeleteOneService<Entity> {
|
|
31
31
|
protected readonly model: Model<Entity>;
|
|
32
32
|
protected constructor(model: Model<Entity>);
|
|
33
|
-
deleteOne(id: string): Promise<
|
|
33
|
+
deleteOne(id: string): Promise<DeletePresenter>;
|
|
34
34
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseDeleteOneService = void 0;
|
|
4
4
|
const builder_pattern_1 = require("builder-pattern");
|
|
5
|
+
const dtos_1 = require("../../dtos");
|
|
5
6
|
const services_1 = require("../../services");
|
|
6
|
-
const delete_one_presenter_1 = require("./delete-one.presenter");
|
|
7
7
|
class BaseDeleteOneService extends services_1.BaseService {
|
|
8
8
|
constructor(model) {
|
|
9
9
|
super(model);
|
|
@@ -23,7 +23,7 @@ class BaseDeleteOneService extends services_1.BaseService {
|
|
|
23
23
|
else {
|
|
24
24
|
op = await this.model.deleteOne({ _id: id }).exec();
|
|
25
25
|
}
|
|
26
|
-
return (0, builder_pattern_1.Builder)(
|
|
26
|
+
return (0, builder_pattern_1.Builder)(dtos_1.DeletePresenter).deletedCount(op.deletedCount).build();
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
exports.BaseDeleteOneService = BaseDeleteOneService;
|
|
@@ -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 { DeleteOneControllerConstructor } from './delete-one-controller.interface';
|
|
5
|
-
declare function DeleteOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>,
|
|
5
|
+
declare function DeleteOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): DeleteOneControllerConstructor<Entity>;
|
|
6
6
|
export { DeleteOneControllerMixin };
|
|
@@ -16,47 +16,15 @@ exports.DeleteOneControllerMixin = 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
|
|
20
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
22
21
|
const mixins_1 = require("../../mixins");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
let isPublic;
|
|
28
|
-
if (typeof isPublicRoute === 'boolean') {
|
|
29
|
-
isPublic = isPublicRoute;
|
|
30
|
-
}
|
|
31
|
-
else if (typeof isPublicController === 'boolean') {
|
|
32
|
-
isPublic = isPublicController;
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
isPublic = false;
|
|
36
|
-
}
|
|
37
|
-
class RouteParam extends (CustomParam ?? dtos_1.EntityParam) {
|
|
38
|
-
}
|
|
39
|
-
if (!CustomParam) {
|
|
40
|
-
Object.defineProperty(RouteParam, 'name', {
|
|
41
|
-
value: `DeleteOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
42
|
-
writable: false,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
class RoutePresenter extends (CustomPresenter ?? delete_one_presenter_1.DeleteOnePresenter) {
|
|
46
|
-
}
|
|
47
|
-
if (!CustomPresenter) {
|
|
48
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
49
|
-
value: `DeleteOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
50
|
-
writable: false,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DeleteOne', entity, version, description, isPublic, {
|
|
54
|
-
param: RouteParam,
|
|
55
|
-
query: undefined,
|
|
56
|
-
body: undefined,
|
|
22
|
+
function DeleteOneControllerMixin(entity, controllerOptions, routeConfig, version) {
|
|
23
|
+
const { routeType, description, isPublic, EntityParam, RoutePresenter, abilityPredicate, } = (0, controller_mixin_helper_1.getControllerMixinData)(entity, controllerOptions, routeConfig, version);
|
|
24
|
+
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
|
|
25
|
+
param: EntityParam,
|
|
57
26
|
presenter: RoutePresenter,
|
|
58
27
|
});
|
|
59
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
60
28
|
class DeleteOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
61
29
|
}
|
|
62
30
|
class BaseDeleteOneController {
|
|
@@ -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>,
|
|
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,44 +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
|
|
20
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
|
-
function DuplicateManyControllerMixin(entity,
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
|
|
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
|
-
if (!CustomBody) {
|
|
38
|
-
Object.defineProperty(RouteBody, 'name', {
|
|
39
|
-
value: `DuplicateMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
40
|
-
writable: false,
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
44
|
-
}
|
|
45
|
-
if (!CustomPresenter) {
|
|
46
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
47
|
-
value: `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
48
|
-
writable: false,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateMany', entity, version, description, isPublic, {
|
|
52
|
-
param: undefined,
|
|
53
|
-
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, {
|
|
54
26
|
body: RouteBody,
|
|
55
27
|
presenter: RoutePresenter,
|
|
56
28
|
});
|
|
57
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
58
29
|
class DuplicateManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
59
30
|
}
|
|
60
31
|
class BaseDuplicateManyController {
|
|
@@ -73,7 +44,7 @@ function DuplicateManyControllerMixin(entity, { path, apiTag, isPublic: isPublic
|
|
|
73
44
|
__param(0, (0, common_1.Query)('ids')),
|
|
74
45
|
__param(1, (0, common_1.Body)()),
|
|
75
46
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [Array, RouteBody]),
|
|
47
|
+
__metadata("design:paramtypes", [Array, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
|
|
77
48
|
__metadata("design:returntype", Promise)
|
|
78
49
|
], BaseDuplicateManyController.prototype, "duplicateMany", null);
|
|
79
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>,
|
|
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,52 +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
|
|
21
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
|
-
function DuplicateOneControllerMixin(entity,
|
|
24
|
-
|
|
25
|
-
const {
|
|
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 RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
|
|
37
|
-
}
|
|
38
|
-
if (!CustomBody) {
|
|
39
|
-
Object.defineProperty(RouteBody, 'name', {
|
|
40
|
-
value: `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
class RouteParam extends (CustomParam ?? dtos_1.EntityParam) {
|
|
45
|
-
}
|
|
46
|
-
if (!CustomParam) {
|
|
47
|
-
Object.defineProperty(RouteParam, 'name', {
|
|
48
|
-
value: `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
49
|
-
writable: false,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
53
|
-
}
|
|
54
|
-
if (!CustomPresenter) {
|
|
55
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
56
|
-
value: `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
57
|
-
writable: false,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
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);
|
|
60
26
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateOne', entity, version, description, isPublic, {
|
|
61
|
-
param:
|
|
62
|
-
query: undefined,
|
|
27
|
+
param: dtos_1.EntityParam,
|
|
63
28
|
body: RouteBody,
|
|
64
29
|
presenter: RoutePresenter,
|
|
65
30
|
});
|
|
66
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
67
31
|
class DuplicateOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
68
32
|
}
|
|
69
33
|
class BaseDuplicateOneController {
|
|
@@ -82,7 +46,7 @@ function DuplicateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicC
|
|
|
82
46
|
__param(0, (0, common_1.Param)('id')),
|
|
83
47
|
__param(1, (0, common_1.Body)()),
|
|
84
48
|
__metadata("design:type", Function),
|
|
85
|
-
__metadata("design:paramtypes", [String, RouteBody]),
|
|
49
|
+
__metadata("design:paramtypes", [String, typeof (_a = typeof RouteBody !== "undefined" && RouteBody) === "function" ? _a : Object]),
|
|
86
50
|
__metadata("design:returntype", Promise)
|
|
87
51
|
], BaseDuplicateOneController.prototype, "duplicateOne", null);
|
|
88
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>,
|
|
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,46 +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
|
|
20
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
22
21
|
const mixins_1 = require("../../mixins");
|
|
23
|
-
function GetManyControllerMixin(entity,
|
|
24
|
-
|
|
25
|
-
const {
|
|
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
|
-
if (!CustomQuery) {
|
|
39
|
-
Object.defineProperty(RouteQuery, 'name', {
|
|
40
|
-
value: `${routeType}${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
45
|
-
}
|
|
46
|
-
if (!CustomPresenter) {
|
|
47
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
48
|
-
value: `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
49
|
-
writable: false,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
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);
|
|
52
25
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
|
|
53
|
-
param: undefined,
|
|
54
26
|
query: RouteQuery,
|
|
55
|
-
body: undefined,
|
|
56
27
|
presenter: RoutePresenter,
|
|
57
28
|
});
|
|
58
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
59
29
|
class GetManyPoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
60
30
|
}
|
|
61
31
|
class BaseGetManyController {
|
|
@@ -73,7 +43,7 @@ function GetManyControllerMixin(entity, { path, apiTag, isPublic: isPublicContro
|
|
|
73
43
|
(0, decorators_1.CheckPolicies)((ability) => ability.can(routeType, entity)),
|
|
74
44
|
__param(0, (0, common_1.Query)()),
|
|
75
45
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [RouteQuery]),
|
|
46
|
+
__metadata("design:paramtypes", [typeof (_a = typeof RouteQuery !== "undefined" && RouteQuery) === "function" ? _a : Object]),
|
|
77
47
|
__metadata("design:returntype", Promise)
|
|
78
48
|
], BaseGetManyController.prototype, "getMany", null);
|
|
79
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>,
|
|
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,52 +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
|
|
21
|
+
const controller_mixin_helper_1 = require("../../helpers/controller-mixin.helper");
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
|
-
function GetOneControllerMixin(entity,
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
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
|
-
if (!CustomParam) {
|
|
39
|
-
Object.defineProperty(RouteParam, 'name', {
|
|
40
|
-
value: `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
class RouteQuery extends (CustomQuery ?? dtos_1.EntityQuery) {
|
|
45
|
-
}
|
|
46
|
-
if (!CustomQuery) {
|
|
47
|
-
Object.defineProperty(RouteQuery, 'name', {
|
|
48
|
-
value: `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
|
|
49
|
-
writable: false,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
53
|
-
}
|
|
54
|
-
if (!CustomPresenter) {
|
|
55
|
-
Object.defineProperty(RoutePresenter, 'name', {
|
|
56
|
-
value: `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
57
|
-
writable: false,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('GetOne', entity, version, description, isPublic, {
|
|
61
|
-
param: RouteParam,
|
|
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, {
|
|
26
|
+
param: dtos_1.EntityParam,
|
|
62
27
|
query: RouteQuery,
|
|
63
|
-
body: undefined,
|
|
64
28
|
presenter: RoutePresenter,
|
|
65
29
|
});
|
|
66
|
-
const abilityPredicate = routeAbilityPredicate ?? (0, controller_ability_predicates_helper_1.getPredicateFromControllerAbilityPredicates)(controllerAbilityPredicates, routeType);
|
|
67
30
|
class GetOnePoliciesGuard extends (0, mixins_1.CreatePoliciesGuardMixin)(entity, routeType, version, abilityPredicate) {
|
|
68
31
|
}
|
|
69
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>,
|
|
5
|
+
declare function ReplaceOneControllerMixin<Entity extends BaseEntity>(entity: Type<Entity>, controllerOptions: DynamicApiControllerOptions<Entity>, routeConfig: DynamicAPIRouteConfig<Entity>, version?: string): ReplaceOneControllerConstructor<Entity>;
|
|
6
6
|
export { ReplaceOneControllerMixin };
|