@automerge/sedimentree 0.8.2 → 0.9.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.
Files changed (30) hide show
  1. package/dist/cjs/wasm-base64.cjs +1 -1
  2. package/dist/cjs/web-bindings.cjs +345 -80
  3. package/dist/cjs/web.cjs +346 -81
  4. package/dist/esm/wasm-base64.js +1 -1
  5. package/dist/iife/index.js +345 -81
  6. package/dist/index.d.ts +107 -33
  7. package/dist/sedimentree.wasm +0 -0
  8. package/dist/wasm_bindgen/bundler/sedimentree_wasm.d.ts +107 -33
  9. package/dist/wasm_bindgen/bundler/sedimentree_wasm.js +1 -1
  10. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.js +360 -81
  11. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.wasm +0 -0
  12. package/dist/wasm_bindgen/bundler/sedimentree_wasm_bg.wasm.d.ts +26 -16
  13. package/dist/wasm_bindgen/nodejs/sedimentree_wasm.cjs +361 -81
  14. package/dist/wasm_bindgen/nodejs/sedimentree_wasm.d.ts +107 -33
  15. package/dist/wasm_bindgen/nodejs/sedimentree_wasm_bg.wasm +0 -0
  16. package/dist/wasm_bindgen/nodejs/sedimentree_wasm_bg.wasm.d.ts +26 -16
  17. package/dist/wasm_bindgen/web/sedimentree_wasm.d.ts +133 -49
  18. package/dist/wasm_bindgen/web/sedimentree_wasm.js +360 -81
  19. package/dist/wasm_bindgen/web/sedimentree_wasm_bg.wasm +0 -0
  20. package/dist/wasm_bindgen/web/sedimentree_wasm_bg.wasm.d.ts +26 -16
  21. package/package.json +1 -1
  22. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  23. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  24. /package/dist/wasm_bindgen/bundler/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
  25. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  26. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  27. /package/dist/wasm_bindgen/nodejs/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
  28. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline0.js +0 -0
  29. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline1.js +0 -0
  30. /package/dist/wasm_bindgen/web/snippets/{sedimentree_wasm-75027ecce41278de → sedimentree_wasm-8e1863d4f7634be2}/inline2.js +0 -0
package/dist/index.d.ts CHANGED
@@ -7,23 +7,23 @@ export interface SedimentreeStorage {
7
7
  loadAllSedimentreeIds(): Promise<SedimentreeId[]>;
8
8
 
9
9
  // Compound storage for commits (signed data + blob stored together)
10
- saveCommit(sedimentreeId: SedimentreeId, digest: Digest, signedCommit: SignedLooseCommit, blob: Uint8Array): Promise<void>;
11
- loadCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<CommitWithBlob | null>;
12
- listCommitDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
10
+ saveCommit(sedimentreeId: SedimentreeId, commitId: CommitId, signedCommit: SignedLooseCommit, blob: Uint8Array): Promise<void>;
11
+ loadCommit(sedimentreeId: SedimentreeId, commitId: CommitId): Promise<CommitWithBlob | null>;
12
+ listCommitIds(sedimentreeId: SedimentreeId): Promise<CommitId[]>;
13
13
  loadAllCommits(sedimentreeId: SedimentreeId): Promise<CommitWithBlob[]>;
14
- deleteCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
14
+ deleteCommit(sedimentreeId: SedimentreeId, commitId: CommitId): Promise<void>;
15
15
  deleteAllCommits(sedimentreeId: SedimentreeId): Promise<void>;
16
16
 
17
17
  // Compound storage for fragments (signed data + blob stored together)
18
- saveFragment(sedimentreeId: SedimentreeId, digest: Digest, signedFragment: SignedFragment, blob: Uint8Array): Promise<void>;
19
- loadFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<FragmentWithBlob | null>;
20
- listFragmentDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
18
+ saveFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId, signedFragment: SignedFragment, blob: Uint8Array): Promise<void>;
19
+ loadFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId): Promise<FragmentWithBlob | null>;
20
+ listFragmentIds(sedimentreeId: SedimentreeId): Promise<CommitId[]>;
21
21
  loadAllFragments(sedimentreeId: SedimentreeId): Promise<FragmentWithBlob[]>;
22
- deleteFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
22
+ deleteFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId): Promise<void>;
23
23
  deleteAllFragments(sedimentreeId: SedimentreeId): Promise<void>;
24
24
 
