@privateaim/server-kit 0.8.7 → 0.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/index.cjs +231 -124
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.mjs +227 -121
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/services/authup/module.d.ts +1 -2
  9. package/dist/services/authup/module.d.ts.map +1 -1
  10. package/dist/services/authup/types.d.ts +2 -2
  11. package/dist/services/authup/types.d.ts.map +1 -1
  12. package/dist/services/authup-client-authentication-hook/index.d.ts +2 -0
  13. package/dist/services/authup-client-authentication-hook/index.d.ts.map +1 -0
  14. package/dist/services/authup-client-authentication-hook/singleton.d.ts +6 -0
  15. package/dist/services/authup-client-authentication-hook/singleton.d.ts.map +1 -0
  16. package/dist/services/domain-event/index.d.ts +6 -0
  17. package/dist/services/domain-event/index.d.ts.map +1 -0
  18. package/dist/services/domain-event/module.d.ts +9 -0
  19. package/dist/services/domain-event/module.d.ts.map +1 -0
  20. package/dist/services/domain-event/redis/index.d.ts +2 -0
  21. package/dist/services/domain-event/redis/index.d.ts.map +1 -0
  22. package/dist/services/domain-event/redis/module.d.ts +8 -0
  23. package/dist/services/domain-event/redis/module.d.ts.map +1 -0
  24. package/dist/services/domain-event/singleton.d.ts +3 -0
  25. package/dist/services/domain-event/singleton.d.ts.map +1 -0
  26. package/dist/services/domain-event/socket/index.d.ts +2 -0
  27. package/dist/services/domain-event/socket/index.d.ts.map +1 -0
  28. package/dist/services/domain-event/socket/module.d.ts +8 -0
  29. package/dist/services/domain-event/socket/module.d.ts.map +1 -0
  30. package/dist/services/domain-event/type.d.ts +15 -0
  31. package/dist/services/domain-event/type.d.ts.map +1 -0
  32. package/dist/services/domain-event/utils.d.ts +4 -0
  33. package/dist/services/domain-event/utils.d.ts.map +1 -0
  34. package/dist/services/index.d.ts +2 -0
  35. package/dist/services/index.d.ts.map +1 -1
  36. package/package.json +10 -11
  37. package/src/index.ts +0 -1
  38. package/src/services/authup/module.ts +16 -18
  39. package/src/services/authup/types.ts +6 -2
  40. package/src/services/authup-client-authentication-hook/index.ts +8 -0
  41. package/src/services/authup-client-authentication-hook/singleton.ts +26 -0
  42. package/src/{domain-event → services/domain-event}/index.ts +2 -1
  43. package/src/services/domain-event/module.ts +40 -0
  44. package/src/{domain-event → services/domain-event}/redis/index.ts +1 -1
  45. package/src/services/domain-event/redis/module.ts +37 -0
  46. package/src/services/domain-event/singleton.ts +32 -0
  47. package/src/{domain-event → services/domain-event}/socket/index.ts +1 -1
  48. package/src/services/domain-event/socket/module.ts +57 -0
  49. package/src/{domain-event → services/domain-event}/type.ts +13 -0
  50. package/src/{domain-event → services/domain-event}/utils.ts +2 -2
  51. package/src/services/index.ts +2 -0
  52. package/dist/domain-event/index.d.ts +0 -5
  53. package/dist/domain-event/index.d.ts.map +0 -1
  54. package/dist/domain-event/publish.d.ts +0 -5
  55. package/dist/domain-event/publish.d.ts.map +0 -1
  56. package/dist/domain-event/redis/index.d.ts +0 -2
  57. package/dist/domain-event/redis/index.d.ts.map +0 -1
  58. package/dist/domain-event/redis/publish.d.ts +0 -5
  59. package/dist/domain-event/redis/publish.d.ts.map +0 -1
  60. package/dist/domain-event/socket/index.d.ts +0 -2
  61. package/dist/domain-event/socket/index.d.ts.map +0 -1
  62. package/dist/domain-event/socket/publish.d.ts +0 -5
  63. package/dist/domain-event/socket/publish.d.ts.map +0 -1
  64. package/dist/domain-event/type.d.ts +0 -7
  65. package/dist/domain-event/type.d.ts.map +0 -1
  66. package/dist/domain-event/utils.d.ts +0 -4
  67. package/dist/domain-event/utils.d.ts.map +0 -1
  68. package/src/domain-event/publish.ts +0 -21
  69. package/src/domain-event/redis/publish.ts +0 -41
  70. package/src/domain-event/socket/publish.ts +0 -60
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.8.9](https://github.com/PrivateAIM/hub/compare/v0.8.8...v0.8.9) (2025-04-17)
4
+
5
+
6
+ ### Features
7
+
8
+ * restructure domain event handling ([2ad7318](https://github.com/PrivateAIM/hub/commit/2ad7318930bd342d571105982fc92996443326fa))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** bump the minorandpatch group across 1 directory with 2 updates ([#1033](https://github.com/PrivateAIM/hub/issues/1033)) ([b228557](https://github.com/PrivateAIM/hub/commit/b228557eb213761ab97d2d9f8e618b86c50ab155))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * The following workspace dependencies were updated
19
+ * dependencies
20
+ * @privateaim/kit bumped from ^0.8.8 to ^0.8.9
21
+
22
+ ## [0.8.8](https://github.com/PrivateAIM/hub/compare/v0.8.7...v0.8.8) (2025-04-15)
23
+
24
+
25
+ ### Features
26
+
27
+ * migrated to authup v1.0.0-beta.25 ([a5f6b65](https://github.com/PrivateAIM/hub/commit/a5f6b65499ee3a8c4b4bbdcda47979fa73ee5c48))
28
+ * reusable client authentication hook ([0a608cd](https://github.com/PrivateAIM/hub/commit/0a608cd94984314166c15fa11684e022b5ceb53e))
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **deps:** bump amqp-extension from 4.0.0-beta.3 to 4.0.0 ([#1018](https://github.com/PrivateAIM/hub/issues/1018)) ([6f969f1](https://github.com/PrivateAIM/hub/commit/6f969f17c64f61da85799fd1193d7343d0130ac5))
34
+ * **deps:** bump the minorandpatch group across 1 directory with 3 updates ([#1019](https://github.com/PrivateAIM/hub/issues/1019)) ([a82d65d](https://github.com/PrivateAIM/hub/commit/a82d65da5e08edce3d97e7432c22d8a028853217))
35
+
36
+
37
+ ### Dependencies
38
+
39
+ * The following workspace dependencies were updated
40
+ * dependencies
41
+ * @privateaim/core-kit bumped from ^0.8.7 to ^0.8.8
42
+ * @privateaim/kit bumped from ^0.8.7 to ^0.8.8
43
+
3
44
  ## [0.8.7](https://github.com/PrivateAIM/hub/compare/v0.8.6...v0.8.7) (2025-03-12)
4
45
 
5
46
 
package/dist/index.cjs CHANGED
@@ -11,7 +11,6 @@ var envix = require('envix');
11
11
  var path = require('node:path');
12
12
  var typeormExtension = require('typeorm-extension');
13
13
  var winston = require('winston');
14
- var coreKit = require('@privateaim/core-kit');
15
14
  var redisEmitter = require('@socket.io/redis-emitter');
16
15
 
17
16
  /*
@@ -19,7 +18,7 @@ var redisEmitter = require('@socket.io/redis-emitter');
19
18
  * Author Peter Placzek (tada5hi)
20
19
  * For the full copyright and license information,
21
20
  * view the LICENSE file that was distributed with this source code.
22
- */ function _define_property$4(obj, key, value) {
21
+ */ function _define_property$7(obj, key, value) {
23
22
  if (key in obj) {
24
23
  Object.defineProperty(obj, key, {
25
24
  value: value,
@@ -36,7 +35,7 @@ class ComponentError extends Error {
36
35
  constructor(input){
37
36
  super(input.message, {
38
37
  cause: input.cause
39
- }), _define_property$4(this, "code", void 0);
38
+ }), _define_property$7(this, "code", void 0);
40
39
  this.code = input.code;
41
40
  }
42
41
  }
@@ -84,30 +83,30 @@ function isQueueRouterPayload(input) {
84
83
  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);
85
84
  }
86
85
 
87
- const instance$8 = singa.singa({
86
+ const instance$a = singa.singa({
88
87
  name: 'amqp'
89
88
  });
90
89
  function setAmqpClientFactory(factory) {
91
- instance$8.setFactory(factory);
90
+ instance$a.setFactory(factory);
92
91
  }
93
92
  function isAmqpClientUsable() {
94
- return instance$8.has() || instance$8.hasFactory();
93
+ return instance$a.has() || instance$a.hasFactory();
95
94
  }
96
95
  function useAmqpClient() {
97
- return instance$8.use();
96
+ return instance$a.use();
98
97
  }
99
98
 
100
- const instance$7 = singa.singa({
99
+ const instance$9 = singa.singa({
101
100
  name: 'vault'
102
101
  });
103
102
  function setVaultFactory(factory) {
104
- instance$7.setFactory(factory);
103
+ instance$9.setFactory(factory);
105
104
  }
106
105
  function isVaultClientUsable() {
107
- return instance$7.has() || instance$7.hasFactory();
106
+ return instance$9.has() || instance$9.hasFactory();
108
107
  }
109
108
  function useVaultClient() {
110
- return instance$7.use();
109
+ return instance$9.use();
111
110
  }
112
111
 
113
112
  function guessAuthupTokenCreatorOptions() {
@@ -128,67 +127,76 @@ function guessAuthupTokenCreatorOptions() {
128
127
  return options;
129
128
  }
130
129
 
130
+ const instance$8 = singa.singa({
131
+ name: 'clientAuthenticationHook'
132
+ });
133
+ function setClientAuthenticationHookFactory(factory) {
134
+ instance$8.setFactory(factory);
135
+ }
136
+ function isClientAuthenticationHookUsable() {
137
+ return instance$8.has() || instance$8.hasFactory();
138
+ }
139
+ function useClientAuthenticationHook() {
140
+ return instance$8.use();
141
+ }
142
+
131
143
  class AuthupClient extends coreHttpKit.Client {
132
144
  constructor(options = {}){
133
145
  super(options);
134
- let tokenHook;
135
- if (options.tokenHook) {
136
- tokenHook = options.tokenHook;
137
- tokenHook.baseURL = tokenHook.baseURL || options.baseURL;
138
- } else {
139
- const tokenCreator = guessAuthupTokenCreatorOptions();
140
- tokenHook = {
141
- baseURL: options.baseURL,
142
- tokenCreator
143
- };
146
+ if (!isClientAuthenticationHookUsable()) {
147
+ setClientAuthenticationHookFactory(()=>new coreHttpKit.ClientAuthenticationHook({
148
+ baseURL: options.baseURL,
149
+ tokenCreator: options.tokenCreator || guessAuthupTokenCreatorOptions()
150
+ }));
144
151
  }
145
- coreHttpKit.mountClientResponseErrorTokenHook(this, tokenHook);
152
+ const hook = useClientAuthenticationHook();
153
+ hook.attach(this);
146
154
  }
147
155
  }
148
156
 
149
- const instance$6 = singa.singa({
157
+ const instance$7 = singa.singa({
150
158
  name: 'authup'
151
159
  });
152
160
  function useAuthupClient() {
153
- return instance$6.use();
161
+ return instance$7.use();
154
162
  }
155
163
  function isAuthupClientUsable() {
156
- return instance$6.has() || instance$6.hasFactory();
164
+ return instance$7.has() || instance$7.hasFactory();
157
165
  }
158
166
  function setAuthupClientFactory(factory) {
159
- instance$6.setFactory(factory);
167
+ instance$7.setFactory(factory);
160
168
  }
161
169
 
162
- const instance$5 = singa.singa({
170
+ const instance$6 = singa.singa({
163
171
  name: 'redis'
164
172
  });
165
173
  function setRedisFactory(factory) {
166
- instance$5.setFactory(factory);
174
+ instance$6.setFactory(factory);
167
175
  }
168
176
  function isRedisClientUsable() {
169
- return instance$5.has() || instance$5.hasFactory();
177
+ return instance$6.has() || instance$6.hasFactory();
170
178
  }
171
179
  function setRedisClient(input) {
172
- instance$5.set(input);
180
+ instance$6.set(input);
173
181
  }
174
182
  function useRedisClient() {
175
- return instance$5.use();
183
+ return instance$6.use();
176
184
  }
177
185
 
178
- const instance$4 = singa.singa({
186
+ const instance$5 = singa.singa({
179
187
  name: 'redisPublish',
180
188
  factory: ()=>useRedisClient().duplicate()
181
189
  });
182
190
  function useRedisPublishClient() {
183
- return instance$4.use();
191
+ return instance$5.use();
184
192
  }
185
193
 
186
- const instance$3 = singa.singa({
194
+ const instance$4 = singa.singa({
187
195
  name: 'redisSubscribe',
188
196
  factory: ()=>useRedisClient().duplicate()
189
197
  });
190
198
  function useRedisSubscribeClient() {
191
- return instance$3.use();
199
+ return instance$4.use();
192
200
  }
193
201
 
194
202
  /*
@@ -196,7 +204,7 @@ function useRedisSubscribeClient() {
196
204
  * Author Peter Placzek (tada5hi)
197
205
  * For the full copyright and license information,
198
206
  * view the LICENSE file that was distributed with this source code.
199
- */ function _define_property$3(obj, key, value) {
207
+ */ function _define_property$6(obj, key, value) {
200
208
  if (key in obj) {
201
209
  Object.defineProperty(obj, key, {
202
210
  value: value,
@@ -244,7 +252,7 @@ class MemoryCacheAdapter {
244
252
  this.instance.clear();
245
253
  }
246
254
  constructor(options = {}){
247
- _define_property$3(this, "instance", void 0);
255
+ _define_property$6(this, "instance", void 0);
248
256
  this.instance = new TTLCache({
249
257
  checkAgeOnGet: true,
250
258
  ttl: Infinity,
@@ -258,7 +266,7 @@ class MemoryCacheAdapter {
258
266
  * Author Peter Placzek (tada5hi)
259
267
  * For the full copyright and license information,
260
268
  * view the LICENSE file that was distributed with this source code.
261
- */ function _define_property$2(obj, key, value) {
269
+ */ function _define_property$5(obj, key, value) {
262
270
  if (key in obj) {
263
271
  Object.defineProperty(obj, key, {
264
272
  value: value,
@@ -307,8 +315,8 @@ class RedisCacheAdapter {
307
315
  await this.client.flushdb();
308
316
  }
309
317
  constructor(){
310
- _define_property$2(this, "client", void 0);
311
- _define_property$2(this, "instance", void 0);
318
+ _define_property$5(this, "client", void 0);
319
+ _define_property$5(this, "instance", void 0);
312
320
  this.client = useRedisClient();
313
321
  this.instance = new redisExtension.JsonAdapter(this.client);
314
322
  }
@@ -330,7 +338,7 @@ function buildCacheKey(options) {
330
338
  * Author Peter Placzek (tada5hi)
331
339
  * For the full copyright and license information,
332
340
  * view the LICENSE file that was distributed with this source code.
333
- */ function _define_property$1(obj, key, value) {
341
+ */ function _define_property$4(obj, key, value) {
334
342
  if (key in obj) {
335
343
  Object.defineProperty(obj, key, {
336
344
  value: value,
@@ -363,12 +371,12 @@ class Cache {
363
371
  return this.adapter.clear(options);
364
372
  }
365
373
  constructor(adapter){
366
- _define_property$1(this, "adapter", void 0);
374
+ _define_property$4(this, "adapter", void 0);
367
375
  this.adapter = adapter;
368
376
  }
369
377
  }
370
378
 
371
- const instance$2 = singa.singa({
379
+ const instance$3 = singa.singa({
372
380
  name: 'cache',
373
381
  factory: ()=>{
374
382
  let adapter;
@@ -381,7 +389,7 @@ const instance$2 = singa.singa({
381
389
  }
382
390
  });
383
391
  function useCache() {
384
- return instance$2.use();
392
+ return instance$3.use();
385
393
  }
386
394
 
387
395
  function createLogger(ctx = {}) {
@@ -423,19 +431,187 @@ function createLogger(ctx = {}) {
423
431
  });
424
432
  }
425
433
 
426
- const instance$1 = singa.singa({
434
+ const instance$2 = singa.singa({
427
435
  name: 'logger'
428
436
  });
429
437
  function setLoggerFactory(factory) {
430
- instance$1.setFactory(factory);
438
+ instance$2.setFactory(factory);
431
439
  }
432
440
  function isLoggerUsable() {
433
- return instance$1.has() || instance$1.hasFactory();
441
+ return instance$2.has() || instance$2.hasFactory();
434
442
  }
435
443
  function setLogger(input) {
436
- instance$1.set(input);
444
+ instance$2.set(input);
437
445
  }
438
446
  function useLogger() {
447
+ return instance$2.use();
448
+ }
449
+
450
+ /*
451
+ * Copyright (c) 2024-2024.
452
+ * Author Peter Placzek (tada5hi)
453
+ * For the full copyright and license information,
454
+ * view the LICENSE file that was distributed with this source code.
455
+ */ function _define_property$3(obj, key, value) {
456
+ if (key in obj) {
457
+ Object.defineProperty(obj, key, {
458
+ value: value,
459
+ enumerable: true,
460
+ configurable: true,
461
+ writable: true
462
+ });
463
+ } else {
464
+ obj[key] = value;
465
+ }
466
+ return obj;
467
+ }
468
+ class DomainEventPublisher {
469
+ addPublisher(publisher) {
470
+ this.publishers.add(publisher);
471
+ }
472
+ async publish(ctx) {
473
+ if (isLoggerUsable()) {
474
+ useLogger().info(`Publishing event ${ctx.data.event} for ${ctx.data.type}`);
475
+ }
476
+ const publishers = this.publishers.values();
477
+ while(true){
478
+ const it = publishers.next();
479
+ if (it.done) {
480
+ return;
481
+ }
482
+ await it.value.publish(ctx);
483
+ }
484
+ }
485
+ constructor(){
486
+ _define_property$3(this, "publishers", void 0);
487
+ this.publishers = new Set();
488
+ }
489
+ }
490
+
491
+ function transformEventData(input) {
492
+ if (kit.isObject(input)) {
493
+ const keys = Object.keys(input);
494
+ for(let i = 0; i < keys.length; i++){
495
+ const value = input[keys[i]];
496
+ if (value instanceof Date) {
497
+ input[keys[i]] = value.toISOString();
498
+ }
499
+ }
500
+ }
501
+ return input;
502
+ }
503
+ function buildEventChannelName(input, id) {
504
+ if (typeof input === 'string') {
505
+ return input;
506
+ }
507
+ return input(id);
508
+ }
509
+
510
+ /*
511
+ * Copyright (c) 2023-2024.
512
+ * Author Peter Placzek (tada5hi)
513
+ * For the full copyright and license information,
514
+ * view the LICENSE file that was distributed with this source code.
515
+ */ function _define_property$2(obj, key, value) {
516
+ if (key in obj) {
517
+ Object.defineProperty(obj, key, {
518
+ value: value,
519
+ enumerable: true,
520
+ configurable: true,
521
+ writable: true
522
+ });
523
+ } else {
524
+ obj[key] = value;
525
+ }
526
+ return obj;
527
+ }
528
+ class DomainEventRedisPublisher {
529
+ async publish(ctx) {
530
+ const data = JSON.stringify(transformEventData(ctx.data));
531
+ const pipeline = this.driver.pipeline();
532
+ for(let i = 0; i < ctx.destinations.length; i++){
533
+ const keyPrefix = ctx.destinations[i].namespace ? `${ctx.destinations[i].namespace}:` : '';
534
+ let key = keyPrefix + buildEventChannelName(ctx.destinations[i].channel);
535
+ pipeline.publish(key, data);
536
+ if (typeof ctx.destinations[i].channel === 'function') {
537
+ key = keyPrefix + buildEventChannelName(ctx.destinations[i].channel, ctx.data.data.id);
538
+ pipeline.publish(key, data);
539
+ }
540
+ }
541
+ await pipeline.exec();
542
+ }
543
+ constructor(client){
544
+ _define_property$2(this, "driver", void 0);
545
+ this.driver = client;
546
+ }
547
+ }
548
+
549
+ /*
550
+ * Copyright (c) 2022-2024.
551
+ * Author Peter Placzek (tada5hi)
552
+ * For the full copyright and license information,
553
+ * view the LICENSE file that was distributed with this source code.
554
+ */ function _define_property$1(obj, key, value) {
555
+ if (key in obj) {
556
+ Object.defineProperty(obj, key, {
557
+ value: value,
558
+ enumerable: true,
559
+ configurable: true,
560
+ writable: true
561
+ });
562
+ } else {
563
+ obj[key] = value;
564
+ }
565
+ return obj;
566
+ }
567
+ class DomainEventSocketPublisher {
568
+ async publish(ctx) {
569
+ ctx.data = transformEventData(ctx.data);
570
+ for(let i = 0; i < ctx.destinations.length; i++){
571
+ let namespace;
572
+ if (ctx.destinations[i].namespace) {
573
+ namespace = ctx.destinations[i].namespace;
574
+ } else {
575
+ namespace = '/';
576
+ }
577
+ const emitter = new redisEmitter.Emitter(this.client, {}, namespace);
578
+ const fullEventName = kit.buildDomainEventFullName(ctx.data.type, ctx.data.event);
579
+ const rooms = [
580
+ buildEventChannelName(ctx.destinations[i].channel)
581
+ ];
582
+ if (typeof ctx.destinations[i].channel === 'function') {
583
+ rooms.push(buildEventChannelName(ctx.destinations[i].channel, ctx.data.data.id));
584
+ }
585
+ for(let j = 0; j < rooms.length; j++){
586
+ emitter.in(rooms[j]).emit(fullEventName, {
587
+ ...ctx.data,
588
+ meta: {
589
+ namespace,
590
+ roomName: rooms[j]
591
+ }
592
+ });
593
+ }
594
+ }
595
+ }
596
+ constructor(client){
597
+ _define_property$1(this, "client", void 0);
598
+ this.client = client;
599
+ }
600
+ }
601
+
602
+ const instance$1 = singa.singa({
603
+ name: 'domainEventPublisher',
604
+ factory: ()=>{
605
+ const publisher = new DomainEventPublisher();
606
+ if (isRedisClientUsable()) {
607
+ const client = useRedisClient();
608
+ publisher.addPublisher(new DomainEventRedisPublisher(client));
609
+ publisher.addPublisher(new DomainEventSocketPublisher(client));
610
+ }
611
+ return publisher;
612
+ }
613
+ });
614
+ function useDomainEventPublisher() {
439
615
  return instance$1.use();
440
616
  }
441
617
 
@@ -550,75 +726,6 @@ function useQueueRouter() {
550
726
  return instance.use();
551
727
  }
552
728
 
553
- function transformDomainEventData(input) {
554
- if (kit.isObject(input)) {
555
- const keys = Object.keys(input);
556
- for(let i = 0; i < keys.length; i++){
557
- const value = input[keys[i]];
558
- if (value instanceof Date) {
559
- input[keys[i]] = value.toISOString();
560
- }
561
- }
562
- }
563
- return input;
564
- }
565
- function buildDomainEventChannelName(input, id) {
566
- if (typeof input === 'string') {
567
- return input;
568
- }
569
- return input(id);
570
- }
571
-
572
- async function publishDomainRedisEvent(client, context, destinations) {
573
- context = transformDomainEventData(context);
574
- const json = JSON.stringify(context);
575
- const pipeline = client.pipeline();
576
- for(let i = 0; i < destinations.length; i++){
577
- const { namespace } = destinations[i];
578
- const keyPrefix = namespace ? `${namespace}:` : '';
579
- let key = keyPrefix + buildDomainEventChannelName(destinations[i].channel);
580
- pipeline.publish(key, json);
581
- if (context.event !== coreKit.DomainEventName.CREATED && typeof destinations[i].channel === 'function') {
582
- key = keyPrefix + buildDomainEventChannelName(destinations[i].channel, context.data.id);
583
- pipeline.publish(key, json);
584
- }
585
- }
586
- return pipeline.exec();
587
- }
588
-
589
- function publishDomainSocketEvent(client, context, destinations) {
590
- context = transformDomainEventData(context);
591
- for(let i = 0; i < destinations.length; i++){
592
- let emitter = new redisEmitter.Emitter(client);
593
- if (destinations[i].namespace) {
594
- emitter = emitter.of(destinations[i].namespace);
595
- }
596
- let roomName = buildDomainEventChannelName(destinations[i].channel);
597
- const fullEventName = coreKit.buildDomainEventFullName(context.type, context.event);
598
- emitter.in(roomName).emit(fullEventName, {
599
- ...context,
600
- meta: {
601
- roomName
602
- }
603
- });
604
- if (context.event !== coreKit.DomainEventName.CREATED && typeof destinations[i].channel === 'function') {
605
- roomName = buildDomainEventChannelName(destinations[i].channel, context.data.id);
606
- emitter.in(roomName).emit(fullEventName, {
607
- ...context,
608
- meta: {
609
- roomName,
610
- roomId: context.data.id
611
- }
612
- });
613
- }
614
- }
615
- }
616
-
617
- async function publishDomainEvent(client, context, destinations) {
618
- await publishDomainRedisEvent(client, context, destinations);
619
- publishDomainSocketEvent(client, context, destinations);
620
- }
621
-
622
729
  /*
623
730
  * Copyright (c) 2022-2024.
624
731
  * Author Peter Placzek (tada5hi)
@@ -636,10 +743,6 @@ Object.defineProperty(exports, "createVaultClient", {
636
743
  enumerable: true,
637
744
  get: function () { return vault.createClient; }
638
745
  });
639
- Object.defineProperty(exports, "mountAuthupClientResponseErrorTokenHook", {
640
- enumerable: true,
641
- get: function () { return coreHttpKit.mountClientResponseErrorTokenHook; }
642
- });
643
746
  Object.defineProperty(exports, "RedisClient", {
644
747
  enumerable: true,
645
748
  get: function () { return redisExtension.Client; }
@@ -659,6 +762,9 @@ Object.defineProperty(exports, "createRedisClient", {
659
762
  exports.AuthupClient = AuthupClient;
660
763
  exports.Cache = Cache;
661
764
  exports.ComponentError = ComponentError;
765
+ exports.DomainEventPublisher = DomainEventPublisher;
766
+ exports.DomainEventRedisPublisher = DomainEventRedisPublisher;
767
+ exports.DomainEventSocketPublisher = DomainEventSocketPublisher;
662
768
  exports.MemoryCacheAdapter = MemoryCacheAdapter;
663
769
  exports.QueueRouter = QueueRouter;
664
770
  exports.QueueRouterRoutingType = QueueRouterRoutingType;
@@ -671,6 +777,7 @@ exports.guessAuthupTokenCreatorOptions = guessAuthupTokenCreatorOptions;
671
777
  exports.hasOwnProperty = hasOwnProperty;
672
778
  exports.isAmqpClientUsable = isAmqpClientUsable;
673
779
  exports.isAuthupClientUsable = isAuthupClientUsable;
780
+ exports.isClientAuthenticationHookUsable = isClientAuthenticationHookUsable;
674
781
  exports.isComponentError = isComponentError;
675
782
  exports.isLoggerUsable = isLoggerUsable;
676
783
  exports.isQueuePayload = isQueuePayload;
@@ -678,11 +785,9 @@ exports.isQueueRouterPayload = isQueueRouterPayload;
678
785
  exports.isQueueRouterUsable = isQueueRouterUsable;
679
786
  exports.isRedisClientUsable = isRedisClientUsable;
680
787
  exports.isVaultClientUsable = isVaultClientUsable;
681
- exports.publishDomainEvent = publishDomainEvent;
682
- exports.publishDomainRedisEvent = publishDomainRedisEvent;
683
- exports.publishDomainSocketEvent = publishDomainSocketEvent;
684
788
  exports.setAmqpClientFactory = setAmqpClientFactory;
685
789
  exports.setAuthupClientFactory = setAuthupClientFactory;
790
+ exports.setClientAuthenticationHookFactory = setClientAuthenticationHookFactory;
686
791
  exports.setLogger = setLogger;
687
792
  exports.setLoggerFactory = setLoggerFactory;
688
793
  exports.setRedisClient = setRedisClient;
@@ -691,6 +796,8 @@ exports.setVaultFactory = setVaultFactory;
691
796
  exports.useAmqpClient = useAmqpClient;
692
797
  exports.useAuthupClient = useAuthupClient;
693
798
  exports.useCache = useCache;
799
+ exports.useClientAuthenticationHook = useClientAuthenticationHook;
800
+ exports.useDomainEventPublisher = useDomainEventPublisher;
694
801
  exports.useLogger = useLogger;
695
802
  exports.useQueueRouter = useQueueRouter;
696
803
  exports.useRedisClient = useRedisClient;