@registrystack/client 0.38.0 → 0.39.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @registrystack/client
2
2
 
3
- One versioned Node.js package for the Discovery, Evidence, Relay, Base Registry
3
+ One versioned Node.js package for the Discovery, Evidence, Base Registry
4
4
  Engine, Casework, and Messaging client APIs in Registry Stack.
5
5
 
6
6
  ## Install
@@ -11,13 +11,13 @@ npm install "@registrystack/client@<version>"
11
11
 
12
12
  Requires Node.js 22.12 or newer. Supported targets are macOS arm64, Linux
13
13
  arm64 with glibc, and Linux x64 with glibc; installing the package pulls in
14
- one platform-specific optional dependency containing all six native
14
+ one platform-specific optional dependency containing all five native
15
15
  bindings.
16
16
 
17
17
  ## Usage
18
18
 
19
19
  ```js
20
- const { discovery, evidence, relay, breg, casework, messaging } = require('@registrystack/client');
20
+ const { discovery, evidence, breg, casework, messaging } = require('@registrystack/client');
21
21
 
22
22
  const registry = new breg.BaseRegistryClient({
23
23
  baseUrl: 'https://registry.example.invalid/',
@@ -36,7 +36,6 @@ const messages = new messaging.MessagingClient({
36
36
  curated index.
37
37
  - `evidence`: Evidence Gateway, request and verify signed minimum-disclosure
38
38
  assertions.
39
- - `relay`: Registry Relay, scoped read-only APIs over existing sources.
40
39
  - `breg`: Base Registry Engine, records, contracts, writes, lifecycle, and typed
41
40
  applied-request result navigation.
42
41
  - `casework`: Registry Casework, staff inbox, claims, drafts, decisions,
package/breg/client.d.ts CHANGED
@@ -349,8 +349,17 @@ export interface RawOutcome {
349
349
  mediaType: string
350
350
  traceId: string
351
351
  etag?: string
352
+ reprDigest?: string
352
353
  }
353
354
 
355
+ export type StatisticsFormat = 'json' | 'csv'
356
+ export type StatisticsReleaseStatus = 'provisional' | 'final'
357
+ export type StatisticsReleaseSelection = 'any' | 'final'
358
+ export type StatisticsWithdrawalReason =
359
+ | 'computation-error'
360
+ | 'source-data-error'
361
+ | 'disclosure-risk'
362
+
354
363
  export interface PatchOperation {
355
364
  op: 'add' | 'replace' | 'test'
356
365
  field: string
@@ -986,6 +995,8 @@ export interface BaseRegistryClientFailure extends Error {
986
995
  readonly code?: string
987
996
  readonly planRefusal?: string
988
997
  readonly refusalCode?: string
998
+ readonly reasonCode?: string
999
+ readonly fieldPath?: string
989
1000
  readonly status?: number
990
1001
  readonly traceId?: string
991
1002
  readonly transportKind?: string
@@ -997,6 +1008,8 @@ export declare class BaseRegistryClientError extends Error implements BaseRegist
997
1008
  readonly code?: string
998
1009
  readonly planRefusal?: string
999
1010
  readonly refusalCode?: string
1011
+ readonly reasonCode?: string
1012
+ readonly fieldPath?: string
1000
1013
  readonly status?: number
1001
1014
  readonly traceId?: string
1002
1015
  readonly transportKind?: string
@@ -1009,6 +1022,13 @@ export declare class BaseRegistryClient {
1009
1022
  ready(): Promise<CompleteOutcome<ProbeStatus>>
1010
1023
  openapi(accessProfile?: string | null): Promise<RawOutcome>
1011
1024
  registryMetadata(accessProfile?: string | null): Promise<RawOutcome>
1025
+ statisticsLive(dataset: string, from?: string | null, to?: string | null, accessProfile?: string | null, format?: StatisticsFormat | null): Promise<RawOutcome>
1026
+ statisticsReleases(dataset: string, top?: SafeInteger | null, skipToken?: string | null, accessProfile?: string | null): Promise<RawOutcome>
1027
+ statisticsLatestRelease(dataset: string, period: string, selection: StatisticsReleaseSelection, accessProfile?: string | null, format?: StatisticsFormat | null): Promise<RawOutcome>
1028
+ statisticsReleaseVersion(dataset: string, period: string, version: SafeInteger, accessProfile?: string | null, format?: StatisticsFormat | null): Promise<RawOutcome>
1029
+ statisticsReleaseSeries(dataset: string, from: string, to: string, selection: StatisticsReleaseSelection, accessProfile?: string | null, format?: StatisticsFormat | null): Promise<RawOutcome>
1030
+ statisticsPublish(dataset: string, period: string, status: StatisticsReleaseStatus, accessProfile: string, idempotencyKey: string): Promise<RawOutcome>
1031
+ statisticsWithdraw(dataset: string, period: string, version: SafeInteger, reason: StatisticsWithdrawalReason, accessProfile: string, idempotencyKey: string): Promise<RawOutcome>
1012
1032
  registryContract(accessProfile?: string | null): Promise<BRegMetadata>
1013
1033
  entitySchema(entityIdentifier: string, accessProfile?: string | null): Promise<RawOutcome>
1014
1034
  recordRevisions(entityRoute: string, recordIdentifier: string, accessProfile?: string | null): Promise<RawOutcome>
package/breg/client.js CHANGED
@@ -12,9 +12,17 @@ class BaseRegistryClientError extends Error {
12
12
  super(envelope.message);
13
13
  this.name = 'BaseRegistryClientError';
14
14
  this.kind = envelope.kind;
15
- for (const field of ['code', 'planRefusal', 'refusalCode', 'status', 'traceId', 'transportKind', 'tokenKind']) {
15
+ for (const field of ['code', 'planRefusal', 'refusalCode', 'reasonCode', 'status', 'traceId', 'transportKind', 'tokenKind']) {
16
16
  if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
17
17
  }
18
+ if (envelope.fieldPath !== undefined && envelope.fieldPath !== null) {
19
+ Object.defineProperty(this, 'fieldPath', {
20
+ value: envelope.fieldPath,
21
+ configurable: true,
22
+ enumerable: false,
23
+ writable: true,
24
+ });
25
+ }
18
26
  }
19
27
  }
20
28
 
@@ -197,6 +205,9 @@ function wrapAsync(name, jsonIndexes = [], requiredIndexes = []) {
197
205
 
198
206
  for (const [method, jsonIndexes, requiredIndexes] of [
199
207
  ['health'], ['ready'], ['openapi'], ['registryMetadata'], ['registryContract'], ['entitySchema'],
208
+ ['statisticsLive'], ['statisticsReleases'], ['statisticsLatestRelease'],
209
+ ['statisticsReleaseVersion'], ['statisticsReleaseSeries'], ['statisticsPublish'],
210
+ ['statisticsWithdraw'],
200
211
  ['recordRevisions'], ['getRecordRevision', [3]],
201
212
  ['getRecord', [2]], ['listRecords', [1]], ['continueList', [0], [0]],
202
213
  ['getGeoJsonRecord', [2]], ['listGeoJsonRecords', [1]], ['continueGeoJsonList', [0], [0]],
package/breg/index.d.ts CHANGED
@@ -7,6 +7,13 @@ export declare class BaseRegistryClient {
7
7
  ready(): Promise<CompleteOutcome>
8
8
  openapi(accessProfile?: string | undefined | null): Promise<RawOutcome>
9
9
  registryMetadata(accessProfile?: string | undefined | null): Promise<RawOutcome>
10
+ statisticsLive(dataset: string, from?: string | undefined | null, to?: string | undefined | null, accessProfile?: string | undefined | null, format?: string | undefined | null): Promise<RawOutcome>
11
+ statisticsReleases(dataset: string, top?: number | undefined | null, skipToken?: string | undefined | null, accessProfile?: string | undefined | null): Promise<RawOutcome>
12
+ statisticsLatestRelease(dataset: string, period: string, selection: string, accessProfile?: string | undefined | null, format?: string | undefined | null): Promise<RawOutcome>
13
+ statisticsReleaseVersion(dataset: string, period: string, version: number, accessProfile?: string | undefined | null, format?: string | undefined | null): Promise<RawOutcome>
14
+ statisticsReleaseSeries(dataset: string, from: string, to: string, selection: string, accessProfile?: string | undefined | null, format?: string | undefined | null): Promise<RawOutcome>
15
+ statisticsPublish(dataset: string, period: string, status: string, accessProfile: string, idempotencyKey: string): Promise<RawOutcome>
16
+ statisticsWithdraw(dataset: string, period: string, version: number, reason: string, accessProfile: string, idempotencyKey: string): Promise<RawOutcome>
10
17
  registryContract(accessProfile?: string | undefined | null): Promise<BRegMetadata>
11
18
  entitySchema(entityIdentifier: string, accessProfile?: string | undefined | null): Promise<RawOutcome>
12
19
  /** Retrieve one bounded first page of record revisions as inert JSON. */
@@ -369,6 +376,7 @@ export interface RawOutcome {
369
376
  mediaType: string
370
377
  traceId: string
371
378
  etag?: string
379
+ reprDigest?: string
372
380
  }
373
381
 
374
382
  /** Authenticated BReg webhook metadata and exact body. */
@@ -1,4 +1,4 @@
1
- export type ServiceKind = 'evidence' | 'relay';
1
+ export type ServiceKind = 'evidence';
2
2
 
3
3
  export interface DiscoveryClientOptions {
4
4
  baseUrl: string;
@@ -32,8 +32,6 @@ export interface ServiceFilters {
32
32
  jurisdiction?: string[];
33
33
  conformsTo?: string[];
34
34
  evidenceType?: string[];
35
- semanticClass?: string[];
36
- operationFamily?: string[];
37
35
  }
38
36
 
39
37
  export interface EvidenceServiceQuery {
@@ -43,17 +41,6 @@ export interface EvidenceServiceQuery {
43
41
  conformsTo?: string[];
44
42
  }
45
43
 
46
- interface RelayServiceQueryOptions {
47
- jurisdiction?: string;
48
- serviceIds?: string[];
49
- conformsTo?: string[];
50
- }
51
-
52
- export type RelayServiceQuery = RelayServiceQueryOptions & (
53
- | { semanticClassId: string; operationFamilyId?: string }
54
- | { semanticClassId?: string; operationFamilyId: string }
55
- );
56
-
57
44
  export interface ServiceRecord {
58
45
  recordId: string;
59
46
  bindingId: string;
@@ -83,10 +70,7 @@ export interface ServiceSearchResponse {
83
70
  items: ServiceRecord[];
84
71
  }
85
72
 
86
- export type MatchedCapability =
87
- | { kind: 'evidence-type'; id: string }
88
- | { kind: 'semantic-class'; id: string }
89
- | { kind: 'operation-family'; id: string };
73
+ export type MatchedCapability = { kind: 'evidence-type'; id: string };
90
74
 
91
75
  export interface SelectionRequest {
92
76
  recordId: string;
@@ -110,15 +94,6 @@ export interface EvidenceSelectionRequest {
110
94
  resolution?: EvidenceResolutionContext;
111
95
  }
112
96
 
113
- export type RelayCapabilityMatch =
114
- | { semanticClassId: string; operationFamilyId?: string }
115
- | { semanticClassId?: string; operationFamilyId: string };
116
-
117
- export interface RelaySelectionRequest {
118
- recordId: string;
119
- capabilityMatch: RelayCapabilityMatch;
120
- }
121
-
122
97
  export interface CommonServiceSelection extends Omit<ServiceRecord, 'title' | 'description'> {
123
98
  matchedCapability: MatchedCapability;
124
99
  catalogRevision: string;
@@ -131,14 +106,6 @@ export interface EvidenceServiceSelection extends CommonServiceSelection {
131
106
  evidenceResolution?: EvidenceResolutionContext;
132
107
  }
133
108
 
134
- export interface RelayServiceSelection extends CommonServiceSelection {
135
- serviceKind: 'relay';
136
- matchedCapability:
137
- | { kind: 'semantic-class'; id: string }
138
- | { kind: 'operation-family'; id: string };
139
- relayCapabilityMatch: RelayCapabilityMatch;
140
- }
141
-
142
109
  export type ServiceSelection = CommonServiceSelection;
143
110
 
144
111
  export type DiscoveryClientErrorKind =
@@ -168,7 +135,6 @@ export class DiscoveryClient {
168
135
  resolveEvidenceTypes(request: EvidenceTypeResolveRequest): Promise<EvidenceTypeResolveResponse>;
169
136
  searchServices(filters?: ServiceFilters): Promise<ServiceSearchResponse>;
170
137
  searchEvidenceServices(query: EvidenceServiceQuery): Promise<ServiceSearchResponse>;
171
- searchRelayServices(query: RelayServiceQuery): Promise<ServiceSearchResponse>;
172
138
  selectExact(response: ServiceSearchResponse, request: SelectionRequest): CommonServiceSelection;
173
139
  selectEvidenceAlternative(
174
140
  response: EvidenceTypeResolveResponse,
@@ -178,10 +144,6 @@ export class DiscoveryClient {
178
144
  response: ServiceSearchResponse,
179
145
  request: EvidenceSelectionRequest,
180
146
  ): EvidenceServiceSelection;
181
- selectRelayService(
182
- response: ServiceSearchResponse,
183
- request: RelaySelectionRequest,
184
- ): RelayServiceSelection;
185
147
  }
186
148
 
187
149
  export function selectExact(
@@ -199,11 +161,6 @@ export function selectEvidenceService(
199
161
  request: EvidenceSelectionRequest,
200
162
  ): EvidenceServiceSelection;
201
163
 
202
- export function selectRelayService(
203
- response: ServiceSearchResponse,
204
- request: RelaySelectionRequest,
205
- ): RelayServiceSelection;
206
-
207
164
  /**
208
165
  * Validate closed shape and capability binding only.
209
166
  *
@@ -222,14 +222,6 @@ class DiscoveryClient {
222
222
  }
223
223
  }
224
224
 
225
- async searchRelayServices(query) {
226
- try {
227
- return await this.#inner.searchRelayServices(requestValue(query));
228
- } catch (error) {
229
- throw normalize(error, 'query');
230
- }
231
- }
232
-
233
225
  selectExact(response, request) {
234
226
  try {
235
227
  return this.#inner.selectExact(responseValue(response), requestValue(request));
@@ -246,9 +238,6 @@ class DiscoveryClient {
246
238
  return selectEvidenceService(response, request);
247
239
  }
248
240
 
249
- selectRelayService(response, request) {
250
- return selectRelayService(response, request);
251
- }
252
241
  }
253
242
 
254
243
  function selectExact(response, request) {
@@ -278,14 +267,6 @@ function selectEvidenceService(response, request) {
278
267
  }
279
268
  }
280
269
 
281
- function selectRelayService(response, request) {
282
- try {
283
- return native.selectRelayService(responseValue(response), requestValue(request));
284
- } catch (error) {
285
- throw normalize(error, 'query');
286
- }
287
- }
288
-
289
270
  function validateSelectionStructure(selection) {
290
271
  try {
291
272
  return native.validateSelectionStructure(requestValue(selection));
@@ -323,7 +304,6 @@ module.exports = {
323
304
  selectEvidenceAlternative,
324
305
  selectEvidenceService,
325
306
  selectExact,
326
- selectRelayService,
327
307
  validateSelection,
328
308
  validateSelectionStructure,
329
309
  };
@@ -6,11 +6,9 @@ export declare class DiscoveryClient {
6
6
  resolveEvidenceTypes(request: any): Promise<any>
7
7
  searchServices(filters: any): Promise<any>
8
8
  searchEvidenceServices(query: any): Promise<any>
9
- searchRelayServices(query: any): Promise<any>
10
9
  selectExact(response: any, request: any): any
11
10
  selectEvidenceAlternative(response: any, evidenceTypeListId?: string | undefined | null): any
12
11
  selectEvidenceService(response: any, request: any): any
13
- selectRelayService(response: any, request: any): any
14
12
  }
15
13
 
16
14
  export interface DiscoveryClientOptions {
@@ -29,8 +27,6 @@ export declare function selectEvidenceService(response: any, request: any): any
29
27
 
30
28
  export declare function selectExact(response: any, request: any): any
31
29
 
32
- export declare function selectRelayService(response: any, request: any): any
33
-
34
30
  export declare function validateSelection(selection: any): any
35
31
 
36
32
  export declare function validateSelectionStructure(selection: any): any
package/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
1
  import * as discovery from './discovery/client'
2
2
  import * as evidence from './evidence/client'
3
- import * as relay from './relay/client'
4
3
  import * as breg from './breg/client'
5
4
  import * as casework from './casework/client'
6
5
  import * as messaging from './messaging/client'
7
6
 
8
- export { discovery, evidence, relay, breg, casework, messaging }
7
+ export { discovery, evidence, breg, casework, messaging }
package/index.js CHANGED
@@ -2,10 +2,9 @@
2
2
 
3
3
  // One assignment per namespace, never a `module.exports` object literal: Node
4
4
  // scans this file for these statements to synthesise the named exports an ESM
5
- // consumer imports, and `require()` sees the same six properties either way.
5
+ // consumer imports, and `require()` sees the same five properties either way.
6
6
  exports.discovery = require('./discovery/client');
7
7
  exports.evidence = require('./evidence/client');
8
- exports.relay = require('./relay/client');
9
8
  exports.breg = require('./breg/client');
10
9
  exports.casework = require('./casework/client');
11
10
  exports.messaging = require('./messaging/client');
package/native.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const PACKAGE_VERSION = '0.38.0';
4
- const PRODUCTS = new Set(['discovery', 'evidence', 'relay', 'breg', 'casework', 'messaging']);
3
+ const PACKAGE_VERSION = '0.39.0';
4
+ const PRODUCTS = new Set(['discovery', 'evidence', 'breg', 'casework', 'messaging']);
5
5
 
6
6
  function target() {
7
7
  if (process.platform === 'darwin' && process.arch === 'arm64') return 'darwin-arm64';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@registrystack/client",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Unified Node.js client for Registry Stack products.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.registrystack.org/reference/client-api/",
@@ -12,7 +12,6 @@
12
12
  "registrystack",
13
13
  "discovery",
14
14
  "evidence",
15
- "relay",
16
15
  "breg",
17
16
  "casework",
18
17
  "messaging"
@@ -40,7 +39,6 @@
40
39
  "native.js",
41
40
  "discovery",
42
41
  "evidence",
43
- "relay",
44
42
  "breg",
45
43
  "casework",
46
44
  "messaging"
@@ -59,8 +57,8 @@
59
57
  "typescript": "6.0.3"
60
58
  },
61
59
  "optionalDependencies": {
62
- "@registrystack/client-darwin-arm64": "0.38.0",
63
- "@registrystack/client-linux-arm64-gnu": "0.38.0",
64
- "@registrystack/client-linux-x64-gnu": "0.38.0"
60
+ "@registrystack/client-darwin-arm64": "0.39.0",
61
+ "@registrystack/client-linux-arm64-gnu": "0.39.0",
62
+ "@registrystack/client-linux-x64-gnu": "0.39.0"
65
63
  }
66
64
  }
package/relay/client.d.ts DELETED
@@ -1,460 +0,0 @@
1
- export type JsonScalar = string | number | boolean | null
2
- export type JsonValue = JsonScalar | ReadonlyArray<JsonValue> | { readonly [key: string]: JsonValue }
3
- /** An integer that satisfies `Number.isSafeInteger` and the option's documented bounds. */
4
- export type SafeInteger = number
5
-
6
- export interface PrivateJwk {
7
- readonly kty: string
8
- readonly kid: string
9
- readonly alg: string
10
- readonly [member: string]: JsonValue
11
- }
12
-
13
- export interface PrivateKeyJwtConfig {
14
- tokenEndpoint: string
15
- clientId: string
16
- clientKey: PrivateJwk
17
- /**
18
- * The audience of the client assertion (who checks the client's
19
- * authentication). Defaults to the token endpoint URL. This is not the
20
- * `resource` of the token request.
21
- */
22
- audience?: string | null
23
- /**
24
- * The RFC 8707 resource indicator the token is requested for: the resource
25
- * server's registered identifier, not a URL to fetch.
26
- */
27
- resource?: string | null
28
- /**
29
- * The scopes requested for the token, sent as one space-delimited `scope`
30
- * parameter. A requested scope may narrow the client's registered
31
- * permission set; it can never widen it.
32
- */
33
- scopes?: ReadonlyArray<string> | null
34
- assertionLifetimeSeconds?: SafeInteger | null
35
- refreshMarginSeconds?: SafeInteger | null
36
- requestTimeoutMilliseconds?: SafeInteger | null
37
- connectTimeoutMilliseconds?: SafeInteger | null
38
- userAgent?: string | null
39
- trustedRootCertificates?: string | null
40
- }
41
-
42
- /** One immutable verified person or grant context. Reconstruct after host source facts change. */
43
- export interface ExchangeContext {
44
- issuer: string
45
- subject: string
46
- audience: string
47
- generation: string
48
- deadlineSeconds: SafeInteger
49
- grantId?: string | null
50
- }
51
-
52
- export type ExchangePrivateKeyJwtConfig = PrivateKeyJwtConfig & {
53
- resource: string
54
- scopes: ReadonlyArray<string>
55
- }
56
-
57
- export interface FirstPartyExchangeSource {
58
- key: PrivateJwk
59
- attributes: Readonly<Record<string, JsonValue>>
60
- }
61
-
62
- export interface RemoteExchangeSource {
63
- endpoint: string
64
- bootstrap: ExchangePrivateKeyJwtConfig
65
- bootstrapResource: string
66
- bootstrapScope: string
67
- requestTimeoutMilliseconds?: SafeInteger | null
68
- connectTimeoutMilliseconds?: SafeInteger | null
69
- userAgent?: string | null
70
- trustedRootCertificates?: string | null
71
- }
72
-
73
- export type ExchangeAuthorizationConfig =
74
- | { client: ExchangePrivateKeyJwtConfig; context: ExchangeContext; firstParty: FirstPartyExchangeSource }
75
- | { client: ExchangePrivateKeyJwtConfig; context: ExchangeContext; remote: RemoteExchangeSource }
76
-
77
- export type RelayAuthorization =
78
- | { static: string }
79
- | { privateKeyJwt: PrivateKeyJwtConfig }
80
- | { exchange: ExchangeAuthorizationConfig }
81
-
82
- export interface RelayClientConfig {
83
- baseUrl: string
84
- authorization?: RelayAuthorization | null
85
- requestTimeoutMilliseconds?: SafeInteger | null
86
- connectTimeoutMilliseconds?: SafeInteger | null
87
- userAgent?: string | null
88
- maxResponseBytes?: SafeInteger | null
89
- trustedRootCertificates?: string | null
90
- }
91
-
92
- export type RecordFormat = 'json' | 'json-ld' | 'geojson' | 'json-fg'
93
-
94
- export interface ResourceListOptions {
95
- pageSize?: SafeInteger | null
96
- }
97
-
98
- export interface ResourceContinuation {
99
- cursor: string
100
- }
101
-
102
- export interface RecordOptions {
103
- fields?: ReadonlyArray<string> | null
104
- accessProfile?: string | null
105
- format?: RecordFormat | null
106
- }
107
-
108
- export interface ListOptions extends RecordOptions {
109
- pageSize?: SafeInteger | null
110
- filters?: Readonly<Record<string, string>> | null
111
- }
112
-
113
- export interface SearchOptions extends RecordOptions {
114
- pageSize?: SafeInteger | null
115
- /** `[west, south, east, north]` in WGS84 longitude/latitude degrees. */
116
- bbox: readonly [number, number, number, number]
117
- }
118
-
119
- export type LookupSelector = string | SafeInteger | boolean
120
- export type LookupSelectors = Readonly<Record<string, LookupSelector>>
121
-
122
- export interface RecordsRoute {
123
- kind: 'records'
124
- resource: string
125
- }
126
-
127
- export interface SearchRoute {
128
- kind: 'search'
129
- resource: string
130
- search: string
131
- }
132
-
133
- export interface CollectionContinuation<Route extends RecordsRoute | SearchRoute = RecordsRoute | SearchRoute> {
134
- route: Route
135
- cursor: string
136
- format: 'json' | 'json-ld' | 'geojson-rfc7946' | 'json-fg'
137
- accessProfile?: string
138
- }
139
-
140
- export interface SdmxDataRequest {
141
- agency: string
142
- resource: string
143
- /** A three-part `x.y.z` SDMX version. */
144
- version: string
145
- key?: string | null
146
- constraints?: Readonly<Record<string, string>> | null
147
- offset?: SafeInteger | null
148
- limit?: SafeInteger | null
149
- dimensionAtObservation?: string | null
150
- format?: 'json' | 'csv' | null
151
- }
152
-
153
- export interface SdmxStructureRequest {
154
- kind: 'dataflow' | 'datastructure'
155
- agency: string
156
- resource: string
157
- /** A three-part `x.y.z` SDMX version. */
158
- version: string
159
- }
160
-
161
- export interface ProbeStatus {
162
- status: string
163
- }
164
-
165
- export interface Institution {
166
- identifier: string
167
- name: string
168
- }
169
-
170
- export interface Product {
171
- name: string
172
- version: string
173
- }
174
-
175
- export interface ApiBinding {
176
- name: string
177
- version: string
178
- }
179
-
180
- export interface AlignmentTarget {
181
- name: string
182
- version: string
183
- status: string
184
- cfrTarget?: string
185
- }
186
-
187
- export interface FormatProfileCapability {
188
- id: string
189
- uri: string
190
- crs: string
191
- conformsTo: ReadonlyArray<string>
192
- }
193
-
194
- export interface WireFormatCapability {
195
- id: string
196
- mediaType: string
197
- formatProfiles: ReadonlyArray<FormatProfileCapability>
198
- }
199
-
200
- export interface BboxCapability {
201
- crs: string
202
- predicate: string
203
- maximumLongitudeSpanDegrees: number
204
- maximumLatitudeSpanDegrees: number
205
- }
206
-
207
- export interface SpatialQueryCapability {
208
- bbox: BboxCapability
209
- }
210
-
211
- export interface ConsultationCapability {
212
- family: 'consultation'
213
- pattern: string
214
- resourceIdentifier: string
215
- operationIdentifier: string
216
- accessProfileIdentifier: string
217
- isDefault: boolean
218
- disclosureProfile: string
219
- schemaReference: string
220
- semanticModelReference: string
221
- contextReference: string
222
- href: string
223
- wireFormats: ReadonlyArray<WireFormatCapability>
224
- spatialQuery?: SpatialQueryCapability
225
- classificationReference?: string
226
- processingReference?: string
227
- }
228
-
229
- export interface SdmxProfile {
230
- sdmxRestVersion: string
231
- sdmxDataJsonVersion: string
232
- sdmxDataCsvVersion: string
233
- sdmxStructureJsonVersion: string
234
- }
235
-
236
- export interface SdmxWireFormat {
237
- id: string
238
- mediaType: string
239
- }
240
-
241
- export interface SdmxStructureLinks {
242
- dataflow: string
243
- datastructure: string
244
- }
245
-
246
- export interface AggregateDataCapability {
247
- family: 'aggregate-data'
248
- pattern: string
249
- statisticalDatasetIdentifier: string
250
- operationIdentifier: string
251
- profile: SdmxProfile
252
- wireFormats: ReadonlyArray<SdmxWireFormat>
253
- href: string
254
- structureLinks: SdmxStructureLinks
255
- }
256
-
257
- export type Capability = ConsultationCapability | AggregateDataCapability
258
-
259
- export interface ServiceMetadata {
260
- registryIdentifier: string
261
- name: string
262
- authority: Institution
263
- operator: Institution | null
264
- authoritativeScope: string
265
- product: Product
266
- apiBinding: ApiBinding
267
- alignmentTargets: ReadonlyArray<AlignmentTarget>
268
- capabilities: ReadonlyArray<Capability>
269
- links: { self: string; resources: string; openapi: string }
270
- }
271
-
272
- export interface ResourceDocument {
273
- resourceIdentifier: string
274
- title: string
275
- description: string
276
- semanticClass: string
277
- enumerationPosture: string
278
- capabilities: ReadonlyArray<Capability>
279
- links: { self: string }
280
- }
281
-
282
- export interface CursorPageInfo {
283
- nextCursor: string | null
284
- }
285
-
286
- export interface RegistryMetadata {
287
- registryIdentifier: string
288
- }
289
-
290
- export interface ResourceCollection {
291
- items: ReadonlyArray<ResourceDocument>
292
- pageInfo: CursorPageInfo
293
- meta: RegistryMetadata
294
- }
295
-
296
- export interface ResourceEnvelope {
297
- data: ResourceDocument
298
- meta: RegistryMetadata
299
- }
300
-
301
- export interface RegistryRecord {
302
- registryIdentifier: string
303
- recordIdentifier: string
304
- revisionIdentifier: string
305
- lifecycleState: string
306
- schemaReference: string
307
- semanticModelReference: string
308
- authorityIdentifier: string
309
- recordedAt: string
310
- domainData: Readonly<Record<string, JsonValue>>
311
- '@id'?: string
312
- '@type'?: string
313
- }
314
-
315
- export interface SourceRevision {
316
- profile: string
317
- status: string
318
- value: string | null
319
- }
320
-
321
- export interface RecordLinks {
322
- self: string
323
- context: string
324
- schema: string
325
- semanticModel: string
326
- }
327
-
328
- export interface RecordMetadata {
329
- operationIdentifier: string
330
- accessProfile: string
331
- family: string
332
- pattern: string
333
- disclosureProfile: string
334
- contractRevision: string
335
- sourceRevision: SourceRevision
336
- selectedFields: ReadonlyArray<string>
337
- links: RecordLinks
338
- }
339
-
340
- export interface RecordEnvelope {
341
- data: RegistryRecord
342
- meta: RecordMetadata
343
- '@context'?: string
344
- }
345
-
346
- export interface RecordCollection {
347
- items: ReadonlyArray<RegistryRecord>
348
- pageInfo: CursorPageInfo
349
- meta: RecordMetadata
350
- '@context'?: string
351
- }
352
-
353
- export interface GeoJsonFeature {
354
- type: string
355
- id: string
356
- geometry: JsonValue
357
- properties: RegistryRecord
358
- meta?: RecordMetadata
359
- conformsTo?: ReadonlyArray<string>
360
- featureType?: string
361
- coordRefSys?: string
362
- }
363
-
364
- export interface GeoJsonFeatureCollection {
365
- type: string
366
- features: ReadonlyArray<GeoJsonFeature>
367
- pageInfo: CursorPageInfo
368
- meta: RecordMetadata
369
- conformsTo?: ReadonlyArray<string>
370
- featureType?: string
371
- coordRefSys?: string
372
- }
373
-
374
- export type RecordResponse = RecordEnvelope | GeoJsonFeature
375
- export type RecordCollectionResponse = RecordCollection | GeoJsonFeatureCollection
376
-
377
- export interface CompleteOutcome<T> {
378
- kind: 'complete'
379
- value: T
380
- traceId: string
381
- etag?: string
382
- }
383
-
384
- export interface NotModifiedOutcome {
385
- kind: 'notModified'
386
- etag: string
387
- traceId: string
388
- }
389
-
390
- export type Outcome<T> = CompleteOutcome<T> | NotModifiedOutcome
391
-
392
- export interface ResourcePageCompleteOutcome {
393
- kind: 'complete'
394
- value: ResourceCollection
395
- continuation?: ResourceContinuation
396
- traceId: string
397
- etag?: string
398
- }
399
-
400
- export type ResourcePageOutcome = ResourcePageCompleteOutcome | NotModifiedOutcome
401
-
402
- export interface CollectionPageCompleteOutcome {
403
- kind: 'complete'
404
- value: RecordCollectionResponse
405
- continuation?: CollectionContinuation
406
- traceId: string
407
- etag?: string
408
- }
409
-
410
- export type CollectionPageOutcome = CollectionPageCompleteOutcome | NotModifiedOutcome
411
-
412
- export interface RawCompleteOutcome {
413
- kind: 'complete'
414
- body: Buffer
415
- mediaType: string
416
- traceId: string
417
- etag?: string
418
- }
419
-
420
- export type RawOutcome = RawCompleteOutcome | NotModifiedOutcome
421
-
422
- export interface RelayClientFailure extends Error {
423
- readonly kind: string
424
- readonly code?: string
425
- readonly status?: number
426
- readonly traceId?: string
427
- readonly retryAfterSeconds?: number
428
- readonly transportKind?: string
429
- readonly tokenKind?: string
430
- }
431
-
432
- export declare class RelayClientError extends Error implements RelayClientFailure {
433
- readonly kind: string
434
- readonly code?: string
435
- readonly status?: number
436
- readonly traceId?: string
437
- readonly retryAfterSeconds?: number
438
- readonly transportKind?: string
439
- readonly tokenKind?: string
440
- }
441
-
442
- export declare class RelayClient {
443
- constructor(config: RelayClientConfig)
444
- health(): Promise<CompleteOutcome<ProbeStatus>>
445
- ready(): Promise<CompleteOutcome<ProbeStatus>>
446
- openapi(etag?: string | null): Promise<RawOutcome>
447
- serviceMetadata(etag?: string | null): Promise<Outcome<ServiceMetadata>>
448
- resources(options?: ResourceListOptions | null, etag?: string | null): Promise<ResourcePageOutcome>
449
- continueResources(continuation: ResourceContinuation, etag?: string | null): Promise<ResourcePageOutcome>
450
- resource(resource: string, etag?: string | null): Promise<Outcome<ResourceEnvelope>>
451
- listRecords(resource: string, options?: ListOptions | null, etag?: string | null): Promise<CollectionPageOutcome>
452
- continueListRecords(continuation: CollectionContinuation<RecordsRoute>, etag?: string | null): Promise<CollectionPageOutcome>
453
- readRecord(resource: string, recordIdentifier: string, options?: RecordOptions | null, etag?: string | null): Promise<Outcome<RecordResponse>>
454
- lookup(resource: string, lookup: string, selectors: LookupSelectors, options?: RecordOptions | null, etag?: string | null): Promise<Outcome<RecordResponse>>
455
- search(resource: string, search: string, options: SearchOptions, etag?: string | null): Promise<CollectionPageOutcome>
456
- continueSearch(continuation: CollectionContinuation<SearchRoute>, etag?: string | null): Promise<CollectionPageOutcome>
457
- artifact(artifactIdentifier: string, etag?: string | null): Promise<RawOutcome>
458
- sdmxData(request: SdmxDataRequest, etag?: string | null): Promise<RawOutcome>
459
- sdmxStructure(request: SdmxStructureRequest, etag?: string | null): Promise<RawOutcome>
460
- }
package/relay/client.js DELETED
@@ -1,172 +0,0 @@
1
- 'use strict';
2
-
3
- const { types: { isProxy } } = require('node:util');
4
- const native = require('./index');
5
-
6
- const MAX_JSON_DEPTH = 128;
7
- const MAX_JSON_NODES = 100_000;
8
- const MAX_JSON_STRING_BYTES = 4 * 1024 * 1024;
9
-
10
- class RelayClientError extends Error {
11
- constructor(envelope) {
12
- super(envelope.message);
13
- this.name = 'RelayClientError';
14
- this.kind = envelope.kind;
15
- for (const field of ['code', 'status', 'traceId', 'retryAfterSeconds', 'transportKind', 'tokenKind']) {
16
- if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
17
- }
18
- }
19
- }
20
-
21
- function normalize(error, fallbackKind) {
22
- if (error instanceof RelayClientError) return error;
23
- if (error instanceof Error && typeof error.message === 'string') {
24
- try {
25
- const envelope = JSON.parse(error.message);
26
- if (envelope && typeof envelope === 'object' && typeof envelope.kind === 'string') {
27
- return new RelayClientError(envelope);
28
- }
29
- } catch {
30
- // napi argument conversion errors are not mapped Rust error envelopes.
31
- }
32
- }
33
- if (fallbackKind) {
34
- return new RelayClientError({
35
- kind: fallbackKind,
36
- message: fallbackKind === 'configuration'
37
- ? 'Relay client configuration is invalid'
38
- : 'Relay client arguments are invalid',
39
- });
40
- }
41
- return error;
42
- }
43
-
44
- function inputError(kind) {
45
- return new RelayClientError({
46
- kind,
47
- message: kind === 'configuration'
48
- ? 'Relay client configuration is invalid'
49
- : 'Relay client arguments are invalid',
50
- });
51
- }
52
-
53
- function chargeString(value, budget, kind) {
54
- budget.stringBytes += Buffer.byteLength(value, 'utf8');
55
- if (budget.stringBytes > MAX_JSON_STRING_BYTES) throw inputError(kind);
56
- }
57
-
58
- function cloneJson(value, budget, depth, allowUndefined, kind) {
59
- if (depth > MAX_JSON_DEPTH) throw inputError(kind);
60
- budget.nodes += 1;
61
- if (budget.nodes > MAX_JSON_NODES) throw inputError(kind);
62
-
63
- if (value === undefined) {
64
- if (allowUndefined) return undefined;
65
- throw inputError(kind);
66
- }
67
- if (value === null || typeof value === 'boolean') return value;
68
- if (typeof value === 'string') {
69
- chargeString(value, budget, kind);
70
- return value;
71
- }
72
- if (typeof value === 'number') {
73
- if (!Number.isFinite(value)) throw inputError(kind);
74
- return value;
75
- }
76
- if (typeof value !== 'object' || isProxy(value)) throw inputError(kind);
77
-
78
- const prototype = Object.getPrototypeOf(value);
79
- const array = Array.isArray(value);
80
- if (array ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) {
81
- throw inputError(kind);
82
- }
83
- if (budget.active.has(value)) throw inputError(kind);
84
- budget.active.add(value);
85
-
86
- try {
87
- const keys = Reflect.ownKeys(value);
88
- if (keys.some((key) => typeof key === 'symbol')) throw inputError(kind);
89
-
90
- if (array) {
91
- if (value.length + budget.nodes > MAX_JSON_NODES) throw inputError(kind);
92
- const clone = new Array(value.length);
93
- let elementCount = 0;
94
- for (const key of keys) {
95
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
96
- if (!descriptor || !Object.hasOwn(descriptor, 'value')) throw inputError(kind);
97
- if (key === 'length') continue;
98
- chargeString(key, budget, kind);
99
- const index = Number(key);
100
- if (!descriptor.enumerable || !Number.isInteger(index) || index < 0
101
- || index >= value.length || String(index) !== key) {
102
- throw inputError(kind);
103
- }
104
- clone[index] = cloneJson(descriptor.value, budget, depth + 1, false, kind);
105
- elementCount += 1;
106
- }
107
- if (elementCount !== value.length) throw inputError(kind);
108
- return clone;
109
- }
110
-
111
- const clone = Object.create(null);
112
- for (const key of keys) {
113
- chargeString(key, budget, kind);
114
- const descriptor = Object.getOwnPropertyDescriptor(value, key);
115
- if (!descriptor || !Object.hasOwn(descriptor, 'value')) throw inputError(kind);
116
- if (!descriptor.enumerable) continue;
117
- clone[key] = cloneJson(descriptor.value, budget, depth + 1, false, kind);
118
- }
119
- return clone;
120
- } finally {
121
- budget.active.delete(value);
122
- }
123
- }
124
-
125
- function cloneArguments(args, kind, requiredJsonArguments = new Set()) {
126
- const budget = { nodes: 0, stringBytes: 0, active: new WeakSet() };
127
- return args.map((value, index) => (
128
- cloneJson(value, budget, 0, !requiredJsonArguments.has(index), kind)
129
- ));
130
- }
131
-
132
- function wrapAsync(prototype, name, requiredJsonArguments) {
133
- const original = prototype[name];
134
- prototype[name] = function (...args) {
135
- try {
136
- const clonedArgs = cloneArguments(args, 'invalid_request', requiredJsonArguments);
137
- return original.apply(this, clonedArgs).catch((error) => { throw normalize(error); });
138
- } catch (error) {
139
- throw normalize(error, 'invalid_request');
140
- }
141
- };
142
- }
143
-
144
- const METHODS = [
145
- 'health', 'ready', 'openapi', 'serviceMetadata', 'resources', 'continueResources', 'resource',
146
- 'listRecords', 'continueListRecords', 'readRecord', 'lookup', 'search', 'continueSearch',
147
- 'artifact', 'sdmxData', 'sdmxStructure',
148
- ];
149
- const REQUIRED_JSON_ARGUMENTS = {
150
- continueResources: new Set([0]),
151
- continueListRecords: new Set([0]),
152
- lookup: new Set([2]),
153
- search: new Set([2]),
154
- continueSearch: new Set([0]),
155
- sdmxData: new Set([0]),
156
- sdmxStructure: new Set([0]),
157
- };
158
- for (const method of METHODS) {
159
- wrapAsync(native.RelayClient.prototype, method, REQUIRED_JSON_ARGUMENTS[method]);
160
- }
161
-
162
- class RelayClient extends native.RelayClient {
163
- constructor(config) {
164
- try {
165
- super(...cloneArguments([config], 'configuration', new Set([0])));
166
- } catch (error) {
167
- throw normalize(error, 'configuration');
168
- }
169
- }
170
- }
171
-
172
- module.exports = { RelayClient, RelayClientError };
package/relay/index.d.ts DELETED
@@ -1,59 +0,0 @@
1
- /* auto-generated by NAPI-RS */
2
- /* eslint-disable */
3
-
4
- export declare class RelayClient {
5
- constructor(configValue: any)
6
- health(): Promise<CompleteOutcome>
7
- ready(): Promise<CompleteOutcome>
8
- openapi(etag?: string | undefined | null): Promise<RawCompleteOutcome | NotModifiedOutcome>
9
- serviceMetadata(etag?: string | undefined | null): Promise<CompleteOutcome | NotModifiedOutcome>
10
- resources(options?: any | undefined | null, etag?: string | undefined | null): Promise<ResourcePageOutcome | NotModifiedOutcome>
11
- continueResources(continuation: any, etag?: string | undefined | null): Promise<ResourcePageOutcome | NotModifiedOutcome>
12
- resource(resource: string, etag?: string | undefined | null): Promise<CompleteOutcome | NotModifiedOutcome>
13
- listRecords(resource: string, options?: any | undefined | null, etag?: string | undefined | null): Promise<CollectionPageOutcome | NotModifiedOutcome>
14
- continueListRecords(continuation: any, etag?: string | undefined | null): Promise<CollectionPageOutcome | NotModifiedOutcome>
15
- readRecord(resource: string, recordIdentifier: string, options?: any | undefined | null, etag?: string | undefined | null): Promise<CompleteOutcome | NotModifiedOutcome>
16
- lookup(resource: string, lookup: string, selectors: any, options?: any | undefined | null, etag?: string | undefined | null): Promise<CompleteOutcome | NotModifiedOutcome>
17
- search(resource: string, search: string, options: any, etag?: string | undefined | null): Promise<CollectionPageOutcome | NotModifiedOutcome>
18
- continueSearch(continuation: any, etag?: string | undefined | null): Promise<CollectionPageOutcome | NotModifiedOutcome>
19
- artifact(artifactIdentifier: string, etag?: string | undefined | null): Promise<RawCompleteOutcome | NotModifiedOutcome>
20
- sdmxData(requestValue: any, etag?: string | undefined | null): Promise<RawCompleteOutcome | NotModifiedOutcome>
21
- sdmxStructure(requestValue: any, etag?: string | undefined | null): Promise<RawCompleteOutcome | NotModifiedOutcome>
22
- }
23
-
24
- export interface CollectionPageOutcome {
25
- kind: string
26
- value: any
27
- continuation?: any
28
- traceId: string
29
- etag?: string
30
- }
31
-
32
- export interface CompleteOutcome {
33
- kind: string
34
- value: any
35
- traceId: string
36
- etag?: string
37
- }
38
-
39
- export interface NotModifiedOutcome {
40
- kind: string
41
- etag: string
42
- traceId: string
43
- }
44
-
45
- export interface RawCompleteOutcome {
46
- kind: string
47
- body: Buffer
48
- mediaType: string
49
- traceId: string
50
- etag?: string
51
- }
52
-
53
- export interface ResourcePageOutcome {
54
- kind: string
55
- value: any
56
- continuation?: any
57
- traceId: string
58
- etag?: string
59
- }
package/relay/index.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict';
2
-
3
- module.exports = require('../native').load('relay');