25
25
  // Batch save: write all commits + fragments in a single storage transaction.
26
- saveBatchAll(sedimentreeId: SedimentreeId, commits: Array<{digest: Digest, signedCommit: SignedLooseCommit, blob: Uint8Array}>, fragments: Array<{digest: Digest, signedFragment: SignedFragment, blob: Uint8Array}>): Promise<number>;
26
+ saveBatchAll(sedimentreeId: SedimentreeId, commits: Array<{commitId: CommitId, signedCommit: SignedLooseCommit, blob: Uint8Array}>, fragments: Array<{fragmentHead: CommitId, signedFragment: SignedFragment, blob: Uint8Array}>): Promise<number>;
27
27
  }
28
28
 
29
29
 
@@ -55,6 +55,63 @@ export class BlobMeta {
55
55
  readonly sizeBytes: bigint;
56
56
  }
57
57
 
58
+ /**
59
+ * A user-supplied opaque identifier for a loose commit.
60
+ *
61
+ * Unlike [`Digest`](crate::digest::WasmDigest), which is a content hash
62
+ * computed by the system, `CommitId` is provided by the caller at construction
63
+ * time. This is the identity used for DAG traversal, fragment boundaries,
64
+ * and sync.
65
+ */
66
+ export class CommitId {
67
+ free(): void;
68
+ [Symbol.dispose](): void;
69
+ /**
70
+ * Upcasts; to the JS-import type for [`WasmCommitId`].
71
+ */
72
+ __wasm_refgen_toWasmCommitId(): CommitId;
73
+ /**
74
+ * Creates a new commit identifier from its Base58 string representation.
75
+ *
76
+ * # Errors
77
+ *
78
+ * Returns an error if the string cannot be decoded or is not 32 bytes.
79
+ */
80
+ static fromBase58(s: string): CommitId;
81
+ /**
82
+ * Creates a new commit identifier from its byte representation.
83
+ *
84
+ * # Errors
85
+ *
86
+ * Returns an error if the byte slice is not exactly 32 bytes.
87
+ */
88
+ static fromBytes(bytes: Uint8Array): CommitId;
89
+ /**
90
+ * Creates a new commit identifier from its hexadecimal string representation.
91
+ *
92
+ * # Errors
93
+ *
94
+ * Returns an error if the string is not valid hex or not 32 bytes.
95
+ */
96
+ static fromHexString(s: string): CommitId;
97
+ /**
98
+ * Creates a new commit identifier from its byte representation.
99
+ *
100
+ * # Errors
101
+ *
102
+ * Returns an error if the byte slice is not exactly 32 bytes.
103
+ */
104
+ constructor(bytes: Uint8Array);
105
+ /**
106
+ * Returns the byte representation of the commit identifier.
107
+ */
108
+ toBytes(): Uint8Array;
109
+ /**
110
+ * Returns the hexadecimal string representation.
111
+ */
112
+ toHexString(): string;
113
+ }
114
+
58
115
  /**
59
116
  * A commit stored with its associated blob.
60
117
  */
@@ -175,19 +232,19 @@ export class Fragment {
175
232
  /**
176
233
  * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
177
234
  */
178
- constructor(sedimentree_id: SedimentreeId, head: Digest, boundary: Digest[], checkpoints: Digest[], blob_meta: BlobMeta);
235
+ constructor(sedimentree_id: SedimentreeId, head: CommitId, boundary: CommitId[], checkpoints: CommitId[], blob_meta: BlobMeta);
179
236
  /**
180
237
  * Get the blob metadata of the fragment.
181
238
  */
182
239
  readonly blobMeta: BlobMeta;
183
240
  /**
184
- * Get the boundary digests of the fragment.
241
+ * Get the boundary commit identifiers of the fragment.
185
242
  */
186
- readonly boundary: Digest[];
243
+ readonly boundary: CommitId[];
187
244
  /**
188
- * Get the head digest of the fragment.
245
+ * Get the head commit identifier of the fragment.
189
246
  */
190
- readonly head: Digest;
247
+ readonly head: CommitId;
191
248
  }
192
249
 
193
250
  /**
@@ -235,21 +292,25 @@ export class LooseCommit {
235
292
  */
236
293
  __wasm_refgen_toWasmLooseCommit(): LooseCommit;
237
294
  /**
238
- * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
295
+ * Create a new `LooseCommit` from the given sedimentree ID, head, parents, and blob metadata.
239
296
  */
