mongodb-dynamic-api 2.1.1 → 2.1.2
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 +5 -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/guards/base-policies.guard.d.ts +2 -2
- package/src/helpers/controller-ability-predicates.helper.d.ts +2 -2
- 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.js +9 -13
- package/src/routes/create-one/create-one-controller.mixin.js +9 -13
- package/src/routes/delete-many/delete-many-controller.mixin.js +5 -7
- package/src/routes/delete-one/delete-one-controller.mixin.js +11 -17
- package/src/routes/duplicate-many/duplicate-many-controller.mixin.js +9 -13
- package/src/routes/duplicate-one/duplicate-one-controller.mixin.js +15 -23
- package/src/routes/get-many/get-many-controller.mixin.js +9 -13
- package/src/routes/get-one/get-one-controller.mixin.js +15 -23
- package/src/routes/replace-one/replace-one-controller.mixin.js +15 -23
- package/src/routes/update-many/update-many-controller.mixin.js +9 -13
- package/src/routes/update-one/update-one-controller.mixin.js +14 -20
- package/src/version.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
Changelog
|
|
2
2
|
|
|
3
|
+
## [2.1.2](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.1...v2.1.2) (2024-03-26)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
* rename all custom dto to avoid swagger conflicts ([0bc7e5f](https://github.com/MikeDev75015/mongodb-dynamic-api/commit/0bc7e5fe85f3c44ce3382839e5a502d3232e5526))
|
|
7
|
+
|
|
3
8
|
## [2.1.1](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.0...v2.1.1) (2024-03-21)
|
|
4
9
|
|
|
5
10
|
## [2.1.0](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.0.0...v2.1.0) (2024-03-20)
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import { AppAbility,
|
|
2
|
+
import { AppAbility, RouteAbilityPredicate, RouteType } from '../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../models';
|
|
4
|
-
declare function CaslAbilityBuilder<Entity extends BaseEntity>(entity: Type<Entity>, routeType: RouteType, abilityPredicate:
|
|
4
|
+
declare function CaslAbilityBuilder<Entity extends BaseEntity>(entity: Type<Entity>, routeType: RouteType, abilityPredicate: RouteAbilityPredicate<Entity>, user: unknown): AppAbility<Entity>;
|
|
5
5
|
export { CaslAbilityBuilder };
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CaslAbilityBuilder = void 0;
|
|
4
4
|
const ability_1 = require("@casl/ability");
|
|
5
|
+
const interfaces_1 = require("../../interfaces");
|
|
5
6
|
function CaslAbilityBuilder(entity, routeType, abilityPredicate, user) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
can(routeType, entity);
|
|
7
|
+
if (!entity || !routeType || !abilityPredicate || !user) {
|
|
8
|
+
throw new Error('Invalid parameters, cannot build ability');
|
|
9
9
|
}
|
|
10
|
+
const { can, build } = new ability_1.AbilityBuilder(ability_1.PureAbility);
|
|
11
|
+
can(routeType, entity, (instance) => abilityPredicate(instance, user));
|
|
10
12
|
return build({
|
|
11
|
-
|
|
13
|
+
conditionsMatcher: interfaces_1.lambdaMatcher,
|
|
14
|
+
detectSubjectType: (object) => object.constructor,
|
|
12
15
|
});
|
|
13
16
|
}
|
|
14
17
|
exports.CaslAbilityBuilder = CaslAbilityBuilder;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CanActivate, ExecutionContext, Type } from '@nestjs/common';
|
|
2
2
|
import { Reflector } from '@nestjs/core';
|
|
3
|
-
import {
|
|
3
|
+
import { RouteAbilityPredicate, RouteType } from '../interfaces';
|
|
4
4
|
import { BaseEntity } from '../models';
|
|
5
5
|
export declare abstract class BasePoliciesGuard<Entity extends BaseEntity> implements CanActivate {
|
|
6
6
|
protected readonly reflector: Reflector;
|
|
7
7
|
protected routeType: RouteType;
|
|
8
8
|
protected entity: Type<Entity>;
|
|
9
|
-
protected abilityPredicate:
|
|
9
|
+
protected abilityPredicate: RouteAbilityPredicate<Entity> | undefined;
|
|
10
10
|
protected constructor(reflector: Reflector);
|
|
11
11
|
canActivate(context: ExecutionContext): boolean;
|
|
12
12
|
private execPolicyHandler;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ControllerAbilityPredicate, RouteAbilityPredicate, RouteType } from '../interfaces';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
declare function getPredicateFromControllerAbilityPredicates<Entity extends BaseEntity>(controllerAbilityPredicates:
|
|
3
|
+
declare function getPredicateFromControllerAbilityPredicates<Entity extends BaseEntity>(controllerAbilityPredicates: ControllerAbilityPredicate<Entity>[], route: RouteType): RouteAbilityPredicate<Entity>;
|
|
4
4
|
export { getPredicateFromControllerAbilityPredicates };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isValidVersion = exports.pascalCase = void 0;
|
|
3
|
+
exports.getFormattedApiTag = exports.isValidVersion = exports.pascalCase = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
function pascalCase(str) {
|
|
6
6
|
return str ? (0, lodash_1.upperFirst)((0, lodash_1.camelCase)(str)) : undefined;
|
|
@@ -10,3 +10,7 @@ function isValidVersion(version) {
|
|
|
10
10
|
return /^\d+$/.test(version);
|
|
11
11
|
}
|
|
12
12
|
exports.isValidVersion = isValidVersion;
|
|
13
|
+
function getFormattedApiTag(apiTag, entityName) {
|
|
14
|
+
return pascalCase(apiTag) ?? entityName;
|
|
15
|
+
}
|
|
16
|
+
exports.getFormattedApiTag = getFormattedApiTag;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { AbilityTuple, MatchConditions, PureAbility } from '@casl/ability';
|
|
1
2
|
import { BaseEntity } from '../models';
|
|
2
3
|
import { RouteType } from './dynamic-api-route-type.type';
|
|
3
|
-
type
|
|
4
|
-
|
|
5
|
-
type
|
|
4
|
+
type AppAbility<Entity extends BaseEntity> = PureAbility<AbilityTuple, MatchConditions<Entity>>;
|
|
5
|
+
declare const lambdaMatcher: <Entity extends BaseEntity>(matchConditions: MatchConditions<Entity>) => MatchConditions<Entity>;
|
|
6
|
+
type RouteAbilityPredicate<Entity extends BaseEntity, User = any> = (entity: Entity, user: User) => boolean;
|
|
7
|
+
type RegisterAbilityPredicate<User = any> = (user: User) => boolean;
|
|
8
|
+
type ControllerAbilityPredicate<Entity extends BaseEntity> = {
|
|
6
9
|
targets: RouteType[];
|
|
7
|
-
predicate:
|
|
10
|
+
predicate: RouteAbilityPredicate<Entity>;
|
|
8
11
|
};
|
|
9
|
-
export {
|
|
12
|
+
export { AppAbility, ControllerAbilityPredicate, RegisterAbilityPredicate, RouteAbilityPredicate, lambdaMatcher, };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ValidationPipeOptions } from '@nestjs/common';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
import {
|
|
3
|
+
import { ControllerAbilityPredicate } from './dynamic-api-casl-ability.interface';
|
|
4
4
|
interface DynamicApiControllerOptions<Entity extends BaseEntity> {
|
|
5
5
|
path: string;
|
|
6
6
|
apiTag?: string;
|
|
7
7
|
version?: string;
|
|
8
8
|
isPublic?: boolean;
|
|
9
9
|
validationPipeOptions?: ValidationPipeOptions;
|
|
10
|
-
abilityPredicates?:
|
|
10
|
+
abilityPredicates?: ControllerAbilityPredicate<Entity>[];
|
|
11
11
|
}
|
|
12
12
|
export { DynamicApiControllerOptions };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ExecutionContext, Type } from '@nestjs/common';
|
|
1
|
+
import { ExecutionContext } from '@nestjs/common';
|
|
3
2
|
import { Reflector } from '@nestjs/core';
|
|
4
3
|
import { BaseEntity } from '../models';
|
|
5
|
-
import {
|
|
6
|
-
type AppAbility<Entity extends BaseEntity> = MongoAbility<[RouteType, Type<Entity>]>;
|
|
4
|
+
import { AppAbility } from './dynamic-api-casl-ability.interface';
|
|
7
5
|
interface IPolicyHandler<Entity extends BaseEntity> {
|
|
8
6
|
handle(ability: AppAbility<Entity>): boolean;
|
|
9
7
|
}
|
|
@@ -13,4 +11,4 @@ interface PoliciesGuard<Entity extends BaseEntity> {
|
|
|
13
11
|
canActivate(context: ExecutionContext): boolean;
|
|
14
12
|
}
|
|
15
13
|
type PoliciesGuardConstructor<Entity extends BaseEntity> = new (reflector: Reflector) => PoliciesGuard<Entity>;
|
|
16
|
-
export {
|
|
14
|
+
export { PolicyHandler, PoliciesGuardConstructor, PoliciesGuard };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ValidationPipeOptions } from '@nestjs/common';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
import {
|
|
3
|
+
import { RouteAbilityPredicate } from './dynamic-api-casl-ability.interface';
|
|
4
4
|
import { DTOsBundle } from './dynamic-api-route-dtos-bundle.type';
|
|
5
5
|
import { RouteType } from './dynamic-api-route-type.type';
|
|
6
6
|
interface DynamicAPIRouteConfig<Entity extends BaseEntity> {
|
|
@@ -10,6 +10,6 @@ interface DynamicAPIRouteConfig<Entity extends BaseEntity> {
|
|
|
10
10
|
version?: string;
|
|
11
11
|
dTOs?: DTOsBundle;
|
|
12
12
|
validationPipeOptions?: ValidationPipeOptions;
|
|
13
|
-
abilityPredicate?:
|
|
13
|
+
abilityPredicate?: RouteAbilityPredicate<Entity>;
|
|
14
14
|
}
|
|
15
15
|
export { DynamicAPIRouteConfig };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { RouteAbilityPredicate, PoliciesGuardConstructor, RouteType } from '../interfaces';
|
|
3
3
|
import { BaseEntity } from '../models';
|
|
4
|
-
declare function CreatePoliciesGuardMixin<Entity extends BaseEntity>(entity: Type<Entity>, routeType: RouteType, version: string | undefined, abilityPredicate:
|
|
4
|
+
declare function CreatePoliciesGuardMixin<Entity extends BaseEntity>(entity: Type<Entity>, routeType: RouteType, version: string | undefined, abilityPredicate: RouteAbilityPredicate<Entity> | undefined): PoliciesGuardConstructor<Entity>;
|
|
5
5
|
export { CreatePoliciesGuardMixin };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { RegisterAbilityPredicate } from '../../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../../models';
|
|
4
4
|
type DynamicApiRegisterOptions<Entity extends BaseEntity = any> = {
|
|
5
5
|
protected?: boolean;
|
|
6
|
-
abilityPredicate?:
|
|
6
|
+
abilityPredicate?: RegisterAbilityPredicate;
|
|
7
7
|
additionalFields?: (keyof Entity | {
|
|
8
8
|
name: keyof Entity;
|
|
9
9
|
required?: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
|
-
import {
|
|
2
|
+
import { RegisterAbilityPredicate, PoliciesGuardConstructor, RouteType } from '../../../interfaces';
|
|
3
3
|
import { BaseEntity } from '../../../models';
|
|
4
4
|
declare const registerRouteType: RouteType;
|
|
5
|
-
declare function AuthRegisterPoliciesGuardMixin<Entity extends BaseEntity>(entity: Type<Entity>, abilityPredicate:
|
|
5
|
+
declare function AuthRegisterPoliciesGuardMixin<Entity extends BaseEntity>(entity: Type<Entity>, abilityPredicate: RegisterAbilityPredicate | undefined): PoliciesGuardConstructor<Entity>;
|
|
6
6
|
export { AuthRegisterPoliciesGuardMixin, registerRouteType };
|
|
@@ -14,7 +14,7 @@ class BaseAuthService extends services_1.BaseService {
|
|
|
14
14
|
}
|
|
15
15
|
async validateUser(login, pass) {
|
|
16
16
|
const user = (await this.model.findOne({ [this.loginField]: login }).lean().exec());
|
|
17
|
-
if (!user || !await this.bcryptService.comparePassword(pass, user[this.passwordField])) {
|
|
17
|
+
if (!user || !(await this.bcryptService.comparePassword(pass, user[this.passwordField]))) {
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
const fieldsToBuild = [
|
|
@@ -22,7 +22,7 @@ class BaseAuthService extends services_1.BaseService {
|
|
|
22
22
|
this.loginField,
|
|
23
23
|
...this.additionalRequestFields,
|
|
24
24
|
];
|
|
25
|
-
return this.
|
|
25
|
+
return this.buildUserFields(user, fieldsToBuild);
|
|
26
26
|
}
|
|
27
27
|
async login(user) {
|
|
28
28
|
const fieldsToBuild = [
|
|
@@ -31,7 +31,7 @@ class BaseAuthService extends services_1.BaseService {
|
|
|
31
31
|
this.loginField,
|
|
32
32
|
...this.additionalRequestFields,
|
|
33
33
|
];
|
|
34
|
-
const payload = this.
|
|
34
|
+
const payload = this.buildUserFields(user, fieldsToBuild);
|
|
35
35
|
return {
|
|
36
36
|
accessToken: this.jwtService.sign(payload),
|
|
37
37
|
};
|
|
@@ -49,7 +49,7 @@ class BaseAuthService extends services_1.BaseService {
|
|
|
49
49
|
this.loginField,
|
|
50
50
|
...this.additionalRequestFields,
|
|
51
51
|
];
|
|
52
|
-
return this.
|
|
52
|
+
return this.buildUserFields(user, fieldsToBuild);
|
|
53
53
|
}
|
|
54
54
|
async changePassword(userId, newPassword) {
|
|
55
55
|
const hashedPassword = await this.bcryptService.hashPassword(newPassword);
|
|
@@ -60,5 +60,8 @@ class BaseAuthService extends services_1.BaseService {
|
|
|
60
60
|
async getUserById(userId) {
|
|
61
61
|
return (await this.model.findOne({ _id: userId }).lean().exec());
|
|
62
62
|
}
|
|
63
|
+
buildUserFields(user, fieldsToBuild) {
|
|
64
|
+
return this.buildInstance(fieldsToBuild.reduce((acc, field) => (user[field] !== undefined ? { ...acc, [field]: user[field] } : acc), {}));
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
exports.BaseAuthService = BaseAuthService;
|
|
@@ -23,7 +23,7 @@ const helpers_1 = require("../../helpers");
|
|
|
23
23
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
24
24
|
const mixins_1 = require("../../mixins");
|
|
25
25
|
function CreateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
|
|
26
|
-
const displayedName = (0, helpers_1.
|
|
26
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
27
27
|
const { body: CustomBody, presenter: CustomPresenter } = dTOs ?? {};
|
|
28
28
|
let isPublic;
|
|
29
29
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -53,20 +53,16 @@ function CreateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
|
|
|
53
53
|
], CreateManyBody.prototype, "list", void 0);
|
|
54
54
|
class RouteBody extends (0, swagger_1.PickType)(CustomBody ?? CreateManyBody, ['list']) {
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
61
|
-
}
|
|
56
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
57
|
+
value: CustomBody ? CustomBody.name : `CreateMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
58
|
+
writable: false,
|
|
59
|
+
});
|
|
62
60
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
63
61
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
}
|
|
62
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
63
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
64
|
+
writable: false,
|
|
65
|
+
});
|
|
70
66
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('CreateMany', entity, version, description, isPublic, {
|
|
71
67
|
param: undefined,
|
|
72
68
|
query: undefined,
|
|
@@ -20,7 +20,7 @@ const helpers_1 = require("../../helpers");
|
|
|
20
20
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
22
|
function CreateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
|
|
23
|
-
const displayedName = (0, helpers_1.
|
|
23
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
24
24
|
const { body: CustomBody, presenter: CustomPresenter } = dTOs ?? {};
|
|
25
25
|
let isPublic;
|
|
26
26
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -34,20 +34,16 @@ function CreateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCont
|
|
|
34
34
|
}
|
|
35
35
|
class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity)) {
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
37
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
38
|
+
value: CustomBody ? CustomBody.name : `CreateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
39
|
+
writable: false,
|
|
40
|
+
});
|
|
43
41
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
43
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
44
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
45
|
+
writable: false,
|
|
46
|
+
});
|
|
51
47
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('CreateOne', entity, version, description, isPublic, {
|
|
52
48
|
param: undefined,
|
|
53
49
|
query: undefined,
|
|
@@ -21,7 +21,7 @@ const controller_ability_predicates_helper_1 = require("../../helpers/controller
|
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
22
|
const delete_many_presenter_1 = require("./delete-many.presenter");
|
|
23
23
|
function DeleteManyControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
|
|
24
|
-
const displayedName = (0, helpers_1.
|
|
24
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
25
25
|
const { presenter: CustomPresenter } = dTOs ?? {};
|
|
26
26
|
let isPublic;
|
|
27
27
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -35,12 +35,10 @@ function DeleteManyControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
|
|
|
35
35
|
}
|
|
36
36
|
class RoutePresenter extends (CustomPresenter ?? delete_many_presenter_1.DeleteManyPresenter) {
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
}
|
|
38
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
39
|
+
value: CustomPresenter ? CustomPresenter.name : `DeleteMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
40
|
+
writable: false,
|
|
41
|
+
});
|
|
44
42
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DeleteMany', entity, version, description, isPublic, {
|
|
45
43
|
param: undefined,
|
|
46
44
|
query: undefined,
|
|
@@ -22,8 +22,8 @@ const controller_ability_predicates_helper_1 = require("../../helpers/controller
|
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
23
|
const delete_one_presenter_1 = require("./delete-one.presenter");
|
|
24
24
|
function DeleteOneControllerMixin(entity, { path, apiTag, isPublic: isPublicController, abilityPredicates: controllerAbilityPredicates, }, { type: routeType, description, dTOs, isPublic: isPublicRoute, abilityPredicate: routeAbilityPredicate, }, version) {
|
|
25
|
-
const displayedName = (0, helpers_1.
|
|
26
|
-
const {
|
|
25
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
26
|
+
const { presenter: CustomPresenter } = dTOs ?? {};
|
|
27
27
|
let isPublic;
|
|
28
28
|
if (typeof isPublicRoute === 'boolean') {
|
|
29
29
|
isPublic = isPublicRoute;
|
|
@@ -34,24 +34,18 @@ function DeleteOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCont
|
|
|
34
34
|
else {
|
|
35
35
|
isPublic = false;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
value: `DeleteOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
42
|
-
writable: false,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
37
|
+
Object.defineProperty(dtos_1.EntityParam, 'name', {
|
|
38
|
+
value: `DeleteOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
39
|
+
writable: false,
|
|
40
|
+
});
|
|
45
41
|
class RoutePresenter extends (CustomPresenter ?? delete_one_presenter_1.DeleteOnePresenter) {
|
|
46
42
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
}
|
|
43
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
44
|
+
value: CustomPresenter ? CustomPresenter.name : `DeleteOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
45
|
+
writable: false,
|
|
46
|
+
});
|
|
53
47
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DeleteOne', entity, version, description, isPublic, {
|
|
54
|
-
param:
|
|
48
|
+
param: dtos_1.EntityParam,
|
|
55
49
|
query: undefined,
|
|
56
50
|
body: undefined,
|
|
57
51
|
presenter: RoutePresenter,
|
|
@@ -20,7 +20,7 @@ const helpers_1 = require("../../helpers");
|
|
|
20
20
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
21
21
|
const mixins_1 = require("../../mixins");
|
|
22
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.
|
|
23
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
24
24
|
const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
|
|
25
25
|
let isPublic;
|
|
26
26
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -34,20 +34,16 @@ function DuplicateManyControllerMixin(entity, { path, apiTag, isPublic: isPublic
|
|
|
34
34
|
}
|
|
35
35
|
class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
});
|
|
42
|
-
}
|
|
37
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
38
|
+
value: CustomBody ? CustomBody.name : `DuplicateMany${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
39
|
+
writable: false,
|
|
40
|
+
});
|
|
43
41
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
44
42
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
}
|
|
43
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
44
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
45
|
+
writable: false,
|
|
46
|
+
});
|
|
51
47
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateMany', entity, version, description, isPublic, {
|
|
52
48
|
param: undefined,
|
|
53
49
|
query: undefined,
|
|
@@ -21,8 +21,8 @@ const helpers_1 = require("../../helpers");
|
|
|
21
21
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
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.
|
|
25
|
-
const { body: CustomBody,
|
|
24
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
25
|
+
const { body: CustomBody, presenter: CustomPresenter, } = dTOs ?? {};
|
|
26
26
|
let isPublic;
|
|
27
27
|
if (typeof isPublicRoute === 'boolean') {
|
|
28
28
|
isPublic = isPublicRoute;
|
|
@@ -33,32 +33,24 @@ function DuplicateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicC
|
|
|
33
33
|
else {
|
|
34
34
|
isPublic = false;
|
|
35
35
|
}
|
|
36
|
+
Object.defineProperty(dtos_1.EntityParam, 'name', {
|
|
37
|
+
value: `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
38
|
+
writable: false,
|
|
39
|
+
});
|
|
36
40
|
class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
|
|
37
41
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
}
|
|
42
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
43
|
+
value: CustomBody ? CustomBody.name : `DuplicateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
44
|
+
writable: false,
|
|
45
|
+
});
|
|
52
46
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
53
47
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
}
|
|
48
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
49
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
50
|
+
writable: false,
|
|
51
|
+
});
|
|
60
52
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('DuplicateOne', entity, version, description, isPublic, {
|
|
61
|
-
param:
|
|
53
|
+
param: dtos_1.EntityParam,
|
|
62
54
|
query: undefined,
|
|
63
55
|
body: RouteBody,
|
|
64
56
|
presenter: RoutePresenter,
|
|
@@ -21,7 +21,7 @@ const helpers_1 = require("../../helpers");
|
|
|
21
21
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
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.
|
|
24
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
25
25
|
const { query: CustomQuery, presenter: CustomPresenter } = dTOs ?? {};
|
|
26
26
|
let isPublic;
|
|
27
27
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -35,20 +35,16 @@ function GetManyControllerMixin(entity, { path, apiTag, isPublic: isPublicContro
|
|
|
35
35
|
}
|
|
36
36
|
class RouteQuery extends (CustomQuery ?? dtos_1.EntityQuery) {
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
-
}
|
|
38
|
+
Object.defineProperty(RouteQuery, 'name', {
|
|
39
|
+
value: CustomQuery ? CustomQuery.name : `${routeType}${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
|
|
40
|
+
writable: false,
|
|
41
|
+
});
|
|
44
42
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
45
43
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
44
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
45
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
46
|
+
writable: false,
|
|
47
|
+
});
|
|
52
48
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder(routeType, entity, version, description, isPublic, {
|
|
53
49
|
param: undefined,
|
|
54
50
|
query: RouteQuery,
|
|
@@ -21,8 +21,8 @@ const helpers_1 = require("../../helpers");
|
|
|
21
21
|
const controller_ability_predicates_helper_1 = require("../../helpers/controller-ability-predicates.helper");
|
|
22
22
|
const mixins_1 = require("../../mixins");
|
|
23
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.
|
|
25
|
-
const {
|
|
24
|
+
const displayedName = (0, helpers_1.getFormattedApiTag)(apiTag, entity.name);
|
|
25
|
+
const { query: CustomQuery, presenter: CustomPresenter, } = dTOs ?? {};
|
|
26
26
|
let isPublic;
|
|
27
27
|
if (typeof isPublicRoute === 'boolean') {
|
|
28
28
|
isPublic = isPublicRoute;
|
|
@@ -33,32 +33,24 @@ function GetOneControllerMixin(entity, { path, apiTag, isPublic: isPublicControl
|
|
|
33
33
|
else {
|
|
34
34
|
isPublic = false;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
value: `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
36
|
+
Object.defineProperty(dtos_1.EntityParam, 'name', {
|
|
37
|
+
value: `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
38
|
+
writable: false,
|
|
39
|
+
});
|
|
44
40
|
class RouteQuery extends (CustomQuery ?? dtos_1.EntityQuery) {
|
|
45
41
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
});
|
|
51
|
-
}
|
|
42
|
+
Object.defineProperty(RouteQuery, 'name', {
|
|
43
|
+
value: CustomQuery ? CustomQuery.name : `GetOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Query`,
|
|
44
|
+
writable: false,
|
|
45
|
+
});
|
|
52
46
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
53
47
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
}
|
|
48
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
49
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
50
|
+
writable: false,
|
|
51
|
+
});
|
|
60
52
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('GetOne', entity, version, description, isPublic, {
|
|
61
|
-
param:
|
|
53
|
+
param: dtos_1.EntityParam,
|
|
62
54
|
query: RouteQuery,
|
|
63
55
|
body: undefined,
|
|
64
56
|
presenter: RoutePresenter,
|