@mindignited/continuum-client 2.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/continuum.cjs +3 -0
- package/dist/continuum.cjs.map +1 -0
- package/dist/continuum.js +1156 -0
- package/dist/continuum.js.map +1 -0
- package/dist/src/api/ConnectionInfo.d.ts +35 -0
- package/dist/src/api/Continuum.d.ts +81 -0
- package/dist/src/api/ContinuumDecorators.d.ts +5 -0
- package/dist/src/api/ILogManager.d.ts +49 -0
- package/dist/src/api/Identifiable.d.ts +7 -0
- package/dist/src/api/LogManager.d.ts +9 -0
- package/dist/src/api/errors/AuthenticationError.d.ts +4 -0
- package/dist/src/api/errors/AuthorizationError.d.ts +4 -0
- package/dist/src/api/errors/ContinuumError.d.ts +6 -0
- package/dist/src/api/security/ConnectedInfo.d.ts +9 -0
- package/dist/src/api/security/IParticipant.d.ts +30 -0
- package/dist/src/api/security/Participant.d.ts +11 -0
- package/dist/src/api/security/ParticipantConstants.d.ts +12 -0
- package/dist/src/core/api/CRI.d.ts +122 -0
- package/dist/src/core/api/ContextInterceptor.d.ts +19 -0
- package/dist/src/core/api/DefaultCRI.d.ts +32 -0
- package/dist/src/core/api/EventBus.d.ts +55 -0
- package/dist/src/core/api/IEventBus.d.ts +204 -0
- package/dist/src/core/api/IServiceRegistry.d.ts +74 -0
- package/dist/src/core/api/ServiceIdentifier.d.ts +20 -0
- package/dist/src/core/api/ServiceRegistry.d.ts +29 -0
- package/dist/src/core/api/StompConnectionManager.d.ts +38 -0
- package/dist/src/core/api/StreamData.d.ts +18 -0
- package/dist/src/core/api/crud/AbstractIterablePage.d.ts +23 -0
- package/dist/src/core/api/crud/CrudServiceProxy.d.ts +19 -0
- package/dist/src/core/api/crud/CrudServiceProxyFactory.d.ts +12 -0
- package/dist/src/core/api/crud/FunctionalIterablePage.d.ts +8 -0
- package/dist/src/core/api/crud/ICrudServiceProxy.d.ts +69 -0
- package/dist/src/core/api/crud/ICrudServiceProxyFactory.d.ts +12 -0
- package/dist/src/core/api/crud/IDataSource.d.ts +67 -0
- package/dist/src/core/api/crud/IterablePage.d.ts +15 -0
- package/dist/src/core/api/crud/Page.d.ts +19 -0
- package/dist/src/core/api/crud/Pageable.d.ts +65 -0
- package/dist/src/core/api/crud/Sort.d.ts +63 -0
- package/dist/src/index.d.ts +35 -0
- package/dist/src/internal/core/api/ArgumentResolver.d.ts +14 -0
- package/dist/src/internal/core/api/EventUtil.d.ts +10 -0
- package/dist/src/internal/core/api/Logger.d.ts +21 -0
- package/dist/src/internal/core/api/ReturnValueConverter.d.ts +13 -0
- package/dist/src/internal/core/api/ServiceInvocationSupervisor.d.ts +39 -0
- package/dist/src/internal/core/api/crud/FindAllIterablePage.d.ts +13 -0
- package/dist/src/internal/core/api/crud/SearchIterablePage.d.ts +14 -0
- package/package.json +66 -0
|
@@ -0,0 +1,1156 @@
|
|
|
1
|
+
import { RxStomp as k } from "@stomp/rx-stomp";
|
|
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";
|
|
7
|
+
import { map as R, multicast as J, filter as X, first as W } from "rxjs/operators";
|
|
8
|
+
import { Optional as C } from "typescript-optional";
|
|
9
|
+
import "reflect-metadata";
|
|
10
|
+
import { ATTR_SERVER_ADDRESS as G, ATTR_SERVER_PORT as K } from "@opentelemetry/semantic-conventions";
|
|
11
|
+
class Le {
|
|
12
|
+
}
|
|
13
|
+
class w {
|
|
14
|
+
host;
|
|
15
|
+
port;
|
|
16
|
+
useSSL;
|
|
17
|
+
}
|
|
18
|
+
class Me extends w {
|
|
19
|
+
/**
|
|
20
|
+
* The headers to send during the connection to the continuum server.
|
|
21
|
+
* If a function is provided, it will be called to get the headers each time the connection is established.
|
|
22
|
+
* This is useful for providing dynamic headers, such as a JWT token that expires.
|
|
23
|
+
*/
|
|
24
|
+
connectHeaders;
|
|
25
|
+
/**
|
|
26
|
+
* The maximum number of connection attempts to make during the {@link IEventBus} initial connection request.
|
|
27
|
+
* If the limit is reached the {@link IEventBus} will return an error to the caller of {@link IEventBus#connect}
|
|
28
|
+
* Set to 0, undefined, or null to try forever
|
|
29
|
+
*/
|
|
30
|
+
maxConnectionAttempts;
|
|
31
|
+
/**
|
|
32
|
+
* If true, the session will not be kept alive after the connection is established and then disrupted.
|
|
33
|
+
* If false, the session will be kept alive after the connection is established and then disrupted, for a period of time.
|
|
34
|
+
*/
|
|
35
|
+
disableStickySession;
|
|
36
|
+
}
|
|
37
|
+
class m extends Error {
|
|
38
|
+
constructor(e) {
|
|
39
|
+
super(e), Object.setPrototypeOf(this, m.prototype);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
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 || {});
|
|
43
|
+
class z {
|
|
44
|
+
lastWebsocketError = null;
|
|
45
|
+
/**
|
|
46
|
+
* This will return true if a {@link ConnectionInfo#maxConnectionAttempts} threshold was set and was reached
|
|
47
|
+
*/
|
|
48
|
+
maxConnectionAttemptsReached = !1;
|
|
49
|
+
rxStomp = null;
|
|
50
|
+
INITIAL_RECONNECT_DELAY = 2e3;
|
|
51
|
+
MAX_RECONNECT_DELAY = 12e4;
|
|
52
|
+
// 2 mins
|
|
53
|
+
JITTER_MAX = 5e3;
|
|
54
|
+
connectionAttempts = 0;
|
|
55
|
+
initialConnectionSuccessful = !1;
|
|
56
|
+
debugLogger = q("continuum:stomp");
|
|
57
|
+
replyToId = S();
|
|
58
|
+
replyToCri = o.SERVICE_DESTINATION_PREFIX + this.replyToId + ":" + S() + "@continuum.js.EventBus/replyHandler";
|
|
59
|
+
deactivationHandler = null;
|
|
60
|
+
/**
|
|
61
|
+
* @return true if this {@link StompConnectionManager} is actively trying to maintain a connection to the Stomp server, false if not.
|
|
62
|
+
*/
|
|
63
|
+
get active() {
|
|
64
|
+
return !!this.rxStomp;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* return true if this {@link StompConnectionManager} is active and has a connection to the stomp server
|
|
68
|
+
*/
|
|
69
|
+
get connected() {
|
|
70
|
+
return this.rxStomp != null && this.rxStomp.connected();
|
|
71
|
+
}
|
|
72
|
+
activate(e) {
|
|
73
|
+
return new Promise((t, r) => {
|
|
74
|
+
if (!e) {
|
|
75
|
+
r("You must supply a valid connectionInfo object");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (!e.host) {
|
|
79
|
+
r("No host provided");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this.rxStomp) {
|
|
83
|
+
r("Stomp connection already active");
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
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 : {};
|
|
90
|
+
const c = {
|
|
91
|
+
brokerURL: n,
|
|
92
|
+
connectHeaders: i,
|
|
93
|
+
heartbeatIncoming: 12e4,
|
|
94
|
+
heartbeatOutgoing: 3e4,
|
|
95
|
+
reconnectDelay: this.INITIAL_RECONNECT_DELAY,
|
|
96
|
+
beforeConnect: async () => {
|
|
97
|
+
if (typeof e.connectHeaders == "function") {
|
|
98
|
+
const u = await e.connectHeaders();
|
|
99
|
+
for (const l in u)
|
|
100
|
+
i[l] = u[l];
|
|
101
|
+
}
|
|
102
|
+
if (e.disableStickySession && (i[o.DISABLE_STICKY_SESSION_HEADER] = "true"), i[o.REPLY_TO_ID_HEADER] = this.replyToId, e?.maxConnectionAttempts)
|
|
103
|
+
if (this.connectionAttempts++, this.connectionAttempts > e.maxConnectionAttempts) {
|
|
104
|
+
if (this.maxConnectionAttemptsReached = !0, await this.deactivate(), !this.initialConnectionSuccessful) {
|
|
105
|
+
let u = this.lastWebsocketError?.message ? this.lastWebsocketError?.message : "UNKNOWN";
|
|
106
|
+
r(`Max number of reconnection attempts reached. Last WS Error ${u}`);
|
|
107
|
+
}
|
|
108
|
+
} else
|
|
109
|
+
await this.connectionJitterDelay();
|
|
110
|
+
else
|
|
111
|
+
await this.connectionJitterDelay();
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
this.debugLogger.enabled && (c.debug = (u) => {
|
|
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) => {
|
|
117
|
+
this.lastWebsocketError = u;
|
|
118
|
+
});
|
|
119
|
+
const a = this.rxStomp.connected$.subscribe(() => {
|
|
120
|
+
a.unsubscribe(), this.initialConnectionSuccessful || (this.initialConnectionSuccessful = !0);
|
|
121
|
+
}), h = this.rxStomp.stompErrors$.subscribe((u) => {
|
|
122
|
+
h.unsubscribe();
|
|
123
|
+
const l = u.headers.message;
|
|
124
|
+
this.rxStomp?.deactivate(), this.rxStomp = null, r(l);
|
|
125
|
+
}), p = this.rxStomp.serverHeaders$.subscribe((u) => {
|
|
126
|
+
let l = u[o.CONNECTED_INFO_HEADER];
|
|
127
|
+
if (l != null) {
|
|
128
|
+
const d = JSON.parse(l);
|
|
129
|
+
if (e.disableStickySession)
|
|
130
|
+
if (typeof e.connectHeaders == "function") {
|
|
131
|
+
for (let v in i)
|
|
132
|
+
delete i[v];
|
|
133
|
+
this.initialConnectionSuccessful || t(d);
|
|
134
|
+
} else typeof e.connectHeaders == "object" && (p.unsubscribe(), t(d));
|
|
135
|
+
else if (p.unsubscribe(), d.sessionId != null && d.replyToId != null) {
|
|
136
|
+
if (e.connectHeaders != null)
|
|
137
|
+
for (let v in i)
|
|
138
|
+
delete i[v];
|
|
139
|
+
i[o.SESSION_HEADER] = d.sessionId, t(d);
|
|
140
|
+
} else
|
|
141
|
+
r("Server did not return proper data for successful login");
|
|
142
|
+
} else
|
|
143
|
+
r("Server did not return proper data for successful login");
|
|
144
|
+
});
|
|
145
|
+
this.rxStomp.activate();
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async deactivate(e) {
|
|
149
|
+
this.rxStomp && (await this.rxStomp.deactivate({ force: e }), this.deactivationHandler && this.deactivationHandler(), this.rxStomp = null);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Make sure clients don't all try to reconnect at the same time.
|
|
153
|
+
*/
|
|
154
|
+
async connectionJitterDelay() {
|
|
155
|
+
if (this.initialConnectionSuccessful) {
|
|
156
|
+
const e = Math.random() * this.JITTER_MAX;
|
|
157
|
+
return this.debugLogger(`Adding ${e}ms of jitter delay`), new Promise((t) => setTimeout(t, e));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
class g {
|
|
162
|
+
cri;
|
|
163
|
+
headers;
|
|
164
|
+
data;
|
|
165
|
+
constructor(e, t, r) {
|
|
166
|
+
this.cri = e, t !== void 0 ? this.headers = t : this.headers = /* @__PURE__ */ new Map(), this.data = C.ofNullable(r);
|
|
167
|
+
}
|
|
168
|
+
getHeader(e) {
|
|
169
|
+
return this.headers.get(e);
|
|
170
|
+
}
|
|
171
|
+
hasHeader(e) {
|
|
172
|
+
return this.headers.has(e);
|
|
173
|
+
}
|
|
174
|
+
setHeader(e, t) {
|
|
175
|
+
this.headers.set(e, t);
|
|
176
|
+
}
|
|
177
|
+
removeHeader(e) {
|
|
178
|
+
return this.headers.delete(e);
|
|
179
|
+
}
|
|
180
|
+
setDataString(e) {
|
|
181
|
+
const t = new TextEncoder().encode(e);
|
|
182
|
+
this.data = C.ofNonNull(t);
|
|
183
|
+
}
|
|
184
|
+
getDataString() {
|
|
185
|
+
let e = "";
|
|
186
|
+
return this.data.ifPresent((t) => e = new TextDecoder().decode(t)), e;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
class Z {
|
|
190
|
+
fatalErrors;
|
|
191
|
+
serverInfo = null;
|
|
192
|
+
stompConnectionManager = new z();
|
|
193
|
+
replyToCri = null;
|
|
194
|
+
requestRepliesObservable = null;
|
|
195
|
+
requestRepliesSubject = null;
|
|
196
|
+
requestRepliesSubscription = null;
|
|
197
|
+
errorSubject = new A();
|
|
198
|
+
errorSubjectSubscription = null;
|
|
199
|
+
constructor() {
|
|
200
|
+
this.fatalErrors = this.errorSubject.pipe(R((e) => (this.disconnect().catch((t) => {
|
|
201
|
+
console && console.error("Error disconnecting from Stomp: " + t);
|
|
202
|
+
}), new m(e.headers.message)))), this.stompConnectionManager.deactivationHandler = () => {
|
|
203
|
+
this.cleanup();
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
isConnectionActive() {
|
|
207
|
+
return this.stompConnectionManager.active;
|
|
208
|
+
}
|
|
209
|
+
isConnected() {
|
|
210
|
+
return this.stompConnectionManager.connected;
|
|
211
|
+
}
|
|
212
|
+
async connect(e) {
|
|
213
|
+
if (this.stompConnectionManager.active)
|
|
214
|
+
throw new Error("Event Bus connection already active");
|
|
215
|
+
{
|
|
216
|
+
this.cleanup();
|
|
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;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async disconnect(e) {
|
|
222
|
+
await this.stompConnectionManager.deactivate(e), this.cleanup();
|
|
223
|
+
}
|
|
224
|
+
send(e) {
|
|
225
|
+
if (this.stompConnectionManager.rxStomp) {
|
|
226
|
+
const t = {};
|
|
227
|
+
for (const [n, i] of e.headers.entries())
|
|
228
|
+
t[n] = i;
|
|
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({
|
|
231
|
+
destination: e.cri,
|
|
232
|
+
headers: t,
|
|
233
|
+
binaryBody: e.data.orUndefined()
|
|
234
|
+
});
|
|
235
|
+
} else
|
|
236
|
+
throw this.createSendUnavailableError();
|
|
237
|
+
}
|
|
238
|
+
request(e) {
|
|
239
|
+
return V(this.requestStream(e, !1));
|
|
240
|
+
}
|
|
241
|
+
requestStream(e, t = !0) {
|
|
242
|
+
return this.stompConnectionManager?.rxStomp ? new j((r) => {
|
|
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({
|
|
246
|
+
next(a) {
|
|
247
|
+
if (a.hasHeader(o.CONTROL_HEADER))
|
|
248
|
+
if (a.headers.get(o.CONTROL_HEADER) === "complete")
|
|
249
|
+
n = !0, r.complete();
|
|
250
|
+
else
|
|
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);
|
|
253
|
+
},
|
|
254
|
+
error(a) {
|
|
255
|
+
r.error(a);
|
|
256
|
+
},
|
|
257
|
+
complete() {
|
|
258
|
+
r.complete();
|
|
259
|
+
}
|
|
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) {
|
|
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);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
}) : N(() => this.createSendUnavailableError());
|
|
268
|
+
}
|
|
269
|
+
observe(e) {
|
|
270
|
+
return this._observe(e);
|
|
271
|
+
}
|
|
272
|
+
cleanup() {
|
|
273
|
+
this.requestRepliesSubject != null && (this.requestRepliesSubject.error(new Error("Connection disconnected")), this.requestRepliesSubscription != null && (this.requestRepliesSubscription.unsubscribe(), this.requestRepliesSubscription = null), this.requestRepliesSubject = null, this.requestRepliesObservable = null), this.errorSubjectSubscription && (this.errorSubjectSubscription.unsubscribe(), this.errorSubjectSubscription = null), this.serverInfo = null;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Creates the proper error to return if this.stompConnectionManager?.rxStomp is not available on a send request
|
|
277
|
+
*/
|
|
278
|
+
createSendUnavailableError() {
|
|
279
|
+
let e = "You must call connect on the event bus before sending any request";
|
|
280
|
+
return this.stompConnectionManager.maxConnectionAttemptsReached && (e = "Max connection attempts reached event bus is not available"), new Error(e);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* This is internal impl of observe that creates a cold observable.
|
|
284
|
+
* The public variants transform this to some type of hot observable depending on the need
|
|
285
|
+
* @param cri to observe
|
|
286
|
+
* @return the cold {@link Observable<IEvent>} for the given destination
|
|
287
|
+
*/
|
|
288
|
+
_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());
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
class E {
|
|
299
|
+
_scheme;
|
|
300
|
+
_scope;
|
|
301
|
+
_resourceName;
|
|
302
|
+
_path;
|
|
303
|
+
_version;
|
|
304
|
+
_raw;
|
|
305
|
+
constructor(...e) {
|
|
306
|
+
if (e.length === 1) {
|
|
307
|
+
const t = e[0];
|
|
308
|
+
if (typeof t != "string")
|
|
309
|
+
throw new Error("Raw URI must be a string");
|
|
310
|
+
const r = E.parseRaw(t);
|
|
311
|
+
this._scheme = r.scheme, this._scope = r.scope, this._resourceName = r.resourceName, this._path = r.path, this._version = r.version, this._raw = t;
|
|
312
|
+
} 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);
|
|
315
|
+
} else
|
|
316
|
+
throw new Error("Invalid constructor arguments for DefaultCRI");
|
|
317
|
+
if (!this._scheme || !this._resourceName)
|
|
318
|
+
throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`);
|
|
319
|
+
}
|
|
320
|
+
scheme() {
|
|
321
|
+
return this._scheme;
|
|
322
|
+
}
|
|
323
|
+
scope() {
|
|
324
|
+
return this._scope;
|
|
325
|
+
}
|
|
326
|
+
hasScope() {
|
|
327
|
+
return this._scope !== null;
|
|
328
|
+
}
|
|
329
|
+
resourceName() {
|
|
330
|
+
return this._resourceName;
|
|
331
|
+
}
|
|
332
|
+
version() {
|
|
333
|
+
return this._version;
|
|
334
|
+
}
|
|
335
|
+
hasVersion() {
|
|
336
|
+
return this._version !== null;
|
|
337
|
+
}
|
|
338
|
+
path() {
|
|
339
|
+
return this._path;
|
|
340
|
+
}
|
|
341
|
+
hasPath() {
|
|
342
|
+
return this._path !== null;
|
|
343
|
+
}
|
|
344
|
+
baseResource() {
|
|
345
|
+
let e = `${this._scheme}://`;
|
|
346
|
+
return this.hasScope() && (e += `${this._scope}@`), e += this._resourceName, e;
|
|
347
|
+
}
|
|
348
|
+
raw() {
|
|
349
|
+
return this._raw;
|
|
350
|
+
}
|
|
351
|
+
equals(e) {
|
|
352
|
+
return this === e ? !0 : e instanceof E ? this._raw === e.raw() : !1;
|
|
353
|
+
}
|
|
354
|
+
hashCode() {
|
|
355
|
+
let e = 17;
|
|
356
|
+
return e = e * 37 + this._raw.split("").reduce((t, r) => t + r.charCodeAt(0), 0), e;
|
|
357
|
+
}
|
|
358
|
+
toString() {
|
|
359
|
+
return this._raw;
|
|
360
|
+
}
|
|
361
|
+
// Helper to parse a raw CRI string
|
|
362
|
+
static parseRaw(e) {
|
|
363
|
+
const t = /^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/, r = e.match(t);
|
|
364
|
+
if (!r)
|
|
365
|
+
throw new Error(`Invalid CRI format: ${e}`);
|
|
366
|
+
const [, n, i, c, a, h] = r;
|
|
367
|
+
return {
|
|
368
|
+
scheme: n,
|
|
369
|
+
scope: i || null,
|
|
370
|
+
resourceName: c,
|
|
371
|
+
path: a ? a.substring(1) : null,
|
|
372
|
+
version: h || null
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
// Helper to build a raw CRI string
|
|
376
|
+
static buildRaw(e, t, r, n, i) {
|
|
377
|
+
let c = `${e}://`;
|
|
378
|
+
return t && (c += `${t}@`), c += r, n && (c += `/${n}`), i && (c += `#${i}`), c;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function I(...s) {
|
|
382
|
+
if (s.length === 1) return new E(s[0]);
|
|
383
|
+
if (s.length === 2) return new E(s[0], null, s[1], null, null);
|
|
384
|
+
if (s.length === 3) return new E(s[0], s[1], s[2], null, null);
|
|
385
|
+
if (s.length === 5) return new E(s[0], s[1], s[2], s[3], s[4]);
|
|
386
|
+
throw new Error("Invalid arguments for createCRI");
|
|
387
|
+
}
|
|
388
|
+
class Q {
|
|
389
|
+
resolveArguments(e) {
|
|
390
|
+
if (this.containsJsonContent(e)) {
|
|
391
|
+
const t = e.getDataString();
|
|
392
|
+
return t ? JSON.parse(t) : [];
|
|
393
|
+
} else
|
|
394
|
+
throw new Error("Currently only JSON content is supported");
|
|
395
|
+
}
|
|
396
|
+
containsJsonContent(e) {
|
|
397
|
+
const t = e.getHeader(o.CONTENT_TYPE_HEADER);
|
|
398
|
+
return t != null && t !== "" && t === "application/json";
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
class O {
|
|
402
|
+
static createReplyEvent(e, t, r) {
|
|
403
|
+
if (!e)
|
|
404
|
+
throw new Error("incomingHeaders cannot be null");
|
|
405
|
+
const n = e.get(o.REPLY_TO_HEADER);
|
|
406
|
+
if (!n || n.trim() === "")
|
|
407
|
+
throw new Error("No reply-to header found, cannot create outgoing message");
|
|
408
|
+
const i = /* @__PURE__ */ new Map();
|
|
409
|
+
for (const [c, a] of e)
|
|
410
|
+
c.startsWith("__") && i.set(c, a);
|
|
411
|
+
if (t)
|
|
412
|
+
for (const [c, a] of t)
|
|
413
|
+
i.set(c, a);
|
|
414
|
+
return new g(n, i, r || void 0);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
class ee {
|
|
418
|
+
convert(e, t) {
|
|
419
|
+
return O.createReplyEvent(
|
|
420
|
+
e,
|
|
421
|
+
/* @__PURE__ */ new Map([[o.CONTENT_TYPE_HEADER, "application/json"]]),
|
|
422
|
+
new TextEncoder().encode(JSON.stringify(t))
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
function te(s) {
|
|
427
|
+
let e;
|
|
428
|
+
try {
|
|
429
|
+
e = require("debug")(s);
|
|
430
|
+
} catch {
|
|
431
|
+
e = (...r) => console.debug(`[${s}]`, ...r);
|
|
432
|
+
}
|
|
433
|
+
return {
|
|
434
|
+
trace: (...t) => e("TRACE", ...t),
|
|
435
|
+
debug: (...t) => e("DEBUG", ...t),
|
|
436
|
+
info: (...t) => e("INFO", ...t),
|
|
437
|
+
warn: (...t) => e("WARN", ...t),
|
|
438
|
+
error: (...t) => e("ERROR", ...t)
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
class re {
|
|
442
|
+
namespace;
|
|
443
|
+
name;
|
|
444
|
+
scope;
|
|
445
|
+
version;
|
|
446
|
+
_cri = null;
|
|
447
|
+
constructor(e, t) {
|
|
448
|
+
this.namespace = e, this.name = t;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Returns the qualified name for this {@link ServiceIdentifier}
|
|
452
|
+
* This is the namespace.name
|
|
453
|
+
* @return string containing the qualified name
|
|
454
|
+
*/
|
|
455
|
+
qualifiedName() {
|
|
456
|
+
return this.namespace + "." + this.name;
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* The {@link CRI} that represents this {@link ServiceIdentifier}
|
|
460
|
+
* @return the cri for this {@link ServiceIdentifier}
|
|
461
|
+
*/
|
|
462
|
+
cri() {
|
|
463
|
+
return this._cri == null && (this._cri = I(
|
|
464
|
+
o.SERVICE_DESTINATION_SCHEME,
|
|
465
|
+
// scheme
|
|
466
|
+
this.scope || null,
|
|
467
|
+
// scope
|
|
468
|
+
this.qualifiedName(),
|
|
469
|
+
// resourceName
|
|
470
|
+
null,
|
|
471
|
+
// path (null as per your example)
|
|
472
|
+
this.version || null
|
|
473
|
+
// version
|
|
474
|
+
)), this._cri;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
const P = /* @__PURE__ */ Symbol("scope"), x = /* @__PURE__ */ Symbol("version"), T = /* @__PURE__ */ Symbol("context");
|
|
478
|
+
function ke(s, e, t) {
|
|
479
|
+
Reflect.defineMetadata(P, e, s);
|
|
480
|
+
}
|
|
481
|
+
function Be(s) {
|
|
482
|
+
if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/.test(s))
|
|
483
|
+
throw new Error(`Invalid semantic version: ${s}. Must follow X.Y.Z[-optional] format.`);
|
|
484
|
+
return function(e) {
|
|
485
|
+
Reflect.defineMetadata(x, s, e);
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
function qe() {
|
|
489
|
+
return function(s, e, t) {
|
|
490
|
+
const r = Reflect.getMetadata(T, s, e) || [];
|
|
491
|
+
r.push(t), Reflect.defineMetadata(T, r, s, e);
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
function Fe(s, e) {
|
|
495
|
+
return function(t) {
|
|
496
|
+
const r = t, n = new re(s, e || t.name), i = Reflect.getMetadata(x, t);
|
|
497
|
+
i && (n.version = i);
|
|
498
|
+
const c = function(...a) {
|
|
499
|
+
const h = Reflect.construct(r, a), p = Reflect.getMetadata(P, t.prototype);
|
|
500
|
+
if (p) {
|
|
501
|
+
const u = h[p];
|
|
502
|
+
n.scope = typeof u == "function" ? u.call(h) : u;
|
|
503
|
+
}
|
|
504
|
+
return D.serviceRegistry.register(n, h), h;
|
|
505
|
+
};
|
|
506
|
+
return c.prototype = r.prototype, c;
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
class se {
|
|
510
|
+
log;
|
|
511
|
+
active = !1;
|
|
512
|
+
eventBusService;
|
|
513
|
+
interceptorProvider;
|
|
514
|
+
argumentResolver;
|
|
515
|
+
returnValueConverter;
|
|
516
|
+
serviceIdentifier;
|
|
517
|
+
serviceInstance;
|
|
518
|
+
methodSubscription = null;
|
|
519
|
+
methodMap;
|
|
520
|
+
constructor(e, t, r, n, i = {}) {
|
|
521
|
+
if (!e) throw new Error("ServiceIdentifier must not be null");
|
|
522
|
+
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
|
+
}
|
|
527
|
+
isActive() {
|
|
528
|
+
return this.active;
|
|
529
|
+
}
|
|
530
|
+
start() {
|
|
531
|
+
if (this.active)
|
|
532
|
+
throw new Error("Service already started");
|
|
533
|
+
this.active = !0;
|
|
534
|
+
const e = this.serviceIdentifier.cri().baseResource();
|
|
535
|
+
this.methodSubscription = this.eventBusService.observe(e).subscribe({
|
|
536
|
+
next: async (t) => {
|
|
537
|
+
await this.processEvent(t);
|
|
538
|
+
},
|
|
539
|
+
error: (t) => {
|
|
540
|
+
this.log.error("Event listener error", t), this.active = !1;
|
|
541
|
+
},
|
|
542
|
+
complete: () => {
|
|
543
|
+
this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive."), this.active = !1;
|
|
544
|
+
}
|
|
545
|
+
}), this.log.info(`ServiceInvocationSupervisor started for ${e}`);
|
|
546
|
+
}
|
|
547
|
+
stop() {
|
|
548
|
+
if (!this.active)
|
|
549
|
+
throw new Error("Service already stopped");
|
|
550
|
+
this.active = !1, this.methodSubscription && (this.methodSubscription.unsubscribe(), this.methodSubscription = null), this.log.info("ServiceInvocationSupervisor stopped");
|
|
551
|
+
}
|
|
552
|
+
buildMethodMap(e) {
|
|
553
|
+
const t = {};
|
|
554
|
+
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));
|
|
557
|
+
}
|
|
558
|
+
return t;
|
|
559
|
+
}
|
|
560
|
+
async processEvent(e) {
|
|
561
|
+
const t = e.hasHeader(o.CONTROL_HEADER);
|
|
562
|
+
this.log.trace(`Service ${t ? "Control" : "Invocation"} requested for ${e.cri}`);
|
|
563
|
+
try {
|
|
564
|
+
t ? this.processControlPlaneRequest(e) : this.validateReplyTo(e) ? await this.processInvocationRequest(e) : this.log.error(`ReplyTo header missing or invalid. Ignoring event: ${JSON.stringify(e)}`);
|
|
565
|
+
} catch (r) {
|
|
566
|
+
this.log.debug(`Exception processing service request: ${JSON.stringify(e)}`, r), this.handleException(e, r);
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
processControlPlaneRequest(e) {
|
|
570
|
+
const t = e.getHeader(o.CORRELATION_ID_HEADER);
|
|
571
|
+
if (!t)
|
|
572
|
+
throw new Error("Streaming control plane messages require a CORRELATION_ID_HEADER");
|
|
573
|
+
this.log.trace(`Processing control event for correlationId: ${t}`);
|
|
574
|
+
}
|
|
575
|
+
async processInvocationRequest(e) {
|
|
576
|
+
const t = I(e.cri).path();
|
|
577
|
+
if (!t)
|
|
578
|
+
throw new Error("The methodId must not be blank");
|
|
579
|
+
const r = this.methodMap[t];
|
|
580
|
+
if (!r)
|
|
581
|
+
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) || [];
|
|
583
|
+
let a = {};
|
|
584
|
+
const h = this.interceptorProvider();
|
|
585
|
+
if (h)
|
|
586
|
+
try {
|
|
587
|
+
a = await h.intercept(e, a);
|
|
588
|
+
} catch (l) {
|
|
589
|
+
this.log.error(`Interceptor failed to create context for event: ${JSON.stringify(e)}`, l), this.handleException(e, new Error("Internal server error"));
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
for (const l of c)
|
|
593
|
+
i[l] = a;
|
|
594
|
+
const p = r.length;
|
|
595
|
+
if (i.length !== p)
|
|
596
|
+
throw new Error(`Argument count mismatch for method ${t}: expected ${p}, got ${i.length}`);
|
|
597
|
+
let u;
|
|
598
|
+
try {
|
|
599
|
+
u = r(...i), u instanceof Promise ? u.then(
|
|
600
|
+
(l) => this.processMethodInvocationResult(e, l),
|
|
601
|
+
(l) => this.handleException(e, l)
|
|
602
|
+
) : this.processMethodInvocationResult(e, u);
|
|
603
|
+
} catch (l) {
|
|
604
|
+
this.handleException(e, l);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
processMethodInvocationResult(e, t) {
|
|
608
|
+
const r = this.returnValueConverter.convert(e.headers, t);
|
|
609
|
+
this.eventBusService.send(r);
|
|
610
|
+
}
|
|
611
|
+
handleException(e, t) {
|
|
612
|
+
const r = O.createReplyEvent(
|
|
613
|
+
e.headers,
|
|
614
|
+
/* @__PURE__ */ new Map([
|
|
615
|
+
[o.ERROR_HEADER, t.message || "Unknown error"],
|
|
616
|
+
[o.CONTENT_TYPE_HEADER, "application/json"]
|
|
617
|
+
]),
|
|
618
|
+
new TextEncoder().encode(JSON.stringify({ message: t.message }))
|
|
619
|
+
);
|
|
620
|
+
this.eventBusService.send(r);
|
|
621
|
+
}
|
|
622
|
+
validateReplyTo(e) {
|
|
623
|
+
const t = e.getHeader(o.REPLY_TO_HEADER);
|
|
624
|
+
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
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const ne = "2.14.6", ie = {
|
|
628
|
+
version: ne
|
|
629
|
+
};
|
|
630
|
+
class oe {
|
|
631
|
+
create(e, t) {
|
|
632
|
+
const r = new g(e);
|
|
633
|
+
return r.setHeader(o.CONTENT_TYPE_HEADER, o.CONTENT_JSON), t != null && r.setDataString(JSON.stringify(t)), r;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
class $e {
|
|
637
|
+
create(e, t) {
|
|
638
|
+
const r = new g(e);
|
|
639
|
+
if (r.setHeader(o.CONTENT_TYPE_HEADER, o.CONTENT_TEXT), t != null) {
|
|
640
|
+
let n = "", i = 0;
|
|
641
|
+
for (const c of t)
|
|
642
|
+
i > 0 && (n = n + `
|
|
643
|
+
`), n = n + c, i++;
|
|
644
|
+
n.length > 0 && r.setDataString(n);
|
|
645
|
+
}
|
|
646
|
+
return r;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
class ce {
|
|
650
|
+
eventBus;
|
|
651
|
+
supervisors = /* @__PURE__ */ new Map();
|
|
652
|
+
contextInterceptor = null;
|
|
653
|
+
constructor(e) {
|
|
654
|
+
this.eventBus = e;
|
|
655
|
+
}
|
|
656
|
+
serviceProxy(e) {
|
|
657
|
+
return new ue(e, this.eventBus);
|
|
658
|
+
}
|
|
659
|
+
register(e, t) {
|
|
660
|
+
const r = e.cri().raw();
|
|
661
|
+
if (!this.supervisors.has(r)) {
|
|
662
|
+
const n = new se(
|
|
663
|
+
e,
|
|
664
|
+
t,
|
|
665
|
+
this.eventBus,
|
|
666
|
+
() => this.contextInterceptor
|
|
667
|
+
);
|
|
668
|
+
this.supervisors.set(r, n), n.start();
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
unRegister(e) {
|
|
672
|
+
const t = e.cri().raw(), r = this.supervisors.get(t);
|
|
673
|
+
r && (r.stop(), this.supervisors.delete(t));
|
|
674
|
+
}
|
|
675
|
+
registerContextInterceptor(e) {
|
|
676
|
+
this.contextInterceptor = e;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
const ae = new oe();
|
|
680
|
+
class ue {
|
|
681
|
+
serviceIdentifier;
|
|
682
|
+
eventBus;
|
|
683
|
+
tracer;
|
|
684
|
+
constructor(e, t) {
|
|
685
|
+
if (typeof e > "u" || e.length === 0)
|
|
686
|
+
throw new Error("The serviceIdentifier provided must contain a value");
|
|
687
|
+
this.serviceIdentifier = e, this.eventBus = t, this.tracer = b.trace.getTracer(
|
|
688
|
+
"continuum.client",
|
|
689
|
+
ie.version
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
invoke(e, t, r, n) {
|
|
693
|
+
return this.tracer.startActiveSpan(
|
|
694
|
+
`${this.serviceIdentifier}/${e}`,
|
|
695
|
+
{
|
|
696
|
+
kind: U.CLIENT
|
|
697
|
+
},
|
|
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),
|
|
700
|
+
async (c) => {
|
|
701
|
+
throw i.recordException(c), i.setStatus({ code: Y.ERROR }), i.end(), c;
|
|
702
|
+
}
|
|
703
|
+
))
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
invokeStream(e, t, r, n) {
|
|
707
|
+
return this.__invokeStream(!0, e, t, r, n);
|
|
708
|
+
}
|
|
709
|
+
__invokeStream(e, t, r, n, i) {
|
|
710
|
+
const c = o.SERVICE_DESTINATION_PREFIX + (n != null ? n + "@" : "") + this.serviceIdentifier + "/" + t;
|
|
711
|
+
let a = ae;
|
|
712
|
+
i ? a = i : f.getEventFactory() && (a = f.getEventFactory());
|
|
713
|
+
let h = this.eventBus;
|
|
714
|
+
f.getContinuumInstance() && (h = f.getContinuumInstance().eventBus);
|
|
715
|
+
const p = b.trace.getActiveSpan();
|
|
716
|
+
p && (p.setAttribute(G, h.serverInfo?.host || "unknown"), p.setAttribute(K, h.serverInfo?.port || "unknown"));
|
|
717
|
+
let u = a.create(c, r);
|
|
718
|
+
return h.requestStream(u, e).pipe(R((l) => {
|
|
719
|
+
const d = l.getHeader(o.CONTENT_TYPE_HEADER);
|
|
720
|
+
if (d !== void 0) {
|
|
721
|
+
if (d === "application/json")
|
|
722
|
+
return JSON.parse(l.getDataString());
|
|
723
|
+
if (d === "text/plain")
|
|
724
|
+
return l.getDataString();
|
|
725
|
+
throw new Error("Content Type " + d + " is not supported");
|
|
726
|
+
} else
|
|
727
|
+
return null;
|
|
728
|
+
}));
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
class _ {
|
|
732
|
+
pageable;
|
|
733
|
+
currentPage;
|
|
734
|
+
firstPage = !0;
|
|
735
|
+
constructor(e, t) {
|
|
736
|
+
this.pageable = e, this.currentPage = t;
|
|
737
|
+
}
|
|
738
|
+
async next() {
|
|
739
|
+
let e;
|
|
740
|
+
if (this.firstPage)
|
|
741
|
+
this.firstPage = !1, e = { done: !this.hasContent(), value: this };
|
|
742
|
+
else if (this.isOffsetPageable()) {
|
|
743
|
+
const t = this.pageable;
|
|
744
|
+
t.pageNumber++;
|
|
745
|
+
const r = Math.ceil(this.totalElements / this.pageable.pageSize);
|
|
746
|
+
t.pageNumber < r ? (this.currentPage = await this.findNext(this.pageable), e = { done: !1, value: this }) : e = { done: !0, value: this };
|
|
747
|
+
} else {
|
|
748
|
+
const t = this.pageable;
|
|
749
|
+
t.cursor = this.currentPage.cursor || null, this.currentPage = await this.findNext(this.pageable), e = { done: this.isLastPage(), value: this };
|
|
750
|
+
}
|
|
751
|
+
return e;
|
|
752
|
+
}
|
|
753
|
+
[Symbol.asyncIterator]() {
|
|
754
|
+
return this;
|
|
755
|
+
}
|
|
756
|
+
hasContent() {
|
|
757
|
+
return this.currentPage.content !== null && this.currentPage.content !== void 0 && this.currentPage.content.length > 0;
|
|
758
|
+
}
|
|
759
|
+
isLastPage() {
|
|
760
|
+
let e;
|
|
761
|
+
return this.isOffsetPageable() ? e = Math.ceil(this.totalElements / this.pageable.pageSize) === this.pageable.pageNumber + 1 : e = !this.firstPage && this.currentPage.cursor === null, e;
|
|
762
|
+
}
|
|
763
|
+
isOffsetPageable() {
|
|
764
|
+
return this.pageable.pageNumber !== void 0;
|
|
765
|
+
}
|
|
766
|
+
get totalElements() {
|
|
767
|
+
return this.currentPage.totalElements;
|
|
768
|
+
}
|
|
769
|
+
get cursor() {
|
|
770
|
+
return this.currentPage.cursor;
|
|
771
|
+
}
|
|
772
|
+
get content() {
|
|
773
|
+
return this.currentPage.content;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
class le extends _ {
|
|
777
|
+
crudServiceProxy;
|
|
778
|
+
constructor(e, t, r) {
|
|
779
|
+
super(e, t), this.crudServiceProxy = r;
|
|
780
|
+
}
|
|
781
|
+
findNext(e) {
|
|
782
|
+
return this.crudServiceProxy.findAllSinglePage(e);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
class he extends _ {
|
|
786
|
+
searchText;
|
|
787
|
+
crudServiceProxy;
|
|
788
|
+
constructor(e, t, r, n) {
|
|
789
|
+
super(e, t), this.searchText = r, this.crudServiceProxy = n;
|
|
790
|
+
}
|
|
791
|
+
findNext(e) {
|
|
792
|
+
return this.crudServiceProxy.searchSinglePage(this.searchText, e);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
class pe {
|
|
796
|
+
serviceProxy;
|
|
797
|
+
constructor(e) {
|
|
798
|
+
this.serviceProxy = e;
|
|
799
|
+
}
|
|
800
|
+
count() {
|
|
801
|
+
return this.serviceProxy.invoke("count");
|
|
802
|
+
}
|
|
803
|
+
create(e) {
|
|
804
|
+
return this.serviceProxy.invoke("create", [e]);
|
|
805
|
+
}
|
|
806
|
+
deleteById(e) {
|
|
807
|
+
return this.serviceProxy.invoke("deleteById", [e]);
|
|
808
|
+
}
|
|
809
|
+
async findAll(e) {
|
|
810
|
+
const t = await this.findAllSinglePage(e);
|
|
811
|
+
return new le(e, t, this);
|
|
812
|
+
}
|
|
813
|
+
findAllSinglePage(e) {
|
|
814
|
+
return this.serviceProxy.invoke("findAll", [e]);
|
|
815
|
+
}
|
|
816
|
+
findById(e) {
|
|
817
|
+
return this.serviceProxy.invoke("findById", [e]);
|
|
818
|
+
}
|
|
819
|
+
save(e) {
|
|
820
|
+
return this.serviceProxy.invoke("save", [e]);
|
|
821
|
+
}
|
|
822
|
+
findByIdNotIn(e, t) {
|
|
823
|
+
return this.serviceProxy.invoke("findByIdNotIn", [e, t]);
|
|
824
|
+
}
|
|
825
|
+
async search(e, t) {
|
|
826
|
+
const r = await this.searchSinglePage(e, t);
|
|
827
|
+
return new he(t, r, e, this);
|
|
828
|
+
}
|
|
829
|
+
searchSinglePage(e, t) {
|
|
830
|
+
return this.serviceProxy.invoke("search", [e, t]);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
class de {
|
|
834
|
+
serviceRegistry;
|
|
835
|
+
constructor(e) {
|
|
836
|
+
this.serviceRegistry = e;
|
|
837
|
+
}
|
|
838
|
+
crudServiceProxy(e) {
|
|
839
|
+
if (typeof e > "u" || e.length === 0)
|
|
840
|
+
throw new Error("The serviceIdentifier provided must contain a value");
|
|
841
|
+
return new pe(this.serviceRegistry.serviceProxy(e));
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
class Ee {
|
|
845
|
+
continuumOverride = [];
|
|
846
|
+
getContinuumInstance() {
|
|
847
|
+
return this.continuumOverride[this.continuumOverride.length - 1]?.instance;
|
|
848
|
+
}
|
|
849
|
+
getEventFactory() {
|
|
850
|
+
return this.continuumOverride[this.continuumOverride.length - 1]?.eventFactory;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Sets the current {@link ContinuumContext} instance to use for all {@link IServiceProxy} instances invoked with {@link ContinuumContext.execute}
|
|
854
|
+
* @param continuumContext
|
|
855
|
+
*/
|
|
856
|
+
push(e) {
|
|
857
|
+
this.continuumOverride.push(e);
|
|
858
|
+
}
|
|
859
|
+
/**
|
|
860
|
+
* Removes the current {@link ContinuumContext} from the stack
|
|
861
|
+
*/
|
|
862
|
+
pop() {
|
|
863
|
+
this.continuumOverride.pop();
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
const f = new Ee();
|
|
867
|
+
class fe {
|
|
868
|
+
/**
|
|
869
|
+
* The {@link IEventBus} that is used to communicate with the Continuum server
|
|
870
|
+
*/
|
|
871
|
+
eventBus;
|
|
872
|
+
/**
|
|
873
|
+
* The {@link ServiceRegistry} that is used to manage the services that are available
|
|
874
|
+
*/
|
|
875
|
+
serviceRegistry;
|
|
876
|
+
/**
|
|
877
|
+
* The {@link CrudServiceProxyFactory} that is used to create {@link ICrudServiceProxy} instances
|
|
878
|
+
*/
|
|
879
|
+
crudServiceProxyFactory;
|
|
880
|
+
constructor() {
|
|
881
|
+
this.eventBus = new Z(), this.serviceRegistry = new ce(this.eventBus), this.crudServiceProxyFactory = new de(this.serviceRegistry);
|
|
882
|
+
}
|
|
883
|
+
/**
|
|
884
|
+
* Requests a connection to the given Stomp url
|
|
885
|
+
* @param connectionInfo provides the information needed to connect to the continuum server
|
|
886
|
+
* @return Promise containing the result of the initial connection attempt
|
|
887
|
+
*/
|
|
888
|
+
connect(e) {
|
|
889
|
+
return this.eventBus.connect(e);
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Disconnects the client from the server
|
|
893
|
+
* This will clear any subscriptions and close the connection
|
|
894
|
+
*/
|
|
895
|
+
disconnect(e) {
|
|
896
|
+
return this.eventBus.disconnect(e);
|
|
897
|
+
}
|
|
898
|
+
/**
|
|
899
|
+
* Creates a new service proxy that can be used to access the desired service.
|
|
900
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
901
|
+
* @return the {@link IServiceProxy} that can be used to access the service
|
|
902
|
+
*/
|
|
903
|
+
serviceProxy(e) {
|
|
904
|
+
return this.serviceRegistry.serviceProxy(e);
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Returns a {@link ICrudServiceProxy} for the given service identifier
|
|
908
|
+
* @param serviceIdentifier the identifier of the service to be accessed
|
|
909
|
+
*/
|
|
910
|
+
crudServiceProxy(e) {
|
|
911
|
+
return this.crudServiceProxyFactory.crudServiceProxy(e);
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Allows for the execution of a function that requires a connection to the Continuum server
|
|
915
|
+
* When the function is executed any calls using an {@link IServiceProxy} will be executed using the connection defined by this {@link ContinuumSingleton}
|
|
916
|
+
* @param toExecute the function to execute
|
|
917
|
+
* @param eventFactory an optional {@link IEventFactory} to use for the duration of the execution
|
|
918
|
+
* @return the result of the function that was executed
|
|
919
|
+
* @deprecated we have decided to deprecate this method as it is not thread safe and can cause issues when used in async operations
|
|
920
|
+
* NOTE: this method is experimental and does not work well across multiple threads / async operations
|
|
921
|
+
*/
|
|
922
|
+
async execute(e, t) {
|
|
923
|
+
const r = f;
|
|
924
|
+
r.push({ instance: this, eventFactory: t });
|
|
925
|
+
let n;
|
|
926
|
+
try {
|
|
927
|
+
n = await e();
|
|
928
|
+
} finally {
|
|
929
|
+
r.pop();
|
|
930
|
+
}
|
|
931
|
+
return n;
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
const D = new fe();
|
|
935
|
+
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 {
|
|
937
|
+
configuredLevel;
|
|
938
|
+
}
|
|
939
|
+
class me extends y {
|
|
940
|
+
members = [];
|
|
941
|
+
}
|
|
942
|
+
class ve extends y {
|
|
943
|
+
effectiveLevel;
|
|
944
|
+
}
|
|
945
|
+
class Ue {
|
|
946
|
+
levels = [];
|
|
947
|
+
loggerLevels = /* @__PURE__ */ new Map();
|
|
948
|
+
groups = /* @__PURE__ */ new Map();
|
|
949
|
+
}
|
|
950
|
+
class Se {
|
|
951
|
+
serviceProxy;
|
|
952
|
+
constructor() {
|
|
953
|
+
this.serviceProxy = D.serviceProxy("org.kinotic.continuum.api.log.LogManager");
|
|
954
|
+
}
|
|
955
|
+
loggers(e) {
|
|
956
|
+
return this.serviceProxy.invoke("loggers", null, e);
|
|
957
|
+
}
|
|
958
|
+
async loggerLevels(e, t) {
|
|
959
|
+
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;
|
|
962
|
+
}
|
|
963
|
+
configureLogLevel(e, t, r) {
|
|
964
|
+
return this.serviceProxy.invoke("configureLogLevel", [t, r], e);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
const Ye = new Se();
|
|
968
|
+
class H extends m {
|
|
969
|
+
constructor(e) {
|
|
970
|
+
super(e), Object.setPrototypeOf(this, H.prototype);
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
class L extends m {
|
|
974
|
+
constructor(e) {
|
|
975
|
+
super(e), Object.setPrototypeOf(this, L.prototype);
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
class Ve {
|
|
979
|
+
sessionId;
|
|
980
|
+
replyToId;
|
|
981
|
+
participant;
|
|
982
|
+
}
|
|
983
|
+
class je {
|
|
984
|
+
id;
|
|
985
|
+
tenantId;
|
|
986
|
+
metadata;
|
|
987
|
+
roles;
|
|
988
|
+
constructor(e, t, r, n) {
|
|
989
|
+
this.id = e, this.tenantId = t, this.metadata = r || /* @__PURE__ */ new Map(), this.roles = n || [];
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
class Je {
|
|
993
|
+
static PARTICIPANT_TYPE_METADATA_KEY = "type";
|
|
994
|
+
static PARTICIPANT_TYPE_DEVICE = "device";
|
|
995
|
+
static PARTICIPANT_TYPE_CLI = "cli";
|
|
996
|
+
static PARTICIPANT_TYPE_USER = "user";
|
|
997
|
+
static PARTICIPANT_TYPE_NODE = "node";
|
|
998
|
+
static CLI_PARTICIPANT_ID = "-42-Continuum-CLI-42-";
|
|
999
|
+
}
|
|
1000
|
+
var Re = /* @__PURE__ */ ((s) => (s.EXISTING = "EXISTING", s.UPDATE = "UPDATE", s.REMOVE = "REMOVE", s))(Re || {});
|
|
1001
|
+
class Xe {
|
|
1002
|
+
streamOperation;
|
|
1003
|
+
id;
|
|
1004
|
+
value;
|
|
1005
|
+
constructor(e, t, r) {
|
|
1006
|
+
this.streamOperation = e, this.id = t, this.value = r;
|
|
1007
|
+
}
|
|
1008
|
+
isSet() {
|
|
1009
|
+
return this.value !== null && this.value !== void 0;
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
class We extends _ {
|
|
1013
|
+
pageFunction;
|
|
1014
|
+
constructor(e, t, r) {
|
|
1015
|
+
super(e, t), this.pageFunction = r;
|
|
1016
|
+
}
|
|
1017
|
+
findNext(e) {
|
|
1018
|
+
return this.pageFunction(e);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
class Ge {
|
|
1022
|
+
static instanceOfEditableDataSource(e) {
|
|
1023
|
+
return "create" in e;
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1026
|
+
class M {
|
|
1027
|
+
/**
|
|
1028
|
+
* Returns the sorting parameters (optional).
|
|
1029
|
+
*/
|
|
1030
|
+
sort = null;
|
|
1031
|
+
/**
|
|
1032
|
+
* Returns the number of items to be returned.
|
|
1033
|
+
*/
|
|
1034
|
+
pageSize = 25;
|
|
1035
|
+
/**
|
|
1036
|
+
* Creates a {@link Pageable} that uses Offset based pagination.
|
|
1037
|
+
* @param pageNumber zero based page index.
|
|
1038
|
+
* @param pageSize the size of the page to be returned.
|
|
1039
|
+
* @param sort the sorting parameters (optional).
|
|
1040
|
+
*/
|
|
1041
|
+
static create(e, t, r) {
|
|
1042
|
+
return new Te(e, t, r);
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Creates a {@link Pageable} that uses Cursor based pagination.
|
|
1046
|
+
* @param cursor the cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
1047
|
+
* @param pageSize the size of the page to be returned.
|
|
1048
|
+
* @param sort the sorting parameters (optional).
|
|
1049
|
+
*/
|
|
1050
|
+
static createWithCursor(e, t, r) {
|
|
1051
|
+
return new _e(e, t, r);
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
class Te extends M {
|
|
1055
|
+
/**
|
|
1056
|
+
* Returns the page to be returned.
|
|
1057
|
+
*/
|
|
1058
|
+
pageNumber = 0;
|
|
1059
|
+
/**
|
|
1060
|
+
* Creates a {@link Pageable} that uses Offset based pagination.
|
|
1061
|
+
* @param pageNumber zero based page index.
|
|
1062
|
+
* @param pageSize the size of the page to be returned.
|
|
1063
|
+
* @param sort the sorting parameters (optional).
|
|
1064
|
+
*/
|
|
1065
|
+
constructor(e, t, r) {
|
|
1066
|
+
super(), this.pageNumber = e, this.pageSize = t, this.sort = r;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
class _e extends M {
|
|
1070
|
+
/**
|
|
1071
|
+
* The cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
1072
|
+
*/
|
|
1073
|
+
cursor;
|
|
1074
|
+
/**
|
|
1075
|
+
* Creates a {@link Pageable} that uses Cursor based pagination.
|
|
1076
|
+
* @param cursor the cursor to be used for subsequent retrieval of data, or null if this is the first page.
|
|
1077
|
+
* @param pageSize the size of the page to be returned.
|
|
1078
|
+
* @param sort the sorting parameters (optional).
|
|
1079
|
+
*/
|
|
1080
|
+
constructor(e, t, r) {
|
|
1081
|
+
super(), this.cursor = e, this.pageSize = t, this.sort = r;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
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 || {});
|
|
1085
|
+
class Ke {
|
|
1086
|
+
property;
|
|
1087
|
+
direction = "ASC";
|
|
1088
|
+
nullHandling = "NATIVE";
|
|
1089
|
+
constructor(e, t) {
|
|
1090
|
+
this.property = e, t !== null && (this.direction = t);
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Returns whether sorting for this property shall be ascending.
|
|
1094
|
+
*/
|
|
1095
|
+
isAscending() {
|
|
1096
|
+
return this.direction === "ASC";
|
|
1097
|
+
}
|
|
1098
|
+
/**
|
|
1099
|
+
* Returns whether sorting for this property shall be descending.
|
|
1100
|
+
*/
|
|
1101
|
+
isDescending() {
|
|
1102
|
+
return this.direction === "DESC";
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
class ze {
|
|
1106
|
+
orders = [];
|
|
1107
|
+
}
|
|
1108
|
+
export {
|
|
1109
|
+
_ as AbstractIterablePage,
|
|
1110
|
+
H as AuthenticationError,
|
|
1111
|
+
L as AuthorizationError,
|
|
1112
|
+
T as CONTEXT_METADATA_KEY,
|
|
1113
|
+
Le as ConnectHeaders,
|
|
1114
|
+
Ve as ConnectedInfo,
|
|
1115
|
+
Me as ConnectionInfo,
|
|
1116
|
+
qe as Context,
|
|
1117
|
+
D as Continuum,
|
|
1118
|
+
f as ContinuumContextStack,
|
|
1119
|
+
m as ContinuumError,
|
|
1120
|
+
fe as ContinuumSingleton,
|
|
1121
|
+
pe as CrudServiceProxy,
|
|
1122
|
+
de as CrudServiceProxyFactory,
|
|
1123
|
+
_e as CursorPageable,
|
|
1124
|
+
Ge as DataSourceUtils,
|
|
1125
|
+
E as DefaultCRI,
|
|
1126
|
+
ye as Direction,
|
|
1127
|
+
g as Event,
|
|
1128
|
+
Z as EventBus,
|
|
1129
|
+
o as EventConstants,
|
|
1130
|
+
We as FunctionalIterablePage,
|
|
1131
|
+
me as GroupLoggerLevelsDescriptor,
|
|
1132
|
+
oe as JsonEventFactory,
|
|
1133
|
+
ge as LogLevel,
|
|
1134
|
+
Se as LogManager,
|
|
1135
|
+
y as LoggerLevelsDescriptor,
|
|
1136
|
+
Ue as LoggersDescriptor,
|
|
1137
|
+
be as NullHandling,
|
|
1138
|
+
Te as OffsetPageable,
|
|
1139
|
+
Ke as Order,
|
|
1140
|
+
M as Pageable,
|
|
1141
|
+
je as Participant,
|
|
1142
|
+
Je as ParticipantConstants,
|
|
1143
|
+
Fe as Publish,
|
|
1144
|
+
ke as Scope,
|
|
1145
|
+
w as ServerInfo,
|
|
1146
|
+
ce as ServiceRegistry,
|
|
1147
|
+
ve as SingleLoggerLevelsDescriptor,
|
|
1148
|
+
ze as Sort,
|
|
1149
|
+
Xe as StreamData,
|
|
1150
|
+
Re as StreamOperation,
|
|
1151
|
+
$e as TextEventFactory,
|
|
1152
|
+
Be as Version,
|
|
1153
|
+
I as createCRI,
|
|
1154
|
+
Ye as logManager
|
|
1155
|
+
};
|
|
1156
|
+
//# sourceMappingURL=continuum.js.map
|