240
- constructor(sedimentree_id: SedimentreeId, parents: Digest[], blob_meta: BlobMeta);
297
+ constructor(sedimentree_id: SedimentreeId, head: CommitId, parents: CommitId[], blob_meta: BlobMeta);
241
298
  /**
242
299
  * Get the blob metadata of the commit.
243
300
  */
244
301
  readonly blobMeta: BlobMeta;
245
302
  /**
246
- * Get the digest of the commit.
303
+ * Get the commit's head identifier.
304
+ */
305
+ readonly commitId: CommitId;
306
+ /**
307
+ * Get the digest of the commit (content hash).
247
308
  */
248
309
  readonly digest: Digest;
249
310
  /**
250
- * Get the parent digests of the commit.
311
+ * Get the parent commit identifiers.
251
312
  */
252
- readonly parents: Digest[];
313
+ readonly parents: CommitId[];
253
314
  }
254
315
 
255
316
  /**
@@ -269,25 +330,25 @@ export class MemoryStorage {
269
330
  */
270
331
  deleteAllFragments(sedimentree_id: SedimentreeId): Promise<any>;
271
332
  /**
272
- * Delete a commit by digest.
333
+ * Delete a single commit by its ID.
273
334
  */
274
- deleteCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
335
+ deleteCommit(sedimentree_id: SedimentreeId, commit_id: CommitId): Promise<any>;
275
336
  /**
276
- * Delete a fragment by digest.
337
+ * Delete a fragment by its identifier.
277
338
  */
278
- deleteFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
339
+ deleteFragment(sedimentree_id: SedimentreeId, fragment_head: CommitId): Promise<any>;
279
340
  /**
280
341
  * Delete a sedimentree ID.
281
342
  */
282
343
  deleteSedimentreeId(sedimentree_id: SedimentreeId): Promise<any>;
283
344
  /**
284
- * List all commit digests for a sedimentree.
345
+ * List all commit IDs for a sedimentree.
285
346
  */
286
- listCommitDigests(sedimentree_id: SedimentreeId): Promise<any>;
347
+ listCommitIds(sedimentree_id: SedimentreeId): Promise<any>;
287
348
  /**
288
- * List all fragment digests for a sedimentree.
349
+ * List all fragment IDs for a sedimentree.
289
350
  */
290
- listFragmentDigests(sedimentree_id: SedimentreeId): Promise<any>;
351
+ listFragmentIds(sedimentree_id: SedimentreeId): Promise<any>;
291
352
  /**
292
353
  * Load all commits for a sedimentree, returning `CommitWithBlob[]`.
293
354
  */
