@mindignited/continuum-client 2.14.7 → 3.0.0-beta.1

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