@abraca/dabra 1.3.3 → 1.5.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/abracadabra-provider.cjs +31 -2
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +44 -2
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +45 -1
- package/package.json +1 -1
- package/src/AbracadabraClient.ts +55 -0
- package/src/TreeTimestamps.ts +5 -2
- package/src/types.ts +31 -0
|
@@ -3520,6 +3520,34 @@ var AbracadabraClient = class {
|
|
|
3520
3520
|
async adminStorageRepair() {
|
|
3521
3521
|
return this.request("POST", "/admin/storage/repair");
|
|
3522
3522
|
}
|
|
3523
|
+
/** List snapshot metadata for a document. */
|
|
3524
|
+
async listSnapshots(docId, opts) {
|
|
3525
|
+
const params = new URLSearchParams();
|
|
3526
|
+
if (opts?.limit != null) params.set("limit", String(opts.limit));
|
|
3527
|
+
if (opts?.offset != null) params.set("offset", String(opts.offset));
|
|
3528
|
+
const qs = params.toString();
|
|
3529
|
+
return (await this.request("GET", `/docs/${encodeURIComponent(docId)}/snapshots${qs ? `?${qs}` : ""}`)).snapshots;
|
|
3530
|
+
}
|
|
3531
|
+
/** Fetch a single snapshot including its base64-encoded data blob. */
|
|
3532
|
+
async getSnapshot(docId, version) {
|
|
3533
|
+
return this.request("GET", `/docs/${encodeURIComponent(docId)}/snapshots/${version}`);
|
|
3534
|
+
}
|
|
3535
|
+
/** Create a manual snapshot of the current document state. */
|
|
3536
|
+
async createSnapshot(docId, opts) {
|
|
3537
|
+
return this.request("POST", `/docs/${encodeURIComponent(docId)}/snapshots`, { body: opts ?? {} });
|
|
3538
|
+
}
|
|
3539
|
+
/** Delete a specific snapshot version. Requires manage permission. */
|
|
3540
|
+
async deleteSnapshot(docId, version) {
|
|
3541
|
+
await this.request("DELETE", `/docs/${encodeURIComponent(docId)}/snapshots/${version}`);
|
|
3542
|
+
}
|
|
3543
|
+
/** Restore a snapshot by merging it forward into the current document state. */
|
|
3544
|
+
async restoreSnapshot(docId, version) {
|
|
3545
|
+
return this.request("POST", `/docs/${encodeURIComponent(docId)}/snapshots/${version}/restore`, { body: {} });
|
|
3546
|
+
}
|
|
3547
|
+
/** Fork a snapshot into a new document. */
|
|
3548
|
+
async forkSnapshot(docId, version) {
|
|
3549
|
+
return this.request("POST", `/docs/${encodeURIComponent(docId)}/snapshots/${version}/fork`, { body: {} });
|
|
3550
|
+
}
|
|
3523
3551
|
/** Health check — no auth required. */
|
|
3524
3552
|
async health() {
|
|
3525
3553
|
return this.request("GET", "/health", { auth: false });
|
|
@@ -10830,6 +10858,19 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
|
|
|
10830
10858
|
//#endregion
|
|
10831
10859
|
//#region packages/provider/src/TreeTimestamps.ts
|
|
10832
10860
|
/**
|
|
10861
|
+
* TreeTimestamps
|
|
10862
|
+
*
|
|
10863
|
+
* Attaches an afterUpdate observer on a child Y.Doc so that whenever a
|
|
10864
|
+
* non-offline update is applied, the `updatedAt` timestamp on the
|
|
10865
|
+
* corresponding entry in the root doc's `doc-tree` map is written.
|
|
10866
|
+
*
|
|
10867
|
+
* This propagates "last edited" timestamps to all peers via the root CRDT,
|
|
10868
|
+
* without requiring any server-side changes.
|
|
10869
|
+
*
|
|
10870
|
+
* Limitation: at least one client must have the child doc open after an edit
|
|
10871
|
+
* for the timestamp to propagate (eventually consistent).
|
|
10872
|
+
*/
|
|
10873
|
+
/**
|
|
10833
10874
|
* Attach an observer that writes `updatedAt: Date.now()` to the root
|
|
10834
10875
|
* doc-tree entry for `childDocId` whenever the child doc receives a
|
|
10835
10876
|
* non-offline update.
|
|
@@ -10845,8 +10886,9 @@ var E2EAbracadabraProvider = class E2EAbracadabraProvider extends AbracadabraPro
|
|
|
10845
10886
|
function attachUpdatedAtObserver(treeMap, childDocId, childDoc, offlineStore) {
|
|
10846
10887
|
function handler(update, origin) {
|
|
10847
10888
|
if (offlineStore !== null && origin === offlineStore) return;
|
|
10848
|
-
const
|
|
10849
|
-
if (!
|
|
10889
|
+
const raw = treeMap.get(childDocId);
|
|
10890
|
+
if (!raw) return;
|
|
10891
|
+
const entry = raw instanceof Y.Map ? raw.toJSON() : raw;
|
|
10850
10892
|
treeMap.set(childDocId, {
|
|
10851
10893
|
...entry,
|
|
10852
10894
|
updatedAt: Date.now()
|