@@ -301,25 +362,38 @@ export class MemoryStorage {
301
362
  */
302
363
  loadAllSedimentreeIds(): Promise<any>;
303
364
  /**
304
- * Load a commit by digest, returning `CommitWithBlob` or null.
365
+ * Load a single commit by its ID, returning `CommitWithBlob` or null.
305
366
  */
306
- loadCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
367
+ loadCommit(sedimentree_id: SedimentreeId, commit_id: CommitId): Promise<any>;
307
368
  /**
308
- * Load a fragment by digest, returning `FragmentWithBlob` or null.
369
+ * Load a fragment by its identifier, returning `FragmentWithBlob` or null.
309
370
  */
310
- loadFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
371
+ loadFragment(sedimentree_id: SedimentreeId, fragment_head: CommitId): Promise<any>;
311
372
  /**
312
373
  * Create a new in-memory storage instance.
313
374
  */
314
375
  constructor();
376
+ /**
377
+ * Save commits and fragments in a single batch.
378
+ */
379
+ saveBatchAll(sedimentree_id: SedimentreeId, commits: Array<any>, fragments: Array<any>): Promise<any>;
315
380
  /**
316
381
  * Save a commit with its blob.
382
+ *
383
+ * The `commit_id` parameter must match the `head()` embedded in
384
+ * the signed commit payload. Returns an error if they differ.
385
+ *
386
+ * # Errors
387
+ *
388
+ * Returns a JS error if:
389
+ * - The signed payload cannot be decoded
390
+ * - The `commit_id` does not match the embedded `head()`
317
391
  */
318
- saveCommit(sedimentree_id: SedimentreeId, _digest: Digest, signed_commit: SignedLooseCommit, blob: Uint8Array): Promise<any>;
392
+ saveCommit(sedimentree_id: SedimentreeId, commit_id: CommitId, signed_commit: SignedLooseCommit, blob: Uint8Array): Promise<any>;
319
393
  /**
320
394
  * Save a fragment with its blob.
321
395
  */
322
- saveFragment(sedimentree_id: SedimentreeId, _digest: Digest, signed_fragment: SignedFragment, blob: Uint8Array): Promise<any>;
396
+ saveFragment(sedimentree_id: SedimentreeId, _fragment_head: CommitId, signed_fragment: SignedFragment, blob: Uint8Array): Promise<any>;
323
397
  /**
324
398
  * Save a sedimentree ID.
325
399
  */
Binary file
@@ -7,23 +7,23 @@ export interface SedimentreeStorage {
7
7
  loadAllSedimentreeIds(): Promise<SedimentreeId[]>;
8
8
 
9
9
  // Compound storage for commits (signed data + blob stored together)
10
- saveCommit(sedimentreeId: SedimentreeId, digest: Digest, signedCommit: SignedLooseCommit, blob: Uint8Array): Promise<void>;
11
- loadCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<CommitWithBlob | null>;
12
- listCommitDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
10
+ saveCommit(sedimentreeId: SedimentreeId, commitId: CommitId, signedCommit: SignedLooseCommit, blob: Uint8Array): Promise<void>;
11
+ loadCommit(sedimentreeId: SedimentreeId, commitId: CommitId): Promise<CommitWithBlob | null>;
12
+ listCommitIds(sedimentreeId: SedimentreeId): Promise<CommitId[]>;
13
13
  loadAllCommits(sedimentreeId: SedimentreeId): Promise<CommitWithBlob[]>;
14
- deleteCommit(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
14
+ deleteCommit(sedimentreeId: SedimentreeId, commitId: CommitId): Promise<void>;
15
15
  deleteAllCommits(sedimentreeId: SedimentreeId): Promise<void>;
16
16
 
17
17
  // Compound storage for fragments (signed data + blob stored together)
18
- saveFragment(sedimentreeId: SedimentreeId, digest: Digest, signedFragment: SignedFragment, blob: Uint8Array): Promise<void>;
19
- loadFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<FragmentWithBlob | null>;
20
- listFragmentDigests(sedimentreeId: SedimentreeId): Promise<Digest[]>;
18
+ saveFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId, signedFragment: SignedFragment, blob: Uint8Array): Promise<void>;
19
+ loadFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId): Promise<FragmentWithBlob | null>;
20
+ listFragmentIds(sedimentreeId: SedimentreeId): Promise<CommitId[]>;
21
21
  loadAllFragments(sedimentreeId: SedimentreeId): Promise<FragmentWithBlob[]>;
22
- deleteFragment(sedimentreeId: SedimentreeId, digest: Digest): Promise<void>;
22
+ deleteFragment(sedimentreeId: SedimentreeId, fragmentHead: CommitId): Promise<void>;
23
23
  deleteAllFragments(sedimentreeId: SedimentreeId): Promise<void>;
24
24
 
25
25
  // Batch save: write all commits + fragments in a single storage transaction.
26
- saveBatchAll(sedimentreeId: SedimentreeId, commits: Array<{digest: Digest, signedCommit: SignedLooseCommit, blob: Uint8Array}>, fragments: Array<{digest: Digest, signedFragment: SignedFragment, blob: Uint8Array}>): Promise<number>;
26
+ saveBatchAll(sedimentreeId: SedimentreeId, commits: Array<{commitId: CommitId, signedCommit: SignedLooseCommit, blob: Uint8Array}>, fragments: Array<{fragmentHead: CommitId, signedFragment: SignedFragment, blob: Uint8Array}>): Promise<number>;
27
27
  }
28
28
 
29
29
 
@@ -55,6 +55,63 @@ export class BlobMeta {
55
55
  readonly sizeBytes: bigint;
56
56
  }
57
57
 
