@kinotic-ai/core 1.0.0-beta.0

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/index.js ADDED
@@ -0,0 +1,2565 @@
1
+ import { createRequire } from "node:module";
2
+ var __create = Object.create;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
33
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
34
+
35
+ // node_modules/.bun/reflect-metadata@0.2.2/node_modules/reflect-metadata/Reflect.js
36
+ var require_Reflect = __commonJS(() => {
37
+ /*! *****************************************************************************
38
+ Copyright (C) Microsoft. All rights reserved.
39
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
40
+ this file except in compliance with the License. You may obtain a copy of the
41
+ License at http://www.apache.org/licenses/LICENSE-2.0
42
+
43
+ THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
44
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
45
+ WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
46
+ MERCHANTABLITY OR NON-INFRINGEMENT.
47
+
48
+ See the Apache Version 2.0 License for specific language governing permissions
49
+ and limitations under the License.
50
+ ***************************************************************************** */
51
+ var Reflect2;
52
+ (function(Reflect3) {
53
+ (function(factory) {
54
+ var root = typeof globalThis === "object" ? globalThis : typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : sloppyModeThis();
55
+ var exporter = makeExporter(Reflect3);
56
+ if (typeof root.Reflect !== "undefined") {
57
+ exporter = makeExporter(root.Reflect, exporter);
58
+ }
59
+ factory(exporter, root);
60
+ if (typeof root.Reflect === "undefined") {
61
+ root.Reflect = Reflect3;
62
+ }
63
+ function makeExporter(target, previous) {
64
+ return function(key, value) {
65
+ Object.defineProperty(target, key, { configurable: true, writable: true, value });
66
+ if (previous)
67
+ previous(key, value);
68
+ };
69
+ }
70
+ function functionThis() {
71
+ try {
72
+ return Function("return this;")();
73
+ } catch (_) {}
74
+ }
75
+ function indirectEvalThis() {
76
+ try {
77
+ return (undefined, eval)("(function() { return this; })()");
78
+ } catch (_) {}
79
+ }
80
+ function sloppyModeThis() {
81
+ return functionThis() || indirectEvalThis();
82
+ }
83
+ })(function(exporter, root) {
84
+ var hasOwn = Object.prototype.hasOwnProperty;
85
+ var supportsSymbol = typeof Symbol === "function";
86
+ var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== "undefined" ? Symbol.toPrimitive : "@@toPrimitive";
87
+ var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== "undefined" ? Symbol.iterator : "@@iterator";
88
+ var supportsCreate = typeof Object.create === "function";
89
+ var supportsProto = { __proto__: [] } instanceof Array;
90
+ var downLevel = !supportsCreate && !supportsProto;
91
+ var HashMap = {
92
+ create: supportsCreate ? function() {
93
+ return MakeDictionary(Object.create(null));
94
+ } : supportsProto ? function() {
95
+ return MakeDictionary({ __proto__: null });
96
+ } : function() {
97
+ return MakeDictionary({});
98
+ },
99
+ has: downLevel ? function(map2, key) {
100
+ return hasOwn.call(map2, key);
101
+ } : function(map2, key) {
102
+ return key in map2;
103
+ },
104
+ get: downLevel ? function(map2, key) {
105
+ return hasOwn.call(map2, key) ? map2[key] : undefined;
106
+ } : function(map2, key) {
107
+ return map2[key];
108
+ }
109
+ };
110
+ var functionPrototype = Object.getPrototypeOf(Function);
111
+ var _Map = typeof Map === "function" && typeof Map.prototype.entries === "function" ? Map : CreateMapPolyfill();
112
+ var _Set = typeof Set === "function" && typeof Set.prototype.entries === "function" ? Set : CreateSetPolyfill();
113
+ var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill();
114
+ var registrySymbol = supportsSymbol ? Symbol.for("@reflect-metadata:registry") : undefined;
115
+ var metadataRegistry = GetOrCreateMetadataRegistry();
116
+ var metadataProvider = CreateMetadataProvider(metadataRegistry);
117
+ function decorate(decorators, target, propertyKey, attributes) {
118
+ if (!IsUndefined(propertyKey)) {
119
+ if (!IsArray(decorators))
120
+ throw new TypeError;
121
+ if (!IsObject(target))
122
+ throw new TypeError;
123
+ if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))
124
+ throw new TypeError;
125
+ if (IsNull(attributes))
126
+ attributes = undefined;
127
+ propertyKey = ToPropertyKey(propertyKey);
128
+ return DecorateProperty(decorators, target, propertyKey, attributes);
129
+ } else {
130
+ if (!IsArray(decorators))
131
+ throw new TypeError;
132
+ if (!IsConstructor(target))
133
+ throw new TypeError;
134
+ return DecorateConstructor(decorators, target);
135
+ }
136
+ }
137
+ exporter("decorate", decorate);
138
+ function metadata(metadataKey, metadataValue) {
139
+ function decorator(target, propertyKey) {
140
+ if (!IsObject(target))
141
+ throw new TypeError;
142
+ if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))
143
+ throw new TypeError;
144
+ OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
145
+ }
146
+ return decorator;
147
+ }
148
+ exporter("metadata", metadata);
149
+ function defineMetadata(metadataKey, metadataValue, target, propertyKey) {
150
+ if (!IsObject(target))
151
+ throw new TypeError;
152
+ if (!IsUndefined(propertyKey))
153
+ propertyKey = ToPropertyKey(propertyKey);
154
+ return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);
155
+ }
156
+ exporter("defineMetadata", defineMetadata);
157
+ function hasMetadata(metadataKey, target, propertyKey) {
158
+ if (!IsObject(target))
159
+ throw new TypeError;
160
+ if (!IsUndefined(propertyKey))
161
+ propertyKey = ToPropertyKey(propertyKey);
162
+ return OrdinaryHasMetadata(metadataKey, target, propertyKey);
163
+ }
164
+ exporter("hasMetadata", hasMetadata);
165
+ function hasOwnMetadata(metadataKey, target, propertyKey) {
166
+ if (!IsObject(target))
167
+ throw new TypeError;
168
+ if (!IsUndefined(propertyKey))
169
+ propertyKey = ToPropertyKey(propertyKey);
170
+ return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);
171
+ }
172
+ exporter("hasOwnMetadata", hasOwnMetadata);
173
+ function getMetadata(metadataKey, target, propertyKey) {
174
+ if (!IsObject(target))
175
+ throw new TypeError;
176
+ if (!IsUndefined(propertyKey))
177
+ propertyKey = ToPropertyKey(propertyKey);
178
+ return OrdinaryGetMetadata(metadataKey, target, propertyKey);
179
+ }
180
+ exporter("getMetadata", getMetadata);
181
+ function getOwnMetadata(metadataKey, target, propertyKey) {
182
+ if (!IsObject(target))
183
+ throw new TypeError;
184
+ if (!IsUndefined(propertyKey))
185
+ propertyKey = ToPropertyKey(propertyKey);
186
+ return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);
187
+ }
188
+ exporter("getOwnMetadata", getOwnMetadata);
189
+ function getMetadataKeys(target, propertyKey) {
190
+ if (!IsObject(target))
191
+ throw new TypeError;
192
+ if (!IsUndefined(propertyKey))
193
+ propertyKey = ToPropertyKey(propertyKey);
194
+ return OrdinaryMetadataKeys(target, propertyKey);
195
+ }
196
+ exporter("getMetadataKeys", getMetadataKeys);
197
+ function getOwnMetadataKeys(target, propertyKey) {
198
+ if (!IsObject(target))
199
+ throw new TypeError;
200
+ if (!IsUndefined(propertyKey))
201
+ propertyKey = ToPropertyKey(propertyKey);
202
+ return OrdinaryOwnMetadataKeys(target, propertyKey);
203
+ }
204
+ exporter("getOwnMetadataKeys", getOwnMetadataKeys);
205
+ function deleteMetadata(metadataKey, target, propertyKey) {
206
+ if (!IsObject(target))
207
+ throw new TypeError;
208
+ if (!IsUndefined(propertyKey))
209
+ propertyKey = ToPropertyKey(propertyKey);
210
+ if (!IsObject(target))
211
+ throw new TypeError;
212
+ if (!IsUndefined(propertyKey))
213
+ propertyKey = ToPropertyKey(propertyKey);
214
+ var provider = GetMetadataProvider(target, propertyKey, false);
215
+ if (IsUndefined(provider))
216
+ return false;
217
+ return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);
218
+ }
219
+ exporter("deleteMetadata", deleteMetadata);
220
+ function DecorateConstructor(decorators, target) {
221
+ for (var i = decorators.length - 1;i >= 0; --i) {
222
+ var decorator = decorators[i];
223
+ var decorated = decorator(target);
224
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
225
+ if (!IsConstructor(decorated))
226
+ throw new TypeError;
227
+ target = decorated;
228
+ }
229
+ }
230
+ return target;
231
+ }
232
+ function DecorateProperty(decorators, target, propertyKey, descriptor) {
233
+ for (var i = decorators.length - 1;i >= 0; --i) {
234
+ var decorator = decorators[i];
235
+ var decorated = decorator(target, propertyKey, descriptor);
236
+ if (!IsUndefined(decorated) && !IsNull(decorated)) {
237
+ if (!IsObject(decorated))
238
+ throw new TypeError;
239
+ descriptor = decorated;
240
+ }
241
+ }
242
+ return descriptor;
243
+ }
244
+ function OrdinaryHasMetadata(MetadataKey, O, P) {
245
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
246
+ if (hasOwn2)
247
+ return true;
248
+ var parent = OrdinaryGetPrototypeOf(O);
249
+ if (!IsNull(parent))
250
+ return OrdinaryHasMetadata(MetadataKey, parent, P);
251
+ return false;
252
+ }
253
+ function OrdinaryHasOwnMetadata(MetadataKey, O, P) {
254
+ var provider = GetMetadataProvider(O, P, false);
255
+ if (IsUndefined(provider))
256
+ return false;
257
+ return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));
258
+ }
259
+ function OrdinaryGetMetadata(MetadataKey, O, P) {
260
+ var hasOwn2 = OrdinaryHasOwnMetadata(MetadataKey, O, P);
261
+ if (hasOwn2)
262
+ return OrdinaryGetOwnMetadata(MetadataKey, O, P);
263
+ var parent = OrdinaryGetPrototypeOf(O);
264
+ if (!IsNull(parent))
265
+ return OrdinaryGetMetadata(MetadataKey, parent, P);
266
+ return;
267
+ }
268
+ function OrdinaryGetOwnMetadata(MetadataKey, O, P) {
269
+ var provider = GetMetadataProvider(O, P, false);
270
+ if (IsUndefined(provider))
271
+ return;
272
+ return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);
273
+ }
274
+ function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {
275
+ var provider = GetMetadataProvider(O, P, true);
276
+ provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);
277
+ }
278
+ function OrdinaryMetadataKeys(O, P) {
279
+ var ownKeys = OrdinaryOwnMetadataKeys(O, P);
280
+ var parent = OrdinaryGetPrototypeOf(O);
281
+ if (parent === null)
282
+ return ownKeys;
283
+ var parentKeys = OrdinaryMetadataKeys(parent, P);
284
+ if (parentKeys.length <= 0)
285
+ return ownKeys;
286
+ if (ownKeys.length <= 0)
287
+ return parentKeys;
288
+ var set = new _Set;
289
+ var keys = [];
290
+ for (var _i = 0, ownKeys_1 = ownKeys;_i < ownKeys_1.length; _i++) {
291
+ var key = ownKeys_1[_i];
292
+ var hasKey = set.has(key);
293
+ if (!hasKey) {
294
+ set.add(key);
295
+ keys.push(key);
296
+ }
297
+ }
298
+ for (var _a = 0, parentKeys_1 = parentKeys;_a < parentKeys_1.length; _a++) {
299
+ var key = parentKeys_1[_a];
300
+ var hasKey = set.has(key);
301
+ if (!hasKey) {
302
+ set.add(key);
303
+ keys.push(key);
304
+ }
305
+ }
306
+ return keys;
307
+ }
308
+ function OrdinaryOwnMetadataKeys(O, P) {
309
+ var provider = GetMetadataProvider(O, P, false);
310
+ if (!provider) {
311
+ return [];
312
+ }
313
+ return provider.OrdinaryOwnMetadataKeys(O, P);
314
+ }
315
+ function Type(x) {
316
+ if (x === null)
317
+ return 1;
318
+ switch (typeof x) {
319
+ case "undefined":
320
+ return 0;
321
+ case "boolean":
322
+ return 2;
323
+ case "string":
324
+ return 3;
325
+ case "symbol":
326
+ return 4;
327
+ case "number":
328
+ return 5;
329
+ case "object":
330
+ return x === null ? 1 : 6;
331
+ default:
332
+ return 6;
333
+ }
334
+ }
335
+ function IsUndefined(x) {
336
+ return x === undefined;
337
+ }
338
+ function IsNull(x) {
339
+ return x === null;
340
+ }
341
+ function IsSymbol(x) {
342
+ return typeof x === "symbol";
343
+ }
344
+ function IsObject(x) {
345
+ return typeof x === "object" ? x !== null : typeof x === "function";
346
+ }
347
+ function ToPrimitive(input, PreferredType) {
348
+ switch (Type(input)) {
349
+ case 0:
350
+ return input;
351
+ case 1:
352
+ return input;
353
+ case 2:
354
+ return input;
355
+ case 3:
356
+ return input;
357
+ case 4:
358
+ return input;
359
+ case 5:
360
+ return input;
361
+ }
362
+ var hint = PreferredType === 3 ? "string" : PreferredType === 5 ? "number" : "default";
363
+ var exoticToPrim = GetMethod(input, toPrimitiveSymbol);
364
+ if (exoticToPrim !== undefined) {
365
+ var result = exoticToPrim.call(input, hint);
366
+ if (IsObject(result))
367
+ throw new TypeError;
368
+ return result;
369
+ }
370
+ return OrdinaryToPrimitive(input, hint === "default" ? "number" : hint);
371
+ }
372
+ function OrdinaryToPrimitive(O, hint) {
373
+ if (hint === "string") {
374
+ var toString_1 = O.toString;
375
+ if (IsCallable(toString_1)) {
376
+ var result = toString_1.call(O);
377
+ if (!IsObject(result))
378
+ return result;
379
+ }
380
+ var valueOf = O.valueOf;
381
+ if (IsCallable(valueOf)) {
382
+ var result = valueOf.call(O);
383
+ if (!IsObject(result))
384
+ return result;
385
+ }
386
+ } else {
387
+ var valueOf = O.valueOf;
388
+ if (IsCallable(valueOf)) {
389
+ var result = valueOf.call(O);
390
+ if (!IsObject(result))
391
+ return result;
392
+ }
393
+ var toString_2 = O.toString;
394
+ if (IsCallable(toString_2)) {
395
+ var result = toString_2.call(O);
396
+ if (!IsObject(result))
397
+ return result;
398
+ }
399
+ }
400
+ throw new TypeError;
401
+ }
402
+ function ToBoolean(argument) {
403
+ return !!argument;
404
+ }
405
+ function ToString(argument) {
406
+ return "" + argument;
407
+ }
408
+ function ToPropertyKey(argument) {
409
+ var key = ToPrimitive(argument, 3);
410
+ if (IsSymbol(key))
411
+ return key;
412
+ return ToString(key);
413
+ }
414
+ function IsArray(argument) {
415
+ return Array.isArray ? Array.isArray(argument) : argument instanceof Object ? argument instanceof Array : Object.prototype.toString.call(argument) === "[object Array]";
416
+ }
417
+ function IsCallable(argument) {
418
+ return typeof argument === "function";
419
+ }
420
+ function IsConstructor(argument) {
421
+ return typeof argument === "function";
422
+ }
423
+ function IsPropertyKey(argument) {
424
+ switch (Type(argument)) {
425
+ case 3:
426
+ return true;
427
+ case 4:
428
+ return true;
429
+ default:
430
+ return false;
431
+ }
432
+ }
433
+ function SameValueZero(x, y) {
434
+ return x === y || x !== x && y !== y;
435
+ }
436
+ function GetMethod(V, P) {
437
+ var func = V[P];
438
+ if (func === undefined || func === null)
439
+ return;
440
+ if (!IsCallable(func))
441
+ throw new TypeError;
442
+ return func;
443
+ }
444
+ function GetIterator(obj) {
445
+ var method = GetMethod(obj, iteratorSymbol);
446
+ if (!IsCallable(method))
447
+ throw new TypeError;
448
+ var iterator = method.call(obj);
449
+ if (!IsObject(iterator))
450
+ throw new TypeError;
451
+ return iterator;
452
+ }
453
+ function IteratorValue(iterResult) {
454
+ return iterResult.value;
455
+ }
456
+ function IteratorStep(iterator) {
457
+ var result = iterator.next();
458
+ return result.done ? false : result;
459
+ }
460
+ function IteratorClose(iterator) {
461
+ var f = iterator["return"];
462
+ if (f)
463
+ f.call(iterator);
464
+ }
465
+ function OrdinaryGetPrototypeOf(O) {
466
+ var proto = Object.getPrototypeOf(O);
467
+ if (typeof O !== "function" || O === functionPrototype)
468
+ return proto;
469
+ if (proto !== functionPrototype)
470
+ return proto;
471
+ var prototype = O.prototype;
472
+ var prototypeProto = prototype && Object.getPrototypeOf(prototype);
473
+ if (prototypeProto == null || prototypeProto === Object.prototype)
474
+ return proto;
475
+ var constructor = prototypeProto.constructor;
476
+ if (typeof constructor !== "function")
477
+ return proto;
478
+ if (constructor === O)
479
+ return proto;
480
+ return constructor;
481
+ }
482
+ function CreateMetadataRegistry() {
483
+ var fallback;
484
+ if (!IsUndefined(registrySymbol) && typeof root.Reflect !== "undefined" && !(registrySymbol in root.Reflect) && typeof root.Reflect.defineMetadata === "function") {
485
+ fallback = CreateFallbackProvider(root.Reflect);
486
+ }
487
+ var first;
488
+ var second;
489
+ var rest;
490
+ var targetProviderMap = new _WeakMap;
491
+ var registry = {
492
+ registerProvider,
493
+ getProvider,
494
+ setProvider
495
+ };
496
+ return registry;
497
+ function registerProvider(provider) {
498
+ if (!Object.isExtensible(registry)) {
499
+ throw new Error("Cannot add provider to a frozen registry.");
500
+ }
501
+ switch (true) {
502
+ case fallback === provider:
503
+ break;
504
+ case IsUndefined(first):
505
+ first = provider;
506
+ break;
507
+ case first === provider:
508
+ break;
509
+ case IsUndefined(second):
510
+ second = provider;
511
+ break;
512
+ case second === provider:
513
+ break;
514
+ default:
515
+ if (rest === undefined)
516
+ rest = new _Set;
517
+ rest.add(provider);
518
+ break;
519
+ }
520
+ }
521
+ function getProviderNoCache(O, P) {
522
+ if (!IsUndefined(first)) {
523
+ if (first.isProviderFor(O, P))
524
+ return first;
525
+ if (!IsUndefined(second)) {
526
+ if (second.isProviderFor(O, P))
527
+ return first;
528
+ if (!IsUndefined(rest)) {
529
+ var iterator = GetIterator(rest);
530
+ while (true) {
531
+ var next = IteratorStep(iterator);
532
+ if (!next) {
533
+ return;
534
+ }
535
+ var provider = IteratorValue(next);
536
+ if (provider.isProviderFor(O, P)) {
537
+ IteratorClose(iterator);
538
+ return provider;
539
+ }
540
+ }
541
+ }
542
+ }
543
+ }
544
+ if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {
545
+ return fallback;
546
+ }
547
+ return;
548
+ }
549
+ function getProvider(O, P) {
550
+ var providerMap = targetProviderMap.get(O);
551
+ var provider;
552
+ if (!IsUndefined(providerMap)) {
553
+ provider = providerMap.get(P);
554
+ }
555
+ if (!IsUndefined(provider)) {
556
+ return provider;
557
+ }
558
+ provider = getProviderNoCache(O, P);
559
+ if (!IsUndefined(provider)) {
560
+ if (IsUndefined(providerMap)) {
561
+ providerMap = new _Map;
562
+ targetProviderMap.set(O, providerMap);
563
+ }
564
+ providerMap.set(P, provider);
565
+ }
566
+ return provider;
567
+ }
568
+ function hasProvider(provider) {
569
+ if (IsUndefined(provider))
570
+ throw new TypeError;
571
+ return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);
572
+ }
573
+ function setProvider(O, P, provider) {
574
+ if (!hasProvider(provider)) {
575
+ throw new Error("Metadata provider not registered.");
576
+ }
577
+ var existingProvider = getProvider(O, P);
578
+ if (existingProvider !== provider) {
579
+ if (!IsUndefined(existingProvider)) {
580
+ return false;
581
+ }
582
+ var providerMap = targetProviderMap.get(O);
583
+ if (IsUndefined(providerMap)) {
584
+ providerMap = new _Map;
585
+ targetProviderMap.set(O, providerMap);
586
+ }
587
+ providerMap.set(P, provider);
588
+ }
589
+ return true;
590
+ }
591
+ }
592
+ function GetOrCreateMetadataRegistry() {
593
+ var metadataRegistry2;
594
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
595
+ metadataRegistry2 = root.Reflect[registrySymbol];
596
+ }
597
+ if (IsUndefined(metadataRegistry2)) {
598
+ metadataRegistry2 = CreateMetadataRegistry();
599
+ }
600
+ if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {
601
+ Object.defineProperty(root.Reflect, registrySymbol, {
602
+ enumerable: false,
603
+ configurable: false,
604
+ writable: false,
605
+ value: metadataRegistry2
606
+ });
607
+ }
608
+ return metadataRegistry2;
609
+ }
610
+ function CreateMetadataProvider(registry) {
611
+ var metadata2 = new _WeakMap;
612
+ var provider = {
613
+ isProviderFor: function(O, P) {
614
+ var targetMetadata = metadata2.get(O);
615
+ if (IsUndefined(targetMetadata))
616
+ return false;
617
+ return targetMetadata.has(P);
618
+ },
619
+ OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata2,
620
+ OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata2,
621
+ OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata2,
622
+ OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys2,
623
+ OrdinaryDeleteMetadata
624
+ };
625
+ metadataRegistry.registerProvider(provider);
626
+ return provider;
627
+ function GetOrCreateMetadataMap(O, P, Create) {
628
+ var targetMetadata = metadata2.get(O);
629
+ var createdTargetMetadata = false;
630
+ if (IsUndefined(targetMetadata)) {
631
+ if (!Create)
632
+ return;
633
+ targetMetadata = new _Map;
634
+ metadata2.set(O, targetMetadata);
635
+ createdTargetMetadata = true;
636
+ }
637
+ var metadataMap = targetMetadata.get(P);
638
+ if (IsUndefined(metadataMap)) {
639
+ if (!Create)
640
+ return;
641
+ metadataMap = new _Map;
642
+ targetMetadata.set(P, metadataMap);
643
+ if (!registry.setProvider(O, P, provider)) {
644
+ targetMetadata.delete(P);
645
+ if (createdTargetMetadata) {
646
+ metadata2.delete(O);
647
+ }
648
+ throw new Error("Wrong provider for target.");
649
+ }
650
+ }
651
+ return metadataMap;
652
+ }
653
+ function OrdinaryHasOwnMetadata2(MetadataKey, O, P) {
654
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
655
+ if (IsUndefined(metadataMap))
656
+ return false;
657
+ return ToBoolean(metadataMap.has(MetadataKey));
658
+ }
659
+ function OrdinaryGetOwnMetadata2(MetadataKey, O, P) {
660
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
661
+ if (IsUndefined(metadataMap))
662
+ return;
663
+ return metadataMap.get(MetadataKey);
664
+ }
665
+ function OrdinaryDefineOwnMetadata2(MetadataKey, MetadataValue, O, P) {
666
+ var metadataMap = GetOrCreateMetadataMap(O, P, true);
667
+ metadataMap.set(MetadataKey, MetadataValue);
668
+ }
669
+ function OrdinaryOwnMetadataKeys2(O, P) {
670
+ var keys = [];
671
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
672
+ if (IsUndefined(metadataMap))
673
+ return keys;
674
+ var keysObj = metadataMap.keys();
675
+ var iterator = GetIterator(keysObj);
676
+ var k = 0;
677
+ while (true) {
678
+ var next = IteratorStep(iterator);
679
+ if (!next) {
680
+ keys.length = k;
681
+ return keys;
682
+ }
683
+ var nextValue = IteratorValue(next);
684
+ try {
685
+ keys[k] = nextValue;
686
+ } catch (e) {
687
+ try {
688
+ IteratorClose(iterator);
689
+ } finally {
690
+ throw e;
691
+ }
692
+ }
693
+ k++;
694
+ }
695
+ }
696
+ function OrdinaryDeleteMetadata(MetadataKey, O, P) {
697
+ var metadataMap = GetOrCreateMetadataMap(O, P, false);
698
+ if (IsUndefined(metadataMap))
699
+ return false;
700
+ if (!metadataMap.delete(MetadataKey))
701
+ return false;
702
+ if (metadataMap.size === 0) {
703
+ var targetMetadata = metadata2.get(O);
704
+ if (!IsUndefined(targetMetadata)) {
705
+ targetMetadata.delete(P);
706
+ if (targetMetadata.size === 0) {
707
+ metadata2.delete(targetMetadata);
708
+ }
709
+ }
710
+ }
711
+ return true;
712
+ }
713
+ }
714
+ function CreateFallbackProvider(reflect) {
715
+ var { defineMetadata: defineMetadata2, hasOwnMetadata: hasOwnMetadata2, getOwnMetadata: getOwnMetadata2, getOwnMetadataKeys: getOwnMetadataKeys2, deleteMetadata: deleteMetadata2 } = reflect;
716
+ var metadataOwner = new _WeakMap;
717
+ var provider = {
718
+ isProviderFor: function(O, P) {
719
+ var metadataPropertySet = metadataOwner.get(O);
720
+ if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {
721
+ return true;
722
+ }
723
+ if (getOwnMetadataKeys2(O, P).length) {
724
+ if (IsUndefined(metadataPropertySet)) {
725
+ metadataPropertySet = new _Set;
726
+ metadataOwner.set(O, metadataPropertySet);
727
+ }
728
+ metadataPropertySet.add(P);
729
+ return true;
730
+ }
731
+ return false;
732
+ },
733
+ OrdinaryDefineOwnMetadata: defineMetadata2,
734
+ OrdinaryHasOwnMetadata: hasOwnMetadata2,
735
+ OrdinaryGetOwnMetadata: getOwnMetadata2,
736
+ OrdinaryOwnMetadataKeys: getOwnMetadataKeys2,
737
+ OrdinaryDeleteMetadata: deleteMetadata2
738
+ };
739
+ return provider;
740
+ }
741
+ function GetMetadataProvider(O, P, Create) {
742
+ var registeredProvider = metadataRegistry.getProvider(O, P);
743
+ if (!IsUndefined(registeredProvider)) {
744
+ return registeredProvider;
745
+ }
746
+ if (Create) {
747
+ if (metadataRegistry.setProvider(O, P, metadataProvider)) {
748
+ return metadataProvider;
749
+ }
750
+ throw new Error("Illegal state.");
751
+ }
752
+ return;
753
+ }
754
+ function CreateMapPolyfill() {
755
+ var cacheSentinel = {};
756
+ var arraySentinel = [];
757
+ var MapIterator = function() {
758
+ function MapIterator2(keys, values, selector) {
759
+ this._index = 0;
760
+ this._keys = keys;
761
+ this._values = values;
762
+ this._selector = selector;
763
+ }
764
+ MapIterator2.prototype["@@iterator"] = function() {
765
+ return this;
766
+ };
767
+ MapIterator2.prototype[iteratorSymbol] = function() {
768
+ return this;
769
+ };
770
+ MapIterator2.prototype.next = function() {
771
+ var index = this._index;
772
+ if (index >= 0 && index < this._keys.length) {
773
+ var result = this._selector(this._keys[index], this._values[index]);
774
+ if (index + 1 >= this._keys.length) {
775
+ this._index = -1;
776
+ this._keys = arraySentinel;
777
+ this._values = arraySentinel;
778
+ } else {
779
+ this._index++;
780
+ }
781
+ return { value: result, done: false };
782
+ }
783
+ return { value: undefined, done: true };
784
+ };
785
+ MapIterator2.prototype.throw = function(error) {
786
+ if (this._index >= 0) {
787
+ this._index = -1;
788
+ this._keys = arraySentinel;
789
+ this._values = arraySentinel;
790
+ }
791
+ throw error;
792
+ };
793
+ MapIterator2.prototype.return = function(value) {
794
+ if (this._index >= 0) {
795
+ this._index = -1;
796
+ this._keys = arraySentinel;
797
+ this._values = arraySentinel;
798
+ }
799
+ return { value, done: true };
800
+ };
801
+ return MapIterator2;
802
+ }();
803
+ var Map2 = function() {
804
+ function Map3() {
805
+ this._keys = [];
806
+ this._values = [];
807
+ this._cacheKey = cacheSentinel;
808
+ this._cacheIndex = -2;
809
+ }
810
+ Object.defineProperty(Map3.prototype, "size", {
811
+ get: function() {
812
+ return this._keys.length;
813
+ },
814
+ enumerable: true,
815
+ configurable: true
816
+ });
817
+ Map3.prototype.has = function(key) {
818
+ return this._find(key, false) >= 0;
819
+ };
820
+ Map3.prototype.get = function(key) {
821
+ var index = this._find(key, false);
822
+ return index >= 0 ? this._values[index] : undefined;
823
+ };
824
+ Map3.prototype.set = function(key, value) {
825
+ var index = this._find(key, true);
826
+ this._values[index] = value;
827
+ return this;
828
+ };
829
+ Map3.prototype.delete = function(key) {
830
+ var index = this._find(key, false);
831
+ if (index >= 0) {
832
+ var size = this._keys.length;
833
+ for (var i = index + 1;i < size; i++) {
834
+ this._keys[i - 1] = this._keys[i];
835
+ this._values[i - 1] = this._values[i];
836
+ }
837
+ this._keys.length--;
838
+ this._values.length--;
839
+ if (SameValueZero(key, this._cacheKey)) {
840
+ this._cacheKey = cacheSentinel;
841
+ this._cacheIndex = -2;
842
+ }
843
+ return true;
844
+ }
845
+ return false;
846
+ };
847
+ Map3.prototype.clear = function() {
848
+ this._keys.length = 0;
849
+ this._values.length = 0;
850
+ this._cacheKey = cacheSentinel;
851
+ this._cacheIndex = -2;
852
+ };
853
+ Map3.prototype.keys = function() {
854
+ return new MapIterator(this._keys, this._values, getKey);
855
+ };
856
+ Map3.prototype.values = function() {
857
+ return new MapIterator(this._keys, this._values, getValue);
858
+ };
859
+ Map3.prototype.entries = function() {
860
+ return new MapIterator(this._keys, this._values, getEntry);
861
+ };
862
+ Map3.prototype["@@iterator"] = function() {
863
+ return this.entries();
864
+ };
865
+ Map3.prototype[iteratorSymbol] = function() {
866
+ return this.entries();
867
+ };
868
+ Map3.prototype._find = function(key, insert) {
869
+ if (!SameValueZero(this._cacheKey, key)) {
870
+ this._cacheIndex = -1;
871
+ for (var i = 0;i < this._keys.length; i++) {
872
+ if (SameValueZero(this._keys[i], key)) {
873
+ this._cacheIndex = i;
874
+ break;
875
+ }
876
+ }
877
+ }
878
+ if (this._cacheIndex < 0 && insert) {
879
+ this._cacheIndex = this._keys.length;
880
+ this._keys.push(key);
881
+ this._values.push(undefined);
882
+ }
883
+ return this._cacheIndex;
884
+ };
885
+ return Map3;
886
+ }();
887
+ return Map2;
888
+ function getKey(key, _) {
889
+ return key;
890
+ }
891
+ function getValue(_, value) {
892
+ return value;
893
+ }
894
+ function getEntry(key, value) {
895
+ return [key, value];
896
+ }
897
+ }
898
+ function CreateSetPolyfill() {
899
+ var Set2 = function() {
900
+ function Set3() {
901
+ this._map = new _Map;
902
+ }
903
+ Object.defineProperty(Set3.prototype, "size", {
904
+ get: function() {
905
+ return this._map.size;
906
+ },
907
+ enumerable: true,
908
+ configurable: true
909
+ });
910
+ Set3.prototype.has = function(value) {
911
+ return this._map.has(value);
912
+ };
913
+ Set3.prototype.add = function(value) {
914
+ return this._map.set(value, value), this;
915
+ };
916
+ Set3.prototype.delete = function(value) {
917
+ return this._map.delete(value);
918
+ };
919
+ Set3.prototype.clear = function() {
920
+ this._map.clear();
921
+ };
922
+ Set3.prototype.keys = function() {
923
+ return this._map.keys();
924
+ };
925
+ Set3.prototype.values = function() {
926
+ return this._map.keys();
927
+ };
928
+ Set3.prototype.entries = function() {
929
+ return this._map.entries();
930
+ };
931
+ Set3.prototype["@@iterator"] = function() {
932
+ return this.keys();
933
+ };
934
+ Set3.prototype[iteratorSymbol] = function() {
935
+ return this.keys();
936
+ };
937
+ return Set3;
938
+ }();
939
+ return Set2;
940
+ }
941
+ function CreateWeakMapPolyfill() {
942
+ var UUID_SIZE = 16;
943
+ var keys = HashMap.create();
944
+ var rootKey = CreateUniqueKey();
945
+ return function() {
946
+ function WeakMap2() {
947
+ this._key = CreateUniqueKey();
948
+ }
949
+ WeakMap2.prototype.has = function(target) {
950
+ var table = GetOrCreateWeakMapTable(target, false);
951
+ return table !== undefined ? HashMap.has(table, this._key) : false;
952
+ };
953
+ WeakMap2.prototype.get = function(target) {
954
+ var table = GetOrCreateWeakMapTable(target, false);
955
+ return table !== undefined ? HashMap.get(table, this._key) : undefined;
956
+ };
957
+ WeakMap2.prototype.set = function(target, value) {
958
+ var table = GetOrCreateWeakMapTable(target, true);
959
+ table[this._key] = value;
960
+ return this;
961
+ };
962
+ WeakMap2.prototype.delete = function(target) {
963
+ var table = GetOrCreateWeakMapTable(target, false);
964
+ return table !== undefined ? delete table[this._key] : false;
965
+ };
966
+ WeakMap2.prototype.clear = function() {
967
+ this._key = CreateUniqueKey();
968
+ };
969
+ return WeakMap2;
970
+ }();
971
+ function CreateUniqueKey() {
972
+ var key;
973
+ do
974
+ key = "@@WeakMap@@" + CreateUUID();
975
+ while (HashMap.has(keys, key));
976
+ keys[key] = true;
977
+ return key;
978
+ }
979
+ function GetOrCreateWeakMapTable(target, create) {
980
+ if (!hasOwn.call(target, rootKey)) {
981
+ if (!create)
982
+ return;
983
+ Object.defineProperty(target, rootKey, { value: HashMap.create() });
984
+ }
985
+ return target[rootKey];
986
+ }
987
+ function FillRandomBytes(buffer, size) {
988
+ for (var i = 0;i < size; ++i)
989
+ buffer[i] = Math.random() * 255 | 0;
990
+ return buffer;
991
+ }
992
+ function GenRandomBytes(size) {
993
+ if (typeof Uint8Array === "function") {
994
+ var array = new Uint8Array(size);
995
+ if (typeof crypto !== "undefined") {
996
+ crypto.getRandomValues(array);
997
+ } else if (typeof msCrypto !== "undefined") {
998
+ msCrypto.getRandomValues(array);
999
+ } else {
1000
+ FillRandomBytes(array, size);
1001
+ }
1002
+ return array;
1003
+ }
1004
+ return FillRandomBytes(new Array(size), size);
1005
+ }
1006
+ function CreateUUID() {
1007
+ var data = GenRandomBytes(UUID_SIZE);
1008
+ data[6] = data[6] & 79 | 64;
1009
+ data[8] = data[8] & 191 | 128;
1010
+ var result = "";
1011
+ for (var offset = 0;offset < UUID_SIZE; ++offset) {
1012
+ var byte = data[offset];
1013
+ if (offset === 4 || offset === 6 || offset === 8)
1014
+ result += "-";
1015
+ if (byte < 16)
1016
+ result += "0";
1017
+ result += byte.toString(16).toLowerCase();
1018
+ }
1019
+ return result;
1020
+ }
1021
+ }
1022
+ function MakeDictionary(obj) {
1023
+ obj.__ = undefined;
1024
+ delete obj.__;
1025
+ return obj;
1026
+ }
1027
+ });
1028
+ })(Reflect2 || (Reflect2 = {}));
1029
+ });
1030
+
1031
+ // packages/core/src/api/ConnectionInfo.ts
1032
+ class ConnectHeaders {
1033
+ }
1034
+
1035
+ class ServerInfo {
1036
+ host;
1037
+ port;
1038
+ useSSL;
1039
+ }
1040
+
1041
+ class ConnectionInfo extends ServerInfo {
1042
+ connectHeaders;
1043
+ maxConnectionAttempts;
1044
+ disableStickySession;
1045
+ }
1046
+ // packages/core/src/core/api/crud/AbstractIterablePage.ts
1047
+ class AbstractIterablePage {
1048
+ pageable;
1049
+ currentPage;
1050
+ firstPage = true;
1051
+ constructor(pageable, page) {
1052
+ this.pageable = pageable;
1053
+ this.currentPage = page;
1054
+ }
1055
+ async next() {
1056
+ let ret;
1057
+ if (this.firstPage) {
1058
+ this.firstPage = false;
1059
+ ret = { done: !this.hasContent(), value: this };
1060
+ } else {
1061
+ if (this.isOffsetPageable()) {
1062
+ const offsetPageable = this.pageable;
1063
+ offsetPageable.pageNumber++;
1064
+ const numPages = Math.ceil(this.totalElements / this.pageable.pageSize);
1065
+ if (offsetPageable.pageNumber < numPages) {
1066
+ this.currentPage = await this.findNext(this.pageable);
1067
+ ret = { done: false, value: this };
1068
+ } else {
1069
+ ret = { done: true, value: this };
1070
+ }
1071
+ } else {
1072
+ const cursorPageable = this.pageable;
1073
+ cursorPageable.cursor = this.currentPage.cursor || null;
1074
+ this.currentPage = await this.findNext(this.pageable);
1075
+ ret = { done: this.isLastPage(), value: this };
1076
+ }
1077
+ }
1078
+ return ret;
1079
+ }
1080
+ [Symbol.asyncIterator]() {
1081
+ return this;
1082
+ }
1083
+ hasContent() {
1084
+ return this.currentPage.content !== null && this.currentPage.content !== undefined && this.currentPage.content.length > 0;
1085
+ }
1086
+ isLastPage() {
1087
+ let ret;
1088
+ if (this.isOffsetPageable()) {
1089
+ const numPages = Math.ceil(this.totalElements / this.pageable.pageSize);
1090
+ ret = numPages === this.pageable.pageNumber + 1;
1091
+ } else {
1092
+ ret = !this.firstPage && this.currentPage.cursor === null;
1093
+ }
1094
+ return ret;
1095
+ }
1096
+ isOffsetPageable() {
1097
+ return this.pageable.pageNumber !== undefined;
1098
+ }
1099
+ get totalElements() {
1100
+ return this.currentPage.totalElements;
1101
+ }
1102
+ get cursor() {
1103
+ return this.currentPage.cursor;
1104
+ }
1105
+ get content() {
1106
+ return this.currentPage.content;
1107
+ }
1108
+ }
1109
+
1110
+ // packages/core/src/internal/core/api/crud/FindAllIterablePage.ts
1111
+ class FindAllIterablePage extends AbstractIterablePage {
1112
+ crudServiceProxy;
1113
+ constructor(pageable, page, crudServiceProxy) {
1114
+ super(pageable, page);
1115
+ this.crudServiceProxy = crudServiceProxy;
1116
+ }
1117
+ findNext(pageable) {
1118
+ return this.crudServiceProxy.findAllSinglePage(pageable);
1119
+ }
1120
+ }
1121
+
1122
+ // packages/core/src/internal/core/api/crud/SearchIterablePage.ts
1123
+ class SearchIterablePage extends AbstractIterablePage {
1124
+ searchText;
1125
+ crudServiceProxy;
1126
+ constructor(pageable, page, searchText, crudServiceProxy) {
1127
+ super(pageable, page);
1128
+ this.searchText = searchText;
1129
+ this.crudServiceProxy = crudServiceProxy;
1130
+ }
1131
+ findNext(pageable) {
1132
+ return this.crudServiceProxy.searchSinglePage(this.searchText, pageable);
1133
+ }
1134
+ }
1135
+
1136
+ // packages/core/src/core/api/crud/CrudServiceProxy.ts
1137
+ class CrudServiceProxy {
1138
+ serviceProxy;
1139
+ constructor(serviceProxy) {
1140
+ this.serviceProxy = serviceProxy;
1141
+ }
1142
+ count() {
1143
+ return this.serviceProxy.invoke("count");
1144
+ }
1145
+ create(entity) {
1146
+ return this.serviceProxy.invoke("create", [entity]);
1147
+ }
1148
+ deleteById(id) {
1149
+ return this.serviceProxy.invoke("deleteById", [id]);
1150
+ }
1151
+ async findAll(pageable) {
1152
+ const page = await this.findAllSinglePage(pageable);
1153
+ return new FindAllIterablePage(pageable, page, this);
1154
+ }
1155
+ findAllSinglePage(pageable) {
1156
+ return this.serviceProxy.invoke("findAll", [pageable]);
1157
+ }
1158
+ findById(id) {
1159
+ return this.serviceProxy.invoke("findById", [id]);
1160
+ }
1161
+ save(entity) {
1162
+ return this.serviceProxy.invoke("save", [entity]);
1163
+ }
1164
+ findByIdNotIn(ids, page) {
1165
+ return this.serviceProxy.invoke("findByIdNotIn", [ids, page]);
1166
+ }
1167
+ async search(searchText, pageable) {
1168
+ const page = await this.searchSinglePage(searchText, pageable);
1169
+ return new SearchIterablePage(pageable, page, searchText, this);
1170
+ }
1171
+ searchSinglePage(searchText, pageable) {
1172
+ return this.serviceProxy.invoke("search", [searchText, pageable]);
1173
+ }
1174
+ }
1175
+
1176
+ // packages/core/src/core/api/crud/CrudServiceProxyFactory.ts
1177
+ class CrudServiceProxyFactory {
1178
+ serviceRegistry;
1179
+ constructor(serviceRegistry) {
1180
+ this.serviceRegistry = serviceRegistry;
1181
+ }
1182
+ crudServiceProxy(serviceIdentifier) {
1183
+ if (typeof serviceIdentifier === "undefined" || serviceIdentifier.length === 0) {
1184
+ throw new Error("The serviceIdentifier provided must contain a value");
1185
+ }
1186
+ return new CrudServiceProxy(this.serviceRegistry.serviceProxy(serviceIdentifier));
1187
+ }
1188
+ }
1189
+
1190
+ // packages/core/src/api/errors/KinoticError.ts
1191
+ class KinoticError extends Error {
1192
+ constructor(message) {
1193
+ super(message);
1194
+ Object.setPrototypeOf(this, KinoticError.prototype);
1195
+ }
1196
+ }
1197
+
1198
+ // packages/core/src/core/api/IEventBus.ts
1199
+ var EventConstants;
1200
+ ((EventConstants2) => {
1201
+ EventConstants2["CONTENT_TYPE_HEADER"] = "content-type";
1202
+ EventConstants2["CONTENT_LENGTH_HEADER"] = "content-length";
1203
+ EventConstants2["REPLY_TO_HEADER"] = "reply-to";
1204
+ EventConstants2["REPLY_TO_ID_HEADER"] = "reply-to-id";
1205
+ EventConstants2["SESSION_HEADER"] = "session";
1206
+ EventConstants2["CONNECTED_INFO_HEADER"] = "connected-info";
1207
+ EventConstants2["DISABLE_STICKY_SESSION_HEADER"] = "disable-sticky-session";
1208
+ EventConstants2["CORRELATION_ID_HEADER"] = "__correlation-id";
1209
+ EventConstants2["ERROR_HEADER"] = "error";
1210
+ EventConstants2["COMPLETE_HEADER"] = "complete";
1211
+ EventConstants2["CONTROL_HEADER"] = "control";
1212
+ EventConstants2["CONTROL_VALUE_COMPLETE"] = "complete";
1213
+ EventConstants2["CONTROL_VALUE_CANCEL"] = "cancel";
1214
+ EventConstants2["CONTROL_VALUE_SUSPEND"] = "suspend";
1215
+ EventConstants2["CONTROL_VALUE_RESUME"] = "resume";
1216
+ EventConstants2["SERVICE_DESTINATION_PREFIX"] = "srv://";
1217
+ EventConstants2["SERVICE_DESTINATION_SCHEME"] = "srv";
1218
+ EventConstants2["STREAM_DESTINATION_PREFIX"] = "stream://";
1219
+ EventConstants2["STREAM_DESTINATION_SCHEME"] = "stream";
1220
+ EventConstants2["CONTENT_JSON"] = "application/json";
1221
+ EventConstants2["CONTENT_TEXT"] = "text/plain";
1222
+ EventConstants2["TRACEPARENT_HEADER"] = "traceparent";
1223
+ EventConstants2["TRACESTATE_HEADER"] = "tracestate";
1224
+ })(EventConstants ||= {});
1225
+
1226
+ // packages/core/src/core/api/StompConnectionManager.ts
1227
+ import { RxStomp } from "@stomp/rx-stomp";
1228
+ import { ReconnectionTimeMode } from "@stomp/stompjs";
1229
+ import { v4 as uuidv4 } from "uuid";
1230
+ import debug from "debug";
1231
+
1232
+ class StompConnectionManager {
1233
+ lastWebsocketError = null;
1234
+ maxConnectionAttemptsReached = false;
1235
+ rxStomp = null;
1236
+ INITIAL_RECONNECT_DELAY = 2000;
1237
+ MAX_RECONNECT_DELAY = 120000;
1238
+ JITTER_MAX = 5000;
1239
+ connectionAttempts = 0;
1240
+ initialConnectionSuccessful = false;
1241
+ debugLogger = debug("kinoitc:stomp");
1242
+ uuidv4 = uuidv4();
1243
+ replyToId = uuidv4();
1244
+ _replyToCri = "srv://" /* SERVICE_DESTINATION_PREFIX */ + this.replyToId + ":" + this.uuidv4 + "@kinoitc.js.EventBus/replyHandler";
1245
+ deactivationHandler = null;
1246
+ get active() {
1247
+ return !!this.rxStomp;
1248
+ }
1249
+ get replyToCri() {
1250
+ return this._replyToCri;
1251
+ }
1252
+ get connected() {
1253
+ return this.rxStomp != null && this.rxStomp.connected();
1254
+ }
1255
+ activate(connectionInfo) {
1256
+ return new Promise((resolve, reject) => {
1257
+ if (!connectionInfo) {
1258
+ reject("You must supply a valid connectionInfo object");
1259
+ return;
1260
+ }
1261
+ if (!connectionInfo.host) {
1262
+ reject("No host provided");
1263
+ return;
1264
+ }
1265
+ if (this.rxStomp) {
1266
+ reject("Stomp connection already active");
1267
+ return;
1268
+ }
1269
+ this.connectionAttempts = 0;
1270
+ this.initialConnectionSuccessful = false;
1271
+ this.lastWebsocketError = null;
1272
+ this.maxConnectionAttemptsReached = false;
1273
+ const url = "ws" + (connectionInfo.useSSL ? "s" : "") + "://" + connectionInfo.host + (connectionInfo.port ? ":" + connectionInfo.port : "") + "/v1";
1274
+ this.rxStomp = new RxStomp;
1275
+ let connectHeadersInternal = typeof connectionInfo.connectHeaders !== "function" && connectionInfo.connectHeaders != null ? connectionInfo.connectHeaders : {};
1276
+ const stompConfig = {
1277
+ brokerURL: url,
1278
+ connectHeaders: connectHeadersInternal,
1279
+ heartbeatIncoming: 120000,
1280
+ heartbeatOutgoing: 30000,
1281
+ reconnectDelay: this.INITIAL_RECONNECT_DELAY,
1282
+ beforeConnect: async () => {
1283
+ if (typeof connectionInfo.connectHeaders === "function") {
1284
+ const headers = await connectionInfo.connectHeaders();
1285
+ for (const key in headers) {
1286
+ connectHeadersInternal[key] = headers[key];
1287
+ }
1288
+ }
1289
+ if (connectionInfo.disableStickySession) {
1290
+ connectHeadersInternal["disable-sticky-session" /* DISABLE_STICKY_SESSION_HEADER */] = "true";
1291
+ }
1292
+ if (connectHeadersInternal["reply-to-id" /* REPLY_TO_ID_HEADER */]) {
1293
+ this.replyToId = connectHeadersInternal["reply-to-id" /* REPLY_TO_ID_HEADER */];
1294
+ this._replyToCri = "srv://" /* SERVICE_DESTINATION_PREFIX */ + this.replyToId + ":" + this.uuidv4 + "@kinoitc.js.EventBus/replyHandler";
1295
+ } else {
1296
+ connectHeadersInternal["reply-to-id" /* REPLY_TO_ID_HEADER */] = this.replyToId;
1297
+ }
1298
+ if (connectionInfo?.maxConnectionAttempts) {
1299
+ this.connectionAttempts++;
1300
+ if (this.connectionAttempts > connectionInfo.maxConnectionAttempts) {
1301
+ this.maxConnectionAttemptsReached = true;
1302
+ await this.deactivate();
1303
+ if (!this.initialConnectionSuccessful) {
1304
+ let message = this.lastWebsocketError?.message ? this.lastWebsocketError?.message : "UNKNOWN";
1305
+ reject(`Max number of reconnection attempts reached. Last WS Error ${message}`);
1306
+ }
1307
+ } else {
1308
+ await this.connectionJitterDelay();
1309
+ }
1310
+ } else {
1311
+ await this.connectionJitterDelay();
1312
+ }
1313
+ }
1314
+ };
1315
+ if (this.debugLogger.enabled) {
1316
+ stompConfig.debug = (msg) => {
1317
+ this.debugLogger(msg);
1318
+ };
1319
+ }
1320
+ this.rxStomp.configure(stompConfig);
1321
+ this.rxStomp.stompClient.maxReconnectDelay = this.MAX_RECONNECT_DELAY;
1322
+ this.rxStomp.stompClient.reconnectTimeMode = ReconnectionTimeMode.EXPONENTIAL;
1323
+ this.rxStomp.webSocketErrors$.subscribe((value) => {
1324
+ this.lastWebsocketError = value;
1325
+ });
1326
+ const connectedSubscription = this.rxStomp.connected$.subscribe(() => {
1327
+ connectedSubscription.unsubscribe();
1328
+ if (!this.initialConnectionSuccessful) {
1329
+ this.initialConnectionSuccessful = true;
1330
+ }
1331
+ });
1332
+ const errorSubscription = this.rxStomp.stompErrors$.subscribe((value) => {
1333
+ errorSubscription.unsubscribe();
1334
+ const message = value.headers["message"];
1335
+ this.rxStomp?.deactivate();
1336
+ this.rxStomp = null;
1337
+ reject(message);
1338
+ });
1339
+ const serverHeadersSubscription = this.rxStomp.serverHeaders$.subscribe((value) => {
1340
+ let connectedInfoJson = value["connected-info" /* CONNECTED_INFO_HEADER */];
1341
+ if (connectedInfoJson != null) {
1342
+ const connectedInfo = JSON.parse(connectedInfoJson);
1343
+ if (!connectionInfo.disableStickySession) {
1344
+ serverHeadersSubscription.unsubscribe();
1345
+ if (connectedInfo.sessionId != null && connectedInfo.replyToId != null) {
1346
+ if (connectionInfo.connectHeaders != null) {
1347
+ for (let key in connectHeadersInternal) {
1348
+ delete connectHeadersInternal[key];
1349
+ }
1350
+ }
1351
+ connectHeadersInternal["session" /* SESSION_HEADER */] = connectedInfo.sessionId;
1352
+ resolve(connectedInfo);
1353
+ } else {
1354
+ reject("Server did not return proper data for successful login");
1355
+ }
1356
+ } else if (typeof connectionInfo.connectHeaders === "function") {
1357
+ for (let key in connectHeadersInternal) {
1358
+ delete connectHeadersInternal[key];
1359
+ }
1360
+ if (!this.initialConnectionSuccessful) {
1361
+ resolve(connectedInfo);
1362
+ }
1363
+ } else if (typeof connectionInfo.connectHeaders === "object") {
1364
+ serverHeadersSubscription.unsubscribe();
1365
+ resolve(connectedInfo);
1366
+ }
1367
+ } else {
1368
+ reject("Server did not return proper data for successful login");
1369
+ }
1370
+ });
1371
+ this.rxStomp.activate();
1372
+ });
1373
+ }
1374
+ async deactivate(force) {
1375
+ if (this.rxStomp) {
1376
+ await this.rxStomp.deactivate({ force });
1377
+ if (this.deactivationHandler) {
1378
+ this.deactivationHandler();
1379
+ }
1380
+ this.rxStomp = null;
1381
+ }
1382
+ return;
1383
+ }
1384
+ async connectionJitterDelay() {
1385
+ if (this.initialConnectionSuccessful) {
1386
+ const randomJitter = Math.random() * this.JITTER_MAX;
1387
+ this.debugLogger(`Adding ${randomJitter}ms of jitter delay`);
1388
+ return new Promise((resolve) => setTimeout(resolve, randomJitter));
1389
+ }
1390
+ }
1391
+ }
1392
+
1393
+ // packages/core/src/core/api/EventBus.ts
1394
+ import { context, propagation } from "@opentelemetry/api";
1395
+ import { firstValueFrom, Observable, Subject, throwError } from "rxjs";
1396
+ import { filter, map, multicast } from "rxjs/operators";
1397
+ import { Optional } from "typescript-optional";
1398
+ import { v4 as uuidv42 } from "uuid";
1399
+ class Event {
1400
+ cri;
1401
+ headers;
1402
+ data;
1403
+ constructor(cri, headers, data) {
1404
+ this.cri = cri;
1405
+ if (headers !== undefined) {
1406
+ this.headers = headers;
1407
+ } else {
1408
+ this.headers = new Map;
1409
+ }
1410
+ this.data = Optional.ofNullable(data);
1411
+ }
1412
+ getHeader(key) {
1413
+ return this.headers.get(key);
1414
+ }
1415
+ hasHeader(key) {
1416
+ return this.headers.has(key);
1417
+ }
1418
+ setHeader(key, value) {
1419
+ this.headers.set(key, value);
1420
+ }
1421
+ removeHeader(key) {
1422
+ return this.headers.delete(key);
1423
+ }
1424
+ setDataString(data) {
1425
+ const uint8Array = new TextEncoder().encode(data);
1426
+ this.data = Optional.ofNonNull(uint8Array);
1427
+ }
1428
+ getDataString() {
1429
+ let ret = "";
1430
+ this.data.ifPresent((value) => ret = new TextDecoder().decode(value));
1431
+ return ret;
1432
+ }
1433
+ }
1434
+
1435
+ class EventBus {
1436
+ fatalErrors;
1437
+ serverInfo = null;
1438
+ stompConnectionManager = new StompConnectionManager;
1439
+ replyToCri = null;
1440
+ requestRepliesObservable = null;
1441
+ requestRepliesSubject = null;
1442
+ requestRepliesSubscription = null;
1443
+ errorSubject = new Subject;
1444
+ errorSubjectSubscription = null;
1445
+ constructor() {
1446
+ this.fatalErrors = this.errorSubject.pipe(map((frame) => {
1447
+ this.disconnect().catch((error) => {
1448
+ if (console) {
1449
+ console.error("Error disconnecting from Stomp: " + error);
1450
+ }
1451
+ });
1452
+ return new KinoticError(frame.headers["message"]);
1453
+ }));
1454
+ this.stompConnectionManager.deactivationHandler = () => {
1455
+ this.cleanup();
1456
+ };
1457
+ }
1458
+ isConnectionActive() {
1459
+ return this.stompConnectionManager.active;
1460
+ }
1461
+ isConnected() {
1462
+ return this.stompConnectionManager.connected;
1463
+ }
1464
+ async connect(connectionInfo) {
1465
+ if (!this.stompConnectionManager.active) {
1466
+ this.cleanup();
1467
+ const connectedInfo = await this.stompConnectionManager.activate(connectionInfo);
1468
+ this.serverInfo = new ServerInfo;
1469
+ this.serverInfo.host = connectionInfo.host;
1470
+ this.serverInfo.port = connectionInfo.port;
1471
+ this.serverInfo.useSSL = connectionInfo.useSSL;
1472
+ this.replyToCri = this.stompConnectionManager.replyToCri;
1473
+ this.errorSubjectSubscription = this.stompConnectionManager.rxStomp?.stompErrors$.subscribe(this.errorSubject);
1474
+ return connectedInfo;
1475
+ } else {
1476
+ throw new Error("Event Bus connection already active");
1477
+ }
1478
+ }
1479
+ async disconnect(force) {
1480
+ await this.stompConnectionManager.deactivate(force);
1481
+ this.cleanup();
1482
+ }
1483
+ send(event) {
1484
+ if (this.stompConnectionManager.rxStomp) {
1485
+ const headers = {};
1486
+ for (const [key, value] of event.headers.entries()) {
1487
+ headers[key] = value;
1488
+ }
1489
+ const carrier = {};
1490
+ propagation.inject(context.active(), carrier);
1491
+ if (carrier.traceparent) {
1492
+ headers["traceparent" /* TRACEPARENT_HEADER */] = carrier.traceparent;
1493
+ }
1494
+ if (carrier.tracestate) {
1495
+ headers["tracestate" /* TRACESTATE_HEADER */] = carrier.tracestate;
1496
+ }
1497
+ this.stompConnectionManager.rxStomp.publish({
1498
+ destination: event.cri,
1499
+ headers,
1500
+ binaryBody: event.data.orUndefined()
1501
+ });
1502
+ } else {
1503
+ throw this.createSendUnavailableError();
1504
+ }
1505
+ }
1506
+ request(event) {
1507
+ return firstValueFrom(this.requestStream(event, false));
1508
+ }
1509
+ requestStream(event, sendControlEvents = true) {
1510
+ if (this.stompConnectionManager?.rxStomp) {
1511
+ return new Observable((subscriber) => {
1512
+ if (this.requestRepliesObservable == null) {
1513
+ this.requestRepliesSubject = new Subject;
1514
+ this.requestRepliesObservable = this._observe(this.replyToCri).pipe(multicast(this.requestRepliesSubject));
1515
+ this.requestRepliesSubscription = this.requestRepliesObservable.connect();
1516
+ }
1517
+ let serverSignaledCompletion = false;
1518
+ const correlationId = uuidv42();
1519
+ const defaultMessagesSubscription = this.requestRepliesObservable.pipe(filter((value) => {
1520
+ return value.headers.get("__correlation-id" /* CORRELATION_ID_HEADER */) === correlationId;
1521
+ })).subscribe({
1522
+ next(value) {
1523
+ if (value.hasHeader("control" /* CONTROL_HEADER */)) {
1524
+ if (value.headers.get("control" /* CONTROL_HEADER */) === "complete") {
1525
+ serverSignaledCompletion = true;
1526
+ subscriber.complete();
1527
+ } else {
1528
+ throw new Error("Control Header " + value.headers.get("control" /* CONTROL_HEADER */) + " is not supported");
1529
+ }
1530
+ } else if (value.hasHeader("error" /* ERROR_HEADER */)) {
1531
+ serverSignaledCompletion = true;
1532
+ subscriber.error(new Error(value.getHeader("error" /* ERROR_HEADER */)));
1533
+ } else {
1534
+ subscriber.next(value);
1535
+ }
1536
+ },
1537
+ error(err) {
1538
+ subscriber.error(err);
1539
+ },
1540
+ complete() {
1541
+ subscriber.complete();
1542
+ }
1543
+ });
1544
+ subscriber.add(defaultMessagesSubscription);
1545
+ event.setHeader("reply-to" /* REPLY_TO_HEADER */, this.replyToCri);
1546
+ event.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
1547
+ this.send(event);
1548
+ return () => {
1549
+ if (sendControlEvents && !serverSignaledCompletion) {
1550
+ const controlEvent = new Event(event.cri);
1551
+ controlEvent.setHeader("control" /* CONTROL_HEADER */, "cancel" /* CONTROL_VALUE_CANCEL */);
1552
+ controlEvent.setHeader("__correlation-id" /* CORRELATION_ID_HEADER */, correlationId);
1553
+ this.send(controlEvent);
1554
+ }
1555
+ };
1556
+ });
1557
+ } else {
1558
+ return throwError(() => this.createSendUnavailableError());
1559
+ }
1560
+ }
1561
+ listen(_serverInfo) {
1562
+ return Promise.reject("Not implemented");
1563
+ }
1564
+ observe(cri) {
1565
+ return this._observe(cri);
1566
+ }
1567
+ cleanup() {
1568
+ if (this.requestRepliesSubject != null) {
1569
+ this.requestRepliesSubject.error(new Error("Connection disconnected"));
1570
+ if (this.requestRepliesSubscription != null) {
1571
+ this.requestRepliesSubscription.unsubscribe();
1572
+ this.requestRepliesSubscription = null;
1573
+ }
1574
+ this.requestRepliesSubject = null;
1575
+ this.requestRepliesObservable = null;
1576
+ }
1577
+ if (this.errorSubjectSubscription) {
1578
+ this.errorSubjectSubscription.unsubscribe();
1579
+ this.errorSubjectSubscription = null;
1580
+ }
1581
+ this.serverInfo = null;
1582
+ }
1583
+ createSendUnavailableError() {
1584
+ let ret = "You must call connect on the event bus before sending any request";
1585
+ if (this.stompConnectionManager.maxConnectionAttemptsReached) {
1586
+ ret = "Max connection attempts reached event bus is not available";
1587
+ }
1588
+ return new Error(ret);
1589
+ }
1590
+ _observe(cri) {
1591
+ if (this.stompConnectionManager?.rxStomp) {
1592
+ return this.stompConnectionManager.rxStomp.watch(cri).pipe(map((message) => {
1593
+ const headers = new Map;
1594
+ let destination = "";
1595
+ for (const prop of Object.keys(message.headers)) {
1596
+ if (prop === "destination") {
1597
+ destination = message.headers[prop];
1598
+ } else {
1599
+ headers.set(prop, message.headers[prop]);
1600
+ }
1601
+ }
1602
+ return new Event(destination, headers, message.binaryBody);
1603
+ }));
1604
+ } else {
1605
+ throw this.createSendUnavailableError();
1606
+ }
1607
+ }
1608
+ }
1609
+
1610
+ // packages/core/src/core/api/ServiceRegistry.ts
1611
+ import debug2 from "debug";
1612
+
1613
+ // packages/core/src/core/api/DefaultCRI.ts
1614
+ class DefaultCRI {
1615
+ _scheme;
1616
+ _scope;
1617
+ _resourceName;
1618
+ _path;
1619
+ _version;
1620
+ _raw;
1621
+ constructor(...args) {
1622
+ if (args.length === 1) {
1623
+ const rawURC = args[0];
1624
+ if (typeof rawURC !== "string") {
1625
+ throw new Error("Raw URI must be a string");
1626
+ }
1627
+ const parsed = DefaultCRI.parseRaw(rawURC);
1628
+ this._scheme = parsed.scheme;
1629
+ this._scope = parsed.scope;
1630
+ this._resourceName = parsed.resourceName;
1631
+ this._path = parsed.path;
1632
+ this._version = parsed.version;
1633
+ this._raw = rawURC;
1634
+ } else if (args.length === 5) {
1635
+ const [scheme, scope, resourceName, path, version] = args;
1636
+ this._scheme = scheme;
1637
+ this._scope = scope;
1638
+ this._resourceName = resourceName;
1639
+ this._path = path;
1640
+ this._version = version;
1641
+ this._raw = DefaultCRI.buildRaw(scheme, scope, resourceName, path, version);
1642
+ } else {
1643
+ throw new Error("Invalid constructor arguments for DefaultCRI");
1644
+ }
1645
+ if (!this._scheme || !this._resourceName) {
1646
+ throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`);
1647
+ }
1648
+ }
1649
+ scheme() {
1650
+ return this._scheme;
1651
+ }
1652
+ scope() {
1653
+ return this._scope;
1654
+ }
1655
+ hasScope() {
1656
+ return this._scope !== null;
1657
+ }
1658
+ resourceName() {
1659
+ return this._resourceName;
1660
+ }
1661
+ version() {
1662
+ return this._version;
1663
+ }
1664
+ hasVersion() {
1665
+ return this._version !== null;
1666
+ }
1667
+ path() {
1668
+ return this._path;
1669
+ }
1670
+ hasPath() {
1671
+ return this._path !== null;
1672
+ }
1673
+ baseResource() {
1674
+ let result = `${this._scheme}://`;
1675
+ if (this.hasScope()) {
1676
+ result += `${this._scope}@`;
1677
+ }
1678
+ result += this._resourceName;
1679
+ return result;
1680
+ }
1681
+ raw() {
1682
+ return this._raw;
1683
+ }
1684
+ equals(other) {
1685
+ if (this === other)
1686
+ return true;
1687
+ if (!(other instanceof DefaultCRI))
1688
+ return false;
1689
+ return this._raw === other.raw();
1690
+ }
1691
+ hashCode() {
1692
+ let hash = 17;
1693
+ hash = hash * 37 + this._raw.split("").reduce((a, c) => a + c.charCodeAt(0), 0);
1694
+ return hash;
1695
+ }
1696
+ toString() {
1697
+ return this._raw;
1698
+ }
1699
+ static parseRaw(raw) {
1700
+ const regex = /^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/;
1701
+ const match = raw.match(regex);
1702
+ if (!match) {
1703
+ throw new Error(`Invalid CRI format: ${raw}`);
1704
+ }
1705
+ const [, scheme, scope, resourceName, path, version] = match;
1706
+ return {
1707
+ scheme,
1708
+ scope: scope || null,
1709
+ resourceName,
1710
+ path: path ? path.substring(1) : null,
1711
+ version: version || null
1712
+ };
1713
+ }
1714
+ static buildRaw(scheme, scope, resourceName, path, version) {
1715
+ let result = `${scheme}://`;
1716
+ if (scope) {
1717
+ result += `${scope}@`;
1718
+ }
1719
+ result += resourceName;
1720
+ if (path) {
1721
+ result += `/${path}`;
1722
+ }
1723
+ if (version) {
1724
+ result += `#${version}`;
1725
+ }
1726
+ return result;
1727
+ }
1728
+ }
1729
+
1730
+ // packages/core/src/core/api/CRI.ts
1731
+ function createCRI(...args) {
1732
+ if (args.length === 1)
1733
+ return new DefaultCRI(args[0]);
1734
+ if (args.length === 2)
1735
+ return new DefaultCRI(args[0], null, args[1], null, null);
1736
+ if (args.length === 3)
1737
+ return new DefaultCRI(args[0], args[1], args[2], null, null);
1738
+ if (args.length === 5)
1739
+ return new DefaultCRI(args[0], args[1], args[2], args[3], args[4]);
1740
+ throw new Error("Invalid arguments for createCRI");
1741
+ }
1742
+
1743
+ // packages/core/src/internal/core/api/ArgumentResolver.ts
1744
+ class JsonArgumentResolver {
1745
+ resolveArguments(event) {
1746
+ if (this.containsJsonContent(event)) {
1747
+ const data = event.getDataString();
1748
+ return data ? JSON.parse(data) : [];
1749
+ } else {
1750
+ throw new Error("Currently only JSON content is supported");
1751
+ }
1752
+ }
1753
+ containsJsonContent(event) {
1754
+ const contentType = event.getHeader("content-type" /* CONTENT_TYPE_HEADER */);
1755
+ return contentType != null && contentType !== "" && contentType === "application/json";
1756
+ }
1757
+ }
1758
+
1759
+ // packages/core/src/internal/core/api/EventUtil.ts
1760
+ class EventUtil {
1761
+ static createReplyEvent(incomingHeaders, headers, body) {
1762
+ if (!incomingHeaders) {
1763
+ throw new Error("incomingHeaders cannot be null");
1764
+ }
1765
+ const replyCRI = incomingHeaders.get("reply-to" /* REPLY_TO_HEADER */);
1766
+ if (!replyCRI || replyCRI.trim() === "") {
1767
+ throw new Error("No reply-to header found, cannot create outgoing message");
1768
+ }
1769
+ const newHeaders = new Map;
1770
+ for (const [key, value] of incomingHeaders) {
1771
+ if (key.startsWith("__")) {
1772
+ newHeaders.set(key, value);
1773
+ }
1774
+ }
1775
+ if (headers) {
1776
+ for (const [key, value] of headers) {
1777
+ newHeaders.set(key, value);
1778
+ }
1779
+ }
1780
+ return new Event(replyCRI, newHeaders, body || undefined);
1781
+ }
1782
+ }
1783
+
1784
+ // packages/core/src/internal/core/api/ReturnValueConverter.ts
1785
+ class BasicReturnValueConverter {
1786
+ convert(incomingMetadata, returnValue) {
1787
+ return EventUtil.createReplyEvent(incomingMetadata, new Map([["content-type" /* CONTENT_TYPE_HEADER */, "application/json"]]), new TextEncoder().encode(JSON.stringify(returnValue)));
1788
+ }
1789
+ }
1790
+
1791
+ // packages/core/src/internal/core/api/Logger.ts
1792
+ function createDebugLogger(namespace) {
1793
+ let debug2;
1794
+ try {
1795
+ debug2 = __require("debug")(namespace);
1796
+ } catch (e) {
1797
+ debug2 = (...args) => console.debug(`[${namespace}]`, ...args);
1798
+ }
1799
+ return {
1800
+ trace: (...args) => debug2("TRACE", ...args),
1801
+ debug: (...args) => debug2("DEBUG", ...args),
1802
+ info: (...args) => debug2("INFO", ...args),
1803
+ warn: (...args) => debug2("WARN", ...args),
1804
+ error: (...args) => debug2("ERROR", ...args)
1805
+ };
1806
+ }
1807
+
1808
+ // packages/core/src/api/KinoticDecorators.ts
1809
+ var import_reflect_metadata = __toESM(require_Reflect(), 1);
1810
+
1811
+ // packages/core/src/core/api/ServiceIdentifier.ts
1812
+ class ServiceIdentifier {
1813
+ namespace;
1814
+ name;
1815
+ scope;
1816
+ version;
1817
+ _cri = null;
1818
+ constructor(namespace, name) {
1819
+ this.namespace = namespace;
1820
+ this.name = name;
1821
+ }
1822
+ qualifiedName() {
1823
+ return this.namespace + "." + this.name;
1824
+ }
1825
+ cri() {
1826
+ if (this._cri == null) {
1827
+ this._cri = createCRI("srv" /* SERVICE_DESTINATION_SCHEME */, this.scope || null, this.qualifiedName(), null, this.version || null);
1828
+ }
1829
+ return this._cri;
1830
+ }
1831
+ }
1832
+
1833
+ // packages/core/src/api/KinoticDecorators.ts
1834
+ var SCOPE_METADATA_KEY = Symbol("scope");
1835
+ var VERSION_METADATA_KEY = Symbol("version");
1836
+ var CONTEXT_METADATA_KEY = Symbol("context");
1837
+ function Scope(target, propertyKey, descriptor) {
1838
+ Reflect.defineMetadata(SCOPE_METADATA_KEY, propertyKey, target);
1839
+ }
1840
+ function Version(version) {
1841
+ if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9]+)?$/.test(version)) {
1842
+ throw new Error(`Invalid semantic version: ${version}. Must follow X.Y.Z[-optional] format.`);
1843
+ }
1844
+ return function(target) {
1845
+ Reflect.defineMetadata(VERSION_METADATA_KEY, version, target);
1846
+ };
1847
+ }
1848
+ function Context() {
1849
+ return function(target, propertyKey, parameterIndex) {
1850
+ const existingContexts = Reflect.getMetadata(CONTEXT_METADATA_KEY, target, propertyKey) || [];
1851
+ existingContexts.push(parameterIndex);
1852
+ Reflect.defineMetadata(CONTEXT_METADATA_KEY, existingContexts, target, propertyKey);
1853
+ };
1854
+ }
1855
+ function Publish(namespace, name) {
1856
+ return function(target) {
1857
+ const original = target;
1858
+ const serviceIdentifier = new ServiceIdentifier(namespace, name || target.name);
1859
+ const version = Reflect.getMetadata(VERSION_METADATA_KEY, target);
1860
+ if (version) {
1861
+ serviceIdentifier.version = version;
1862
+ }
1863
+ const newConstructor = function(...args) {
1864
+ const instance = Reflect.construct(original, args);
1865
+ const scopeProperty = Reflect.getMetadata(SCOPE_METADATA_KEY, target.prototype);
1866
+ if (scopeProperty) {
1867
+ const scopeValue = instance[scopeProperty];
1868
+ serviceIdentifier.scope = typeof scopeValue === "function" ? scopeValue.call(instance) : scopeValue;
1869
+ }
1870
+ Kinotic.serviceRegistry.register(serviceIdentifier, instance);
1871
+ return instance;
1872
+ };
1873
+ newConstructor.prototype = original.prototype;
1874
+ return newConstructor;
1875
+ };
1876
+ }
1877
+
1878
+ // packages/core/src/internal/core/api/ServiceInvocationSupervisor.ts
1879
+ class ServiceInvocationSupervisor {
1880
+ log;
1881
+ active = false;
1882
+ _eventBus;
1883
+ interceptorProvider;
1884
+ argumentResolver;
1885
+ returnValueConverter;
1886
+ serviceIdentifier;
1887
+ serviceInstance;
1888
+ methodSubscription = null;
1889
+ methodMap;
1890
+ constructor(serviceIdentifier, serviceInstance, eventBusService, interceptorProvider, options = {}) {
1891
+ if (!serviceIdentifier)
1892
+ throw new Error("ServiceIdentifier must not be null");
1893
+ if (!serviceInstance)
1894
+ throw new Error("Service instance must not be null");
1895
+ if (!eventBusService)
1896
+ throw new Error("IEventBus must not be null");
1897
+ if (!interceptorProvider)
1898
+ throw new Error("interceptorProvider must not be null");
1899
+ this.serviceIdentifier = serviceIdentifier;
1900
+ this.serviceInstance = serviceInstance;
1901
+ this._eventBus = eventBusService;
1902
+ this.interceptorProvider = interceptorProvider;
1903
+ this.log = options.logger || createDebugLogger("kinoitc:ServiceInvocationSupervisor");
1904
+ this.argumentResolver = options.argumentResolver || new JsonArgumentResolver;
1905
+ this.returnValueConverter = options.returnValueConverter || new BasicReturnValueConverter;
1906
+ this.methodMap = this.buildMethodMap(serviceInstance);
1907
+ }
1908
+ isActive() {
1909
+ return this.active;
1910
+ }
1911
+ set eventBus(eventBus) {
1912
+ if (this.active) {
1913
+ this.stop();
1914
+ this._eventBus = eventBus;
1915
+ this.start();
1916
+ } else {
1917
+ this._eventBus = eventBus;
1918
+ }
1919
+ }
1920
+ start() {
1921
+ if (this.active) {
1922
+ throw new Error("Service already started");
1923
+ }
1924
+ this.active = true;
1925
+ const criBase = this.serviceIdentifier.cri().baseResource();
1926
+ this.methodSubscription = this._eventBus.observe(criBase).subscribe({
1927
+ next: async (event) => {
1928
+ await this.processEvent(event);
1929
+ },
1930
+ error: (error) => {
1931
+ this.log.error("Event listener error", error);
1932
+ this.active = false;
1933
+ },
1934
+ complete: () => {
1935
+ this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive.");
1936
+ this.active = false;
1937
+ }
1938
+ });
1939
+ this.log.info(`ServiceInvocationSupervisor started for ${criBase}`);
1940
+ }
1941
+ stop() {
1942
+ if (!this.active) {
1943
+ throw new Error("Service already stopped");
1944
+ }
1945
+ this.active = false;
1946
+ if (this.methodSubscription) {
1947
+ this.methodSubscription.unsubscribe();
1948
+ this.methodSubscription = null;
1949
+ }
1950
+ this.log.info("ServiceInvocationSupervisor stopped");
1951
+ }
1952
+ buildMethodMap(serviceInstance) {
1953
+ const methodMap = {};
1954
+ for (const key of Object.getOwnPropertyNames(Object.getPrototypeOf(serviceInstance))) {
1955
+ const method = serviceInstance[key];
1956
+ if (typeof method === "function" && key !== "constructor") {
1957
+ methodMap[key] = method.bind(serviceInstance);
1958
+ }
1959
+ }
1960
+ return methodMap;
1961
+ }
1962
+ async processEvent(event) {
1963
+ const isControl = event.hasHeader("control" /* CONTROL_HEADER */);
1964
+ this.log.trace(`Service ${isControl ? "Control" : "Invocation"} requested for ${event.cri}`);
1965
+ try {
1966
+ if (isControl) {
1967
+ this.processControlPlaneRequest(event);
1968
+ } else {
1969
+ if (this.validateReplyTo(event)) {
1970
+ await this.processInvocationRequest(event);
1971
+ } else {
1972
+ this.log.error(`ReplyTo header missing or invalid. Ignoring event: ${JSON.stringify(event)}`);
1973
+ }
1974
+ }
1975
+ } catch (e) {
1976
+ this.log.debug(`Exception processing service request: ${JSON.stringify(event)}`, e);
1977
+ this.handleException(event, e);
1978
+ }
1979
+ }
1980
+ processControlPlaneRequest(event) {
1981
+ const correlationId = event.getHeader("__correlation-id" /* CORRELATION_ID_HEADER */);
1982
+ if (!correlationId) {
1983
+ throw new Error("Streaming control plane messages require a CORRELATION_ID_HEADER");
1984
+ }
1985
+ this.log.trace(`Processing control event for correlationId: ${correlationId}`);
1986
+ }
1987
+ async processInvocationRequest(event) {
1988
+ const path = createCRI(event.cri).path();
1989
+ if (!path) {
1990
+ throw new Error("The methodId must not be blank");
1991
+ }
1992
+ const handlerMethod = this.methodMap[path];
1993
+ if (!handlerMethod) {
1994
+ throw new Error(`No method resolved for methodId ${path}`);
1995
+ }
1996
+ const methodName = path;
1997
+ const args = this.argumentResolver.resolveArguments(event);
1998
+ const contextIndices = Reflect.getMetadata(CONTEXT_METADATA_KEY, this.serviceInstance, methodName) || [];
1999
+ let context2 = {};
2000
+ const interceptor = this.interceptorProvider();
2001
+ if (interceptor) {
2002
+ try {
2003
+ context2 = await interceptor.intercept(event, context2);
2004
+ } catch (e) {
2005
+ this.log.error(`Interceptor failed to create context for event: ${JSON.stringify(event)}`, e);
2006
+ this.handleException(event, new Error("Internal server error"));
2007
+ return;
2008
+ }
2009
+ }
2010
+ for (const index of contextIndices) {
2011
+ args[index] = context2;
2012
+ }
2013
+ const expectedArgsCount = handlerMethod.length;
2014
+ if (args.length !== expectedArgsCount) {
2015
+ throw new Error(`Argument count mismatch for method ${path}: expected ${expectedArgsCount}, got ${args.length}`);
2016
+ }
2017
+ let result;
2018
+ try {
2019
+ result = handlerMethod(...args);
2020
+ if (result instanceof Promise) {
2021
+ result.then((resolved) => this.processMethodInvocationResult(event, resolved), (error) => this.handleException(event, error));
2022
+ } else {
2023
+ this.processMethodInvocationResult(event, result);
2024
+ }
2025
+ } catch (e) {
2026
+ this.handleException(event, e);
2027
+ }
2028
+ }
2029
+ processMethodInvocationResult(event, result) {
2030
+ const outgoingEvent = this.returnValueConverter.convert(event.headers, result);
2031
+ this._eventBus.send(outgoingEvent);
2032
+ }
2033
+ handleException(event, error) {
2034
+ const errorEvent = EventUtil.createReplyEvent(event.headers, new Map([
2035
+ ["error" /* ERROR_HEADER */, error.message || "Unknown error"],
2036
+ ["content-type" /* CONTENT_TYPE_HEADER */, "application/json"]
2037
+ ]), new TextEncoder().encode(JSON.stringify({ message: error.message })));
2038
+ this._eventBus.send(errorEvent);
2039
+ }
2040
+ validateReplyTo(event) {
2041
+ const replyTo = event.getHeader("reply-to" /* REPLY_TO_HEADER */);
2042
+ if (!replyTo) {
2043
+ this.log.warn("No reply-to header found in event");
2044
+ return false;
2045
+ }
2046
+ if (replyTo.trim() === "") {
2047
+ this.log.warn("Reply-to header must not be blank");
2048
+ return false;
2049
+ }
2050
+ if (!replyTo.startsWith(`${"srv" /* SERVICE_DESTINATION_SCHEME */}:`)) {
2051
+ this.log.warn("Reply-to header must be a valid service destination");
2052
+ return false;
2053
+ }
2054
+ return true;
2055
+ }
2056
+ }
2057
+
2058
+ // packages/core/src/core/api/ServiceRegistry.ts
2059
+ import opentelemetry, { SpanKind, SpanStatusCode } from "@opentelemetry/api";
2060
+ import {
2061
+ ATTR_SERVER_ADDRESS,
2062
+ ATTR_SERVER_PORT
2063
+ } from "@opentelemetry/semantic-conventions";
2064
+ import { first, map as map2 } from "rxjs/operators";
2065
+ // packages/core/package.json
2066
+ var package_default = {
2067
+ name: "@kinotic-ai/core",
2068
+ description: "Kinotic Core",
2069
+ version: "1.0.0-beta.0",
2070
+ type: "module",
2071
+ files: [
2072
+ "dist"
2073
+ ],
2074
+ module: "./dist/index.js",
2075
+ main: "./dist/index.cjs",
2076
+ types: "./dist/index.d.ts",
2077
+ exports: {
2078
+ ".": {
2079
+ import: {
2080
+ types: "./dist/index.d.ts",
2081
+ default: "./dist/index.js"
2082
+ },
2083
+ require: {
2084
+ types: "./dist/index.d.cts",
2085
+ default: "./dist/index.cjs"
2086
+ }
2087
+ },
2088
+ "./package.json": "./package.json"
2089
+ },
2090
+ homepage: "https://github.com/kinotic-ai/kinotic",
2091
+ license: "Elastic License 2.0",
2092
+ publishConfig: {
2093
+ access: "public"
2094
+ },
2095
+ scripts: {
2096
+ "type-check": "tsc --noEmit",
2097
+ test: "vitest run",
2098
+ coverage: "vitest run --coverage",
2099
+ "ui-test": "vitest --ui --coverage.enabled=true --mode development"
2100
+ },
2101
+ devDependencies: {
2102
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.212.0",
2103
+ "@opentelemetry/resources": "^2.5.1",
2104
+ "@opentelemetry/sdk-metrics": "^2.5.1",
2105
+ "@opentelemetry/sdk-node": "^0.212.0",
2106
+ "@opentelemetry/sdk-trace-node": "^2.5.1",
2107
+ "@types/node": "^25.3.2",
2108
+ "@types/uuid": "^11.0.0",
2109
+ "@types/ws": "^8.18.1",
2110
+ "@vitest/coverage-v8": "^4.0.18",
2111
+ "@vitest/runner": "^4.0.18",
2112
+ "@vitest/ui": "^4.0.18",
2113
+ allure: "^3.3.1",
2114
+ "allure-vitest": "^3.5.0",
2115
+ dotenv: "^17.3.1",
2116
+ "properties-file": "^3.6.4",
2117
+ testcontainers: "^11.12.0",
2118
+ tslib: "^2.8.1",
2119
+ typescript: "^5.9.3",
2120
+ vitest: "^4.0.18",
2121
+ ws: "^8.19.0"
2122
+ },
2123
+ dependencies: {
2124
+ "@opentelemetry/api": "^1.9.0",
2125
+ "@opentelemetry/semantic-conventions": "^1.40.0",
2126
+ "@stomp/rx-stomp": "^2.3.0",
2127
+ "@stomp/stompjs": "^7.3.0",
2128
+ "@types/debug": "^4.1.12",
2129
+ debug: "^4.4.3",
2130
+ "p-tap": "^4.0.0",
2131
+ rxjs: "^7.8.2",
2132
+ "typescript-optional": "3.0.0-alpha.3",
2133
+ uuid: "^13.0.0"
2134
+ },
2135
+ peerDependenciesMeta: {
2136
+ typescript: {
2137
+ optional: true
2138
+ }
2139
+ }
2140
+ };
2141
+
2142
+ // packages/core/src/core/api/ServiceRegistry.ts
2143
+ class JsonEventFactory {
2144
+ create(cri, args) {
2145
+ const event = new Event(cri);
2146
+ event.setHeader("content-type" /* CONTENT_TYPE_HEADER */, "application/json" /* CONTENT_JSON */);
2147
+ if (args != null) {
2148
+ event.setDataString(JSON.stringify(args));
2149
+ }
2150
+ return event;
2151
+ }
2152
+ }
2153
+
2154
+ class TextEventFactory {
2155
+ create(cri, args) {
2156
+ const event = new Event(cri);
2157
+ event.setHeader("content-type" /* CONTENT_TYPE_HEADER */, "text/plain" /* CONTENT_TEXT */);
2158
+ if (args != null) {
2159
+ let data = "";
2160
+ let i = 0;
2161
+ for (const arg of args) {
2162
+ if (i > 0) {
2163
+ data = data + `
2164
+ `;
2165
+ }
2166
+ data = data + arg;
2167
+ i++;
2168
+ }
2169
+ if (data.length > 0) {
2170
+ event.setDataString(data);
2171
+ }
2172
+ }
2173
+ return event;
2174
+ }
2175
+ }
2176
+
2177
+ class ServiceRegistry {
2178
+ _eventBus;
2179
+ supervisors = new Map;
2180
+ contextInterceptor = null;
2181
+ debugLogger = debug2("kinoitc:serviceRegistry");
2182
+ constructor(eventBus) {
2183
+ this._eventBus = eventBus;
2184
+ }
2185
+ set eventBus(eventBus) {
2186
+ this._eventBus = eventBus;
2187
+ for (const supervisor of this.supervisors.values()) {
2188
+ supervisor.eventBus = eventBus;
2189
+ }
2190
+ }
2191
+ get eventBus() {
2192
+ return this._eventBus;
2193
+ }
2194
+ serviceProxy(serviceIdentifier) {
2195
+ return new ServiceProxy(serviceIdentifier, this);
2196
+ }
2197
+ register(serviceIdentifier, service) {
2198
+ const criString = serviceIdentifier.cri().raw();
2199
+ if (!this.supervisors.has(criString)) {
2200
+ this.debugLogger(`Registering service for CRI: ${criString}`);
2201
+ const supervisor = new ServiceInvocationSupervisor(serviceIdentifier, service, this.eventBus, () => this.contextInterceptor);
2202
+ this.supervisors.set(criString, supervisor);
2203
+ supervisor.start();
2204
+ }
2205
+ }
2206
+ unRegister(serviceIdentifier) {
2207
+ const criString = serviceIdentifier.cri().raw();
2208
+ const supervisor = this.supervisors.get(criString);
2209
+ if (supervisor) {
2210
+ this.debugLogger(`Unregistering service for CRI: ${criString}`);
2211
+ supervisor.stop();
2212
+ this.supervisors.delete(criString);
2213
+ }
2214
+ }
2215
+ registerContextInterceptor(interceptor) {
2216
+ this.contextInterceptor = interceptor;
2217
+ }
2218
+ }
2219
+ var defaultEventFactory = new JsonEventFactory;
2220
+
2221
+ class ServiceProxy {
2222
+ serviceIdentifier;
2223
+ serviceRegistry;
2224
+ tracer;
2225
+ constructor(serviceIdentifier, serviceRegistry) {
2226
+ if (typeof serviceIdentifier === "undefined" || serviceIdentifier.length === 0) {
2227
+ throw new Error("The serviceIdentifier provided must contain a value");
2228
+ }
2229
+ this.serviceIdentifier = serviceIdentifier;
2230
+ this.serviceRegistry = serviceRegistry;
2231
+ this.tracer = opentelemetry.trace.getTracer("kinoitc.client", package_default.version);
2232
+ }
2233
+ invoke(methodIdentifier, args, scope, eventFactory) {
2234
+ return this.tracer.startActiveSpan(`${this.serviceIdentifier}/${methodIdentifier}`, {
2235
+ kind: SpanKind.CLIENT
2236
+ }, async (span) => {
2237
+ if (scope) {
2238
+ span.setAttribute("kinoitc.scope", scope);
2239
+ }
2240
+ span.setAttribute("rpc.system", "kinoitc");
2241
+ span.setAttribute("rpc.service", this.serviceIdentifier);
2242
+ span.setAttribute("rpc.method", methodIdentifier);
2243
+ return this.__invokeStream(false, methodIdentifier, args, scope, eventFactory).pipe(first()).toPromise().then(async (value) => {
2244
+ span.end();
2245
+ return value;
2246
+ }, async (ex) => {
2247
+ span.recordException(ex);
2248
+ span.setStatus({ code: SpanStatusCode.ERROR });
2249
+ span.end();
2250
+ throw ex;
2251
+ });
2252
+ });
2253
+ }
2254
+ invokeStream(methodIdentifier, args, scope, eventFactory) {
2255
+ return this.__invokeStream(true, methodIdentifier, args, scope, eventFactory);
2256
+ }
2257
+ __invokeStream(sendControlEvents, methodIdentifier, args, scope, eventFactory) {
2258
+ const cri = "srv://" /* SERVICE_DESTINATION_PREFIX */ + (scope != null ? scope + "@" : "") + this.serviceIdentifier + "/" + methodIdentifier;
2259
+ let eventFactoryToUse = defaultEventFactory;
2260
+ if (eventFactory) {
2261
+ eventFactoryToUse = eventFactory;
2262
+ }
2263
+ let eventBusToUse = this.serviceRegistry.eventBus;
2264
+ const span = opentelemetry.trace.getActiveSpan();
2265
+ if (span) {
2266
+ span.setAttribute(ATTR_SERVER_ADDRESS, eventBusToUse.serverInfo?.host || "unknown");
2267
+ span.setAttribute(ATTR_SERVER_PORT, eventBusToUse.serverInfo?.port || "unknown");
2268
+ }
2269
+ let event = eventFactoryToUse.create(cri, args);
2270
+ return eventBusToUse.requestStream(event, sendControlEvents).pipe(map2((value) => {
2271
+ const contentType = value.getHeader("content-type" /* CONTENT_TYPE_HEADER */);
2272
+ if (contentType !== undefined) {
2273
+ if (contentType === "application/json") {
2274
+ return JSON.parse(value.getDataString());
2275
+ } else if (contentType === "text/plain") {
2276
+ return value.getDataString();
2277
+ } else {
2278
+ throw new Error("Content Type " + contentType + " is not supported");
2279
+ }
2280
+ } else {
2281
+ return null;
2282
+ }
2283
+ }));
2284
+ }
2285
+ }
2286
+
2287
+ // packages/core/src/api/Kinotic.ts
2288
+ class KinoticSingleton {
2289
+ _eventBus;
2290
+ serviceRegistry;
2291
+ crudServiceProxyFactory;
2292
+ constructor() {
2293
+ this._eventBus = new EventBus;
2294
+ this.serviceRegistry = new ServiceRegistry(this._eventBus);
2295
+ this.crudServiceProxyFactory = new CrudServiceProxyFactory(this.serviceRegistry);
2296
+ }
2297
+ get eventBus() {
2298
+ return this._eventBus;
2299
+ }
2300
+ set eventBus(eventBus) {
2301
+ this._eventBus = eventBus;
2302
+ this.serviceRegistry.eventBus = eventBus;
2303
+ }
2304
+ connect(connectionInfo) {
2305
+ return this._eventBus.connect(connectionInfo);
2306
+ }
2307
+ disconnect(force) {
2308
+ return this._eventBus.disconnect(force);
2309
+ }
2310
+ serviceProxy(serviceIdentifier) {
2311
+ return this.serviceRegistry.serviceProxy(serviceIdentifier);
2312
+ }
2313
+ crudServiceProxy(serviceIdentifier) {
2314
+ return this.crudServiceProxyFactory.crudServiceProxy(serviceIdentifier);
2315
+ }
2316
+ }
2317
+ var Kinotic = new KinoticSingleton;
2318
+ // packages/core/src/api/ILogManager.ts
2319
+ var LogLevel;
2320
+ ((LogLevel2) => {
2321
+ LogLevel2["TRACE"] = "TRACE";
2322
+ LogLevel2["DEBUG"] = "DEBUG";
2323
+ LogLevel2["INFO"] = "INFO";
2324
+ LogLevel2["WARN"] = "WARN";
2325
+ LogLevel2["ERROR"] = "ERROR";
2326
+ LogLevel2["FATAL"] = "FATAL";
2327
+ LogLevel2["OFF"] = "OFF";
2328
+ })(LogLevel ||= {});
2329
+
2330
+ class LoggerLevelsDescriptor {
2331
+ configuredLevel;
2332
+ }
2333
+
2334
+ class GroupLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
2335
+ members = [];
2336
+ }
2337
+
2338
+ class SingleLoggerLevelsDescriptor extends LoggerLevelsDescriptor {
2339
+ effectiveLevel;
2340
+ }
2341
+
2342
+ class LoggersDescriptor {
2343
+ levels = [];
2344
+ loggerLevels = new Map;
2345
+ groups = new Map;
2346
+ }
2347
+ // packages/core/src/api/LogManager.ts
2348
+ class LogManager {
2349
+ serviceProxy;
2350
+ constructor() {
2351
+ this.serviceProxy = Kinotic.serviceProxy("org.kinotic.kinoitc.api.log.LogManager");
2352
+ }
2353
+ loggers(nodeId) {
2354
+ return this.serviceProxy.invoke("loggers", null, nodeId);
2355
+ }
2356
+ async loggerLevels(nodeId, name) {
2357
+ const data = await this.serviceProxy.invoke("loggerLevels", [name], nodeId);
2358
+ let ret = null;
2359
+ if (data.hasOwnProperty("members")) {
2360
+ ret = new GroupLoggerLevelsDescriptor;
2361
+ } else if (data.hasOwnProperty("effectiveLevel")) {
2362
+ ret = new SingleLoggerLevelsDescriptor;
2363
+ } else {
2364
+ ret = new LoggerLevelsDescriptor;
2365
+ }
2366
+ Object.assign(ret, data);
2367
+ return ret;
2368
+ }
2369
+ configureLogLevel(nodeId, name, level) {
2370
+ return this.serviceProxy.invoke("configureLogLevel", [name, level], nodeId);
2371
+ }
2372
+ }
2373
+ var logManager = new LogManager;
2374
+ // packages/core/src/api/errors/AuthenticationError.ts
2375
+ class AuthenticationError extends KinoticError {
2376
+ constructor(message) {
2377
+ super(message);
2378
+ Object.setPrototypeOf(this, AuthenticationError.prototype);
2379
+ }
2380
+ }
2381
+ // packages/core/src/api/errors/AuthorizationError.ts
2382
+ class AuthorizationError extends KinoticError {
2383
+ constructor(message) {
2384
+ super(message);
2385
+ Object.setPrototypeOf(this, AuthorizationError.prototype);
2386
+ }
2387
+ }
2388
+ // packages/core/src/api/security/ConnectedInfo.ts
2389
+ class ConnectedInfo {
2390
+ sessionId;
2391
+ replyToId;
2392
+ participant;
2393
+ }
2394
+ // packages/core/src/api/security/Participant.ts
2395
+ class Participant {
2396
+ id;
2397
+ tenantId;
2398
+ metadata;
2399
+ roles;
2400
+ constructor(id, tenantId, metadata, roles) {
2401
+ this.id = id;
2402
+ this.tenantId = tenantId;
2403
+ this.metadata = metadata || new Map;
2404
+ this.roles = roles || [];
2405
+ }
2406
+ }
2407
+ // packages/core/src/api/security/ParticipantConstants.ts
2408
+ class ParticipantConstants {
2409
+ static PARTICIPANT_TYPE_METADATA_KEY = "type";
2410
+ static PARTICIPANT_TYPE_DEVICE = "device";
2411
+ static PARTICIPANT_TYPE_CLI = "cli";
2412
+ static PARTICIPANT_TYPE_USER = "user";
2413
+ static PARTICIPANT_TYPE_NODE = "node";
2414
+ static CLI_PARTICIPANT_ID = "-42-Kinotic-CLI-42-";
2415
+ }
2416
+ // packages/core/src/core/api/StreamData.ts
2417
+ var StreamOperation;
2418
+ ((StreamOperation2) => {
2419
+ StreamOperation2["EXISTING"] = "EXISTING";
2420
+ StreamOperation2["UPDATE"] = "UPDATE";
2421
+ StreamOperation2["REMOVE"] = "REMOVE";
2422
+ })(StreamOperation ||= {});
2423
+
2424
+ class StreamData {
2425
+ streamOperation;
2426
+ id;
2427
+ value;
2428
+ constructor(streamOperation, id, value) {
2429
+ this.streamOperation = streamOperation;
2430
+ this.id = id;
2431
+ this.value = value;
2432
+ }
2433
+ isSet() {
2434
+ return this.value !== null && this.value !== undefined;
2435
+ }
2436
+ }
2437
+ // packages/core/src/core/api/crud/FunctionalIterablePage.ts
2438
+ class FunctionalIterablePage extends AbstractIterablePage {
2439
+ pageFunction;
2440
+ constructor(pageable, page, pageFunction) {
2441
+ super(pageable, page);
2442
+ this.pageFunction = pageFunction;
2443
+ }
2444
+ findNext(pageable) {
2445
+ return this.pageFunction(pageable);
2446
+ }
2447
+ }
2448
+ // packages/core/src/core/api/crud/IDataSource.ts
2449
+ class DataSourceUtils {
2450
+ static instanceOfEditableDataSource(datasource) {
2451
+ return "create" in datasource;
2452
+ }
2453
+ }
2454
+ // packages/core/src/core/api/crud/Pageable.ts
2455
+ class Pageable {
2456
+ sort = null;
2457
+ pageSize = 25;
2458
+ static create(pageNumber, pageSize, sort) {
2459
+ return new OffsetPageable(pageNumber, pageSize, sort);
2460
+ }
2461
+ static createWithCursor(cursor, pageSize, sort) {
2462
+ return new CursorPageable(cursor, pageSize, sort);
2463
+ }
2464
+ }
2465
+
2466
+ class OffsetPageable extends Pageable {
2467
+ pageNumber = 0;
2468
+ constructor(pageNumber, pageSize, sort) {
2469
+ super();
2470
+ this.pageNumber = pageNumber;
2471
+ this.pageSize = pageSize;
2472
+ this.sort = sort;
2473
+ }
2474
+ }
2475
+
2476
+ class CursorPageable extends Pageable {
2477
+ cursor;
2478
+ constructor(cursor, pageSize, sort) {
2479
+ super();
2480
+ this.cursor = cursor;
2481
+ this.pageSize = pageSize;
2482
+ this.sort = sort;
2483
+ }
2484
+ }
2485
+ // packages/core/src/core/api/crud/Sort.ts
2486
+ var Direction;
2487
+ ((Direction2) => {
2488
+ Direction2["ASC"] = "ASC";
2489
+ Direction2["DESC"] = "DESC";
2490
+ })(Direction ||= {});
2491
+ var NullHandling;
2492
+ ((NullHandling2) => {
2493
+ NullHandling2["NATIVE"] = "NATIVE";
2494
+ NullHandling2["NULLS_FIRST"] = "NULLS_FIRST";
2495
+ NullHandling2["NULLS_LAST"] = "NULLS_LAST";
2496
+ })(NullHandling ||= {});
2497
+
2498
+ class Order {
2499
+ property;
2500
+ direction = "ASC" /* ASC */;
2501
+ nullHandling = "NATIVE" /* NATIVE */;
2502
+ constructor(property, direction) {
2503
+ this.property = property;
2504
+ if (direction !== null) {
2505
+ this.direction = direction;
2506
+ }
2507
+ }
2508
+ isAscending() {
2509
+ return this.direction === "ASC" /* ASC */;
2510
+ }
2511
+ isDescending() {
2512
+ return this.direction === "DESC" /* DESC */;
2513
+ }
2514
+ }
2515
+
2516
+ class Sort {
2517
+ orders = [];
2518
+ }
2519
+ export {
2520
+ logManager,
2521
+ createCRI,
2522
+ Version,
2523
+ TextEventFactory,
2524
+ StreamOperation,
2525
+ StreamData,
2526
+ Sort,
2527
+ SingleLoggerLevelsDescriptor,
2528
+ ServiceRegistry,
2529
+ ServerInfo,
2530
+ Scope,
2531
+ Publish,
2532
+ ParticipantConstants,
2533
+ Participant,
2534
+ Pageable,
2535
+ Order,
2536
+ OffsetPageable,
2537
+ NullHandling,
2538
+ LoggersDescriptor,
2539
+ LoggerLevelsDescriptor,
2540
+ LogManager,
2541
+ LogLevel,
2542
+ KinoticSingleton,
2543
+ KinoticError,
2544
+ Kinotic,
2545
+ JsonEventFactory,
2546
+ GroupLoggerLevelsDescriptor,
2547
+ FunctionalIterablePage,
2548
+ EventConstants,
2549
+ EventBus,
2550
+ Event,
2551
+ Direction,
2552
+ DefaultCRI,
2553
+ DataSourceUtils,
2554
+ CursorPageable,
2555
+ CrudServiceProxyFactory,
2556
+ CrudServiceProxy,
2557
+ Context,
2558
+ ConnectionInfo,
2559
+ ConnectedInfo,
2560
+ ConnectHeaders,
2561
+ CONTEXT_METADATA_KEY,
2562
+ AuthorizationError,
2563
+ AuthenticationError,
2564
+ AbstractIterablePage
2565
+ };