@spinajs/rbac 2.0.26 → 2.0.38

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.
@@ -2,7 +2,7 @@ import { DateTime } from 'luxon';
2
2
  import { ModelBase, Relation } from '@spinajs/orm';
3
3
  import { UserMetadata } from './UserMetadata';
4
4
  /**
5
- * Base modele for users used by ACL
5
+ * Base model for users used by auth and ACL system
6
6
  *
7
7
  * To add / extend fields simply extend this model and register as default user model in ACL service
8
8
  */
@@ -15,7 +15,7 @@ const orm_1 = require("@spinajs/orm");
15
15
  const di_1 = require("@spinajs/di");
16
16
  const UserMetadata_1 = require("./UserMetadata");
17
17
  /**
18
- * Base modele for users used by ACL
18
+ * Base model for users used by auth and ACL system
19
19
  *
20
20
  * To add / extend fields simply extend this model and register as default user model in ACL service
21
21
  */
@@ -4,5 +4,9 @@ export declare class UserMetadata extends ModelBase {
4
4
  Id: number;
5
5
  Key: string;
6
6
  Value: string;
7
+ asBoolean(): boolean;
8
+ asNumber(): number;
9
+ asFloat(): number;
10
+ asJsonObject<T = {}>(): T;
7
11
  User: SingleRelation<User>;
8
12
  }
@@ -12,6 +12,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.UserMetadata = void 0;
13
13
  const orm_1 = require("@spinajs/orm");
14
14
  let UserMetadata = class UserMetadata extends orm_1.ModelBase {
15
+ asBoolean() {
16
+ return this.Value.toLowerCase().trim() === 'true' || this.Value.trim() === '1' ? true : false;
17
+ }
18
+ asNumber() {
19
+ return parseInt(this.Value, 10);
20
+ }
21
+ asFloat() {
22
+ return parseFloat(this.Value);
23
+ }
24
+ asJsonObject() {
25
+ return JSON.parse(this.Value);
26
+ }
15
27
  };
16
28
  __decorate([
17
29
  (0, orm_1.Primary)(),
@@ -1 +1 @@
1
- {"version":3,"file":"UserMetadata.js","sourceRoot":"","sources":["../../src/models/UserMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAgG;AAKhG,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,eAAS;CAU1C,CAAA;AARC;IADC,IAAA,aAAO,GAAE;;wCACQ;AAOlB;IADC,IAAA,eAAS,EAAC,MAAM,CAAC;8BACL,oBAAc;0CAAO;AATvB,YAAY;IAFxB,IAAA,gBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,WAAK,EAAC,gBAAgB,CAAC;GACX,YAAY,CAUxB;AAVY,oCAAY"}
1
+ {"version":3,"file":"UserMetadata.js","sourceRoot":"","sources":["../../src/models/UserMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAgG;AAKhG,IAAa,YAAY,GAAzB,MAAa,YAAa,SAAQ,eAAS;IAQlC,SAAS;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,KAAK,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAChG,CAAC;IAEM,QAAQ;QACb,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IAEM,OAAO;QACZ,OAAO,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IAEM,YAAY;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAM,CAAC;IACrC,CAAC;CAIF,CAAA;AAxBC;IADC,IAAA,aAAO,GAAE;;wCACQ;AAuBlB;IADC,IAAA,eAAS,EAAC,MAAM,CAAC;8BACL,oBAAc;0CAAO;AAzBvB,YAAY;IAFxB,IAAA,gBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,WAAK,EAAC,gBAAgB,CAAC;GACX,YAAY,CA0BxB;AA1BY,oCAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spinajs/rbac",
3
- "version": "2.0.26",
3
+ "version": "2.0.38",
4
4
  "description": "Role and Attribute based Access Control for SpinaJS framework",
5
5
  "main": "lib/index.js",
6
6
  "private": false,
@@ -38,12 +38,12 @@
38
38
  },
39
39
  "homepage": "https://github.com/spinajs/main#readme",
40
40
  "dependencies": {
41
- "@spinajs/configuration": "^2.0.19",
42
- "@spinajs/di": "^2.0.19",
41
+ "@spinajs/configuration": "^2.0.38",
42
+ "@spinajs/di": "^2.0.38",
43
43
  "@spinajs/exceptions": "^2.0.12",
44
- "@spinajs/log": "^2.0.19",
45
- "@spinajs/orm": "^2.0.19",
46
- "@spinajs/reflection": "^2.0.19",
44
+ "@spinajs/log": "^2.0.38",
45
+ "@spinajs/orm": "^2.0.38",
46
+ "@spinajs/reflection": "^2.0.38",
47
47
  "accesscontrol": "^2.2.1",
48
48
  "argon2": "^0.28.5",
49
49
  "entropy-string": "^4.2.0",
@@ -52,7 +52,7 @@
52
52
  "uuid": "^8.1.0"
53
53
  },
54
54
  "devDependencies": {
55
- "@spinajs/orm-sqlite": "^2.0.26"
55
+ "@spinajs/orm-sqlite": "^2.0.38"
56
56
  },
57
- "gitHead": "6cc486b8c6d95f3632767f2796496f9807487508"
57
+ "gitHead": "5ea5440ee9db49595f531592ebdbc6d69f457082"
58
58
  }