58
+ /**
59
+ * A user-supplied opaque identifier for a loose commit.
60
+ *
61
+ * Unlike [`Digest`](crate::digest::WasmDigest), which is a content hash
62
+ * computed by the system, `CommitId` is provided by the caller at construction
63
+ * time. This is the identity used for DAG traversal, fragment boundaries,
64
+ * and sync.
65
+ */
66
+ export class CommitId {
67
+ free(): void;
68
+ [Symbol.dispose](): void;
69
+ /**
70
+ * Upcasts; to the JS-import type for [`WasmCommitId`].
71
+ */
72
+ __wasm_refgen_toWasmCommitId(): CommitId;
73
+ /**
74
+ * Creates a new commit identifier from its Base58 string representation.
75
+ *
76
+ * # Errors
77
+ *
78
+ * Returns an error if the string cannot be decoded or is not 32 bytes.
79
+ */
80
+ static fromBase58(s: string): CommitId;
81
+ /**
82
+ * Creates a new commit identifier from its byte representation.
83
+ *
84
+ * # Errors
85
+ *
86
+ * Returns an error if the byte slice is not exactly 32 bytes.
87
+ */
88
+ static fromBytes(bytes: Uint8Array): CommitId;
89
+ /**
90
+ * Creates a new commit identifier from its hexadecimal string representation.
91
+ *
92
+ * # Errors
93
+ *
94
+ * Returns an error if the string is not valid hex or not 32 bytes.
95
+ */
96
+ static fromHexString(s: string): CommitId;
97
+ /**
98
+ * Creates a new commit identifier from its byte representation.
99
+ *
100
+ * # Errors
101
+ *
102
+ * Returns an error if the byte slice is not exactly 32 bytes.
103
+ */
104
+ constructor(bytes: Uint8Array);
105
+ /**
106
+ * Returns the byte representation of the commit identifier.
107
+ */
108
+ toBytes(): Uint8Array;
109
+ /**
110
+ * Returns the hexadecimal string representation.
111
+ */
112
+ toHexString(): string;
113
+ }
114
+
58
115
  /**
59
116
  * A commit stored with its associated blob.
60
117
  */
@@ -175,19 +232,19 @@ export class Fragment {
175
232
  /**
176
233
  * Create a new fragment from the given sedimentree ID, head, boundary, checkpoints, and blob metadata.
177
234
  */
178
- constructor(sedimentree_id: SedimentreeId, head: Digest, boundary: Digest[], checkpoints: Digest[], blob_meta: BlobMeta);
235
+ constructor(sedimentree_id: SedimentreeId, head: CommitId, boundary: CommitId[], checkpoints: CommitId[], blob_meta: BlobMeta);
179
236
  /**
180
237
  * Get the blob metadata of the fragment.
181
238
  */
182
239
  readonly blobMeta: BlobMeta;
183
240
  /**
184
- * Get the boundary digests of the fragment.
241
+ * Get the boundary commit identifiers of the fragment.
185
242
  */
186
- readonly boundary: Digest[];
243
+ readonly boundary: CommitId[];
187
244
  /**
188
- * Get the head digest of the fragment.
245
+ * Get the head commit identifier of the fragment.
189
246
  */
190
- readonly head: Digest;
247
+ readonly head: CommitId;
191
248
  }
192
249
 
193
250
  /**
@@ -235,21 +292,25 @@ export class LooseCommit {
235
292
  */
236
293
  __wasm_refgen_toWasmLooseCommit(): LooseCommit;
237
294
  /**
238
- * Create a new `LooseCommit` from the given sedimentree ID, parents, and blob metadata.
295
+ * Create a new `LooseCommit` from the given sedimentree ID, head, parents, and blob metadata.
239
296
  */
240
- constructor(sedimentree_id: SedimentreeId, parents: Digest[], blob_meta: BlobMeta);
297
+ constructor(sedimentree_id: SedimentreeId, head: CommitId, parents: CommitId[], blob_meta: BlobMeta);
241
298
  /**
242
299
  * Get the blob metadata of the commit.
243
300
  */
244
301
  readonly blobMeta: BlobMeta;
245
302
  /**
246
- * Get the digest of the commit.
303
+ * Get the commit's head identifier.
304
+ */
305
+ readonly commitId: CommitId;
306
+ /**
307
+ * Get the digest of the commit (content hash).
247
308
  */
248
309
  readonly digest: Digest;
249
310
  /**
250
- * Get the parent digests of the commit.
311
+ * Get the parent commit identifiers.
251
312
  */
252
- readonly parents: Digest[];
313
+ readonly parents: CommitId[];
253
314
  }
254
315
 
255
316
  /**
@@ -269,25 +330,25 @@ export class MemoryStorage {
269
330
  */
270
331
  deleteAllFragments(sedimentree_id: SedimentreeId): Promise<any>;
271
332
  /**
272
- * Delete a commit by digest.
333
+ * Delete a single commit by its ID.
273
334
  */
