@abraca/dabra 2.24.0 → 2.26.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 +18 -11
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +15 -8
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +10 -4
- package/package.json +2 -2
- package/src/AbracadabraClient.ts +9 -3
- package/src/TreeTimestamps.ts +17 -8
package/dist/index.d.ts
CHANGED
|
@@ -651,14 +651,20 @@ declare class AbracadabraClient {
|
|
|
651
651
|
effective_public_access: string | null;
|
|
652
652
|
}>;
|
|
653
653
|
/**
|
|
654
|
-
* Update document metadata (label, description, kind, parent_id).
|
|
655
|
-
* manage permission on the doc; reparenting additionally requires
|
|
656
|
-
* the new parent (or admin if moving under the server root).
|
|
654
|
+
* Update document metadata (label, description, kind, doc_type, parent_id).
|
|
655
|
+
* Requires manage permission on the doc; reparenting additionally requires
|
|
656
|
+
* manage on the new parent (or admin if moving under the server root).
|
|
657
|
+
*
|
|
658
|
+
* `doc_type` is the renderer hint (`"kanban"`, `"graph"`, …) — orthogonal
|
|
659
|
+
* to `kind` (the structural role). Use it for post-create type changes;
|
|
660
|
+
* never write renderer strings into `kind`. Servers older than migration
|
|
661
|
+
* 0014 ignore the field (unknown JSON fields are dropped server-side).
|
|
657
662
|
*/
|
|
658
663
|
updateDocumentMeta(docId: string, opts: {
|
|
659
664
|
label?: string | null;
|
|
660
665
|
description?: string | null;
|
|
661
666
|
kind?: string | null;
|
|
667
|
+
doc_type?: string | null;
|
|
662
668
|
parent_id?: string | null;
|
|
663
669
|
}): Promise<void>;
|
|
664
670
|
/**
|
|
@@ -3183,7 +3189,7 @@ declare function makeEncryptedYText(ydoc: Y.Doc, fieldName: string, docKey: Cryp
|
|
|
3183
3189
|
//#region packages/provider/src/TreeTimestamps.d.ts
|
|
3184
3190
|
/**
|
|
3185
3191
|
* Attach an observer that writes `updatedAt` to the root doc-tree entry for
|
|
3186
|
-
* `childDocId` whenever the child doc receives a
|
|
3192
|
+
* `childDocId` whenever the child doc receives a local edit.
|
|
3187
3193
|
*
|
|
3188
3194
|
* @param treeMap The root doc's "doc-tree" Y.Map.
|
|
3189
3195
|
* @param childDocId The child document's UUID (key in treeMap).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abraca/dabra",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
4
4
|
"description": "abracadabra provider",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"abracadabra",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"yjs": "^13.6.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@abraca/schema": "2.
|
|
44
|
+
"@abraca/schema": "2.26.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"test": "node --no-warnings --conditions=source --experimental-transform-types --test 'tests/*.test.ts'"
|
package/src/AbracadabraClient.ts
CHANGED
|
@@ -932,9 +932,14 @@ export class AbracadabraClient {
|
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
/**
|
|
935
|
-
* Update document metadata (label, description, kind, parent_id).
|
|
936
|
-
* manage permission on the doc; reparenting additionally requires
|
|
937
|
-
* the new parent (or admin if moving under the server root).
|
|
935
|
+
* Update document metadata (label, description, kind, doc_type, parent_id).
|
|
936
|
+
* Requires manage permission on the doc; reparenting additionally requires
|
|
937
|
+
* manage on the new parent (or admin if moving under the server root).
|
|
938
|
+
*
|
|
939
|
+
* `doc_type` is the renderer hint (`"kanban"`, `"graph"`, …) — orthogonal
|
|
940
|
+
* to `kind` (the structural role). Use it for post-create type changes;
|
|
941
|
+
* never write renderer strings into `kind`. Servers older than migration
|
|
942
|
+
* 0014 ignore the field (unknown JSON fields are dropped server-side).
|
|
938
943
|
*/
|
|
939
944
|
async updateDocumentMeta(
|
|
940
945
|
docId: string,
|
|
@@ -942,6 +947,7 @@ export class AbracadabraClient {
|
|
|
942
947
|
label?: string | null;
|
|
943
948
|
description?: string | null;
|
|
944
949
|
kind?: string | null;
|
|
950
|
+
doc_type?: string | null;
|
|
945
951
|
parent_id?: string | null;
|
|
946
952
|
},
|
|
947
953
|
): Promise<void> {
|
package/src/TreeTimestamps.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TreeTimestamps
|
|
3
3
|
*
|
|
4
|
-
* Attaches an
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Attaches an afterTransaction observer on a child Y.Doc so that whenever a
|
|
5
|
+
* LOCAL edit is made, the `updatedAt` timestamp on the corresponding entry
|
|
6
|
+
* in the root doc's `doc-tree` map is written.
|
|
7
7
|
*
|
|
8
8
|
* This propagates "last edited" timestamps to all peers via the root CRDT,
|
|
9
9
|
* without requiring any server-side changes.
|
|
@@ -20,7 +20,7 @@ import type { OfflineStore } from "./OfflineStore.ts";
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Attach an observer that writes `updatedAt` to the root doc-tree entry for
|
|
23
|
-
* `childDocId` whenever the child doc receives a
|
|
23
|
+
* `childDocId` whenever the child doc receives a local edit.
|
|
24
24
|
*
|
|
25
25
|
* @param treeMap The root doc's "doc-tree" Y.Map.
|
|
26
26
|
* @param childDocId The child document's UUID (key in treeMap).
|
|
@@ -64,8 +64,17 @@ export function attachUpdatedAtObserver(
|
|
|
64
64
|
writeTs(ts);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
function handler(
|
|
68
|
-
|
|
67
|
+
function handler(tr: Y.Transaction): void {
|
|
68
|
+
// Only LOCAL edits stamp updatedAt. Remote updates (tr.local === false:
|
|
69
|
+
// initial sync replay, other peers' edits, offline-store replay,
|
|
70
|
+
// cross-tab broadcast) are stamped by the client that made them and the
|
|
71
|
+
// timestamp propagates through the root CRDT — counting them here
|
|
72
|
+
// turned "last edited" into "last synced on this client": merely
|
|
73
|
+
// opening a doc bumped its updatedAt to now.
|
|
74
|
+
if (!tr.local) return;
|
|
75
|
+
if (offlineStore !== null && tr.origin === offlineStore) return;
|
|
76
|
+
// No-op transactions (nothing actually changed) don't count as edits.
|
|
77
|
+
if (tr.changed.size === 0) return;
|
|
69
78
|
|
|
70
79
|
const now = Date.now();
|
|
71
80
|
if (now - lastFlushedAt >= throttleMs) {
|
|
@@ -80,10 +89,10 @@ export function attachUpdatedAtObserver(
|
|
|
80
89
|
}
|
|
81
90
|
}
|
|
82
91
|
|
|
83
|
-
childDoc.on("
|
|
92
|
+
childDoc.on("afterTransaction", handler);
|
|
84
93
|
|
|
85
94
|
return () => {
|
|
86
|
-
childDoc.off("
|
|
95
|
+
childDoc.off("afterTransaction", handler);
|
|
87
96
|
if (timer !== null) {
|
|
88
97
|
clearTimeout(timer);
|
|
89
98
|
flushPending();
|