@registrystack/client 0.29.0 → 0.30.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/breg/client.js CHANGED
@@ -12,7 +12,7 @@ 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', 'status', 'traceId', 'transportKind', 'tokenKind']) {
15
+ for (const field of ['code', 'planRefusal', 'refusalCode', 'status', 'traceId', 'transportKind', 'tokenKind']) {
16
16
  if (envelope[field] !== undefined && envelope[field] !== null) this[field] = envelope[field];
17
17
  }
18
18
  }
@@ -65,7 +65,8 @@ function cloneJson(value, budget, depth, kind) {
65
65
  return value;
66
66
  }
67
67
  if (typeof value === 'number') {
68
- if (!Number.isFinite(value)) throw inputError(kind);
68
+ if (!Number.isFinite(value)
69
+ || (Number.isInteger(value) && !Number.isSafeInteger(value))) throw inputError(kind);
69
70
  return value;
70
71
  }
71
72
  if (value === undefined || typeof value !== 'object' || isProxy(value)) throw inputError(kind);
@@ -138,15 +139,85 @@ function wrapAsync(name, jsonIndexes = [], requiredIndexes = []) {
138
139
 
139
140
  for (const [method, jsonIndexes, requiredIndexes] of [
140
141
  ['health'], ['ready'], ['openapi'], ['registryMetadata'], ['registryContract'], ['entitySchema'],
142
+ ['recordRevisions'], ['getRecordRevision', [3]],
141
143
  ['getRecord', [2]], ['listRecords', [1]], ['continueList', [0], [0]],
144
+ ['getGeoJsonRecord', [2]], ['listGeoJsonRecords', [1]], ['continueGeoJsonList', [0], [0]],
145
+ ['listCurrentRecords', [1]], ['continueCurrentList', [0], [0]],
146
+ ['listRecordsAsOf', [1], [1]], ['continueAsOfList', [0], [0]],
147
+ ['listSnapshotRecords', [1]], ['continueSnapshotList', [0], [0]],
148
+ ['listRelationshipRecords', [3]], ['continueRelationshipList', [0], [0]],
142
149
  ['lookupRecord', [2, 3]], ['createRecord', [1], [1]],
143
- ['patchRecord', [3], [3]], ['executeLifecycleAction'],
150
+ ['actionTargetConditions', [1], [1]], ['invokeAction', [1], [1]],
151
+ ['executeRecoveredCreate'],
152
+ ['patchRecord', [3], [3]], ['batchRecords', [1], [1]], ['tombstoneRecord'],
153
+ ['executeLifecycleAction'],
154
+ ['executeRecoveredLifecycleAction'],
144
155
  ['uploadAttachment'], ['downloadAttachment'], ['deleteAttachment'],
145
156
  ['getRecordJson', [2]], ['listRecordsJson', [1]], ['continueListJson', [0], [0]],
157
+ ['getGeoJsonRecordJson', [2]], ['listGeoJsonRecordsJson', [1]],
158
+ ['continueGeoJsonListJson', [0], [0]],
159
+ ['listCurrentRecordsJson', [1]], ['continueCurrentListJson', [0], [0]],
160
+ ['listRecordsAsOfJson', [1], [1]], ['continueAsOfListJson', [0], [0]],
161
+ ['listSnapshotRecordsJson', [1]], ['continueSnapshotListJson', [0], [0]],
162
+ ['listRelationshipRecordsJson', [3]], ['continueRelationshipListJson', [0], [0]],
146
163
  ['lookupRecordJson', [3]], ['createRecordJson'], ['patchRecordJson'], ['executeLifecycleActionJson'],
164
+ ['actionTargetConditionsJson'], ['invokeActionJson'], ['batchRecordsJson'], ['tombstoneRecordJson'],
165
+ ['executeRecoveredCreateJson'], ['executeRecoveredLifecycleActionJson'],
147
166
  ['uploadAttachmentJson'], ['deleteAttachmentJson'],
148
167
  ]) wrapAsync(method, jsonIndexes, requiredIndexes);
149
168
 
169
+ for (const [method, jsonIndexes, requiredIndexes] of [
170
+ ['prepareCreate', [1], [1]], ['prepareCreateJson'], ['recoverCreate'],
171
+ ['prepareLifecycleAction', [1], [1]], ['prepareLifecycleActionJson'],
172
+ ['recoverLifecycleAction'],
173
+ ]) {
174
+ const original = native.BaseRegistryClient.prototype[method];
175
+ native.BaseRegistryClient.prototype[method] = function (...args) {
176
+ try {
177
+ return original.apply(this, sanitizeArguments(
178
+ args, new Set(jsonIndexes), new Set(requiredIndexes),
179
+ ));
180
+ } catch (error) {
181
+ throw normalize(error, 'invalid_request');
182
+ }
183
+ };
184
+ }
185
+
186
+ function preparedClass(Class, label) {
187
+ Object.defineProperty(Class.prototype, Symbol.for('nodejs.util.inspect.custom'), {
188
+ value() { return `${label}(<redacted>)`; },
189
+ });
190
+ Object.defineProperty(Class.prototype, 'toString', {
191
+ value() { return `${label}(<redacted>)`; },
192
+ });
193
+ const Facade = function () {
194
+ throw new TypeError(`${label} has no public constructor`);
195
+ };
196
+ Object.defineProperties(Facade, {
197
+ name: { value: label },
198
+ fromBytes: {
199
+ value(bytes) {
200
+ try {
201
+ if (!Buffer.isBuffer(bytes)) throw inputError('invalid_request');
202
+ return Class.fromBytes(bytes);
203
+ } catch (error) {
204
+ throw normalize(error, 'invalid_request');
205
+ }
206
+ },
207
+ },
208
+ [Symbol.hasInstance]: {
209
+ value(value) { return value instanceof Class; },
210
+ },
211
+ });
212
+ Facade.prototype = Class.prototype;
213
+ return Facade;
214
+ }
215
+
216
+ const BRegPreparedCreate = preparedClass(native.BRegPreparedCreate, 'BRegPreparedCreate');
217
+ const BRegPreparedLifecycle = preparedClass(
218
+ native.BRegPreparedLifecycle, 'BRegPreparedLifecycle',
219
+ );
220
+
150
221
  const withReason = native.BRegLifecycleAction.prototype.withReason;
151
222
  native.BRegLifecycleAction.prototype.withReason = function (reason) {
152
223
  try {
@@ -193,7 +264,10 @@ for (const name of ['prepareUpload', 'acceptsContentType']) {
193
264
  };
194
265
  }
195
266
 
196
- for (const name of ['selectCreate', 'selectPatch', 'selectLifecycle', 'selectAttachments']) {
267
+ for (const name of [
268
+ 'selectCreate', 'selectPatch', 'selectLifecycle', 'selectAttachments',
269
+ 'selectImmediateAction', 'selectTombstone', 'selectBatch', 'changeRequestCapability',
270
+ ]) {
197
271
  const original = native.BRegMetadata.prototype[name];
198
272
  native.BRegMetadata.prototype[name] = function (...args) {
199
273
  try {
@@ -224,4 +298,12 @@ module.exports = {
224
298
  BRegLifecycleAction: native.BRegLifecycleAction,
225
299
  BRegAttachmentSlot: native.BRegAttachmentSlot,
226
300
  BRegAttachmentUpload: native.BRegAttachmentUpload,
301
+ BRegImmediateActionBinding: native.BRegImmediateActionBinding,
302
+ BRegActionTargetConditions: native.BRegActionTargetConditions,
303
+ BRegTombstoneBinding: native.BRegTombstoneBinding,
304
+ BRegBatchBinding: native.BRegBatchBinding,
305
+ BRegPreparedCreate,
306
+ BRegPreparedLifecycle,
307
+ BRegRecoveredCreate: native.BRegRecoveredCreate,
308
+ BRegRecoveredLifecycle: native.BRegRecoveredLifecycle,
227
309
  };
package/breg/index.d.ts CHANGED
@@ -8,12 +8,41 @@ export declare class BaseRegistryClient {
8
8
  registryMetadata(accessProfile?: string | undefined | null): Promise<RawOutcome>
9
9
  registryContract(accessProfile?: string | undefined | null): Promise<BRegMetadata>
10
10
  entitySchema(entityIdentifier: string, accessProfile?: string | undefined | null): Promise<RawOutcome>
11
+ /** Retrieve one bounded first page of record revisions as inert JSON. */
12
+ recordRevisions(entityRoute: string, recordIdentifier: string, accessProfile?: string | undefined | null): Promise<RawOutcome>
13
+ /** Retrieve one exact retained revision as validated inert record JSON. */
14
+ getRecordRevision(entityRoute: string, recordIdentifier: string, revision: number, options?: any | undefined | null): Promise<RawOutcome>
11
15
  getRecord(entityRoute: string, recordIdentifier: string, options?: any | undefined | null): Promise<CompleteOutcome>
12
16
  listRecords(entityRoute: string, options?: any | undefined | null): Promise<PageOutcome>
13
17
  continueList(value: any): Promise<PageOutcome>
18
+ getGeoJsonRecord(entityRoute: string, recordIdentifier: string, options?: any | undefined | null): Promise<CompleteOutcome>
19
+ listGeoJsonRecords(entityRoute: string, options?: any | undefined | null): Promise<PageOutcome>
20
+ continueGeoJsonList(value: any): Promise<PageOutcome>
21
+ listCurrentRecords(entityRoute: string, options?: any | undefined | null): Promise<PageOutcome>
22
+ continueCurrentList(value: any): Promise<PageOutcome>
23
+ listRecordsAsOf(entityRoute: string, options?: any | undefined | null): Promise<PageOutcome>
24
+ continueAsOfList(value: any): Promise<PageOutcome>
25
+ listSnapshotRecords(entityRoute: string, options?: any | undefined | null): Promise<PageOutcome>
26
+ continueSnapshotList(value: any): Promise<PageOutcome>
27
+ listRelationshipRecords(entityRoute: string, recordIdentifier: string, pathRoute: string, options?: any | undefined | null): Promise<PageOutcome>
28
+ continueRelationshipList(value: any): Promise<PageOutcome>
14
29
  lookupRecord(entityRoute: string, selector: string, values?: any | undefined | null, options?: any | undefined | null): Promise<CompleteOutcome>
30
+ /** Fetch opaque target conditions for one metadata-selected action. */
31
+ actionTargetConditions(binding: BRegImmediateActionBinding, inputs: any): Promise<BRegActionTargetConditions>
32
+ /** Invoke one metadata-selected immediate action without automatic retry. */
33
+ invokeAction(binding: BRegImmediateActionBinding, inputs: any, idempotencyKey: string, conditions?: BRegActionTargetConditions | undefined | null): Promise<CompleteOutcome>
15
34
  createRecord(binding: BRegCreateBinding, data: any, idempotencyKey: string, formatValue?: string | undefined | null): Promise<CompleteOutcome>
35
+ /** Prepare inert Create evidence before any token acquisition or I/O. */
36
+ prepareCreate(binding: BRegCreateBinding, data: any, idempotencyKey: string, formatValue?: string | undefined | null): BRegPreparedCreate
37
+ /** Revalidate saved Create evidence against freshly selected authority. */
38
+ recoverCreate(binding: BRegCreateBinding, prepared: BRegPreparedCreate): BRegRecoveredCreate
39
+ /** Explicitly send a recovered Create request with fresh authority. */
40
+ executeRecoveredCreate(binding: BRegCreateBinding, recovered: BRegRecoveredCreate): Promise<CompleteOutcome>
16
41
  patchRecord(binding: BRegPatchBinding, recordIdentifier: string, etag: string, operations: any, idempotencyKey: string, formatValue?: string | undefined | null): Promise<CompleteOutcome>
42
+ /** Execute one metadata-selected atomic batch without automatic retry. */
43
+ batchRecords(binding: BRegBatchBinding, request: any, idempotencyKey: string): Promise<CompleteOutcome>
44
+ /** Tombstone one record against its current strong ETag. */
45
+ tombstoneRecord(binding: BRegTombstoneBinding, recordIdentifier: string, etag: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<CompleteOutcome>
17
46
  /**
18
47
  * Replace one governed attachment slot with exact bytes. The prepared
19
48
  * upload already satisfies the slot's served size and content-type policy.
@@ -25,18 +54,59 @@ export declare class BaseRegistryClient {
25
54
  deleteAttachment(slot: BRegAttachmentSlot, recordIdentifier: string, etag: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<CompleteOutcome>
26
55
  lifecycleActions(authority: BRegLifecycleAuthority, record: any, formatValue?: string | undefined | null): Array<BRegLifecycleAction>
27
56
  executeLifecycleAction(action: BRegLifecycleAction, idempotencyKey: string): Promise<CompleteOutcome>
57
+ /** Prepare inert lifecycle evidence before any token acquisition or I/O. */
58
+ prepareLifecycleAction(authority: BRegLifecycleAuthority, record: any, action: BRegLifecycleAction, idempotencyKey: string, formatValue?: string | undefined | null): BRegPreparedLifecycle
59
+ /** Revalidate saved lifecycle evidence against freshly selected authority. */
60
+ recoverLifecycleAction(authority: BRegLifecycleAuthority, prepared: BRegPreparedLifecycle): BRegRecoveredLifecycle
61
+ /** Explicitly send a recovered lifecycle action. */
62
+ executeRecoveredLifecycleAction(recovered: BRegRecoveredLifecycle): Promise<CompleteOutcome>
28
63
  getRecordJson(entityRoute: string, recordIdentifier: string, options?: any | undefined | null): Promise<JsonOutcome>
29
64
  listRecordsJson(entityRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
30
65
  continueListJson(value: any): Promise<JsonOutcome>
66
+ getGeoJsonRecordJson(entityRoute: string, recordIdentifier: string, options?: any | undefined | null): Promise<JsonOutcome>
67
+ listGeoJsonRecordsJson(entityRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
68
+ continueGeoJsonListJson(value: any): Promise<JsonOutcome>
69
+ listCurrentRecordsJson(entityRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
70
+ continueCurrentListJson(value: any): Promise<JsonOutcome>
71
+ listRecordsAsOfJson(entityRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
72
+ continueAsOfListJson(value: any): Promise<JsonOutcome>
73
+ listSnapshotRecordsJson(entityRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
74
+ continueSnapshotListJson(value: any): Promise<JsonOutcome>
75
+ listRelationshipRecordsJson(entityRoute: string, recordIdentifier: string, pathRoute: string, options?: any | undefined | null): Promise<JsonOutcome>
76
+ continueRelationshipListJson(value: any): Promise<JsonOutcome>
31
77
  lookupRecordJson(entityRoute: string, selector: string, valuesJson?: string | undefined | null, options?: any | undefined | null): Promise<JsonOutcome>
78
+ /** Fetch opaque target conditions from exact action-input JSON. */
79
+ actionTargetConditionsJson(binding: BRegImmediateActionBinding, inputsJson: string): Promise<BRegActionTargetConditions>
80
+ /** Invoke an action from exact JSON and preserve exact receipt values. */
81
+ invokeActionJson(binding: BRegImmediateActionBinding, inputsJson: string, idempotencyKey: string, conditions?: BRegActionTargetConditions | undefined | null): Promise<JsonOutcome>
32
82
  createRecordJson(binding: BRegCreateBinding, dataJson: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<JsonOutcome>
83
+ /** Prepare inert Create evidence from exact JSON text. */
84
+ prepareCreateJson(binding: BRegCreateBinding, dataJson: string, idempotencyKey: string, formatValue?: string | undefined | null): BRegPreparedCreate
85
+ /** Explicitly send a recovered Create request and preserve exact values. */
86
+ executeRecoveredCreateJson(binding: BRegCreateBinding, recovered: BRegRecoveredCreate): Promise<JsonOutcome>
33
87
  patchRecordJson(binding: BRegPatchBinding, recordIdentifier: string, etag: string, operationsJson: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<JsonOutcome>
88
+ /** Execute one metadata-selected atomic batch from exact JSON. */
89
+ batchRecordsJson(binding: BRegBatchBinding, requestJson: string, idempotencyKey: string): Promise<JsonOutcome>
90
+ /** Tombstone one record and preserve exact response values. */
91
+ tombstoneRecordJson(binding: BRegTombstoneBinding, recordIdentifier: string, etag: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<JsonOutcome>
34
92
  uploadAttachmentJson(slot: BRegAttachmentSlot, recordIdentifier: string, etag: string, upload: BRegAttachmentUpload, idempotencyKey: string, formatValue?: string | undefined | null): Promise<JsonOutcome>
35
93
  deleteAttachmentJson(slot: BRegAttachmentSlot, recordIdentifier: string, etag: string, idempotencyKey: string, formatValue?: string | undefined | null): Promise<JsonOutcome>
36
94
  lifecycleActionsJson(authority: BRegLifecycleAuthority, recordJson: string, formatValue?: string | undefined | null): Array<BRegLifecycleAction>
95
+ /** Prepare inert lifecycle evidence from an exact Registry Record response. */
96
+ prepareLifecycleActionJson(authority: BRegLifecycleAuthority, recordJson: string, action: BRegLifecycleAction, idempotencyKey: string, formatValue?: string | undefined | null): BRegPreparedLifecycle
37
97
  executeLifecycleActionJson(action: BRegLifecycleAction, idempotencyKey: string): Promise<JsonOutcome>
98
+ /** Explicitly send a recovered lifecycle action and preserve exact values. */
99
+ executeRecoveredLifecycleActionJson(recovered: BRegRecoveredLifecycle): Promise<JsonOutcome>
38
100
  }
39
101
 
102
+ /** Opaque server-validated target conditions for one immediate action. */
103
+ export declare class BRegActionTargetConditions {
104
+ get preconditionKeys(): Array<string>
105
+ get valueJson(): string
106
+ get traceId(): string
107
+ }
108
+ export type ActionTargetConditions = BRegActionTargetConditions
109
+
40
110
  /** Opaque governed attachment slot selected from metadata fetched by this client source. */
41
111
  export declare class BRegAttachmentSlot {
42
112
  get slotIdentifier(): string
@@ -66,11 +136,21 @@ export declare class BRegAttachmentUpload {
66
136
  }
67
137
  export type AttachmentUpload = BRegAttachmentUpload
68
138
 
139
+ export declare class BRegBatchBinding {
140
+
141
+ }
142
+ export type BatchBinding = BRegBatchBinding
143
+
69
144
  export declare class BRegCreateBinding {
70
145
 
71
146
  }
72
147
  export type CreateBinding = BRegCreateBinding
73
148
 
149
+ export declare class BRegImmediateActionBinding {
150
+
151
+ }
152
+ export type ImmediateActionBinding = BRegImmediateActionBinding
153
+
74
154
  export declare class BRegLifecycleAction {
75
155
  withReason(reason: string): BRegLifecycleAction
76
156
  get bodyJson(): string
@@ -91,6 +171,12 @@ export type LifecycleAuthority = BRegLifecycleAuthority
91
171
  export declare class BRegMetadata {
92
172
  /** Caller-filtered inert descriptors. Selectors below remain the only authority constructors. */
93
173
  get operations(): any
174
+ /** Complete typed caller-filtered immediate-action descriptors. */
175
+ get immediateActions(): any
176
+ /** Original caller-filtered action metadata as exact JSON text. */
177
+ get actionsJson(): string | null
178
+ /** Descriptive change-request capability for one entity, when advertised. */
179
+ changeRequestCapability(entityIdentifier: string): any | null
94
180
  get registryIdentifier(): string
95
181
  get registryVersion(): string
96
182
  get registryRevision(): string
@@ -100,6 +186,9 @@ export declare class BRegMetadata {
100
186
  selectPatch(operationIdentifier: string, expectedProfile: string): BRegPatchBinding
101
187
  selectLifecycle(entityIdentifier: string, expectedProfile: string): BRegLifecycleAuthority
102
188
  selectAttachments(entityIdentifier: string, expectedProfile: string): Array<BRegAttachmentSlot>
189
+ selectImmediateAction(actionIdentifier: string, expectedProfile: string): BRegImmediateActionBinding
190
+ selectTombstone(entityIdentifier: string, expectedProfile: string): BRegTombstoneBinding
191
+ selectBatch(entityIdentifier: string, expectedProfile: string): BRegBatchBinding
103
192
  }
104
193
  export type Metadata = BRegMetadata
105
194
 
@@ -108,6 +197,53 @@ export declare class BRegPatchBinding {
108
197
  }
109
198
  export type PatchBinding = BRegPatchBinding
110
199
 
200
+ /**
201
+ * Inert original Create request evidence. The bytes carry values and an
202
+ * idempotency key, but no token or executable metadata authority.
203
+ */
204
+ export declare class BRegPreparedCreate {
205
+ /** Restore bounded inert evidence previously returned by `toBytes`. */
206
+ static fromBytes(bytes: Buffer): BRegPreparedCreate
207
+ /** Copy the exact evidence bytes for owner-protected persistence. */
208
+ toBytes(): Buffer
209
+ }
210
+ export type PreparedCreate = BRegPreparedCreate
211
+
212
+ /**
213
+ * Inert original lifecycle request evidence. The bytes carry record values
214
+ * and an idempotency key, but no token or executable metadata authority.
215
+ */
216
+ export declare class BRegPreparedLifecycle {
217
+ /** Restore bounded inert evidence previously returned by `toBytes`. */
218
+ static fromBytes(bytes: Buffer): BRegPreparedLifecycle
219
+ /** Copy the exact evidence bytes for owner-protected persistence. */
220
+ toBytes(): Buffer
221
+ }
222
+ export type PreparedLifecycle = BRegPreparedLifecycle
223
+
224
+ /**
225
+ * A recovered Create request, key, and representation. This remains inert
226
+ * until `executeRecoveredCreate` is explicitly called with fresh authority.
227
+ */
228
+ export declare class BRegRecoveredCreate {
229
+
230
+ }
231
+ export type RecoveredCreate = BRegRecoveredCreate
232
+
233
+ /**
234
+ * A recovered lifecycle action and key. This remains inert until
235
+ * `executeRecoveredLifecycleAction` is explicitly called.
236
+ */
237
+ export declare class BRegRecoveredLifecycle {
238
+
239
+ }
240
+ export type RecoveredLifecycle = BRegRecoveredLifecycle
241
+
242
+ export declare class BRegTombstoneBinding {
243
+
244
+ }
245
+ export type TombstoneBinding = BRegTombstoneBinding
246
+
111
247
  export interface CompleteOutcome {
112
248
  kind: string
113
249
  value: any
@@ -124,6 +260,8 @@ export interface JsonOutcome {
124
260
  traceId: string
125
261
  etag?: string
126
262
  location?: string
263
+ snapshot?: string
264
+ validAt?: string
127
265
  }
128
266
 
129
267
  export interface PageOutcome {
@@ -132,6 +270,8 @@ export interface PageOutcome {
132
270
  continuation?: any
133
271
  traceId: string
134
272
  etag?: string
273
+ snapshot?: string
274
+ validAt?: string
135
275
  }
136
276
 
137
277
  export interface RawOutcome {