@open-rlb/nestjs-amqp 1.0.27 → 2.0.1
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/README.md +572 -169
- package/amqp-lib/amqp/connection.d.ts +1 -1
- package/common/errors.d.ts +13 -0
- package/common/errors.js +26 -0
- package/common/errors.js.map +1 -0
- package/common/flatten.util.d.ts +1 -0
- package/common/flatten.util.js +29 -0
- package/common/flatten.util.js.map +1 -0
- package/common/index.d.ts +3 -0
- package/common/index.js +20 -0
- package/common/index.js.map +1 -0
- package/common/pagination.model.d.ts +6 -0
- package/common/pagination.model.js +3 -0
- package/common/pagination.model.js.map +1 -0
- package/index.d.ts +3 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/modules/acl/acl.module.d.ts +5 -0
- package/modules/acl/acl.module.js +36 -0
- package/modules/acl/acl.module.js.map +1 -0
- package/modules/acl/cache/acl-cache.service.d.ts +15 -0
- package/modules/acl/cache/acl-cache.service.js +98 -0
- package/modules/acl/cache/acl-cache.service.js.map +1 -0
- package/modules/acl/cache/cache-store.d.ts +6 -0
- package/modules/acl/cache/cache-store.js +3 -0
- package/modules/acl/cache/cache-store.js.map +1 -0
- package/modules/acl/config/acl.config.d.ts +8 -0
- package/modules/acl/config/acl.config.js +3 -0
- package/modules/acl/config/acl.config.js.map +1 -0
- package/modules/acl/const.d.ts +17 -0
- package/modules/acl/const.js +21 -0
- package/modules/acl/const.js.map +1 -0
- package/modules/acl/index.d.ts +11 -0
- package/modules/acl/index.js +28 -0
- package/modules/acl/index.js.map +1 -0
- package/modules/acl/models.d.ts +19 -0
- package/modules/acl/models.js +3 -0
- package/modules/acl/models.js.map +1 -0
- package/modules/acl/repository/acl-action.repository.d.ts +11 -0
- package/modules/acl/repository/acl-action.repository.js +7 -0
- package/modules/acl/repository/acl-action.repository.js.map +1 -0
- package/modules/acl/repository/acl-grant.repository.d.ts +11 -0
- package/modules/acl/repository/acl-grant.repository.js +7 -0
- package/modules/acl/repository/acl-grant.repository.js.map +1 -0
- package/modules/acl/repository/acl-role.repository.d.ts +10 -0
- package/modules/acl/repository/acl-role.repository.js +7 -0
- package/modules/acl/repository/acl-role.repository.js.map +1 -0
- package/modules/acl/services/acl-management.service.d.ts +26 -0
- package/modules/acl/services/acl-management.service.js +202 -0
- package/modules/acl/services/acl-management.service.js.map +1 -0
- package/modules/acl/services/acl.service.d.ts +11 -0
- package/modules/acl/services/acl.service.js +63 -0
- package/modules/acl/services/acl.service.js.map +1 -0
- package/modules/broker/broker.module.d.ts +1 -7
- package/modules/broker/broker.module.js +1 -27
- package/modules/broker/broker.module.js.map +1 -1
- package/modules/broker/services/broker.service.js +2 -2
- package/modules/broker/services/broker.service.js.map +1 -1
- package/modules/gateway-admin/config/gateway-admin.config.d.ts +3 -0
- package/modules/gateway-admin/config/gateway-admin.config.js +3 -0
- package/modules/gateway-admin/config/gateway-admin.config.js.map +1 -0
- package/modules/gateway-admin/const.d.ts +18 -0
- package/modules/gateway-admin/const.js +22 -0
- package/modules/gateway-admin/const.js.map +1 -0
- package/modules/gateway-admin/gateway-admin.module.d.ts +5 -0
- package/modules/gateway-admin/gateway-admin.module.js +35 -0
- package/modules/gateway-admin/gateway-admin.module.js.map +1 -0
- package/modules/gateway-admin/index.d.ts +11 -0
- package/modules/gateway-admin/index.js +28 -0
- package/modules/gateway-admin/index.js.map +1 -0
- package/modules/gateway-admin/models.d.ts +22 -0
- package/modules/gateway-admin/models.js +3 -0
- package/modules/gateway-admin/models.js.map +1 -0
- package/modules/gateway-admin/repository/auth-provider.repository.d.ts +15 -0
- package/modules/gateway-admin/repository/auth-provider.repository.js +7 -0
- package/modules/gateway-admin/repository/auth-provider.repository.js.map +1 -0
- package/modules/gateway-admin/repository/http-metric.repository.d.ts +7 -0
- package/modules/gateway-admin/repository/http-metric.repository.js +7 -0
- package/modules/gateway-admin/repository/http-metric.repository.js.map +1 -0
- package/modules/gateway-admin/repository/http-path.repository.d.ts +15 -0
- package/modules/gateway-admin/repository/http-path.repository.js +7 -0
- package/modules/gateway-admin/repository/http-path.repository.js.map +1 -0
- package/modules/gateway-admin/services/gateway-auth.service.d.ts +14 -0
- package/modules/gateway-admin/services/gateway-auth.service.js +100 -0
- package/modules/gateway-admin/services/gateway-auth.service.js.map +1 -0
- package/modules/gateway-admin/services/gateway-metrics.service.d.ts +11 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js +59 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js.map +1 -0
- package/modules/gateway-admin/services/gateway-path.service.d.ts +14 -0
- package/modules/gateway-admin/services/gateway-path.service.js +106 -0
- package/modules/gateway-admin/services/gateway-path.service.js.map +1 -0
- package/modules/gateway-admin/util/path-order.d.ts +3 -0
- package/modules/gateway-admin/util/path-order.js +36 -0
- package/modules/gateway-admin/util/path-order.js.map +1 -0
- package/modules/proxy/config/path-definition.config.d.ts +14 -1
- package/modules/proxy/proxy.module.d.ts +15 -2
- package/modules/proxy/proxy.module.js +24 -4
- package/modules/proxy/proxy.module.js.map +1 -1
- package/modules/proxy/services/http-auth-handler.service.d.ts +6 -0
- package/modules/proxy/services/http-auth-handler.service.js +48 -24
- package/modules/proxy/services/http-auth-handler.service.js.map +1 -1
- package/modules/proxy/services/http-handler.service.d.ts +5 -1
- package/modules/proxy/services/http-handler.service.js +79 -10
- package/modules/proxy/services/http-handler.service.js.map +1 -1
- package/modules/proxy/services/jwt.service.d.ts +3 -0
- package/modules/proxy/services/jwt.service.js +66 -9
- package/modules/proxy/services/jwt.service.js.map +1 -1
- package/modules/proxy/services/websocket.service.d.ts +33 -6
- package/modules/proxy/services/websocket.service.js +250 -82
- package/modules/proxy/services/websocket.service.js.map +1 -1
- package/package.json +29 -28
- package/schematics/nest-add/files/skills/rlb-amqp/SKILL.md +59 -0
- package/schematics/nest-add/files/skills/rlb-amqp/references/config-schema.md +214 -0
- package/schematics/nest-add/files/skills/rlb-amqp/references/gotchas.md +95 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-action/SKILL.md +102 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-route/SKILL.md +61 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-ws-event/SKILL.md +93 -0
- package/schematics/nest-add/files/skills/rlb-amqp-scaffold/SKILL.md +160 -0
- package/schematics/nest-add/index.js +82 -49
- package/schematics/nest-add/index.js.map +1 -1
- package/schematics/nest-add/index.ts +113 -68
- package/schematics/nest-add/init.schema.d.ts +2 -0
- package/schematics/nest-add/init.schema.ts +11 -1
- package/schematics/nest-add/schema.json +25 -12
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -26,7 +26,7 @@ export declare class AmqpConnection implements OnApplicationShutdown, OnModuleIn
|
|
|
26
26
|
get managedConnection(): AmqpConnectionManager;
|
|
27
27
|
get configuration(): RabbitMQConfig;
|
|
28
28
|
get channels(): Record<string, ConfirmChannel>;
|
|
29
|
-
get managedChannels(): Record<string, import("amqp-connection-manager/dist/types/ChannelWrapper").default>;
|
|
29
|
+
get managedChannels(): Record<string, import("node_modules/amqp-connection-manager/dist/types/ChannelWrapper").default>;
|
|
30
30
|
get connected(): boolean;
|
|
31
31
|
init(): Promise<void>;
|
|
32
32
|
request<T>(requestOptions: RequestOptions): Promise<T>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class BrokerHttpError extends Error {
|
|
2
|
+
constructor(message?: string);
|
|
3
|
+
}
|
|
4
|
+
export declare class BadRequestError extends BrokerHttpError {
|
|
5
|
+
}
|
|
6
|
+
export declare class UnauthorizedError extends BrokerHttpError {
|
|
7
|
+
}
|
|
8
|
+
export declare class ForbiddenError extends BrokerHttpError {
|
|
9
|
+
}
|
|
10
|
+
export declare class NotFoundError extends BrokerHttpError {
|
|
11
|
+
}
|
|
12
|
+
export declare class InvalidParamsErrror extends BrokerHttpError {
|
|
13
|
+
}
|
package/common/errors.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InvalidParamsErrror = exports.NotFoundError = exports.ForbiddenError = exports.UnauthorizedError = exports.BadRequestError = exports.BrokerHttpError = void 0;
|
|
4
|
+
class BrokerHttpError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = new.target.name;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.BrokerHttpError = BrokerHttpError;
|
|
11
|
+
class BadRequestError extends BrokerHttpError {
|
|
12
|
+
}
|
|
13
|
+
exports.BadRequestError = BadRequestError;
|
|
14
|
+
class UnauthorizedError extends BrokerHttpError {
|
|
15
|
+
}
|
|
16
|
+
exports.UnauthorizedError = UnauthorizedError;
|
|
17
|
+
class ForbiddenError extends BrokerHttpError {
|
|
18
|
+
}
|
|
19
|
+
exports.ForbiddenError = ForbiddenError;
|
|
20
|
+
class NotFoundError extends BrokerHttpError {
|
|
21
|
+
}
|
|
22
|
+
exports.NotFoundError = NotFoundError;
|
|
23
|
+
class InvalidParamsErrror extends BrokerHttpError {
|
|
24
|
+
}
|
|
25
|
+
exports.InvalidParamsErrror = InvalidParamsErrror;
|
|
26
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/errors.ts"],"names":[],"mappings":";;;AAKA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;IAC9B,CAAC;CACF;AALD,0CAKC;AAED,MAAa,eAAgB,SAAQ,eAAe;CAAI;AAAxD,0CAAwD;AACxD,MAAa,iBAAkB,SAAQ,eAAe;CAAI;AAA1D,8CAA0D;AAC1D,MAAa,cAAe,SAAQ,eAAe;CAAI;AAAvD,wCAAuD;AACvD,MAAa,aAAc,SAAQ,eAAe;CAAI;AAAtD,sCAAsD;AAEtD,MAAa,mBAAoB,SAAQ,eAAe;CAAI;AAA5D,kDAA4D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function flattenObject(input: Record<string, any>, prefix?: string, out?: Record<string, any>): Record<string, any>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenObject = flattenObject;
|
|
4
|
+
function flattenObject(input, prefix = '', out = {}) {
|
|
5
|
+
for (const key of Object.keys(input ?? {})) {
|
|
6
|
+
const value = input[key];
|
|
7
|
+
const path = prefix ? `${prefix}.${key}` : key;
|
|
8
|
+
if (isPlainObject(value)) {
|
|
9
|
+
flattenObject(value, path, out);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
out[path] = value;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
function isPlainObject(value) {
|
|
18
|
+
if (value === null || typeof value !== 'object')
|
|
19
|
+
return false;
|
|
20
|
+
if (Array.isArray(value))
|
|
21
|
+
return false;
|
|
22
|
+
if (value instanceof Date)
|
|
23
|
+
return false;
|
|
24
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(value))
|
|
25
|
+
return false;
|
|
26
|
+
const proto = Object.getPrototypeOf(value);
|
|
27
|
+
return proto === Object.prototype || proto === null;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=flatten.util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.util.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/flatten.util.ts"],"names":[],"mappings":";;AAKA,sCAWC;AAXD,SAAgB,aAAa,CAAC,KAA0B,EAAE,MAAM,GAAG,EAAE,EAAE,MAA2B,EAAE;IAClG,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;QAC/C,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,aAAa,CAAC,KAAU;IAC/B,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,KAAK,YAAY,IAAI;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE1E,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACtD,CAAC"}
|
package/common/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./errors"), exports);
|
|
18
|
+
__exportStar(require("./flatten.util"), exports);
|
|
19
|
+
__exportStar(require("./pagination.model"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,iDAA+B;AAC/B,qDAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.model.js","sourceRoot":"","sources":["../../libs/rlb-nestjs-amqp/src/common/pagination.model.ts"],"names":[],"mappings":""}
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './modules/acl';
|
|
1
3
|
export * from './modules/broker/index';
|
|
2
4
|
export * from './modules/broker/services/utils.service';
|
|
5
|
+
export * from './modules/gateway-admin';
|
|
3
6
|
export * from './modules/proxy/index';
|
|
4
7
|
export * from './modules/remote-config/index';
|
package/index.js
CHANGED
|
@@ -14,8 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./common"), exports);
|
|
18
|
+
__exportStar(require("./modules/acl"), exports);
|
|
17
19
|
__exportStar(require("./modules/broker/index"), exports);
|
|
18
20
|
__exportStar(require("./modules/broker/services/utils.service"), exports);
|
|
21
|
+
__exportStar(require("./modules/gateway-admin"), exports);
|
|
19
22
|
__exportStar(require("./modules/proxy/index"), exports);
|
|
20
23
|
__exportStar(require("./modules/remote-config/index"), exports);
|
|
21
24
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../libs/rlb-nestjs-amqp/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAuC;AACvC,0EAAwD;AACxD,wDAAsC;AACtC,gEAA8C"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../libs/rlb-nestjs-amqp/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,gDAA8B;AAC9B,yDAAuC;AACvC,0EAAwD;AACxD,0DAAwC;AACxC,wDAAsC;AACtC,gEAA8C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var AclModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.AclModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const const_1 = require("./const");
|
|
13
|
+
const acl_cache_service_1 = require("./cache/acl-cache.service");
|
|
14
|
+
const acl_management_service_1 = require("./services/acl-management.service");
|
|
15
|
+
const acl_service_1 = require("./services/acl.service");
|
|
16
|
+
const SERVICES = [acl_cache_service_1.AclCacheService, acl_service_1.AclService, acl_management_service_1.AclManagementService];
|
|
17
|
+
const MODULE_EXPORTS = [acl_service_1.AclService, acl_cache_service_1.AclCacheService];
|
|
18
|
+
let AclModule = AclModule_1 = class AclModule {
|
|
19
|
+
static forRoot(providers, options = {}) {
|
|
20
|
+
return {
|
|
21
|
+
module: AclModule_1,
|
|
22
|
+
global: true,
|
|
23
|
+
providers: [
|
|
24
|
+
{ provide: const_1.RLB_ACL_OPTIONS, useValue: options },
|
|
25
|
+
...providers,
|
|
26
|
+
...SERVICES,
|
|
27
|
+
],
|
|
28
|
+
exports: MODULE_EXPORTS,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.AclModule = AclModule;
|
|
33
|
+
exports.AclModule = AclModule = AclModule_1 = __decorate([
|
|
34
|
+
(0, common_1.Module)({})
|
|
35
|
+
], AclModule);
|
|
36
|
+
//# sourceMappingURL=acl.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.module.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/acl.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAiE;AAEjE,mCAA0C;AAC1C,iEAA4D;AAC5D,8EAAyE;AACzE,wDAAoD;AAEpD,MAAM,QAAQ,GAAe,CAAC,mCAAe,EAAE,wBAAU,EAAE,6CAAoB,CAAC,CAAC;AACjF,MAAM,cAAc,GAAG,CAAC,wBAAU,EAAE,mCAAe,CAAC,CAAC;AAG9C,IAAM,SAAS,iBAAf,MAAM,SAAS;IAOpB,MAAM,CAAC,OAAO,CAAC,SAAqB,EAAE,UAA4B,EAAE;QAClE,OAAO;YACL,MAAM,EAAE,WAAS;YACjB,MAAM,EAAE,IAAI;YACZ,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,uBAAe,EAAE,QAAQ,EAAE,OAAO,EAAE;gBAC/C,GAAG,SAAS;gBACZ,GAAG,QAAQ;aACZ;YACD,OAAO,EAAE,cAAc;SACxB,CAAC;IACJ,CAAC;CACF,CAAA;AAnBY,8BAAS;oBAAT,SAAS;IADrB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,SAAS,CAmBrB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AclModuleOptions } from '../config/acl.config';
|
|
2
|
+
import { AclCacheStore } from './cache-store';
|
|
3
|
+
export declare class AclCacheService {
|
|
4
|
+
private readonly store?;
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly ram;
|
|
7
|
+
private readonly ramTtlMs;
|
|
8
|
+
private readonly l2TtlSec;
|
|
9
|
+
constructor(options: AclModuleOptions, store?: AclCacheStore);
|
|
10
|
+
private key;
|
|
11
|
+
get(userId: string, topic: string, action: string): Promise<boolean | null>;
|
|
12
|
+
set(userId: string, topic: string, action: string, value: boolean): Promise<void>;
|
|
13
|
+
invalidate(userId?: string): Promise<void>;
|
|
14
|
+
invalidateLocalRam(userId?: string): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var AclCacheService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.AclCacheService = void 0;
|
|
17
|
+
const common_1 = require("@nestjs/common");
|
|
18
|
+
const const_1 = require("../const");
|
|
19
|
+
let AclCacheService = AclCacheService_1 = class AclCacheService {
|
|
20
|
+
constructor(options, store) {
|
|
21
|
+
this.store = store;
|
|
22
|
+
this.logger = new common_1.Logger(AclCacheService_1.name);
|
|
23
|
+
this.ram = new Map();
|
|
24
|
+
this.ramTtlMs = options.cache?.ramTtlMs ?? 30_000;
|
|
25
|
+
this.l2TtlSec = options.cache?.l2TtlSec ?? 600;
|
|
26
|
+
}
|
|
27
|
+
key(userId, topic, action) {
|
|
28
|
+
return `acl/${userId}/${topic}/${action}`;
|
|
29
|
+
}
|
|
30
|
+
async get(userId, topic, action) {
|
|
31
|
+
const key = this.key(userId, topic, action);
|
|
32
|
+
const local = this.ram.get(key);
|
|
33
|
+
if (local && local.exp > Date.now())
|
|
34
|
+
return local.v;
|
|
35
|
+
if (local)
|
|
36
|
+
this.ram.delete(key);
|
|
37
|
+
if (this.store) {
|
|
38
|
+
try {
|
|
39
|
+
const cached = await this.store.get(key);
|
|
40
|
+
if (cached === '1' || cached === '0') {
|
|
41
|
+
const value = cached === '1';
|
|
42
|
+
this.ram.set(key, { v: value, exp: Date.now() + this.ramTtlMs });
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.logger.warn(`ACL L2 cache read failed for ${key}: ${error?.message}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
async set(userId, topic, action, value) {
|
|
53
|
+
const key = this.key(userId, topic, action);
|
|
54
|
+
this.ram.set(key, { v: value, exp: Date.now() + this.ramTtlMs });
|
|
55
|
+
if (this.store) {
|
|
56
|
+
try {
|
|
57
|
+
await this.store.set(key, value ? '1' : '0', this.l2TtlSec);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
this.logger.warn(`ACL L2 cache write failed for ${key}: ${error?.message}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async invalidate(userId) {
|
|
65
|
+
this.invalidateLocalRam(userId);
|
|
66
|
+
if (!this.store)
|
|
67
|
+
return;
|
|
68
|
+
const pattern = userId ? `acl/${userId}/*` : 'acl/*';
|
|
69
|
+
try {
|
|
70
|
+
const keys = await this.store.keys(pattern);
|
|
71
|
+
if (keys.length)
|
|
72
|
+
await this.store.del(keys);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.logger.warn(`ACL L2 cache invalidation failed for ${pattern}: ${error?.message}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
invalidateLocalRam(userId) {
|
|
79
|
+
if (!userId) {
|
|
80
|
+
this.ram.clear();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const prefix = `acl/${userId}/`;
|
|
84
|
+
for (const key of this.ram.keys()) {
|
|
85
|
+
if (key.startsWith(prefix))
|
|
86
|
+
this.ram.delete(key);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
exports.AclCacheService = AclCacheService;
|
|
91
|
+
exports.AclCacheService = AclCacheService = AclCacheService_1 = __decorate([
|
|
92
|
+
(0, common_1.Injectable)(),
|
|
93
|
+
__param(0, (0, common_1.Inject)(const_1.RLB_ACL_OPTIONS)),
|
|
94
|
+
__param(1, (0, common_1.Optional)()),
|
|
95
|
+
__param(1, (0, common_1.Inject)(const_1.RLB_ACL_CACHE_STORE)),
|
|
96
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
97
|
+
], AclCacheService);
|
|
98
|
+
//# sourceMappingURL=acl-cache.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl-cache.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/cache/acl-cache.service.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache-store.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/cache/cache-store.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl.config.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/config/acl.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const ACL_TOPIC = "rlb-acl";
|
|
2
|
+
export declare const RLB_ACL_OPTIONS = "RLB_ACL_OPTIONS";
|
|
3
|
+
export declare const RLB_ACL_CACHE_STORE = "RLB_ACL_CACHE_STORE";
|
|
4
|
+
export declare const ACL_ACTIONS: {
|
|
5
|
+
readonly canUserDo: "acl-can-user-do";
|
|
6
|
+
readonly grant: "acl-grant";
|
|
7
|
+
readonly revoke: "acl-revoke";
|
|
8
|
+
readonly invalidate: "acl-invalidate";
|
|
9
|
+
readonly actionCreate: "acl-action-create";
|
|
10
|
+
readonly actionUpdate: "acl-action-update";
|
|
11
|
+
readonly actionDelete: "acl-action-delete";
|
|
12
|
+
readonly actionList: "acl-action-list";
|
|
13
|
+
readonly roleCreate: "acl-role-create";
|
|
14
|
+
readonly roleUpdate: "acl-role-update";
|
|
15
|
+
readonly roleDelete: "acl-role-delete";
|
|
16
|
+
readonly roleList: "acl-role-list";
|
|
17
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ACL_ACTIONS = exports.RLB_ACL_CACHE_STORE = exports.RLB_ACL_OPTIONS = exports.ACL_TOPIC = void 0;
|
|
4
|
+
exports.ACL_TOPIC = 'rlb-acl';
|
|
5
|
+
exports.RLB_ACL_OPTIONS = 'RLB_ACL_OPTIONS';
|
|
6
|
+
exports.RLB_ACL_CACHE_STORE = 'RLB_ACL_CACHE_STORE';
|
|
7
|
+
exports.ACL_ACTIONS = {
|
|
8
|
+
canUserDo: 'acl-can-user-do',
|
|
9
|
+
grant: 'acl-grant',
|
|
10
|
+
revoke: 'acl-revoke',
|
|
11
|
+
invalidate: 'acl-invalidate',
|
|
12
|
+
actionCreate: 'acl-action-create',
|
|
13
|
+
actionUpdate: 'acl-action-update',
|
|
14
|
+
actionDelete: 'acl-action-delete',
|
|
15
|
+
actionList: 'acl-action-list',
|
|
16
|
+
roleCreate: 'acl-role-create',
|
|
17
|
+
roleUpdate: 'acl-role-update',
|
|
18
|
+
roleDelete: 'acl-role-delete',
|
|
19
|
+
roleList: 'acl-role-list',
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=const.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/const.ts"],"names":[],"mappings":";;;AAEa,QAAA,SAAS,GAAG,SAAS,CAAC;AAEtB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAG5C,QAAA,WAAW,GAAG;IACzB,SAAS,EAAE,iBAAiB;IAC5B,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,gBAAgB;IAC5B,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,QAAQ,EAAE,eAAe;CACjB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './acl.module';
|
|
2
|
+
export * from './cache/acl-cache.service';
|
|
3
|
+
export * from './cache/cache-store';
|
|
4
|
+
export * from './config/acl.config';
|
|
5
|
+
export * from './const';
|
|
6
|
+
export * from './models';
|
|
7
|
+
export * from './repository/acl-action.repository';
|
|
8
|
+
export * from './repository/acl-grant.repository';
|
|
9
|
+
export * from './repository/acl-role.repository';
|
|
10
|
+
export * from './services/acl-management.service';
|
|
11
|
+
export * from './services/acl.service';
|
|
@@ -0,0 +1,28 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./acl.module"), exports);
|
|
18
|
+
__exportStar(require("./cache/acl-cache.service"), exports);
|
|
19
|
+
__exportStar(require("./cache/cache-store"), exports);
|
|
20
|
+
__exportStar(require("./config/acl.config"), exports);
|
|
21
|
+
__exportStar(require("./const"), exports);
|
|
22
|
+
__exportStar(require("./models"), exports);
|
|
23
|
+
__exportStar(require("./repository/acl-action.repository"), exports);
|
|
24
|
+
__exportStar(require("./repository/acl-grant.repository"), exports);
|
|
25
|
+
__exportStar(require("./repository/acl-role.repository"), exports);
|
|
26
|
+
__exportStar(require("./services/acl-management.service"), exports);
|
|
27
|
+
__exportStar(require("./services/acl.service"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,4DAA0C;AAC1C,sDAAoC;AACpC,sDAAoC;AACpC,0CAAwB;AACxB,2CAAyB;AACzB,qEAAmD;AACnD,oEAAkD;AAClD,mEAAiD;AACjD,oEAAkD;AAClD,yDAAuC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface AclAction<Id = string> {
|
|
2
|
+
_id?: Id;
|
|
3
|
+
name: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AclRole<Id = string> {
|
|
7
|
+
_id?: Id;
|
|
8
|
+
name: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
actions: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AclGrant<Id = string> {
|
|
13
|
+
_id?: Id;
|
|
14
|
+
resourceBusinessId?: string;
|
|
15
|
+
friendlyName?: string;
|
|
16
|
+
userId: string;
|
|
17
|
+
resourceId?: string;
|
|
18
|
+
roles: string[];
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/models.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { AclAction } from '../models';
|
|
3
|
+
export declare abstract class AclActionRepository {
|
|
4
|
+
abstract insert(model: AclAction): Promise<AclAction>;
|
|
5
|
+
abstract findById(id: string): Promise<AclAction>;
|
|
6
|
+
abstract findOne(filter: Record<string, any>): Promise<AclAction>;
|
|
7
|
+
abstract updateById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
8
|
+
abstract removeById(id: string): Promise<AclAction>;
|
|
9
|
+
abstract filter(filter: Record<string, any>): Promise<AclAction[]>;
|
|
10
|
+
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclAction>>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl-action.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-action.repository.ts"],"names":[],"mappings":";;;AAOA,MAAsB,mBAAmB;CAQxC;AARD,kDAQC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { AclGrant } from '../models';
|
|
3
|
+
export declare abstract class AclGrantRepository {
|
|
4
|
+
abstract insert(model: AclGrant): Promise<AclGrant>;
|
|
5
|
+
abstract findOne(filter: Record<string, any>): Promise<AclGrant>;
|
|
6
|
+
abstract updateOne(filter: Record<string, any>, model: Partial<AclGrant>): Promise<AclGrant>;
|
|
7
|
+
abstract removeOne(filter: Record<string, any>): Promise<AclGrant>;
|
|
8
|
+
abstract filter(filter: Record<string, any>): Promise<AclGrant[]>;
|
|
9
|
+
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclGrant>>;
|
|
10
|
+
abstract checkActions(filter: Record<string, any>, actions: string | string[]): Promise<boolean>;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl-grant.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-grant.repository.ts"],"names":[],"mappings":";;;AAIA,MAAsB,kBAAkB;CAYvC;AAZD,gDAYC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { AclRole } from '../models';
|
|
3
|
+
export declare abstract class AclRoleRepository {
|
|
4
|
+
abstract insert(model: AclRole): Promise<AclRole>;
|
|
5
|
+
abstract findOne(filter: Record<string, any>): Promise<AclRole>;
|
|
6
|
+
abstract updateOne(filter: Record<string, any>, model: Partial<AclRole>): Promise<AclRole>;
|
|
7
|
+
abstract removeOne(filter: Record<string, any>): Promise<AclRole>;
|
|
8
|
+
abstract filter(filter: Record<string, any>): Promise<AclRole[]>;
|
|
9
|
+
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acl-role.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-role.repository.ts"],"names":[],"mappings":";;;AAIA,MAAsB,iBAAiB;CAOtC;AAPD,8CAOC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PaginationModel } from '../../../common';
|
|
2
|
+
import { AclCacheService } from '../cache/acl-cache.service';
|
|
3
|
+
import { AclAction, AclGrant, AclRole } from '../models';
|
|
4
|
+
import { AclActionRepository } from '../repository/acl-action.repository';
|
|
5
|
+
import { AclGrantRepository } from '../repository/acl-grant.repository';
|
|
6
|
+
import { AclRoleRepository } from '../repository/acl-role.repository';
|
|
7
|
+
export declare class AclManagementService {
|
|
8
|
+
private readonly actions;
|
|
9
|
+
private readonly roles;
|
|
10
|
+
private readonly grants;
|
|
11
|
+
private readonly cache;
|
|
12
|
+
private readonly logger;
|
|
13
|
+
constructor(actions: AclActionRepository, roles: AclRoleRepository, grants: AclGrantRepository, cache: AclCacheService);
|
|
14
|
+
grant(userId: string, roles: string[], resourceId?: string, resourceBusinessId?: string, friendlyName?: string): Promise<AclGrant>;
|
|
15
|
+
revoke(userId: string, resourceId?: string): Promise<AclGrant>;
|
|
16
|
+
createAction(name: string, description?: string): Promise<AclAction>;
|
|
17
|
+
updateAction(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
18
|
+
deleteAction(id: string): Promise<AclAction>;
|
|
19
|
+
listActions(page?: number, limit?: number): Promise<PaginationModel<AclAction>>;
|
|
20
|
+
createRole(name: string, actions: string[], description?: string): Promise<AclRole>;
|
|
21
|
+
updateRole(name: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
22
|
+
deleteRole(name: string): Promise<AclRole>;
|
|
23
|
+
listRoles(page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
24
|
+
private assertActionsExist;
|
|
25
|
+
private assertRolesExist;
|
|
26
|
+
}
|