mongodb-dynamic-api 2.1.0 → 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 +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/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
|
@@ -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 ReplaceOneControllerMixin(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 ReplaceOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
|
|
|
33
33
|
else {
|
|
34
34
|
isPublic = false;
|
|
35
35
|
}
|
|
36
|
+
Object.defineProperty(dtos_1.EntityParam, 'name', {
|
|
37
|
+
value: `ReplaceOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
38
|
+
writable: false,
|
|
39
|
+
});
|
|
36
40
|
class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity)) {
|
|
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: `ReplaceOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Param`,
|
|
49
|
-
writable: false,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
42
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
43
|
+
value: CustomBody ? CustomBody.name : `ReplaceOne${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('ReplaceOne', entity, version, description, isPublic, {
|
|
61
|
-
param:
|
|
53
|
+
param: dtos_1.EntityParam,
|
|
62
54
|
query: undefined,
|
|
63
55
|
body: RouteBody,
|
|
64
56
|
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 UpdateManyControllerMixin(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 UpdateManyControllerMixin(entity, { path, apiTag, isPublic: isPublicCon
|
|
|
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 : `UpdateMany${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('UpdateMany', entity, version, description, isPublic, {
|
|
52
48
|
param: undefined,
|
|
53
49
|
query: undefined,
|
|
@@ -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 UpdateOneControllerMixin(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 { body: CustomBody, param: CustomParam, presenter: CustomPresenter, } = dTOs ?? {};
|
|
26
26
|
let isPublic;
|
|
27
27
|
if (typeof isPublicRoute === 'boolean') {
|
|
@@ -33,30 +33,24 @@ function UpdateOneControllerMixin(entity, { path, apiTag, isPublic: isPublicCont
|
|
|
33
33
|
else {
|
|
34
34
|
isPublic = false;
|
|
35
35
|
}
|
|
36
|
-
class RouteBody extends (CustomBody ?? (0, mixins_1.EntityBodyMixin)(entity, true)) {
|
|
37
|
-
}
|
|
38
|
-
if (!CustomBody) {
|
|
39
|
-
Object.defineProperty(RouteBody, 'name', {
|
|
40
|
-
value: `UpdateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
41
|
-
writable: false,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
36
|
class RouteParam extends (CustomParam ?? dtos_1.EntityParam) {
|
|
45
37
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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)) {
|
|
51
43
|
}
|
|
44
|
+
Object.defineProperty(RouteBody, 'name', {
|
|
45
|
+
value: CustomBody ? CustomBody.name : `UpdateOne${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Dto`,
|
|
46
|
+
writable: false,
|
|
47
|
+
});
|
|
52
48
|
class RoutePresenter extends (CustomPresenter ?? (0, mixins_1.EntityPresenterMixin)(entity)) {
|
|
53
49
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
});
|
|
59
|
-
}
|
|
50
|
+
Object.defineProperty(RoutePresenter, 'name', {
|
|
51
|
+
value: CustomPresenter ? CustomPresenter.name : `${displayedName}${(0, helpers_1.addVersionSuffix)(version)}Presenter`,
|
|
52
|
+
writable: false,
|
|
53
|
+
});
|
|
60
54
|
const routeDecoratorsBuilder = new builders_1.RouteDecoratorsBuilder('UpdateOne', entity, version, description, isPublic, {
|
|
61
55
|
param: RouteParam,
|
|
62
56
|
query: undefined,
|
package/src/version.json
CHANGED