@xemahq/service-registry-nest 0.3.2 → 0.4.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.d.ts CHANGED
@@ -13,4 +13,9 @@ export { KernelStateServiceRegistry } from './lib/service-registry-impl';
13
13
  export { EnvServiceTokenProvider, SERVICE_TOKEN_ENV_VAR, type ServiceTokenProvider, } from './lib/service-token-provider';
14
14
  export { ServiceUnavailableError } from './lib/service-unavailable.error';
15
15
  export { TypedServiceClient, TypedServiceClientMethod, type TypedServiceClientOptions, type ScopedRequestInit, } from './lib/typed-service-client';
16
+ export { RegistryFederationBridge, FEDERATED_LABEL, FEDERATED_ORIGIN_REGION_LABEL, type RegistryFederationBridgeOptions, type FederationSyncResult, } from './lib/registry-federation-bridge';
17
+ export { isMeshCgnatHost, isMeshUrl, selectMeshEndpoint, buildMeshHttpEndpoint, type MeshEndpointOptions, } from './lib/mesh-endpoint';
18
+ export { resolveFederatedRealmTrust, parseFederatedRealmTrustFromEnv, type FederatedRealmTrust, type MultiRealmTrust, } from './lib/cross-realm-trust';
19
+ export { parseFederationConfigFromEnv, DEFAULT_FEDERATION_SYNC_INTERVAL_MS, type FederationPeerConfig, type RegistryFederationConfig, } from './lib/registry-federation.config';
20
+ export { RegistryFederationModule, RegistryFederationService, REGISTRY_FEDERATION_CONFIG, } from './lib/registry-federation.module';
16
21
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,gCAAgC,EAChC,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,wBAAwB,EACxB,KAAK,UAAU,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,aAAa,EACb,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,OAAO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5B,mCAAmC,EACnC,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,GAC9B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,0BAA0B,GAC3B,MAAM,kCAAkC,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypedServiceClientMethod = exports.TypedServiceClient = exports.ServiceUnavailableError = exports.SERVICE_TOKEN_ENV_VAR = exports.EnvServiceTokenProvider = exports.KernelStateServiceRegistry = exports.resolveHttpUrlEagerly = exports.resolveHttpUrl = exports.parseKernelStateProfile = exports.createOpenApiStubRegistry = exports.openApiExtractionStubUrl = exports.isOpenApiExtraction = exports.OPENAPI_EXTRACTION_ENV_VAR = exports.IdentityBackedServiceTokenProvider = exports.SERVICE_TOKEN_PROVIDER_TOKEN = exports.SERVICE_REGISTRY_TOKEN = exports.ServiceRegistryModule = exports.ServiceRegistryBootstrap = exports.KERNEL_STATE_TOKEN = exports.typedServiceClientToken = exports.InjectService = exports.resolveServiceInstanceId = exports.buildSelfHttpEndpointUrlFromEnv = exports.buildSelfHttpEndpointUrl = exports.resolveAdapterKind = exports.SERVICE_REGISTRY_ADAPTER_ENV_VAR = exports.ServiceRegistryAdapterKind = void 0;
3
+ exports.REGISTRY_FEDERATION_CONFIG = exports.RegistryFederationService = exports.RegistryFederationModule = exports.DEFAULT_FEDERATION_SYNC_INTERVAL_MS = exports.parseFederationConfigFromEnv = exports.parseFederatedRealmTrustFromEnv = exports.resolveFederatedRealmTrust = exports.buildMeshHttpEndpoint = exports.selectMeshEndpoint = exports.isMeshUrl = exports.isMeshCgnatHost = exports.FEDERATED_ORIGIN_REGION_LABEL = exports.FEDERATED_LABEL = exports.RegistryFederationBridge = exports.TypedServiceClientMethod = exports.TypedServiceClient = exports.ServiceUnavailableError = exports.SERVICE_TOKEN_ENV_VAR = exports.EnvServiceTokenProvider = exports.KernelStateServiceRegistry = exports.resolveHttpUrlEagerly = exports.resolveHttpUrl = exports.parseKernelStateProfile = exports.createOpenApiStubRegistry = exports.openApiExtractionStubUrl = exports.isOpenApiExtraction = exports.OPENAPI_EXTRACTION_ENV_VAR = exports.IdentityBackedServiceTokenProvider = exports.SERVICE_TOKEN_PROVIDER_TOKEN = exports.SERVICE_REGISTRY_TOKEN = exports.ServiceRegistryModule = exports.ServiceRegistryBootstrap = exports.KERNEL_STATE_TOKEN = exports.typedServiceClientToken = exports.InjectService = exports.resolveServiceInstanceId = exports.buildSelfHttpEndpointUrlFromEnv = exports.buildSelfHttpEndpointUrl = exports.resolveAdapterKind = exports.SERVICE_REGISTRY_ADAPTER_ENV_VAR = exports.ServiceRegistryAdapterKind = void 0;
4
4
  var adapter_kind_1 = require("./lib/adapter-kind");
5
5
  Object.defineProperty(exports, "ServiceRegistryAdapterKind", { enumerable: true, get: function () { return adapter_kind_1.ServiceRegistryAdapterKind; } });
6
6
  Object.defineProperty(exports, "SERVICE_REGISTRY_ADAPTER_ENV_VAR", { enumerable: true, get: function () { return adapter_kind_1.SERVICE_REGISTRY_ADAPTER_ENV_VAR; } });
