@open-rlb/nestjs-amqp 2.0.3 → 2.0.5
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 +4 -2
- package/amqp-lib/config/rabbitmq.config.d.ts +6 -0
- package/modules/acl/const.d.ts +1 -4
- package/modules/acl/const.js +1 -4
- package/modules/acl/const.js.map +1 -1
- package/modules/acl/models.d.ts +5 -7
- package/modules/acl/repository/acl-action.repository.d.ts +1 -5
- package/modules/acl/repository/acl-action.repository.js.map +1 -1
- package/modules/acl/repository/acl-grant.repository.d.ts +0 -1
- package/modules/acl/repository/acl-grant.repository.js.map +1 -1
- package/modules/acl/repository/acl-role.repository.d.ts +1 -5
- package/modules/acl/repository/acl-role.repository.js.map +1 -1
- package/modules/acl/services/acl-management.service.d.ts +6 -7
- package/modules/acl/services/acl-management.service.js +44 -61
- package/modules/acl/services/acl-management.service.js.map +1 -1
- package/modules/acl/services/acl.service.d.ts +1 -3
- package/modules/acl/services/acl.service.js +5 -47
- package/modules/acl/services/acl.service.js.map +1 -1
- package/modules/broker/broker.module.d.ts +2 -4
- package/modules/broker/broker.module.js +23 -5
- package/modules/broker/broker.module.js.map +1 -1
- package/modules/broker/config/route-discovery.config.d.ts +2 -0
- package/modules/broker/const.d.ts +1 -0
- package/modules/broker/const.js +2 -1
- package/modules/broker/const.js.map +1 -1
- package/modules/broker/services/broker.service.js +1 -1
- package/modules/broker/services/broker.service.js.map +1 -1
- package/modules/broker/services/route-discovery-publisher.service.js +7 -5
- package/modules/broker/services/route-discovery-publisher.service.js.map +1 -1
- package/modules/gateway-admin/config/gateway-admin.config.d.ts +4 -0
- package/modules/gateway-admin/const.d.ts +1 -1
- package/modules/gateway-admin/const.js +1 -1
- package/modules/gateway-admin/const.js.map +1 -1
- package/modules/gateway-admin/gateway-admin.module.d.ts +7 -1
- package/modules/gateway-admin/gateway-admin.module.js +13 -0
- package/modules/gateway-admin/gateway-admin.module.js.map +1 -1
- package/modules/gateway-admin/repository/auth-provider.repository.d.ts +3 -4
- package/modules/gateway-admin/repository/auth-provider.repository.js.map +1 -1
- package/modules/gateway-admin/services/gateway-auth.service.d.ts +3 -4
- package/modules/gateway-admin/services/gateway-auth.service.js +15 -23
- package/modules/gateway-admin/services/gateway-auth.service.js.map +1 -1
- package/modules/gateway-admin/services/gateway-metrics.service.d.ts +3 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js +9 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js.map +1 -1
- package/modules/gateway-admin/services/route-sync.service.d.ts +3 -1
- package/modules/gateway-admin/services/route-sync.service.js +14 -8
- package/modules/gateway-admin/services/route-sync.service.js.map +1 -1
- package/modules/proxy/services/http-handler.service.d.ts +3 -0
- package/modules/proxy/services/http-handler.service.js +28 -4
- package/modules/proxy/services/http-handler.service.js.map +1 -1
- package/package.json +5 -1
- package/schematics/nest-add/files/acl/src/cache/in-memory-acl-store.ts +54 -0
- package/schematics/nest-add/files/acl/src/modules/database/repository/acl.repository.ts +74 -0
- package/schematics/nest-add/files/db-core/src/modules/database/repository/in-memory-collection.ts +122 -0
- package/schematics/nest-add/files/gateway-admin/src/modules/database/repository/gateway.repository.ts +151 -0
- package/schematics/nest-add/files/gateway-admin/src/modules/database/repository/route-sync.repository.ts +15 -0
- package/schematics/nest-add/files/skills/rlb-amqp/SKILL.md +30 -5
- package/schematics/nest-add/files/skills/rlb-amqp/references/config-schema.md +182 -93
- package/schematics/nest-add/files/skills/rlb-amqp/references/gotchas.md +120 -79
- package/schematics/nest-add/files/skills/rlb-amqp-acl/SKILL.md +185 -0
- package/schematics/nest-add/files/skills/rlb-amqp-add-action/SKILL.md +49 -2
- package/schematics/nest-add/files/skills/rlb-amqp-add-route/SKILL.md +82 -19
- package/schematics/nest-add/files/skills/rlb-amqp-add-ws-event/SKILL.md +40 -18
- package/schematics/nest-add/files/skills/rlb-amqp-gateway-admin/SKILL.md +233 -0
- package/schematics/nest-add/files/skills/rlb-amqp-scaffold/SKILL.md +172 -42
- package/schematics/nest-add/index.js +612 -142
- package/schematics/nest-add/index.js.map +1 -1
- package/schematics/nest-add/index.ts +673 -241
- package/schematics/nest-add/init.schema.d.ts +10 -1
- package/schematics/nest-add/init.schema.ts +29 -3
- package/schematics/nest-add/schema.json +37 -8
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @open-rlb/nestjs-amqp
|
|
2
2
|
|
|
3
|
+
> 📖 **Full English documentation:** [`docs/`](./docs/README.md) — paginated guides for the Broker, Gateway, ACL and Gateway-admin modules, plus Getting Started and Troubleshooting. (This README is the older Italian overview.)
|
|
4
|
+
|
|
3
5
|
Libreria **NestJS** che fornisce un'astrazione di alto livello su **RabbitMQ/AMQP**, più un **API Gateway HTTP/WebSocket** che traduce le richieste esterne in messaggi sul broker.
|
|
4
6
|
|
|
5
7
|
È il cuore di un'architettura a microservizi event-driven: i servizi comunicano tra loro via RabbitMQ con semplici decoratori, e un gateway espone tutto al mondo esterno via HTTP/WS, il tutto guidato dalla configurazione YAML.
|
|
@@ -531,7 +533,7 @@ ws.send(JSON.stringify({ action: 'unsubscribe', topic: 'orders' }));
|
|
|
531
533
|
|
|
532
534
|
## Moduli opzionali `AclModule` e `GatewayAdminModule` (persistenza fornita dal consumer)
|
|
533
535
|
|
|
534
|
-
Due moduli **opzionali** per gestire ACL e configurazione gateway a database. **La lib non dipende da Mongo/Redis**: definisce i servizi/cache + i **contratti repository (classi astratte)** e l'interfaccia `AclCacheStore`; **il consumer fornisce le implementazioni** (es. Mongo + Redis). Esempio completo e funzionante: **[`
|
|
536
|
+
Due moduli **opzionali** per gestire ACL e configurazione gateway a database. **La lib non dipende da Mongo/Redis**: definisce i servizi/cache + i **contratti repository (classi astratte)** e l'interfaccia `AclCacheStore`; **il consumer fornisce le implementazioni** (es. Mongo + Redis). Esempio completo e funzionante: **[`sample/config-sample/gateway-in-memory`](sample/config-sample/gateway-in-memory)** — per restare autonomo usa **repository in-RAM** (`InMemory*Repository`) e una **cache L2 in-RAM** (`InMemoryAclStore`), così gira solo con RabbitMQ; in produzione si rimpiazzano con implementazioni Mongo/Redis senza toccare la lib.
|
|
535
537
|
|
|
536
538
|
### `AclModule` — ACL DB-backed con cache 2-livelli
|
|
537
539
|
|
|
@@ -575,7 +577,7 @@ export class AppModule {}
|
|
|
575
577
|
- `canUserDoGtw(roles, userId)` — **filtro primario del gateway** (role-based, OR): vero se l'utente ha almeno uno dei ruoli, resource-agnostico. È quello usato da `checkRoles` su `path.roles`. RPC `acl-can-user-do-gtw`.
|
|
576
578
|
- `canUserDo(roles, userId, resourceId)` — **lato microservizio**: vero se un grant **globale** (senza `resourceId`) **oppure** legato a quella risorsa dà all'utente il ruolo (`roles` accetta `string | string[]`). La risorsa è nota solo al ms, che chiama l'RPC `acl-can-user-do` con payload `{ userId, resource, roles }`.
|
|
577
579
|
- **Invalidazione**: ogni mutazione (grant/role/action) svuota L1 e L2 → la prossima verifica pesca dal DB. Senza L2, la coerenza multi-istanza è limitata dal `ramTtlMs`.
|
|
578
|
-
- **Cache L2 pluggable**: il consumer fornisce `{ provide: RLB_ACL_CACHE_STORE, useClass/useExisting }` che implementa `AclCacheStore` (`get/set/del/keys`). In `gateway-
|
|
580
|
+
- **Cache L2 pluggable**: il consumer fornisce `{ provide: RLB_ACL_CACHE_STORE, useClass/useExisting }` che implementa `AclCacheStore` (`get/set/del/keys`). In `gateway-in-memory` è `InMemoryAclStore` (mock in RAM, nessuna dipendenza esterna); in produzione plugga uno store condiviso (es. Redis).
|
|
579
581
|
|
|
580
582
|
### `GatewayAdminModule` — CRUD rotte/auth + liste + metriche
|
|
581
583
|
|
|
@@ -39,6 +39,12 @@ export interface RabbitMQConfig {
|
|
|
39
39
|
replyQueues?: {
|
|
40
40
|
[key: string]: string;
|
|
41
41
|
};
|
|
42
|
+
routeDiscovery?: {
|
|
43
|
+
serviceName?: string;
|
|
44
|
+
publishOnBoot?: boolean;
|
|
45
|
+
exchange?: string;
|
|
46
|
+
queue?: string;
|
|
47
|
+
};
|
|
42
48
|
}
|
|
43
49
|
export interface ConnectionInitOptions {
|
|
44
50
|
wait?: boolean;
|
package/modules/acl/const.d.ts
CHANGED
|
@@ -5,16 +5,13 @@ export declare const ACL_ACTIONS: {
|
|
|
5
5
|
readonly canUserDo: "acl-can-user-do";
|
|
6
6
|
readonly canUserDoGtw: "acl-can-user-do-gtw";
|
|
7
7
|
readonly listResourcesByUser: "acl-list-resources-by-user";
|
|
8
|
-
readonly listByUser: "acl-list-by-user";
|
|
9
|
-
readonly verifyAccess: "acl-verify-access";
|
|
10
8
|
readonly grant: "acl-grant";
|
|
11
9
|
readonly revoke: "acl-revoke";
|
|
12
10
|
readonly invalidate: "acl-invalidate";
|
|
13
|
-
readonly actionCreate: "acl-action-create";
|
|
14
11
|
readonly actionUpdate: "acl-action-update";
|
|
15
12
|
readonly actionDelete: "acl-action-delete";
|
|
16
13
|
readonly actionList: "acl-action-list";
|
|
17
|
-
readonly
|
|
14
|
+
readonly actionGet: "acl-action-get";
|
|
18
15
|
readonly roleUpdate: "acl-role-update";
|
|
19
16
|
readonly roleDelete: "acl-role-delete";
|
|
20
17
|
readonly roleList: "acl-role-list";
|
package/modules/acl/const.js
CHANGED
|
@@ -8,16 +8,13 @@ exports.ACL_ACTIONS = {
|
|
|
8
8
|
canUserDo: 'acl-can-user-do',
|
|
9
9
|
canUserDoGtw: 'acl-can-user-do-gtw',
|
|
10
10
|
listResourcesByUser: 'acl-list-resources-by-user',
|
|
11
|
-
listByUser: 'acl-list-by-user',
|
|
12
|
-
verifyAccess: 'acl-verify-access',
|
|
13
11
|
grant: 'acl-grant',
|
|
14
12
|
revoke: 'acl-revoke',
|
|
15
13
|
invalidate: 'acl-invalidate',
|
|
16
|
-
actionCreate: 'acl-action-create',
|
|
17
14
|
actionUpdate: 'acl-action-update',
|
|
18
15
|
actionDelete: 'acl-action-delete',
|
|
19
16
|
actionList: 'acl-action-list',
|
|
20
|
-
|
|
17
|
+
actionGet: 'acl-action-get',
|
|
21
18
|
roleUpdate: 'acl-role-update',
|
|
22
19
|
roleDelete: 'acl-role-delete',
|
|
23
20
|
roleList: 'acl-role-list',
|
package/modules/acl/const.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/const.ts"],"names":[],"mappings":";;;AAGa,QAAA,SAAS,GAAG,SAAS,CAAC;AAEtB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAG5C,QAAA,WAAW,GAAG;IAEzB,SAAS,EAAE,iBAAiB;IAE5B,YAAY,EAAE,qBAAqB;IAEnC,mBAAmB,EAAE,4BAA4B;
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/acl/const.ts"],"names":[],"mappings":";;;AAGa,QAAA,SAAS,GAAG,SAAS,CAAC;AAEtB,QAAA,eAAe,GAAG,iBAAiB,CAAC;AAEpC,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAG5C,QAAA,WAAW,GAAG;IAEzB,SAAS,EAAE,iBAAiB;IAE5B,YAAY,EAAE,qBAAqB;IAEnC,mBAAmB,EAAE,4BAA4B;IACjD,KAAK,EAAE,WAAW;IAClB,MAAM,EAAE,YAAY;IACpB,UAAU,EAAE,gBAAgB;IAE5B,YAAY,EAAE,mBAAmB;IACjC,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,iBAAiB;IAC7B,SAAS,EAAE,gBAAgB;IAC3B,UAAU,EAAE,iBAAiB;IAC7B,UAAU,EAAE,iBAAiB;IAC7B,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,cAAc;CACf,CAAC"}
|
package/modules/acl/models.d.ts
CHANGED
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
export interface AclAction
|
|
2
|
-
_id?: Id;
|
|
1
|
+
export interface AclAction {
|
|
3
2
|
name: string;
|
|
4
3
|
description?: string;
|
|
5
4
|
}
|
|
6
|
-
export interface AclRole
|
|
7
|
-
_id?: Id;
|
|
5
|
+
export interface AclRole {
|
|
8
6
|
name: string;
|
|
9
7
|
description?: string;
|
|
10
8
|
actions: string[];
|
|
11
9
|
}
|
|
12
10
|
export interface AclGrant<Id = string> {
|
|
13
11
|
_id?: Id;
|
|
14
|
-
resourceBusinessId?: string;
|
|
15
|
-
friendlyName?: string;
|
|
16
12
|
userId: string;
|
|
17
13
|
resourceId?: string;
|
|
14
|
+
companyId?: string;
|
|
15
|
+
friendlyName?: string;
|
|
18
16
|
roles: string[];
|
|
19
17
|
}
|
|
20
18
|
export interface AclResource {
|
|
@@ -23,6 +21,6 @@ export interface AclResource {
|
|
|
23
21
|
friendlyName?: string;
|
|
24
22
|
}
|
|
25
23
|
export interface AclResourceGroup {
|
|
26
|
-
|
|
24
|
+
companyId?: string;
|
|
27
25
|
resources: AclResource[];
|
|
28
26
|
}
|
|
@@ -3,15 +3,11 @@ import { AclAction } from '../models';
|
|
|
3
3
|
export declare abstract class AclActionRepository {
|
|
4
4
|
abstract insert(model: AclAction): Promise<AclAction>;
|
|
5
5
|
abstract insertMany(models: AclAction[]): Promise<AclAction[]>;
|
|
6
|
-
abstract
|
|
6
|
+
abstract findByName(name: string): Promise<AclAction>;
|
|
7
7
|
abstract findOne(filter: Record<string, any>): Promise<AclAction>;
|
|
8
|
-
abstract upsertById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
9
8
|
abstract upsertOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
10
|
-
abstract updateById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
11
9
|
abstract updateOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
12
|
-
abstract mergeById(id: string, model: Partial<AclAction>): Promise<AclAction>;
|
|
13
10
|
abstract mergeOne(filter: Record<string, any>, model: Partial<AclAction>): Promise<AclAction>;
|
|
14
|
-
abstract removeById(id: string): Promise<AclAction>;
|
|
15
11
|
abstract removeOne(filter: Record<string, any>): Promise<AclAction>;
|
|
16
12
|
abstract removeMany(filter: Record<string, any>): Promise<number>;
|
|
17
13
|
abstract filter(filter: Record<string, any>): Promise<AclAction[]>;
|
|
@@ -1 +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":";;;AAQA,MAAsB,mBAAmB;
|
|
1
|
+
{"version":3,"file":"acl-action.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-action.repository.ts"],"names":[],"mappings":";;;AAQA,MAAsB,mBAAmB;CAgBxC;AAhBD,kDAgBC"}
|
|
@@ -11,5 +11,4 @@ export declare abstract class AclGrantRepository {
|
|
|
11
11
|
abstract removeOne(filter: Record<string, any>): Promise<AclGrant>;
|
|
12
12
|
abstract filter(filter: Record<string, any>): Promise<AclGrant[]>;
|
|
13
13
|
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclGrant>>;
|
|
14
|
-
abstract checkActions(filter: Record<string, any>, actions: string | string[]): Promise<boolean>;
|
|
15
14
|
}
|
|
@@ -1 +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":";;;AAOA,MAAsB,kBAAkB;
|
|
1
|
+
{"version":3,"file":"acl-grant.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-grant.repository.ts"],"names":[],"mappings":";;;AAOA,MAAsB,kBAAkB;CAYvC;AAZD,gDAYC"}
|
|
@@ -3,14 +3,10 @@ import { AclRole } from '../models';
|
|
|
3
3
|
export declare abstract class AclRoleRepository {
|
|
4
4
|
abstract insert(model: AclRole): Promise<AclRole>;
|
|
5
5
|
abstract insertMany(models: AclRole[]): Promise<AclRole[]>;
|
|
6
|
-
abstract
|
|
6
|
+
abstract findByName(name: string): Promise<AclRole>;
|
|
7
7
|
abstract findOne(filter: Record<string, any>): Promise<AclRole>;
|
|
8
|
-
abstract upsertById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
9
8
|
abstract upsertOne(filter: Record<string, any>, model: Partial<AclRole>): Promise<AclRole>;
|
|
10
|
-
abstract updateById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
11
9
|
abstract updateOne(filter: Record<string, any>, model: Partial<AclRole>): Promise<AclRole>;
|
|
12
|
-
abstract mergeById(id: string, model: Partial<AclRole>): Promise<AclRole>;
|
|
13
|
-
abstract removeById(id: string): Promise<AclRole>;
|
|
14
10
|
abstract removeOne(filter: Record<string, any>): Promise<AclRole>;
|
|
15
11
|
abstract filter(filter: Record<string, any>): Promise<AclRole[]>;
|
|
16
12
|
abstract filterPaginated(filter: Record<string, any>, page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
@@ -1 +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":";;;AAQA,MAAsB,iBAAiB;
|
|
1
|
+
{"version":3,"file":"acl-role.repository.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/repository/acl-role.repository.ts"],"names":[],"mappings":";;;AAQA,MAAsB,iBAAiB;CAetC;AAfD,8CAeC"}
|
|
@@ -11,15 +11,14 @@ export declare class AclManagementService {
|
|
|
11
11
|
private readonly cache;
|
|
12
12
|
private readonly logger;
|
|
13
13
|
constructor(actions: AclActionRepository, roles: AclRoleRepository, grants: AclGrantRepository, cache: AclCacheService);
|
|
14
|
-
grant(userId: string, roles: string[], resourceId?: string,
|
|
15
|
-
revoke(userId: string, resourceId?: string,
|
|
14
|
+
grant(userId: string, roles: string[], resourceId?: string, companyId?: string, friendlyName?: string): Promise<AclGrant>;
|
|
15
|
+
revoke(userId: string, roles: string[], resourceId?: string, companyId?: string): Promise<AclGrant | null>;
|
|
16
16
|
private findGrant;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
deleteAction(id: string): Promise<AclAction>;
|
|
17
|
+
upsertAction(name: string, description?: string): Promise<AclAction>;
|
|
18
|
+
deleteAction(name: string): Promise<AclAction>;
|
|
20
19
|
listActions(page?: number, limit?: number): Promise<PaginationModel<AclAction>>;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
getAction(name: string): Promise<AclAction>;
|
|
21
|
+
upsertRole(name: string, actions: string[], description?: string): Promise<AclRole>;
|
|
23
22
|
deleteRole(name: string): Promise<AclRole>;
|
|
24
23
|
listRoles(page?: number, limit?: number): Promise<PaginationModel<AclRole>>;
|
|
25
24
|
getRole(name: string): Promise<AclRole>;
|
|
@@ -30,7 +30,7 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
30
30
|
this.cache = cache;
|
|
31
31
|
this.logger = new common_1.Logger(AclManagementService_1.name);
|
|
32
32
|
}
|
|
33
|
-
async grant(userId, roles, resourceId,
|
|
33
|
+
async grant(userId, roles, resourceId, companyId, friendlyName) {
|
|
34
34
|
if (!userId)
|
|
35
35
|
throw new common_2.BadRequestError('userId is required');
|
|
36
36
|
if (!roles?.length)
|
|
@@ -42,32 +42,28 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
42
42
|
const merged = Array.from(new Set([...(existing.roles || []), ...roles]));
|
|
43
43
|
result = await this.grants.updateById(existing._id, {
|
|
44
44
|
roles: merged,
|
|
45
|
-
|
|
45
|
+
companyId: companyId ?? existing.companyId,
|
|
46
46
|
friendlyName: friendlyName ?? existing.friendlyName,
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
result = await this.grants.insert({ userId, roles: Array.from(new Set(roles)), resourceId,
|
|
50
|
+
result = await this.grants.insert({ userId, roles: Array.from(new Set(roles)), resourceId, companyId, friendlyName });
|
|
51
51
|
}
|
|
52
52
|
await this.cache.invalidate(userId);
|
|
53
53
|
return result;
|
|
54
54
|
}
|
|
55
|
-
async revoke(userId, resourceId,
|
|
55
|
+
async revoke(userId, roles, resourceId, companyId) {
|
|
56
56
|
if (!userId)
|
|
57
57
|
throw new common_2.BadRequestError('userId is required');
|
|
58
|
+
if (!roles?.length)
|
|
59
|
+
throw new common_2.BadRequestError('roles are required');
|
|
58
60
|
const existing = await this.findGrant(userId, resourceId);
|
|
59
61
|
if (!existing)
|
|
60
62
|
return null;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
? await this.grants.updateById(existing._id, { roles: remaining })
|
|
66
|
-
: await this.grants.removeById(existing._id);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
result = await this.grants.removeById(existing._id);
|
|
70
|
-
}
|
|
63
|
+
const remaining = (existing.roles || []).filter((r) => !roles.includes(r));
|
|
64
|
+
const result = remaining.length
|
|
65
|
+
? await this.grants.updateById(existing._id, { roles: remaining })
|
|
66
|
+
: await this.grants.removeById(existing._id);
|
|
71
67
|
await this.cache.invalidate(userId);
|
|
72
68
|
return result;
|
|
73
69
|
}
|
|
@@ -75,48 +71,43 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
75
71
|
const all = await this.grants.filter({ userId });
|
|
76
72
|
return (all || []).find((g) => (g.resourceId ?? null) === (resourceId ?? null));
|
|
77
73
|
}
|
|
78
|
-
async
|
|
74
|
+
async upsertAction(name, description) {
|
|
79
75
|
if (!name)
|
|
80
76
|
throw new common_2.BadRequestError('name is required');
|
|
81
|
-
const
|
|
82
|
-
await this.
|
|
83
|
-
return created;
|
|
84
|
-
}
|
|
85
|
-
async updateAction(id, model) {
|
|
86
|
-
if (!id)
|
|
87
|
-
throw new common_2.BadRequestError('id is required');
|
|
88
|
-
const updated = await this.actions.updateById(id, model);
|
|
77
|
+
const model = { name, ...(description !== undefined ? { description } : {}) };
|
|
78
|
+
const result = await this.actions.upsertOne({ name }, model);
|
|
89
79
|
await this.cache.invalidate();
|
|
90
|
-
return
|
|
80
|
+
return result;
|
|
91
81
|
}
|
|
92
|
-
async deleteAction(
|
|
93
|
-
|
|
82
|
+
async deleteAction(name) {
|
|
83
|
+
if (!name)
|
|
84
|
+
throw new common_2.BadRequestError('name is required');
|
|
85
|
+
const removed = await this.actions.removeOne({ name });
|
|
94
86
|
await this.cache.invalidate();
|
|
95
87
|
return removed;
|
|
96
88
|
}
|
|
97
89
|
async listActions(page, limit) {
|
|
98
90
|
return this.actions.filterPaginated({}, Number(page) || 1, Number(limit) || 10);
|
|
99
91
|
}
|
|
100
|
-
async
|
|
92
|
+
async getAction(name) {
|
|
93
|
+
if (!name)
|
|
94
|
+
throw new common_2.BadRequestError('name is required');
|
|
95
|
+
return this.actions.findByName(name);
|
|
96
|
+
}
|
|
97
|
+
async upsertRole(name, actions, description) {
|
|
101
98
|
if (!name)
|
|
102
99
|
throw new common_2.BadRequestError('name is required');
|
|
103
100
|
if (!actions?.length)
|
|
104
101
|
throw new common_2.BadRequestError('actions are required');
|
|
105
102
|
await this.assertActionsExist(actions);
|
|
106
|
-
const
|
|
103
|
+
const model = { name, actions, ...(description !== undefined ? { description } : {}) };
|
|
104
|
+
const result = await this.roles.upsertOne({ name }, model);
|
|
107
105
|
await this.cache.invalidate();
|
|
108
|
-
return
|
|
106
|
+
return result;
|
|
109
107
|
}
|
|
110
|
-
async
|
|
108
|
+
async deleteRole(name) {
|
|
111
109
|
if (!name)
|
|
112
110
|
throw new common_2.BadRequestError('name is required');
|
|
113
|
-
if (model?.actions?.length)
|
|
114
|
-
await this.assertActionsExist(model.actions);
|
|
115
|
-
const updated = await this.roles.updateOne({ name }, model);
|
|
116
|
-
await this.cache.invalidate();
|
|
117
|
-
return updated;
|
|
118
|
-
}
|
|
119
|
-
async deleteRole(name) {
|
|
120
111
|
const removed = await this.roles.removeOne({ name });
|
|
121
112
|
await this.cache.invalidate();
|
|
122
113
|
return removed;
|
|
@@ -127,7 +118,7 @@ let AclManagementService = AclManagementService_1 = class AclManagementService {
|
|
|
127
118
|
async getRole(name) {
|
|
128
119
|
if (!name)
|
|
129
120
|
throw new common_2.BadRequestError('name is required');
|
|
130
|
-
return this.roles.
|
|
121
|
+
return this.roles.findByName(name);
|
|
131
122
|
}
|
|
132
123
|
async getActionsByNames(names) {
|
|
133
124
|
return this.roles.getActionsByNames(names);
|
|
@@ -151,7 +142,7 @@ __decorate([
|
|
|
151
142
|
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
152
143
|
__param(1, (0, broker_1.BrokerParam)('body', 'roles')),
|
|
153
144
|
__param(2, (0, broker_1.BrokerParam)('body', 'resourceId')),
|
|
154
|
-
__param(3, (0, broker_1.BrokerParam)('body', '
|
|
145
|
+
__param(3, (0, broker_1.BrokerParam)('body', 'companyId')),
|
|
155
146
|
__param(4, (0, broker_1.BrokerParam)('body', 'friendlyName')),
|
|
156
147
|
__metadata("design:type", Function),
|
|
157
148
|
__metadata("design:paramtypes", [String, Array, String, String, String]),
|
|
@@ -160,31 +151,24 @@ __decorate([
|
|
|
160
151
|
__decorate([
|
|
161
152
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.revoke, 'rpc'),
|
|
162
153
|
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
163
|
-
__param(1, (0, broker_1.BrokerParam)('body', '
|
|
164
|
-
__param(2, (0, broker_1.BrokerParam)('body', '
|
|
154
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'roles')),
|
|
155
|
+
__param(2, (0, broker_1.BrokerParam)('body', 'resourceId')),
|
|
156
|
+
__param(3, (0, broker_1.BrokerParam)('body', 'companyId')),
|
|
165
157
|
__metadata("design:type", Function),
|
|
166
|
-
__metadata("design:paramtypes", [String, String,
|
|
158
|
+
__metadata("design:paramtypes", [String, Array, String, String]),
|
|
167
159
|
__metadata("design:returntype", Promise)
|
|
168
160
|
], AclManagementService.prototype, "revoke", null);
|
|
169
161
|
__decorate([
|
|
170
|
-
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.
|
|
162
|
+
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.actionUpdate, 'rpc'),
|
|
171
163
|
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
172
164
|
__param(1, (0, broker_1.BrokerParam)('body', 'description')),
|
|
173
165
|
__metadata("design:type", Function),
|
|
174
166
|
__metadata("design:paramtypes", [String, String]),
|
|
175
167
|
__metadata("design:returntype", Promise)
|
|
176
|
-
], AclManagementService.prototype, "
|
|
177
|
-
__decorate([
|
|
178
|
-
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.actionUpdate, 'rpc'),
|
|
179
|
-
__param(0, (0, broker_1.BrokerParam)('body', 'id')),
|
|
180
|
-
__param(1, (0, broker_1.BrokerParam)('body-full')),
|
|
181
|
-
__metadata("design:type", Function),
|
|
182
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
183
|
-
__metadata("design:returntype", Promise)
|
|
184
|
-
], AclManagementService.prototype, "updateAction", null);
|
|
168
|
+
], AclManagementService.prototype, "upsertAction", null);
|
|
185
169
|
__decorate([
|
|
186
170
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.actionDelete, 'rpc'),
|
|
187
|
-
__param(0, (0, broker_1.BrokerParam)('body', '
|
|
171
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
188
172
|
__metadata("design:type", Function),
|
|
189
173
|
__metadata("design:paramtypes", [String]),
|
|
190
174
|
__metadata("design:returntype", Promise)
|
|
@@ -198,22 +182,21 @@ __decorate([
|
|
|
198
182
|
__metadata("design:returntype", Promise)
|
|
199
183
|
], AclManagementService.prototype, "listActions", null);
|
|
200
184
|
__decorate([
|
|
201
|
-
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.
|
|
185
|
+
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.actionGet, 'rpc'),
|
|
202
186
|
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
203
|
-
__param(1, (0, broker_1.BrokerParam)('body', 'actions')),
|
|
204
|
-
__param(2, (0, broker_1.BrokerParam)('body', 'description')),
|
|
205
187
|
__metadata("design:type", Function),
|
|
206
|
-
__metadata("design:paramtypes", [String
|
|
188
|
+
__metadata("design:paramtypes", [String]),
|
|
207
189
|
__metadata("design:returntype", Promise)
|
|
208
|
-
], AclManagementService.prototype, "
|
|
190
|
+
], AclManagementService.prototype, "getAction", null);
|
|
209
191
|
__decorate([
|
|
210
192
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.roleUpdate, 'rpc'),
|
|
211
193
|
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
212
|
-
__param(1, (0, broker_1.BrokerParam)('body
|
|
194
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'actions')),
|
|
195
|
+
__param(2, (0, broker_1.BrokerParam)('body', 'description')),
|
|
213
196
|
__metadata("design:type", Function),
|
|
214
|
-
__metadata("design:paramtypes", [String,
|
|
197
|
+
__metadata("design:paramtypes", [String, Array, String]),
|
|
215
198
|
__metadata("design:returntype", Promise)
|
|
216
|
-
], AclManagementService.prototype, "
|
|
199
|
+
], AclManagementService.prototype, "upsertRole", null);
|
|
217
200
|
__decorate([
|
|
218
201
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.roleDelete, 'rpc'),
|
|
219
202
|
__param(0, (0, broker_1.BrokerParam)('body', 'name')),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl-management.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/services/acl-management.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AACnE,yCAAyD;AACzD,kEAA6D;AAC7D,oCAAkD;AAElD,+EAA0E;AAC1E,6EAAwE;AACxE,2EAAsE;AAG/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,OAA4B,EAC5B,KAAwB,EACxB,MAA0B,EAC1B,KAAsB;QAHtB,YAAO,GAAP,OAAO,CAAqB;QAC5B,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAiB;QANxB,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAO5D,CAAC;
|
|
1
|
+
{"version":3,"file":"acl-management.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/services/acl-management.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAmE;AACnE,yCAAyD;AACzD,kEAA6D;AAC7D,oCAAkD;AAElD,+EAA0E;AAC1E,6EAAwE;AACxE,2EAAsE;AAG/D,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAG/B,YACmB,OAA4B,EAC5B,KAAwB,EACxB,MAA0B,EAC1B,KAAsB;QAHtB,YAAO,GAAP,OAAO,CAAqB;QAC5B,UAAK,GAAL,KAAK,CAAmB;QACxB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAiB;QANxB,WAAM,GAAG,IAAI,eAAM,CAAC,sBAAoB,CAAC,IAAI,CAAC,CAAC;IAO5D,CAAC;IAOC,AAAN,KAAK,CAAC,KAAK,CACsB,MAAc,EACf,KAAe,EACV,UAAmB,EACpB,SAAkB,EACf,YAAqB;QAE1D,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,wBAAe,CAAC,oBAAoB,CAAC,CAAC;QAC7D,IAAI,CAAC,KAAK,EAAE,MAAM;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AC,MAAM,EAAE,MAAM,CAAC,CAAA;;;;qDAG3C;AAKK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,UAAU,EAAE,KAAK,CAAC;IAEpD,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAC9B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,aAAa,CAAC,CAAA;;;;sDASpC;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,UAAU,EAAE,KAAK,CAAC;IACrC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;;;;sDAO5C;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,QAAQ,EAAE,KAAK,CAAC;IAElD,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,OAAO,CAAC,CAAA;;;;qDAG9B;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,OAAO,EAAE,KAAK,CAAC;IACrC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;;;;mDAGzC;+BAjJU,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAKiB,2CAAmB;QACrB,uCAAiB;QAChB,yCAAkB;QACnB,mCAAe;GAP9B,oBAAoB,CAkKhC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IAclRoleService } from '../../proxy/services/acl.service';
|
|
2
2
|
import { AclCacheService } from '../cache/acl-cache.service';
|
|
3
|
-
import {
|
|
3
|
+
import { AclResourceGroup } from '../models';
|
|
4
4
|
import { AclGrantRepository } from '../repository/acl-grant.repository';
|
|
5
5
|
import { AclRoleRepository } from '../repository/acl-role.repository';
|
|
6
6
|
export declare class AclService implements IAclRoleService {
|
|
@@ -15,6 +15,4 @@ export declare class AclService implements IAclRoleService {
|
|
|
15
15
|
handleCanUserDoGtw(userId: string, roles?: string | string[]): Promise<boolean>;
|
|
16
16
|
handleCanUserDo(userId: string, resource: string, roles?: string | string[]): Promise<boolean>;
|
|
17
17
|
listResourcesByUser(userId: string): Promise<AclResourceGroup[]>;
|
|
18
|
-
listByUser(userId: string): Promise<AclGrant[]>;
|
|
19
|
-
verifyAccess(userId: string, resourceId: string, action: string, resourceBusinessId?: string, productId?: string): Promise<boolean>;
|
|
20
18
|
}
|
|
@@ -83,14 +83,14 @@ let AclService = AclService_1 = class AclService {
|
|
|
83
83
|
const acls = await this.grants.filter({ userId });
|
|
84
84
|
const grouped = {};
|
|
85
85
|
for (const item of acls || []) {
|
|
86
|
-
const
|
|
87
|
-
if (!grouped[
|
|
88
|
-
grouped[
|
|
86
|
+
const companyKey = item.companyId ?? '';
|
|
87
|
+
if (!grouped[companyKey]) {
|
|
88
|
+
grouped[companyKey] = { companyId: item.companyId, resources: [] };
|
|
89
89
|
}
|
|
90
|
-
let resource = grouped[
|
|
90
|
+
let resource = grouped[companyKey].resources.find((r) => r.resourceId === item.resourceId);
|
|
91
91
|
if (!resource) {
|
|
92
92
|
resource = { resourceId: item.resourceId, actions: [], friendlyName: item.friendlyName };
|
|
93
|
-
grouped[
|
|
93
|
+
grouped[companyKey].resources.push(resource);
|
|
94
94
|
}
|
|
95
95
|
const roleNames = Array.isArray(item.roles) ? item.roles : [item.roles];
|
|
96
96
|
const actions = await this.roles.getActionsByNames(roleNames);
|
|
@@ -104,30 +104,6 @@ let AclService = AclService_1 = class AclService {
|
|
|
104
104
|
throw error;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
async listByUser(userId) {
|
|
108
|
-
try {
|
|
109
|
-
return await this.grants.filter({ userId });
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
this.logger.error(error);
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async verifyAccess(userId, resourceId, action, resourceBusinessId, productId) {
|
|
117
|
-
try {
|
|
118
|
-
const businessId = resourceBusinessId ?? productId;
|
|
119
|
-
const filter = {
|
|
120
|
-
userId,
|
|
121
|
-
resourceId,
|
|
122
|
-
...(businessId !== undefined ? { resourceBusinessId: businessId } : {}),
|
|
123
|
-
};
|
|
124
|
-
return await this.grants.checkActions(filter, action);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
this.logger.error(error);
|
|
128
|
-
throw error;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
107
|
};
|
|
132
108
|
exports.AclService = AclService;
|
|
133
109
|
__decorate([
|
|
@@ -154,24 +130,6 @@ __decorate([
|
|
|
154
130
|
__metadata("design:paramtypes", [String]),
|
|
155
131
|
__metadata("design:returntype", Promise)
|
|
156
132
|
], AclService.prototype, "listResourcesByUser", null);
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.listByUser, 'rpc'),
|
|
159
|
-
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
160
|
-
__metadata("design:type", Function),
|
|
161
|
-
__metadata("design:paramtypes", [String]),
|
|
162
|
-
__metadata("design:returntype", Promise)
|
|
163
|
-
], AclService.prototype, "listByUser", null);
|
|
164
|
-
__decorate([
|
|
165
|
-
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.verifyAccess, 'rpc'),
|
|
166
|
-
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
167
|
-
__param(1, (0, broker_1.BrokerParam)('body', 'resourceId')),
|
|
168
|
-
__param(2, (0, broker_1.BrokerParam)('body', 'action')),
|
|
169
|
-
__param(3, (0, broker_1.BrokerParam)('body', 'resourceBusinessId')),
|
|
170
|
-
__param(4, (0, broker_1.BrokerParam)('body', 'productId')),
|
|
171
|
-
__metadata("design:type", Function),
|
|
172
|
-
__metadata("design:paramtypes", [String, String, String, String, String]),
|
|
173
|
-
__metadata("design:returntype", Promise)
|
|
174
|
-
], AclService.prototype, "verifyAccess", null);
|
|
175
133
|
exports.AclService = AclService = AclService_1 = __decorate([
|
|
176
134
|
(0, common_1.Injectable)(),
|
|
177
135
|
__metadata("design:paramtypes", [acl_grant_repository_1.AclGrantRepository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acl.service.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/acl/services/acl.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,4CAAoD;AACpD,yCAAyD;AAEzD,kEAA6D;AAC7D,oCAAkD;AAElD,6EAAwE;AACxE,2EAAsE;AAG/D,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAGrB,YACmB,MAA0B,EAC1B,KAAwB,EACxB,KAAsB;QAFtB,WAAM,GAAN,MAAM,CAAoB;QAC1B,UAAK,GAAL,KAAK,CAAmB;QACxB,UAAK,GAAL,KAAK,CAAiB;QALxB,WAAM,GAAG,IAAI,eAAM,CAAC,YAAU,CAAC,IAAI,CAAC,CAAC;IAMlD,CAAC;IAEG,MAAM,CAAC,KAAwB;QACrC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,KAAwB,EAAE,MAAc;QACzD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAC1C,MAAM,WAAW,GAAG,YAAY,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI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2
|
import { RabbitMQConfig } from '../../amqp-lib/config/rabbitmq.config';
|
|
3
3
|
import { BrokerTopic } from './config/topics.config';
|
|
4
|
-
import { RouteDiscoveryConfig } from './config/route-discovery.config';
|
|
5
4
|
import { AppConfig } from './services/utils.service';
|
|
6
5
|
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RabbitMQConfig, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
7
6
|
export declare class BrokerModule {
|
|
8
|
-
static
|
|
7
|
+
private static withServiceNameConnection;
|
|
8
|
+
static forRoot(options: RabbitMQConfig, topics: BrokerTopic[], appOptions?: AppConfig): DynamicModule;
|
|
9
9
|
static forRootAsync(asyncOptions: {
|
|
10
10
|
useFactory: (...args: any[]) => Promise<{
|
|
11
11
|
options: RabbitMQConfig;
|
|
12
12
|
topics: BrokerTopic[];
|
|
13
13
|
appOptions?: AppConfig;
|
|
14
|
-
routeDiscovery?: RouteDiscoveryConfig;
|
|
15
14
|
}> | {
|
|
16
15
|
options: RabbitMQConfig;
|
|
17
16
|
topics: BrokerTopic[];
|
|
18
17
|
appOptions?: AppConfig;
|
|
19
|
-
routeDiscovery?: RouteDiscoveryConfig;
|
|
20
18
|
};
|
|
21
19
|
inject?: Type<any>[];
|
|
22
20
|
imports?: Type<any>[];
|