@kamilio/wire 0.1.56 → 0.1.57
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/README.md +44 -1
- package/dist/adapters/document-shell.d.ts +7 -0
- package/dist/adapters/document-shell.d.ts.map +1 -0
- package/dist/adapters/document-shell.js +51 -0
- package/dist/adapters/document-shell.js.map +1 -0
- package/dist/adapters/root.d.ts.map +1 -1
- package/dist/adapters/root.js +69 -4
- package/dist/adapters/root.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -2
- package/dist/cli.js.map +1 -1
- package/dist/document-shell-engine.mjs +1880 -0
- package/dist/executable.js +1 -1
- package/dist/executable.js.map +1 -1
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +19 -19
- package/dist/hooks.js.map +1 -1
- package/node_modules/provider-asana/dist/asana-project.d.ts +7 -1
- package/node_modules/provider-asana/dist/asana-project.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/asana-task.d.ts +7 -1
- package/node_modules/provider-asana/dist/asana-task.d.ts.map +1 -1
- package/node_modules/provider-asana/dist/index.d.ts +14 -2
- package/node_modules/provider-asana/dist/index.d.ts.map +1 -1
- package/node_modules/provider-chatgpt/dist/chatgpt.d.ts +7 -1
- package/node_modules/provider-chatgpt/dist/chatgpt.d.ts.map +1 -1
- package/node_modules/provider-chatgpt/dist/index.d.ts +7 -1
- package/node_modules/provider-chatgpt/dist/index.d.ts.map +1 -1
- package/node_modules/provider-gmail/dist/gmail.d.ts +7 -1
- package/node_modules/provider-gmail/dist/gmail.d.ts.map +1 -1
- package/node_modules/provider-gmail/dist/index.d.ts +7 -1
- package/node_modules/provider-gmail/dist/index.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/doc-blocks.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/doc-blocks.js +6 -2
- package/node_modules/provider-google-docs/dist/doc-blocks.js.map +1 -1
- package/node_modules/provider-google-docs/dist/google-docs.d.ts +7 -1
- package/node_modules/provider-google-docs/dist/google-docs.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/google-docs.js +31 -10
- package/node_modules/provider-google-docs/dist/google-docs.js.map +1 -1
- package/node_modules/provider-google-docs/dist/google-forms.d.ts +7 -1
- package/node_modules/provider-google-docs/dist/google-forms.d.ts.map +1 -1
- package/node_modules/provider-google-docs/dist/index.d.ts +14 -2
- package/node_modules/provider-google-docs/dist/index.d.ts.map +1 -1
- package/node_modules/provider-google-docs/src/doc-blocks.ts +8 -2
- package/node_modules/provider-google-docs/src/google-docs.ts +26 -10
- package/node_modules/provider-lattice/dist/index.d.ts +14 -2
- package/node_modules/provider-lattice/dist/index.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/index.d.ts +7 -1
- package/node_modules/provider-notion/dist/index.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/notion-sync.d.ts +2 -2
- package/node_modules/provider-notion/dist/notion-sync.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/notion-sync.js +24 -15
- package/node_modules/provider-notion/dist/notion-sync.js.map +1 -1
- package/node_modules/provider-notion/dist/notion.d.ts +7 -1
- package/node_modules/provider-notion/dist/notion.d.ts.map +1 -1
- package/node_modules/provider-notion/dist/notion.js +1 -1
- package/node_modules/provider-notion/dist/notion.js.map +1 -1
- package/node_modules/provider-notion/src/notion-sync.ts +23 -15
- package/node_modules/provider-notion/src/notion.ts +1 -1
- package/node_modules/provider-slack/dist/index.d.ts +7 -1
- package/node_modules/provider-slack/dist/index.d.ts.map +1 -1
- package/node_modules/provider-slack/dist/slack.d.ts +7 -1
- package/node_modules/provider-slack/dist/slack.d.ts.map +1 -1
- package/node_modules/provider-zoom/dist/index.d.ts +7 -1
- package/node_modules/provider-zoom/dist/index.d.ts.map +1 -1
- package/node_modules/provider-zoom/dist/zoom-hub.d.ts +7 -1
- package/node_modules/provider-zoom/dist/zoom-hub.d.ts.map +1 -1
- package/node_modules/wire-core/dist/core/editor-receipts.d.ts +5 -0
- package/node_modules/wire-core/dist/core/editor-receipts.d.ts.map +1 -0
- package/node_modules/wire-core/dist/core/editor-receipts.js +9 -0
- package/node_modules/wire-core/dist/core/editor-receipts.js.map +1 -0
- package/node_modules/wire-core/dist/core/model.d.ts +4 -1
- package/node_modules/wire-core/dist/core/model.d.ts.map +1 -1
- package/node_modules/wire-core/dist/core/owner.d.ts +3 -0
- package/node_modules/wire-core/dist/core/owner.d.ts.map +1 -0
- package/node_modules/wire-core/dist/core/owner.js +16 -0
- package/node_modules/wire-core/dist/core/owner.js.map +1 -0
- package/node_modules/wire-core/dist/core/source.d.ts +4 -1
- package/node_modules/wire-core/dist/core/source.d.ts.map +1 -1
- package/node_modules/wire-core/dist/core/source.js +12 -2
- package/node_modules/wire-core/dist/core/source.js.map +1 -1
- package/node_modules/wire-core/dist/index.d.ts +1 -1
- package/node_modules/wire-core/dist/index.d.ts.map +1 -1
- package/node_modules/wire-core/dist/index.js +1 -1
- package/node_modules/wire-core/dist/index.js.map +1 -1
- package/node_modules/wire-core/dist/operations.d.ts +11 -2
- package/node_modules/wire-core/dist/operations.d.ts.map +1 -1
- package/node_modules/wire-core/dist/operations.js +399 -31
- package/node_modules/wire-core/dist/operations.js.map +1 -1
- package/node_modules/wire-core/dist/storage/editor-receipts.d.ts +17 -0
- package/node_modules/wire-core/dist/storage/editor-receipts.d.ts.map +1 -0
- package/node_modules/wire-core/dist/storage/editor-receipts.js +27 -0
- package/node_modules/wire-core/dist/storage/editor-receipts.js.map +1 -0
- package/node_modules/wire-core/dist/storage/history-integrity.d.ts +4 -0
- package/node_modules/wire-core/dist/storage/history-integrity.d.ts.map +1 -0
- package/node_modules/wire-core/dist/storage/history-integrity.js +32 -0
- package/node_modules/wire-core/dist/storage/history-integrity.js.map +1 -0
- package/node_modules/wire-core/dist/storage/history.d.ts +93 -0
- package/node_modules/wire-core/dist/storage/history.d.ts.map +1 -0
- package/node_modules/wire-core/dist/storage/history.js +450 -0
- package/node_modules/wire-core/dist/storage/history.js.map +1 -0
- package/node_modules/wire-core/dist/storage/registry.d.ts +2 -2
- package/node_modules/wire-core/dist/storage/registry.d.ts.map +1 -1
- package/node_modules/wire-core/dist/storage/registry.js +34 -14
- package/node_modules/wire-core/dist/storage/registry.js.map +1 -1
- package/node_modules/wire-core/dist/storage/workspace.d.ts.map +1 -1
- package/node_modules/wire-core/dist/storage/workspace.js +183 -40
- package/node_modules/wire-core/dist/storage/workspace.js.map +1 -1
- package/node_modules/wire-core/src/core/editor-receipts.ts +8 -0
- package/node_modules/wire-core/src/core/model.ts +4 -1
- package/node_modules/wire-core/src/core/owner.ts +16 -0
- package/node_modules/wire-core/src/core/source.ts +13 -1
- package/node_modules/wire-core/src/index.ts +1 -1
- package/node_modules/wire-core/src/operations.ts +339 -33
- package/node_modules/wire-core/src/storage/editor-receipts.ts +27 -0
- package/node_modules/wire-core/src/storage/history-integrity.ts +25 -0
- package/node_modules/wire-core/src/storage/history.ts +331 -0
- package/node_modules/wire-core/src/storage/registry.ts +22 -15
- package/node_modules/wire-core/src/storage/workspace.ts +129 -34
- package/package.json +6 -2
- package/src/adapters/document-shell.ts +43 -0
- package/src/adapters/root.ts +71 -4
- package/src/cli.ts +8 -2
- package/src/executable.ts +1 -1
- package/src/hooks.ts +19 -18
|
@@ -2,6 +2,7 @@ export { latticeReviewDraft, listLatticeReviewRequests, syncLatticeDrafts } from
|
|
|
2
2
|
import { type AddMarkdown, type RuntimeCapabilities } from "wire-core";
|
|
3
3
|
export declare const latticeService: Readonly<{
|
|
4
4
|
name: string;
|
|
5
|
+
owner?: string;
|
|
5
6
|
matches(url: URL): boolean;
|
|
6
7
|
parse(url: URL): import("wire-core").Source;
|
|
7
8
|
fetch(input: RuntimeCapabilities, url: string, source: Readonly<{
|
|
@@ -20,17 +21,23 @@ export declare const latticeService: Readonly<{
|
|
|
20
21
|
identifier: string;
|
|
21
22
|
type: import("wire-core").ResourceType;
|
|
22
23
|
}>, write: import("wire-core").DownloadWriter, addMarkdown?: AddMarkdown): Promise<import("wire-core").DownloadedDocument | null>;
|
|
24
|
+
mergeDrafts?(base: string, editor: string, shell: string): string;
|
|
23
25
|
synchronize?(input: RuntimeCapabilities, url: string, source: Readonly<{
|
|
24
26
|
[key: string]: import("wire-core").JsonValue;
|
|
25
27
|
service: string;
|
|
26
28
|
identifier: string;
|
|
27
29
|
type: import("wire-core").ResourceType;
|
|
28
|
-
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string
|
|
30
|
+
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string, observeRemote?: (remote: Readonly<{
|
|
31
|
+
title: string;
|
|
32
|
+
markdown: string;
|
|
33
|
+
data: import("wire-core").JsonValue;
|
|
34
|
+
}>) => void | Promise<void>, requireConditionalWrite?: boolean): Promise<import("wire-core").SynchronizedDocument>;
|
|
29
35
|
upload?(input: RuntimeCapabilities, markdown: string, markdownPath: string): Promise<import("wire-core").UploadedDocument>;
|
|
30
36
|
}>;
|
|
31
37
|
export declare const latticeProvider: Readonly<{
|
|
32
38
|
services: readonly [Readonly<{
|
|
33
39
|
name: string;
|
|
40
|
+
owner?: string;
|
|
34
41
|
matches(url: URL): boolean;
|
|
35
42
|
parse(url: URL): import("wire-core").Source;
|
|
36
43
|
fetch(input: RuntimeCapabilities, url: string, source: Readonly<{
|
|
@@ -49,12 +56,17 @@ export declare const latticeProvider: Readonly<{
|
|
|
49
56
|
identifier: string;
|
|
50
57
|
type: import("wire-core").ResourceType;
|
|
51
58
|
}>, write: import("wire-core").DownloadWriter, addMarkdown?: AddMarkdown): Promise<import("wire-core").DownloadedDocument | null>;
|
|
59
|
+
mergeDrafts?(base: string, editor: string, shell: string): string;
|
|
52
60
|
synchronize?(input: RuntimeCapabilities, url: string, source: Readonly<{
|
|
53
61
|
[key: string]: import("wire-core").JsonValue;
|
|
54
62
|
service: string;
|
|
55
63
|
identifier: string;
|
|
56
64
|
type: import("wire-core").ResourceType;
|
|
57
|
-
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string
|
|
65
|
+
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string, observeRemote?: (remote: Readonly<{
|
|
66
|
+
title: string;
|
|
67
|
+
markdown: string;
|
|
68
|
+
data: import("wire-core").JsonValue;
|
|
69
|
+
}>) => void | Promise<void>, requireConditionalWrite?: boolean): Promise<import("wire-core").SynchronizedDocument>;
|
|
58
70
|
upload?(input: RuntimeCapabilities, markdown: string, markdownPath: string): Promise<import("wire-core").UploadedDocument>;
|
|
59
71
|
}>];
|
|
60
72
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAiB,KAAK,WAAW,EAAwB,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAmd5G,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAiB,KAAK,WAAW,EAAwB,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAmd5G,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBzB,CAAC;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAyD,CAAC"}
|
|
@@ -4,6 +4,7 @@ export type { NotionBlock, NotionDiffSummary, NotionOperation, NotionRichText, N
|
|
|
4
4
|
export declare const notionProvider: Readonly<{
|
|
5
5
|
services: readonly [Readonly<{
|
|
6
6
|
name: string;
|
|
7
|
+
owner?: string;
|
|
7
8
|
matches(url: URL): boolean;
|
|
8
9
|
parse(url: URL): import("wire-core").Source;
|
|
9
10
|
fetch(input: import("wire-core").RuntimeCapabilities, url: string, source: Readonly<{
|
|
@@ -22,12 +23,17 @@ export declare const notionProvider: Readonly<{
|
|
|
22
23
|
identifier: string;
|
|
23
24
|
type: import("wire-core").ResourceType;
|
|
24
25
|
}>, write: import("wire-core").DownloadWriter, addMarkdown?: import("wire-core").AddMarkdown): Promise<import("wire-core").DownloadedDocument | null>;
|
|
26
|
+
mergeDrafts?(base: string, editor: string, shell: string): string;
|
|
25
27
|
synchronize?(input: import("wire-core").RuntimeCapabilities, url: string, source: Readonly<{
|
|
26
28
|
[key: string]: import("wire-core").JsonValue;
|
|
27
29
|
service: string;
|
|
28
30
|
identifier: string;
|
|
29
31
|
type: import("wire-core").ResourceType;
|
|
30
|
-
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string
|
|
32
|
+
}>, base: import("wire-core").JsonValue, markdown: string, markdownPath: string, observeRemote?: (remote: Readonly<{
|
|
33
|
+
title: string;
|
|
34
|
+
markdown: string;
|
|
35
|
+
data: import("wire-core").JsonValue;
|
|
36
|
+
}>) => void | Promise<void>, requireConditionalWrite?: boolean): Promise<import("wire-core").SynchronizedDocument>;
|
|
31
37
|
upload?(input: import("wire-core").RuntimeCapabilities, markdown: string, markdownPath: string): Promise<import("wire-core").UploadedDocument>;
|
|
32
38
|
}>];
|
|
33
39
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC3O,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxI,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC3O,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACxI,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEzB,CAAC;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DownloadedDocument, DownloadWriter, FetchedDocument, JsonObject, JsonValue, Source, UploadedDocument } from "wire-core";
|
|
1
|
+
import type { DownloadedDocument, DownloadWriter, FetchedDocument, JsonObject, JsonValue, Source, SynchronizedDocument, UploadedDocument } from "wire-core";
|
|
2
2
|
import type { RuntimeCapabilities } from "wire-core";
|
|
3
3
|
export type NotionRichText = JsonValue[][];
|
|
4
4
|
export type NotionBlock = Readonly<{
|
|
@@ -54,6 +54,6 @@ export declare function lookupNotionUsers(runtime: RuntimeCapabilities, query: s
|
|
|
54
54
|
export declare function fetchNotionDocument(runtime: RuntimeCapabilities, url: string, source: Source): Promise<FetchedDocument>;
|
|
55
55
|
export declare function downloadNotionDirectory(runtime: RuntimeCapabilities, url: string, source: Source, write: DownloadWriter): Promise<DownloadedDocument | null>;
|
|
56
56
|
export declare function uploadNotionDocument(runtime: RuntimeCapabilities, markdown: string, _markdownPath: string): Promise<UploadedDocument>;
|
|
57
|
-
export declare function synchronizeNotionDocument(runtime: RuntimeCapabilities, url: string, source: Source, base: JsonValue, markdown: string, _markdownPath: string): Promise<
|
|
57
|
+
export declare function synchronizeNotionDocument(runtime: RuntimeCapabilities, url: string, source: Source, base: JsonValue, markdown: string, _markdownPath: string, observeRemote?: (remote: FetchedDocument) => void | Promise<void>, requireConditionalWrite?: boolean): Promise<SynchronizedDocument>;
|
|
58
58
|
export {};
|
|
59
59
|
//# sourceMappingURL=notion-sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notion-sync.d.ts","sourceRoot":"","sources":["../src/notion-sync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"notion-sync.d.ts","sourceRoot":"","sources":["../src/notion-sync.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE5J,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAErD,MAAM,MAAM,cAAc,GAAG,SAAS,EAAE,EAAE,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAC;IAAC,SAAS,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACzI,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,CAAC,CAAC;AACtG,MAAM,MAA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kD3I;AAUD,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,mBAAmB,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,uBAAuB,UAAQ,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA+DtS"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { posix } from "node:path";
|
|
3
|
-
import { markdownFilename, stableJsonCompact, stableJsonPretty } from "wire-core";
|
|
3
|
+
import { WireMergeConflict, markdownFilename, stableJsonCompact, stableJsonPretty } from "wire-core";
|
|
4
4
|
function object(value) { return value; }
|
|
5
5
|
function array(value) { return value; }
|
|
6
6
|
function text(value) { return value; }
|
|
@@ -1256,12 +1256,22 @@ function splitTitle(markdown) {
|
|
|
1256
1256
|
return { title: first.replace(/^#+\s+/, "").trim(), body: lines.slice(1).join("\n") };
|
|
1257
1257
|
return { title: "", body: markdown };
|
|
1258
1258
|
}
|
|
1259
|
-
export async function synchronizeNotionDocument(runtime, url, source, base, markdown, _markdownPath) {
|
|
1259
|
+
export async function synchronizeNotionDocument(runtime, url, source, base, markdown, _markdownPath, observeRemote, requireConditionalWrite = false) {
|
|
1260
1260
|
const remote = await fetchTree(runtime, url, source);
|
|
1261
|
+
const save = async (operations) => {
|
|
1262
|
+
if (operations.length === 0)
|
|
1263
|
+
return;
|
|
1264
|
+
// saveTransactionsFanout cannot check the tree revision at commit time.
|
|
1265
|
+
if (requireConditionalWrite)
|
|
1266
|
+
throw new Error("Notion cannot condition a save on the revision read. Local draft preserved; apply the edit in Notion.");
|
|
1267
|
+
await notionPost(runtime, "saveTransactionsFanout", remote.cookie, { requestId: randomUUID(), transactions: [{ id: randomUUID(), spaceId: remote.spaceId, operations }] }, remote.headers);
|
|
1268
|
+
};
|
|
1261
1269
|
const baseObject = object(base);
|
|
1262
1270
|
const mentions = baseUserMentions(baseObject);
|
|
1263
1271
|
const emailMentions = { ...baseObject["email_mentions"] };
|
|
1264
|
-
const
|
|
1272
|
+
const observed = notionDocument(remote.tree.id, remote.tree, mentions, { ...emailMentions }, remote.comments);
|
|
1273
|
+
await observeRemote?.(observed);
|
|
1274
|
+
const currentMarkdown = withoutComments(observed.markdown);
|
|
1265
1275
|
const baseMarkdown = baseObject["markdown"] === undefined ? undefined : withoutComments(baseObject["markdown"]);
|
|
1266
1276
|
let split = splitTitle(withoutComments(markdown));
|
|
1267
1277
|
const currentSplit = splitTitle(currentMarkdown);
|
|
@@ -1273,7 +1283,7 @@ export async function synchronizeNotionDocument(runtime, url, source, base, mark
|
|
|
1273
1283
|
const localBodyChanged = baseSplit.body !== split.body;
|
|
1274
1284
|
const remoteBodyChanged = baseSplit.body !== currentSplit.body;
|
|
1275
1285
|
if (localTitleChanged && remoteTitleChanged && split.title !== "" && split.title !== currentSplit.title || localBodyChanged && remoteBodyChanged && split.body !== currentSplit.body)
|
|
1276
|
-
throw new
|
|
1286
|
+
throw new WireMergeConflict("Markdown and Notion changed since last sync");
|
|
1277
1287
|
if ((localTitleChanged || localBodyChanged) && (remoteTitleChanged || remoteBodyChanged)) {
|
|
1278
1288
|
split = { title: localTitleChanged ? split.title : currentSplit.title, body: localBodyChanged ? split.body : currentSplit.body };
|
|
1279
1289
|
fieldMerged = true;
|
|
@@ -1285,28 +1295,28 @@ export async function synchronizeNotionDocument(runtime, url, source, base, mark
|
|
|
1285
1295
|
const localTitleChanged = baseSplit.title !== split.title;
|
|
1286
1296
|
const remoteTitleChanged = baseSplit.title !== currentSplit.title;
|
|
1287
1297
|
if (!localTitleChanged && remoteTitleChanged)
|
|
1288
|
-
return
|
|
1298
|
+
return { ...observed, wroteRemote: false };
|
|
1289
1299
|
if (localTitleChanged && remoteTitleChanged && split.title !== currentSplit.title)
|
|
1290
|
-
throw new
|
|
1300
|
+
throw new WireMergeConflict("Markdown and Notion changed since last sync");
|
|
1291
1301
|
if (localTitleChanged && remoteTitleChanged)
|
|
1292
|
-
return
|
|
1302
|
+
return { ...observed, wroteRemote: false };
|
|
1293
1303
|
}
|
|
1294
1304
|
const titleRich = split.title === "" ? object(remote.tree.block["properties"])["title"] : titleRichText(split.title);
|
|
1295
1305
|
const titleChanged = split.title !== "" && compact(object(remote.tree.block["properties"])["title"]) !== compact(titleRich);
|
|
1296
1306
|
if (titleChanged)
|
|
1297
|
-
await
|
|
1307
|
+
await save([{ pointer: pointer(remote.tree.id, remote.spaceId), path: ["properties", "title"], command: "updateBlockPropertyValue", args: { primitiveOp: { command: "set", args: titleRich } } }, { pointer: pointer(remote.tree.id, remote.spaceId), path: ["last_edited_time"], command: "set", args: runtime.clock.now().getTime() }]);
|
|
1298
1308
|
const outputTree = { ...remote.tree, block: { ...remote.tree.block, properties: { ...object(remote.tree.block["properties"]), title: titleRich } } };
|
|
1299
|
-
return notionDocument(remote.tree.id, outputTree, mentions, emailMentions, remote.comments);
|
|
1309
|
+
return { ...notionDocument(remote.tree.id, outputTree, mentions, emailMentions, remote.comments), wroteRemote: titleChanged };
|
|
1300
1310
|
}
|
|
1301
1311
|
if (baseMarkdown !== undefined) {
|
|
1302
1312
|
const localChanged = baseMarkdown !== targetMarkdown;
|
|
1303
1313
|
const remoteChanged = baseMarkdown !== currentMarkdown;
|
|
1304
1314
|
if (!localChanged && remoteChanged)
|
|
1305
|
-
return
|
|
1315
|
+
return { ...observed, wroteRemote: false };
|
|
1306
1316
|
if (localChanged && remoteChanged && targetMarkdown !== currentMarkdown && !fieldMerged)
|
|
1307
|
-
throw new
|
|
1317
|
+
throw new WireMergeConflict("Markdown and Notion changed since last sync");
|
|
1308
1318
|
if (localChanged && remoteChanged && targetMarkdown === currentMarkdown)
|
|
1309
|
-
return
|
|
1319
|
+
return { ...observed, wroteRemote: false };
|
|
1310
1320
|
}
|
|
1311
1321
|
const localBody = mentions === undefined ? split.body : hydrateUserMentions(split.body, mentions);
|
|
1312
1322
|
const localBlocks = parseNotionMarkdown(localBody);
|
|
@@ -1317,9 +1327,8 @@ export async function synchronizeNotionDocument(runtime, url, source, base, mark
|
|
|
1317
1327
|
const titleRich = split.title === "" ? object(remote.tree.block["properties"])["title"] : titleRichText(split.title);
|
|
1318
1328
|
if (split.title !== "" && compact(object(remote.tree.block["properties"])["title"]) !== compact(titleRich))
|
|
1319
1329
|
operations.unshift({ pointer: pointer(remote.tree.id, remote.spaceId), path: ["properties", "title"], command: "updateBlockPropertyValue", args: { primitiveOp: { command: "set", args: titleRich } } });
|
|
1320
|
-
|
|
1321
|
-
await notionPost(runtime, "saveTransactionsFanout", remote.cookie, { requestId: randomUUID(), transactions: [{ id: randomUUID(), spaceId: remote.spaceId, operations }] }, remote.headers);
|
|
1330
|
+
await save(operations);
|
|
1322
1331
|
const outputTree = { id: remote.tree.id, block: { ...remote.tree.block, properties: { ...object(remote.tree.block["properties"]), title: titleRich } }, children: localTree(localBlocks).map((node, index) => outputNode(node, remote.tree.children[index], remote.tree.id, remote, ambient.currentTime)) };
|
|
1323
|
-
return notionDocument(remote.tree.id, outputTree, mentions, emailMentions, remote.comments);
|
|
1332
|
+
return { ...notionDocument(remote.tree.id, outputTree, mentions, emailMentions, remote.comments), wroteRemote: operations.length > 0 };
|
|
1324
1333
|
}
|
|
1325
1334
|
//# sourceMappingURL=notion-sync.js.map
|