@@ -43,4 +43,23 @@ Object.defineProperty(exports, "ServiceUnavailableError", { enumerable: true, ge
43
43
  var typed_service_client_1 = require("./lib/typed-service-client");
44
44
  Object.defineProperty(exports, "TypedServiceClient", { enumerable: true, get: function () { return typed_service_client_1.TypedServiceClient; } });
45
45
  Object.defineProperty(exports, "TypedServiceClientMethod", { enumerable: true, get: function () { return typed_service_client_1.TypedServiceClientMethod; } });
46
+ var registry_federation_bridge_1 = require("./lib/registry-federation-bridge");
47
+ Object.defineProperty(exports, "RegistryFederationBridge", { enumerable: true, get: function () { return registry_federation_bridge_1.RegistryFederationBridge; } });
48
+ Object.defineProperty(exports, "FEDERATED_LABEL", { enumerable: true, get: function () { return registry_federation_bridge_1.FEDERATED_LABEL; } });
49
+ Object.defineProperty(exports, "FEDERATED_ORIGIN_REGION_LABEL", { enumerable: true, get: function () { return registry_federation_bridge_1.FEDERATED_ORIGIN_REGION_LABEL; } });
50
+ var mesh_endpoint_1 = require("./lib/mesh-endpoint");
51
+ Object.defineProperty(exports, "isMeshCgnatHost", { enumerable: true, get: function () { return mesh_endpoint_1.isMeshCgnatHost; } });
52
+ Object.defineProperty(exports, "isMeshUrl", { enumerable: true, get: function () { return mesh_endpoint_1.isMeshUrl; } });
53
+ Object.defineProperty(exports, "selectMeshEndpoint", { enumerable: true, get: function () { return mesh_endpoint_1.selectMeshEndpoint; } });
54
+ Object.defineProperty(exports, "buildMeshHttpEndpoint", { enumerable: true, get: function () { return mesh_endpoint_1.buildMeshHttpEndpoint; } });
55
+ var cross_realm_trust_1 = require("./lib/cross-realm-trust");
56
+ Object.defineProperty(exports, "resolveFederatedRealmTrust", { enumerable: true, get: function () { return cross_realm_trust_1.resolveFederatedRealmTrust; } });
57
+ Object.defineProperty(exports, "parseFederatedRealmTrustFromEnv", { enumerable: true, get: function () { return cross_realm_trust_1.parseFederatedRealmTrustFromEnv; } });
58
+ var registry_federation_config_1 = require("./lib/registry-federation.config");
59
+ Object.defineProperty(exports, "parseFederationConfigFromEnv", { enumerable: true, get: function () { return registry_federation_config_1.parseFederationConfigFromEnv; } });
60
+ Object.defineProperty(exports, "DEFAULT_FEDERATION_SYNC_INTERVAL_MS", { enumerable: true, get: function () { return registry_federation_config_1.DEFAULT_FEDERATION_SYNC_INTERVAL_MS; } });
61
+ var registry_federation_module_1 = require("./lib/registry-federation.module");
62
+ Object.defineProperty(exports, "RegistryFederationModule", { enumerable: true, get: function () { return registry_federation_module_1.RegistryFederationModule; } });
63
+ Object.defineProperty(exports, "RegistryFederationService", { enumerable: true, get: function () { return registry_federation_module_1.RegistryFederationService; } });
64
+ Object.defineProperty(exports, "REGISTRY_FEDERATION_CONFIG", { enumerable: true, get: function () { return registry_federation_module_1.REGISTRY_FEDERATION_CONFIG; } });
46
65
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAI4B;AAH1B,0HAAA,0BAA0B,OAAA;AAC1B,gIAAA,gCAAgC,OAAA;AAChC,kHAAA,kBAAkB,OAAA;AAEpB,yEAKuC;AAJrC,mIAAA,wBAAwB,OAAA;AACxB,0IAAA,+BAA+B,OAAA;AAC/B,mIAAA,wBAAwB,OAAA;AAG1B,2EAGwC;AAFtC,yHAAA,aAAa,OAAA;AACb,mIAAA,uBAAuB,OAAA;AAEzB,+DAGkC;AAFhC,wHAAA,kBAAkB,OAAA;AAGpB,yEAOuC;AANrC,mIAAA,wBAAwB,OAAA;AACxB,gIAAA,qBAAqB,OAAA;AACrB,iIAAA,sBAAsB,OAAA;AACtB,uIAAA,4BAA4B,OAAA;AAI9B,uGAGsD;AAFpD,4JAAA,kCAAkC,OAAA;AAGpC,+DAIkC;AAHhC,gIAAA,0BAA0B,OAAA;AAC1B,yHAAA,mBAAmB,OAAA;AACnB,8HAAA,wBAAwB,OAAA;AAE1B,qEAAwE;AAA/D,kIAAA,yBAAyB,OAAA;AAClC,+EAA2E;AAAlE,qIAAA,uBAAuB,OAAA;AAChC,2DAAwD;AAA/C,kHAAA,cAAc,OAAA;AACvB,2EAAiG;AAAxF,iIAAA,qBAAqB,OAAA;AAC9B,qEAAyE;AAAhE,mIAAA,0BAA0B,OAAA;AACnC,uEAIsC;AAHpC,iIAAA,uBAAuB,OAAA;AACvB,+HAAA,qBAAqB,OAAA;AAGvB,6EAA0E;AAAjE,oIAAA,uBAAuB,OAAA;AAChC,mEAKoC;AAJlC,0HAAA,kBAAkB,OAAA;AAClB,gIAAA,wBAAwB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mDAI4B;AAH1B,0HAAA,0BAA0B,OAAA;AAC1B,gIAAA,gCAAgC,OAAA;AAChC,kHAAA,kBAAkB,OAAA;AAE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A,mCAAmC,OAAA;AAIrC,+EAI0C;AAHxC,sIAAA,wBAAwB,OAAA;AACxB,uIAAA,yBAAyB,OAAA;AACzB,wIAAA,0BAA0B,OAAA"}
@@ -0,0 +1,15 @@
1
+ export interface FederatedRealmTrust {
2
+ readonly discoveryBaseUrl: string;
3
+ readonly realms: readonly string[];
4
+ }
5
+ export interface MultiRealmTrust {
6
+ readonly discoveryBaseUrls: string[];
7
+ readonly allowedRealms: string[];
8
+ }
9
+ export declare function resolveFederatedRealmTrust(input: {
10
+ localDiscoveryBaseUrl: string;
11
+ localRealms: readonly string[];
12
+ peers: readonly FederatedRealmTrust[];
13
+ }): MultiRealmTrust;
14
+ export declare function parseFederatedRealmTrustFromEnv(env?: NodeJS.ProcessEnv): MultiRealmTrust | undefined;
15
+ //# sourceMappingURL=cross-realm-trust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-realm-trust.d.ts","sourceRoot":"","sources":["../../src/lib/cross-realm-trust.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,mBAAmB;IAKlC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAElC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CACpC;AAGD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;CAClC;AAWD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IAC/B,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACvC,GAAG,eAAe,CA8BlB;AASD,wBAAgB,+BAA+B,CAC7C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,eAAe,GAAG,SAAS,CA8B7B"}
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFederatedRealmTrust = resolveFederatedRealmTrust;
4
+ exports.parseFederatedRealmTrustFromEnv = parseFederatedRealmTrustFromEnv;
5
+ function resolveFederatedRealmTrust(input) {
6
+ if (input.localDiscoveryBaseUrl.trim() === '') {
7
+ throw new Error('[cross-realm-trust] localDiscoveryBaseUrl must be a non-empty string.');
8
+ }
9
+ const baseUrls = [normalizeBaseUrl(input.localDiscoveryBaseUrl)];
10
+ const realms = [...input.localRealms];
11
+ for (const peer of input.peers) {
12
+ if (peer.discoveryBaseUrl.trim() === '') {
13
+ throw new Error('[cross-realm-trust] a federated peer has an empty discoveryBaseUrl.');
14
+ }
15
+ if (peer.realms.length === 0) {
16
+ throw new Error(`[cross-realm-trust] federated peer "${peer.discoveryBaseUrl}" declares no realms — ` +
17
+ 'an empty realm list would trust nothing; omit the peer instead.');
18
+ }
19
+ baseUrls.push(normalizeBaseUrl(peer.discoveryBaseUrl));
20
+ realms.push(...peer.realms);
21
+ }
22
+ return {
23
+ discoveryBaseUrls: dedupe(baseUrls),
24
+ allowedRealms: dedupe(realms),
25
+ };
26
+ }
27
+ function parseFederatedRealmTrustFromEnv(env = process.env) {
28
+ const raw = env['XEMA_FEDERATION_REALM_TRUST']?.trim();
29
+ if (raw === undefined || raw === '') {
30
+ return undefined;
31
+ }
32
+ let parsed;
33
+ try {
34
+ parsed = JSON.parse(raw);
35
+ }
36
+ catch (cause) {
37
+ throw new Error('[cross-realm-trust] XEMA_FEDERATION_REALM_TRUST is not valid JSON.', { cause: cause });
38
+ }
39
+ if (typeof parsed !== 'object' || parsed === null) {
40
+ throw new Error('[cross-realm-trust] XEMA_FEDERATION_REALM_TRUST must be a JSON object { discoveryBaseUrls, allowedRealms }.');
41
+ }
42
+ const obj = parsed;
43
+ return {
44
+ discoveryBaseUrls: requireStringArray(obj['discoveryBaseUrls'], 'XEMA_FEDERATION_REALM_TRUST.discoveryBaseUrls').map(normalizeBaseUrl),
45
+ allowedRealms: requireStringArray(obj['allowedRealms'], 'XEMA_FEDERATION_REALM_TRUST.allowedRealms'),
46
+ };
47
+ }
48
+ function requireStringArray(value, at) {
49
+ if (!Array.isArray(value) ||
50
+ value.length === 0 ||
51
+ value.some((v) => typeof v !== 'string' || v.trim() === '')) {
52
+ throw new Error(`[cross-realm-trust] ${at} must be a non-empty array of non-empty strings.`);
53
+ }
54
+ return value;
55
+ }
56
+ function normalizeBaseUrl(url) {
57
+ return url.replace(/\/+$/, '');
58
+ }
59
+ function dedupe(values) {
60
+ const seen = new Set();
61
+ const out = [];
62
+ for (const v of values) {
63
+ if (!seen.has(v)) {
64
+ seen.add(v);
65
+ out.push(v);
66
+ }
67
+ }
68
+ return out;
69
+ }
70
+ //# sourceMappingURL=cross-realm-trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cross-realm-trust.js","sourceRoot":"","sources":["../../src/lib/cross-realm-trust.ts"],"names":[],"mappings":";;AA4CA,gEAkCC;AASD,0EAgCC;AA3ED,SAAgB,0BAA0B,CAAC,KAI1C;IACC,IAAI,KAAK,CAAC,qBAAqB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAa,CAAC,gBAAgB,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC,CAAC;IAC3E,MAAM,MAAM,GAAa,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IAEhD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC/B,IAAI,IAAI,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CACb,uCAAuC,IAAI,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AAkB,CAAC,KAAc,EAAE,EAAU;IACpD,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAC3D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,uBAAuB,EAAE,kDAAkD,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,KAAiB,CAAC;AAC3B,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAW;IACnC,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,MAAM,CAAC,MAAyB;IACvC,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;YACjB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACZ,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { ServiceEndpointAuth, type ServiceEndpoint } from '@xemahq/kernel-contracts/service-registry';
2
+ export interface MeshEndpointOptions {
3
+ readonly magicDnsSuffix?: string;
4
+ }
5
+ export declare function isMeshCgnatHost(host: string): boolean;
6
+ export declare function isMeshUrl(url: string, options?: MeshEndpointOptions): boolean;
7
+ export declare function selectMeshEndpoint(endpoints: readonly ServiceEndpoint[], options?: MeshEndpointOptions): ServiceEndpoint | undefined;
8
+ export declare function buildMeshHttpEndpoint(input: {
9
+ meshHostOrIp: string;
10
+ port: number;
11
+ auth?: ServiceEndpointAuth;
12
+ }): ServiceEndpoint;
13
+ //# sourceMappingURL=mesh-endpoint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh-endpoint.d.ts","sourceRoot":"","sources":["../../src/lib/mesh-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAEnB,KAAK,eAAe,EACrB,MAAM,2CAA2C,CAAC;AAwBnD,MAAM,WAAW,mBAAmB;IAKlC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAsBD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGrD;AAGD,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAejF;AAOD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,SAAS,eAAe,EAAE,EACrC,OAAO,GAAE,mBAAwB,GAChC,eAAe,GAAG,SAAS,CAK7B;AAOD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B,GAAG,eAAe,CAMlB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMeshCgnatHost = isMeshCgnatHost;
4
+ exports.isMeshUrl = isMeshUrl;
5
+ exports.selectMeshEndpoint = selectMeshEndpoint;
6
+ exports.buildMeshHttpEndpoint = buildMeshHttpEndpoint;
7
+ const service_registry_1 = require("@xemahq/kernel-contracts/service-registry");
8
+ const CGNAT_FIRST = 1_681_915_904;
9
+ const CGNAT_LAST = 1_686_110_207;
10
+ function ipv4ToInt(ip) {
11
+ const parts = ip.split('.');
12
+ if (parts.length !== 4) {
13
+ return null;
14
+ }
15
+ let acc = 0;
16
+ for (const part of parts) {
17
+ if (!/^\d{1,3}$/.test(part)) {
18
+ return null;
19
+ }
20
+ const n = Number(part);
21
+ if (n > 255) {
22
+ return null;
23
+ }
24
+ acc = acc * 256 + n;
25
+ }
26
+ return acc >>> 0;
27
+ }
28
+ function isMeshCgnatHost(host) {
29
+ const n = ipv4ToInt(host);
30
+ return n !== null && n >= CGNAT_FIRST && n <= CGNAT_LAST;
31
+ }
32
+ function isMeshUrl(url, options = {}) {
33
+ let host;
34
+ try {
35
+ host = new URL(url).hostname;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ if (options.magicDnsSuffix !== undefined &&
41
+ options.magicDnsSuffix !== '' &&
42
+ host.endsWith(options.magicDnsSuffix)) {
43
+ return true;
44
+ }
45
+ return isMeshCgnatHost(host);
46
+ }
47
+ function selectMeshEndpoint(endpoints, options = {}) {
48
+ return endpoints.find((e) => e.protocol === service_registry_1.ServiceEndpointProtocol.Http && isMeshUrl(e.url, options));
49
+ }
50
+ function buildMeshHttpEndpoint(input) {
51
+ return {
52
+ protocol: service_registry_1.ServiceEndpointProtocol.Http,
53
+ url: `http://${input.meshHostOrIp}:${input.port}`,
54
+ auth: input.auth ?? service_registry_1.ServiceEndpointAuth.ServiceToken,
55
+ };
56
+ }
57
+ //# sourceMappingURL=mesh-endpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mesh-endpoint.js","sourceRoot":"","sources":["../../src/lib/mesh-endpoint.ts"],"names":[],"mappings":";;AAwDA,0CAGC;AAGD,8BAeC;AAOD,gDAQC;AAOD,sDAUC;AA7GD,gFAImD;AAqBnD,MAAM,WAAW,GAAG,aAAa,CAAC;AAClC,MAAM,UAAU,GAAG,aAAa,CAAC;AAUjC,SAAS,SAAS,CAAC,EAAU;IAC3B,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,GAAG,GAAG,CA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C,CAAC,GAAG,EAAE,OAAO,CAAC,CAC3E,CAAC;AACJ,CAAC;AAOD,SAAgB,qBAAqB,CAAC,KAIrC;IACC,OAAO;QACL,QAAQ,EAAE,0CAAuB,CAAC,IAAI;QACtC,GAAG,EAAE,UAAU,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC,IAAI,EAAE;QACjD,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,sCAAmB,CAAC,YAAY;KACrD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type ServiceEndpoint, type ServiceRegistry } from '@xemahq/kernel-contracts/service-registry';
2
+ export interface RegistryFederationBridgeOptions {
3
+ readonly region: string;
4
+ readonly allowServiceNames: readonly string[];
5
+ readonly selectReachableEndpoint?: (endpoints: readonly ServiceEndpoint[]) => ServiceEndpoint | undefined;
6
+ }
7
+ export declare const FEDERATED_LABEL = "xema.federated";
8
+ export declare const FEDERATED_ORIGIN_REGION_LABEL = "xema.origin-region";
9
+ export interface FederationSyncResult {
10
+ readonly registered: number;
11
+ readonly renewed: number;
12
+ readonly pruned: number;
13
+ }
14
+ export declare class RegistryFederationBridge {
15
+ private readonly local;
16
+ private readonly peer;
17
+ private readonly options;
18
+ private readonly mirroredLeases;
19
+ private readonly allow;
20
+ private readonly selectEndpoint;
21
+ constructor(local: ServiceRegistry, peer: ServiceRegistry, options: RegistryFederationBridgeOptions);
22
+ syncOnce(): Promise<FederationSyncResult>;
23
+ get mirroredCount(): number;
24
+ private toMirrorDescriptor;
25
+ }
26
+ //# sourceMappingURL=registry-federation-bridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation-bridge.d.ts","sourceRoot":"","sources":["../../src/lib/registry-federation-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,eAAe,EACrB,MAAM,2CAA2C,CAAC;AAwBnD,MAAM,WAAW,+BAA+B;IAE9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAKxB,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAM9C,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CACjC,SAAS,EAAE,SAAS,eAAe,EAAE,KAClC,eAAe,GAAG,SAAS,CAAC;CAClC;AAGD,eAAO,MAAM,eAAe,mBAAmB,CAAC;AAEhD,eAAO,MAAM,6BAA6B,uBAAuB,CAAC;AAElE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAQD,qBAAa,wBAAwB;IAUjC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAV1B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA6B;IAE5D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAEE;gBAGd,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,+BAA+B;IAarD,QAAQ,IAAI,OAAO,CAAC,oBAAoB,CAAC;IA6C/C,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED,OAAO,CAAC,kBAAkB;CAwB3B"}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RegistryFederationBridge = exports.FEDERATED_ORIGIN_REGION_LABEL = exports.FEDERATED_LABEL = void 0;
4
+ const service_registry_1 = require("@xemahq/kernel-contracts/service-registry");
5
+ exports.FEDERATED_LABEL = 'xema.federated';
6
+ exports.FEDERATED_ORIGIN_REGION_LABEL = 'xema.origin-region';
7
+ function defaultEndpointSelector(endpoints) {
8
+ return endpoints.find((e) => e.protocol === service_registry_1.ServiceEndpointProtocol.Http);
9
+ }
10
+ class RegistryFederationBridge {
11
+ local;
12
+ peer;
13
+ options;
14
+ mirroredLeases = new Map();
15
+ allow;
16
+ selectEndpoint;
17
+ constructor(local, peer, options) {
18
+ this.local = local;
19
+ this.peer = peer;
20
+ this.options = options;
21
+ this.allow = new Set(options.allowServiceNames);
22
+ this.selectEndpoint =
23
+ options.selectReachableEndpoint ?? defaultEndpointSelector;
24
+ }
25
+ async syncOnce() {
26
+ const peerServices = await this.peer.list();
27
+ const wanted = peerServices.filter((s) => this.allow.has(s.name));
28
+ const seen = new Set();
29
+ let registered = 0;
30
+ let renewed = 0;
31
+ for (const svc of wanted) {
32
+ const key = `${svc.name}:${svc.instanceId}`;
33
+ seen.add(key);
34
+ const existingLease = this.mirroredLeases.get(key);
35
+ if (existingLease !== undefined) {
36
+ try {
37
+ const lease = await this.local.renew(existingLease);
38
+ this.mirroredLeases.set(key, lease.leaseId);
39
+ renewed += 1;
40
+ continue;
41
+ }
42
+ catch {
43
+ this.mirroredLeases.delete(key);
44
+ }
45
+ }
46
+ const lease = await this.local.register(this.toMirrorDescriptor(svc));
47
+ this.mirroredLeases.set(key, lease.leaseId);
48
+ registered += 1;
49
+ }
50
+ let pruned = 0;
51
+ for (const key of [...this.mirroredLeases.keys()]) {
52
+ if (!seen.has(key)) {
53
+ this.mirroredLeases.delete(key);
54
+ pruned += 1;
55
+ }
56
+ }
57
+ return { registered, renewed, pruned };
58
+ }
59
+ get mirroredCount() {
60
+ return this.mirroredLeases.size;
61
+ }
62
+ toMirrorDescriptor(svc) {
63
+ const endpoint = this.selectEndpoint(svc.endpoints);
64
+ if (endpoint === undefined) {
65
+ throw new Error(`[registry-federation] peer service "${svc.name}" (instance ${svc.instanceId}) ` +
66
+ `is whitelisted but advertises no selectable endpoint — cannot mirror it. ` +
67
+ `A federated service MUST expose a reachable (mesh) endpoint.`);
68
+ }
69
+ return {
70
+ name: svc.name,
71
+ semver: svc.semver,
72
+ instanceId: svc.instanceId,
73
+ endpoints: [endpoint],
74
+ exposesCapabilities: [...svc.descriptor.exposesCapabilities],
75
+ requiresServices: [...svc.descriptor.requiresServices],
76
+ region: this.options.region,
77
+ labels: {
78
+ ...svc.descriptor.labels,
79
+ [exports.FEDERATED_LABEL]: 'true',
80
+ [exports.FEDERATED_ORIGIN_REGION_LABEL]: this.options.region,
81
+ },
82
+ };
83
+ }
84
+ }
85
+ exports.RegistryFederationBridge = RegistryFederationBridge;
86
+ //# sourceMappingURL=registry-federation-bridge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation-bridge.js","sourceRoot":"","sources":["../../src/lib/registry-federation-bridge.ts"],"names":[],"mappings":";;;AAAA,gFAMmD;AA2CtC,QAAA,eAAe,GAAG,gBAAgB,CAAC;AAEnC,QAAA,6BAA6B,GAAG,oBAAoB,CAAC;AAQlE,SAAS,uBAAuB,CAC9B,SAAqC;IAErC,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,0CAAuB,CAAC,IAAI,CAAC,CAAC;AAC5E,CAAC;AAED,MAAa,wBAAwB;IAUhB;IACA;IACA;IAVF,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,KAAK,CAAsB;IAC3B,cAAc,CAEE;IAEjC,YACmB,KAAsB,EACtB,IAAqB,EACrB,OAAwC;QAFxC,UAAK,GAAL,KAAK,CAAiB;QACtB,SAAI,GAAJ,IAAI,CAAiB;QACrB,YAAO,GAAP,OAAO,CAAiC;QAEzD,IAAI,CAAC,KAAK,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAChD,IAAI,CAAC,cAAc;YACjB,OAAO,CAAC,uBAAuB,IAAI,uBAAuB,CAAC;IAC/D,CAAC;IAQD,KAAK,CAAC,QAAQ;QACZ,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5C,MAAM,MAAM,GAAG,Y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-0,0 +1,13 @@
1
+ export interface FederationPeerConfig {
2
+ readonly region: string;
3
+ readonly etcdEndpoints: readonly string[];
4
+ readonly allowServiceNames: readonly string[];
5
+ readonly magicDnsSuffix?: string;
6
+ }
7
+ export interface RegistryFederationConfig {
8
+ readonly peers: readonly FederationPeerConfig[];
9
+ readonly syncIntervalMs: number;
10
+ }
11
+ export declare const DEFAULT_FEDERATION_SYNC_INTERVAL_MS = 10000;
12
+ export declare function parseFederationConfigFromEnv(env?: NodeJS.ProcessEnv): RegistryFederationConfig;
13
+ //# sourceMappingURL=registry-federation.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation.config.d.ts","sourceRoot":"","sources":["../../src/lib/registry-federation.config.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,oBAAoB;IAEnC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1C,QAAQ,CAAC,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IAE9C,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAKhD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAGD,eAAO,MAAM,mCAAmC,QAAS,CAAC;AAY1D,wBAAgB,4BAA4B,CAC1C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,wBAAwB,CAiB1B"}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_FEDERATION_SYNC_INTERVAL_MS = void 0;
4
+ exports.parseFederationConfigFromEnv = parseFederationConfigFromEnv;
5
+ exports.DEFAULT_FEDERATION_SYNC_INTERVAL_MS = 10_000;
6
+ const PEERS_ENV = 'XEMA_FEDERATION_PEERS';
7
+ const INTERVAL_ENV = 'XEMA_FEDERATION_SYNC_INTERVAL_MS';
8
+ function parseFederationConfigFromEnv(env = process.env) {
9
+ const raw = env[PEERS_ENV]?.trim();
10
+ const peers = raw === undefined || raw === '' ? [] : parsePeers(raw);
11
+ const intervalRaw = env[INTERVAL_ENV]?.trim();
12
+ let syncIntervalMs = exports.DEFAULT_FEDERATION_SYNC_INTERVAL_MS;
13
+ if (intervalRaw !== undefined && intervalRaw !== '') {
14
+ const n = Number(intervalRaw);
15
+ if (!Number.isInteger(n) || n <= 0) {
16
+ throw new Error(`[registry-federation] ${INTERVAL_ENV} must be a positive integer (ms); got "${intervalRaw}".`);
17
+ }
18
+ syncIntervalMs = n;
19
+ }
20
+ return { peers, syncIntervalMs };
21
+ }
22
+ function parsePeers(raw) {
23
+ let parsed;
24
+ try {
25
+ parsed = JSON.parse(raw);
26
+ }
27
+ catch (cause) {
28
+ throw new Error(`[registry-federation] ${PEERS_ENV} is not valid JSON.`, { cause: cause });
29
+ }
30
+ if (!Array.isArray(parsed)) {
31
+ throw new Error(`[registry-federation] ${PEERS_ENV} must be a JSON array of peer configs.`);
32
+ }
33
+ return parsed.map((p, i) => validatePeer(p, i));
34
+ }
35
+ function validatePeer(value, index) {
36
+ const at = `${PEERS_ENV}[${index}]`;
37
+ if (typeof value !== 'object' || value === null) {
38
+ throw new Error(`[registry-federation] ${at} is not an object.`);
39
+ }
40
+ const p = value;
41
+ const region = requireNonEmptyString(p['region'], `${at}.region`);
42
+ const etcdEndpoints = requireNonEmptyStringArray(p['etcdEndpoints'], `${at}.etcdEndpoints`);
43
+ const allowServiceNames = requireNonEmptyStringArray(p['allowServiceNames'], `${at}.allowServiceNames`);
44
+ const magicDnsSuffix = p['magicDnsSuffix'];
45
+ if (magicDnsSuffix !== undefined && typeof magicDnsSuffix !== 'string') {
46
+ throw new Error(`[registry-federation] ${at}.magicDnsSuffix must be a string.`);
47
+ }
48
+ return {
49
+ region,
50
+ etcdEndpoints,
51
+ allowServiceNames,
52
+ ...(magicDnsSuffix !== undefined ? { magicDnsSuffix } : {}),
53
+ };
54
+ }
55
+ function requireNonEmptyString(value, at) {
56
+ if (typeof value !== 'string' || value.trim() === '') {
57
+ throw new Error(`[registry-federation] ${at} must be a non-empty string.`);
58
+ }
59
+ return value;
60
+ }
61
+ function requireNonEmptyStringArray(value, at) {
62
+ if (!Array.isArray(value) ||
63
+ value.length === 0 ||
64
+ value.some((v) => typeof v !== 'string' || v.trim() === '')) {
65
+ throw new Error(`[registry-federation] ${at} must be a non-empty array of non-empty strings.`);
66
+ }
67
+ return value;
68
+ }
69
+ //# sourceMappingURL=registry-federation.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation.config.js","sourceRoot":"","sources":["../../src/lib/registry-federation.config.ts"],"names":[],"mappings":";;;AAyCA,oEAmBC;AA/BY,QAAA,mCAAmC,GAAG,MAAM,CAAC;AAE1D,MAAM,SAAS,GAAG,uBAAuB,CAAC;AAC1C,MAAM,YAAY,GAAG,kCAAkC,CAAC;AASxD,SAAgB,4BAA4B,CAC1C,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC;IACnC,MAAM,KAAK,GAAG,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IAErE,MAAM,WAAW,GAAG,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,cAAc,GAAG,2CAAmC,CAAC;IACzD,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,EAAE,EAAE,CAAC;QACpD,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,MAAM,IA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IACF,MAAM,iBAAiB,GAAG,0BAA0B,CAClD,CAAC,CAAC,mBAAmB,CAAC,EACtB,GAAG,EAAE,oBAAoB,CAC1B,CAAC;IACF,MAAM,cAAc,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC;IAC3C,IAAI,cAAc,KAAK,SAAS,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;QACvE,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,mCAAmC,CAAC,CAAC;IAClF,CAAC;IACD,OAAO;QACL,MAAM;QACN,aAAa;QACb,iBAAiB;QACjB,GAAG,CAAC,cAAc,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,CAAC;AACJ,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAc,EAAE,EAAU;IACvD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CAAC,yBAAyB,EAAE,8BAA8B,CAAC,CAAC;IAC7E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,0BAA0B,CAAC,KAAc,EAAE,EAAU;IAC5D,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,KAAK,CAAC,MAAM,KAAK,CAAC;QAClB,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,EAC3D,CAAC;QACD,MAAM,IAAI,KAAK,CACb,yBAAyB,EAAE,kDAAkD,CAC9E,CAAC;IACJ,CAAC;IACD,OAAO,KAAiB,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { type DynamicModule, type OnApplicationBootstrap, type OnModuleDestroy } from '@nestjs/common';
2
+ import type { ServiceRegistry } from '@xemahq/kernel-contracts/service-registry';
3
+ import { type RegistryFederationConfig } from './registry-federation.config';
4
+ export declare const REGISTRY_FEDERATION_CONFIG: unique symbol;
5
+ export declare class RegistryFederationService implements OnApplicationBootstrap, OnModuleDestroy {
6
+ private readonly local;
7
+ private readonly config;
8
+ private readonly logger;
9
+ private readonly bridges;
10
+ private readonly peerRegistries;
11
+ private timer;
12
+ constructor(local: ServiceRegistry, config: RegistryFederationConfig);
13
+ onApplicationBootstrap(): Promise<void>;
14
+ reconcileOnce(): Promise<void>;
15
+ onModuleDestroy(): void;
16
+ }
17
+ export declare class RegistryFederationModule {
18
+ static forRoot(config?: RegistryFederationConfig): DynamicModule;
19
+ }
20
+ //# sourceMappingURL=registry-federation.module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation.module.d.ts","sourceRoot":"","sources":["../../src/lib/registry-federation.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,eAAe,EACrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAOjF,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAMtC,eAAO,MAAM,0BAA0B,eAEtC,CAAC;AAcF,qBACa,yBACX,YAAW,sBAAsB,EAAE,eAAe;IAShD,OAAO,CAAC,QAAQ,CAAC,KAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,MAAM;IATzB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8C;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAoC;IACnE,OAAO,CAAC,KAAK,CAA6C;gBAIvC,KAAK,EAAE,eAAe,EAEtB,MAAM,EAAE,wBAAwB;IAG7C,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8CvC,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAiBpC,eAAe,IAAI,IAAI;CASxB;AAQD,qBACa,wBAAwB;IACnC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,wBAAwB,GAAG,aAAa;CAajE"}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var RegistryFederationService_1, RegistryFederationModule_1;
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.RegistryFederationModule = exports.RegistryFederationService = exports.REGISTRY_FEDERATION_CONFIG = void 0;
17
+ const common_1 = require("@nestjs/common");
18
+ const kernel_state_runtime_1 = require("@xemahq/kernel-state-runtime");
19
+ const mesh_endpoint_1 = require("./mesh-endpoint");
20
+ const registry_federation_config_1 = require("./registry-federation.config");
21
+ const registry_federation_bridge_1 = require("./registry-federation-bridge");
22
+ const service_registry_impl_1 = require("./service-registry-impl");
23
+ const service_registry_module_1 = require("./service-registry.module");
24
+ exports.REGISTRY_FEDERATION_CONFIG = Symbol.for('@xemahq/service-registry-nest/registry-federation-config');
25
+ let RegistryFederationService = RegistryFederationService_1 = class RegistryFederationService {
26
+ local;
27
+ config;
28
+ logger = new common_1.Logger(RegistryFederationService_1.name);
29
+ bridges = [];
30
+ peerRegistries = [];
31
+ timer;
32
+ constructor(local, config) {
33
+ this.local = local;
34
+ this.config = config;
35
+ }
36
+ async onApplicationBootstrap() {
37
+ for (const peer of this.config.peers) {
38
+ const kernelState = (0, kernel_state_runtime_1.createKernelState)({
39
+ profile: kernel_state_runtime_1.KernelStateProfile.Cluster,
40
+ etcd: { endpoints: [...peer.etcdEndpoints] },
41
+ });
42
+ const peerRegistry = new service_registry_impl_1.KernelStateServiceRegistry(kernelState);
43
+ await peerRegistry.onModuleInit();
44
+ this.peerRegistries.push(peerRegistry);
45
+ this.bridges.push(new registry_federation_bridge_1.RegistryFederationBridge(this.local, peerRegistry, {
46
+ region: peer.region,
47
+ allowServiceNames: peer.allowServiceNames,
48
+ selectReachableEndpoint: (eps) => (0, mesh_endpoint_1.selectMeshEndpoint)(eps, peer.magicDnsSuffix !== undefined
49
+ ? { magicDnsSuffix: peer.magicDnsSuffix }
50
+ : {}),
51
+ }));
52
+ }
53
+ if (this.bridges.length === 0) {
54
+ this.logger.log('Registry federation: no peers configured — disabled.');
55
+ return;
56
+ }
57
+ this.logger.log(`Registry federation: ${this.bridges.length} peer(s), reconciling every ${this.config.syncIntervalMs}ms.`);
58
+ await this.reconcileOnce();
59
+ this.timer = setInterval(() => {
60
+ void this.reconcileOnce();
61
+ }, this.config.syncIntervalMs);
62
+ this.timer.unref?.();
63
+ }
64
+ async reconcileOnce() {
65
+ for (const bridge of this.bridges) {
66
+ try {
67
+ const result = await bridge.syncOnce();
68
+ this.logger.debug(`Federation sync: registered=${result.registered} renewed=${result.renewed} pruned=${result.pruned}`);
69
+ }
70
+ catch (error) {
71
+ this.logger.error(`Federation sync failed for a peer (will retry next interval): ${error instanceof Error ? error.message : String(error)}`);
72
+ }
73
+ }
74
+ }
75
+ onModuleDestroy() {
76
+ if (this.timer !== undefined) {
77
+ clearInterval(this.timer);
78
+ this.timer = undefined;
79
+ }
80
+ for (const reg of this.peerRegistries) {
81
+ reg.onModuleDestroy();
82
+ }
83
+ }
84
+ };
85
+ exports.RegistryFederationService = RegistryFederationService;
86
+ exports.RegistryFederationService = RegistryFederationService = RegistryFederationService_1 = __decorate([
87
+ (0, common_1.Injectable)(),
88
+ __param(0, (0, common_1.Inject)(service_registry_module_1.SERVICE_REGISTRY_TOKEN)),
89
+ __param(1, (0, common_1.Inject)(exports.REGISTRY_FEDERATION_CONFIG)),
90
+ __metadata("design:paramtypes", [Object, Object])
91
+ ], RegistryFederationService);
92
+ let RegistryFederationModule = RegistryFederationModule_1 = class RegistryFederationModule {
93
+ static forRoot(config) {
94
+ return {
95
+ module: RegistryFederationModule_1,
96
+ providers: [
97
+ {
98
+ provide: exports.REGISTRY_FEDERATION_CONFIG,
99
+ useValue: config ?? (0, registry_federation_config_1.parseFederationConfigFromEnv)(),
100
+ },
101
+ RegistryFederationService,
102
+ ],
103
+ exports: [RegistryFederationService],
104
+ };
105
+ }
106
+ };
107
+ exports.RegistryFederationModule = RegistryFederationModule;
108
+ exports.RegistryFederationModule = RegistryFederationModule = RegistryFederationModule_1 = __decorate([
109
+ (0, common_1.Module)({})
110
+ ], RegistryFederationModule);
111
+ //# sourceMappingURL=registry-federation.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-federation.module.js","sourceRoot":"","sources":["../../src/lib/registry-federation.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAQwB;AAExB,uEAGsC;AAEtC,mDAAqD;AACrD,6EAGsC;AACtC,6EAAwE;AACxE,mEAAqE;AACrE,uEAAmE;AAGtD,QAAA,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAClD,0DAA0D,CAC3D,CAAC;AAeK,IAAM,yBAAyB,iCAA/B,MAAM,yBAAyB;IAUjB;IAEA;IATF,MAAM,GAAG,IAAI,eAAM,CAAC,2BAAyB,CAAC,IAAI,CAAC,CAAC;IACpD,OAAO,GAA+B,EAAE,CAAC;IACzC,cAAc,GAAiC,EAAE,CAAC;IAC3D,KAAK,CAA6C;IAE1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,CAAA;IAE9B,WAAA,IAAA,eAAM,EAAC,kCAA0B,CAAC,CAAA;;GAX1B,yBAAyB,CAuFrC;AASM,IAAM,wBAAwB,gCAA9B,MAAM,wBAAwB;IACnC,MAAM,CAAC,OAAO,CAAC,MAAiC;QAC9C,OAAO;YACL,MAAM,EAAE,0BAAwB;YAChC,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,kCAA0B;oBACnC,QAAQ,EAAE,MAAM,IAAI,IAAA,yDAA4B,GAAE;iBACnD;gBACD,yBAAyB;aAC1B;YACD,OAAO,EAAE,CAAC,yBAAyB,CAAC;SACrC,CAAC;IACJ,CAAC;CACF,CAAA;AAdY,4DAAwB;mCAAxB,wBAAwB;IADpC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,wBAAwB,CAcpC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xemahq/service-registry-nest",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "NestJS runtime SDK for the Xema OS Service Registry. Provides `ServiceRegistryModule.forRootAsync()` — registers the host service's `ServiceDescriptor` against KernelState at boot, renews the lease on a heartbeat, removes the entry on shutdown, and exposes the `@InjectService(name)` decorator that hands consumers a typed HTTP client whose base URL is resolved dynamically from the registry on every call. The SDK is adapter-agnostic; the `KernelState` instance is injected via a factory so the same code runs against a SQLite-backed dev adapter and an etcd-backed cluster adapter.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Neuralchowder Inc. <developer@xema.dev> (https://xema.dev)",
@@ -30,7 +30,7 @@
30
30
  "reflect-metadata": "0.2.2",
31
31
  "ts-jest": "^29.4.9",
32
32
  "typescript": "5.9.3",
33
- "@xemahq/kernel-contracts": "^0.39.0"
33
+ "@xemahq/kernel-contracts": "^0.48.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@nestjs/common": "^10 || ^11",