@registrystack/client 0.37.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 +11 -4
- package/breg/client.d.ts +20 -0
- package/breg/client.js +12 -1
- package/breg/index.d.ts +8 -0
- package/discovery/client.d.ts +2 -45
- package/discovery/client.js +0 -20
- package/discovery/index.d.ts +0 -4
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/messaging/client.d.ts +143 -0
- package/messaging/client.js +121 -0
- package/messaging/index.d.ts +27 -0
- package/messaging/index.js +3 -0
- package/native.js +2 -2
- package/package.json +8 -8
- package/relay/client.d.ts +0 -460
- package/relay/client.js +0 -172
- package/relay/index.d.ts +0 -59
- package/relay/index.js +0 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@registrystack/client",
|
|
3
|
-
"version": "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,9 +12,9 @@
|
|
|
12
12
|
"registrystack",
|
|
13
13
|
"discovery",
|
|
14
14
|
"evidence",
|
|
15
|
-
"relay",
|
|
16
15
|
"breg",
|
|
17
|
-
"casework"
|
|
16
|
+
"casework",
|
|
17
|
+
"messaging"
|
|
18
18
|
],
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"access": "public",
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"native.js",
|
|
40
40
|
"discovery",
|
|
41
41
|
"evidence",
|
|
42
|
-
"relay",
|
|
43
42
|
"breg",
|
|
44
|
-
"casework"
|
|
43
|
+
"casework",
|
|
44
|
+
"messaging"
|
|
45
45
|
],
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22.12.0"
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
"typescript": "6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"optionalDependencies": {
|
|
60
|
-
"@registrystack/client-darwin-arm64": "0.
|
|
61
|
-
"@registrystack/client-linux-arm64-gnu": "0.
|
|
62
|
-
"@registrystack/client-linux-x64-gnu": "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"
|
|
63
63
|
}
|
|
64
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 };
|