easywork-common-lib 1.0.993 → 1.0.996
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/dist/common/@types/enums/permission.enum.d.ts +50 -6
- package/dist/common/@types/enums/permission.enum.js +39 -9
- package/dist/common/@types/enums/permission.enum.js.map +1 -1
- package/dist/entities/permission.entity.d.ts +2 -1
- package/dist/entities/permission.entity.js +11 -9
- package/dist/entities/permission.entity.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -4,10 +4,54 @@ export declare enum Roles {
|
|
|
4
4
|
SUPERVISOR = "SUPERVISOR",
|
|
5
5
|
AUTHOR = "AUTHOR"
|
|
6
6
|
}
|
|
7
|
-
export declare enum
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
export declare enum PermissionAction {
|
|
8
|
+
CREATE = "create",
|
|
9
|
+
READ = "read",
|
|
10
|
+
UPDATE = "update",
|
|
11
|
+
DELETE = "delete",
|
|
12
|
+
MANAGE = "manage",
|
|
13
|
+
ASSIGN = "assign",
|
|
14
|
+
EXPORT = "export",
|
|
15
|
+
IMPORT = "import",
|
|
16
|
+
APPROVE = "approve",
|
|
17
|
+
REJECT = "reject",
|
|
18
|
+
CANCEL = "cancel",
|
|
19
|
+
COMMENT = "comment",
|
|
20
|
+
SHARE = "share",
|
|
21
|
+
ARCHIVE = "archive"
|
|
22
|
+
}
|
|
23
|
+
export declare enum PermissionScope {
|
|
24
|
+
OWN = "own",
|
|
25
|
+
TEAM = "team",
|
|
26
|
+
GROUP = "group",
|
|
27
|
+
ALL = "all",
|
|
28
|
+
ASSIGNED = "assigned",
|
|
29
|
+
SUPERVISED = "supervised"
|
|
30
|
+
}
|
|
31
|
+
export declare enum PermissionCondition {
|
|
32
|
+
ALWAYS = "always",
|
|
33
|
+
OWNER = "owner",
|
|
34
|
+
ASSIGNED_TO = "assignedTo",
|
|
35
|
+
OBSERVER = "observer",
|
|
36
|
+
SAME_GROUP = "sameGroup",
|
|
37
|
+
SAME_TEAM = "sameTeam",
|
|
38
|
+
ROLE_LEVEL = "roleLevel",
|
|
39
|
+
TIME_BASED = "timeBased",
|
|
40
|
+
STATUS_BASED = "statusBased"
|
|
41
|
+
}
|
|
42
|
+
export interface PermissionRule {
|
|
43
|
+
action: PermissionAction;
|
|
44
|
+
scope: PermissionScope;
|
|
45
|
+
conditions?: PermissionCondition[];
|
|
46
|
+
roleLevel?: number;
|
|
47
|
+
customConditions?: Record<string, any>;
|
|
48
|
+
timeRestrictions?: {
|
|
49
|
+
createdWithin?: number;
|
|
50
|
+
modifiedWithin?: number;
|
|
51
|
+
};
|
|
52
|
+
statusRestrictions?: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface ResourcePermission {
|
|
55
|
+
resource: string;
|
|
56
|
+
rules: PermissionRule[];
|
|
13
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PermissionCondition = exports.PermissionScope = exports.PermissionAction = exports.Roles = void 0;
|
|
4
4
|
var Roles;
|
|
5
5
|
(function (Roles) {
|
|
6
6
|
Roles["ADMIN"] = "ADMIN";
|
|
@@ -8,12 +8,42 @@ var Roles;
|
|
|
8
8
|
Roles["SUPERVISOR"] = "SUPERVISOR";
|
|
9
9
|
Roles["AUTHOR"] = "AUTHOR";
|
|
10
10
|
})(Roles || (exports.Roles = Roles = {}));
|
|
11
|
-
var
|
|
12
|
-
(function (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
var PermissionAction;
|
|
12
|
+
(function (PermissionAction) {
|
|
13
|
+
PermissionAction["CREATE"] = "create";
|
|
14
|
+
PermissionAction["READ"] = "read";
|
|
15
|
+
PermissionAction["UPDATE"] = "update";
|
|
16
|
+
PermissionAction["DELETE"] = "delete";
|
|
17
|
+
PermissionAction["MANAGE"] = "manage";
|
|
18
|
+
PermissionAction["ASSIGN"] = "assign";
|
|
19
|
+
PermissionAction["EXPORT"] = "export";
|
|
20
|
+
PermissionAction["IMPORT"] = "import";
|
|
21
|
+
PermissionAction["APPROVE"] = "approve";
|
|
22
|
+
PermissionAction["REJECT"] = "reject";
|
|
23
|
+
PermissionAction["CANCEL"] = "cancel";
|
|
24
|
+
PermissionAction["COMMENT"] = "comment";
|
|
25
|
+
PermissionAction["SHARE"] = "share";
|
|
26
|
+
PermissionAction["ARCHIVE"] = "archive";
|
|
27
|
+
})(PermissionAction || (exports.PermissionAction = PermissionAction = {}));
|
|
28
|
+
var PermissionScope;
|
|
29
|
+
(function (PermissionScope) {
|
|
30
|
+
PermissionScope["OWN"] = "own";
|
|
31
|
+
PermissionScope["TEAM"] = "team";
|
|
32
|
+
PermissionScope["GROUP"] = "group";
|
|
33
|
+
PermissionScope["ALL"] = "all";
|
|
34
|
+
PermissionScope["ASSIGNED"] = "assigned";
|
|
35
|
+
PermissionScope["SUPERVISED"] = "supervised";
|
|
36
|
+
})(PermissionScope || (exports.PermissionScope = PermissionScope = {}));
|
|
37
|
+
var PermissionCondition;
|
|
38
|
+
(function (PermissionCondition) {
|
|
39
|
+
PermissionCondition["ALWAYS"] = "always";
|
|
40
|
+
PermissionCondition["OWNER"] = "owner";
|
|
41
|
+
PermissionCondition["ASSIGNED_TO"] = "assignedTo";
|
|
42
|
+
PermissionCondition["OBSERVER"] = "observer";
|
|
43
|
+
PermissionCondition["SAME_GROUP"] = "sameGroup";
|
|
44
|
+
PermissionCondition["SAME_TEAM"] = "sameTeam";
|
|
45
|
+
PermissionCondition["ROLE_LEVEL"] = "roleLevel";
|
|
46
|
+
PermissionCondition["TIME_BASED"] = "timeBased";
|
|
47
|
+
PermissionCondition["STATUS_BASED"] = "statusBased";
|
|
48
|
+
})(PermissionCondition || (exports.PermissionCondition = PermissionCondition = {}));
|
|
19
49
|
//# sourceMappingURL=permission.enum.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.enum.js","sourceRoot":"","sources":["../../../../src/common/@types/enums/permission.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,KAKX;AALD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;IACb,kCAAyB,CAAA;IACzB,0BAAiB,CAAA;AACnB,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"permission.enum.js","sourceRoot":"","sources":["../../../../src/common/@types/enums/permission.enum.ts"],"names":[],"mappings":";;;AAAA,IAAY,KAKX;AALD,WAAY,KAAK;IACf,wBAAe,CAAA;IACf,sBAAa,CAAA;IACb,kCAAyB,CAAA;IACzB,0BAAiB,CAAA;AACnB,CAAC,EALW,KAAK,qBAAL,KAAK,QAKhB;AAED,IAAY,gBAeX;AAfD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,iCAAa,CAAA;IACb,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;IACnB,mCAAe,CAAA;IACf,uCAAmB,CAAA;AACrB,CAAC,EAfW,gBAAgB,gCAAhB,gBAAgB,QAe3B;AAED,IAAY,eAOX;AAPD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,gCAAa,CAAA;IACb,kCAAe,CAAA;IACf,8BAAW,CAAA;IACX,wCAAqB,CAAA;IACrB,4CAAyB,CAAA;AAC3B,CAAC,EAPW,eAAe,+BAAf,eAAe,QAO1B;AAED,IAAY,mBAUX;AAVD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,sCAAe,CAAA;IACf,iDAA0B,CAAA;IAC1B,4CAAqB,CAAA;IACrB,+CAAwB,CAAA;IACxB,6CAAsB,CAAA;IACtB,+CAAwB,CAAA;IACxB,+CAAwB,CAAA;IACxB,mDAA4B,CAAA;AAC9B,CAAC,EAVW,mBAAmB,mCAAnB,mBAAmB,QAU9B"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { EntityBase } from "../common/database/base.entity";
|
|
2
2
|
import { Role } from "./role.entity";
|
|
3
|
+
import { PermissionRule } from "../common";
|
|
3
4
|
export declare class Permission extends EntityBase {
|
|
4
5
|
resource: string;
|
|
5
|
-
|
|
6
|
+
rules: PermissionRule[];
|
|
6
7
|
roles?: Role[];
|
|
7
8
|
}
|
|
@@ -16,22 +16,25 @@ const role_entity_1 = require("./role.entity");
|
|
|
16
16
|
const swagger_1 = require("@nestjs/swagger");
|
|
17
17
|
let Permission = class Permission extends base_entity_1.EntityBase {
|
|
18
18
|
resource;
|
|
19
|
-
|
|
19
|
+
rules;
|
|
20
20
|
roles;
|
|
21
21
|
};
|
|
22
22
|
exports.Permission = Permission;
|
|
23
23
|
__decorate([
|
|
24
|
-
(0, swagger_1.ApiProperty)({ type: String, description:
|
|
24
|
+
(0, swagger_1.ApiProperty)({ type: String, description: "Resource for the permission" }),
|
|
25
25
|
(0, typeorm_1.Column)(),
|
|
26
26
|
__metadata("design:type", String)
|
|
27
27
|
], Permission.prototype, "resource", void 0);
|
|
28
28
|
__decorate([
|
|
29
|
-
(0, swagger_1.ApiProperty)({ type: String, description:
|
|
30
|
-
(0, typeorm_1.Column)(),
|
|
31
|
-
__metadata("design:type",
|
|
32
|
-
], Permission.prototype, "
|
|
29
|
+
(0, swagger_1.ApiProperty)({ type: String, description: "Rules for the permission" }),
|
|
30
|
+
(0, typeorm_1.Column)({ type: "jsonb", nullable: true }),
|
|
31
|
+
__metadata("design:type", Array)
|
|
32
|
+
], Permission.prototype, "rules", void 0);
|
|
33
33
|
__decorate([
|
|
34
|
-
(0, swagger_1.ApiProperty)({
|
|
34
|
+
(0, swagger_1.ApiProperty)({
|
|
35
|
+
type: () => [role_entity_1.Role],
|
|
36
|
+
description: "Roles associated with the permission",
|
|
37
|
+
}),
|
|
35
38
|
(0, typeorm_1.ManyToMany)(() => role_entity_1.Role, {
|
|
36
39
|
onDelete: "CASCADE",
|
|
37
40
|
onUpdate: "CASCADE",
|
|
@@ -40,7 +43,6 @@ __decorate([
|
|
|
40
43
|
__metadata("design:type", Array)
|
|
41
44
|
], Permission.prototype, "roles", void 0);
|
|
42
45
|
exports.Permission = Permission = __decorate([
|
|
43
|
-
(0, typeorm_1.Entity)()
|
|
44
|
-
(0, typeorm_1.Index)(["resource", "action"], { unique: true })
|
|
46
|
+
(0, typeorm_1.Entity)()
|
|
45
47
|
], Permission);
|
|
46
48
|
//# sourceMappingURL=permission.entity.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permission.entity.js","sourceRoot":"","sources":["../../src/entities/permission.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"permission.entity.js","sourceRoot":"","sources":["../../src/entities/permission.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gEAA4D;AAC5D,qCAAgE;AAChE,+CAAqC;AACrC,6CAA8C;AAIvC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,wBAAU;IAGxC,QAAQ,CAAS;IAIjB,KAAK,CAAmB;IAWxB,KAAK,CAAU;CAChB,CAAA;AAnBY,gCAAU;AAGrB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,6BAA6B,EAAE,CAAC;IACzE,IAAA,gBAAM,GAAE;;4CACQ;AAIjB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;IACtE,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yCAClB;AAWxB;IATC,IAAA,qBAAW,EAAC;QACX,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,kBAAI,CAAC;QAClB,WAAW,EAAE,sCAAsC;KACpD,CAAC;IACD,IAAA,oBAAU,EAAC,GAAG,EAAE,CAAC,kBAAI,EAAE;QACtB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,SAAS;KACpB,CAAC;IACD,IAAA,mBAAS,GAAE;;yCACG;qBAlBJ,UAAU;IADtB,IAAA,gBAAM,GAAE;GACI,UAAU,CAmBtB"}
|