@registrystack/client 0.38.0 → 0.40.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 +30 -7
- package/breg/client.d.ts +120 -10
- package/breg/client.js +53 -35
- package/breg/index.d.ts +64 -2
- package/casework/client.d.ts +84 -30
- package/casework/client.js +22 -17
- package/casework/index.d.ts +7 -0
- package/discovery/client.d.ts +9 -52
- package/discovery/client.js +1 -21
- package/discovery/index.d.ts +0 -4
- package/evidence/client.d.ts +1 -1
- package/evidence/index.d.ts +3 -6
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/messaging/client.d.ts +23 -4
- package/messaging/client.js +32 -21
- package/messaging/index.d.ts +1 -10
- package/native.js +2 -2
- package/package.json +9 -9
- package/scheduling/client.d.ts +226 -0
- package/scheduling/client.js +141 -0
- package/scheduling/index.d.ts +27 -0
- package/scheduling/index.js +3 -0
- 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/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