Skip to content

Commit b69fa39

Browse files
committed
add timestamp support to patch
- Extend bun patch to include createdAt getter, safe lastModifiedAt, timestamps in toJson (createdAt, lastModifiedAt, completedAt) - Add ct field parsing in schema Upstream PRs: - Root fix: karelklima/workflowy#10 - Timestamps: karelklima/workflowy#12
1 parent ac4552e commit b69fa39

File tree

1 file changed

+58
-2
lines changed

1 file changed

+58
-2
lines changed

patches/workflowy@2.8.2.patch

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
11
diff --git a/esm/src/document.js b/esm/src/document.js
2-
index 4d9346c41dad9338fb20175f8b4c1ef94aaf57b3..b13f1555ea1a1ec9e85d6a3c13fa7db3032d2c2b 100644
2+
index 4d9346c..c24ccb9 100644
33
--- a/esm/src/document.js
44
+++ b/esm/src/document.js
5-
@@ -318,7 +318,7 @@ export class List {
5+
@@ -210,9 +210,19 @@ export class List {
6+
get note() {
7+
return this.data.note || "";
8+
}
9+
- /** Date of last change */
10+
+ /** Date of creation, or undefined if not available */
11+
+ get createdAt() {
12+
+ if (this.data.created !== undefined) {
13+
+ return this.#companion.getRealTimestamp(this.data.created);
14+
+ }
15+
+ return undefined;
16+
+ }
17+
+ /** Date of last change, or undefined if not available */
18+
get lastModifiedAt() {
19+
- return this.#companion.getRealTimestamp(this.data.lastModified);
20+
+ if (this.data.lastModified !== undefined) {
21+
+ return this.#companion.getRealTimestamp(this.data.lastModified);
22+
+ }
23+
+ return undefined;
24+
}
25+
/** Date of completion, or undefined if not completed */
26+
get completedAt() {
27+
@@ -318,7 +328,7 @@ export class List {
628
});
729
this.#companion.shortIdMap.set(newId.split("-").pop(), newId);
830
this.itemIds.splice(priority, 0, newId);
@@ -11,3 +33,37 @@ index 4d9346c41dad9338fb20175f8b4c1ef94aaf57b3..b13f1555ea1a1ec9e85d6a3c13fa7db3
1133
this.#companion.addOperation(this.data.treeId, {
1234
type: "create",
1335
data: {
36+
diff --git a/esm/src/export.js b/esm/src/export.js
37+
index 0213a2c..34f7ba6 100644
38+
--- a/esm/src/export.js
39+
+++ b/esm/src/export.js
40+
@@ -53,6 +53,9 @@ export function toJson(list) {
41+
name: list.name,
42+
note: list.note,
43+
isCompleted: list.isCompleted,
44+
+ createdAt: list.createdAt?.toISOString(),
45+
+ lastModifiedAt: list.lastModifiedAt?.toISOString(),
46+
+ completedAt: list.completedAt?.toISOString(),
47+
items: list.items.map((sublist) => toJson(sublist)),
48+
};
49+
}
50+
diff --git a/esm/src/schema.js b/esm/src/schema.js
51+
index f3d3e31..057da4a 100644
52+
--- a/esm/src/schema.js
53+
+++ b/esm/src/schema.js
54+
@@ -48,6 +48,7 @@ export const TreeDataSchema = z.object({
55+
prnt: z.string().or(z.null()),
56+
pr: z.number(),
57+
cp: z.number().optional(),
58+
+ ct: z.number().optional(),
59+
lm: z.number(),
60+
metadata: z.object({
61+
mirror: z.object({
62+
@@ -63,6 +64,7 @@ export const TreeDataSchema = z.object({
63+
parentId: i.prnt !== null ? i.prnt : ROOT,
64+
priority: i.pr,
65+
completed: i.cp,
66+
+ created: i.ct,
67+
lastModified: i.lm,
68+
originalId: i.metadata?.mirror?.originalId,
69+
isMirrorRoot: i.metadata?.mirror?.isMirrorRoot === true,

0 commit comments

Comments
 (0)