@blimu/nestjs 0.4.5 → 0.4.9
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/config/blimu.config.d.ts +1 -1
- package/dist/config/blimu.config.d.ts.map +1 -1
- package/dist/config/blimu.config.js +1 -1
- package/dist/decorators/entitlement.decorator.d.ts +3 -2
- package/dist/decorators/entitlement.decorator.d.ts.map +1 -1
- package/dist/decorators/entitlement.decorator.js +2 -2
- package/dist/decorators/entitlement.decorator.js.map +1 -1
- package/dist/exceptions/blimu-forbidden.exception.d.ts +11 -0
- package/dist/exceptions/blimu-forbidden.exception.d.ts.map +1 -0
- package/dist/exceptions/blimu-forbidden.exception.js +38 -0
- package/dist/exceptions/blimu-forbidden.exception.js.map +1 -0
- package/dist/guards/entitlement.guard.d.ts +10 -6
- package/dist/guards/entitlement.guard.d.ts.map +1 -1
- package/dist/guards/entitlement.guard.js +16 -15
- package/dist/guards/entitlement.guard.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/modules/blimu.module.d.ts +2 -2
- package/dist/modules/blimu.module.d.ts.map +1 -1
- package/dist/modules/blimu.module.js +15 -12
- package/dist/modules/blimu.module.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/README.md +0 -562
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blimu.config.d.ts","sourceRoot":"","sources":["../../src/config/blimu.config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW,CAAC,QAAQ,GAAG,GAAG;IAIzC,
|
|
1
|
+
{"version":3,"file":"blimu.config.d.ts","sourceRoot":"","sources":["../../src/config/blimu.config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,WAAW,CAAC,QAAQ,GAAG,GAAG;IAIzC,MAAM,EAAE,MAAM,CAAC;IAMf,OAAO,CAAC,EAAE,MAAM,CAAC;IAMjB,aAAa,CAAC,EAAE,MAAM,CAAC;IAMvB,SAAS,CAAC,EAAE,MAAM,CAAC;IA2BnB,SAAS,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC5D;AAKD,eAAO,MAAM,YAAY,eAAyB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EntitlementInfo } from '../guards/entitlement.guard';
|
|
2
|
+
import { Schema } from '@blimu/backend';
|
|
3
|
+
export declare const Entitlement: <TRequest = any>(entitlementKey: Schema.EntitlementType, getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>) => <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
3
4
|
//# sourceMappingURL=entitlement.decorator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/entitlement.decorator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"entitlement.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/entitlement.decorator.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,eAAe,EAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AA0FxC,eAAO,MAAM,WAAW,GAAI,QAAQ,GAAG,GAAG,EACxC,gBAAgB,MAAM,CAAC,eAAe,EACtC,oBAAoB,CAAC,OAAO,EAAE,QAAQ,KAAK,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,gJAMtF,CAAC"}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Entitlement = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
5
|
const entitlement_guard_1 = require("../guards/entitlement.guard");
|
|
6
|
-
const Entitlement = (entitlementKey,
|
|
7
|
-
return (0, common_1.applyDecorators)((0, entitlement_guard_1.SetEntitlementMetadata)(entitlementKey,
|
|
6
|
+
const Entitlement = (entitlementKey, getEntitlementInfo) => {
|
|
7
|
+
return (0, common_1.applyDecorators)((0, entitlement_guard_1.SetEntitlementMetadata)(entitlementKey, getEntitlementInfo), (0, common_1.UseGuards)(entitlement_guard_1.EntitlementGuard));
|
|
8
8
|
};
|
|
9
9
|
exports.Entitlement = Entitlement;
|
|
10
10
|
//# sourceMappingURL=entitlement.decorator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.decorator.js","sourceRoot":"","sources":["../../src/decorators/entitlement.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"entitlement.decorator.js","sourceRoot":"","sources":["../../src/decorators/entitlement.decorator.ts"],"names":[],"mappings":";;;AAAA,2CAA4D;AAC5D,mEAIqC;AA2F9B,MAAM,WAAW,GAAG,CACzB,cAAsC,EACtC,kBAAqF,EACrF,EAAE;IACF,OAAO,IAAA,wBAAe,EACpB,IAAA,0CAAsB,EAAW,cAAc,EAAE,kBAAkB,CAAC,EACpE,IAAA,kBAAS,EAAC,oCAAgB,CAAC,CAC5B,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,WAAW,eAQtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ForbiddenException } from '@nestjs/common';
|
|
2
|
+
import type { Schema } from '@blimu/backend';
|
|
3
|
+
export declare class BlimuForbiddenException extends ForbiddenException {
|
|
4
|
+
readonly entitlementResult: Schema.EntitlementCheckResult;
|
|
5
|
+
readonly entitlementKey: Schema.EntitlementType;
|
|
6
|
+
readonly resourceId: string;
|
|
7
|
+
readonly userId: string;
|
|
8
|
+
constructor(entitlementResult: Schema.EntitlementCheckResult, entitlementKey: Schema.EntitlementType, resourceId: string, userId: string);
|
|
9
|
+
private static buildMessage;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=blimu-forbidden.exception.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blimu-forbidden.exception.d.ts","sourceRoot":"","sources":["../../src/exceptions/blimu-forbidden.exception.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAS7C,qBAAa,uBAAwB,SAAQ,kBAAkB;IAI7D,SAAgB,iBAAiB,EAAE,MAAM,CAAC,sBAAsB,CAAC;IAKjE,SAAgB,cAAc,EAAE,MAAM,CAAC,eAAe,CAAC;IAKvD,SAAgB,UAAU,EAAE,MAAM,CAAC;IAKnC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAG7B,iBAAiB,EAAE,MAAM,CAAC,sBAAsB,EAChD,cAAc,EAAE,MAAM,CAAC,eAAe,EACtC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM;IAsBhB,OAAO,CAAC,MAAM,CAAC,YAAY;CA4B5B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlimuForbiddenException = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
class BlimuForbiddenException extends common_1.ForbiddenException {
|
|
6
|
+
constructor(entitlementResult, entitlementKey, resourceId, userId) {
|
|
7
|
+
const message = BlimuForbiddenException.buildMessage(entitlementResult, entitlementKey);
|
|
8
|
+
super({
|
|
9
|
+
message,
|
|
10
|
+
entitlementResult,
|
|
11
|
+
entitlementKey,
|
|
12
|
+
resourceId,
|
|
13
|
+
userId,
|
|
14
|
+
});
|
|
15
|
+
this.entitlementResult = entitlementResult;
|
|
16
|
+
this.entitlementKey = entitlementKey;
|
|
17
|
+
this.resourceId = resourceId;
|
|
18
|
+
this.userId = userId;
|
|
19
|
+
}
|
|
20
|
+
static buildMessage(result, entitlementKey) {
|
|
21
|
+
const reasons = [];
|
|
22
|
+
if (result.roles && !result.roles.allowed) {
|
|
23
|
+
reasons.push(`Insufficient roles. Required: ${result.roles.allowedRoles?.join(', ') || 'unknown'}. User has: ${result.roles.userRoles?.join(', ') || 'none'}.`);
|
|
24
|
+
}
|
|
25
|
+
if (result.plans && !result.plans.allowed) {
|
|
26
|
+
reasons.push(`Plan restriction. Required plans: ${result.plans.allowedPlans?.join(', ') || 'unknown'}. Current plan: ${result.plans.plan || 'none'}.`);
|
|
27
|
+
}
|
|
28
|
+
if (result.limit && !result.limit.allowed) {
|
|
29
|
+
reasons.push(`Usage limit exceeded. ${result.limit.reason || 'Limit has been reached'}.`);
|
|
30
|
+
}
|
|
31
|
+
if (reasons.length === 0) {
|
|
32
|
+
return `Access denied for entitlement: ${entitlementKey}`;
|
|
33
|
+
}
|
|
34
|
+
return `Access denied for entitlement "${entitlementKey}": ${reasons.join(' ')}`;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BlimuForbiddenException = BlimuForbiddenException;
|
|
38
|
+
//# sourceMappingURL=blimu-forbidden.exception.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blimu-forbidden.exception.js","sourceRoot":"","sources":["../../src/exceptions/blimu-forbidden.exception.ts"],"names":[],"mappings":";;;AAAA,2CAAoD;AAUpD,MAAa,uBAAwB,SAAQ,2BAAkB;IAqB7D,YACE,iBAAgD,EAChD,cAAsC,EACtC,UAAkB,EAClB,MAAc;QAGd,MAAM,OAAO,GAAG,uBAAuB,CAAC,YAAY,CAAC,iBAAiB,EAAE,cAAc,CAAC,CAAC;QAExF,KAAK,CAAC;YACJ,OAAO;YACP,iBAAiB;YACjB,cAAc;YACd,UAAU;YACV,MAAM;SACP,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;QAC3C,IAAI,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 @@
|
|
|
1
|
-
import { CanActivate, ExecutionContext } from
|
|
2
|
-
import { Reflector } from
|
|
3
|
-
import { Blimu, Schema } from
|
|
4
|
-
import type { BlimuConfig } from
|
|
1
|
+
import { CanActivate, ExecutionContext } from '@nestjs/common';
|
|
2
|
+
import { Reflector } from '@nestjs/core';
|
|
3
|
+
import { Blimu, Schema } from '@blimu/backend';
|
|
4
|
+
import type { BlimuConfig } from '../config/blimu.config';
|
|
5
5
|
export declare const ENTITLEMENT_KEY = "entitlement";
|
|
6
6
|
export declare const ENTITLEMENT_METADATA_KEY: unique symbol;
|
|
7
|
+
export interface EntitlementInfo {
|
|
8
|
+
resourceId: string;
|
|
9
|
+
amount?: number;
|
|
10
|
+
}
|
|
7
11
|
export interface EntitlementMetadata<TRequest = any> {
|
|
8
12
|
entitlementKey: Schema.EntitlementType;
|
|
9
|
-
|
|
13
|
+
getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>;
|
|
10
14
|
}
|
|
11
|
-
export declare const SetEntitlementMetadata: <TRequest = any>(entitlementKey: string,
|
|
15
|
+
export declare const SetEntitlementMetadata: <TRequest = any>(entitlementKey: string, getEntitlementInfo: (request: TRequest) => EntitlementInfo | Promise<EntitlementInfo>) => import("@nestjs/common").CustomDecorator<typeof ENTITLEMENT_METADATA_KEY>;
|
|
12
16
|
export declare class EntitlementGuard<TRequest = any> implements CanActivate {
|
|
13
17
|
private readonly reflector;
|
|
14
18
|
private readonly config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.guard.d.ts","sourceRoot":"","sources":["../../src/guards/entitlement.guard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,gBAAgB,EAKjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,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CAAC;CA4D/D"}
|
|
@@ -17,11 +17,12 @@ const common_1 = require("@nestjs/common");
|
|
|
17
17
|
const core_1 = require("@nestjs/core");
|
|
18
18
|
const backend_1 = require("@blimu/backend");
|
|
19
19
|
const blimu_config_1 = require("../config/blimu.config");
|
|
20
|
-
|
|
21
|
-
exports.
|
|
22
|
-
|
|
20
|
+
const blimu_forbidden_exception_1 = require("../exceptions/blimu-forbidden.exception");
|
|
21
|
+
exports.ENTITLEMENT_KEY = 'entitlement';
|
|
22
|
+
exports.ENTITLEMENT_METADATA_KEY = Symbol('entitlement');
|
|
23
|
+
const SetEntitlementMetadata = (entitlementKey, getEntitlementInfo) => (0, common_1.SetMetadata)(exports.ENTITLEMENT_METADATA_KEY, {
|
|
23
24
|
entitlementKey,
|
|
24
|
-
|
|
25
|
+
getEntitlementInfo,
|
|
25
26
|
});
|
|
26
27
|
exports.SetEntitlementMetadata = SetEntitlementMetadata;
|
|
27
28
|
let EntitlementGuard = class EntitlementGuard {
|
|
@@ -41,33 +42,33 @@ let EntitlementGuard = class EntitlementGuard {
|
|
|
41
42
|
userId = await this.config.getUserId(request);
|
|
42
43
|
}
|
|
43
44
|
catch (error) {
|
|
44
|
-
throw new common_1.ForbiddenException(
|
|
45
|
+
throw new common_1.ForbiddenException('Failed to extract user ID from request');
|
|
45
46
|
}
|
|
46
47
|
if (!userId) {
|
|
47
|
-
throw new common_1.ForbiddenException(
|
|
48
|
+
throw new common_1.ForbiddenException('User ID is required for entitlement check');
|
|
48
49
|
}
|
|
49
|
-
const
|
|
50
|
-
if (!resourceId) {
|
|
51
|
-
throw new common_1.ForbiddenException(
|
|
50
|
+
const entitlementInfo = await metadata.getEntitlementInfo(request);
|
|
51
|
+
if (!entitlementInfo || !entitlementInfo.resourceId) {
|
|
52
|
+
throw new common_1.ForbiddenException('Resource ID is required for entitlement check');
|
|
52
53
|
}
|
|
53
54
|
try {
|
|
54
55
|
const result = await this.runtime.entitlements.checkEntitlement({
|
|
55
56
|
userId,
|
|
56
57
|
entitlement: metadata.entitlementKey,
|
|
57
|
-
resourceId,
|
|
58
|
+
resourceId: entitlementInfo.resourceId,
|
|
59
|
+
amount: entitlementInfo.amount,
|
|
58
60
|
});
|
|
59
61
|
if (!result.allowed) {
|
|
60
|
-
throw new
|
|
61
|
-
`User does not have required entitlement: ${metadata.entitlementKey}`);
|
|
62
|
+
throw new blimu_forbidden_exception_1.BlimuForbiddenException(result, metadata.entitlementKey, entitlementInfo.resourceId, userId);
|
|
62
63
|
}
|
|
63
64
|
return true;
|
|
64
65
|
}
|
|
65
66
|
catch (error) {
|
|
66
|
-
if (error instanceof common_1.ForbiddenException) {
|
|
67
|
+
if (error instanceof blimu_forbidden_exception_1.BlimuForbiddenException || error instanceof common_1.ForbiddenException) {
|
|
67
68
|
throw error;
|
|
68
69
|
}
|
|
69
|
-
console.error(
|
|
70
|
-
throw new common_1.ForbiddenException(
|
|
70
|
+
console.error('Entitlement check failed:', error);
|
|
71
|
+
throw new common_1.ForbiddenException('Failed to verify entitlements');
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entitlement.guard.js","sourceRoot":"","sources":["../../src/guards/entitlement.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,uCAAyC;AACzC,4CAA+C;AAE/C,yDAAsD;
|
|
1
|
+
{"version":3,"file":"entitlement.guard.js","sourceRoot":"","sources":["../../src/guards/entitlement.guard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAOwB;AACxB,uCAAyC;AACzC,4CAA+C;AAE/C,yDAAsD;AACtD,uFAAkF;AAErE,QAAA,eAAe,GAAG,aAAa,CAAC;AAChC,QAAA,wBAAwB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAsBvD,MAAM,sBAAsB,GAAG,CACpC,cAAsB,EACtB,kBAAqF,EACrF,EAAE,CACF,IAAA,oBAAW,EAAC,gCAA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,EAAE,QAAQ,CAAC,cAAc;gBACpC,UAAU,EAAE,eAAe,CAAC,UAAU;gBACtC,MAAM,EAAE,eAAe,CAAC,MAAM;aAC/B,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,IAAI,mDAAuB,CAC/B,MAAM,EACN,QAAQ,CAAC,cAAc,EACvB,eAAe,CAAC,UAAU,EAC1B,MAAM,CACP,CAAC;YACJ,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,mDAAuB,IAAI,KAAK,YAAY,2BAAkB,EAAE,CAAC;gBACpF,MAAM,KAAK,CAAC;YACd,CAAC;YAGD,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;YAClD,MAAM,IAAI,2BAAkB,CAAC,+BAA+B,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;CACF,CAAA;AArEY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAIR,WAAA,IAAA,eAAM,EAAC,2BAAY,CAAC,CAAA;IAEpB,WAAA,IAAA,eAAM,EAAC,eAAK,CAAC,CAAA;qCAHc,gBAAS,UAIX,eAAK;GANtB,gBAAgB,CAqE5B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from './modules/blimu.module';
|
|
2
|
+
export * from './config/blimu.config';
|
|
3
|
+
export * from './guards/entitlement.guard';
|
|
4
|
+
export * from './decorators/entitlement.decorator';
|
|
5
|
+
export * from './exceptions/blimu-forbidden.exception';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AAGvC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,wBAAwB,CAAC;AAGvC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,oCAAoC,CAAC;AAGnD,cAAc,wCAAwC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -18,4 +18,5 @@ __exportStar(require("./modules/blimu.module"), exports);
|
|
|
18
18
|
__exportStar(require("./config/blimu.config"), exports);
|
|
19
19
|
__exportStar(require("./guards/entitlement.guard"), exports);
|
|
20
20
|
__exportStar(require("./decorators/entitlement.decorator"), exports);
|
|
21
|
+
__exportStar(require("./exceptions/blimu-forbidden.exception"), exports);
|
|
21
22
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yDAAuC;AAGvC,wDAAsC;AAGtC,6DAA2C;AAG3C,qEAAmD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,yDAAuC;AAGvC,wDAAsC;AAGtC,6DAA2C;AAG3C,qEAAmD;AAGnD,yEAAuD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DynamicModule, Type, ForwardReference, InjectionToken, OptionalFactoryDependency } from
|
|
2
|
-
import type { BlimuConfig } from
|
|
1
|
+
import { DynamicModule, Type, ForwardReference, InjectionToken, OptionalFactoryDependency } from '@nestjs/common';
|
|
2
|
+
import type { BlimuConfig } from '../config/blimu.config';
|
|
3
3
|
export declare class BlimuModule {
|
|
4
4
|
static forRoot<TRequest = any>(config: BlimuConfig<TRequest>): DynamicModule;
|
|
5
5
|
static forRootAsync<TRequest = any>(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blimu.module.d.ts","sourceRoot":"","sources":["../../src/modules/blimu.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"blimu.module.d.ts","sourceRoot":"","sources":["../../src/modules/blimu.module.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EAEb,IAAI,EACJ,gBAAgB,EAChB,cAAc,EACd,yBAAyB,EAC1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAU1D,qBACa,WAAW;IA0CtB,MAAM,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,GAAG,aAAa;IA0G5E,MAAM,CAAC,YAAY,CAAC,QAAQ,GAAG,GAAG,EAAE,OAAO,EAAE;QAC3C,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC3F,MAAM,CAAC,EAAE,KAAK,CAAC,cAAc,GAAG,yBAAyB,CAAC,CAAC;QAC3D,OAAO,CAAC,EAAE,KAAK,CACb,IAAI,CAAC,OAAO,CAAC,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,GAAG,gBAAgB,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,CAC/F,CAAC;KACH,GAAG,aAAa;CAwClB"}
|
|
@@ -9,6 +9,7 @@ var BlimuModule_1;
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.BlimuModule = void 0;
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
|
+
const core_1 = require("@nestjs/core");
|
|
12
13
|
const entitlement_guard_1 = require("../guards/entitlement.guard");
|
|
13
14
|
const blimu_config_1 = require("../config/blimu.config");
|
|
14
15
|
const backend_1 = require("@blimu/backend");
|
|
@@ -18,28 +19,29 @@ let BlimuModule = BlimuModule_1 = class BlimuModule {
|
|
|
18
19
|
module: BlimuModule_1,
|
|
19
20
|
global: true,
|
|
20
21
|
providers: [
|
|
22
|
+
core_1.Reflector,
|
|
23
|
+
entitlement_guard_1.EntitlementGuard,
|
|
21
24
|
{
|
|
22
25
|
provide: blimu_config_1.BLIMU_CONFIG,
|
|
23
26
|
useValue: {
|
|
24
|
-
|
|
25
|
-
baseURL: config.baseURL ||
|
|
27
|
+
apiKey: config.apiKey,
|
|
28
|
+
baseURL: config.baseURL || 'https://runtime.blimu.com',
|
|
26
29
|
environmentId: config.environmentId,
|
|
27
30
|
timeoutMs: config.timeoutMs ?? 30000,
|
|
28
31
|
getUserId: config.getUserId,
|
|
29
32
|
},
|
|
30
33
|
},
|
|
31
|
-
entitlement_guard_1.EntitlementGuard,
|
|
32
34
|
{
|
|
33
35
|
provide: backend_1.Blimu,
|
|
34
36
|
useFactory: (config) => new backend_1.Blimu({
|
|
35
|
-
|
|
36
|
-
baseURL: config.baseURL ||
|
|
37
|
+
apiKey: config.apiKey,
|
|
38
|
+
baseURL: config.baseURL || 'https://runtime.blimu.com',
|
|
37
39
|
timeoutMs: config.timeoutMs ?? 30000,
|
|
38
40
|
}),
|
|
39
41
|
inject: [blimu_config_1.BLIMU_CONFIG],
|
|
40
42
|
},
|
|
41
43
|
],
|
|
42
|
-
exports: [entitlement_guard_1.EntitlementGuard, backend_1.Blimu, blimu_config_1.BLIMU_CONFIG],
|
|
44
|
+
exports: [core_1.Reflector, entitlement_guard_1.EntitlementGuard, backend_1.Blimu, blimu_config_1.BLIMU_CONFIG],
|
|
43
45
|
};
|
|
44
46
|
}
|
|
45
47
|
static forRootAsync(options) {
|
|
@@ -49,13 +51,15 @@ let BlimuModule = BlimuModule_1 = class BlimuModule {
|
|
|
49
51
|
global: true,
|
|
50
52
|
imports: [...additionalImports],
|
|
51
53
|
providers: [
|
|
54
|
+
core_1.Reflector,
|
|
55
|
+
entitlement_guard_1.EntitlementGuard,
|
|
52
56
|
{
|
|
53
57
|
provide: blimu_config_1.BLIMU_CONFIG,
|
|
54
58
|
useFactory: async (...args) => {
|
|
55
59
|
const config = await options.useFactory(...args);
|
|
56
60
|
return {
|
|
57
|
-
|
|
58
|
-
baseURL: config.baseURL ||
|
|
61
|
+
apiKey: config.apiKey,
|
|
62
|
+
baseURL: config.baseURL || 'https://runtime.blimu.com',
|
|
59
63
|
environmentId: config.environmentId,
|
|
60
64
|
timeoutMs: config.timeoutMs ?? 30000,
|
|
61
65
|
getUserId: config.getUserId,
|
|
@@ -63,18 +67,17 @@ let BlimuModule = BlimuModule_1 = class BlimuModule {
|
|
|
63
67
|
},
|
|
64
68
|
inject: options.inject,
|
|
65
69
|
},
|
|
66
|
-
entitlement_guard_1.EntitlementGuard,
|
|
67
70
|
{
|
|
68
71
|
provide: backend_1.Blimu,
|
|
69
72
|
useFactory: (config) => new backend_1.Blimu({
|
|
70
|
-
|
|
71
|
-
baseURL: config.baseURL ||
|
|
73
|
+
apiKey: config.apiKey,
|
|
74
|
+
baseURL: config.baseURL || 'https://runtime.blimu.com',
|
|
72
75
|
timeoutMs: config.timeoutMs ?? 30000,
|
|
73
76
|
}),
|
|
74
77
|
inject: [blimu_config_1.BLIMU_CONFIG],
|
|
75
78
|
},
|
|
76
79
|
],
|
|
77
|
-
exports: [entitlement_guard_1.EntitlementGuard, backend_1.Blimu, blimu_config_1.BLIMU_CONFIG],
|
|
80
|
+
exports: [core_1.Reflector, entitlement_guard_1.EntitlementGuard, backend_1.Blimu, blimu_config_1.BLIMU_CONFIG],
|
|
78
81
|
};
|
|
79
82
|
}
|
|
80
83
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blimu.module.js","sourceRoot":"","sources":["../../src/modules/blimu.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,mEAA+D;AAE/D,yDAAsD;AACtD,4CAAuC;AAShC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IA0CtB,MAAM,CAAC,OAAO,CAAiB,MAA6B;QAC1D,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,2BAAY;oBACrB,QAAQ,EAAE;wBACR,
|
|
1
|
+
{"version":3,"file":"blimu.module.js","sourceRoot":"","sources":["../../src/modules/blimu.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAOwB;AACxB,uCAAyC;AACzC,mEAA+D;AAE/D,yDAAsD;AACtD,4CAAuC;AAShC,IAAM,WAAW,mBAAjB,MAAM,WAAW;IA0CtB,MAAM,CAAC,OAAO,CAAiB,MAA6B;QAC1D,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT,gBAAS;gBACT,oCAAgB;gBAChB;oBACE,OAAO,EAAE,2BAAY;oBACrB,QAAQ,EAAE;wBACR,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,2BAA2B;wBACtD,aAAa,EAAE,MAAM,CAAC,aAAa;wBACnC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;wBACpC,SAAS,EAAE,MAAM,CAAC,SAAS;qBAC5B;iBACF;gBACD;oBACE,OAAO,EAAE,eAAK;oBACd,UAAU,EAAE,CAAC,MAAmB,EAAE,EAAE,CAClC,IAAI,eAAK,CAAC;wBACR,MAAM,EAAE,MAAM,CAAC,MAAM;wBACrB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,2BAA2B;wBACtD,SAAS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