gdc-sdk-node-ts 0.6.3 → 0.6.4

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.
@@ -35,6 +35,8 @@ export declare class DefaultFirstDataspaceDiscovery {
35
35
  getDigitalTwinProviders(input: SimpleDataspaceDiscoveryRequest): Promise<PublishedProviderMatch[]>;
36
36
  private getProviders;
37
37
  private createResolver;
38
+ private buildBootstrapPlan;
39
+ private resolveDefaultPublishedProviders;
38
40
  }
39
41
  /**
40
42
  * Convenience factory for the default-first portal/backend discovery facade.
@@ -1,9 +1,57 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
- import { DataspaceDiscoverySourceMode, ServiceCapabilityToken, createDataspaceDiscoveryDefaultsRegistry, DataspaceProtocolVersions, } from 'gdc-common-utils-ts';
2
+ import { DataspaceCoverageScope, DataspaceDiscoverySourceMode, ServiceCapabilityToken, createDataspaceDiscoveryDefaultsRegistry, DataspaceProtocolVersions, inferCoverageScopeFromCountryCode, isProviderServiceCapability, normalizeCountryCode, } from 'gdc-common-utils-ts';
3
3
  import { HttpDataspaceResolver } from './HttpDataspaceResolver.js';
4
4
  function normalizeString(value) {
5
5
  return typeof value === 'string' ? value.trim() : '';
6
6
  }
7
+ function equalsIgnoreCase(left, right) {
8
+ return left.trim().toLowerCase() === right.trim().toLowerCase();
9
+ }
10
+ function splitTokens(value) {
11
+ if (Array.isArray(value)) {
12
+ return value.map((entry) => normalizeString(entry)).filter(Boolean);
13
+ }
14
+ const raw = normalizeString(value);
15
+ if (!raw)
16
+ return [];
17
+ return raw.split(',').map((entry) => entry.trim()).filter(Boolean);
18
+ }
19
+ function buildCoverageTokens(areaServed, filterJurisdiction) {
20
+ const tokens = new Set(splitTokens(areaServed).map((token) => token.toUpperCase()));
21
+ const normalizedJurisdiction = normalizeCountryCode(filterJurisdiction);
22
+ if (normalizedJurisdiction) {
23
+ const inferred = inferCoverageScopeFromCountryCode(normalizedJurisdiction);
24
+ if (inferred)
25
+ tokens.add(inferred.toUpperCase());
26
+ }
27
+ return tokens;
28
+ }
29
+ function matchesProviderCoverage(provider, jurisdiction, coverageScope) {
30
+ const normalizedJurisdiction = normalizeCountryCode(jurisdiction);
31
+ const normalizedCoverageScope = normalizeString(coverageScope).toUpperCase();
32
+ if (!normalizedJurisdiction && !normalizedCoverageScope)
33
+ return true;
34
+ const tokens = buildCoverageTokens(provider.areaServed, jurisdiction);
35
+ if (normalizedJurisdiction && tokens.has(normalizedJurisdiction))
36
+ return true;
37
+ if (normalizedCoverageScope && tokens.has(normalizedCoverageScope))
38
+ return true;
39
+ if (normalizedCoverageScope === DataspaceCoverageScope.EuropeanUnion) {
40
+ return Array.from(tokens).some((token) => inferCoverageScopeFromCountryCode(token) === DataspaceCoverageScope.EuropeanUnion);
41
+ }
42
+ return false;
43
+ }
44
+ function matchesDefaultPublishedProvider(provider, input, providerCapability) {
45
+ if (!equalsIgnoreCase(provider.category, input.sector))
46
+ return false;
47
+ if (!isProviderServiceCapability(provider.serviceType))
48
+ return false;
49
+ if (!equalsIgnoreCase(provider.serviceType, providerCapability))
50
+ return false;
51
+ if (!matchesProviderCoverage(provider, input.jurisdiction, input.coverageScope))
52
+ return false;
53
+ return true;
54
+ }
7
55
  function isDefaultsRegistry(value) {
8
56
  return Boolean(value)
9
57
  && typeof value === 'object'
@@ -60,7 +108,15 @@ export class DefaultFirstDataspaceDiscovery {
60
108
  return this.getProviders(input, ServiceCapabilityToken.DigitalTwinProvider);
61
109
  }
62
110
  async getProviders(input, providerCapability) {
63
- const resolver = this.createResolver(input, [providerCapability]);
111
+ const bootstrapPlan = this.buildBootstrapPlan(input, [providerCapability]);
112
+ const defaultPublishedProviders = this.resolveDefaultPublishedProviders(bootstrapPlan.hostingOperators, input, providerCapability);
113
+ if (defaultPublishedProviders.length > 0) {
114
+ return defaultPublishedProviders;
115
+ }
116
+ const resolver = new HttpDataspaceResolver({
117
+ hostingOperators: bootstrapPlan.hostingOperators,
118
+ fetcher: this.fetcher,
119
+ });
64
120
  return resolver.resolvePublishedProviders({
65
121
  sector: input.sector,
66
122
  jurisdiction: input.jurisdiction,
@@ -69,7 +125,14 @@ export class DefaultFirstDataspaceDiscovery {
69
125
  });
70
126
  }
71
127
  createResolver(input, requiredCapabilities) {
72
- const bootstrapPlan = this.defaultsRegistry.buildBootstrapPlan({
128
+ const bootstrapPlan = this.buildBootstrapPlan(input, requiredCapabilities);
129
+ return new HttpDataspaceResolver({
130
+ hostingOperators: bootstrapPlan.hostingOperators,
131
+ fetcher: this.fetcher,
132
+ });
133
+ }
134
+ buildBootstrapPlan(input, requiredCapabilities) {
135
+ return this.defaultsRegistry.buildBootstrapPlan({
73
136
  jurisdiction: input.jurisdiction,
74
137
  version: this.version,
75
138
  networkType: this.networkType,
@@ -78,10 +141,18 @@ export class DefaultFirstDataspaceDiscovery {
78
141
  requiredCapabilities,
79
142
  sourceMode: DataspaceDiscoverySourceMode.DefaultFirst,
80
143
  });
81
- return new HttpDataspaceResolver({
82
- hostingOperators: bootstrapPlan.hostingOperators,
83
- fetcher: this.fetcher,
84
- });
144
+ }
145
+ resolveDefaultPublishedProviders(hosts, input, providerCapability) {
146
+ return hosts.flatMap((host) => (host.publishedProviders || [])
147
+ .filter((provider) => matchesDefaultPublishedProvider(provider, input, providerCapability))
148
+ .map((provider) => ({
149
+ providerDid: provider.providerDid,
150
+ record: provider,
151
+ hostingOperator: host.record,
152
+ hostingOperatorDid: host.operatorDid,
153
+ discoveryUrl: provider.discoveryUrl || host.discoveryUrl,
154
+ catalogUrl: provider.catalogUrl || host.catalogUrl,
155
+ })));
85
156
  }
86
157
  }
87
158
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-sdk-node-ts",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "description": "Next-generation Node runtime package for the GDC SDK family",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Antifraud Services Inc.",
@@ -17,7 +17,7 @@
17
17
  "test:e2e:live-gw": "npm run build && RUN_LIVE_GW_E2E=1 node --test tests/live-gw-node-runtime.e2e.test.mjs"
18
18
  },
19
19
  "dependencies": {
20
- "gdc-common-utils-ts": "^1.14.2",
20
+ "gdc-common-utils-ts": "file:../gdc-common-utils-ts",
21
21
  "gdc-sdk-core-ts": "^0.6.3"
22
22
  },
23
23
  "devDependencies": {