@kinotic-ai/core 3.0.0 → 4.0.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.cjs +127 -93
- package/dist/index.d.cts +55 -35
- package/dist/index.d.ts +55 -35
- package/dist/index.js +127 -96
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -67,9 +67,10 @@ __export(exports_src, {
|
|
|
67
67
|
validateZone: () => validateZone,
|
|
68
68
|
validateLabel: () => validateLabel,
|
|
69
69
|
receivesContext: () => receivesContext,
|
|
70
|
+
isAdvertised: () => isAdvertised,
|
|
70
71
|
createCRI: () => createCRI,
|
|
71
72
|
createAuthenticatedWebSocketFactory: () => createAuthenticatedWebSocketFactory,
|
|
72
|
-
|
|
73
|
+
Zone: () => Zone,
|
|
73
74
|
Version: () => Version,
|
|
74
75
|
TextEventFactory: () => TextEventFactory,
|
|
75
76
|
Sort: () => Sort,
|
|
@@ -610,12 +611,15 @@ class EventBus {
|
|
|
610
611
|
}
|
|
611
612
|
|
|
612
613
|
// packages/core/src/api/ServiceRegistry.ts
|
|
613
|
-
var
|
|
614
|
+
var import_debug3 = __toESM(require("debug"));
|
|
614
615
|
|
|
615
616
|
// packages/core/src/api/event/DefaultCRI.ts
|
|
617
|
+
var ZONE_DELIMITER = "~";
|
|
618
|
+
|
|
616
619
|
class DefaultCRI {
|
|
617
620
|
_scheme;
|
|
618
621
|
_scope;
|
|
622
|
+
_zone;
|
|
619
623
|
_resourceName;
|
|
620
624
|
_path;
|
|
621
625
|
_version;
|
|
@@ -629,24 +633,42 @@ class DefaultCRI {
|
|
|
629
633
|
const parsed = DefaultCRI.parseRaw(rawURC);
|
|
630
634
|
this._scheme = parsed.scheme;
|
|
631
635
|
this._scope = parsed.scope;
|
|
632
|
-
|
|
636
|
+
const [zone, resourceName] = DefaultCRI.splitZone(parsed.resourceName);
|
|
637
|
+
this._zone = zone;
|
|
638
|
+
this._resourceName = resourceName;
|
|
633
639
|
this._path = parsed.path;
|
|
634
640
|
this._version = parsed.version;
|
|
635
|
-
this._raw = rawURC;
|
|
636
641
|
} else if (args.length === 5) {
|
|
637
642
|
const [scheme, scope, resourceName, path, version] = args;
|
|
643
|
+
if (scope && scope.includes("@")) {
|
|
644
|
+
throw new Error(`The scope must not contain '@' but was '${scope}'`);
|
|
645
|
+
}
|
|
646
|
+
if (resourceName.includes("@")) {
|
|
647
|
+
throw new Error(`The resourceName must not contain '@' but was '${resourceName}'`);
|
|
648
|
+
}
|
|
638
649
|
this._scheme = scheme;
|
|
639
|
-
this._scope = scope;
|
|
640
|
-
|
|
650
|
+
this._scope = scope ?? null;
|
|
651
|
+
const [zone, name] = DefaultCRI.splitZone(resourceName);
|
|
652
|
+
this._zone = zone;
|
|
653
|
+
this._resourceName = name;
|
|
641
654
|
this._path = path;
|
|
642
655
|
this._version = version;
|
|
643
|
-
this._raw = DefaultCRI.buildRaw(scheme, scope, resourceName, path, version);
|
|
644
656
|
} else {
|
|
645
657
|
throw new Error("Invalid constructor arguments for DefaultCRI");
|
|
646
658
|
}
|
|
659
|
+
this._raw = DefaultCRI.buildRaw(this._scheme, this._scope, this._zone, this._resourceName, this._path, this._version);
|
|
647
660
|
if (!this._scheme || !this._resourceName) {
|
|
648
661
|
throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`);
|
|
649
662
|
}
|
|
663
|
+
if (this._scope !== null && this._scope.includes(ZONE_DELIMITER)) {
|
|
664
|
+
throw new Error(`The scope must not contain '~' but was '${this._scope}'`);
|
|
665
|
+
}
|
|
666
|
+
if (this._resourceName.includes(ZONE_DELIMITER)) {
|
|
667
|
+
throw new Error(`The resourceName must not contain '~' but was '${this._resourceName}'`);
|
|
668
|
+
}
|
|
669
|
+
if (this._resourceName.includes("@") || this._zone !== null && this._zone.includes("@")) {
|
|
670
|
+
throw new Error(`The authority must contain at most one '@' but was '${this._raw}'`);
|
|
671
|
+
}
|
|
650
672
|
}
|
|
651
673
|
scheme() {
|
|
652
674
|
return this._scheme;
|
|
@@ -657,6 +679,12 @@ class DefaultCRI {
|
|
|
657
679
|
hasScope() {
|
|
658
680
|
return this._scope !== null;
|
|
659
681
|
}
|
|
682
|
+
zone() {
|
|
683
|
+
return this._zone;
|
|
684
|
+
}
|
|
685
|
+
hasZone() {
|
|
686
|
+
return this._zone !== null;
|
|
687
|
+
}
|
|
660
688
|
resourceName() {
|
|
661
689
|
return this._resourceName;
|
|
662
690
|
}
|
|
@@ -677,6 +705,9 @@ class DefaultCRI {
|
|
|
677
705
|
if (this.hasScope()) {
|
|
678
706
|
result += `${this._scope}@`;
|
|
679
707
|
}
|
|
708
|
+
if (this.hasZone()) {
|
|
709
|
+
result += `${this._zone}${ZONE_DELIMITER}`;
|
|
710
|
+
}
|
|
680
711
|
result += this._resourceName;
|
|
681
712
|
return result;
|
|
682
713
|
}
|
|
@@ -698,6 +729,10 @@ class DefaultCRI {
|
|
|
698
729
|
toString() {
|
|
699
730
|
return this._raw;
|
|
700
731
|
}
|
|
732
|
+
static splitZone(hostPart) {
|
|
733
|
+
const delimiter = hostPart.indexOf(ZONE_DELIMITER);
|
|
734
|
+
return delimiter >= 0 ? [hostPart.substring(0, delimiter), hostPart.substring(delimiter + 1)] : [null, hostPart];
|
|
735
|
+
}
|
|
701
736
|
static parseRaw(raw) {
|
|
702
737
|
const regex = /^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/;
|
|
703
738
|
const match = raw.match(regex);
|
|
@@ -713,11 +748,14 @@ class DefaultCRI {
|
|
|
713
748
|
version: version || null
|
|
714
749
|
};
|
|
715
750
|
}
|
|
716
|
-
static buildRaw(scheme, scope, resourceName, path, version) {
|
|
751
|
+
static buildRaw(scheme, scope, zone, resourceName, path, version) {
|
|
717
752
|
let result = `${scheme}://`;
|
|
718
753
|
if (scope) {
|
|
719
754
|
result += `${scope}@`;
|
|
720
755
|
}
|
|
756
|
+
if (zone) {
|
|
757
|
+
result += `${zone}${ZONE_DELIMITER}`;
|
|
758
|
+
}
|
|
721
759
|
result += resourceName;
|
|
722
760
|
if (path) {
|
|
723
761
|
result += `/${path}`;
|
|
@@ -766,19 +804,15 @@ class BasicReturnValueConverter {
|
|
|
766
804
|
}
|
|
767
805
|
|
|
768
806
|
// packages/core/src/internal/api/Logger.ts
|
|
807
|
+
var import_debug2 = __toESM(require("debug"));
|
|
769
808
|
function createDebugLogger(namespace) {
|
|
770
|
-
|
|
771
|
-
try {
|
|
772
|
-
debug2 = require("debug")(namespace);
|
|
773
|
-
} catch (e) {
|
|
774
|
-
debug2 = (...args) => console.debug(`[${namespace}]`, ...args);
|
|
775
|
-
}
|
|
809
|
+
const debugLogger = import_debug2.default(namespace);
|
|
776
810
|
return {
|
|
777
|
-
trace: (...args) =>
|
|
778
|
-
debug: (...args) =>
|
|
779
|
-
info: (...args) =>
|
|
780
|
-
warn: (...args) =>
|
|
781
|
-
error: (...args) =>
|
|
811
|
+
trace: (...args) => debugLogger("TRACE", ...args),
|
|
812
|
+
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
813
|
+
info: (...args) => debugLogger("INFO", ...args),
|
|
814
|
+
warn: (...args) => debugLogger("WARN", ...args),
|
|
815
|
+
error: (...args) => debugLogger("ERROR", ...args)
|
|
782
816
|
};
|
|
783
817
|
}
|
|
784
818
|
|
|
@@ -786,54 +820,51 @@ function createDebugLogger(namespace) {
|
|
|
786
820
|
class ServiceIdentifier {
|
|
787
821
|
namespace;
|
|
788
822
|
name;
|
|
789
|
-
|
|
823
|
+
zone;
|
|
790
824
|
scope;
|
|
791
825
|
version;
|
|
792
|
-
|
|
793
|
-
constructor(namespace, name,
|
|
826
|
+
_cri = null;
|
|
827
|
+
constructor(namespace, name, zone) {
|
|
828
|
+
if (name.includes(".")) {
|
|
829
|
+
throw new Error(`The name must not contain '.' but was '${name}'`);
|
|
830
|
+
}
|
|
831
|
+
if (namespace != null && namespace.includes("_")) {
|
|
832
|
+
throw new Error(`The namespace must not contain '_' but was '${namespace}'`);
|
|
833
|
+
}
|
|
834
|
+
if (name.includes("~")) {
|
|
835
|
+
throw new Error(`The name must not contain '~' but was '${name}'`);
|
|
836
|
+
}
|
|
837
|
+
if (namespace != null && namespace.includes("~")) {
|
|
838
|
+
throw new Error(`The namespace must not contain '~' but was '${namespace}'`);
|
|
839
|
+
}
|
|
794
840
|
this.namespace = namespace;
|
|
795
841
|
this.name = name;
|
|
796
|
-
this.
|
|
842
|
+
this.zone = zone;
|
|
797
843
|
}
|
|
798
844
|
qualifiedName() {
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
}
|
|
802
|
-
return this.qualifiedNameFor(this.zones?.[0]);
|
|
803
|
-
}
|
|
804
|
-
cris() {
|
|
805
|
-
if (this._cris == null) {
|
|
806
|
-
const zones = this.zones && this.zones.length > 0 ? this.zones : [undefined];
|
|
807
|
-
this._cris = zones.map((zone) => createCRI("srv" /* SERVICE_DESTINATION_SCHEME */, this.scope || null, this.qualifiedNameFor(zone), null, this.version || null));
|
|
808
|
-
}
|
|
809
|
-
return this._cris;
|
|
845
|
+
const name = this.namespace ? this.namespace + "." + this.name : this.name;
|
|
846
|
+
return this.zone ? this.zone + "~" + name : name;
|
|
810
847
|
}
|
|
811
848
|
cri() {
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
if (cris.length !== 1 || !cri) {
|
|
815
|
-
throw new Error(`ServiceIdentifier has ${cris.length} cris so there is no single cri`);
|
|
849
|
+
if (this._cri == null) {
|
|
850
|
+
this._cri = createCRI("srv" /* SERVICE_DESTINATION_SCHEME */, this.scope || null, this.qualifiedName(), null, this.version || null);
|
|
816
851
|
}
|
|
817
|
-
return
|
|
818
|
-
}
|
|
819
|
-
qualifiedNameFor(zone) {
|
|
820
|
-
const name = this.namespace ? this.namespace + "." + this.name : this.name;
|
|
821
|
-
return zone ? zone + "." + name : name;
|
|
852
|
+
return this._cri;
|
|
822
853
|
}
|
|
823
854
|
}
|
|
824
855
|
|
|
825
856
|
// packages/core/src/api/ZoneUtil.ts
|
|
826
|
-
var LABEL = "[a-z0-9]([a-z0-
|
|
857
|
+
var LABEL = "[a-z0-9]([a-z0-9-]*[a-z0-9])?";
|
|
827
858
|
var LABEL_PATTERN = new RegExp(`^${LABEL}$`);
|
|
828
859
|
var ZONE_PATTERN = new RegExp(`^${LABEL}(\\.${LABEL})*$`);
|
|
829
860
|
function validateZone(zone) {
|
|
830
861
|
if (!zone || !ZONE_PATTERN.test(zone)) {
|
|
831
|
-
throw new Error(`Invalid zone '${zone}'. Zones must be dot separated labels of lowercase letters, digits, and interior dashes
|
|
862
|
+
throw new Error(`Invalid zone '${zone}'. Zones must be dot separated labels of lowercase letters, digits, and interior dashes`);
|
|
832
863
|
}
|
|
833
864
|
}
|
|
834
865
|
function validateLabel(label) {
|
|
835
866
|
if (!label || !LABEL_PATTERN.test(label)) {
|
|
836
|
-
throw new Error(`Invalid zone label '${label}'. Labels must be lowercase letters, digits, and interior dashes
|
|
867
|
+
throw new Error(`Invalid zone label '${label}'. Labels must be lowercase letters, digits, and interior dashes`);
|
|
837
868
|
}
|
|
838
869
|
}
|
|
839
870
|
|
|
@@ -841,6 +872,7 @@ function validateLabel(label) {
|
|
|
841
872
|
var scopeFunctions = new WeakSet;
|
|
842
873
|
var versionRegistry = new WeakMap;
|
|
843
874
|
var zonesRegistry = new WeakMap;
|
|
875
|
+
var advertisedRegistry = new WeakMap;
|
|
844
876
|
var contextMarkedFunctions = new WeakSet;
|
|
845
877
|
function findInConstructorChain(registry, constructor) {
|
|
846
878
|
let current = constructor;
|
|
@@ -883,14 +915,15 @@ function Version(version) {
|
|
|
883
915
|
versionRegistry.set(value, version);
|
|
884
916
|
};
|
|
885
917
|
}
|
|
886
|
-
function
|
|
887
|
-
|
|
888
|
-
validateZone(zone);
|
|
889
|
-
}
|
|
918
|
+
function Zone(zone) {
|
|
919
|
+
validateZone(zone);
|
|
890
920
|
return function(value, _context) {
|
|
891
|
-
zonesRegistry.set(value,
|
|
921
|
+
zonesRegistry.set(value, zone);
|
|
892
922
|
};
|
|
893
923
|
}
|
|
924
|
+
function isAdvertised(serviceInstance) {
|
|
925
|
+
return findInConstructorChain(advertisedRegistry, serviceInstance.constructor) === true;
|
|
926
|
+
}
|
|
894
927
|
function Context(value, _context) {
|
|
895
928
|
contextMarkedFunctions.add(value);
|
|
896
929
|
}
|
|
@@ -898,29 +931,30 @@ function receivesContext(serviceInstance, methodName) {
|
|
|
898
931
|
const method = serviceInstance[methodName];
|
|
899
932
|
return typeof method === "function" && contextMarkedFunctions.has(method);
|
|
900
933
|
}
|
|
901
|
-
function
|
|
902
|
-
const
|
|
934
|
+
function resolveEffectiveZone(constructor) {
|
|
935
|
+
const declaredZone = findInConstructorChain(zonesRegistry, constructor) ?? Kinotic.defaultZone;
|
|
903
936
|
const prefix = Kinotic.zonePrefix;
|
|
904
|
-
let
|
|
905
|
-
if (prefix != null &&
|
|
906
|
-
|
|
937
|
+
let effectiveZone;
|
|
938
|
+
if (prefix != null && declaredZone != null) {
|
|
939
|
+
effectiveZone = `${prefix}.${declaredZone}`;
|
|
907
940
|
} else if (prefix != null) {
|
|
908
|
-
|
|
941
|
+
effectiveZone = prefix;
|
|
909
942
|
} else {
|
|
910
|
-
|
|
943
|
+
effectiveZone = declaredZone ?? null;
|
|
911
944
|
}
|
|
912
|
-
|
|
913
|
-
validateZone(
|
|
945
|
+
if (effectiveZone != null) {
|
|
946
|
+
validateZone(effectiveZone);
|
|
914
947
|
}
|
|
915
|
-
return
|
|
948
|
+
return effectiveZone;
|
|
916
949
|
}
|
|
917
|
-
function Publish(namespace, name) {
|
|
950
|
+
function Publish(namespace, name, advertise = false) {
|
|
918
951
|
return function(value, _context) {
|
|
952
|
+
advertisedRegistry.set(value, advertise);
|
|
919
953
|
return class extends value {
|
|
920
954
|
constructor(...args) {
|
|
921
955
|
super(...args);
|
|
922
|
-
const
|
|
923
|
-
const serviceIdentifier = new ServiceIdentifier(namespace ?? null, name || value.name,
|
|
956
|
+
const zone = resolveEffectiveZone(this.constructor);
|
|
957
|
+
const serviceIdentifier = new ServiceIdentifier(namespace ?? null, name || value.name, zone ?? undefined);
|
|
924
958
|
const version = findInConstructorChain(versionRegistry, this.constructor);
|
|
925
959
|
if (version) {
|
|
926
960
|
serviceIdentifier.version = version;
|
|
@@ -945,7 +979,7 @@ class ServiceInvocationSupervisor {
|
|
|
945
979
|
returnValueConverter;
|
|
946
980
|
serviceIdentifier;
|
|
947
981
|
serviceInstance;
|
|
948
|
-
|
|
982
|
+
methodSubscription = null;
|
|
949
983
|
methodMap;
|
|
950
984
|
constructor(serviceIdentifier, serviceInstance, eventBusService, interceptorProvider, options = {}) {
|
|
951
985
|
if (!serviceIdentifier)
|
|
@@ -982,33 +1016,29 @@ class ServiceInvocationSupervisor {
|
|
|
982
1016
|
throw new Error("Service already started");
|
|
983
1017
|
}
|
|
984
1018
|
this.active = true;
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
error
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
this.log.info(`ServiceInvocationSupervisor started for ${criBase}`);
|
|
1001
|
-
}
|
|
1019
|
+
const criBase = this.serviceIdentifier.cri().baseResource();
|
|
1020
|
+
this.methodSubscription = this._eventBus.observe(criBase).subscribe({
|
|
1021
|
+
next: async (event) => {
|
|
1022
|
+
await this.processEvent(event);
|
|
1023
|
+
},
|
|
1024
|
+
error: (error) => {
|
|
1025
|
+
this.log.error("Event listener error", error);
|
|
1026
|
+
this.active = false;
|
|
1027
|
+
},
|
|
1028
|
+
complete: () => {
|
|
1029
|
+
this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive.");
|
|
1030
|
+
this.active = false;
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
this.log.info(`ServiceInvocationSupervisor started for ${criBase}`);
|
|
1002
1034
|
}
|
|
1003
1035
|
stop() {
|
|
1004
1036
|
if (!this.active) {
|
|
1005
1037
|
throw new Error("Service already stopped");
|
|
1006
1038
|
}
|
|
1007
1039
|
this.active = false;
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
this.methodSubscriptions = [];
|
|
1040
|
+
this.methodSubscription?.unsubscribe();
|
|
1041
|
+
this.methodSubscription = null;
|
|
1012
1042
|
this.log.info("ServiceInvocationSupervisor stopped");
|
|
1013
1043
|
}
|
|
1014
1044
|
buildMethodMap(serviceInstance) {
|
|
@@ -1128,7 +1158,7 @@ var import_operators2 = require("rxjs/operators");
|
|
|
1128
1158
|
// packages/core/package.json
|
|
1129
1159
|
var package_default = {
|
|
1130
1160
|
name: "@kinotic-ai/core",
|
|
1131
|
-
version: "
|
|
1161
|
+
version: "4.0.0",
|
|
1132
1162
|
type: "module",
|
|
1133
1163
|
files: [
|
|
1134
1164
|
"dist"
|
|
@@ -1240,7 +1270,7 @@ class ServiceRegistry {
|
|
|
1240
1270
|
_eventBus;
|
|
1241
1271
|
supervisors = new Map;
|
|
1242
1272
|
contextInterceptor = null;
|
|
1243
|
-
debugLogger =
|
|
1273
|
+
debugLogger = import_debug3.default("kinoitc:serviceRegistry");
|
|
1244
1274
|
constructor(eventBus) {
|
|
1245
1275
|
this._eventBus = eventBus;
|
|
1246
1276
|
}
|
|
@@ -1257,7 +1287,7 @@ class ServiceRegistry {
|
|
|
1257
1287
|
return new ServiceProxy(serviceIdentifier, this);
|
|
1258
1288
|
}
|
|
1259
1289
|
register(serviceIdentifier, service) {
|
|
1260
|
-
const criString = serviceIdentifier.
|
|
1290
|
+
const criString = serviceIdentifier.cri().raw();
|
|
1261
1291
|
if (!this.supervisors.has(criString)) {
|
|
1262
1292
|
this.debugLogger(`Registering service for CRI: ${criString}`);
|
|
1263
1293
|
const supervisor = new ServiceInvocationSupervisor(serviceIdentifier, service, this.eventBus, () => this.contextInterceptor);
|
|
@@ -1266,7 +1296,7 @@ class ServiceRegistry {
|
|
|
1266
1296
|
}
|
|
1267
1297
|
}
|
|
1268
1298
|
unRegister(serviceIdentifier) {
|
|
1269
|
-
const criString = serviceIdentifier.
|
|
1299
|
+
const criString = serviceIdentifier.cri().raw();
|
|
1270
1300
|
const supervisor = this.supervisors.get(criString);
|
|
1271
1301
|
if (supervisor) {
|
|
1272
1302
|
this.debugLogger(`Unregistering service for CRI: ${criString}`);
|
|
@@ -1353,7 +1383,7 @@ class KinoticSingleton {
|
|
|
1353
1383
|
_eventBus;
|
|
1354
1384
|
serviceRegistry;
|
|
1355
1385
|
zonePrefix = null;
|
|
1356
|
-
|
|
1386
|
+
defaultZone = null;
|
|
1357
1387
|
constructor() {
|
|
1358
1388
|
this._eventBus = new EventBus;
|
|
1359
1389
|
this.serviceRegistry = new ServiceRegistry(this._eventBus);
|
|
@@ -1622,8 +1652,12 @@ function createAuthenticatedWebSocketFactory(serverInfo, authProvider) {
|
|
|
1622
1652
|
class BasicAuthProvider {
|
|
1623
1653
|
authHeader;
|
|
1624
1654
|
constructor(login, passcode) {
|
|
1625
|
-
const
|
|
1626
|
-
|
|
1655
|
+
const bytes = new TextEncoder().encode(`${login}:${passcode}`);
|
|
1656
|
+
let binary = "";
|
|
1657
|
+
for (const byte of bytes) {
|
|
1658
|
+
binary += String.fromCharCode(byte);
|
|
1659
|
+
}
|
|
1660
|
+
this.authHeader = `Basic ${btoa(binary)}`;
|
|
1627
1661
|
}
|
|
1628
1662
|
getAuthHeaders() {
|
|
1629
1663
|
return { Authorization: this.authHeader };
|
package/dist/index.d.cts
CHANGED
|
@@ -338,10 +338,12 @@ interface ContextInterceptor<T extends ServiceContext> {
|
|
|
338
338
|
*
|
|
339
339
|
* Will be in a format as follows where anything surrounded with `[]` is optional:
|
|
340
340
|
*
|
|
341
|
-
* scheme://[scope@]resourceName[/path][#version]
|
|
341
|
+
* scheme://[scope@][zone~]resourceName[/path][#version]
|
|
342
342
|
*
|
|
343
343
|
* NOTE: If scope needs to be used to identify a sub-scope, it will follow the form `scope = scope:sub-scope`.
|
|
344
344
|
*
|
|
345
|
+
* Every part keeps the case it was written with; addresses match by exact string comparison.
|
|
346
|
+
*
|
|
345
347
|
* This format can have varied meanings based upon the scheme used.
|
|
346
348
|
*
|
|
347
349
|
* @author Navid Mitchell
|
|
@@ -367,6 +369,23 @@ interface CRI {
|
|
|
367
369
|
*/
|
|
368
370
|
hasScope(): boolean;
|
|
369
371
|
/**
|
|
372
|
+
* The zone this `CRI` is addressed in, or `null` if un-zoned.
|
|
373
|
+
*
|
|
374
|
+
* The zone is the isolation boundary routing is validated against, such as
|
|
375
|
+
* `app.acme-org.orders-app` or `os-api`.
|
|
376
|
+
*
|
|
377
|
+
* For the following CRI, `zone` would be the portion specified by `zone`:
|
|
378
|
+
*
|
|
379
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
380
|
+
*
|
|
381
|
+
* @returns a string containing the zone if provided or `null` if not set
|
|
382
|
+
*/
|
|
383
|
+
zone(): string | null;
|
|
384
|
+
/**
|
|
385
|
+
* @returns `true` if the `zone` is set
|
|
386
|
+
*/
|
|
387
|
+
hasZone(): boolean;
|
|
388
|
+
/**
|
|
370
389
|
* The name of the resource represented by this `CRI`.
|
|
371
390
|
*
|
|
372
391
|
* In the case of a `srv` `CRI`, this will be the service name.
|
|
@@ -374,7 +393,7 @@ interface CRI {
|
|
|
374
393
|
*
|
|
375
394
|
* For the following CRI, `resourceName` would be the portion specified by `resourceName`:
|
|
376
395
|
*
|
|
377
|
-
* `scheme://[scope@]resourceName/path`
|
|
396
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
378
397
|
*
|
|
379
398
|
* @returns the string containing the name of this resource
|
|
380
399
|
*/
|
|
@@ -394,7 +413,7 @@ interface CRI {
|
|
|
394
413
|
*
|
|
395
414
|
* For the following CRI, `path` would be the portion specified by `path`:
|
|
396
415
|
*
|
|
397
|
-
* `scheme://[scope@]resourceName/path`
|
|
416
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
398
417
|
*
|
|
399
418
|
* @returns the path string if provided or `null` if not set
|
|
400
419
|
*/
|
|
@@ -406,7 +425,7 @@ interface CRI {
|
|
|
406
425
|
/**
|
|
407
426
|
* Base Resource is a portion of the fully qualified `CRI` containing the following:
|
|
408
427
|
*
|
|
409
|
-
* `scheme://[scope@]resourceName`
|
|
428
|
+
* `scheme://[scope@][zone~]resourceName`
|
|
410
429
|
*
|
|
411
430
|
* @returns string containing the baseResource
|
|
412
431
|
*/
|
|
@@ -456,32 +475,22 @@ declare function createCRI(scheme: string, scope: string | null, resourceName: s
|
|
|
456
475
|
declare class ServiceIdentifier {
|
|
457
476
|
namespace: string | null;
|
|
458
477
|
name: string;
|
|
459
|
-
|
|
478
|
+
zone?: string;
|
|
460
479
|
scope?: string;
|
|
461
480
|
version?: string;
|
|
462
|
-
private
|
|
463
|
-
constructor(namespace: string | null, name: string,
|
|
481
|
+
private _cri;
|
|
482
|
+
constructor(namespace: string | null, name: string, zone?: string);
|
|
464
483
|
/**
|
|
465
484
|
* Returns the fully qualified name this {@link ServiceIdentifier} is addressed by
|
|
466
|
-
* This is the zone
|
|
485
|
+
* This is the zone~namespace.name, omitting any part that is not set
|
|
467
486
|
* @return string containing the qualified name
|
|
468
|
-
* @throws if this {@link ServiceIdentifier} has more than one zone and therefore more than
|
|
469
|
-
* one qualified name
|
|
470
487
|
*/
|
|
471
488
|
qualifiedName(): string;
|
|
472
489
|
/**
|
|
473
|
-
* The {@link CRI}s this {@link ServiceIdentifier} is addressable by, one per zone
|
|
474
|
-
* @return the cris for this {@link ServiceIdentifier}, never empty
|
|
475
|
-
*/
|
|
476
|
-
cris(): CRI[];
|
|
477
|
-
/**
|
|
478
490
|
* The {@link CRI} that represents this {@link ServiceIdentifier}
|
|
479
491
|
* @return the cri for this {@link ServiceIdentifier}
|
|
480
|
-
* @throws if this {@link ServiceIdentifier} has more than one zone and therefore more than
|
|
481
|
-
* one cri
|
|
482
492
|
*/
|
|
483
493
|
cri(): CRI;
|
|
484
|
-
private qualifiedNameFor;
|
|
485
494
|
}
|
|
486
495
|
import { Observable as Observable2 } from "rxjs";
|
|
487
496
|
/**
|
|
@@ -599,10 +608,10 @@ interface IKinotic {
|
|
|
599
608
|
*/
|
|
600
609
|
zonePrefix: string | null;
|
|
601
610
|
/**
|
|
602
|
-
* The
|
|
603
|
-
* own, typically loaded from the project package.json `kinotic.
|
|
611
|
+
* The zone applied to published services that carry no {@link Zone} declaration of their
|
|
612
|
+
* own, typically loaded from the project package.json `kinotic.zone` field.
|
|
604
613
|
*/
|
|
605
|
-
|
|
614
|
+
defaultZone: string | null;
|
|
606
615
|
/**
|
|
607
616
|
* Requests a connection to the given Stomp url
|
|
608
617
|
* @param connectionInfo provides the information needed to connect to the kinoitc server
|
|
@@ -641,7 +650,7 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
641
650
|
*/
|
|
642
651
|
readonly serviceRegistry: ServiceRegistry;
|
|
643
652
|
zonePrefix: string | null;
|
|
644
|
-
|
|
653
|
+
defaultZone: string | null;
|
|
645
654
|
constructor();
|
|
646
655
|
get eventBus(): IEventBus;
|
|
647
656
|
set eventBus(eventBus: IEventBus);
|
|
@@ -685,15 +694,20 @@ declare function Scope(value: Function, _context: ClassGetterDecoratorContext |
|
|
|
685
694
|
*/
|
|
686
695
|
declare function Version(version: string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
687
696
|
/**
|
|
688
|
-
* Declares the
|
|
689
|
-
* declared
|
|
690
|
-
* can never leave its own `app.<organizationId>.<applicationId>` zone.
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
* @param
|
|
694
|
-
*
|
|
697
|
+
* Declares the zone a service is addressable in, relative to this client's trust context: the
|
|
698
|
+
* declared zone is appended to {@link KinoticSingleton#zonePrefix}, so an application's service
|
|
699
|
+
* can never leave its own `app.<organizationId>.<applicationId>` zone. When absent,
|
|
700
|
+
* {@link KinoticSingleton#defaultZone} (typically loaded from the project package.json
|
|
701
|
+
* `kinotic.zone` field) applies.
|
|
702
|
+
* @param zone one or more dot separated labels of lowercase letters, digits, and interior
|
|
703
|
+
* dashes, e.g. `billing` or `billing.internal`
|
|
704
|
+
*/
|
|
705
|
+
declare function Zone(zone: string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
706
|
+
/**
|
|
707
|
+
* Returns whether the given service instance's class was published with `advertise` set.
|
|
708
|
+
* @param serviceInstance the service instance to inspect
|
|
695
709
|
*/
|
|
696
|
-
declare function
|
|
710
|
+
declare function isAdvertised(serviceInstance: object): boolean;
|
|
697
711
|
/**
|
|
698
712
|
* Marks a service method that receives the {@link ServiceContext} produced by the registered
|
|
699
713
|
* {@link ContextInterceptor}. The context parameter MUST be the method's final parameter:
|
|
@@ -708,24 +722,26 @@ declare function Context(value: Function, _context: ClassMethodDecoratorContext)
|
|
|
708
722
|
declare function receivesContext(serviceInstance: object, methodName: string): boolean;
|
|
709
723
|
/**
|
|
710
724
|
* Registers each instance of the decorated class with the Kinotic ServiceRegistry.
|
|
711
|
-
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link
|
|
725
|
+
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link Zone}
|
|
712
726
|
* on the same class refine the registration.
|
|
713
727
|
* @param namespace the optional namespace the service is published under
|
|
714
728
|
* @param name the service name, defaults to the class name
|
|
729
|
+
* @param advertise when true the service advertises itself in the platform ServiceDirectory,
|
|
730
|
+
* so it appears in directory listings
|
|
715
731
|
*/
|
|
716
|
-
declare function Publish(namespace?: string | null, name?: string): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
|
|
732
|
+
declare function Publish(namespace?: string | null, name?: string, advertise?: boolean): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
|
|
717
733
|
/**
|
|
718
734
|
* Validates that the given zone satisfies the zone grammar
|
|
719
735
|
* @param zone the zone to validate
|
|
720
736
|
* @throws if the zone is empty or contains anything other than dot separated labels of
|
|
721
|
-
* lowercase letters, digits, and interior dashes
|
|
737
|
+
* lowercase letters, digits, and interior dashes
|
|
722
738
|
*/
|
|
723
739
|
declare function validateZone(zone: string): void;
|
|
724
740
|
/**
|
|
725
741
|
* Validates that the given value is a single zone label
|
|
726
742
|
* @param label the label to validate
|
|
727
743
|
* @throws if the label is empty or is not a single label of lowercase letters, digits, and
|
|
728
|
-
* interior dashes
|
|
744
|
+
* interior dashes
|
|
729
745
|
*/
|
|
730
746
|
declare function validateLabel(label: string): void;
|
|
731
747
|
/**
|
|
@@ -1097,6 +1113,7 @@ declare class FunctionalIterablePage<T> extends AbstractIterablePage<T> {
|
|
|
1097
1113
|
declare class DefaultCRI implements CRI {
|
|
1098
1114
|
private readonly _scheme;
|
|
1099
1115
|
private readonly _scope;
|
|
1116
|
+
private readonly _zone;
|
|
1100
1117
|
private readonly _resourceName;
|
|
1101
1118
|
private readonly _path;
|
|
1102
1119
|
private readonly _version;
|
|
@@ -1106,6 +1123,8 @@ declare class DefaultCRI implements CRI {
|
|
|
1106
1123
|
scheme(): string;
|
|
1107
1124
|
scope(): string | null;
|
|
1108
1125
|
hasScope(): boolean;
|
|
1126
|
+
zone(): string | null;
|
|
1127
|
+
hasZone(): boolean;
|
|
1109
1128
|
resourceName(): string;
|
|
1110
1129
|
version(): string | null;
|
|
1111
1130
|
hasVersion(): boolean;
|
|
@@ -1116,6 +1135,7 @@ declare class DefaultCRI implements CRI {
|
|
|
1116
1135
|
equals(other: any): boolean;
|
|
1117
1136
|
hashCode(): number;
|
|
1118
1137
|
toString(): string;
|
|
1138
|
+
private static splitZone;
|
|
1119
1139
|
private static parseRaw;
|
|
1120
1140
|
private static buildRaw;
|
|
1121
1141
|
}
|
|
@@ -1246,4 +1266,4 @@ declare class ParticipantConstants {
|
|
|
1246
1266
|
static readonly PARTICIPANT_TYPE_NODE: string;
|
|
1247
1267
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1248
1268
|
}
|
|
1249
|
-
export { validateZone, validateLabel, receivesContext, createCRI, createAuthenticatedWebSocketFactory,
|
|
1269
|
+
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, createAuthenticatedWebSocketFactory, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, ServiceRegistry, ServiceContext, ServerInfo, Scope, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, IAuthProvider, FunctionalIterablePage, EventConstants, EventBus, Event, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, ContextInterceptor, Context, ConnectionInfo, ConnectedInfo, CRI, BearerTokenAuthProvider, BasicAuthProvider, AbstractIterablePage };
|
package/dist/index.d.ts
CHANGED
|
@@ -338,10 +338,12 @@ interface ContextInterceptor<T extends ServiceContext> {
|
|
|
338
338
|
*
|
|
339
339
|
* Will be in a format as follows where anything surrounded with `[]` is optional:
|
|
340
340
|
*
|
|
341
|
-
* scheme://[scope@]resourceName[/path][#version]
|
|
341
|
+
* scheme://[scope@][zone~]resourceName[/path][#version]
|
|
342
342
|
*
|
|
343
343
|
* NOTE: If scope needs to be used to identify a sub-scope, it will follow the form `scope = scope:sub-scope`.
|
|
344
344
|
*
|
|
345
|
+
* Every part keeps the case it was written with; addresses match by exact string comparison.
|
|
346
|
+
*
|
|
345
347
|
* This format can have varied meanings based upon the scheme used.
|
|
346
348
|
*
|
|
347
349
|
* @author Navid Mitchell
|
|
@@ -367,6 +369,23 @@ interface CRI {
|
|
|
367
369
|
*/
|
|
368
370
|
hasScope(): boolean;
|
|
369
371
|
/**
|
|
372
|
+
* The zone this `CRI` is addressed in, or `null` if un-zoned.
|
|
373
|
+
*
|
|
374
|
+
* The zone is the isolation boundary routing is validated against, such as
|
|
375
|
+
* `app.acme-org.orders-app` or `os-api`.
|
|
376
|
+
*
|
|
377
|
+
* For the following CRI, `zone` would be the portion specified by `zone`:
|
|
378
|
+
*
|
|
379
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
380
|
+
*
|
|
381
|
+
* @returns a string containing the zone if provided or `null` if not set
|
|
382
|
+
*/
|
|
383
|
+
zone(): string | null;
|
|
384
|
+
/**
|
|
385
|
+
* @returns `true` if the `zone` is set
|
|
386
|
+
*/
|
|
387
|
+
hasZone(): boolean;
|
|
388
|
+
/**
|
|
370
389
|
* The name of the resource represented by this `CRI`.
|
|
371
390
|
*
|
|
372
391
|
* In the case of a `srv` `CRI`, this will be the service name.
|
|
@@ -374,7 +393,7 @@ interface CRI {
|
|
|
374
393
|
*
|
|
375
394
|
* For the following CRI, `resourceName` would be the portion specified by `resourceName`:
|
|
376
395
|
*
|
|
377
|
-
* `scheme://[scope@]resourceName/path`
|
|
396
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
378
397
|
*
|
|
379
398
|
* @returns the string containing the name of this resource
|
|
380
399
|
*/
|
|
@@ -394,7 +413,7 @@ interface CRI {
|
|
|
394
413
|
*
|
|
395
414
|
* For the following CRI, `path` would be the portion specified by `path`:
|
|
396
415
|
*
|
|
397
|
-
* `scheme://[scope@]resourceName/path`
|
|
416
|
+
* `scheme://[scope@][zone~]resourceName/path`
|
|
398
417
|
*
|
|
399
418
|
* @returns the path string if provided or `null` if not set
|
|
400
419
|
*/
|
|
@@ -406,7 +425,7 @@ interface CRI {
|
|
|
406
425
|
/**
|
|
407
426
|
* Base Resource is a portion of the fully qualified `CRI` containing the following:
|
|
408
427
|
*
|
|
409
|
-
* `scheme://[scope@]resourceName`
|
|
428
|
+
* `scheme://[scope@][zone~]resourceName`
|
|
410
429
|
*
|
|
411
430
|
* @returns string containing the baseResource
|
|
412
431
|
*/
|
|
@@ -456,32 +475,22 @@ declare function createCRI(scheme: string, scope: string | null, resourceName: s
|
|
|
456
475
|
declare class ServiceIdentifier {
|
|
457
476
|
namespace: string | null;
|
|
458
477
|
name: string;
|
|
459
|
-
|
|
478
|
+
zone?: string;
|
|
460
479
|
scope?: string;
|
|
461
480
|
version?: string;
|
|
462
|
-
private
|
|
463
|
-
constructor(namespace: string | null, name: string,
|
|
481
|
+
private _cri;
|
|
482
|
+
constructor(namespace: string | null, name: string, zone?: string);
|
|
464
483
|
/**
|
|
465
484
|
* Returns the fully qualified name this {@link ServiceIdentifier} is addressed by
|
|
466
|
-
* This is the zone
|
|
485
|
+
* This is the zone~namespace.name, omitting any part that is not set
|
|
467
486
|
* @return string containing the qualified name
|
|
468
|
-
* @throws if this {@link ServiceIdentifier} has more than one zone and therefore more than
|
|
469
|
-
* one qualified name
|
|
470
487
|
*/
|
|
471
488
|
qualifiedName(): string;
|
|
472
489
|
/**
|
|
473
|
-
* The {@link CRI}s this {@link ServiceIdentifier} is addressable by, one per zone
|
|
474
|
-
* @return the cris for this {@link ServiceIdentifier}, never empty
|
|
475
|
-
*/
|
|
476
|
-
cris(): CRI[];
|
|
477
|
-
/**
|
|
478
490
|
* The {@link CRI} that represents this {@link ServiceIdentifier}
|
|
479
491
|
* @return the cri for this {@link ServiceIdentifier}
|
|
480
|
-
* @throws if this {@link ServiceIdentifier} has more than one zone and therefore more than
|
|
481
|
-
* one cri
|
|
482
492
|
*/
|
|
483
493
|
cri(): CRI;
|
|
484
|
-
private qualifiedNameFor;
|
|
485
494
|
}
|
|
486
495
|
import { Observable as Observable2 } from "rxjs";
|
|
487
496
|
/**
|
|
@@ -599,10 +608,10 @@ interface IKinotic {
|
|
|
599
608
|
*/
|
|
600
609
|
zonePrefix: string | null;
|
|
601
610
|
/**
|
|
602
|
-
* The
|
|
603
|
-
* own, typically loaded from the project package.json `kinotic.
|
|
611
|
+
* The zone applied to published services that carry no {@link Zone} declaration of their
|
|
612
|
+
* own, typically loaded from the project package.json `kinotic.zone` field.
|
|
604
613
|
*/
|
|
605
|
-
|
|
614
|
+
defaultZone: string | null;
|
|
606
615
|
/**
|
|
607
616
|
* Requests a connection to the given Stomp url
|
|
608
617
|
* @param connectionInfo provides the information needed to connect to the kinoitc server
|
|
@@ -641,7 +650,7 @@ declare class KinoticSingleton implements IKinotic {
|
|
|
641
650
|
*/
|
|
642
651
|
readonly serviceRegistry: ServiceRegistry;
|
|
643
652
|
zonePrefix: string | null;
|
|
644
|
-
|
|
653
|
+
defaultZone: string | null;
|
|
645
654
|
constructor();
|
|
646
655
|
get eventBus(): IEventBus;
|
|
647
656
|
set eventBus(eventBus: IEventBus);
|
|
@@ -685,15 +694,20 @@ declare function Scope(value: Function, _context: ClassGetterDecoratorContext |
|
|
|
685
694
|
*/
|
|
686
695
|
declare function Version(version: string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
687
696
|
/**
|
|
688
|
-
* Declares the
|
|
689
|
-
* declared
|
|
690
|
-
* can never leave its own `app.<organizationId>.<applicationId>` zone.
|
|
691
|
-
*
|
|
692
|
-
*
|
|
693
|
-
* @param
|
|
694
|
-
*
|
|
697
|
+
* Declares the zone a service is addressable in, relative to this client's trust context: the
|
|
698
|
+
* declared zone is appended to {@link KinoticSingleton#zonePrefix}, so an application's service
|
|
699
|
+
* can never leave its own `app.<organizationId>.<applicationId>` zone. When absent,
|
|
700
|
+
* {@link KinoticSingleton#defaultZone} (typically loaded from the project package.json
|
|
701
|
+
* `kinotic.zone` field) applies.
|
|
702
|
+
* @param zone one or more dot separated labels of lowercase letters, digits, and interior
|
|
703
|
+
* dashes, e.g. `billing` or `billing.internal`
|
|
704
|
+
*/
|
|
705
|
+
declare function Zone(zone: string): (value: Function, _context: ClassDecoratorContext<any>) => void;
|
|
706
|
+
/**
|
|
707
|
+
* Returns whether the given service instance's class was published with `advertise` set.
|
|
708
|
+
* @param serviceInstance the service instance to inspect
|
|
695
709
|
*/
|
|
696
|
-
declare function
|
|
710
|
+
declare function isAdvertised(serviceInstance: object): boolean;
|
|
697
711
|
/**
|
|
698
712
|
* Marks a service method that receives the {@link ServiceContext} produced by the registered
|
|
699
713
|
* {@link ContextInterceptor}. The context parameter MUST be the method's final parameter:
|
|
@@ -708,24 +722,26 @@ declare function Context(value: Function, _context: ClassMethodDecoratorContext)
|
|
|
708
722
|
declare function receivesContext(serviceInstance: object, methodName: string): boolean;
|
|
709
723
|
/**
|
|
710
724
|
* Registers each instance of the decorated class with the Kinotic ServiceRegistry.
|
|
711
|
-
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link
|
|
725
|
+
* The service name defaults to the class name; {@link Version}, {@link Scope}, and {@link Zone}
|
|
712
726
|
* on the same class refine the registration.
|
|
713
727
|
* @param namespace the optional namespace the service is published under
|
|
714
728
|
* @param name the service name, defaults to the class name
|
|
729
|
+
* @param advertise when true the service advertises itself in the platform ServiceDirectory,
|
|
730
|
+
* so it appears in directory listings
|
|
715
731
|
*/
|
|
716
|
-
declare function Publish(namespace?: string | null, name?: string): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
|
|
732
|
+
declare function Publish(namespace?: string | null, name?: string, advertise?: boolean): <T extends new (...args: any[]) => object>(value: T, _context: ClassDecoratorContext<any>) => T;
|
|
717
733
|
/**
|
|
718
734
|
* Validates that the given zone satisfies the zone grammar
|
|
719
735
|
* @param zone the zone to validate
|
|
720
736
|
* @throws if the zone is empty or contains anything other than dot separated labels of
|
|
721
|
-
* lowercase letters, digits, and interior dashes
|
|
737
|
+
* lowercase letters, digits, and interior dashes
|
|
722
738
|
*/
|
|
723
739
|
declare function validateZone(zone: string): void;
|
|
724
740
|
/**
|
|
725
741
|
* Validates that the given value is a single zone label
|
|
726
742
|
* @param label the label to validate
|
|
727
743
|
* @throws if the label is empty or is not a single label of lowercase letters, digits, and
|
|
728
|
-
* interior dashes
|
|
744
|
+
* interior dashes
|
|
729
745
|
*/
|
|
730
746
|
declare function validateLabel(label: string): void;
|
|
731
747
|
/**
|
|
@@ -1097,6 +1113,7 @@ declare class FunctionalIterablePage<T> extends AbstractIterablePage<T> {
|
|
|
1097
1113
|
declare class DefaultCRI implements CRI {
|
|
1098
1114
|
private readonly _scheme;
|
|
1099
1115
|
private readonly _scope;
|
|
1116
|
+
private readonly _zone;
|
|
1100
1117
|
private readonly _resourceName;
|
|
1101
1118
|
private readonly _path;
|
|
1102
1119
|
private readonly _version;
|
|
@@ -1106,6 +1123,8 @@ declare class DefaultCRI implements CRI {
|
|
|
1106
1123
|
scheme(): string;
|
|
1107
1124
|
scope(): string | null;
|
|
1108
1125
|
hasScope(): boolean;
|
|
1126
|
+
zone(): string | null;
|
|
1127
|
+
hasZone(): boolean;
|
|
1109
1128
|
resourceName(): string;
|
|
1110
1129
|
version(): string | null;
|
|
1111
1130
|
hasVersion(): boolean;
|
|
@@ -1116,6 +1135,7 @@ declare class DefaultCRI implements CRI {
|
|
|
1116
1135
|
equals(other: any): boolean;
|
|
1117
1136
|
hashCode(): number;
|
|
1118
1137
|
toString(): string;
|
|
1138
|
+
private static splitZone;
|
|
1119
1139
|
private static parseRaw;
|
|
1120
1140
|
private static buildRaw;
|
|
1121
1141
|
}
|
|
@@ -1246,4 +1266,4 @@ declare class ParticipantConstants {
|
|
|
1246
1266
|
static readonly PARTICIPANT_TYPE_NODE: string;
|
|
1247
1267
|
static readonly CLI_PARTICIPANT_ID: string;
|
|
1248
1268
|
}
|
|
1249
|
-
export { validateZone, validateLabel, receivesContext, createCRI, createAuthenticatedWebSocketFactory,
|
|
1269
|
+
export { validateZone, validateLabel, receivesContext, isAdvertised, createCRI, createAuthenticatedWebSocketFactory, Zone, WebSocketFactory, Version, TextEventFactory, Sort, SessionKeepAliveMode, ServiceRegistry, ServiceContext, ServerInfo, Scope, Publish, ParticipantConstants, Participant, Pageable, Page, Order, OffsetPageable, NullHandling, KinoticSingleton, KinoticPlugin, Kinotic, JsonEventFactory, IterablePage, Identifiable, IWebSocket, IServiceRegistry, IServiceProxy, IParticipant, IKinotic, IEventFactory, IEventBus, IEvent, IEditableDataSource, IDataSource, ICrudServiceProxyFactory, ICrudServiceProxy, IAuthProvider, FunctionalIterablePage, EventConstants, EventBus, Event, Direction, DefaultCRI, DataSourceUtils, CursorPageable, CrudServiceProxyFactory, CrudServiceProxy, ContextInterceptor, Context, ConnectionInfo, ConnectedInfo, CRI, BearerTokenAuthProvider, BasicAuthProvider, AbstractIterablePage };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
1
|
// packages/core/src/api/ConnectionInfo.ts
|
|
5
2
|
class ServerInfo {
|
|
6
3
|
host;
|
|
@@ -506,12 +503,15 @@ class EventBus {
|
|
|
506
503
|
}
|
|
507
504
|
|
|
508
505
|
// packages/core/src/api/ServiceRegistry.ts
|
|
509
|
-
import
|
|
506
|
+
import debug3 from "debug";
|
|
510
507
|
|
|
511
508
|
// packages/core/src/api/event/DefaultCRI.ts
|
|
509
|
+
var ZONE_DELIMITER = "~";
|
|
510
|
+
|
|
512
511
|
class DefaultCRI {
|
|
513
512
|
_scheme;
|
|
514
513
|
_scope;
|
|
514
|
+
_zone;
|
|
515
515
|
_resourceName;
|
|
516
516
|
_path;
|
|
517
517
|
_version;
|
|
@@ -525,24 +525,42 @@ class DefaultCRI {
|
|
|
525
525
|
const parsed = DefaultCRI.parseRaw(rawURC);
|
|
526
526
|
this._scheme = parsed.scheme;
|
|
527
527
|
this._scope = parsed.scope;
|
|
528
|
-
|
|
528
|
+
const [zone, resourceName] = DefaultCRI.splitZone(parsed.resourceName);
|
|
529
|
+
this._zone = zone;
|
|
530
|
+
this._resourceName = resourceName;
|
|
529
531
|
this._path = parsed.path;
|
|
530
532
|
this._version = parsed.version;
|
|
531
|
-
this._raw = rawURC;
|
|
532
533
|
} else if (args.length === 5) {
|
|
533
534
|
const [scheme, scope, resourceName, path, version] = args;
|
|
535
|
+
if (scope && scope.includes("@")) {
|
|
536
|
+
throw new Error(`The scope must not contain '@' but was '${scope}'`);
|
|
537
|
+
}
|
|
538
|
+
if (resourceName.includes("@")) {
|
|
539
|
+
throw new Error(`The resourceName must not contain '@' but was '${resourceName}'`);
|
|
540
|
+
}
|
|
534
541
|
this._scheme = scheme;
|
|
535
|
-
this._scope = scope;
|
|
536
|
-
|
|
542
|
+
this._scope = scope ?? null;
|
|
543
|
+
const [zone, name] = DefaultCRI.splitZone(resourceName);
|
|
544
|
+
this._zone = zone;
|
|
545
|
+
this._resourceName = name;
|
|
537
546
|
this._path = path;
|
|
538
547
|
this._version = version;
|
|
539
|
-
this._raw = DefaultCRI.buildRaw(scheme, scope, resourceName, path, version);
|
|
540
548
|
} else {
|
|
541
549
|
throw new Error("Invalid constructor arguments for DefaultCRI");
|
|
542
550
|
}
|
|
551
|
+
this._raw = DefaultCRI.buildRaw(this._scheme, this._scope, this._zone, this._resourceName, this._path, this._version);
|
|
543
552
|
if (!this._scheme || !this._resourceName) {
|
|
544
553
|
throw new Error(`Invalid CRI: scheme and resourceName are required. Got: ${this._raw}`);
|
|
545
554
|
}
|
|
555
|
+
if (this._scope !== null && this._scope.includes(ZONE_DELIMITER)) {
|
|
556
|
+
throw new Error(`The scope must not contain '~' but was '${this._scope}'`);
|
|
557
|
+
}
|
|
558
|
+
if (this._resourceName.includes(ZONE_DELIMITER)) {
|
|
559
|
+
throw new Error(`The resourceName must not contain '~' but was '${this._resourceName}'`);
|
|
560
|
+
}
|
|
561
|
+
if (this._resourceName.includes("@") || this._zone !== null && this._zone.includes("@")) {
|
|
562
|
+
throw new Error(`The authority must contain at most one '@' but was '${this._raw}'`);
|
|
563
|
+
}
|
|
546
564
|
}
|
|
547
565
|
scheme() {
|
|
548
566
|
return this._scheme;
|
|
@@ -553,6 +571,12 @@ class DefaultCRI {
|
|
|
553
571
|
hasScope() {
|
|
554
572
|
return this._scope !== null;
|
|
555
573
|
}
|
|
574
|
+
zone() {
|
|
575
|
+
return this._zone;
|
|
576
|
+
}
|
|
577
|
+
hasZone() {
|
|
578
|
+
return this._zone !== null;
|
|
579
|
+
}
|
|
556
580
|
resourceName() {
|
|
557
581
|
return this._resourceName;
|
|
558
582
|
}
|
|
@@ -573,6 +597,9 @@ class DefaultCRI {
|
|
|
573
597
|
if (this.hasScope()) {
|
|
574
598
|
result += `${this._scope}@`;
|
|
575
599
|
}
|
|
600
|
+
if (this.hasZone()) {
|
|
601
|
+
result += `${this._zone}${ZONE_DELIMITER}`;
|
|
602
|
+
}
|
|
576
603
|
result += this._resourceName;
|
|
577
604
|
return result;
|
|
578
605
|
}
|
|
@@ -594,6 +621,10 @@ class DefaultCRI {
|
|
|
594
621
|
toString() {
|
|
595
622
|
return this._raw;
|
|
596
623
|
}
|
|
624
|
+
static splitZone(hostPart) {
|
|
625
|
+
const delimiter = hostPart.indexOf(ZONE_DELIMITER);
|
|
626
|
+
return delimiter >= 0 ? [hostPart.substring(0, delimiter), hostPart.substring(delimiter + 1)] : [null, hostPart];
|
|
627
|
+
}
|
|
597
628
|
static parseRaw(raw) {
|
|
598
629
|
const regex = /^([^:]+):\/\/(?:([^@]+)@)?([^\/#]+)(\/[^#]*)?(?:#(.+))?$/;
|
|
599
630
|
const match = raw.match(regex);
|
|
@@ -609,11 +640,14 @@ class DefaultCRI {
|
|
|
609
640
|
version: version || null
|
|
610
641
|
};
|
|
611
642
|
}
|
|
612
|
-
static buildRaw(scheme, scope, resourceName, path, version) {
|
|
643
|
+
static buildRaw(scheme, scope, zone, resourceName, path, version) {
|
|
613
644
|
let result = `${scheme}://`;
|
|
614
645
|
if (scope) {
|
|
615
646
|
result += `${scope}@`;
|
|
616
647
|
}
|
|
648
|
+
if (zone) {
|
|
649
|
+
result += `${zone}${ZONE_DELIMITER}`;
|
|
650
|
+
}
|
|
617
651
|
result += resourceName;
|
|
618
652
|
if (path) {
|
|
619
653
|
result += `/${path}`;
|
|
@@ -662,19 +696,15 @@ class BasicReturnValueConverter {
|
|
|
662
696
|
}
|
|
663
697
|
|
|
664
698
|
// packages/core/src/internal/api/Logger.ts
|
|
699
|
+
import debug2 from "debug";
|
|
665
700
|
function createDebugLogger(namespace) {
|
|
666
|
-
|
|
667
|
-
try {
|
|
668
|
-
debug2 = __require("debug")(namespace);
|
|
669
|
-
} catch (e) {
|
|
670
|
-
debug2 = (...args) => console.debug(`[${namespace}]`, ...args);
|
|
671
|
-
}
|
|
701
|
+
const debugLogger = debug2(namespace);
|
|
672
702
|
return {
|
|
673
|
-
trace: (...args) =>
|
|
674
|
-
debug: (...args) =>
|
|
675
|
-
info: (...args) =>
|
|
676
|
-
warn: (...args) =>
|
|
677
|
-
error: (...args) =>
|
|
703
|
+
trace: (...args) => debugLogger("TRACE", ...args),
|
|
704
|
+
debug: (...args) => debugLogger("DEBUG", ...args),
|
|
705
|
+
info: (...args) => debugLogger("INFO", ...args),
|
|
706
|
+
warn: (...args) => debugLogger("WARN", ...args),
|
|
707
|
+
error: (...args) => debugLogger("ERROR", ...args)
|
|
678
708
|
};
|
|
679
709
|
}
|
|
680
710
|
|
|
@@ -682,54 +712,51 @@ function createDebugLogger(namespace) {
|
|
|
682
712
|
class ServiceIdentifier {
|
|
683
713
|
namespace;
|
|
684
714
|
name;
|
|
685
|
-
|
|
715
|
+
zone;
|
|
686
716
|
scope;
|
|
687
717
|
version;
|
|
688
|
-
|
|
689
|
-
constructor(namespace, name,
|
|
718
|
+
_cri = null;
|
|
719
|
+
constructor(namespace, name, zone) {
|
|
720
|
+
if (name.includes(".")) {
|
|
721
|
+
throw new Error(`The name must not contain '.' but was '${name}'`);
|
|
722
|
+
}
|
|
723
|
+
if (namespace != null && namespace.includes("_")) {
|
|
724
|
+
throw new Error(`The namespace must not contain '_' but was '${namespace}'`);
|
|
725
|
+
}
|
|
726
|
+
if (name.includes("~")) {
|
|
727
|
+
throw new Error(`The name must not contain '~' but was '${name}'`);
|
|
728
|
+
}
|
|
729
|
+
if (namespace != null && namespace.includes("~")) {
|
|
730
|
+
throw new Error(`The namespace must not contain '~' but was '${namespace}'`);
|
|
731
|
+
}
|
|
690
732
|
this.namespace = namespace;
|
|
691
733
|
this.name = name;
|
|
692
|
-
this.
|
|
734
|
+
this.zone = zone;
|
|
693
735
|
}
|
|
694
736
|
qualifiedName() {
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}
|
|
698
|
-
return this.qualifiedNameFor(this.zones?.[0]);
|
|
699
|
-
}
|
|
700
|
-
cris() {
|
|
701
|
-
if (this._cris == null) {
|
|
702
|
-
const zones = this.zones && this.zones.length > 0 ? this.zones : [undefined];
|
|
703
|
-
this._cris = zones.map((zone) => createCRI("srv" /* SERVICE_DESTINATION_SCHEME */, this.scope || null, this.qualifiedNameFor(zone), null, this.version || null));
|
|
704
|
-
}
|
|
705
|
-
return this._cris;
|
|
737
|
+
const name = this.namespace ? this.namespace + "." + this.name : this.name;
|
|
738
|
+
return this.zone ? this.zone + "~" + name : name;
|
|
706
739
|
}
|
|
707
740
|
cri() {
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
if (cris.length !== 1 || !cri) {
|
|
711
|
-
throw new Error(`ServiceIdentifier has ${cris.length} cris so there is no single cri`);
|
|
741
|
+
if (this._cri == null) {
|
|
742
|
+
this._cri = createCRI("srv" /* SERVICE_DESTINATION_SCHEME */, this.scope || null, this.qualifiedName(), null, this.version || null);
|
|
712
743
|
}
|
|
713
|
-
return
|
|
714
|
-
}
|
|
715
|
-
qualifiedNameFor(zone) {
|
|
716
|
-
const name = this.namespace ? this.namespace + "." + this.name : this.name;
|
|
717
|
-
return zone ? zone + "." + name : name;
|
|
744
|
+
return this._cri;
|
|
718
745
|
}
|
|
719
746
|
}
|
|
720
747
|
|
|
721
748
|
// packages/core/src/api/ZoneUtil.ts
|
|
722
|
-
var LABEL = "[a-z0-9]([a-z0-
|
|
749
|
+
var LABEL = "[a-z0-9]([a-z0-9-]*[a-z0-9])?";
|
|
723
750
|
var LABEL_PATTERN = new RegExp(`^${LABEL}$`);
|
|
724
751
|
var ZONE_PATTERN = new RegExp(`^${LABEL}(\\.${LABEL})*$`);
|
|
725
752
|
function validateZone(zone) {
|
|
726
753
|
if (!zone || !ZONE_PATTERN.test(zone)) {
|
|
727
|
-
throw new Error(`Invalid zone '${zone}'. Zones must be dot separated labels of lowercase letters, digits, and interior dashes
|
|
754
|
+
throw new Error(`Invalid zone '${zone}'. Zones must be dot separated labels of lowercase letters, digits, and interior dashes`);
|
|
728
755
|
}
|
|
729
756
|
}
|
|
730
757
|
function validateLabel(label) {
|
|
731
758
|
if (!label || !LABEL_PATTERN.test(label)) {
|
|
732
|
-
throw new Error(`Invalid zone label '${label}'. Labels must be lowercase letters, digits, and interior dashes
|
|
759
|
+
throw new Error(`Invalid zone label '${label}'. Labels must be lowercase letters, digits, and interior dashes`);
|
|
733
760
|
}
|
|
734
761
|
}
|
|
735
762
|
|
|
@@ -737,6 +764,7 @@ function validateLabel(label) {
|
|
|
737
764
|
var scopeFunctions = new WeakSet;
|
|
738
765
|
var versionRegistry = new WeakMap;
|
|
739
766
|
var zonesRegistry = new WeakMap;
|
|
767
|
+
var advertisedRegistry = new WeakMap;
|
|
740
768
|
var contextMarkedFunctions = new WeakSet;
|
|
741
769
|
function findInConstructorChain(registry, constructor) {
|
|
742
770
|
let current = constructor;
|
|
@@ -779,14 +807,15 @@ function Version(version) {
|
|
|
779
807
|
versionRegistry.set(value, version);
|
|
780
808
|
};
|
|
781
809
|
}
|
|
782
|
-
function
|
|
783
|
-
|
|
784
|
-
validateZone(zone);
|
|
785
|
-
}
|
|
810
|
+
function Zone(zone) {
|
|
811
|
+
validateZone(zone);
|
|
786
812
|
return function(value, _context) {
|
|
787
|
-
zonesRegistry.set(value,
|
|
813
|
+
zonesRegistry.set(value, zone);
|
|
788
814
|
};
|
|
789
815
|
}
|
|
816
|
+
function isAdvertised(serviceInstance) {
|
|
817
|
+
return findInConstructorChain(advertisedRegistry, serviceInstance.constructor) === true;
|
|
818
|
+
}
|
|
790
819
|
function Context(value, _context) {
|
|
791
820
|
contextMarkedFunctions.add(value);
|
|
792
821
|
}
|
|
@@ -794,29 +823,30 @@ function receivesContext(serviceInstance, methodName) {
|
|
|
794
823
|
const method = serviceInstance[methodName];
|
|
795
824
|
return typeof method === "function" && contextMarkedFunctions.has(method);
|
|
796
825
|
}
|
|
797
|
-
function
|
|
798
|
-
const
|
|
826
|
+
function resolveEffectiveZone(constructor) {
|
|
827
|
+
const declaredZone = findInConstructorChain(zonesRegistry, constructor) ?? Kinotic.defaultZone;
|
|
799
828
|
const prefix = Kinotic.zonePrefix;
|
|
800
|
-
let
|
|
801
|
-
if (prefix != null &&
|
|
802
|
-
|
|
829
|
+
let effectiveZone;
|
|
830
|
+
if (prefix != null && declaredZone != null) {
|
|
831
|
+
effectiveZone = `${prefix}.${declaredZone}`;
|
|
803
832
|
} else if (prefix != null) {
|
|
804
|
-
|
|
833
|
+
effectiveZone = prefix;
|
|
805
834
|
} else {
|
|
806
|
-
|
|
835
|
+
effectiveZone = declaredZone ?? null;
|
|
807
836
|
}
|
|
808
|
-
|
|
809
|
-
validateZone(
|
|
837
|
+
if (effectiveZone != null) {
|
|
838
|
+
validateZone(effectiveZone);
|
|
810
839
|
}
|
|
811
|
-
return
|
|
840
|
+
return effectiveZone;
|
|
812
841
|
}
|
|
813
|
-
function Publish(namespace, name) {
|
|
842
|
+
function Publish(namespace, name, advertise = false) {
|
|
814
843
|
return function(value, _context) {
|
|
844
|
+
advertisedRegistry.set(value, advertise);
|
|
815
845
|
return class extends value {
|
|
816
846
|
constructor(...args) {
|
|
817
847
|
super(...args);
|
|
818
|
-
const
|
|
819
|
-
const serviceIdentifier = new ServiceIdentifier(namespace ?? null, name || value.name,
|
|
848
|
+
const zone = resolveEffectiveZone(this.constructor);
|
|
849
|
+
const serviceIdentifier = new ServiceIdentifier(namespace ?? null, name || value.name, zone ?? undefined);
|
|
820
850
|
const version = findInConstructorChain(versionRegistry, this.constructor);
|
|
821
851
|
if (version) {
|
|
822
852
|
serviceIdentifier.version = version;
|
|
@@ -841,7 +871,7 @@ class ServiceInvocationSupervisor {
|
|
|
841
871
|
returnValueConverter;
|
|
842
872
|
serviceIdentifier;
|
|
843
873
|
serviceInstance;
|
|
844
|
-
|
|
874
|
+
methodSubscription = null;
|
|
845
875
|
methodMap;
|
|
846
876
|
constructor(serviceIdentifier, serviceInstance, eventBusService, interceptorProvider, options = {}) {
|
|
847
877
|
if (!serviceIdentifier)
|
|
@@ -878,33 +908,29 @@ class ServiceInvocationSupervisor {
|
|
|
878
908
|
throw new Error("Service already started");
|
|
879
909
|
}
|
|
880
910
|
this.active = true;
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
error
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
this.log.info(`ServiceInvocationSupervisor started for ${criBase}`);
|
|
897
|
-
}
|
|
911
|
+
const criBase = this.serviceIdentifier.cri().baseResource();
|
|
912
|
+
this.methodSubscription = this._eventBus.observe(criBase).subscribe({
|
|
913
|
+
next: async (event) => {
|
|
914
|
+
await this.processEvent(event);
|
|
915
|
+
},
|
|
916
|
+
error: (error) => {
|
|
917
|
+
this.log.error("Event listener error", error);
|
|
918
|
+
this.active = false;
|
|
919
|
+
},
|
|
920
|
+
complete: () => {
|
|
921
|
+
this.log.error("Event listener stopped unexpectedly. Setting supervisor inactive.");
|
|
922
|
+
this.active = false;
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
this.log.info(`ServiceInvocationSupervisor started for ${criBase}`);
|
|
898
926
|
}
|
|
899
927
|
stop() {
|
|
900
928
|
if (!this.active) {
|
|
901
929
|
throw new Error("Service already stopped");
|
|
902
930
|
}
|
|
903
931
|
this.active = false;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
this.methodSubscriptions = [];
|
|
932
|
+
this.methodSubscription?.unsubscribe();
|
|
933
|
+
this.methodSubscription = null;
|
|
908
934
|
this.log.info("ServiceInvocationSupervisor stopped");
|
|
909
935
|
}
|
|
910
936
|
buildMethodMap(serviceInstance) {
|
|
@@ -1027,7 +1053,7 @@ import { first, map as map2 } from "rxjs/operators";
|
|
|
1027
1053
|
// packages/core/package.json
|
|
1028
1054
|
var package_default = {
|
|
1029
1055
|
name: "@kinotic-ai/core",
|
|
1030
|
-
version: "
|
|
1056
|
+
version: "4.0.0",
|
|
1031
1057
|
type: "module",
|
|
1032
1058
|
files: [
|
|
1033
1059
|
"dist"
|
|
@@ -1139,7 +1165,7 @@ class ServiceRegistry {
|
|
|
1139
1165
|
_eventBus;
|
|
1140
1166
|
supervisors = new Map;
|
|
1141
1167
|
contextInterceptor = null;
|
|
1142
|
-
debugLogger =
|
|
1168
|
+
debugLogger = debug3("kinoitc:serviceRegistry");
|
|
1143
1169
|
constructor(eventBus) {
|
|
1144
1170
|
this._eventBus = eventBus;
|
|
1145
1171
|
}
|
|
@@ -1156,7 +1182,7 @@ class ServiceRegistry {
|
|
|
1156
1182
|
return new ServiceProxy(serviceIdentifier, this);
|
|
1157
1183
|
}
|
|
1158
1184
|
register(serviceIdentifier, service) {
|
|
1159
|
-
const criString = serviceIdentifier.
|
|
1185
|
+
const criString = serviceIdentifier.cri().raw();
|
|
1160
1186
|
if (!this.supervisors.has(criString)) {
|
|
1161
1187
|
this.debugLogger(`Registering service for CRI: ${criString}`);
|
|
1162
1188
|
const supervisor = new ServiceInvocationSupervisor(serviceIdentifier, service, this.eventBus, () => this.contextInterceptor);
|
|
@@ -1165,7 +1191,7 @@ class ServiceRegistry {
|
|
|
1165
1191
|
}
|
|
1166
1192
|
}
|
|
1167
1193
|
unRegister(serviceIdentifier) {
|
|
1168
|
-
const criString = serviceIdentifier.
|
|
1194
|
+
const criString = serviceIdentifier.cri().raw();
|
|
1169
1195
|
const supervisor = this.supervisors.get(criString);
|
|
1170
1196
|
if (supervisor) {
|
|
1171
1197
|
this.debugLogger(`Unregistering service for CRI: ${criString}`);
|
|
@@ -1252,7 +1278,7 @@ class KinoticSingleton {
|
|
|
1252
1278
|
_eventBus;
|
|
1253
1279
|
serviceRegistry;
|
|
1254
1280
|
zonePrefix = null;
|
|
1255
|
-
|
|
1281
|
+
defaultZone = null;
|
|
1256
1282
|
constructor() {
|
|
1257
1283
|
this._eventBus = new EventBus;
|
|
1258
1284
|
this.serviceRegistry = new ServiceRegistry(this._eventBus);
|
|
@@ -1521,8 +1547,12 @@ function createAuthenticatedWebSocketFactory(serverInfo, authProvider) {
|
|
|
1521
1547
|
class BasicAuthProvider {
|
|
1522
1548
|
authHeader;
|
|
1523
1549
|
constructor(login, passcode) {
|
|
1524
|
-
const
|
|
1525
|
-
|
|
1550
|
+
const bytes = new TextEncoder().encode(`${login}:${passcode}`);
|
|
1551
|
+
let binary = "";
|
|
1552
|
+
for (const byte of bytes) {
|
|
1553
|
+
binary += String.fromCharCode(byte);
|
|
1554
|
+
}
|
|
1555
|
+
this.authHeader = `Basic ${btoa(binary)}`;
|
|
1526
1556
|
}
|
|
1527
1557
|
getAuthHeaders() {
|
|
1528
1558
|
return { Authorization: this.authHeader };
|
|
@@ -1557,9 +1587,10 @@ export {
|
|
|
1557
1587
|
validateZone,
|
|
1558
1588
|
validateLabel,
|
|
1559
1589
|
receivesContext,
|
|
1590
|
+
isAdvertised,
|
|
1560
1591
|
createCRI,
|
|
1561
1592
|
createAuthenticatedWebSocketFactory,
|
|
1562
|
-
|
|
1593
|
+
Zone,
|
|
1563
1594
|
Version,
|
|
1564
1595
|
TextEventFactory,
|
|
1565
1596
|
Sort,
|