@nest-boot/permission 7.2.0 → 8.0.0-beta.0
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/decorators/can.decorator.d.ts +4 -4
- package/dist/decorators/can.decorator.js +5 -8
- package/dist/decorators/can.decorator.js.map +1 -1
- package/dist/enums/permission-action.enum.js +2 -5
- package/dist/enums/permission-action.enum.js.map +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.js +16 -32
- package/dist/index.js.map +1 -1
- package/dist/interfaces/can-options.interface.d.ts +2 -2
- package/dist/interfaces/can-options.interface.js +1 -2
- package/dist/interfaces/permission-module-options.interface.d.ts +1 -1
- package/dist/interfaces/permission-module-options.interface.js +1 -2
- package/dist/interfaces/route-argument-metadata-value.interface.js +1 -2
- package/dist/permission.ability-builder.d.ts +1 -1
- package/dist/permission.ability-builder.js +3 -7
- package/dist/permission.ability-builder.js.map +1 -1
- package/dist/permission.constants.js +7 -10
- package/dist/permission.constants.js.map +1 -1
- package/dist/permission.guard.d.ts +1 -1
- package/dist/permission.guard.js +39 -39
- package/dist/permission.guard.js.map +1 -1
- package/dist/permission.module-definition.d.ts +1 -1
- package/dist/permission.module-definition.js +4 -7
- package/dist/permission.module-definition.js.map +1 -1
- package/dist/permission.module.d.ts +1 -1
- package/dist/permission.module.js +10 -13
- package/dist/permission.module.js.map +1 -1
- package/dist/types/build-ability-callback.type.d.ts +1 -1
- package/dist/types/build-ability-callback.type.js +1 -2
- package/dist/types/can-subject-factory.type.js +1 -2
- package/dist/types/can-subject.type.d.ts +1 -1
- package/dist/types/can-subject.type.js +1 -2
- package/dist/types/permission-ability.type.d.ts +1 -1
- package/dist/types/permission-ability.type.js +1 -2
- package/dist/types/route-argument-metadata.type.d.ts +1 -1
- package/dist/types/route-argument-metadata.type.js +1 -2
- package/dist/utils/can.util.d.ts +1 -1
- package/dist/utils/can.util.js +3 -6
- package/dist/utils/can.util.js.map +1 -1
- package/dist/utils/get-permission-ability.util.d.ts +1 -1
- package/dist/utils/get-permission-ability.util.js +6 -10
- package/dist/utils/get-permission-ability.util.js.map +1 -1
- package/package.json +21 -24
- package/dist/decorators/can.decorator.spec.d.ts +0 -1
- package/dist/decorators/can.decorator.spec.js +0 -50
- package/dist/decorators/can.decorator.spec.js.map +0 -1
- package/dist/index.spec.d.ts +0 -0
- package/dist/index.spec.js +0 -47
- package/dist/index.spec.js.map +0 -1
- package/dist/permission.ability-builder.spec.d.ts +0 -1
- package/dist/permission.ability-builder.spec.js +0 -16
- package/dist/permission.ability-builder.spec.js.map +0 -1
- package/dist/permission.guard.spec.d.ts +0 -1
- package/dist/permission.guard.spec.js +0 -577
- package/dist/permission.guard.spec.js.map +0 -1
- package/dist/permission.module.spec.d.ts +0 -1
- package/dist/permission.module.spec.js +0 -12
- package/dist/permission.module.spec.js.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- package/dist/utils/can.util.spec.d.ts +0 -1
- package/dist/utils/can.util.spec.js +0 -34
- package/dist/utils/can.util.spec.js.map +0 -1
- package/dist/utils/get-permission-ability.util.spec.d.ts +0 -1
- package/dist/utils/get-permission-ability.util.spec.js +0 -27
- package/dist/utils/get-permission-ability.util.spec.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Subject } from "@casl/ability";
|
|
2
2
|
import type { Type } from "@nestjs/common";
|
|
3
|
-
import type { CanSubjectFactory } from "./can-subject-factory.type";
|
|
3
|
+
import type { CanSubjectFactory } from "./can-subject-factory.type.js";
|
|
4
4
|
/** Permission subject type or subject resolver factory. */
|
|
5
5
|
export type CanSubject<T extends Subject = Subject> = Type<T> | CanSubjectFactory<T>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { MongoAbility, Subject } from "@casl/ability";
|
|
2
|
-
import type { PermissionAction } from "../enums/permission-action.enum";
|
|
2
|
+
import type { PermissionAction } from "../enums/permission-action.enum.js";
|
|
3
3
|
/** CASL ability type used by the permission module. */
|
|
4
4
|
export type PermissionAbility = MongoAbility<[PermissionAction, Subject]>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RouteArgumentMetadataValue } from "../interfaces/route-argument-metadata-value.interface";
|
|
1
|
+
import type { RouteArgumentMetadataValue } from "../interfaces/route-argument-metadata-value.interface.js";
|
|
2
2
|
/** Nest route arguments metadata map keyed by route parameter metadata token. */
|
|
3
3
|
export type RouteArgumentMetadata = Record<string, RouteArgumentMetadataValue>;
|
package/dist/utils/can.util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Subject } from "@casl/ability";
|
|
2
|
-
import type { PermissionAction } from "../enums/permission-action.enum";
|
|
2
|
+
import type { PermissionAction } from "../enums/permission-action.enum.js";
|
|
3
3
|
/** Checks a permission with the ability prepared for the current request. */
|
|
4
4
|
export declare function can(action: PermissionAction, subject: Subject): boolean;
|
package/dist/utils/can.util.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.can = can;
|
|
4
|
-
const get_permission_ability_util_1 = require("./get-permission-ability.util");
|
|
1
|
+
import { getPermissionAbility } from "./get-permission-ability.util.js";
|
|
5
2
|
/** Checks a permission with the ability prepared for the current request. */
|
|
6
|
-
function can(action, subject) {
|
|
7
|
-
return
|
|
3
|
+
export function can(action, subject) {
|
|
4
|
+
return getPermissionAbility().can(action, subject);
|
|
8
5
|
}
|
|
9
6
|
//# sourceMappingURL=can.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,6EAA6E;AAC7E,MAAM,UAAU,GAAG,CAAC,MAAwB,EAAE,OAAgB;IAC5D,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { PermissionAbility } from "../types/permission-ability.type";
|
|
1
|
+
import type { PermissionAbility } from "../types/permission-ability.type.js";
|
|
2
2
|
/** Reads the permission ability prepared for the current request. */
|
|
3
3
|
export declare const getPermissionAbility: () => PermissionAbility;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const request_context_1 = require("@nest-boot/request-context");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const permission_constants_1 = require("../permission.constants");
|
|
1
|
+
import { RequestContext } from "@nest-boot/request-context";
|
|
2
|
+
import { ForbiddenException } from "@nestjs/common";
|
|
3
|
+
import { PERMISSION_ABILITY } from "../permission.constants.js";
|
|
7
4
|
/** Reads the permission ability prepared for the current request. */
|
|
8
|
-
const getPermissionAbility = () => {
|
|
9
|
-
const ability =
|
|
5
|
+
export const getPermissionAbility = () => {
|
|
6
|
+
const ability = RequestContext.get(PERMISSION_ABILITY) ?? null;
|
|
10
7
|
if (!ability) {
|
|
11
|
-
throw new
|
|
8
|
+
throw new ForbiddenException("Permission ability is not available");
|
|
12
9
|
}
|
|
13
10
|
return ability;
|
|
14
11
|
};
|
|
15
|
-
exports.getPermissionAbility = getPermissionAbility;
|
|
16
12
|
//# sourceMappingURL=get-permission-ability.util.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-permission-ability.util.js","sourceRoot":"","sources":["../../src/utils/get-permission-ability.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-permission-ability.util.js","sourceRoot":"","sources":["../../src/utils/get-permission-ability.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,qEAAqE;AACrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAsB,EAAE;IAC1D,MAAM,OAAO,GACX,cAAc,CAAC,GAAG,CAAoB,kBAAkB,CAAC,IAAI,IAAI,CAAC;IAEpE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAAC,qCAAqC,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-boot/permission",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/nest-boot/nest-boot.git",
|
|
@@ -24,32 +24,31 @@
|
|
|
24
24
|
],
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@casl/ability": "^6.0.0",
|
|
27
|
-
"@
|
|
28
|
-
"@nestjs/
|
|
29
|
-
"@nestjs/core": "^11.0.0",
|
|
27
|
+
"@nestjs/common": "^12.0.0-alpha.5",
|
|
28
|
+
"@nestjs/core": "^12.0.0-alpha.5",
|
|
30
29
|
"express": "^5.0.0",
|
|
31
30
|
"reflect-metadata": "^0.2.2",
|
|
32
|
-
"rxjs": "^7.0.0"
|
|
31
|
+
"rxjs": "^7.0.0",
|
|
32
|
+
"@nest-boot/request-context": "^8.0.0-beta.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@casl/ability": "^6.7.5",
|
|
36
|
-
"@nestjs/common": "
|
|
37
|
-
"@nestjs/core": "
|
|
38
|
-
"@nestjs/testing": "
|
|
36
|
+
"@nestjs/common": "next",
|
|
37
|
+
"@nestjs/core": "next",
|
|
38
|
+
"@nestjs/testing": "next",
|
|
39
39
|
"@types/express": "^5.0.3",
|
|
40
|
-
"@types/
|
|
41
|
-
"@
|
|
40
|
+
"@types/node": "^26.0.0",
|
|
41
|
+
"@vitest/coverage-v8": "^4.1.2",
|
|
42
42
|
"eslint": "^9.39.3",
|
|
43
43
|
"express": "^5.1.0",
|
|
44
|
-
"jest": "^29.7.0",
|
|
45
44
|
"reflect-metadata": "^0.2.2",
|
|
46
45
|
"rxjs": "^7.8.2",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"@nest-boot/eslint-config": "^
|
|
50
|
-
"@nest-boot/eslint-plugin": "^
|
|
51
|
-
"@nest-boot/
|
|
52
|
-
"@nest-boot/
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vitest": "^4.1.2",
|
|
48
|
+
"@nest-boot/eslint-config": "^8.0.0-beta.0",
|
|
49
|
+
"@nest-boot/eslint-plugin": "^8.0.0-beta.0",
|
|
50
|
+
"@nest-boot/tsconfig": "^8.0.0-beta.0",
|
|
51
|
+
"@nest-boot/request-context": "^8.0.0-beta.0"
|
|
53
52
|
},
|
|
54
53
|
"publishConfig": {
|
|
55
54
|
"access": "public"
|
|
@@ -60,18 +59,16 @@
|
|
|
60
59
|
"eslint --fix"
|
|
61
60
|
]
|
|
62
61
|
},
|
|
63
|
-
"
|
|
64
|
-
"extends": "../../package.json"
|
|
65
|
-
},
|
|
62
|
+
"type": "module",
|
|
66
63
|
"scripts": {
|
|
67
64
|
"build": "tsc -p tsconfig.build.json",
|
|
68
65
|
"clean": "rm -rf .nx && rm -rf node_modules && rm -rf dist",
|
|
69
66
|
"dev": "tsc -w -p tsconfig.build.json",
|
|
70
67
|
"lint": "eslint \"{src,test}/**/*.ts\"",
|
|
71
68
|
"lint:fix": "eslint \"{src,test}/**/*.ts\" --fix",
|
|
72
|
-
"test": "
|
|
73
|
-
"test:cov": "
|
|
74
|
-
"test:watch": "
|
|
75
|
-
"test:debug": "
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"test:cov": "vitest run --coverage",
|
|
71
|
+
"test:watch": "vitest",
|
|
72
|
+
"test:debug": "vitest --inspect-brk --no-file-parallelism"
|
|
76
73
|
}
|
|
77
74
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const common_1 = require("@nestjs/common");
|
|
4
|
-
const permission_action_enum_1 = require("../enums/permission-action.enum");
|
|
5
|
-
const permission_constants_1 = require("../permission.constants");
|
|
6
|
-
const can_decorator_1 = require("./can.decorator");
|
|
7
|
-
jest.mock("@nestjs/common", () => ({
|
|
8
|
-
SetMetadata: jest.fn((key, value) => ({ key, value })),
|
|
9
|
-
}));
|
|
10
|
-
class Subject {
|
|
11
|
-
}
|
|
12
|
-
describe("Can", () => {
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
jest.mocked(common_1.SetMetadata).mockClear();
|
|
15
|
-
});
|
|
16
|
-
it("stores action and subject metadata from positional arguments", () => {
|
|
17
|
-
expect((0, can_decorator_1.Can)(permission_action_enum_1.PermissionAction.READ, Subject)).toEqual({
|
|
18
|
-
key: permission_constants_1.CAN_METADATA,
|
|
19
|
-
value: {
|
|
20
|
-
action: permission_action_enum_1.PermissionAction.READ,
|
|
21
|
-
subject: Subject,
|
|
22
|
-
},
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
it("stores subject factory as positional subject argument", () => {
|
|
26
|
-
const subjectFactory = jest.fn();
|
|
27
|
-
expect((0, can_decorator_1.Can)(permission_action_enum_1.PermissionAction.READ, subjectFactory)).toEqual({
|
|
28
|
-
key: permission_constants_1.CAN_METADATA,
|
|
29
|
-
value: {
|
|
30
|
-
action: permission_action_enum_1.PermissionAction.READ,
|
|
31
|
-
subject: subjectFactory,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
it("stores full permission options when an options object is provided", () => {
|
|
36
|
-
const options = {
|
|
37
|
-
action: permission_action_enum_1.PermissionAction.UPDATE,
|
|
38
|
-
subject: Subject,
|
|
39
|
-
};
|
|
40
|
-
expect((0, can_decorator_1.Can)(options)).toEqual({
|
|
41
|
-
key: permission_constants_1.CAN_METADATA,
|
|
42
|
-
value: options,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
it("throws when positional arguments omit the subject", () => {
|
|
46
|
-
expect(() => (0, can_decorator_1.Can)(permission_action_enum_1.PermissionAction.READ)).toThrow("Permission subject is required.");
|
|
47
|
-
expect(common_1.SetMetadata).not.toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=can.decorator.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"can.decorator.spec.js","sourceRoot":"","sources":["../../src/decorators/can.decorator.spec.ts"],"names":[],"mappings":";;AAAA,2CAA6C;AAE7C,4EAAmE;AACnE,kEAAuD;AACvD,mDAAsC;AAEtC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,EAAE,CAAC,CAAC;IACjC,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;CACvD,CAAC,CAAC,CAAC;AAEJ,MAAM,OAAO;CAAG;AAEhB,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE;IACnB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,MAAM,CAAC,oBAAW,CAAC,CAAC,SAAS,EAAE,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,CAAC,IAAA,mBAAG,EAAC,yCAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;YAClD,GAAG,EAAE,mCAAY;YACjB,KAAK,EAAE;gBACL,MAAM,EAAE,yCAAgB,CAAC,IAAI;gBAC7B,OAAO,EAAE,OAAO;aACjB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAEjC,MAAM,CAAC,IAAA,mBAAG,EAAC,yCAAgB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC;YACzD,GAAG,EAAE,mCAAY;YACjB,KAAK,EAAE;gBACL,MAAM,EAAE,yCAAgB,CAAC,IAAI;gBAC7B,OAAO,EAAE,cAAc;aACxB;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,yCAAgB,CAAC,MAAM;YAC/B,OAAO,EAAE,OAAO;SACjB,CAAC;QAEF,MAAM,CAAC,IAAA,mBAAG,EAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;YAC3B,GAAG,EAAE,mCAAY;YACjB,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,mDAAmD,EAAE,GAAG,EAAE;QAC3D,MAAM,CAAC,GAAG,EAAE,CAAC,IAAA,mBAAG,EAAC,yCAAgB,CAAC,IAAa,CAAC,CAAC,CAAC,OAAO,CACvD,iCAAiC,CAClC,CAAC;QACF,MAAM,CAAC,oBAAW,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.spec.d.ts
DELETED
|
File without changes
|
package/dist/index.spec.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
describe("public API", () => {
|
|
36
|
-
it("should export permission package APIs", async () => {
|
|
37
|
-
const api = await Promise.resolve().then(() => __importStar(require(".")));
|
|
38
|
-
expect(api.Can).toBeDefined();
|
|
39
|
-
expect(api.PermissionAction).toBeDefined();
|
|
40
|
-
expect(api.PermissionAbilityBuilder).toBeDefined();
|
|
41
|
-
expect(api.PermissionGuard).toBeDefined();
|
|
42
|
-
expect(api.PermissionModule).toBeDefined();
|
|
43
|
-
expect(api.can).toBeDefined();
|
|
44
|
-
expect(api.getPermissionAbility).toBeDefined();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=index.spec.js.map
|
package/dist/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../src/index.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,GAAG,GAAG,wDAAa,GAAG,GAAC,CAAC;QAE9B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC,WAAW,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1C,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,WAAW,EAAE,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const permission_action_enum_1 = require("./enums/permission-action.enum");
|
|
4
|
-
const permission_ability_builder_1 = require("./permission.ability-builder");
|
|
5
|
-
class Post {
|
|
6
|
-
}
|
|
7
|
-
describe("PermissionAbilityBuilder", () => {
|
|
8
|
-
it("should build a CASL mongo ability", () => {
|
|
9
|
-
const builder = new permission_ability_builder_1.PermissionAbilityBuilder();
|
|
10
|
-
builder.can(permission_action_enum_1.PermissionAction.READ, Post);
|
|
11
|
-
const ability = builder.build();
|
|
12
|
-
expect(ability.can(permission_action_enum_1.PermissionAction.READ, Post)).toBe(true);
|
|
13
|
-
expect(ability.can(permission_action_enum_1.PermissionAction.DELETE, Post)).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=permission.ability-builder.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"permission.ability-builder.spec.js","sourceRoot":"","sources":["../src/permission.ability-builder.spec.ts"],"names":[],"mappings":";;AAAA,2EAAkE;AAClE,6EAAwE;AAExE,MAAM,IAAI;CAAG;AAEb,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;QAC3C,MAAM,OAAO,GAAG,IAAI,qDAAwB,EAAE,CAAC;QAE/C,OAAO,CAAC,GAAG,CAAC,yCAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACzC,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;QAEhC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,yCAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,yCAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|