@mindignited/continuum-client 2.14.7 → 2.14.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.
package/dist/continuum.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { RxStomp as k } from "@stomp/rx-stomp";
2
2
  import { ReconnectionTimeMode as B } from "@stomp/stompjs";
3
- import { v4 as S } from "uuid";
4
- import q from "debug";
5
- import b, { propagation as F, context as $, SpanKind as U, SpanStatusCode as Y } from "@opentelemetry/api";
6
- import { Subject as A, firstValueFrom as V, Observable as j, throwError as N } from "rxjs";
3
+ import { v4 as m } from "uuid";
4
+ import I from "debug";
5
+ import b, { propagation as F, context as $, SpanKind as q, SpanStatusCode as Y } from "@opentelemetry/api";
6
+ import { Subject as A, firstValueFrom as U, Observable as V, throwError as j } from "rxjs";
7
7
  import { map as R, multicast as J, filter as X, first as W } from "rxjs/operators";
8
8
  import { Optional as C } from "typescript-optional";
9
9
  import "reflect-metadata";
10
10
  import { ATTR_SERVER_ADDRESS as G, ATTR_SERVER_PORT as K } from "@opentelemetry/semantic-conventions";
11
11
  class Le {
12
12
  }
13
- class w {
13
+ class N {
14
14
  host;
15
15
  port;
16
16
  useSSL;
17
17
  }
18
- class Me extends w {
18
+ class Me extends N {
19
19
  /**
20
20
  * The headers to send during the connection to the continuum server.
21
21
  * If a function is provided, it will be called to get the headers each time the connection is established.
@@ -34,9 +34,9 @@ class Me extends w {
34
34
  */
35
35
  disableStickySession;
36
36
  }
37
- class m extends Error {
37
+ class v extends Error {
38
38
  constructor(e) {
39
- super(e), Object.setPrototypeOf(this, m.prototype);
39
+ super(e), Object.setPrototypeOf(this, v.prototype);
40
40
  }
41
41
  }
42
42
  var o = /* @__PURE__ */ ((s) => (s.CONTENT_TYPE_HEADER = "content-type", s.CONTENT_LENGTH_HEADER = "content-length", s.REPLY_TO_HEADER = "reply-to", s.REPLY_TO_ID_HEADER = "reply-to-id", s.SESSION_HEADER = "session", s.CONNECTED_INFO_HEADER = "connected-info", s.DISABLE_STICKY_SESSION_HEADER = "disable-sticky-session", s.CORRELATION_ID_HEADER = "__correlation-id", s.ERROR_HEADER = "error", s.COMPLETE_HEADER = "complete", s.CONTROL_HEADER = "control", s.CONTROL_VALUE_COMPLETE = "complete", s.CONTROL_VALUE_CANCEL = "cancel", s.CONTROL_VALUE_SUSPEND = "suspend", s.CONTROL_VALUE_RESUME = "resume", s.SERVICE_DESTINATION_PREFIX = "srv://", s.SERVICE_DESTINATION_SCHEME = "srv", s.STREAM_DESTINATION_PREFIX = "stream://", s.STREAM_DESTINATION_SCHEME = "stream", s.CONTENT_JSON = "application/json", s.CONTENT_TEXT = "text/plain", s.TRACEPARENT_HEADER = "traceparent", s.TRACESTATE_HEADER = "tracestate", s))(o || {});
@@ -53,9 +53,9 @@ class z {
53
53
  JITTER_MAX = 5e3;
54
54
  connectionAttempts = 0;
55
55
  initialConnectionSuccessful = !1;
56
- debugLogger = q("continuum:stomp");
57
- replyToId = S();
58
- replyToCri = o.SERVICE_DESTINATION_PREFIX + this.replyToId + ":" + S() + "@continuum.js.EventBus/replyHandler";
56
+ debugLogger = I("continuum:stomp");
57
+ replyToId = m();
58
+ _replyToCri = o.SERVICE_DESTINATION_PREFIX + this.replyToId + ":" + m() + "@continuum.js.EventBus/replyHandler";
59
59
  deactivationHandler = null;
60
60
  /**
61
61
  * @return true if this {@link StompConnectionManager} is actively trying to maintain a connection to the Stomp server, false if not.
@@ -63,6 +63,9 @@ class z {
63
63
  get active() {
64
64
  return !!this.rxStomp;
65
65
  }
66
+ get replyToCri() {
67
+ return this._replyToCri;
68
+ }
66
69
  /**
67
70
  * return true if this {@link StompConnectionManager} is active and has a connection to the stomp server
68
71
  */
@@ -84,12 +87,12 @@ class z {
84
87
  return;
85
88
  }
86
89
  this.connectionAttempts = 0, this.initialConnectionSuccessful = !1, this.lastWebsocketError = null, this.maxConnectionAttemptsReached = !1;
87
- const n = "ws" + (e.useSSL ? "s" : "") + "://" + e.host + (e.port ? ":" + e.port : "") + "/v1";
90
+ const i = "ws" + (e.useSSL ? "s" : "") + "://" + e.host + (e.port ? ":" + e.port : "") + "/v1";
88
91
  this.rxStomp = new k();
89
- let i = typeof e.connectHeaders != "function" && e.connectHeaders != null ? e.connectHeaders : {};
92
+ let n = typeof e.connectHeaders != "function" && e.connectHeaders != null ? e.connectHeaders : {};
90
93
  const c = {
91
- brokerURL: n,
92
- connectHeaders: i,
94
+ brokerURL: i,
95
+ connectHeaders: n,
93
96
  heartbeatIncoming: 12e4,
94
97
  heartbeatOutgoing: 3e4,
95
98
  reconnectDelay: this.INITIAL_RECONNECT_DELAY,
@@ -97,9 +100,9 @@ class z {
97
100
  if (typeof e.connectHeaders == "function") {
98
101
  const u = await e.connectHeaders();
99
102
  for (const l in u)
100
- i[l] = u[l];
103
+ n[l] = u[l];
101
104
  }
102
- if (e.disableStickySession && (i[o.DISABLE_STICKY_SESSION_HEADER] = "true"), i[o.REPLY_TO_ID_HEADER] = this.replyToId, e?.maxConnectionAttempts)
105
+ if (e.disableStickySession && (n[o.DISABLE_STICKY_SESSION_HEADER] = "true"), n[o.REPLY_TO_ID_HEADER] ? (this.replyToId = n[o.REPLY_TO_ID_HEADER], this._replyToCri = o.SERVICE_DESTINATION_PREFIX + this.replyToId + ":" + m() + "@continuum.js.EventBus/replyHandler") : n[o.REPLY_TO_ID_HEADER] = this.replyToId, e?.maxConnectionAttempts)
103
106
  if (this.connectionAttempts++, this.connectionAttempts > e.maxConnectionAttempts) {
104
107
  if (this.maxConnectionAttemptsReached = !0, await this.deactivate(), !this.initialConnectionSuccessful) {
105
108
  let u = this.lastWebsocketError?.message ? this.lastWebsocketError?.message : "UNKNOWN";
@@ -128,15 +131,15 @@ class z {
128
131
  const d = JSON.parse(l);
129
132
  if (e.disableStickySession)
130
133
  if (typeof e.connectHeaders == "function") {
131
- for (let v in i)
132
- delete i[v];
134
+ for (let S in n)
135
+ delete n[S];
133
136
  this.initialConnectionSuccessful || t(d);
134
137
  } else typeof e.connectHeaders == "object" && (p.unsubscribe(), t(d));
135
138
  else if (p.unsubscribe(), d.sessionId != null && d.replyToId != null) {
136
139
  if (e.connectHeaders != null)
137
- for (let v in i)
138
- delete i[v];
139
- i[o.SESSION_HEADER] = d.sessionId, t(d);
140
+ for (let S in n)
141
+ delete n[S];
142
+ n[o.SESSION_HEADER] = d.sessionId, t(d);
140
143
  } else
141
144
  r("Server did not return proper data for successful login");
142
145
  } else
@@ -199,7 +202,7 @@ class Z {
199
202
  constructor() {
200
203
  this.fatalErrors = this.errorSubject.pipe(R((e) => (this.disconnect().catch((t) => {
201
204
  console && console.error("Error disconnecting from Stomp: " + t);
202
- }), new m(e.headers.message)))), this.stompConnectionManager.deactivationHandler = () => {
205
+ }), new v(e.headers.message)))), this.stompConnectionManager.deactivationHandler = () => {
203
206
  this.cleanup();
204
207
  };
205
208
  }
@@ -215,7 +218,7 @@ class Z {
215
218
  {
216
219
  this.cleanup();
217
220
  const t = await this.stompConnectionManager.activate(e);
218
- return this.serverInfo = new w(), this.serverInfo.host = e.host, this.serverInfo.port = e.port, this.serverInfo.useSSL = e.useSSL, this.replyToCri = this.stompConnectionManager.replyToCri, this.errorSubjectSubscription = this.stompConnectionManager.rxStomp?.stompErrors$.subscribe(this.errorSubject), t;
221
+ return this.serverInfo = new N(), this.serverInfo.host = e.host, this.serverInfo.port = e.port, this.serverInfo.useSSL = e.useSSL, this.replyToCri = this.stompConnectionManager.replyToCri, this.errorSubjectSubscription = this.stompConnectionManager.rxStomp?.stompErrors$.subscribe(this.errorSubject), t;
219
222
  }
220
223
  }
221
224
  async disconnect(e) {
@@ -224,8 +227,8 @@ class Z {
224
227
  send(e) {
225
228
  if (this.stompConnectionManager.rxStomp) {
226
229
  const t = {};
227
- for (const [n, i] of e.headers.entries())
228
- t[n] = i;
230
+ for (const [i, n] of e.headers.entries())
231
+ t[i] = n;
229
232
  const r = {};
230
233
  F.inject($.active(), r), r.traceparent && (t[o.TRACEPARENT_HEADER] = r.traceparent), r.tracestate && (t[o.TRACESTATE_HEADER] = r.tracestate), this.stompConnectionManager.rxStomp.publish({
231
234
  destination: e.cri,
@@ -236,20 +239,20 @@ class Z {
236
239
  throw this.createSendUnavailableError();
237
240
  }
238
241
  request(e) {
239
- return V(this.requestStream(e, !1));
242
+ return U(this.requestStream(e, !1));
240
243
  }
241
244
  requestStream(e, t = !0) {
242
- return this.stompConnectionManager?.rxStomp ? new j((r) => {
245
+ return this.stompConnectionManager?.rxStomp ? new V((r) => {
243
246
  this.requestRepliesObservable == null && (this.requestRepliesSubject = new A(), this.requestRepliesObservable = this._observe(this.replyToCri).pipe(J(this.requestRepliesSubject)), this.requestRepliesSubscription = this.requestRepliesObservable.connect());
244
- let n = !1;
245
- const i = S(), c = this.requestRepliesObservable.pipe(X((a) => a.headers.get(o.CORRELATION_ID_HEADER) === i)).subscribe({
247
+ let i = !1;
248
+ const n = m(), c = this.requestRepliesObservable.pipe(X((a) => a.headers.get(o.CORRELATION_ID_HEADER) === n)).subscribe({
246
249
  next(a) {
247
250
  if (a.hasHeader(o.CONTROL_HEADER))
248
251
  if (a.headers.get(o.CONTROL_HEADER) === "complete")
249
- n = !0, r.complete();
252
+ i = !0, r.complete();
250
253
  else
251
254
  throw new Error("Control Header " + a.headers.get(o.CONTROL_HEADER) + " is not supported");
252
- else a.hasHeader(o.ERROR_HEADER) ? (n = !0, r.error(new Error(a.getHeader(o.ERROR_HEADER)))) : r.next(a);
255
+ else a.hasHeader(o.ERROR_HEADER) ? (i = !0, r.error(new Error(a.getHeader(o.ERROR_HEADER)))) : r.next(a);
253
256
  },
254
257
  error(a) {
255
258
  r.error(a);
@@ -258,13 +261,16 @@ class Z {
258
261
  r.complete();
259
262
  }
260
263
  });
261
- return r.add(c), e.setHeader(o.REPLY_TO_HEADER, this.replyToCri), e.setHeader(o.CORRELATION_ID_HEADER, i), this.send(e), () => {
262
- if (t && !n) {
264
+ return r.add(c), e.setHeader(o.REPLY_TO_HEADER, this.replyToCri), e.setHeader(o.CORRELATION_ID_HEADER, n), this.send(e), () => {
265
+ if (t && !i) {
263
266
  const a = new g(e.cri);
264
- a.setHeader(o.CONTROL_HEADER, o.CONTROL_VALUE_CANCEL), a.setHeader(o.CORRELATION_ID_HEADER, i), this.send(a);
267
+ a.setHeader(o.CONTROL_HEADER, o.CONTROL_VALUE_CANCEL), a.setHeader(o.CORRELATION_ID_HEADER, n), this.send(a);
265
268
  }
266
269
  };
267
- }) : N(() => this.createSendUnavailableError());
270
+ }) : j(() => this.createSendUnavailableError());
271
+ }
272
+ listen(e) {
273
+ return Promise.reject("Not implemented");
268
274
  }
269
275
  observe(e) {
270
276
  return this._observe(e);
@@ -286,13 +292,15 @@ class Z {
286
292
  * @return the cold {@link Observable<IEvent>} for the given destination
287
293
  */
288
294
  _observe(e) {
289
- return this.stompConnectionManager?.rxStomp ? this.stompConnectionManager.rxStomp.watch(e).pipe(R((t) => {
290
- const r = /* @__PURE__ */ new Map();
291
- let n = "";
292
- for (const i of Object.keys(t.headers))
293
- i === "destination" ? n = t.headers[i] : r.set(i, t.headers[i]);
294
- return new g(n, r, t.binaryBody);
295
- })) : N(() => this.createSendUnavailableError());
295
+ if (this.stompConnectionManager?.rxStomp)
296
+ return this.stompConnectionManager.rxStomp.watch(e).pipe(R((t) => {
297
+ const r = /* @__PURE__ */ new Map();
298
+ let i = "";
299
+ for (const n of Object.keys(t.headers))
300
+ n === "destination" ? i = t.headers[n] : r.set(n, t.headers[n]);
301
+ return new g(i, r, t.binaryBody);
302
+ }));
303
+ throw this.createSendUnavailableError();
296
304
  }
297
305
  }
298
306
  class E {
@@ -310,8 +318,8 @@ class E {
310
318
  const r = E.parseRaw(t);
311
319
  this._scheme = r.scheme, this._scope = r.scope, this._resourceName = r.resourceName, this._path = r.path, this._version = r.version, this._raw = t;
312
320
  } else if (e.length === 5) {
313
- const [t, r, n, i, c] = e;
314
- this._scheme = t, this._scope = r, this._resourceName = n, this._path = i, this._version = c, this._raw = E.buildRaw(t, r, n, i, c);
321
+ const [t, r, i, n, c] = e;
322
+ this._scheme = t, this._scope = r, this._resourceName = i, this._path = n, this._version = c, this._raw = E.buildRaw(t, r, i, n, c);
315
323
  } else
316
324
  throw new Error("Invalid constructor arguments for DefaultCRI");
317
325
  if (!this._scheme || !this._resourceName)
@@ -363,22 +371,22 @@ class E {
363
371
  const t = /^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/, r = e.match(t);
364
372
  if (!r)
365
373
  throw new Error(`Invalid CRI format: ${e}`);
366
- const [, n, i, c, a, h] = r;
374
+ const [, i, n, c, a, h] = r;
367
375
  return {
368
- scheme: n,
369
- scope: i || null,
376
+ scheme: i,
377
+ scope: n || null,
370
378
  resourceName: c,
371
379
  path: a ? a.substring(1) : null,
372
380
  version: h || null
373
381
  };
374
382
  }
375
383
  // Helper to build a raw CRI string
376
- static buildRaw(e, t, r, n, i) {
384
+ static buildRaw(e, t, r, i, n) {
377
385
  let c = `${e}://`;
378
- return t && (c += `${t}@`), c += r, n && (c += `/${n}`), i && (c += `#${i}`), c;
386
+ return t && (c += `${t}@`), c += r, i && (c += `/${i}`), n && (c += `#${n}`), c;
379
387
  }
380
388
  }
381
- function I(...s) {
389
+ function w(...s) {
382
390
  if (s.length === 1) return new E(s[0]);
383
391
  if (s.length === 2) return new E(s[0], null, s[1], null, null);
384
392
  if (s.length === 3) return new E(s[0], s[1], s[2], null, null);
@@ -402,16 +410,16 @@ class O {
402
410
  static createReplyEvent(e, t, r) {
403
411
  if (!e)
404
412
  throw new Error("incomingHeaders cannot be null");
405
- const n = e.get(o.REPLY_TO_HEADER);
406
- if (!n || n.trim() === "")
413
+ const i = e.get(o.REPLY_TO_HEADER);
414
+ if (!i || i.trim() === "")
407
415
  throw new Error("No reply-to header found, cannot create outgoing message");
408
- const i = /* @__PURE__ */ new Map();
416
+ const n = /* @__PURE__ */ new Map();
409
417
  for (const [c, a] of e)
410
- c.startsWith("__") && i.set(c, a);
418
+ c.startsWith("__") && n.set(c, a);
411
419
  if (t)
412
420
  for (const [c, a] of t)
413
- i.set(c, a);
414
- return new g(n, i, r || void 0);
421
+ n.set(c, a);
422
+ return new g(i, n, r || void 0);
415
423
  }
416
424
  }
417
425
  class ee {
@@ -460,7 +468,7 @@ class re {
460
468
  * @return the cri for this {@link ServiceIdentifier}
461
469
  */
462
470
  cri() {
463
- return this._cri == null && (this._cri = I(
471
+ return this._cri == null && (this._cri = w(
464
472
  o.SERVICE_DESTINATION_SCHEME,
465
473
  // scheme
466
474
  this.scope || null,
@@ -474,7 +482,7 @@ class re {
474
482
  )), this._cri;
475
483
  }
476
484
  }
477
- const P = /* @__PURE__ */ Symbol("scope"), x = /* @__PURE__ */ Symbol("version"), T = /* @__PURE__ */ Symbol("context");
485
+ const P = /* @__PURE__ */ Symbol("scope"), x = /* @__PURE__ */ Symbol("version"), _ = /* @__PURE__ */ Symbol("context");
478
486
  function ke(s, e, t) {
479
487
  Reflect.defineMetadata(P, e, s);
480
488
  }
@@ -485,23 +493,23 @@ function Be(s) {
485
493
  Reflect.defineMetadata(x, s, e);
486
494
  };
487
495
  }
488
- function qe() {
496
+ function Fe() {
489
497
  return function(s, e, t) {
490
- const r = Reflect.getMetadata(T, s, e) || [];
491
- r.push(t), Reflect.defineMetadata(T, r, s, e);
498
+ const r = Reflect.getMetadata(_, s, e) || [];
499
+ r.push(t), Reflect.defineMetadata(_, r, s, e);
492
500
  };
493
501
  }
494
- function Fe(s, e) {
502
+ function $e(s, e) {
495
503
  return function(t) {
496
- const r = t, n = new re(s, e || t.name), i = Reflect.getMetadata(x, t);
497
- i && (n.version = i);
504
+ const r = t, i = new re(s, e || t.name), n = Reflect.getMetadata(x, t);
505
+ n && (i.version = n);
498
506
  const c = function(...a) {
499
507
  const h = Reflect.construct(r, a), p = Reflect.getMetadata(P, t.prototype);
500
508
  if (p) {
501
509
  const u = h[p];
502
- n.scope = typeof u == "function" ? u.call(h) : u;
510
+ i.scope = typeof u == "function" ? u.call(h) : u;
503
511
  }
504
- return D.serviceRegistry.register(n, h), h;
512
+ return D.serviceRegistry.register(i, h), h;
505
513
  };
506
514
  return c.prototype = r.prototype, c;
507
515
  };
@@ -509,7 +517,7 @@ function Fe(s, e) {
509
517
  class se {
510
518
  log;
511
519
  active = !1;
512
- eventBusService;
520
+ _eventBus;
513
521
  interceptorProvider;
514
522
  argumentResolver;
515
523
  returnValueConverter;
@@ -517,22 +525,30 @@ class se {
517
525
  serviceInstance;
518
526
  methodSubscription = null;
519
527
  methodMap;
520
- constructor(e, t, r, n, i = {}) {
528
+ constructor(e, t, r, i, n = {}) {
521
529
  if (!e) throw new Error("ServiceIdentifier must not be null");
522
530
  if (!t) throw new Error("Service instance must not be null");
523
- if (!r) throw new Error("EventBusService must not be null");
524
- if (!n) throw new Error("interceptorProvider must not be null");
525
- this.serviceIdentifier = e, this.serviceInstance = t, this.eventBusService = r, this.interceptorProvider = n, this.log = i.logger || te("continuum:ServiceInvocationSupervisor"), this.argumentResolver = i.argumentResolver || new Q(), this.returnValueConverter = i.returnValueConverter || new ee(), this.methodMap = this.buildMethodMap(t);
531
+ if (!r) throw new Error("IEventBus must not be null");
532
+ if (!i) throw new Error("interceptorProvider must not be null");
533
+ this.serviceIdentifier = e, this.serviceInstance = t, this._eventBus = r, this.interceptorProvider = i, this.log = n.logger || te("continuum:ServiceInvocationSupervisor"), this.argumentResolver = n.argumentResolver || new Q(), this.returnValueConverter = n.returnValueConverter || new ee(), this.methodMap = this.buildMethodMap(t);
526
534
  }
527
535
  isActive() {
528
536
  return this.active;
529
537
  }
538
+ /**
539
+ * The {@link IEventBus} that this supervisor uses to listen for service invocation events
540
+ * This can be changed at runtime, the supervisor will restart to use the new event bus
541
+ * @param eventBus the new IEventBus to use
542
+ */
543
+ set eventBus(e) {
544
+ this.active ? (this.stop(), this._eventBus = e, this.start()) : this._eventBus = e;
545
+ }
530
546
  start() {
531
547
  if (this.active)
532
548
  throw new Error("Service already started");
533
549
  this.active = !0;
534
550
  const e = this.serviceIdentifier.cri().baseResource();
535
- this.methodSubscription = this.eventBusService.observe(e).subscribe({
551
+ this.methodSubscription = this._eventBus.observe(e).subscribe({
536
552
  next: async (t) => {
537
553
  await this.processEvent(t);
538
554
  },
@@ -552,8 +568,8 @@ class se {
552
568
  buildMethodMap(e) {
553
569
  const t = {};
554
570
  for (const r of Object.getOwnPropertyNames(Object.getPrototypeOf(e))) {
555
- const n = e[r];
556
- typeof n == "function" && r !== "constructor" && (t[r] = n.bind(e));
571
+ const i = e[r];
572
+ typeof i == "function" && r !== "constructor" && (t[r] = i.bind(e));
557
573
  }
558
574
  return t;
559
575
  }
@@ -573,13 +589,13 @@ class se {
573
589
  this.log.trace(`Processing control event for correlationId: ${t}`);
574
590
  }
575
591
  async processInvocationRequest(e) {
576
- const t = I(e.cri).path();
592
+ const t = w(e.cri).path();
577
593
  if (!t)
578
594
  throw new Error("The methodId must not be blank");
579
595
  const r = this.methodMap[t];
580
596
  if (!r)
581
597
  throw new Error(`No method resolved for methodId ${t}`);
582
- const n = t, i = this.argumentResolver.resolveArguments(e), c = Reflect.getMetadata(T, this.serviceInstance, n) || [];
598
+ const i = t, n = this.argumentResolver.resolveArguments(e), c = Reflect.getMetadata(_, this.serviceInstance, i) || [];
583
599
  let a = {};
584
600
  const h = this.interceptorProvider();
585
601
  if (h)
@@ -590,13 +606,13 @@ class se {
590
606
  return;
591
607
  }
592
608
  for (const l of c)
593
- i[l] = a;
609
+ n[l] = a;
594
610
  const p = r.length;
595
- if (i.length !== p)
596
- throw new Error(`Argument count mismatch for method ${t}: expected ${p}, got ${i.length}`);
611
+ if (n.length !== p)
612
+ throw new Error(`Argument count mismatch for method ${t}: expected ${p}, got ${n.length}`);
597
613
  let u;
598
614
  try {
599
- u = r(...i), u instanceof Promise ? u.then(
615
+ u = r(...n), u instanceof Promise ? u.then(
600
616
  (l) => this.processMethodInvocationResult(e, l),
601
617
  (l) => this.handleException(e, l)
602
618
  ) : this.processMethodInvocationResult(e, u);
@@ -606,7 +622,7 @@ class se {
606
622
  }
607
623
  processMethodInvocationResult(e, t) {
608
624
  const r = this.returnValueConverter.convert(e.headers, t);
609
- this.eventBusService.send(r);
625
+ this._eventBus.send(r);
610
626
  }
611
627
  handleException(e, t) {
612
628
  const r = O.createReplyEvent(
@@ -617,15 +633,15 @@ class se {
617
633
  ]),
618
634
  new TextEncoder().encode(JSON.stringify({ message: t.message }))
619
635
  );
620
- this.eventBusService.send(r);
636
+ this._eventBus.send(r);
621
637
  }
622
638
  validateReplyTo(e) {
623
639
  const t = e.getHeader(o.REPLY_TO_HEADER);
624
640
  return t ? t.trim() === "" ? (this.log.warn("Reply-to header must not be blank"), !1) : t.startsWith(`${o.SERVICE_DESTINATION_SCHEME}:`) ? !0 : (this.log.warn("Reply-to header must be a valid service destination"), !1) : (this.log.warn("No reply-to header found in event"), !1);
625
641
  }
626
642
  }
627
- const ne = "2.14.7", ie = {
628
- version: ne
643
+ const ie = "2.14.9", ne = {
644
+ version: ie
629
645
  };
630
646
  class oe {
631
647
  create(e, t) {
@@ -633,44 +649,54 @@ class oe {
633
649
  return r.setHeader(o.CONTENT_TYPE_HEADER, o.CONTENT_JSON), t != null && r.setDataString(JSON.stringify(t)), r;
634
650
  }
635
651
  }
636
- class $e {
652
+ class qe {
637
653
  create(e, t) {
638
654
  const r = new g(e);
639
655
  if (r.setHeader(o.CONTENT_TYPE_HEADER, o.CONTENT_TEXT), t != null) {
640
- let n = "", i = 0;
656
+ let i = "", n = 0;
641
657
  for (const c of t)
642
- i > 0 && (n = n + `
643
- `), n = n + c, i++;
644
- n.length > 0 && r.setDataString(n);
658
+ n > 0 && (i = i + `
659
+ `), i = i + c, n++;
660
+ i.length > 0 && r.setDataString(i);
645
661
  }
646
662
  return r;
647
663
  }
648
664
  }
649
665
  class ce {
650
- eventBus;
666
+ _eventBus;
651
667
  supervisors = /* @__PURE__ */ new Map();
652
668
  contextInterceptor = null;
669
+ debugLogger = I("continuum:serviceRegistry");
653
670
  constructor(e) {
654
- this.eventBus = e;
671
+ this._eventBus = e;
672
+ }
673
+ set eventBus(e) {
674
+ this._eventBus = e;
675
+ for (const t of this.supervisors.values())
676
+ t.eventBus = e;
677
+ }
678
+ get eventBus() {
679
+ return this._eventBus;
655
680
  }
656
681
  serviceProxy(e) {
657
- return new ue(e, this.eventBus);
682
+ return new ue(e, this);
658
683
  }
659
684
  register(e, t) {
660
685
  const r = e.cri().raw();
661
686
  if (!this.supervisors.has(r)) {
662
- const n = new se(
687
+ this.debugLogger(`Registering service for CRI: ${r}`);
688
+ const i = new se(
663
689
  e,
664
690
  t,
665
691
  this.eventBus,
666
692
  () => this.contextInterceptor
667
693
  );
668
- this.supervisors.set(r, n), n.start();
694
+ this.supervisors.set(r, i), i.start();
669
695
  }
670
696
  }
671
697
  unRegister(e) {
672
698
  const t = e.cri().raw(), r = this.supervisors.get(t);
673
- r && (r.stop(), this.supervisors.delete(t));
699
+ r && (this.debugLogger(`Unregistering service for CRI: ${t}`), r.stop(), this.supervisors.delete(t));
674
700
  }
675
701
  registerContextInterceptor(e) {
676
702
  this.contextInterceptor = e;
@@ -679,38 +705,38 @@ class ce {
679
705
  const ae = new oe();
680
706
  class ue {
681
707
  serviceIdentifier;
682
- eventBus;
708
+ serviceRegistry;
683
709
  tracer;
684
710
  constructor(e, t) {
685
711
  if (typeof e > "u" || e.length === 0)
686
712
  throw new Error("The serviceIdentifier provided must contain a value");
687
- this.serviceIdentifier = e, this.eventBus = t, this.tracer = b.trace.getTracer(
713
+ this.serviceIdentifier = e, this.serviceRegistry = t, this.tracer = b.trace.getTracer(
688
714
  "continuum.client",
689
- ie.version
715
+ ne.version
690
716
  );
691
717
  }
692
- invoke(e, t, r, n) {
718
+ invoke(e, t, r, i) {
693
719
  return this.tracer.startActiveSpan(
694
720
  `${this.serviceIdentifier}/${e}`,
695
721
  {
696
- kind: U.CLIENT
722
+ kind: q.CLIENT
697
723
  },
698
- async (i) => (r && i.setAttribute("continuum.scope", r), i.setAttribute("rpc.system", "continuum"), i.setAttribute("rpc.service", this.serviceIdentifier), i.setAttribute("rpc.method", e), this.__invokeStream(!1, e, t, r, n).pipe(W()).toPromise().then(
699
- async (c) => (i.end(), c),
724
+ async (n) => (r && n.setAttribute("continuum.scope", r), n.setAttribute("rpc.system", "continuum"), n.setAttribute("rpc.service", this.serviceIdentifier), n.setAttribute("rpc.method", e), this.__invokeStream(!1, e, t, r, i).pipe(W()).toPromise().then(
725
+ async (c) => (n.end(), c),
700
726
  async (c) => {
701
- throw i.recordException(c), i.setStatus({ code: Y.ERROR }), i.end(), c;
727
+ throw n.recordException(c), n.setStatus({ code: Y.ERROR }), n.end(), c;
702
728
  }
703
729
  ))
704
730
  );
705
731
  }
706
- invokeStream(e, t, r, n) {
707
- return this.__invokeStream(!0, e, t, r, n);
732
+ invokeStream(e, t, r, i) {
733
+ return this.__invokeStream(!0, e, t, r, i);
708
734
  }
709
- __invokeStream(e, t, r, n, i) {
710
- const c = o.SERVICE_DESTINATION_PREFIX + (n != null ? n + "@" : "") + this.serviceIdentifier + "/" + t;
735
+ __invokeStream(e, t, r, i, n) {
736
+ const c = o.SERVICE_DESTINATION_PREFIX + (i != null ? i + "@" : "") + this.serviceIdentifier + "/" + t;
711
737
  let a = ae;
712
- i ? a = i : f.getEventFactory() && (a = f.getEventFactory());
713
- let h = this.eventBus;
738
+ n ? a = n : f.getEventFactory() && (a = f.getEventFactory());
739
+ let h = this.serviceRegistry.eventBus;
714
740
  f.getContinuumInstance() && (h = f.getContinuumInstance().eventBus);
715
741
  const p = b.trace.getActiveSpan();
716
742
  p && (p.setAttribute(G, h.serverInfo?.host || "unknown"), p.setAttribute(K, h.serverInfo?.port || "unknown"));
@@ -728,7 +754,7 @@ class ue {
728
754
  }));
729
755
  }
730
756
  }
731
- class _ {
757
+ class T {
732
758
  pageable;
733
759
  currentPage;
734
760
  firstPage = !0;
@@ -773,7 +799,7 @@ class _ {
773
799
  return this.currentPage.content;
774
800
  }
775
801
  }
776
- class le extends _ {
802
+ class le extends T {
777
803
  crudServiceProxy;
778
804
  constructor(e, t, r) {
779
805
  super(e, t), this.crudServiceProxy = r;
@@ -782,11 +808,11 @@ class le extends _ {
782
808
  return this.crudServiceProxy.findAllSinglePage(e);
783
809
  }
784
810
  }
785
- class he extends _ {
811
+ class he extends T {
786
812
  searchText;
787
813
  crudServiceProxy;
788
- constructor(e, t, r, n) {
789
- super(e, t), this.searchText = r, this.crudServiceProxy = n;
814
+ constructor(e, t, r, i) {
815
+ super(e, t), this.searchText = r, this.crudServiceProxy = i;
790
816
  }
791
817
  findNext(e) {
792
818
  return this.crudServiceProxy.searchSinglePage(this.searchText, e);
@@ -868,7 +894,7 @@ class fe {
868
894
  /**
869
895
  * The {@link IEventBus} that is used to communicate with the Continuum server
870
896
  */
871
- eventBus;
897
+ _eventBus;
872
898
  /**
873
899
  * The {@link ServiceRegistry} that is used to manage the services that are available
874
900
  */
@@ -878,7 +904,13 @@ class fe {
878
904
  */
879
905
  crudServiceProxyFactory;
880
906
  constructor() {
881
- this.eventBus = new Z(), this.serviceRegistry = new ce(this.eventBus), this.crudServiceProxyFactory = new de(this.serviceRegistry);
907
+ this._eventBus = new Z(), this.serviceRegistry = new ce(this._eventBus), this.crudServiceProxyFactory = new de(this.serviceRegistry);
908
+ }
909
+ get eventBus() {
910
+ return this._eventBus;
911
+ }
912
+ set eventBus(e) {
913
+ this._eventBus = e, this.serviceRegistry.eventBus = e;
882
914
  }
883
915
  /**
884
916
  * Requests a connection to the given Stomp url
@@ -886,14 +918,14 @@ class fe {
886
918
  * @return Promise containing the result of the initial connection attempt
887
919
  */
888
920
  connect(e) {
889
- return this.eventBus.connect(e);
921
+ return this._eventBus.connect(e);
890
922
  }
891
923
  /**
892
924
  * Disconnects the client from the server
893
925
  * This will clear any subscriptions and close the connection
894
926
  */
895
927
  disconnect(e) {
896
- return this.eventBus.disconnect(e);
928
+ return this._eventBus.disconnect(e);
897
929
  }
898
930
  /**
899
931
  * Creates a new service proxy that can be used to access the desired service.
@@ -922,13 +954,13 @@ class fe {
922
954
  async execute(e, t) {
923
955
  const r = f;
924
956
  r.push({ instance: this, eventFactory: t });
925
- let n;
957
+ let i;
926
958
  try {
927
- n = await e();
959
+ i = await e();
928
960
  } finally {
929
961
  r.pop();
930
962
  }
931
- return n;
963
+ return i;
932
964
  }
933
965
  }
934
966
  const D = new fe();
@@ -936,13 +968,13 @@ var ge = /* @__PURE__ */ ((s) => (s.TRACE = "TRACE", s.DEBUG = "DEBUG", s.INFO =
936
968
  class y {
937
969
  configuredLevel;
938
970
  }
939
- class me extends y {
971
+ class ve extends y {
940
972
  members = [];
941
973
  }
942
- class ve extends y {
974
+ class me extends y {
943
975
  effectiveLevel;
944
976
  }
945
- class Ue {
977
+ class Ye {
946
978
  levels = [];
947
979
  loggerLevels = /* @__PURE__ */ new Map();
948
980
  groups = /* @__PURE__ */ new Map();
@@ -957,20 +989,20 @@ class Se {
957
989
  }
958
990
  async loggerLevels(e, t) {
959
991
  const r = await this.serviceProxy.invoke("loggerLevels", [t], e);
960
- let n = null;
961
- return r.hasOwnProperty("members") ? n = new me() : r.hasOwnProperty("effectiveLevel") ? n = new ve() : n = new y(), Object.assign(n, r), n;
992
+ let i = null;
993
+ return r.hasOwnProperty("members") ? i = new ve() : r.hasOwnProperty("effectiveLevel") ? i = new me() : i = new y(), Object.assign(i, r), i;
962
994
  }
963
995
  configureLogLevel(e, t, r) {
964
996
  return this.serviceProxy.invoke("configureLogLevel", [t, r], e);
965
997
  }
966
998
  }
967
- const Ye = new Se();
968
- class H extends m {
999
+ const Ue = new Se();
1000
+ class H extends v {
969
1001
  constructor(e) {
970
1002
  super(e), Object.setPrototypeOf(this, H.prototype);
971
1003
  }
972
1004
  }
973
- class L extends m {
1005
+ class L extends v {
974
1006
  constructor(e) {
975
1007
  super(e), Object.setPrototypeOf(this, L.prototype);
976
1008
  }
@@ -985,8 +1017,8 @@ class je {
985
1017
  tenantId;
986
1018
  metadata;
987
1019
  roles;
988
- constructor(e, t, r, n) {
989
- this.id = e, this.tenantId = t, this.metadata = r || /* @__PURE__ */ new Map(), this.roles = n || [];
1020
+ constructor(e, t, r, i) {
1021
+ this.id = e, this.tenantId = t, this.metadata = r || /* @__PURE__ */ new Map(), this.roles = i || [];
990
1022
  }
991
1023
  }
992
1024
  class Je {
@@ -1009,7 +1041,7 @@ class Xe {
1009
1041
  return this.value !== null && this.value !== void 0;
1010
1042
  }
1011
1043
  }
1012
- class We extends _ {
1044
+ class We extends T {
1013
1045
  pageFunction;
1014
1046
  constructor(e, t, r) {
1015
1047
  super(e, t), this.pageFunction = r;
@@ -1039,7 +1071,7 @@ class M {
1039
1071
  * @param sort the sorting parameters (optional).
1040
1072
  */
1041
1073
  static create(e, t, r) {
1042
- return new Te(e, t, r);
1074
+ return new _e(e, t, r);
1043
1075
  }
1044
1076
  /**
1045
1077
  * Creates a {@link Pageable} that uses Cursor based pagination.
@@ -1048,10 +1080,10 @@ class M {
1048
1080
  * @param sort the sorting parameters (optional).
1049
1081
  */
1050
1082
  static createWithCursor(e, t, r) {
1051
- return new _e(e, t, r);
1083
+ return new Te(e, t, r);
1052
1084
  }
1053
1085
  }
1054
- class Te extends M {
1086
+ class _e extends M {
1055
1087
  /**
1056
1088
  * Returns the page to be returned.
1057
1089
  */
@@ -1066,7 +1098,7 @@ class Te extends M {
1066
1098
  super(), this.pageNumber = e, this.pageSize = t, this.sort = r;
1067
1099
  }
1068
1100
  }
1069
- class _e extends M {
1101
+ class Te extends M {
1070
1102
  /**
1071
1103
  * The cursor to be used for subsequent retrieval of data, or null if this is the first page.
1072
1104
  */
@@ -1106,21 +1138,21 @@ class ze {
1106
1138
  orders = [];
1107
1139
  }
1108
1140
  export {
1109
- _ as AbstractIterablePage,
1141
+ T as AbstractIterablePage,
1110
1142
  H as AuthenticationError,
1111
1143
  L as AuthorizationError,
1112
- T as CONTEXT_METADATA_KEY,
1144
+ _ as CONTEXT_METADATA_KEY,
1113
1145
  Le as ConnectHeaders,
1114
1146
  Ve as ConnectedInfo,
1115
1147
  Me as ConnectionInfo,
1116
- qe as Context,
1148
+ Fe as Context,
1117
1149
  D as Continuum,
1118
1150
  f as ContinuumContextStack,
1119
- m as ContinuumError,
1151
+ v as ContinuumError,
1120
1152
  fe as ContinuumSingleton,
1121
1153
  pe as CrudServiceProxy,
1122
1154
  de as CrudServiceProxyFactory,
1123
- _e as CursorPageable,
1155
+ Te as CursorPageable,
1124
1156
  Ge as DataSourceUtils,
1125
1157
  E as DefaultCRI,
1126
1158
  ye as Direction,
@@ -1128,29 +1160,29 @@ export {
1128
1160
  Z as EventBus,
1129
1161
  o as EventConstants,
1130
1162
  We as FunctionalIterablePage,
1131
- me as GroupLoggerLevelsDescriptor,
1163
+ ve as GroupLoggerLevelsDescriptor,
1132
1164
  oe as JsonEventFactory,
1133
1165
  ge as LogLevel,
1134
1166
  Se as LogManager,
1135
1167
  y as LoggerLevelsDescriptor,
1136
- Ue as LoggersDescriptor,
1168
+ Ye as LoggersDescriptor,
1137
1169
  be as NullHandling,
1138
- Te as OffsetPageable,
1170
+ _e as OffsetPageable,
1139
1171
  Ke as Order,
1140
1172
  M as Pageable,
1141
1173
  je as Participant,
1142
1174
  Je as ParticipantConstants,
1143
- Fe as Publish,
1175
+ $e as Publish,
1144
1176
  ke as Scope,
1145
- w as ServerInfo,
1177
+ N as ServerInfo,
1146
1178
  ce as ServiceRegistry,
1147
- ve as SingleLoggerLevelsDescriptor,
1179
+ me as SingleLoggerLevelsDescriptor,
1148
1180
  ze as Sort,
1149
1181
  Xe as StreamData,
1150
1182
  Re as StreamOperation,
1151
- $e as TextEventFactory,
1183
+ qe as TextEventFactory,
1152
1184
  Be as Version,
1153
- I as createCRI,
1154
- Ye as logManager
1185
+ w as createCRI,
1186
+ Ue as logManager
1155
1187
  };
1156
1188
  //# sourceMappingURL=continuum.js.map