274
- deleteCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
335
+ deleteCommit(sedimentree_id: SedimentreeId, commit_id: CommitId): Promise<any>;
275
336
  /**
276
- * Delete a fragment by digest.
337
+ * Delete a fragment by its identifier.
277
338
  */
278
- deleteFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
339
+ deleteFragment(sedimentree_id: SedimentreeId, fragment_head: CommitId): Promise<any>;
279
340
  /**
280
341
  * Delete a sedimentree ID.
281
342
  */
282
343
  deleteSedimentreeId(sedimentree_id: SedimentreeId): Promise<any>;
283
344
  /**
284
- * List all commit digests for a sedimentree.
345
+ * List all commit IDs for a sedimentree.
285
346
  */
286
- listCommitDigests(sedimentree_id: SedimentreeId): Promise<any>;
347
+ listCommitIds(sedimentree_id: SedimentreeId): Promise<any>;
287
348
  /**
288
- * List all fragment digests for a sedimentree.
349
+ * List all fragment IDs for a sedimentree.
289
350
  */
290
- listFragmentDigests(sedimentree_id: SedimentreeId): Promise<any>;
351
+ listFragmentIds(sedimentree_id: SedimentreeId): Promise<any>;
291
352
  /**
292
353
  * Load all commits for a sedimentree, returning `CommitWithBlob[]`.
293
354
  */
@@ -301,25 +362,38 @@ export class MemoryStorage {
301
362
  */
302
363
  loadAllSedimentreeIds(): Promise<any>;
303
364
  /**
304
- * Load a commit by digest, returning `CommitWithBlob` or null.
365
+ * Load a single commit by its ID, returning `CommitWithBlob` or null.
305
366
  */
306
- loadCommit(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
367
+ loadCommit(sedimentree_id: SedimentreeId, commit_id: CommitId): Promise<any>;
307
368
  /**
308
- * Load a fragment by digest, returning `FragmentWithBlob` or null.
369
+ * Load a fragment by its identifier, returning `FragmentWithBlob` or null.
309
370
  */
310
- loadFragment(sedimentree_id: SedimentreeId, digest: Digest): Promise<any>;
371
+ loadFragment(sedimentree_id: SedimentreeId, fragment_head: CommitId): Promise<any>;
311
372
  /**
312
373
  * Create a new in-memory storage instance.
313
374
  */
314
375
  constructor();
376
+ /**
377
+ * Save commits and fragments in a single batch.
378
+ */
379
+ saveBatchAll(sedimentree_id: SedimentreeId, commits: Array<any>, fragments: Array<any>): Promise<any>;
315
380
  /**
316
381
  * Save a commit with its blob.
382
+ *
383
+ * The `commit_id` parameter must match the `head()` embedded in
384
+ * the signed commit payload. Returns an error if they differ.
385
+ *
386
+ * # Errors
387
+ *
388
+ * Returns a JS error if:
389
+ * - The signed payload cannot be decoded
390
+ * - The `commit_id` does not match the embedded `head()`
317
391
  */
318
- saveCommit(sedimentree_id: SedimentreeId, _digest: Digest, signed_commit: SignedLooseCommit, blob: Uint8Array): Promise<any>;
392
+ saveCommit(sedimentree_id: SedimentreeId, commit_id: CommitId, signed_commit: SignedLooseCommit, blob: Uint8Array): Promise<any>;
319
393
  /**
320
394
  * Save a fragment with its blob.
321
395
  */
322
- saveFragment(sedimentree_id: SedimentreeId, _digest: Digest, signed_fragment: SignedFragment, blob: Uint8Array): Promise<any>;
396
+ saveFragment(sedimentree_id: SedimentreeId, _fragment_head: CommitId, signed_fragment: SignedFragment, blob: Uint8Array): Promise<any>;
323
397
  /**
324
398
  * Save a sedimentree ID.
325
399
  */
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./sedimentree_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- BlobMeta, CommitWithBlob, Depth, Digest, Fragment, FragmentWithBlob, FragmentsArray, LooseCommit, MemoryStorage, Sedimentree, SedimentreeId, SedimentreeIdsArray, SignedFragment, SignedLooseCommit
8
+ BlobMeta, CommitId, CommitWithBlob, Depth, Digest, Fragment, FragmentWithBlob, FragmentsArray, LooseCommit, MemoryStorage, Sedimentree, SedimentreeId, SedimentreeIdsArray, SignedFragment, SignedLooseCommit
9
9
  } from "./sedimentree_wasm_bg.js";