@privateaim/server-kit 0.8.15 → 0.8.16
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/CHANGELOG.md +24 -0
- package/dist/core/component/handler/check.d.ts +4 -0
- package/dist/core/component/handler/check.d.ts.map +1 -0
- package/dist/core/component/handler/index.d.ts +3 -0
- package/dist/core/component/handler/index.d.ts.map +1 -0
- package/dist/core/component/handler/module.d.ts +11 -0
- package/dist/core/component/handler/module.d.ts.map +1 -0
- package/dist/core/component/handler/types.d.ts +11 -0
- package/dist/core/component/handler/types.d.ts.map +1 -0
- package/dist/core/component/index.d.ts +1 -0
- package/dist/core/component/index.d.ts.map +1 -1
- package/dist/core/queue-router/module.d.ts +3 -2
- package/dist/core/queue-router/module.d.ts.map +1 -1
- package/dist/core/queue-router/types.d.ts +7 -4
- package/dist/core/queue-router/types.d.ts.map +1 -1
- package/dist/index.cjs +214 -526
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +208 -484
- package/dist/index.mjs.map +1 -1
- package/dist/services/amqp/index.d.ts +1 -0
- package/dist/services/amqp/index.d.ts.map +1 -1
- package/dist/services/amqp/module.d.ts +2 -5
- package/dist/services/amqp/module.d.ts.map +1 -1
- package/dist/services/amqp/singleton.d.ts +6 -0
- package/dist/services/amqp/singleton.d.ts.map +1 -0
- package/dist/services/domain-event/module.d.ts +3 -3
- package/dist/services/domain-event/module.d.ts.map +1 -1
- package/dist/services/domain-event/redis/helpers.d.ts +2 -0
- package/dist/services/domain-event/redis/helpers.d.ts.map +1 -0
- package/dist/services/domain-event/redis/index.d.ts +1 -0
- package/dist/services/domain-event/redis/index.d.ts.map +1 -1
- package/dist/services/domain-event/redis/module.d.ts +3 -3
- package/dist/services/domain-event/redis/module.d.ts.map +1 -1
- package/dist/services/domain-event/socket/helpers.d.ts +3 -0
- package/dist/services/domain-event/socket/helpers.d.ts.map +1 -0
- package/dist/services/domain-event/socket/index.d.ts +1 -0
- package/dist/services/domain-event/socket/index.d.ts.map +1 -1
- package/dist/services/domain-event/socket/module.d.ts +3 -3
- package/dist/services/domain-event/socket/module.d.ts.map +1 -1
- package/dist/services/domain-event/types.d.ts +22 -14
- package/dist/services/domain-event/types.d.ts.map +1 -1
- package/dist/services/domain-event/utils.d.ts +0 -2
- package/dist/services/domain-event/utils.d.ts.map +1 -1
- package/dist/services/index.d.ts +0 -2
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/logger/module.d.ts.map +1 -1
- package/dist/services/logger/types.d.ts +2 -5
- package/dist/services/logger/types.d.ts.map +1 -1
- package/package.json +3 -5
- package/src/core/component/handler/check.ts +23 -0
- package/src/{services/loki → core/component/handler}/index.ts +2 -2
- package/src/core/component/handler/module.ts +57 -0
- package/src/core/component/handler/types.ts +28 -0
- package/src/core/component/index.ts +1 -0
- package/src/core/queue-router/module.ts +30 -4
- package/src/core/queue-router/types.ts +12 -5
- package/src/services/amqp/index.ts +1 -0
- package/src/services/amqp/module.ts +5 -19
- package/src/services/{loki → amqp}/singleton.ts +6 -6
- package/src/services/domain-event/module.ts +25 -8
- package/src/services/domain-event/redis/helpers.ts +28 -0
- package/src/services/domain-event/redis/index.ts +1 -0
- package/src/services/domain-event/redis/module.ts +10 -22
- package/src/services/domain-event/singleton.ts +3 -3
- package/src/services/domain-event/socket/helpers.ts +26 -0
- package/src/services/domain-event/socket/index.ts +1 -0
- package/src/services/domain-event/socket/module.ts +21 -36
- package/src/services/domain-event/types.ts +30 -21
- package/src/services/domain-event/utils.ts +0 -12
- package/src/services/index.ts +0 -2
- package/src/services/logger/module.ts +6 -31
- package/src/services/logger/types.ts +3 -6
- package/dist/services/log-store/entities/base.d.ts +0 -7
- package/dist/services/log-store/entities/base.d.ts.map +0 -1
- package/dist/services/log-store/entities/index.d.ts +0 -3
- package/dist/services/log-store/entities/index.d.ts.map +0 -1
- package/dist/services/log-store/entities/loki.d.ts +0 -13
- package/dist/services/log-store/entities/loki.d.ts.map +0 -1
- package/dist/services/log-store/entities/memory.d.ts +0 -11
- package/dist/services/log-store/entities/memory.d.ts.map +0 -1
- package/dist/services/log-store/index.d.ts +0 -4
- package/dist/services/log-store/index.d.ts.map +0 -1
- package/dist/services/log-store/singleton.d.ts +0 -6
- package/dist/services/log-store/singleton.d.ts.map +0 -1
- package/dist/services/log-store/types.d.ts +0 -27
- package/dist/services/log-store/types.d.ts.map +0 -1
- package/dist/services/logger/store.d.ts +0 -14
- package/dist/services/logger/store.d.ts.map +0 -1
- package/dist/services/loki/index.d.ts +0 -3
- package/dist/services/loki/index.d.ts.map +0 -1
- package/dist/services/loki/module.d.ts +0 -3
- package/dist/services/loki/module.d.ts.map +0 -1
- package/dist/services/loki/singleton.d.ts +0 -6
- package/dist/services/loki/singleton.d.ts.map +0 -1
- package/src/services/log-store/entities/base.ts +0 -25
- package/src/services/log-store/entities/index.ts +0 -9
- package/src/services/log-store/entities/loki.ts +0 -158
- package/src/services/log-store/entities/memory.ts +0 -100
- package/src/services/log-store/index.ts +0 -10
- package/src/services/log-store/singleton.ts +0 -36
- package/src/services/log-store/types.ts +0 -42
- package/src/services/logger/store.ts +0 -70
- package/src/services/loki/module.ts +0 -30
- package/test/unit/log-store.spec.ts +0 -21
- package/test/unit/logger.spec.ts +0 -36
package/dist/index.cjs
CHANGED
|
@@ -8,11 +8,8 @@ var coreHttpKit = require('@authup/core-http-kit');
|
|
|
8
8
|
var redisExtension = require('redis-extension');
|
|
9
9
|
var TTLCache = require('@isaacs/ttlcache');
|
|
10
10
|
var envix = require('envix');
|
|
11
|
-
var path = require('node:path');
|
|
12
11
|
var typeormExtension = require('typeorm-extension');
|
|
13
12
|
var winston = require('winston');
|
|
14
|
-
var WinstonTransport = require('winston-transport');
|
|
15
|
-
var loki = require('@hapic/loki');
|
|
16
13
|
var redisEmitter = require('@socket.io/redis-emitter');
|
|
17
14
|
|
|
18
15
|
/*
|
|
@@ -20,7 +17,7 @@ var redisEmitter = require('@socket.io/redis-emitter');
|
|
|
20
17
|
* Author Peter Placzek (tada5hi)
|
|
21
18
|
* For the full copyright and license information,
|
|
22
19
|
* view the LICENSE file that was distributed with this source code.
|
|
23
|
-
*/ function _define_property$
|
|
20
|
+
*/ function _define_property$8(obj, key, value) {
|
|
24
21
|
if (key in obj) {
|
|
25
22
|
Object.defineProperty(obj, key, {
|
|
26
23
|
value: value,
|
|
@@ -37,11 +34,81 @@ class ComponentError extends Error {
|
|
|
37
34
|
constructor(input){
|
|
38
35
|
super(input.message, {
|
|
39
36
|
cause: input.cause
|
|
40
|
-
}), _define_property$
|
|
37
|
+
}), _define_property$8(this, "code", void 0);
|
|
41
38
|
this.code = input.code;
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
|
|
42
|
+
/*
|
|
43
|
+
* Copyright (c) 2022-2024.
|
|
44
|
+
* Author Peter Placzek (tada5hi)
|
|
45
|
+
* For the full copyright and license information,
|
|
46
|
+
* view the LICENSE file that was distributed with this source code.
|
|
47
|
+
*/ function hasOwnProperty(obj, prop) {
|
|
48
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isComponentHandlerFn(input) {
|
|
52
|
+
return typeof input === 'function';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/*
|
|
56
|
+
* Copyright (c) 2025.
|
|
57
|
+
* Author Peter Placzek (tada5hi)
|
|
58
|
+
* For the full copyright and license information,
|
|
59
|
+
* view the LICENSE file that was distributed with this source code.
|
|
60
|
+
*/ function _define_property$7(obj, key, value) {
|
|
61
|
+
if (key in obj) {
|
|
62
|
+
Object.defineProperty(obj, key, {
|
|
63
|
+
value: value,
|
|
64
|
+
enumerable: true,
|
|
65
|
+
configurable: true,
|
|
66
|
+
writable: true
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
obj[key] = value;
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
class ComponentHandlers {
|
|
74
|
+
mount(key, fn) {
|
|
75
|
+
this.handlers[key] = fn;
|
|
76
|
+
}
|
|
77
|
+
unmount(key) {
|
|
78
|
+
delete this.handlers[key];
|
|
79
|
+
}
|
|
80
|
+
async setup() {
|
|
81
|
+
const keys = Object.keys(this.handlers);
|
|
82
|
+
for(let i = 0; i < keys.length; i++){
|
|
83
|
+
const handler = this.handlers[keys[i]];
|
|
84
|
+
if (!isComponentHandlerFn(handler) && handler.setup) {
|
|
85
|
+
await handler.setup();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async execute(key, value = {}, metadata = {}) {
|
|
90
|
+
const handler = this.handlers[key];
|
|
91
|
+
if (!handler) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (isComponentHandlerFn(handler)) {
|
|
95
|
+
await handler(value, {
|
|
96
|
+
key,
|
|
97
|
+
metadata
|
|
98
|
+
});
|
|
99
|
+
} else {
|
|
100
|
+
await handler.handle(value, {
|
|
101
|
+
key,
|
|
102
|
+
metadata
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
constructor(){
|
|
107
|
+
_define_property$7(this, "handlers", void 0);
|
|
108
|
+
this.handlers = {};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
45
112
|
function isComponentError(input) {
|
|
46
113
|
if (!kit.isObject(input)) {
|
|
47
114
|
return false;
|
|
@@ -85,30 +152,30 @@ function isQueueRouterPayload(input) {
|
|
|
85
152
|
return kit.isObject(input) && typeof input.id === 'string' && typeof input.type === 'string' && kit.hasOwnProperty(input, 'data') && kit.isObject(input.data) && kit.hasOwnProperty(input, 'metadata') && kit.isObject(input.metadata);
|
|
86
153
|
}
|
|
87
154
|
|
|
88
|
-
const instance$
|
|
155
|
+
const instance$9 = singa.singa({
|
|
89
156
|
name: 'amqp'
|
|
90
157
|
});
|
|
91
158
|
function setAmqpClientFactory(factory) {
|
|
92
|
-
instance$
|
|
159
|
+
instance$9.setFactory(factory);
|
|
93
160
|
}
|
|
94
161
|
function isAmqpClientUsable() {
|
|
95
|
-
return instance$
|
|
162
|
+
return instance$9.has() || instance$9.hasFactory();
|
|
96
163
|
}
|
|
97
164
|
function useAmqpClient() {
|
|
98
|
-
return instance$
|
|
165
|
+
return instance$9.use();
|
|
99
166
|
}
|
|
100
167
|
|
|
101
|
-
const instance$
|
|
168
|
+
const instance$8 = singa.singa({
|
|
102
169
|
name: 'vault'
|
|
103
170
|
});
|
|
104
171
|
function setVaultFactory(factory) {
|
|
105
|
-
instance$
|
|
172
|
+
instance$8.setFactory(factory);
|
|
106
173
|
}
|
|
107
174
|
function isVaultClientUsable() {
|
|
108
|
-
return instance$
|
|
175
|
+
return instance$8.has() || instance$8.hasFactory();
|
|
109
176
|
}
|
|
110
177
|
function useVaultClient() {
|
|
111
|
-
return instance$
|
|
178
|
+
return instance$8.use();
|
|
112
179
|
}
|
|
113
180
|
|
|
114
181
|
function guessAuthupTokenCreatorOptions() {
|
|
@@ -129,17 +196,17 @@ function guessAuthupTokenCreatorOptions() {
|
|
|
129
196
|
return options;
|
|
130
197
|
}
|
|
131
198
|
|
|
132
|
-
const instance$
|
|
199
|
+
const instance$7 = singa.singa({
|
|
133
200
|
name: 'clientAuthenticationHook'
|
|
134
201
|
});
|
|
135
202
|
function setClientAuthenticationHookFactory(factory) {
|
|
136
|
-
instance$
|
|
203
|
+
instance$7.setFactory(factory);
|
|
137
204
|
}
|
|
138
205
|
function isClientAuthenticationHookUsable() {
|
|
139
|
-
return instance$
|
|
206
|
+
return instance$7.has() || instance$7.hasFactory();
|
|
140
207
|
}
|
|
141
208
|
function useClientAuthenticationHook() {
|
|
142
|
-
return instance$
|
|
209
|
+
return instance$7.use();
|
|
143
210
|
}
|
|
144
211
|
|
|
145
212
|
class AuthupClient extends coreHttpKit.Client {
|
|
@@ -156,49 +223,49 @@ class AuthupClient extends coreHttpKit.Client {
|
|
|
156
223
|
}
|
|
157
224
|
}
|
|
158
225
|
|
|
159
|
-
const instance$
|
|
226
|
+
const instance$6 = singa.singa({
|
|
160
227
|
name: 'authup'
|
|
161
228
|
});
|
|
162
229
|
function useAuthupClient() {
|
|
163
|
-
return instance$
|
|
230
|
+
return instance$6.use();
|
|
164
231
|
}
|
|
165
232
|
function isAuthupClientUsable() {
|
|
166
|
-
return instance$
|
|
233
|
+
return instance$6.has() || instance$6.hasFactory();
|
|
167
234
|
}
|
|
168
235
|
function setAuthupClientFactory(factory) {
|
|
169
|
-
instance$
|
|
236
|
+
instance$6.setFactory(factory);
|
|
170
237
|
}
|
|
171
238
|
|
|
172
|
-
const instance$
|
|
239
|
+
const instance$5 = singa.singa({
|
|
173
240
|
name: 'redis'
|
|
174
241
|
});
|
|
175
242
|
function setRedisFactory(factory) {
|
|
176
|
-
instance$
|
|
243
|
+
instance$5.setFactory(factory);
|
|
177
244
|
}
|
|
178
245
|
function isRedisClientUsable() {
|
|
179
|
-
return instance$
|
|
246
|
+
return instance$5.has() || instance$5.hasFactory();
|
|
180
247
|
}
|
|
181
248
|
function setRedisClient(input) {
|
|
182
|
-
instance$
|
|
249
|
+
instance$5.set(input);
|
|
183
250
|
}
|
|
184
251
|
function useRedisClient() {
|
|
185
|
-
return instance$
|
|
252
|
+
return instance$5.use();
|
|
186
253
|
}
|
|
187
254
|
|
|
188
|
-
const instance$
|
|
255
|
+
const instance$4 = singa.singa({
|
|
189
256
|
name: 'redisPublish',
|
|
190
257
|
factory: ()=>useRedisClient().duplicate()
|
|
191
258
|
});
|
|
192
259
|
function useRedisPublishClient() {
|
|
193
|
-
return instance$
|
|
260
|
+
return instance$4.use();
|
|
194
261
|
}
|
|
195
262
|
|
|
196
|
-
const instance$
|
|
263
|
+
const instance$3 = singa.singa({
|
|
197
264
|
name: 'redisSubscribe',
|
|
198
265
|
factory: ()=>useRedisClient().duplicate()
|
|
199
266
|
});
|
|
200
267
|
function useRedisSubscribeClient() {
|
|
201
|
-
return instance$
|
|
268
|
+
return instance$3.use();
|
|
202
269
|
}
|
|
203
270
|
|
|
204
271
|
/*
|
|
@@ -206,7 +273,7 @@ function useRedisSubscribeClient() {
|
|
|
206
273
|
* Author Peter Placzek (tada5hi)
|
|
207
274
|
* For the full copyright and license information,
|
|
208
275
|
* view the LICENSE file that was distributed with this source code.
|
|
209
|
-
*/ function _define_property$
|
|
276
|
+
*/ function _define_property$6(obj, key, value) {
|
|
210
277
|
if (key in obj) {
|
|
211
278
|
Object.defineProperty(obj, key, {
|
|
212
279
|
value: value,
|
|
@@ -254,7 +321,7 @@ class MemoryCacheAdapter {
|
|
|
254
321
|
this.instance.clear();
|
|
255
322
|
}
|
|
256
323
|
constructor(options = {}){
|
|
257
|
-
_define_property$
|
|
324
|
+
_define_property$6(this, "instance", void 0);
|
|
258
325
|
this.instance = new TTLCache({
|
|
259
326
|
checkAgeOnGet: true,
|
|
260
327
|
ttl: Infinity,
|
|
@@ -268,7 +335,7 @@ class MemoryCacheAdapter {
|
|
|
268
335
|
* Author Peter Placzek (tada5hi)
|
|
269
336
|
* For the full copyright and license information,
|
|
270
337
|
* view the LICENSE file that was distributed with this source code.
|
|
271
|
-
*/ function _define_property$
|
|
338
|
+
*/ function _define_property$5(obj, key, value) {
|
|
272
339
|
if (key in obj) {
|
|
273
340
|
Object.defineProperty(obj, key, {
|
|
274
341
|
value: value,
|
|
@@ -317,8 +384,8 @@ class RedisCacheAdapter {
|
|
|
317
384
|
await this.client.flushdb();
|
|
318
385
|
}
|
|
319
386
|
constructor(){
|
|
320
|
-
_define_property$
|
|
321
|
-
_define_property$
|
|
387
|
+
_define_property$5(this, "client", void 0);
|
|
388
|
+
_define_property$5(this, "instance", void 0);
|
|
322
389
|
this.client = useRedisClient();
|
|
323
390
|
this.instance = new redisExtension.JsonAdapter(this.client);
|
|
324
391
|
}
|
|
@@ -340,7 +407,7 @@ function buildCacheKey(options) {
|
|
|
340
407
|
* Author Peter Placzek (tada5hi)
|
|
341
408
|
* For the full copyright and license information,
|
|
342
409
|
* view the LICENSE file that was distributed with this source code.
|
|
343
|
-
*/ function _define_property$
|
|
410
|
+
*/ function _define_property$4(obj, key, value) {
|
|
344
411
|
if (key in obj) {
|
|
345
412
|
Object.defineProperty(obj, key, {
|
|
346
413
|
value: value,
|
|
@@ -373,12 +440,12 @@ class Cache {
|
|
|
373
440
|
return this.adapter.clear(options);
|
|
374
441
|
}
|
|
375
442
|
constructor(adapter){
|
|
376
|
-
_define_property$
|
|
443
|
+
_define_property$4(this, "adapter", void 0);
|
|
377
444
|
this.adapter = adapter;
|
|
378
445
|
}
|
|
379
446
|
}
|
|
380
447
|
|
|
381
|
-
const instance$
|
|
448
|
+
const instance$2 = singa.singa({
|
|
382
449
|
name: 'cache',
|
|
383
450
|
factory: ()=>{
|
|
384
451
|
let adapter;
|
|
@@ -391,397 +458,29 @@ const instance$4 = singa.singa({
|
|
|
391
458
|
}
|
|
392
459
|
});
|
|
393
460
|
function useCache() {
|
|
394
|
-
return instance$4.use();
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
/*
|
|
398
|
-
* Copyright (c) 2025.
|
|
399
|
-
* Author Peter Placzek (tada5hi)
|
|
400
|
-
* For the full copyright and license information,
|
|
401
|
-
* view the LICENSE file that was distributed with this source code.
|
|
402
|
-
*/ function _define_property$7(obj, key, value) {
|
|
403
|
-
if (key in obj) {
|
|
404
|
-
Object.defineProperty(obj, key, {
|
|
405
|
-
value: value,
|
|
406
|
-
enumerable: true,
|
|
407
|
-
configurable: true,
|
|
408
|
-
writable: true
|
|
409
|
-
});
|
|
410
|
-
} else {
|
|
411
|
-
obj[key] = value;
|
|
412
|
-
}
|
|
413
|
-
return obj;
|
|
414
|
-
}
|
|
415
|
-
class LogStoreTransport extends WinstonTransport {
|
|
416
|
-
log(info, next) {
|
|
417
|
-
const { message, timestamp, stack, ...data } = info;
|
|
418
|
-
const labels = {
|
|
419
|
-
...this.labels
|
|
420
|
-
};
|
|
421
|
-
const keys = Object.keys(data);
|
|
422
|
-
for(let i = 0; i < keys.length; i++){
|
|
423
|
-
if (typeof keys[i] !== 'string') {
|
|
424
|
-
continue;
|
|
425
|
-
}
|
|
426
|
-
const value = data[keys[i]];
|
|
427
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
428
|
-
labels[keys[i]] = `${value}`;
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
let date;
|
|
432
|
-
if (typeof timestamp === 'string') {
|
|
433
|
-
date = new Date(`${timestamp}`);
|
|
434
|
-
} else {
|
|
435
|
-
date = new Date();
|
|
436
|
-
}
|
|
437
|
-
const payload = {
|
|
438
|
-
message: stack || message,
|
|
439
|
-
time: BigInt(date.getTime()) * 1000000n,
|
|
440
|
-
labels
|
|
441
|
-
};
|
|
442
|
-
Promise.resolve().then(()=>this.instance.write(payload)).then(()=>next());
|
|
443
|
-
}
|
|
444
|
-
constructor(store, options = {}){
|
|
445
|
-
super(options), _define_property$7(this, "instance", void 0), _define_property$7(this, "labels", void 0);
|
|
446
|
-
this.instance = store;
|
|
447
|
-
this.labels = options.labels || {};
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
const instance$3 = singa.singa({
|
|
452
|
-
name: 'loki'
|
|
453
|
-
});
|
|
454
|
-
function setLokiFactory(factory) {
|
|
455
|
-
instance$3.setFactory(factory);
|
|
456
|
-
}
|
|
457
|
-
function isLokiClientUsable() {
|
|
458
|
-
return instance$3.has() || instance$3.hasFactory();
|
|
459
|
-
}
|
|
460
|
-
function useLokiClient() {
|
|
461
|
-
return instance$3.use();
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
/*
|
|
465
|
-
* Copyright (c) 2025.
|
|
466
|
-
* Author Peter Placzek (tada5hi)
|
|
467
|
-
* For the full copyright and license information,
|
|
468
|
-
* view the LICENSE file that was distributed with this source code.
|
|
469
|
-
*/ function _define_property$6(obj, key, value) {
|
|
470
|
-
if (key in obj) {
|
|
471
|
-
Object.defineProperty(obj, key, {
|
|
472
|
-
value: value,
|
|
473
|
-
enumerable: true,
|
|
474
|
-
configurable: true,
|
|
475
|
-
writable: true
|
|
476
|
-
});
|
|
477
|
-
} else {
|
|
478
|
-
obj[key] = value;
|
|
479
|
-
}
|
|
480
|
-
return obj;
|
|
481
|
-
}
|
|
482
|
-
class BaseLogStore {
|
|
483
|
-
setLabels(labels) {
|
|
484
|
-
this.labels = labels;
|
|
485
|
-
}
|
|
486
|
-
getLabels() {
|
|
487
|
-
return this.labels;
|
|
488
|
-
}
|
|
489
|
-
extendLabels(labels) {
|
|
490
|
-
const keys = Object.keys(labels);
|
|
491
|
-
for(let i = 0; i < keys.length; i++){
|
|
492
|
-
this.labels[keys[i]] = labels[keys[i]];
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
constructor(){
|
|
496
|
-
_define_property$6(this, "labels", void 0);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/*
|
|
501
|
-
* Copyright (c) 2025.
|
|
502
|
-
* Author Peter Placzek (tada5hi)
|
|
503
|
-
* For the full copyright and license information,
|
|
504
|
-
* view the LICENSE file that was distributed with this source code.
|
|
505
|
-
*/ function _define_property$5(obj, key, value) {
|
|
506
|
-
if (key in obj) {
|
|
507
|
-
Object.defineProperty(obj, key, {
|
|
508
|
-
value: value,
|
|
509
|
-
enumerable: true,
|
|
510
|
-
configurable: true,
|
|
511
|
-
writable: true
|
|
512
|
-
});
|
|
513
|
-
} else {
|
|
514
|
-
obj[key] = value;
|
|
515
|
-
}
|
|
516
|
-
return obj;
|
|
517
|
-
}
|
|
518
|
-
class LokiLogStore extends BaseLogStore {
|
|
519
|
-
async write(message, labels) {
|
|
520
|
-
let data;
|
|
521
|
-
if (typeof message === 'string') {
|
|
522
|
-
const labelsNormalized = {
|
|
523
|
-
...this.labels,
|
|
524
|
-
...labels || {}
|
|
525
|
-
};
|
|
526
|
-
const level = labelsNormalized.level || kit.LogLevel.DEBUG;
|
|
527
|
-
delete labelsNormalized.level;
|
|
528
|
-
data = {
|
|
529
|
-
message,
|
|
530
|
-
level,
|
|
531
|
-
time: loki.nanoSeconds(),
|
|
532
|
-
labels: labelsNormalized
|
|
533
|
-
};
|
|
534
|
-
} else {
|
|
535
|
-
const labelsNormalized = {
|
|
536
|
-
...this.labels,
|
|
537
|
-
...message.labels || {},
|
|
538
|
-
...labels || {}
|
|
539
|
-
};
|
|
540
|
-
const level = message.level || labelsNormalized.level || kit.LogLevel.DEBUG;
|
|
541
|
-
delete labelsNormalized.level;
|
|
542
|
-
data = {
|
|
543
|
-
...message,
|
|
544
|
-
level,
|
|
545
|
-
time: message.time || loki.nanoSeconds(),
|
|
546
|
-
labels: labelsNormalized
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
const stream = {
|
|
550
|
-
stream: data.labels,
|
|
551
|
-
values: [
|
|
552
|
-
[
|
|
553
|
-
data.time,
|
|
554
|
-
data.message,
|
|
555
|
-
{
|
|
556
|
-
level: data.level
|
|
557
|
-
}
|
|
558
|
-
]
|
|
559
|
-
]
|
|
560
|
-
};
|
|
561
|
-
await this.instance.distributor.push(stream);
|
|
562
|
-
return data;
|
|
563
|
-
}
|
|
564
|
-
async delete(options) {
|
|
565
|
-
await this.instance.compactor.createDeletionRequest({
|
|
566
|
-
start: options.start,
|
|
567
|
-
...options.end ? {
|
|
568
|
-
end: options.end
|
|
569
|
-
} : {},
|
|
570
|
-
query: this.buildQuery({
|
|
571
|
-
...this.labels,
|
|
572
|
-
...options.labels || {}
|
|
573
|
-
})
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
async query(input) {
|
|
577
|
-
const options = {
|
|
578
|
-
query: this.buildQuery({
|
|
579
|
-
...this.labels,
|
|
580
|
-
...input.labels || {}
|
|
581
|
-
})
|
|
582
|
-
};
|
|
583
|
-
if (input.sort) {
|
|
584
|
-
options.direction = input.sort === 'DESC' ? 'forward' : 'backward';
|
|
585
|
-
}
|
|
586
|
-
if (input.limit) {
|
|
587
|
-
options.limit = input.limit;
|
|
588
|
-
}
|
|
589
|
-
if (input.start) {
|
|
590
|
-
options.start = BigInt(new Date(`${input.start}`).getTime()) * 1000000n;
|
|
591
|
-
}
|
|
592
|
-
if (input.end) {
|
|
593
|
-
options.end = BigInt(new Date(`${input.end}`).getTime()) * 1000000n;
|
|
594
|
-
}
|
|
595
|
-
const output = [];
|
|
596
|
-
const response = await this.instance.querier.queryRange(options);
|
|
597
|
-
if (response.data.resultType === 'streams') {
|
|
598
|
-
for(let i = 0; i < response.data.result.length; i++){
|
|
599
|
-
const set = response.data.result[i];
|
|
600
|
-
const labels = set.stream;
|
|
601
|
-
let level;
|
|
602
|
-
if (labels.level) {
|
|
603
|
-
level = labels.level;
|
|
604
|
-
} else {
|
|
605
|
-
level = labels.detected_level;
|
|
606
|
-
}
|
|
607
|
-
delete labels.level;
|
|
608
|
-
delete labels.detected_level;
|
|
609
|
-
if (!labels.service) {
|
|
610
|
-
labels.service = labels.service_name;
|
|
611
|
-
}
|
|
612
|
-
delete labels.service_name;
|
|
613
|
-
for(let j = 0; j < set.values.length; j++){
|
|
614
|
-
output.push({
|
|
615
|
-
time: BigInt(set.values[j][0]),
|
|
616
|
-
message: set.values[j][1],
|
|
617
|
-
level,
|
|
618
|
-
labels
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
return [
|
|
624
|
-
output,
|
|
625
|
-
output.length
|
|
626
|
-
];
|
|
627
|
-
}
|
|
628
|
-
// ----------------------------------------------
|
|
629
|
-
buildQuery(labels) {
|
|
630
|
-
const output = [];
|
|
631
|
-
const keys = Object.keys(labels);
|
|
632
|
-
for(let i = 0; i < keys.length; i++){
|
|
633
|
-
output.push(`${keys[i]}="${labels[keys[i]]}"`);
|
|
634
|
-
}
|
|
635
|
-
return `{${output.join(',')}}`;
|
|
636
|
-
}
|
|
637
|
-
constructor(instance, labels){
|
|
638
|
-
super(), _define_property$5(this, "instance", void 0);
|
|
639
|
-
this.instance = instance;
|
|
640
|
-
this.labels = labels || {};
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
/*
|
|
645
|
-
* Copyright (c) 2025.
|
|
646
|
-
* Author Peter Placzek (tada5hi)
|
|
647
|
-
* For the full copyright and license information,
|
|
648
|
-
* view the LICENSE file that was distributed with this source code.
|
|
649
|
-
*/ function _define_property$4(obj, key, value) {
|
|
650
|
-
if (key in obj) {
|
|
651
|
-
Object.defineProperty(obj, key, {
|
|
652
|
-
value: value,
|
|
653
|
-
enumerable: true,
|
|
654
|
-
configurable: true,
|
|
655
|
-
writable: true
|
|
656
|
-
});
|
|
657
|
-
} else {
|
|
658
|
-
obj[key] = value;
|
|
659
|
-
}
|
|
660
|
-
return obj;
|
|
661
|
-
}
|
|
662
|
-
class MemoryLogStore extends BaseLogStore {
|
|
663
|
-
// todo: apply query options
|
|
664
|
-
async delete() {
|
|
665
|
-
return Promise.resolve();
|
|
666
|
-
}
|
|
667
|
-
async query(options = {}) {
|
|
668
|
-
// todo: apply all query options
|
|
669
|
-
const data = this.items.filter((item)=>{
|
|
670
|
-
if (options.labels) {
|
|
671
|
-
if (!item.labels) {
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
674
|
-
const labelKeys = Object.keys(options.labels);
|
|
675
|
-
for(let i = 0; i < labelKeys.length; i++){
|
|
676
|
-
if (!item.labels[labelKeys[i]]) {
|
|
677
|
-
return false;
|
|
678
|
-
}
|
|
679
|
-
if (item.labels[labelKeys[i]] !== options.labels[labelKeys[i]]) {
|
|
680
|
-
return false;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
return true;
|
|
685
|
-
});
|
|
686
|
-
return [
|
|
687
|
-
data,
|
|
688
|
-
data.length
|
|
689
|
-
];
|
|
690
|
-
}
|
|
691
|
-
async write(message, labels) {
|
|
692
|
-
let data;
|
|
693
|
-
if (typeof message === 'string') {
|
|
694
|
-
const labelsNormalized = {
|
|
695
|
-
...this.labels,
|
|
696
|
-
...labels || {}
|
|
697
|
-
};
|
|
698
|
-
const level = labelsNormalized.level || kit.LogLevel.DEBUG;
|
|
699
|
-
delete labelsNormalized.level;
|
|
700
|
-
data = {
|
|
701
|
-
message,
|
|
702
|
-
level,
|
|
703
|
-
time: loki.nanoSeconds(),
|
|
704
|
-
labels: labelsNormalized
|
|
705
|
-
};
|
|
706
|
-
} else {
|
|
707
|
-
const labelsNormalized = {
|
|
708
|
-
...this.labels,
|
|
709
|
-
...message.labels || {},
|
|
710
|
-
...labels || {}
|
|
711
|
-
};
|
|
712
|
-
const level = message.level || labelsNormalized.level || kit.LogLevel.DEBUG;
|
|
713
|
-
delete labelsNormalized.level;
|
|
714
|
-
data = {
|
|
715
|
-
...message,
|
|
716
|
-
level,
|
|
717
|
-
time: message.time || loki.nanoSeconds(),
|
|
718
|
-
labels: labelsNormalized
|
|
719
|
-
};
|
|
720
|
-
}
|
|
721
|
-
this.items.push(data);
|
|
722
|
-
return data;
|
|
723
|
-
}
|
|
724
|
-
constructor(labels){
|
|
725
|
-
super(), _define_property$4(this, "items", void 0);
|
|
726
|
-
this.items = [];
|
|
727
|
-
this.labels = labels;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
const instance$2 = singa.singa({
|
|
732
|
-
name: 'logStore',
|
|
733
|
-
factory: ()=>{
|
|
734
|
-
if (isLokiClientUsable()) {
|
|
735
|
-
const loki = useLokiClient();
|
|
736
|
-
return new LokiLogStore(loki);
|
|
737
|
-
}
|
|
738
|
-
return new MemoryLogStore();
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
function isLogStoreUsable() {
|
|
742
|
-
return instance$2.has() || instance$2.hasFactory();
|
|
743
|
-
}
|
|
744
|
-
function setLogStoreFactory(input) {
|
|
745
|
-
instance$2.setFactory(input);
|
|
746
|
-
}
|
|
747
|
-
function useLogStore() {
|
|
748
461
|
return instance$2.use();
|
|
749
462
|
}
|
|
750
463
|
|
|
464
|
+
function toTransports(input) {
|
|
465
|
+
return Array.isArray(input) ? input : [
|
|
466
|
+
input
|
|
467
|
+
];
|
|
468
|
+
}
|
|
751
469
|
function createLogger(ctx = {}) {
|
|
752
|
-
const store = ctx.store || useLogStore();
|
|
753
470
|
let loggerTransports;
|
|
754
471
|
if (envix.read('env') === typeormExtension.EnvironmentName.PRODUCTION) {
|
|
755
472
|
loggerTransports = [
|
|
756
473
|
new winston.transports.Console({
|
|
757
474
|
level: 'info'
|
|
758
475
|
}),
|
|
759
|
-
|
|
760
|
-
filename: path.join(ctx.directory || process.cwd(), 'access.log'),
|
|
761
|
-
level: 'http',
|
|
762
|
-
maxsize: 10 * 1024 * 1024,
|
|
763
|
-
maxFiles: 5
|
|
764
|
-
}),
|
|
765
|
-
new winston.transports.File({
|
|
766
|
-
filename: path.join(ctx.directory || process.cwd(), 'error.log'),
|
|
767
|
-
level: 'warn',
|
|
768
|
-
maxsize: 10 * 1024 * 1024,
|
|
769
|
-
maxFiles: 5
|
|
770
|
-
}),
|
|
771
|
-
new LogStoreTransport(store, {
|
|
772
|
-
level: 'http',
|
|
773
|
-
labels: ctx.labels
|
|
774
|
-
})
|
|
476
|
+
...ctx.transports ? toTransports(ctx.transports) : []
|
|
775
477
|
];
|
|
776
478
|
} else {
|
|
777
479
|
loggerTransports = [
|
|
778
480
|
new winston.transports.Console({
|
|
779
481
|
level: 'debug'
|
|
780
482
|
}),
|
|
781
|
-
|
|
782
|
-
level: 'http',
|
|
783
|
-
labels: ctx.labels
|
|
784
|
-
})
|
|
483
|
+
...ctx.transports ? toTransports(ctx.transports) : []
|
|
785
484
|
];
|
|
786
485
|
}
|
|
787
486
|
return winston.createLogger({
|
|
@@ -830,8 +529,8 @@ function useLogger() {
|
|
|
830
529
|
return obj;
|
|
831
530
|
}
|
|
832
531
|
class DomainEventPublisher {
|
|
833
|
-
|
|
834
|
-
this.
|
|
532
|
+
addConsumer(consumer) {
|
|
533
|
+
this.consumers.add(consumer);
|
|
835
534
|
}
|
|
836
535
|
async safePublish(ctx) {
|
|
837
536
|
try {
|
|
@@ -847,18 +546,28 @@ class DomainEventPublisher {
|
|
|
847
546
|
if (isLoggerUsable()) {
|
|
848
547
|
useLogger().info(`Publishing event ${kit.buildDomainEventFullName(ctx.metadata.domain, ctx.metadata.event)}`);
|
|
849
548
|
}
|
|
850
|
-
|
|
549
|
+
let destinations = [];
|
|
550
|
+
if (typeof ctx.destinations === 'function') {
|
|
551
|
+
destinations = ctx.destinations(ctx.data);
|
|
552
|
+
} else {
|
|
553
|
+
destinations = ctx.destinations;
|
|
554
|
+
}
|
|
555
|
+
const consumeContext = {
|
|
556
|
+
...ctx,
|
|
557
|
+
destinations
|
|
558
|
+
};
|
|
559
|
+
const consumers = this.consumers.values();
|
|
851
560
|
while(true){
|
|
852
|
-
const it =
|
|
561
|
+
const it = consumers.next();
|
|
853
562
|
if (it.done) {
|
|
854
563
|
return;
|
|
855
564
|
}
|
|
856
|
-
await it.value.
|
|
565
|
+
await it.value.consume(consumeContext);
|
|
857
566
|
}
|
|
858
567
|
}
|
|
859
568
|
constructor(){
|
|
860
|
-
_define_property$3(this, "
|
|
861
|
-
this.
|
|
569
|
+
_define_property$3(this, "consumers", void 0);
|
|
570
|
+
this.consumers = new Set();
|
|
862
571
|
}
|
|
863
572
|
}
|
|
864
573
|
|
|
@@ -874,11 +583,25 @@ function transformEventData(input) {
|
|
|
874
583
|
}
|
|
875
584
|
return input;
|
|
876
585
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
586
|
+
|
|
587
|
+
/*
|
|
588
|
+
* Copyright (c) 2025.
|
|
589
|
+
* Author Peter Placzek (tada5hi)
|
|
590
|
+
* For the full copyright and license information,
|
|
591
|
+
* view the LICENSE file that was distributed with this source code.
|
|
592
|
+
*/ function stringify(input) {
|
|
593
|
+
return typeof input === 'string' ? input : input.join('/');
|
|
594
|
+
}
|
|
595
|
+
function buildDomainEventRedisChannel(channel, namespace) {
|
|
596
|
+
const channelNormalized = stringify(channel);
|
|
597
|
+
let namespaceNormalized;
|
|
598
|
+
if (namespace) {
|
|
599
|
+
namespaceNormalized = stringify(namespace);
|
|
880
600
|
}
|
|
881
|
-
|
|
601
|
+
if (typeof namespaceNormalized === 'undefined') {
|
|
602
|
+
return channelNormalized;
|
|
603
|
+
}
|
|
604
|
+
return `${namespaceNormalized}/${channelNormalized}`;
|
|
882
605
|
}
|
|
883
606
|
|
|
884
607
|
/*
|
|
@@ -900,7 +623,7 @@ function buildEventChannelName(input, id) {
|
|
|
900
623
|
return obj;
|
|
901
624
|
}
|
|
902
625
|
class DomainEventRedisPublisher {
|
|
903
|
-
async
|
|
626
|
+
async consume(ctx) {
|
|
904
627
|
const payload = {
|
|
905
628
|
type: ctx.metadata.domain,
|
|
906
629
|
event: ctx.metadata.event,
|
|
@@ -910,21 +633,8 @@ class DomainEventRedisPublisher {
|
|
|
910
633
|
const pipeline = this.driver.pipeline();
|
|
911
634
|
for(let i = 0; i < ctx.destinations.length; i++){
|
|
912
635
|
const destination = ctx.destinations[i];
|
|
913
|
-
|
|
914
|
-
if (destination.namespace) {
|
|
915
|
-
keyPrefix = typeof destination.namespace === 'function' ? destination.namespace(ctx.data) : destination.namespace;
|
|
916
|
-
}
|
|
917
|
-
let key;
|
|
918
|
-
if (keyPrefix) {
|
|
919
|
-
key = keyPrefix + buildEventChannelName(destination.channel);
|
|
920
|
-
} else {
|
|
921
|
-
key = buildEventChannelName(destination.channel);
|
|
922
|
-
}
|
|
636
|
+
const key = buildDomainEventRedisChannel(destination.channel, destination.namespace);
|
|
923
637
|
pipeline.publish(key, payloadSerialized);
|
|
924
|
-
if (typeof destination.channel === 'function') {
|
|
925
|
-
key = keyPrefix + buildEventChannelName(destination.channel, ctx.data.id);
|
|
926
|
-
pipeline.publish(key, payloadSerialized);
|
|
927
|
-
}
|
|
928
638
|
}
|
|
929
639
|
await pipeline.exec();
|
|
930
640
|
}
|
|
@@ -934,6 +644,27 @@ class DomainEventRedisPublisher {
|
|
|
934
644
|
}
|
|
935
645
|
}
|
|
936
646
|
|
|
647
|
+
/*
|
|
648
|
+
* Copyright (c) 2025.
|
|
649
|
+
* Author Peter Placzek (tada5hi)
|
|
650
|
+
* For the full copyright and license information,
|
|
651
|
+
* view the LICENSE file that was distributed with this source code.
|
|
652
|
+
*/ function buildDomainEventSocketNamespace(namespace) {
|
|
653
|
+
if (typeof namespace === 'undefined') {
|
|
654
|
+
return '/';
|
|
655
|
+
}
|
|
656
|
+
if (typeof namespace === 'string') {
|
|
657
|
+
return namespace.startsWith('/') ? namespace : `/${namespace}`;
|
|
658
|
+
}
|
|
659
|
+
return `/${namespace.join('/')}`;
|
|
660
|
+
}
|
|
661
|
+
function buildDomainEventSocketChannel(channel) {
|
|
662
|
+
if (typeof channel === 'string') {
|
|
663
|
+
return channel;
|
|
664
|
+
}
|
|
665
|
+
return channel.join('/');
|
|
666
|
+
}
|
|
667
|
+
|
|
937
668
|
/*
|
|
938
669
|
* Copyright (c) 2022-2024.
|
|
939
670
|
* Author Peter Placzek (tada5hi)
|
|
@@ -952,38 +683,26 @@ class DomainEventRedisPublisher {
|
|
|
952
683
|
}
|
|
953
684
|
return obj;
|
|
954
685
|
}
|
|
955
|
-
class
|
|
956
|
-
async
|
|
686
|
+
class DomainEventSocketConsumer {
|
|
687
|
+
async consume(ctx) {
|
|
957
688
|
ctx.data = transformEventData(ctx.data);
|
|
958
689
|
for(let i = 0; i < ctx.destinations.length; i++){
|
|
959
690
|
const destination = ctx.destinations[i];
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
namespace = typeof destination.namespace === 'function' ? destination.namespace(ctx.data) : destination.namespace;
|
|
963
|
-
} else {
|
|
964
|
-
namespace = '/';
|
|
965
|
-
}
|
|
966
|
-
const emitter = new redisEmitter.Emitter(this.client, {}, namespace);
|
|
691
|
+
const namespace = buildDomainEventSocketNamespace(destination.namespace);
|
|
692
|
+
const roomName = buildDomainEventSocketChannel(destination.channel);
|
|
967
693
|
const fullEventName = kit.buildDomainEventFullName(ctx.metadata.domain, ctx.metadata.event);
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
},
|
|
981
|
-
meta: {
|
|
982
|
-
namespace,
|
|
983
|
-
roomName: rooms[j]
|
|
984
|
-
}
|
|
985
|
-
});
|
|
986
|
-
}
|
|
694
|
+
const emitter = new redisEmitter.Emitter(this.client, {}, namespace);
|
|
695
|
+
emitter.in(roomName).emit(fullEventName, {
|
|
696
|
+
data: {
|
|
697
|
+
data: ctx.data,
|
|
698
|
+
type: ctx.metadata.domain,
|
|
699
|
+
event: ctx.metadata.event
|
|
700
|
+
},
|
|
701
|
+
meta: {
|
|
702
|
+
namespace,
|
|
703
|
+
roomName
|
|
704
|
+
}
|
|
705
|
+
});
|
|
987
706
|
}
|
|
988
707
|
}
|
|
989
708
|
constructor(client){
|
|
@@ -998,8 +717,8 @@ const singaInstance = singa.singa({
|
|
|
998
717
|
const publisher = new DomainEventPublisher();
|
|
999
718
|
if (isRedisClientUsable()) {
|
|
1000
719
|
const client = useRedisClient();
|
|
1001
|
-
publisher.
|
|
1002
|
-
publisher.
|
|
720
|
+
publisher.addConsumer(new DomainEventRedisPublisher(client));
|
|
721
|
+
publisher.addConsumer(new DomainEventSocketConsumer(client));
|
|
1003
722
|
}
|
|
1004
723
|
return publisher;
|
|
1005
724
|
}
|
|
@@ -1031,7 +750,9 @@ function useDomainEventPublisher() {
|
|
|
1031
750
|
}
|
|
1032
751
|
class QueueRouter {
|
|
1033
752
|
//----------------------------------------------------------------
|
|
1034
|
-
publish(message) {
|
|
753
|
+
publish(message, options = {}) {
|
|
754
|
+
var _options;
|
|
755
|
+
(_options = options).logging ?? (_options.logging = true);
|
|
1035
756
|
let exchange;
|
|
1036
757
|
if (message.metadata.routing.type === 'work') {
|
|
1037
758
|
exchange = this.driver.of({
|
|
@@ -1044,7 +765,7 @@ class QueueRouter {
|
|
|
1044
765
|
name: message.metadata.routing.namespace || 'FLAME'
|
|
1045
766
|
});
|
|
1046
767
|
}
|
|
1047
|
-
if (isLoggerUsable()) {
|
|
768
|
+
if (options.logging && isLoggerUsable()) {
|
|
1048
769
|
useLogger().debug(`Publishing queue message ${message.type} in ${message.metadata.routing.key}`);
|
|
1049
770
|
}
|
|
1050
771
|
return exchange.publish(message.metadata.routing.key, message, {
|
|
@@ -1053,6 +774,11 @@ class QueueRouter {
|
|
|
1053
774
|
persistent: message.metadata.persistent ?? message.metadata.routing.type === QueueRouterRoutingType.WORK
|
|
1054
775
|
});
|
|
1055
776
|
}
|
|
777
|
+
consumeAny(routing, fn) {
|
|
778
|
+
return this.consume(routing, {
|
|
779
|
+
$any: (payload)=>fn(payload)
|
|
780
|
+
});
|
|
781
|
+
}
|
|
1056
782
|
consume(routing, handlers) {
|
|
1057
783
|
let exchange;
|
|
1058
784
|
if (routing.type === 'work') {
|
|
@@ -1097,7 +823,14 @@ class QueueRouter {
|
|
|
1097
823
|
}
|
|
1098
824
|
return;
|
|
1099
825
|
}
|
|
1100
|
-
|
|
826
|
+
try {
|
|
827
|
+
await handler(payload);
|
|
828
|
+
} catch (e) {
|
|
829
|
+
if (isLoggerUsable()) {
|
|
830
|
+
useLogger().error(e);
|
|
831
|
+
}
|
|
832
|
+
throw e;
|
|
833
|
+
}
|
|
1101
834
|
}
|
|
1102
835
|
});
|
|
1103
836
|
}
|
|
@@ -1122,15 +855,10 @@ function useQueueRouter() {
|
|
|
1122
855
|
return instance.use();
|
|
1123
856
|
}
|
|
1124
857
|
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
* view the LICENSE file that was distributed with this source code.
|
|
1130
|
-
*/ function hasOwnProperty(obj, prop) {
|
|
1131
|
-
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1132
|
-
}
|
|
1133
|
-
|
|
858
|
+
Object.defineProperty(exports, "AmqpClient", {
|
|
859
|
+
enumerable: true,
|
|
860
|
+
get: function () { return amqpExtension.Client; }
|
|
861
|
+
});
|
|
1134
862
|
Object.defineProperty(exports, "VaultClient", {
|
|
1135
863
|
enumerable: true,
|
|
1136
864
|
get: function () { return vault.VaultClient; }
|
|
@@ -1155,55 +883,21 @@ Object.defineProperty(exports, "createRedisClient", {
|
|
|
1155
883
|
enumerable: true,
|
|
1156
884
|
get: function () { return redisExtension.createClient; }
|
|
1157
885
|
});
|
|
1158
|
-
Object.defineProperty(exports, "LokiClient", {
|
|
1159
|
-
enumerable: true,
|
|
1160
|
-
get: function () { return loki.LokiClient; }
|
|
1161
|
-
});
|
|
1162
|
-
Object.defineProperty(exports, "LokiCompactorDeletionRequestCreate", {
|
|
1163
|
-
enumerable: true,
|
|
1164
|
-
get: function () { return loki.CompactorDeletionRequestCreate; }
|
|
1165
|
-
});
|
|
1166
|
-
Object.defineProperty(exports, "LokiConfig", {
|
|
1167
|
-
enumerable: true,
|
|
1168
|
-
get: function () { return loki.Config; }
|
|
1169
|
-
});
|
|
1170
|
-
Object.defineProperty(exports, "LokiConfigInput", {
|
|
1171
|
-
enumerable: true,
|
|
1172
|
-
get: function () { return loki.ConfigInput; }
|
|
1173
|
-
});
|
|
1174
|
-
Object.defineProperty(exports, "LokiDistributorPushStream", {
|
|
1175
|
-
enumerable: true,
|
|
1176
|
-
get: function () { return loki.DistributorPushStream; }
|
|
1177
|
-
});
|
|
1178
|
-
Object.defineProperty(exports, "LokiQuerierQueryRangeOptions", {
|
|
1179
|
-
enumerable: true,
|
|
1180
|
-
get: function () { return loki.QuerierQueryRangeOptions; }
|
|
1181
|
-
});
|
|
1182
|
-
Object.defineProperty(exports, "LokiQuerierQueryResult", {
|
|
1183
|
-
enumerable: true,
|
|
1184
|
-
get: function () { return loki.QuerierQueryResult; }
|
|
1185
|
-
});
|
|
1186
|
-
Object.defineProperty(exports, "createLokiClient", {
|
|
1187
|
-
enumerable: true,
|
|
1188
|
-
get: function () { return loki.createClient; }
|
|
1189
|
-
});
|
|
1190
|
-
Object.defineProperty(exports, "nanoSeconds", {
|
|
1191
|
-
enumerable: true,
|
|
1192
|
-
get: function () { return loki.nanoSeconds; }
|
|
1193
|
-
});
|
|
1194
886
|
exports.AuthupClient = AuthupClient;
|
|
1195
887
|
exports.Cache = Cache;
|
|
1196
888
|
exports.ComponentError = ComponentError;
|
|
889
|
+
exports.ComponentHandlers = ComponentHandlers;
|
|
1197
890
|
exports.DomainEventPublisher = DomainEventPublisher;
|
|
1198
891
|
exports.DomainEventRedisPublisher = DomainEventRedisPublisher;
|
|
1199
|
-
exports.
|
|
1200
|
-
exports.LokiLogStore = LokiLogStore;
|
|
892
|
+
exports.DomainEventSocketConsumer = DomainEventSocketConsumer;
|
|
1201
893
|
exports.MemoryCacheAdapter = MemoryCacheAdapter;
|
|
1202
|
-
exports.MemoryLogStore = MemoryLogStore;
|
|
1203
894
|
exports.QueueRouter = QueueRouter;
|
|
1204
895
|
exports.QueueRouterRoutingType = QueueRouterRoutingType;
|
|
1205
896
|
exports.RedisCacheAdapter = RedisCacheAdapter;
|
|
1206
897
|
exports.buildCacheKey = buildCacheKey;
|
|
898
|
+
exports.buildDomainEventRedisChannel = buildDomainEventRedisChannel;
|
|
899
|
+
exports.buildDomainEventSocketChannel = buildDomainEventSocketChannel;
|
|
900
|
+
exports.buildDomainEventSocketNamespace = buildDomainEventSocketNamespace;
|
|
1207
901
|
exports.buildQueueRouterPublishPayload = buildQueueRouterPublishPayload;
|
|
1208
902
|
exports.createCacheAdapter = createCacheAdapter;
|
|
1209
903
|
exports.createLogger = createLogger;
|
|
@@ -1213,9 +907,7 @@ exports.isAmqpClientUsable = isAmqpClientUsable;
|
|
|
1213
907
|
exports.isAuthupClientUsable = isAuthupClientUsable;
|
|
1214
908
|
exports.isClientAuthenticationHookUsable = isClientAuthenticationHookUsable;
|
|
1215
909
|
exports.isComponentError = isComponentError;
|
|
1216
|
-
exports.isLogStoreUsable = isLogStoreUsable;
|
|
1217
910
|
exports.isLoggerUsable = isLoggerUsable;
|
|
1218
|
-
exports.isLokiClientUsable = isLokiClientUsable;
|
|
1219
911
|
exports.isQueuePayload = isQueuePayload;
|
|
1220
912
|
exports.isQueueRouterPayload = isQueueRouterPayload;
|
|
1221
913
|
exports.isQueueRouterUsable = isQueueRouterUsable;
|
|
@@ -1224,10 +916,8 @@ exports.isVaultClientUsable = isVaultClientUsable;
|
|
|
1224
916
|
exports.setAmqpClientFactory = setAmqpClientFactory;
|
|
1225
917
|
exports.setAuthupClientFactory = setAuthupClientFactory;
|
|
1226
918
|
exports.setClientAuthenticationHookFactory = setClientAuthenticationHookFactory;
|
|
1227
|
-
exports.setLogStoreFactory = setLogStoreFactory;
|
|
1228
919
|
exports.setLogger = setLogger;
|
|
1229
920
|
exports.setLoggerFactory = setLoggerFactory;
|
|
1230
|
-
exports.setLokiFactory = setLokiFactory;
|
|
1231
921
|
exports.setRedisClient = setRedisClient;
|
|
1232
922
|
exports.setRedisFactory = setRedisFactory;
|
|
1233
923
|
exports.setVaultFactory = setVaultFactory;
|
|
@@ -1237,9 +927,7 @@ exports.useCache = useCache;
|
|
|
1237
927
|
exports.useClientAuthenticationHook = useClientAuthenticationHook;
|
|
1238
928
|
exports.useDomainEventPublisher = useDomainEventPublisher;
|
|
1239
929
|
exports.useDomainEventPublisherSinga = useDomainEventPublisherSinga;
|
|
1240
|
-
exports.useLogStore = useLogStore;
|
|
1241
930
|
exports.useLogger = useLogger;
|
|
1242
|
-
exports.useLokiClient = useLokiClient;
|
|
1243
931
|
exports.useQueueRouter = useQueueRouter;
|
|
1244
932
|
exports.useRedisClient = useRedisClient;
|
|
1245
933
|
exports.useRedisPublishClient = useRedisPublishClient;
|