mongodb-dynamic-api 2.1.4 → 2.1.6

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  Changelog
2
2
 
3
+ ## [2.1.6](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.5...v2.1.6) (2024-03-31)
4
+
5
+ ## [2.1.5](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.4...v2.1.5) (2024-03-29)
6
+
3
7
  ## [2.1.4](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.3...v2.1.4) (2024-03-29)
4
8
 
5
9
  ## [2.1.3](https://github.com/MikeDev75015/mongodb-dynamic-api/compare/v2.1.2...v2.1.3) (2024-03-29)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mongodb-dynamic-api",
3
- "version": "2.1.4",
3
+ "version": "2.1.6",
4
4
  "description": "Auto generated CRUD API for MongoDB using NestJS",
5
5
  "readmeFilename": "README.md",
6
6
  "main": "index.js",
@@ -84,6 +84,7 @@
84
84
  "eslint-plugin-prettier": "^5.1.3",
85
85
  "jest": "^29.7.0",
86
86
  "jest-junit": "^16.0.0",
87
+ "jest-mock-extended": "^3.0.5",
87
88
  "jest-sonar-reporter": "^2.0.0",
88
89
  "prettier": "^3.2.5",
89
90
  "release-it": "^17.1.1",
@@ -23,6 +23,9 @@ const guards_1 = require("../guards");
23
23
  const auth_register_policies_guard_mixin_1 = require("./auth-register-policies-guard.mixin");
24
24
  function AuthControllerMixin(userEntity, loginField, passwordField, additionalRequestFields = [], { additionalFields: additionalRegisterFields, protected: registerProtected, abilityPredicate: registerAbilityPredicate, } = {}) {
25
25
  var _a;
26
+ if (!loginField || !passwordField) {
27
+ throw new Error('Login and password fields are required');
28
+ }
26
29
  class AuthBodyPasswordFieldDto {
27
30
  }
28
31
  _a = passwordField;
@@ -36,6 +39,9 @@ function AuthControllerMixin(userEntity, loginField, passwordField, additionalRe
36
39
  }
37
40
  const additionalMandatoryFields = [];
38
41
  const additionalOptionalFields = [];
42
+ if (!additionalRegisterFields) {
43
+ additionalRegisterFields = [];
44
+ }
39
45
  additionalRegisterFields.forEach((field) => {
40
46
  if (typeof field === 'string') {
41
47
  additionalOptionalFields.push(field);
@@ -32,10 +32,8 @@ function AuthRegisterPoliciesGuardMixin(entity, abilityPredicate) {
32
32
  if (!user) {
33
33
  throw new common_1.ForbiddenException('Forbidden resource');
34
34
  }
35
- const { can, build } = new ability_1.AbilityBuilder(ability_1.createMongoAbility);
36
- if (abilityPredicate(user)) {
37
- can(registerRouteType, entity);
38
- }
35
+ const { can, build } = new ability_1.AbilityBuilder(ability_1.PureAbility);
36
+ can(registerRouteType, entity, abilityPredicate);
39
37
  const ability = build({
40
38
  detectSubjectType: (object) => object.constructor,
41
39
  });
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "2.1.4"
2
+ "version": "2.1.6"
3
3
  }