@open-rlb/nestjs-amqp 2.0.2 → 2.0.3
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 +6 -8
- package/common/errors.d.ts +2 -0
- package/common/errors.js +4 -1
- package/common/errors.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/modules/acl/cache/acl-cache.service.d.ts +2 -2
- package/modules/acl/cache/acl-cache.service.js +6 -6
- package/modules/acl/cache/acl-cache.service.js.map +1 -1
- package/modules/acl/config/acl.config.d.ts +0 -1
- package/modules/acl/const.d.ts +5 -0
- package/modules/acl/const.js +5 -0
- package/modules/acl/const.js.map +1 -1
- package/modules/acl/models.d.ts +9 -0
- package/modules/acl/repository/acl-action.repository.d.ts +10 -0
- package/modules/acl/repository/acl-action.repository.js.map +1 -1
- package/modules/acl/repository/acl-grant.repository.d.ts +4 -0
- package/modules/acl/repository/acl-grant.repository.js.map +1 -1
- package/modules/acl/repository/acl-role.repository.d.ts +10 -0
- package/modules/acl/repository/acl-role.repository.js.map +1 -1
- package/modules/acl/services/acl-management.service.d.ts +4 -1
- package/modules/acl/services/acl-management.service.js +50 -6
- package/modules/acl/services/acl-management.service.js.map +1 -1
- package/modules/acl/services/acl.service.d.ts +12 -3
- package/modules/acl/services/acl.service.js +129 -11
- package/modules/acl/services/acl.service.js.map +1 -1
- package/modules/broker/broker.module.d.ts +4 -1
- package/modules/broker/broker.module.js +17 -1
- package/modules/broker/broker.module.js.map +1 -1
- package/modules/broker/config/decorator-paths.d.ts +1 -0
- package/modules/broker/config/decorator-paths.js +35 -0
- package/modules/broker/config/decorator-paths.js.map +1 -0
- package/modules/broker/config/handler-auth.config.d.ts +2 -2
- package/modules/broker/config/route-discovery.config.d.ts +8 -0
- package/modules/broker/config/route-discovery.config.js +3 -0
- package/modules/broker/config/route-discovery.config.js.map +1 -0
- package/modules/broker/const.d.ts +3 -0
- package/modules/broker/const.js +4 -1
- package/modules/broker/const.js.map +1 -1
- package/modules/broker/decorators/broker-action.decorator.d.ts +15 -2
- package/modules/broker/decorators/broker-action.decorator.js +4 -4
- package/modules/broker/decorators/broker-action.decorator.js.map +1 -1
- package/modules/broker/index.d.ts +3 -0
- package/modules/broker/index.js +3 -0
- package/modules/broker/index.js.map +1 -1
- package/modules/broker/services/metadata-scanner.service.d.ts +1 -0
- package/modules/broker/services/metadata-scanner.service.js +28 -4
- package/modules/broker/services/metadata-scanner.service.js.map +1 -1
- package/modules/broker/services/route-discovery-publisher.service.d.ts +13 -0
- package/modules/broker/services/route-discovery-publisher.service.js +64 -0
- package/modules/broker/services/route-discovery-publisher.service.js.map +1 -0
- package/modules/gateway-admin/const.d.ts +2 -0
- package/modules/gateway-admin/const.js +2 -0
- package/modules/gateway-admin/const.js.map +1 -1
- package/modules/gateway-admin/gateway-admin.module.js +2 -1
- package/modules/gateway-admin/gateway-admin.module.js.map +1 -1
- package/modules/gateway-admin/index.d.ts +4 -0
- package/modules/gateway-admin/index.js +4 -0
- package/modules/gateway-admin/index.js.map +1 -1
- package/modules/gateway-admin/models.d.ts +49 -0
- package/modules/gateway-admin/repository/http-metric.repository.d.ts +4 -1
- package/modules/gateway-admin/repository/http-metric.repository.js.map +1 -1
- package/modules/gateway-admin/repository/http-path.repository.d.ts +5 -0
- package/modules/gateway-admin/repository/http-path.repository.js +6 -0
- package/modules/gateway-admin/repository/http-path.repository.js.map +1 -1
- package/modules/gateway-admin/repository/route-sync-log.repository.d.ts +5 -0
- package/modules/gateway-admin/repository/route-sync-log.repository.js +7 -0
- package/modules/gateway-admin/repository/route-sync-log.repository.js.map +1 -0
- package/modules/gateway-admin/services/gateway-metrics.service.d.ts +3 -1
- package/modules/gateway-admin/services/gateway-metrics.service.js +53 -0
- package/modules/gateway-admin/services/gateway-metrics.service.js.map +1 -1
- package/modules/gateway-admin/services/gateway-path.service.d.ts +1 -0
- package/modules/gateway-admin/services/gateway-path.service.js +16 -1
- package/modules/gateway-admin/services/gateway-path.service.js.map +1 -1
- package/modules/gateway-admin/services/route-sync.service.d.ts +19 -0
- package/modules/gateway-admin/services/route-sync.service.js +137 -0
- package/modules/gateway-admin/services/route-sync.service.js.map +1 -0
- package/modules/gateway-admin/util/route-diff.d.ts +27 -0
- package/modules/gateway-admin/util/route-diff.js +44 -0
- package/modules/gateway-admin/util/route-diff.js.map +1 -0
- package/modules/gateway-admin/util/route-manifest.d.ts +7 -0
- package/modules/gateway-admin/util/route-manifest.js +34 -0
- package/modules/gateway-admin/util/route-manifest.js.map +1 -0
- package/modules/proxy/index.d.ts +1 -0
- package/modules/proxy/index.js +1 -0
- package/modules/proxy/index.js.map +1 -1
- package/modules/proxy/services/acl.service.d.ts +2 -1
- package/modules/proxy/services/http-auth-handler.service.d.ts +1 -1
- package/modules/proxy/services/http-auth-handler.service.js +29 -34
- package/modules/proxy/services/http-auth-handler.service.js.map +1 -1
- package/modules/proxy/services/http-handler.service.d.ts +3 -1
- package/modules/proxy/services/http-handler.service.js +49 -18
- package/modules/proxy/services/http-handler.service.js.map +1 -1
- package/modules/proxy/services/metrics-hook.d.ts +15 -0
- package/modules/proxy/services/metrics-hook.js +5 -0
- package/modules/proxy/services/metrics-hook.js.map +1 -0
- package/modules/proxy/services/websocket.service.js +4 -1
- package/modules/proxy/services/websocket.service.js.map +1 -1
- package/package.json +1 -1
- package/schematics/nest-add/files/skills/rlb-amqp/references/config-schema.md +4 -3
- package/schematics/nest-add/files/skills/rlb-amqp/references/gotchas.md +14 -5
- package/schematics/nest-add/files/skills/rlb-amqp-add-route/SKILL.md +5 -2
- package/modules/remote-config/index.d.ts +0 -2
- package/modules/remote-config/index.js +0 -19
- package/modules/remote-config/index.js.map +0 -1
- package/modules/remote-config/remote-config.module.d.ts +0 -2
- package/modules/remote-config/remote-config.module.js +0 -22
- package/modules/remote-config/remote-config.module.js.map +0 -1
- package/modules/remote-config/remote-config.service.d.ts +0 -12
- package/modules/remote-config/remote-config.service.js +0 -68
- package/modules/remote-config/remote-config.service.js.map +0 -1
|
@@ -15,49 +15,167 @@ var AclService_1;
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.AclService = void 0;
|
|
17
17
|
const common_1 = require("@nestjs/common");
|
|
18
|
+
const common_2 = require("../../../common");
|
|
18
19
|
const broker_1 = require("../../broker");
|
|
19
20
|
const acl_cache_service_1 = require("../cache/acl-cache.service");
|
|
20
21
|
const const_1 = require("../const");
|
|
21
22
|
const acl_grant_repository_1 = require("../repository/acl-grant.repository");
|
|
23
|
+
const acl_role_repository_1 = require("../repository/acl-role.repository");
|
|
22
24
|
let AclService = AclService_1 = class AclService {
|
|
23
|
-
constructor(grants, cache) {
|
|
25
|
+
constructor(grants, roles, cache) {
|
|
24
26
|
this.grants = grants;
|
|
27
|
+
this.roles = roles;
|
|
25
28
|
this.cache = cache;
|
|
26
29
|
this.logger = new common_1.Logger(AclService_1.name);
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
toList(roles) {
|
|
32
|
+
return Array.isArray(roles) ? roles : (roles ? [roles] : []);
|
|
33
|
+
}
|
|
34
|
+
async canUserDoGtw(roles, userId) {
|
|
35
|
+
const list = this.toList(roles);
|
|
36
|
+
if (!userId || !list.length)
|
|
37
|
+
return false;
|
|
38
|
+
const cacheAction = `role-gtw:${[...list].sort().join(',')}`;
|
|
39
|
+
const cached = await this.cache.get(userId, cacheAction);
|
|
40
|
+
if (cached !== null)
|
|
41
|
+
return cached;
|
|
42
|
+
const grants = await this.grants.filter({ userId });
|
|
43
|
+
const allowed = grants.some((g) => (g.roles || []).some((r) => list.includes(r)));
|
|
44
|
+
await this.cache.set(userId, cacheAction, allowed);
|
|
45
|
+
return allowed;
|
|
46
|
+
}
|
|
47
|
+
async canUserDo(roles, userId, resourceId) {
|
|
48
|
+
const list = this.toList(roles);
|
|
49
|
+
if (!userId || !list.length)
|
|
30
50
|
return false;
|
|
31
|
-
const
|
|
51
|
+
const cacheAction = `role-res:${resourceId ?? '*'}:${[...list].sort().join(',')}`;
|
|
52
|
+
const cached = await this.cache.get(userId, cacheAction);
|
|
32
53
|
if (cached !== null)
|
|
33
54
|
return cached;
|
|
34
|
-
const
|
|
35
|
-
|
|
55
|
+
const grants = await this.grants.filter({ userId });
|
|
56
|
+
const scoped = grants.filter((g) => g.resourceId == null || g.resourceId === resourceId);
|
|
57
|
+
const allowed = scoped.some((g) => (g.roles || []).some((r) => list.includes(r)));
|
|
58
|
+
await this.cache.set(userId, cacheAction, allowed);
|
|
36
59
|
return allowed;
|
|
37
60
|
}
|
|
38
|
-
async
|
|
61
|
+
async handleCanUserDoGtw(userId, roles) {
|
|
39
62
|
try {
|
|
40
|
-
return await this.
|
|
63
|
+
return await this.canUserDoGtw(roles ?? [], userId);
|
|
41
64
|
}
|
|
42
65
|
catch (error) {
|
|
43
66
|
this.logger.error(error);
|
|
44
67
|
return false;
|
|
45
68
|
}
|
|
46
69
|
}
|
|
70
|
+
async handleCanUserDo(userId, resource, roles) {
|
|
71
|
+
try {
|
|
72
|
+
return await this.canUserDo(roles ?? [], userId, resource);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
this.logger.error(error);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async listResourcesByUser(userId) {
|
|
80
|
+
try {
|
|
81
|
+
if (!userId)
|
|
82
|
+
throw new common_2.UnauthorizedError('User ID is required');
|
|
83
|
+
const acls = await this.grants.filter({ userId });
|
|
84
|
+
const grouped = {};
|
|
85
|
+
for (const item of acls || []) {
|
|
86
|
+
const businessId = item.resourceBusinessId ?? '';
|
|
87
|
+
if (!grouped[businessId]) {
|
|
88
|
+
grouped[businessId] = { resourceBusinessId: item.resourceBusinessId, resources: [] };
|
|
89
|
+
}
|
|
90
|
+
let resource = grouped[businessId].resources.find((r) => r.resourceId === item.resourceId);
|
|
91
|
+
if (!resource) {
|
|
92
|
+
resource = { resourceId: item.resourceId, actions: [], friendlyName: item.friendlyName };
|
|
93
|
+
grouped[businessId].resources.push(resource);
|
|
94
|
+
}
|
|
95
|
+
const roleNames = Array.isArray(item.roles) ? item.roles : [item.roles];
|
|
96
|
+
const actions = await this.roles.getActionsByNames(roleNames);
|
|
97
|
+
resource.actions.push(...actions);
|
|
98
|
+
resource.actions = Array.from(new Set(resource.actions));
|
|
99
|
+
}
|
|
100
|
+
return Object.values(grouped);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.logger.error(error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
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
|
+
}
|
|
47
131
|
};
|
|
48
132
|
exports.AclService = AclService;
|
|
133
|
+
__decorate([
|
|
134
|
+
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.canUserDoGtw, 'rpc'),
|
|
135
|
+
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
136
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'roles')),
|
|
137
|
+
__metadata("design:type", Function),
|
|
138
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
139
|
+
__metadata("design:returntype", Promise)
|
|
140
|
+
], AclService.prototype, "handleCanUserDoGtw", null);
|
|
49
141
|
__decorate([
|
|
50
142
|
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.canUserDo, 'rpc'),
|
|
51
143
|
__param(0, (0, broker_1.BrokerParam)('body', 'userId')),
|
|
52
|
-
__param(1, (0, broker_1.BrokerParam)('body', '
|
|
53
|
-
__param(2, (0, broker_1.BrokerParam)('body', '
|
|
144
|
+
__param(1, (0, broker_1.BrokerParam)('body', 'resource')),
|
|
145
|
+
__param(2, (0, broker_1.BrokerParam)('body', 'roles')),
|
|
54
146
|
__metadata("design:type", Function),
|
|
55
|
-
__metadata("design:paramtypes", [String, String,
|
|
147
|
+
__metadata("design:paramtypes", [String, String, Object]),
|
|
56
148
|
__metadata("design:returntype", Promise)
|
|
57
149
|
], AclService.prototype, "handleCanUserDo", null);
|
|
150
|
+
__decorate([
|
|
151
|
+
(0, broker_1.BrokerAction)(const_1.ACL_TOPIC, const_1.ACL_ACTIONS.listResourcesByUser, 'rpc'),
|
|
152
|
+
__param(0, (0, broker_1.BrokerParam)('header', 'X-GTW-AUTH-USERID')),
|
|
153
|
+
__metadata("design:type", Function),
|
|
154
|
+
__metadata("design:paramtypes", [String]),
|
|
155
|
+
__metadata("design:returntype", Promise)
|
|
156
|
+
], 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);
|
|
58
175
|
exports.AclService = AclService = AclService_1 = __decorate([
|
|
59
176
|
(0, common_1.Injectable)(),
|
|
60
177
|
__metadata("design:paramtypes", [acl_grant_repository_1.AclGrantRepository,
|
|
178
|
+
acl_role_repository_1.AclRoleRepository,
|
|
61
179
|
acl_cache_service_1.AclCacheService])
|
|
62
180
|
], AclService);
|
|
63
181
|
//# sourceMappingURL=acl.service.js.map
|
|
@@ -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,yCAAyD;AAEzD,kEAA6D;AAC7D,oCAAkD;
|
|
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;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qDA0B5C;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,UAAU,EAAE,KAAK,CAAC;IACrC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;;;;4CAO9C;AAGK;IADL,IAAA,qBAAY,EAAC,iBAAS,EAAE,mBAAW,CAAC,YAAY,EAAE,KAAK,CAAC;IAEtD,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC7B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,YAAY,CAAC,CAAA;IACjC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC7B,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,oBAAoB,CAAC,CAAA;IACzC,WAAA,IAAA,oBAAW,EAAC,MAAM,EAAE,WAAW,CAAC,CAAA;;;;8CAclC;qBA7HU,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAKgB,yCAAkB;QACnB,uCAAiB;QACjB,mCAAe;GAN9B,UAAU,CA8HtB"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { DynamicModule, Type } from '@nestjs/common';
|
|
2
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';
|
|
4
5
|
import { AppConfig } from './services/utils.service';
|
|
5
6
|
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RabbitMQConfig, "forRoot", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol;
|
|
6
7
|
export declare class BrokerModule {
|
|
7
|
-
static forRoot(options: RabbitMQConfig, topics: BrokerTopic[], appOptions?: AppConfig): DynamicModule;
|
|
8
|
+
static forRoot(options: RabbitMQConfig, topics: BrokerTopic[], appOptions?: AppConfig, routeDiscovery?: RouteDiscoveryConfig): DynamicModule;
|
|
8
9
|
static forRootAsync(asyncOptions: {
|
|
9
10
|
useFactory: (...args: any[]) => Promise<{
|
|
10
11
|
options: RabbitMQConfig;
|
|
11
12
|
topics: BrokerTopic[];
|
|
12
13
|
appOptions?: AppConfig;
|
|
14
|
+
routeDiscovery?: RouteDiscoveryConfig;
|
|
13
15
|
}> | {
|
|
14
16
|
options: RabbitMQConfig;
|
|
15
17
|
topics: BrokerTopic[];
|
|
16
18
|
appOptions?: AppConfig;
|
|
19
|
+
routeDiscovery?: RouteDiscoveryConfig;
|
|
17
20
|
};
|
|
18
21
|
inject?: Type<any>[];
|
|
19
22
|
imports?: Type<any>[];
|
|
@@ -16,11 +16,12 @@ const auto_discovery_service_1 = require("./services/auto-discovery.service");
|
|
|
16
16
|
const broker_service_1 = require("./services/broker.service");
|
|
17
17
|
const handler_registry_service_1 = require("./services/handler-registry.service");
|
|
18
18
|
const metadata_scanner_service_1 = require("./services/metadata-scanner.service");
|
|
19
|
+
const route_discovery_publisher_service_1 = require("./services/route-discovery-publisher.service");
|
|
19
20
|
const shutdown_state_service_1 = require("./services/shutdown-state.service");
|
|
20
21
|
const utils_service_1 = require("./services/utils.service");
|
|
21
22
|
_a = new common_1.ConfigurableModuleBuilder().setClassMethodName('forRoot').build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN;
|
|
22
23
|
let BrokerModule = BrokerModule_1 = class BrokerModule {
|
|
23
|
-
static forRoot(options, topics, appOptions) {
|
|
24
|
+
static forRoot(options, topics, appOptions, routeDiscovery) {
|
|
24
25
|
if (!options) {
|
|
25
26
|
throw new Error('RabbitMQConfig is required');
|
|
26
27
|
}
|
|
@@ -30,17 +31,20 @@ let BrokerModule = BrokerModule_1 = class BrokerModule {
|
|
|
30
31
|
const amqpOptionsProvider = { provide: const_1.RLB_AMQP_BROKER_OPTIONS, useValue: options };
|
|
31
32
|
const topicOptionsProvider = { provide: const_1.RLB_AMQP_TOPIC_CONNECTION, useValue: topics };
|
|
32
33
|
const appOptionsProvider = { provide: const_1.RLB_AMQP_APP_OPTIONS, useValue: appOptions };
|
|
34
|
+
const routeDiscoveryProvider = { provide: const_1.RLB_ROUTE_DISCOVERY_OPTIONS, useValue: routeDiscovery };
|
|
33
35
|
return {
|
|
34
36
|
module: BrokerModule_1,
|
|
35
37
|
providers: [
|
|
36
38
|
amqpOptionsProvider,
|
|
37
39
|
topicOptionsProvider,
|
|
38
40
|
appOptionsProvider,
|
|
41
|
+
routeDiscoveryProvider,
|
|
39
42
|
],
|
|
40
43
|
exports: [
|
|
41
44
|
amqpOptionsProvider,
|
|
42
45
|
topicOptionsProvider,
|
|
43
46
|
appOptionsProvider,
|
|
47
|
+
routeDiscoveryProvider,
|
|
44
48
|
],
|
|
45
49
|
};
|
|
46
50
|
}
|
|
@@ -69,17 +73,27 @@ let BrokerModule = BrokerModule_1 = class BrokerModule {
|
|
|
69
73
|
},
|
|
70
74
|
inject: asyncOptions.inject || [],
|
|
71
75
|
};
|
|
76
|
+
const routeDiscoveryProvider = {
|
|
77
|
+
provide: const_1.RLB_ROUTE_DISCOVERY_OPTIONS,
|
|
78
|
+
useFactory: async (...args) => {
|
|
79
|
+
const result = await asyncOptions.useFactory(...args);
|
|
80
|
+
return result.routeDiscovery;
|
|
81
|
+
},
|
|
82
|
+
inject: asyncOptions.inject || [],
|
|
83
|
+
};
|
|
72
84
|
return {
|
|
73
85
|
module: BrokerModule_1,
|
|
74
86
|
providers: [
|
|
75
87
|
amqpOptionsProvider,
|
|
76
88
|
topicOptionsProvider,
|
|
77
89
|
appOptionsProvider,
|
|
90
|
+
routeDiscoveryProvider,
|
|
78
91
|
],
|
|
79
92
|
exports: [
|
|
80
93
|
amqpOptionsProvider,
|
|
81
94
|
topicOptionsProvider,
|
|
82
95
|
appOptionsProvider,
|
|
96
|
+
routeDiscoveryProvider,
|
|
83
97
|
],
|
|
84
98
|
};
|
|
85
99
|
}
|
|
@@ -95,6 +109,7 @@ exports.BrokerModule = BrokerModule = BrokerModule_1 = __decorate([
|
|
|
95
109
|
metadata_scanner_service_1.MetadataScannerService,
|
|
96
110
|
shutdown_state_service_1.ShutdownStateService,
|
|
97
111
|
auto_discovery_service_1.AutoDiscoveryService,
|
|
112
|
+
route_discovery_publisher_service_1.RouteDiscoveryPublisherService,
|
|
98
113
|
utils_service_1.UtilsService
|
|
99
114
|
],
|
|
100
115
|
exports: [
|
|
@@ -102,6 +117,7 @@ exports.BrokerModule = BrokerModule = BrokerModule_1 = __decorate([
|
|
|
102
117
|
utils_service_1.UtilsService,
|
|
103
118
|
broker_service_1.BrokerService,
|
|
104
119
|
auto_discovery_service_1.AutoDiscoveryService,
|
|
120
|
+
route_discovery_publisher_service_1.RouteDiscoveryPublisherService,
|
|
105
121
|
shutdown_state_service_1.ShutdownStateService
|
|
106
122
|
],
|
|
107
123
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker.module.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/broker.module.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAA0G;AAC1G,6DAAgE;
|
|
1
|
+
{"version":3,"file":"broker.module.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/broker.module.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2CAA0G;AAC1G,6DAAgE;AAIhE,mCAAgI;AAChI,8EAAyE;AACzE,8DAA0D;AAC1D,kFAA6E;AAC7E,kFAA6E;AAC7E,oGAA8F;AAC9F,8EAAyE;AACzE,4DAAmE;AACtD,KACX,IAAI,kCAAyB,EAAkB,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EADxE,+BAAuB,+BAAE,4BAAoB,2BAC4B;AAuBjF,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,OAAO,CACZ,OAAuB,EACvB,MAAqB,EACrB,UAAsB,EACtB,cAAqC;QAGrC,I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yBAAc;YACd,4BAAY;YACZ,8BAAa;YACb,6CAAoB;YACpB,kEAA8B;YAC9B,6CAAoB;SACrB;KACF,CAAC;GACW,YAAY,CAyGxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildPathDefinitionsFromMeta(meta: any): any[];
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildPathDefinitionsFromMeta = buildPathDefinitionsFromMeta;
|
|
4
|
+
function buildPathDefinitionsFromMeta(meta) {
|
|
5
|
+
const out = [];
|
|
6
|
+
for (const topic of Object.keys(meta || {})) {
|
|
7
|
+
for (const action of Object.keys(meta[topic] || {})) {
|
|
8
|
+
const entry = meta[topic][action] || {};
|
|
9
|
+
const auth = Array.isArray(entry.auth) ? entry.auth[0] : undefined;
|
|
10
|
+
for (const h of entry.http || []) {
|
|
11
|
+
out.push({
|
|
12
|
+
name: h.name ?? `${topic}:${action}:${h.method}:${h.path}`,
|
|
13
|
+
method: h.method,
|
|
14
|
+
path: h.path,
|
|
15
|
+
dataSource: h.dataSource ?? 'body',
|
|
16
|
+
topic,
|
|
17
|
+
action,
|
|
18
|
+
mode: h.mode ?? (entry.type === 'event' ? 'event' : 'rpc'),
|
|
19
|
+
auth: h.auth ?? auth?.authName,
|
|
20
|
+
allowAnonymous: h.allowAnonymous ?? auth?.allowAnonymous,
|
|
21
|
+
roles: h.roles ?? auth?.roles ?? [],
|
|
22
|
+
successStatusCode: h.successStatusCode,
|
|
23
|
+
timeout: h.timeout,
|
|
24
|
+
parseRaw: h.parseRaw,
|
|
25
|
+
binary: h.binary,
|
|
26
|
+
redirect: h.redirect,
|
|
27
|
+
headers: h.headers ?? {},
|
|
28
|
+
forwardHeaders: h.forwardHeaders ?? {},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=decorator-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-paths.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/broker/config/decorator-paths.ts"],"names":[],"mappings":";;AAMA,oEA8BC;AA9BD,SAAgB,4BAA4B,CAAC,IAAS;IACpD,MAAM,GAAG,GAAU,EAAE,CAAC;IACtB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QAC5C,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;YACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnE,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC;gBACjC,GAAG,CAAC,IAAI,CAAC;oBACP,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,GAAG,KAAK,IAAI,MAAM,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,IAAI,EAAE;oBAC1D,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,MAAM;oBAClC,KAAK;oBACL,MAAM;oBACN,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;oBAC1D,IAAI,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,QAAQ;oBAC9B,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAI,EAAE,cAAc;oBACxD,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,EAAE,KAAK,IAAI,EAAE;oBACnC,iBAAiB,EAAE,CAAC,CAAC,iBAAiB;oBACtC,OAAO,EAAE,CAAC,CAAC,OAAO;oBAClB,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,EAAE;oBACxB,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,EAAE;iBACvC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -15,8 +15,8 @@ export interface HandlerAuthConfig extends AuthConfig {
|
|
|
15
15
|
type: 'jwt' | 'jwks' | 'basic' | 'str-compare' | 'none';
|
|
16
16
|
usernameClaim: string;
|
|
17
17
|
uidClaim: string;
|
|
18
|
-
aclTopic
|
|
19
|
-
aclAction
|
|
18
|
+
aclTopic?: string;
|
|
19
|
+
aclAction?: string;
|
|
20
20
|
jwtMap?: string[];
|
|
21
21
|
headerPrefix: string;
|
|
22
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-discovery.config.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/broker/config/route-discovery.config.ts"],"names":[],"mappings":""}
|
|
@@ -7,3 +7,6 @@ export declare const RLB_BROKER_METHOD_METADATA_KEY = "rlb-broker:method";
|
|
|
7
7
|
export declare const RLB_BROKER_HTTP_METADATA_KEY = "rlb-broker:http";
|
|
8
8
|
export declare const RLB_BROKER_AUTH_METADATA_KEY = "rlb-broker:auth";
|
|
9
9
|
export declare const RLB_BROKER_PARAM_METADATA_KEY = "rlb-broker:param";
|
|
10
|
+
export declare const RLB_ROUTE_DISCOVERY_OPTIONS = "RLB_ROUTE_DISCOVERY_OPTIONS";
|
|
11
|
+
export declare const ROUTE_DISCOVERY_EXCHANGE = "rlb-route-discovery";
|
|
12
|
+
export declare const ROUTE_SYNC_QUEUE = "rlb-route-sync";
|
package/modules/broker/const.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RLB_BROKER_PARAM_METADATA_KEY = exports.RLB_BROKER_AUTH_METADATA_KEY = exports.RLB_BROKER_HTTP_METADATA_KEY = exports.RLB_BROKER_METHOD_METADATA_KEY = exports.RLB_AMQP_GATEWAY_OPTIONS = exports.RLB_AMQP_AUTH_OPTIONS = exports.RLB_AMQP_APP_OPTIONS = exports.RLB_AMQP_TOPIC_CONNECTION = exports.RLB_AMQP_BROKER_OPTIONS = void 0;
|
|
3
|
+
exports.ROUTE_SYNC_QUEUE = exports.ROUTE_DISCOVERY_EXCHANGE = exports.RLB_ROUTE_DISCOVERY_OPTIONS = exports.RLB_BROKER_PARAM_METADATA_KEY = exports.RLB_BROKER_AUTH_METADATA_KEY = exports.RLB_BROKER_HTTP_METADATA_KEY = exports.RLB_BROKER_METHOD_METADATA_KEY = exports.RLB_AMQP_GATEWAY_OPTIONS = exports.RLB_AMQP_AUTH_OPTIONS = exports.RLB_AMQP_APP_OPTIONS = exports.RLB_AMQP_TOPIC_CONNECTION = exports.RLB_AMQP_BROKER_OPTIONS = void 0;
|
|
4
4
|
exports.RLB_AMQP_BROKER_OPTIONS = 'RLB_AMQP_BROKER_OPTIONS';
|
|
5
5
|
exports.RLB_AMQP_TOPIC_CONNECTION = 'RLB_AMQP_TOPIC_CONNECTION';
|
|
6
6
|
exports.RLB_AMQP_APP_OPTIONS = 'RLB_AMQP_APP_OPTIONS';
|
|
@@ -10,4 +10,7 @@ exports.RLB_BROKER_METHOD_METADATA_KEY = 'rlb-broker:method';
|
|
|
10
10
|
exports.RLB_BROKER_HTTP_METADATA_KEY = 'rlb-broker:http';
|
|
11
11
|
exports.RLB_BROKER_AUTH_METADATA_KEY = 'rlb-broker:auth';
|
|
12
12
|
exports.RLB_BROKER_PARAM_METADATA_KEY = 'rlb-broker:param';
|
|
13
|
+
exports.RLB_ROUTE_DISCOVERY_OPTIONS = 'RLB_ROUTE_DISCOVERY_OPTIONS';
|
|
14
|
+
exports.ROUTE_DISCOVERY_EXCHANGE = 'rlb-route-discovery';
|
|
15
|
+
exports.ROUTE_SYNC_QUEUE = 'rlb-route-sync';
|
|
13
16
|
//# sourceMappingURL=const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACtD,QAAA,8BAA8B,GAAG,mBAAmB,CAAC;AACrD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,6BAA6B,GAAG,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/const.ts"],"names":[],"mappings":";;;AAAa,QAAA,uBAAuB,GAAG,yBAAyB,CAAC;AACpD,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,qBAAqB,GAAG,uBAAuB,CAAC;AAChD,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AACtD,QAAA,8BAA8B,GAAG,mBAAmB,CAAC;AACrD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,4BAA4B,GAAG,iBAAiB,CAAC;AACjD,QAAA,6BAA6B,GAAG,kBAAkB,CAAC;AAGnD,QAAA,2BAA2B,GAAG,6BAA6B,CAAC;AAE5D,QAAA,wBAAwB,GAAG,qBAAqB,CAAC;AAEjD,QAAA,gBAAgB,GAAG,gBAAgB,CAAC"}
|
|
@@ -4,6 +4,19 @@ export type BrokerActionType = 'rpc' | 'event';
|
|
|
4
4
|
export type BrokerHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
5
5
|
export type BrokerHttpDataSource = 'query' | 'body' | 'params';
|
|
6
6
|
export declare function BrokerAction(topic: string, action: string, type?: BrokerActionType): MethodDecorator;
|
|
7
|
-
export declare function BrokerHTTP(method: BrokerHttpMethod, path: string, dataSource
|
|
8
|
-
|
|
7
|
+
export declare function BrokerHTTP(method: BrokerHttpMethod, path: string, dataSource: BrokerHttpDataSource, options?: {
|
|
8
|
+
action?: string;
|
|
9
|
+
successStatusCode?: number;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
parseRaw?: boolean;
|
|
12
|
+
binary?: boolean;
|
|
13
|
+
redirect?: number;
|
|
14
|
+
headers?: {
|
|
15
|
+
[k: string]: string | number | boolean;
|
|
16
|
+
};
|
|
17
|
+
forwardHeaders?: {
|
|
18
|
+
[k: string]: string | number | boolean;
|
|
19
|
+
};
|
|
20
|
+
}): MethodDecorator;
|
|
21
|
+
export declare function BrokerAuth(authName: string, allowAnonymous?: boolean, roles?: string[], action?: string): MethodDecorator;
|
|
9
22
|
export declare function BrokerParam(source: BrokerParamSource, name?: string, pipe?: PipeTransform): ParameterDecorator;
|
|
@@ -21,7 +21,7 @@ function BrokerAction(topic, action, type) {
|
|
|
21
21
|
Reflect.defineMetadata(const_1.RLB_BROKER_METHOD_METADATA_KEY, existingMetadata, target.constructor);
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
|
-
function BrokerHTTP(method, path, dataSource,
|
|
24
|
+
function BrokerHTTP(method, path, dataSource, options) {
|
|
25
25
|
return (target, propertyKey, descriptor) => {
|
|
26
26
|
const existingMetadata = Reflect.getMetadata(const_1.RLB_BROKER_HTTP_METADATA_KEY, target.constructor) || [];
|
|
27
27
|
const params = getParamNames(descriptor.value);
|
|
@@ -30,13 +30,12 @@ function BrokerHTTP(method, path, dataSource, timeout, parseRaw) {
|
|
|
30
30
|
method,
|
|
31
31
|
path,
|
|
32
32
|
dataSource,
|
|
33
|
-
|
|
34
|
-
timeout,
|
|
33
|
+
...(options || {})
|
|
35
34
|
});
|
|
36
35
|
Reflect.defineMetadata(const_1.RLB_BROKER_HTTP_METADATA_KEY, existingMetadata, target.constructor);
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
|
-
function BrokerAuth(authName, allowAnonymous, roles) {
|
|
38
|
+
function BrokerAuth(authName, allowAnonymous, roles, action) {
|
|
40
39
|
return (target, propertyKey, descriptor) => {
|
|
41
40
|
const existingMetadata = Reflect.getMetadata(const_1.RLB_BROKER_AUTH_METADATA_KEY, target.constructor) || [];
|
|
42
41
|
const params = getParamNames(descriptor.value);
|
|
@@ -45,6 +44,7 @@ function BrokerAuth(authName, allowAnonymous, roles) {
|
|
|
45
44
|
authName,
|
|
46
45
|
allowAnonymous,
|
|
47
46
|
roles,
|
|
47
|
+
action,
|
|
48
48
|
});
|
|
49
49
|
Reflect.defineMetadata(const_1.RLB_BROKER_AUTH_METADATA_KEY, existingMetadata, target.constructor);
|
|
50
50
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broker-action.decorator.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/broker/decorators/broker-action.decorator.ts"],"names":[],"mappings":";;AAUA,oCAaC;AAED,
|
|
1
|
+
{"version":3,"file":"broker-action.decorator.js","sourceRoot":"","sources":["../../../../libs/rlb-nestjs-amqp/src/modules/broker/decorators/broker-action.dec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AAC,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC3F,IAAI,MAAM,KAAK,IAAI;QACjB,MAAM,GAAG,EAAE,CAAC;IACd,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export * from '../../amqp-lib/config/rabbitmq.config';
|
|
2
2
|
export * from './broker.module';
|
|
3
3
|
export * from './config/broker.config';
|
|
4
|
+
export * from './config/decorator-paths';
|
|
4
5
|
export * from './config/handler-auth.config';
|
|
6
|
+
export * from './config/route-discovery.config';
|
|
5
7
|
export * from './config/topics.config';
|
|
6
8
|
export * from './data/events/messages';
|
|
7
9
|
export * from './decorators';
|
|
@@ -9,5 +11,6 @@ export * from './pipes';
|
|
|
9
11
|
export * from './services/auto-discovery.service';
|
|
10
12
|
export * from './services/broker.service';
|
|
11
13
|
export * from './services/handler-registry.service';
|
|
14
|
+
export * from './services/route-discovery-publisher.service';
|
|
12
15
|
export * from './services/shutdown-state.service';
|
|
13
16
|
export * from './utils/drainable-stream';
|
package/modules/broker/index.js
CHANGED
|
@@ -17,7 +17,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("../../amqp-lib/config/rabbitmq.config"), exports);
|
|
18
18
|
__exportStar(require("./broker.module"), exports);
|
|
19
19
|
__exportStar(require("./config/broker.config"), exports);
|
|
20
|
+
__exportStar(require("./config/decorator-paths"), exports);
|
|
20
21
|
__exportStar(require("./config/handler-auth.config"), exports);
|
|
22
|
+
__exportStar(require("./config/route-discovery.config"), exports);
|
|
21
23
|
__exportStar(require("./config/topics.config"), exports);
|
|
22
24
|
__exportStar(require("./data/events/messages"), exports);
|
|
23
25
|
__exportStar(require("./decorators"), exports);
|
|
@@ -25,6 +27,7 @@ __exportStar(require("./pipes"), exports);
|
|
|
25
27
|
__exportStar(require("./services/auto-discovery.service"), exports);
|
|
26
28
|
__exportStar(require("./services/broker.service"), exports);
|
|
27
29
|
__exportStar(require("./services/handler-registry.service"), exports);
|
|
30
|
+
__exportStar(require("./services/route-discovery-publisher.service"), exports);
|
|
28
31
|
__exportStar(require("./services/shutdown-state.service"), exports);
|
|
29
32
|
__exportStar(require("./utils/drainable-stream"), exports);
|
|
30
33
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wEAAsD;AACtD,kDAAgC;AAChC,yDAAuC;AACvC,+DAA6C;AAC7C,yDAAuC;AACvC,yDAAuC;AACvC,+CAA6B;AAC7B,0CAAwB;AACxB,oEAAkD;AAClD,4DAA0C;AAC1C,sEAAoD;AACpD,oEAAkD;AAClD,2DAAyC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../libs/rlb-nestjs-amqp/src/modules/broker/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wEAAsD;AACtD,kDAAgC;AAChC,yDAAuC;AACvC,2DAAyC;AACzC,+DAA6C;AAC7C,kEAAgD;AAChD,yDAAuC;AACvC,yDAAuC;AACvC,+CAA6B;AAC7B,0CAAwB;AACxB,oEAAkD;AAClD,4DAA0C;AAC1C,sEAAoD;AACpD,+EAA6D;AAC7D,oEAAkD;AAClD,2DAAyC"}
|
|
@@ -61,10 +61,9 @@ let MetadataScannerService = MetadataScannerService_1 = class MetadataScannerSer
|
|
|
61
61
|
this.metadata[method.topic][method.action] = {};
|
|
62
62
|
}
|
|
63
63
|
const paramMetadata = Reflect.getMetadata(const_1.RLB_BROKER_PARAM_METADATA_KEY, instance, method.methodName) || [];
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const httpMetadata = (Reflect.getMetadata(const_1.RLB_BROKER_HTTP_METADATA_KEY, instance.constructor) || [])
|
|
67
|
-
.filter((m) => m.methodName === method.methodName);
|
|
64
|
+
const actionsForMethod = metadata.filter((m) => m.methodName === method.methodName);
|
|
65
|
+
const authMetadata = this.pairToAction(Reflect.getMetadata(const_1.RLB_BROKER_AUTH_METADATA_KEY, instance.constructor) || [], method, actionsForMethod, instance.constructor.name, 'auth');
|
|
66
|
+
const httpMetadata = this.pairToAction(Reflect.getMetadata(const_1.RLB_BROKER_HTTP_METADATA_KEY, instance.constructor) || [], method, actionsForMethod, instance.constructor.name, 'http');
|
|
68
67
|
this.metadata[method.topic][method.action] = {
|
|
69
68
|
service: instance,
|
|
70
69
|
method: instance[method.methodName],
|
|
@@ -196,6 +195,31 @@ let MetadataScannerService = MetadataScannerService_1 = class MetadataScannerSer
|
|
|
196
195
|
return { success: false, error: this.utils.error2Object(error, this.appConfig.environment !== 'production') };
|
|
197
196
|
}
|
|
198
197
|
}
|
|
198
|
+
pairToAction(allEntries, method, actionsForMethod, instanceName, kind) {
|
|
199
|
+
const multiAction = actionsForMethod.length > 1;
|
|
200
|
+
const actionNames = new Set(actionsForMethod.map((m) => m.action));
|
|
201
|
+
const logOnce = actionsForMethod[0]?.action === method.action;
|
|
202
|
+
const where = `'${instanceName}.${String(method.methodName)}'`;
|
|
203
|
+
return (allEntries || [])
|
|
204
|
+
.filter((e) => e.methodName === method.methodName)
|
|
205
|
+
.filter((e) => {
|
|
206
|
+
const label = kind === 'auth' ? `@BrokerAuth '${e.authName}'` : `@BrokerHTTP ${e.method} '${e.path}'`;
|
|
207
|
+
if (e.action == null) {
|
|
208
|
+
if (multiAction) {
|
|
209
|
+
if (logOnce)
|
|
210
|
+
this.logger.error(`${label} on ${where} has no 'action' but the method declares multiple @BrokerAction (${[...actionNames].join(', ')}); ignored. Add an action to bind it.`);
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
if (!actionNames.has(e.action)) {
|
|
216
|
+
if (logOnce)
|
|
217
|
+
this.logger.error(`${label} on ${where} references action '${e.action}' not declared by any @BrokerAction on that method (${[...actionNames].join(', ')}); ignored.`);
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
return e.action === method.action;
|
|
221
|
+
});
|
|
222
|
+
}
|
|
199
223
|
removeDefaultsFromParams(params) {
|
|
200
224
|
const cleaned = [];
|
|
201
225
|
for (let i = 0; i < params.length; i++) {
|