@enbox/agent 0.5.16 → 0.6.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/dist/browser.mjs +11 -11
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/dwn-api.js +433 -33
- package/dist/esm/dwn-api.js.map +1 -1
- package/dist/esm/dwn-encryption.js +131 -12
- package/dist/esm/dwn-encryption.js.map +1 -1
- package/dist/esm/dwn-key-delivery.js +64 -47
- package/dist/esm/dwn-key-delivery.js.map +1 -1
- package/dist/esm/enbox-connect-protocol.js +400 -3
- package/dist/esm/enbox-connect-protocol.js.map +1 -1
- package/dist/esm/permissions-api.js +11 -1
- package/dist/esm/permissions-api.js.map +1 -1
- package/dist/esm/sync-engine-level.js +407 -6
- package/dist/esm/sync-engine-level.js.map +1 -1
- package/dist/esm/sync-messages.js +10 -3
- package/dist/esm/sync-messages.js.map +1 -1
- package/dist/types/dwn-api.d.ts +159 -0
- package/dist/types/dwn-api.d.ts.map +1 -1
- package/dist/types/dwn-encryption.d.ts +39 -2
- package/dist/types/dwn-encryption.d.ts.map +1 -1
- package/dist/types/dwn-key-delivery.d.ts +1 -9
- package/dist/types/dwn-key-delivery.d.ts.map +1 -1
- package/dist/types/enbox-connect-protocol.d.ts +166 -1
- package/dist/types/enbox-connect-protocol.d.ts.map +1 -1
- package/dist/types/permissions-api.d.ts.map +1 -1
- package/dist/types/sync-engine-level.d.ts +45 -1
- package/dist/types/sync-engine-level.d.ts.map +1 -1
- package/dist/types/sync-messages.d.ts +2 -2
- package/dist/types/sync-messages.d.ts.map +1 -1
- package/dist/types/types/permissions.d.ts +9 -0
- package/dist/types/types/permissions.d.ts.map +1 -1
- package/dist/types/types/sync.d.ts +70 -2
- package/dist/types/types/sync.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/dwn-api.ts +494 -38
- package/src/dwn-encryption.ts +160 -11
- package/src/dwn-key-delivery.ts +73 -61
- package/src/enbox-connect-protocol.ts +575 -6
- package/src/permissions-api.ts +13 -1
- package/src/sync-engine-level.ts +368 -4
- package/src/sync-messages.ts +14 -5
- package/src/types/permissions.ts +9 -0
- package/src/types/sync.ts +86 -2
package/src/types/sync.ts
CHANGED
|
@@ -196,13 +196,20 @@ export type ReplicationLinkState = {
|
|
|
196
196
|
* Result of a batch push operation. Replaces the previous throw-on-first-failure
|
|
197
197
|
* pattern so callers can advance the push replication checkpoint incrementally.
|
|
198
198
|
*/
|
|
199
|
+
/** A permanently failed push entry with diagnostic info. */
|
|
200
|
+
export type PermanentPushFailure = {
|
|
201
|
+
cid : string;
|
|
202
|
+
statusCode : number;
|
|
203
|
+
detail : string;
|
|
204
|
+
};
|
|
205
|
+
|
|
199
206
|
export type PushResult = {
|
|
200
207
|
/** messageCids that were accepted (202/204/409 — idempotent success). */
|
|
201
208
|
succeeded: string[];
|
|
202
209
|
/** messageCids that failed with a transient error (5xx, network) — worth retrying. */
|
|
203
210
|
failed: string[];
|
|
204
|
-
/**
|
|
205
|
-
permanentlyFailed:
|
|
211
|
+
/** Messages that failed permanently (400/401/403) — will never succeed, do NOT retry. */
|
|
212
|
+
permanentlyFailed: PermanentPushFailure[];
|
|
206
213
|
};
|
|
207
214
|
|
|
208
215
|
/**
|
|
@@ -257,6 +264,52 @@ export type SyncEvent =
|
|
|
257
264
|
|
|
258
265
|
export type SyncEventListener = (event: SyncEvent) => void;
|
|
259
266
|
|
|
267
|
+
// ---------------------------------------------------------------------------
|
|
268
|
+
// Dead letter tracking
|
|
269
|
+
// ---------------------------------------------------------------------------
|
|
270
|
+
|
|
271
|
+
/** Category of sync failure for dead letter entries. */
|
|
272
|
+
export type DeadLetterCategory = 'push-permanent' | 'push-exhausted' | 'pull-processing' | 'closure';
|
|
273
|
+
|
|
274
|
+
/** A message that permanently failed to sync. */
|
|
275
|
+
export type DeadLetterEntry = {
|
|
276
|
+
/** The message CID that failed. */
|
|
277
|
+
messageCid: string;
|
|
278
|
+
/** The tenant DID the message belongs to. */
|
|
279
|
+
tenantDid: string;
|
|
280
|
+
/** The remote DWN endpoint involved (for push failures). */
|
|
281
|
+
remoteEndpoint?: string;
|
|
282
|
+
/** The protocol URI, if applicable. */
|
|
283
|
+
protocol?: string;
|
|
284
|
+
/** What kind of failure occurred. */
|
|
285
|
+
category: DeadLetterCategory;
|
|
286
|
+
/** Machine-readable error code (e.g., HTTP status or ClosureFailureCode). */
|
|
287
|
+
errorCode?: string;
|
|
288
|
+
/** Human-readable error detail. */
|
|
289
|
+
errorDetail: string;
|
|
290
|
+
/** ISO-8601 timestamp of when the failure was recorded. */
|
|
291
|
+
failedAt: string;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Sync health summary returned by `getSyncHealth()`.
|
|
296
|
+
*
|
|
297
|
+
* `failedMessageCount` reflects messages that are currently failing — entries
|
|
298
|
+
* are auto-cleared when the same CID later succeeds via push or pull, so the
|
|
299
|
+
* count decreases as the engine self-heals through reconciliation and repair.
|
|
300
|
+
*/
|
|
301
|
+
export type SyncHealthSummary = {
|
|
302
|
+
/** Current connectivity state. */
|
|
303
|
+
connectivity: SyncConnectivityState;
|
|
304
|
+
/**
|
|
305
|
+
* Number of messages currently in the dead letter store. Decreases as
|
|
306
|
+
* the engine self-heals — entries are auto-cleared on later success.
|
|
307
|
+
*/
|
|
308
|
+
failedMessageCount: number;
|
|
309
|
+
/** Number of links currently in 'repairing' or 'degraded_poll' status. */
|
|
310
|
+
degradedLinkCount: number;
|
|
311
|
+
};
|
|
312
|
+
|
|
260
313
|
export interface SyncEngine {
|
|
261
314
|
/**
|
|
262
315
|
* The agent that the SyncEngine is attached to.
|
|
@@ -323,4 +376,35 @@ export interface SyncEngine {
|
|
|
323
376
|
* be reused.
|
|
324
377
|
*/
|
|
325
378
|
close(): Promise<void>;
|
|
379
|
+
|
|
380
|
+
// ---------------------------------------------------------------------------
|
|
381
|
+
// Dead letter / sync health
|
|
382
|
+
// ---------------------------------------------------------------------------
|
|
383
|
+
|
|
384
|
+
/**
|
|
385
|
+
* Returns messages that are currently failing to sync, optionally filtered
|
|
386
|
+
* by tenant. Entries are auto-cleared when the same CID later succeeds
|
|
387
|
+
* (via push or pull), so the list reflects current health — not historical
|
|
388
|
+
* incidents. Sorted newest-first by `failedAt`.
|
|
389
|
+
*/
|
|
390
|
+
getFailedMessages(tenantDid?: string): Promise<DeadLetterEntry[]>;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Remove dead letter entries for a CID. When `remoteEndpoint` is provided,
|
|
394
|
+
* only the entry for that specific CID + remote pair is removed. Without
|
|
395
|
+
* it, all entries for the CID (across all remotes) are removed. Returns
|
|
396
|
+
* `true` if at least one entry was found and removed.
|
|
397
|
+
*/
|
|
398
|
+
clearFailedMessage(messageCid: string, remoteEndpoint?: string): Promise<boolean>;
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Clear all dead letter entries, optionally scoped to a tenant.
|
|
402
|
+
*/
|
|
403
|
+
clearAllFailedMessages(tenantDid?: string): Promise<void>;
|
|
404
|
+
|
|
405
|
+
/**
|
|
406
|
+
* Returns a summary of sync health: connectivity, failed message count,
|
|
407
|
+
* and degraded link count.
|
|
408
|
+
*/
|
|
409
|
+
getSyncHealth(): Promise<SyncHealthSummary>;
|
|
326
410
|
}
|