@graview/core 0.1.56 → 0.1.58
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 +12 -4
- package/dist/capabilities.js +1 -1
- package/dist/capabilities.js.map +1 -1
- package/dist/cli/document-schema.js +3 -3
- package/dist/cli/document-schema.js.map +1 -1
- package/dist/document/blocks.d.ts +4 -2
- package/dist/document/blocks.d.ts.map +1 -1
- package/dist/document/blocks.js +7 -4
- package/dist/document/blocks.js.map +1 -1
- package/dist/document/compile.d.ts.map +1 -1
- package/dist/document/compile.js +4 -0
- package/dist/document/compile.js.map +1 -1
- package/dist/document/compiled.d.ts +2 -0
- package/dist/document/compiled.d.ts.map +1 -1
- package/dist/document/compiled.js +21 -1
- package/dist/document/compiled.js.map +1 -1
- package/dist/document/connection-findings.d.ts.map +1 -1
- package/dist/document/connection-findings.js +189 -25
- package/dist/document/connection-findings.js.map +1 -1
- package/dist/document/connection-spec.d.ts +42 -2
- package/dist/document/connection-spec.d.ts.map +1 -1
- package/dist/document/connection-spec.js +64 -19
- package/dist/document/connection-spec.js.map +1 -1
- package/dist/document/describe-place.d.ts +2 -0
- package/dist/document/describe-place.d.ts.map +1 -1
- package/dist/document/describe-place.js +8 -1
- package/dist/document/describe-place.js.map +1 -1
- package/dist/document/described.d.ts +2 -1
- package/dist/document/described.d.ts.map +1 -1
- package/dist/document/edit.d.ts +1 -1
- package/dist/document/edit.d.ts.map +1 -1
- package/dist/document/edit.js +101 -4
- package/dist/document/edit.js.map +1 -1
- package/dist/document/expr/evaluate.d.ts +1 -1
- package/dist/document/expr/evaluate.d.ts.map +1 -1
- package/dist/document/expr/evaluate.js +20 -1
- package/dist/document/expr/evaluate.js.map +1 -1
- package/dist/document/kept-in-step.d.ts +7 -0
- package/dist/document/kept-in-step.d.ts.map +1 -0
- package/dist/document/kept-in-step.js +28 -0
- package/dist/document/kept-in-step.js.map +1 -0
- package/dist/document/rule-line.d.ts.map +1 -1
- package/dist/document/rule-line.js +2 -0
- package/dist/document/rule-line.js.map +1 -1
- package/dist/document/schema.d.ts +33 -5
- package/dist/document/schema.d.ts.map +1 -1
- package/dist/document/schema.js +13 -1
- package/dist/document/schema.js.map +1 -1
- package/dist/document/to-document.d.ts.map +1 -1
- package/dist/document/to-document.js +4 -2
- package/dist/document/to-document.js.map +1 -1
- package/dist/document/views.d.ts +6 -1
- package/dist/document/views.d.ts.map +1 -1
- package/dist/document/views.js +16 -5
- package/dist/document/views.js.map +1 -1
- package/dist/document.schema.json +281 -98
- package/dist/mutations/derive-edits.d.ts +4 -2
- package/dist/mutations/derive-edits.d.ts.map +1 -1
- package/dist/mutations/derive-edits.js +13 -4
- package/dist/mutations/derive-edits.js.map +1 -1
- package/dist/scaffold/from-template.d.ts.map +1 -1
- package/dist/scaffold/from-template.js +2 -1
- package/dist/scaffold/from-template.js.map +1 -1
- package/dist/schema/field-words.d.ts +10 -0
- package/dist/schema/field-words.d.ts.map +1 -1
- package/dist/schema/field-words.js +26 -10
- package/dist/schema/field-words.js.map +1 -1
- package/dist/schema/reading.d.ts.map +1 -1
- package/dist/schema/reading.js +5 -2
- package/dist/schema/reading.js.map +1 -1
- package/dist/schema/types.d.ts +32 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/sync/connection-filter.d.ts +2 -2
- package/dist/sync/connection-filter.d.ts.map +1 -1
- package/dist/sync/connection-filter.js.map +1 -1
- package/dist/sync/connection.d.ts +72 -28
- package/dist/sync/connection.d.ts.map +1 -1
- package/dist/sync/connection.js +255 -43
- package/dist/sync/connection.js.map +1 -1
- package/dist/sync/creating-act.d.ts +20 -0
- package/dist/sync/creating-act.d.ts.map +1 -0
- package/dist/sync/creating-act.js +29 -0
- package/dist/sync/creating-act.js.map +1 -0
- package/dist/sync/engine.d.ts +83 -1
- package/dist/sync/engine.d.ts.map +1 -1
- package/dist/sync/engine.js +269 -32
- package/dist/sync/engine.js.map +1 -1
- package/dist/sync/google-calendar.d.ts +3 -0
- package/dist/sync/google-calendar.d.ts.map +1 -1
- package/dist/sync/index.d.ts +10 -4
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +6 -2
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/notion-stub.d.ts +81 -0
- package/dist/sync/notion-stub.d.ts.map +1 -0
- package/dist/sync/notion-stub.js +467 -0
- package/dist/sync/notion-stub.js.map +1 -0
- package/dist/sync/notion-types.d.ts +23 -0
- package/dist/sync/notion-types.d.ts.map +1 -0
- package/dist/sync/notion-types.js +49 -0
- package/dist/sync/notion-types.js.map +1 -0
- package/dist/sync/notion.d.ts +98 -0
- package/dist/sync/notion.d.ts.map +1 -0
- package/dist/sync/notion.js +477 -0
- package/dist/sync/notion.js.map +1 -0
- package/dist/sync/types.d.ts +38 -0
- package/dist/sync/types.d.ts.map +1 -1
- package/dist/sync/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/sync/connection.js
CHANGED
|
@@ -1,39 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fieldSpecOf } from "../document/field-spec.js";
|
|
2
2
|
import { GOOGLE_COLORS, MADE_BY_GRAVIEW, inConnectionFilter, tagPattern } from "./connection-filter.js";
|
|
3
|
+
import { relationActName } from "../mutations/derived-names.js";
|
|
4
|
+
import { creatingActFor } from "./creating-act.js";
|
|
3
5
|
import { SyncEngine } from "./engine.js";
|
|
4
6
|
import { googleCalendar } from "./google-calendar.js";
|
|
7
|
+
import { notion, notionKey } from "./notion.js";
|
|
8
|
+
import { NOTION_EDGE, NOTION_INFERABLE } from "./notion-types.js";
|
|
5
9
|
/**
|
|
6
10
|
* A DECLARED CONNECTION, RUN.
|
|
7
11
|
*
|
|
8
|
-
* `connections.<name>` in a declaration says which calendar
|
|
9
|
-
* which
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* `connections.<name>` in a declaration says which calendar or database,
|
|
13
|
+
* which kind, which fields and which way; this turns that into the engine,
|
|
14
|
+
* the mapping and the transport, so a host (`graview serve`, the preview,
|
|
15
|
+
* Graview Cloud) supplies only a token and a place to keep the engine's
|
|
16
|
+
* state. Everything it decides is said here once:
|
|
13
17
|
*
|
|
14
|
-
* - A
|
|
15
|
-
* all-day event's day (`start.date`; the end day is inclusive
|
|
16
|
-
* exclusive at Google, so it is moved by one each way), a
|
|
17
|
-
* field a timed event's instant (`start.dateTime`, read back as
|
|
18
|
-
* instant however Google says it).
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
18
|
+
* - A GOOGLE CALENDAR's field types say what kind of event it is: a `date`
|
|
19
|
+
* field is an all-day event's day (`start.date`; the end day is inclusive
|
|
20
|
+
* here and exclusive at Google, so it is moved by one each way), a
|
|
21
|
+
* `datetime` field a timed event's instant (`start.dateTime`, read back as
|
|
22
|
+
* one UTC instant however Google says it). A FILTER is applied as events
|
|
23
|
+
* arrive, because Google refuses a sync token beside a search: an event
|
|
24
|
+
* outside it is not news, and one that leaves it is gone here. An event
|
|
25
|
+
* made here is given what the filter needs (the color; the tag in its
|
|
26
|
+
* title) so it stays in it, and a private extended property naming the app.
|
|
27
|
+
* - A NOTION DATABASE's properties are the fields the declaration maps, or,
|
|
28
|
+
* when it maps none, every field whose name a property has, the kind's name
|
|
29
|
+
* field being the database's title. A `date` field holds a date property's
|
|
30
|
+
* day, a `datetime` field its instant; an `enum` field a select or status,
|
|
31
|
+
* matched to its options ignoring case and punctuation.
|
|
32
|
+
* - A NOTION RELATION is one of the kind's relations, when `properties`
|
|
33
|
+
* maps it (or, matched by name, when a relation property has its name and
|
|
34
|
+
* every kind it reaches is kept by a Notion connection of the app): a link
|
|
35
|
+
* in Notion is a link here, made and taken away through
|
|
36
|
+
* `connect-<kind>-<relation>` and `disconnect-<kind>-<relation>`. The page
|
|
37
|
+
* it reaches is found through `links`, shared by every connection of the
|
|
38
|
+
* app (`sharedLinks()`), so it may be another connection's record; one
|
|
39
|
+
* not linked yet is held until it is. A relation of one takes the first
|
|
40
|
+
* page Notion lists, and says the rest once.
|
|
41
|
+
* - READ means the other system owns the kind: an act here that would change
|
|
42
|
+
* a record of it is refused with a sentence saying so (`SyncEngine.guard`),
|
|
26
43
|
* rather than accepted and never sent.
|
|
27
|
-
* - Inbound changes land through the app's own acts —
|
|
28
|
-
* the
|
|
29
|
-
* `
|
|
44
|
+
* - Inbound changes land through the app's own acts — one that creates the
|
|
45
|
+
* kind from the fields mapped alone (`creatingAct`), `edit-<kind>` and
|
|
46
|
+
* `remove-<kind>` — authored by the system
|
|
47
|
+
* (`google-calendar`, `notion`), so Activity credits it and undo works.
|
|
30
48
|
*/
|
|
31
49
|
export { CONNECTION_TAG, GOOGLE_COLORS, MADE_BY_GRAVIEW, inConnectionFilter } from "./connection-filter.js";
|
|
32
50
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
33
51
|
const instant = (value) => {
|
|
34
52
|
if (typeof value !== "string" || !value)
|
|
35
53
|
return value;
|
|
36
|
-
const time = Date.parse(value);
|
|
54
|
+
const time = Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(value) ? `${value}T00:00:00Z` : value);
|
|
37
55
|
return Number.isNaN(time) ? value : new Date(time).toISOString().replace(/\.000Z$/, "Z");
|
|
38
56
|
};
|
|
39
57
|
const shiftDay = (value, days) => {
|
|
@@ -41,14 +59,27 @@ const shiftDay = (value, days) => {
|
|
|
41
59
|
return value;
|
|
42
60
|
return new Date(Date.parse(`${value}T00:00:00Z`) + days * DAY_MS).toISOString().slice(0, 10);
|
|
43
61
|
};
|
|
62
|
+
/** A kind's fields as a document says them, by name. */
|
|
63
|
+
function fieldSpecs(app, kind) {
|
|
64
|
+
const shape = app.schema.tryDefinition(kind)?.fields?.shape ?? {};
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const [field, schema] of Object.entries(shape)) {
|
|
67
|
+
const spec = fieldSpecOf(schema);
|
|
68
|
+
if (spec)
|
|
69
|
+
out[field] = spec;
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
44
73
|
/** Whether a field of the kind is a `date` (an all-day event's day) rather than a `datetime`. */
|
|
45
74
|
export function isDayField(app, kind, field) {
|
|
46
|
-
|
|
47
|
-
const read = shape?.[field] === undefined ? undefined : fieldOf(shape[field]);
|
|
48
|
-
return read !== undefined && "spec" in read && read.spec.type === "date";
|
|
75
|
+
return fieldSpecs(app, kind)[field]?.type === "date";
|
|
49
76
|
}
|
|
50
|
-
/** The mapping a declaration says
|
|
77
|
+
/** The mapping a declaration says. */
|
|
51
78
|
export function connectionMapping(app, declaration) {
|
|
79
|
+
return declaration.system === "notion" ? notionConnectionMapping(app, declaration).mapping : googleConnectionMapping(app, declaration);
|
|
80
|
+
}
|
|
81
|
+
/** A Google connection's mapping: field types decide the paths, the filter's tag is kept or stripped. */
|
|
82
|
+
function googleConnectionMapping(app, declaration) {
|
|
52
83
|
const { kind, fields } = declaration;
|
|
53
84
|
const day = isDayField(app, kind, fields.start);
|
|
54
85
|
const when = day ? "date" : "dateTime";
|
|
@@ -93,15 +124,147 @@ export function connectionMapping(app, declaration) {
|
|
|
93
124
|
};
|
|
94
125
|
return { system: "google-calendar", resources: [resource] };
|
|
95
126
|
}
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
127
|
+
/** Words compared loosely: "In progress", "in-progress" and "inProgress" are one. */
|
|
128
|
+
const loose = (word) => word.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
129
|
+
/** The field a kind is named by: one called name or title, else its first required words, else its first words. */
|
|
130
|
+
function nameField(specs) {
|
|
131
|
+
const words = Object.entries(specs).filter(([, spec]) => spec.type === "string" || spec.type === "text");
|
|
132
|
+
return (words.find(([field]) => field === "name" || field === "title") ?? words.find(([, spec]) => spec.required) ?? words[0])?.[0];
|
|
133
|
+
}
|
|
134
|
+
/** A kind's relations as its definition declares them, by name. */
|
|
135
|
+
function edgeSpecs(app, kind) {
|
|
136
|
+
return (app.schema.tryDefinition(kind)?.edges ?? {});
|
|
137
|
+
}
|
|
138
|
+
/** The kinds a Notion connection of the app keeps. */
|
|
139
|
+
function notionKinds(app) {
|
|
140
|
+
return new Set(Object.values(app.connections ?? {}).flatMap((declared) => (declared.system === "notion" ? [declared.kind] : [])));
|
|
141
|
+
}
|
|
142
|
+
/** What a Notion connection maps: the engine's mapping, the property names the transport resolves with their field types, the name that is the title, and the relations matched by name that need not be there. */
|
|
143
|
+
export function notionConnectionMapping(app, declaration, say) {
|
|
144
|
+
const { kind } = declaration;
|
|
145
|
+
const specs = fieldSpecs(app, kind);
|
|
146
|
+
const relations = edgeSpecs(app, kind);
|
|
147
|
+
const fields = {};
|
|
148
|
+
const edges = {};
|
|
149
|
+
const refs = {};
|
|
150
|
+
const quiet = [];
|
|
151
|
+
let titleRef;
|
|
152
|
+
if (declaration.properties) {
|
|
153
|
+
for (const [field, property] of Object.entries(declaration.properties)) {
|
|
154
|
+
const ref = typeof property === "string" ? property : property.name;
|
|
155
|
+
if (!specs[field] && relations[field]) {
|
|
156
|
+
edges[field] = ref;
|
|
157
|
+
refs[ref] = NOTION_EDGE;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
fields[field] = ref;
|
|
161
|
+
refs[ref] = specs[field]?.type;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
for (const [field, spec] of Object.entries(specs)) {
|
|
166
|
+
if (!NOTION_INFERABLE.has(spec.type))
|
|
167
|
+
continue;
|
|
168
|
+
fields[field] = field;
|
|
169
|
+
refs[field] = spec.type;
|
|
170
|
+
}
|
|
171
|
+
titleRef = nameField(specs);
|
|
172
|
+
// A relation is kept by name only when every kind it reaches is another Notion connection's: a relation property of its name may not be there.
|
|
173
|
+
const kept = notionKinds(app);
|
|
174
|
+
for (const [edge, spec] of Object.entries(relations)) {
|
|
175
|
+
if (spec.to === "*" || spec.to.length === 0 || !spec.to.every((target) => kept.has(target)))
|
|
176
|
+
continue;
|
|
177
|
+
edges[edge] = edge;
|
|
178
|
+
refs[edge] = NOTION_EDGE;
|
|
179
|
+
quiet.push(edge);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const encode = {};
|
|
183
|
+
const decode = {};
|
|
184
|
+
for (const field of Object.keys(fields)) {
|
|
185
|
+
const spec = specs[field];
|
|
186
|
+
switch (spec?.type) {
|
|
187
|
+
case "date":
|
|
188
|
+
encode[field] = (value) => (typeof value === "string" ? value.slice(0, 10) : value);
|
|
189
|
+
decode[field] = (value) => (typeof value === "string" ? value.slice(0, 10) : value);
|
|
190
|
+
break;
|
|
191
|
+
case "datetime":
|
|
192
|
+
encode[field] = instant;
|
|
193
|
+
decode[field] = instant;
|
|
194
|
+
break;
|
|
195
|
+
case "enum": {
|
|
196
|
+
const options = spec.options ?? [];
|
|
197
|
+
decode[field] = (value) => (typeof value === "string" ? (options.find((option) => option === value) ?? options.find((option) => loose(option) === loose(value)) ?? value) : value);
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
case "list":
|
|
201
|
+
decode[field] = (value) => (typeof value === "string" ? [value] : value);
|
|
202
|
+
break;
|
|
203
|
+
case "string":
|
|
204
|
+
case "text":
|
|
205
|
+
case "url":
|
|
206
|
+
case "email":
|
|
207
|
+
case "phone":
|
|
208
|
+
// People arrive as a list of names.
|
|
209
|
+
decode[field] = (value) => (Array.isArray(value) ? value.join(", ") : value);
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
for (const edge of Object.keys(edges)) {
|
|
214
|
+
if (relations[edge]?.cardinality !== "one")
|
|
215
|
+
continue;
|
|
216
|
+
// A relation of one holds the first page Notion lists; the rest are said once and left there.
|
|
217
|
+
decode[edge] = (value) => {
|
|
218
|
+
if (!Array.isArray(value) || value.length <= 1)
|
|
219
|
+
return value;
|
|
220
|
+
say?.(`${edge}: each ${kind} links one page, and a page in Notion links ${value.length}, so the first is kept here and the rest are left in Notion`);
|
|
221
|
+
return [value[0]];
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const resource = {
|
|
225
|
+
kind,
|
|
226
|
+
resource: "pages",
|
|
227
|
+
fields,
|
|
228
|
+
...(Object.keys(edges).length > 0 ? { edges } : {}),
|
|
229
|
+
encode,
|
|
230
|
+
decode,
|
|
231
|
+
...(declaration.direction === "read" ? { readonly: true, because: `Each ${kind} comes from a Notion database this app only reads: change it there.` } : {}),
|
|
232
|
+
};
|
|
233
|
+
return { mapping: { system: "notion", resources: [resource] }, refs, ...(titleRef ? { titleRef } : {}), quiet };
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* The act a record of the kind from another system is made through: one
|
|
237
|
+
* that creates it, takes no subject and asks for nothing the connection
|
|
238
|
+
* does not map (`mapped`, our field names) — `add-<kind>` when it fits, else
|
|
239
|
+
* the first declared act that does (`creatingActFor`). Undefined when none
|
|
240
|
+
* fits, which `graview check` says at `connections.<name>`.
|
|
241
|
+
*/
|
|
242
|
+
export function creatingAct(app, kind, mapped) {
|
|
243
|
+
return creatingActFor((app.mutations ?? []), kind, mapped).act;
|
|
244
|
+
}
|
|
245
|
+
/** Our fields from a remote record's, decoded: what a record made from it holds. */
|
|
246
|
+
function decodedBy(resource) {
|
|
247
|
+
return (fields) => {
|
|
248
|
+
const out = {};
|
|
249
|
+
for (const [ours, theirs] of Object.entries(resource.fields)) {
|
|
250
|
+
if (!(theirs in fields))
|
|
251
|
+
continue;
|
|
252
|
+
const decode = resource.decode?.[ours];
|
|
253
|
+
out[ours] = decode ? decode(fields[theirs]) : fields[theirs];
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
};
|
|
100
257
|
}
|
|
101
258
|
/** The engine, the mapping and the transport for one declared connection. */
|
|
102
259
|
export function connection(run) {
|
|
103
|
-
const { declaration
|
|
104
|
-
|
|
260
|
+
const { declaration } = run;
|
|
261
|
+
return declaration.system === "notion" ? notionConnection(run, declaration) : googleConnection(run, declaration);
|
|
262
|
+
}
|
|
263
|
+
function googleConnection(run, declaration) {
|
|
264
|
+
const { app, store } = run;
|
|
265
|
+
if (!run.calendarId)
|
|
266
|
+
throw new Error(`connection ${run.name}: a Google connection needs its calendar's id`);
|
|
267
|
+
const mapping = googleConnectionMapping(app, declaration);
|
|
105
268
|
const resource = mapping.resources[0];
|
|
106
269
|
const color = declaration.filter?.color ? GOOGLE_COLORS[declaration.filter.color] : undefined;
|
|
107
270
|
const remote = googleCalendar({
|
|
@@ -114,17 +277,8 @@ export function connection(run) {
|
|
|
114
277
|
extendedProperties: { private: { [MADE_BY_GRAVIEW]: app.name } },
|
|
115
278
|
},
|
|
116
279
|
});
|
|
117
|
-
const creates = creatingAct(app, declaration.kind);
|
|
118
|
-
const decoded = (
|
|
119
|
-
const out = {};
|
|
120
|
-
for (const [ours, theirs] of Object.entries(resource.fields)) {
|
|
121
|
-
if (!(theirs in fields))
|
|
122
|
-
continue;
|
|
123
|
-
const decode = resource.decode?.[ours];
|
|
124
|
-
out[ours] = decode ? decode(fields[theirs]) : fields[theirs];
|
|
125
|
-
}
|
|
126
|
-
return out;
|
|
127
|
-
};
|
|
280
|
+
const creates = creatingAct(app, declaration.kind, Object.keys(resource.fields));
|
|
281
|
+
const decoded = decodedBy(resource);
|
|
128
282
|
let made = 0;
|
|
129
283
|
const engine = new SyncEngine({
|
|
130
284
|
store,
|
|
@@ -145,4 +299,62 @@ export function connection(run) {
|
|
|
145
299
|
const unguard = declaration.direction === "read" ? engine.guard() : undefined;
|
|
146
300
|
return { engine, mapping, remote, ...(unguard ? { unguard } : {}) };
|
|
147
301
|
}
|
|
302
|
+
function notionConnection(run, declaration) {
|
|
303
|
+
const { app, store } = run;
|
|
304
|
+
if (!run.databaseId)
|
|
305
|
+
throw new Error(`connection ${run.name}: a Notion connection needs its database's id`);
|
|
306
|
+
const { mapping, refs, titleRef, quiet } = notionConnectionMapping(app, declaration, run.say);
|
|
307
|
+
const resource = mapping.resources[0];
|
|
308
|
+
let engine;
|
|
309
|
+
const remote = notion({
|
|
310
|
+
databaseId: run.databaseId,
|
|
311
|
+
...(declaration.source ? { source: declaration.source } : {}),
|
|
312
|
+
token: () => run.token(),
|
|
313
|
+
...(run.secretName ? { secretName: run.secretName } : {}),
|
|
314
|
+
...(run.fetch ? { fetch: run.fetch } : {}),
|
|
315
|
+
refs,
|
|
316
|
+
...(titleRef ? { titleRef } : {}),
|
|
317
|
+
...(quiet.length > 0 ? { quiet } : {}),
|
|
318
|
+
// The pages linked when the pass began: a whole read that no longer lists one finds out whether it is gone.
|
|
319
|
+
known: () => Object.values(engine?.snapshot.links ?? {}).map((link) => link.id),
|
|
320
|
+
...(run.say ? { say: run.say } : {}),
|
|
321
|
+
});
|
|
322
|
+
const creates = creatingAct(app, declaration.kind, Object.keys(resource.fields));
|
|
323
|
+
const decoded = decodedBy(resource);
|
|
324
|
+
// A relation's link lands through its derived pair, when the app has it (the checker says when it has not).
|
|
325
|
+
const has = (name) => {
|
|
326
|
+
try {
|
|
327
|
+
store.mutation(name);
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
catch {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
const relationAct = (act) => ({ localId, edge, to }) => {
|
|
335
|
+
const name = relationActName(act, declaration.kind, edge);
|
|
336
|
+
return has(name) ? { name, args: { id: localId, to } } : null;
|
|
337
|
+
};
|
|
338
|
+
engine = new SyncEngine({
|
|
339
|
+
store,
|
|
340
|
+
mapping,
|
|
341
|
+
remote,
|
|
342
|
+
...(run.links ? { links: run.links } : {}),
|
|
343
|
+
connectInbound: relationAct("connect"),
|
|
344
|
+
disconnectInbound: relationAct("disconnect"),
|
|
345
|
+
conflicts: declaration.conflicts ?? "report",
|
|
346
|
+
applyInbound: ({ localId, fields }) => ({ name: `edit-${declaration.kind}`, args: { id: localId, ...fields } }),
|
|
347
|
+
removeInbound: ({ localId }) => ({ name: `remove-${declaration.kind}`, args: { id: localId } }),
|
|
348
|
+
createInbound: ({ id, fields }) => {
|
|
349
|
+
if (!creates)
|
|
350
|
+
return null;
|
|
351
|
+
// An empty property is no value for a record being made; the page's own id names it, so a full read makes it once.
|
|
352
|
+
const values = Object.fromEntries(Object.entries(decoded(fields)).filter(([, value]) => value !== null && value !== undefined));
|
|
353
|
+
return { name: creates, args: { id: `${declaration.kind}:${run.name}-${notionKey(id)}`, ...values } };
|
|
354
|
+
},
|
|
355
|
+
}, run.state);
|
|
356
|
+
run.links?.add(engine);
|
|
357
|
+
const unguard = declaration.direction === "read" ? engine.guard() : undefined;
|
|
358
|
+
return { engine, mapping, remote, ...(unguard ? { unguard } : {}) };
|
|
359
|
+
}
|
|
148
360
|
//# sourceMappingURL=connection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.js","sourceRoot":"","sources":["../../src/sync/connection.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACxG,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAyC,MAAM,sBAAsB,CAAC;AAG7F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AA0B5G,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACnC,MAAM,OAAO,GAAG,CAAC,KAAc,EAAW,EAAE;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IACtD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,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IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,CAAC;QACxG,CAAC;KACF,EACD,GAAG,CAAC,KAAK,CACV,CAAC;IACF,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,MAAM,OAAO,GAAG,WAAW,CAAC,SAAS,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9E,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AnyMutationDefinition } from "../mutations/types.js";
|
|
2
|
+
/** Why an act that creates the kind cannot make a record from another system's fields alone. */
|
|
3
|
+
export interface UnfitCreatingAct {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
/** The kinds it acts on, when it takes a subject. */
|
|
6
|
+
readonly on?: readonly string[];
|
|
7
|
+
/** The arguments it requires that the connection does not map. */
|
|
8
|
+
readonly asks?: readonly string[];
|
|
9
|
+
}
|
|
10
|
+
export interface CreatingActChoice {
|
|
11
|
+
/** The act a record is made through, when one fits. */
|
|
12
|
+
readonly act?: string;
|
|
13
|
+
/** Every act that creates the kind and does not fit, and why. Empty when none creates it. */
|
|
14
|
+
readonly unfit: readonly UnfitCreatingAct[];
|
|
15
|
+
/** Whether any declared act creates the kind at all. */
|
|
16
|
+
readonly creates: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The act a record of `kind` from another system is made through, given the fields the connection maps. */
|
|
19
|
+
export declare function creatingActFor(mutations: readonly AnyMutationDefinition[], kind: string, mapped: readonly string[]): CreatingActChoice;
|
|
20
|
+
//# sourceMappingURL=creating-act.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"creating-act.d.ts","sourceRoot":"","sources":["../../src/sync/creating-act.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAiBnE,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,iBAAiB;IAChC,uDAAuD;IACvD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,6FAA6F;IAC7F,QAAQ,CAAC,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC5C,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AASD,4GAA4G;AAC5G,wBAAgB,cAAc,CAAC,SAAS,EAAE,SAAS,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,iBAAiB,CAiBtI"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** The arguments an act's input requires, when its input is an object whose shape can be read. */
|
|
2
|
+
function requiredArgs(input) {
|
|
3
|
+
const shape = input?._zod?.def?.shape;
|
|
4
|
+
if (!shape)
|
|
5
|
+
return undefined;
|
|
6
|
+
return Object.keys(shape).filter((arg) => shape[arg]?._zod?.optin !== "optional");
|
|
7
|
+
}
|
|
8
|
+
/** The act a record of `kind` from another system is made through, given the fields the connection maps. */
|
|
9
|
+
export function creatingActFor(mutations, kind, mapped) {
|
|
10
|
+
const creating = mutations.filter((mutation) => (mutation.creates ?? []).includes(kind));
|
|
11
|
+
const given = new Set([...mapped, "id"]);
|
|
12
|
+
const fitting = [];
|
|
13
|
+
const unfit = [];
|
|
14
|
+
for (const mutation of creating) {
|
|
15
|
+
const subject = mutation.subject;
|
|
16
|
+
if (subject) {
|
|
17
|
+
unfit.push({ name: mutation.name, on: subject.kinds === "*" ? [] : subject.kinds });
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const asks = (requiredArgs(mutation.input) ?? []).filter((arg) => !given.has(arg));
|
|
21
|
+
if (asks.length > 0)
|
|
22
|
+
unfit.push({ name: mutation.name, asks });
|
|
23
|
+
else
|
|
24
|
+
fitting.push(mutation.name);
|
|
25
|
+
}
|
|
26
|
+
const act = fitting.find((name) => name === `add-${kind}`) ?? fitting[0];
|
|
27
|
+
return { ...(act ? { act } : {}), unfit, creates: creating.length > 0 };
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=creating-act.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"creating-act.js","sourceRoot":"","sources":["../../src/sync/creating-act.ts"],"names":[],"mappings":"AAmCA,kGAAkG;AAClG,SAAS,YAAY,CAAC,KAAc;IAClC,MAAM,KAAK,GAAI,KAAoG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC;IACtI,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAC;IAC7B,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,KAAK,UAAU,CAAC,CAAC;AACpF,CAAC;AAED,4GAA4G;AAC5G,MAAM,UAAU,cAAc,CAAC,SAA2C,EAAE,IAAY,EAAE,MAAyB;IACjH,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;IACzF,MAAM,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,CAAC"}
|
package/dist/sync/engine.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PlannedChange, Store } from "../store.js";
|
|
2
2
|
import type { AnySchema } from "../schema/schema.js";
|
|
3
|
-
import
|
|
3
|
+
import type { MutationCall } from "../mutations/types.js";
|
|
4
|
+
import { type ConflictPolicy, type LinkResolver, type RemoteSystem, type RemoteWrite, type SyncConflict, type SyncMapping, type SyncState } from "./types.js";
|
|
4
5
|
/** A conflict the engine's policy settled, and the side it took. */
|
|
5
6
|
export type SettledConflict = SyncConflict & {
|
|
6
7
|
readonly took: "ours" | "theirs";
|
|
@@ -41,6 +42,12 @@ export interface SyncReport {
|
|
|
41
42
|
/** Records the remote deleted: removed here through `removeInbound`, or, without one, kept here and no longer synced. */
|
|
42
43
|
readonly gone: readonly string[];
|
|
43
44
|
readonly offline: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* What the remote said when it could not be reached, in its transport's
|
|
47
|
+
* words — a secret it refused, a database not shared — so a host says
|
|
48
|
+
* why rather than only that. Absent when the run reached it.
|
|
49
|
+
*/
|
|
50
|
+
readonly problem?: string;
|
|
44
51
|
readonly state: SyncState;
|
|
45
52
|
}
|
|
46
53
|
/**
|
|
@@ -58,6 +65,8 @@ export interface SyncRefusal {
|
|
|
58
65
|
readonly id?: string;
|
|
59
66
|
}
|
|
60
67
|
export type { SyncConflict } from "./types.js";
|
|
68
|
+
/** A relation's value as both sides compare it: the remote ids it reaches, once each, sorted; none is `null`. */
|
|
69
|
+
export declare function edgeValue(ids: unknown): string[] | null;
|
|
61
70
|
export interface SyncOptions<S extends AnySchema> {
|
|
62
71
|
readonly store: Store<S>;
|
|
63
72
|
readonly mapping: SyncMapping;
|
|
@@ -110,7 +119,43 @@ export interface SyncOptions<S extends AnySchema> {
|
|
|
110
119
|
readonly name: string;
|
|
111
120
|
readonly args: Record<string, unknown>;
|
|
112
121
|
} | null;
|
|
122
|
+
/**
|
|
123
|
+
* WHERE A RECORD A RELATION REACHES IS FOUND, by either id: every engine
|
|
124
|
+
* of the app when its relations reach records another engine keeps
|
|
125
|
+
* (`syncLinks`). Absent: this engine's own links.
|
|
126
|
+
*/
|
|
127
|
+
readonly links?: LinkResolver;
|
|
128
|
+
/** The act that links a record to another, for a relation the remote linked (`connect-<kind>-<edge>`). Required for a mapping with `edges`. */
|
|
129
|
+
connectInbound?(call: {
|
|
130
|
+
readonly localId: string;
|
|
131
|
+
readonly kind: string;
|
|
132
|
+
readonly edge: string;
|
|
133
|
+
readonly to: string;
|
|
134
|
+
}): MutationCall | null;
|
|
135
|
+
/** The act that unlinks them, for a link the remote took away (`disconnect-<kind>-<edge>`). Absent: the link stays here. */
|
|
136
|
+
disconnectInbound?(call: {
|
|
137
|
+
readonly localId: string;
|
|
138
|
+
readonly kind: string;
|
|
139
|
+
readonly edge: string;
|
|
140
|
+
readonly to: string;
|
|
141
|
+
}): MutationCall | null;
|
|
113
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* ONE PLACE TO FIND A RECORD BY EITHER ID, over every engine added to it:
|
|
145
|
+
* what an app's engines share when their relations reach each other's
|
|
146
|
+
* records (one Notion connection per table, each table's relations to
|
|
147
|
+
* another's pages). Read live, so a record another engine linked a moment
|
|
148
|
+
* ago is found; an id is matched as written, then as Notion writes one
|
|
149
|
+
* (hyphenated, lower case).
|
|
150
|
+
*/
|
|
151
|
+
export interface SharedLinks extends LinkResolver {
|
|
152
|
+
/** Adds an engine whose links are looked in. */
|
|
153
|
+
add(engine: {
|
|
154
|
+
linkOf(localId: string): string | undefined;
|
|
155
|
+
linkedTo(id: string): string | undefined;
|
|
156
|
+
}): void;
|
|
157
|
+
}
|
|
158
|
+
export declare function sharedLinks(): SharedLinks;
|
|
114
159
|
/**
|
|
115
160
|
* Two-way sync, on top of the op log rather than beside it.
|
|
116
161
|
*
|
|
@@ -131,6 +176,8 @@ export interface SyncOptions<S extends AnySchema> {
|
|
|
131
176
|
export declare class SyncEngine<S extends AnySchema> {
|
|
132
177
|
private state;
|
|
133
178
|
private readonly options;
|
|
179
|
+
private readonly resolver;
|
|
180
|
+
private reverse?;
|
|
134
181
|
constructor(options: SyncOptions<S>, state?: SyncState);
|
|
135
182
|
get snapshot(): SyncState;
|
|
136
183
|
private get policy();
|
|
@@ -143,6 +190,41 @@ export declare class SyncEngine<S extends AnySchema> {
|
|
|
143
190
|
* an act is even offered.
|
|
144
191
|
*/
|
|
145
192
|
refuses(kind: string): string | undefined;
|
|
193
|
+
/** The remote's id of a record this engine linked. */
|
|
194
|
+
linkOf(localId: string): string | undefined;
|
|
195
|
+
/** Our id of the remote's record, if this engine linked it. */
|
|
196
|
+
linkedTo(id: string): string | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* A NODE'S VALUES AS THE REMOTE IS COMPARED WITH: its mapped fields, and
|
|
199
|
+
* each mapped relation as the remote ids of the records it reaches — those
|
|
200
|
+
* linked, and those held until they are — sorted. A record it reaches that
|
|
201
|
+
* no engine has linked yet (made here, not sent) is not in it until it is.
|
|
202
|
+
*/
|
|
203
|
+
private valuesOf;
|
|
204
|
+
/**
|
|
205
|
+
* THE ACTS ONE CHANGE COMING IN LANDS THROUGH, in one batch: the record
|
|
206
|
+
* made (`create`) or its fields edited (`applyInbound`), then each of its
|
|
207
|
+
* relations brought to what the remote says — links it lost taken away
|
|
208
|
+
* first, so a relation of one is never refused for holding two — and the
|
|
209
|
+
* remote ids no engine has linked yet, to hold.
|
|
210
|
+
*/
|
|
211
|
+
private inboundCalls;
|
|
212
|
+
/** Keeps what a landed change left to link, by our id and edge. */
|
|
213
|
+
private hold;
|
|
214
|
+
/**
|
|
215
|
+
* LANDS ONE CHANGE COMING IN through its acts, authored by the remote's
|
|
216
|
+
* system, and holds the links it could not make yet. Undefined when this
|
|
217
|
+
* store refused it (said in `refused`, or thrown without it).
|
|
218
|
+
*/
|
|
219
|
+
private landInbound;
|
|
220
|
+
/**
|
|
221
|
+
* LINKS WHAT WAS HELD, now that its records are linked — by this engine
|
|
222
|
+
* or another of the app's. Nothing is sent for it: the relation's value
|
|
223
|
+
* already held those ids. A host running several engines calls this on
|
|
224
|
+
* each after a pass, so the order they ran in does not matter; `run`
|
|
225
|
+
* calls it too. Returns the records it linked.
|
|
226
|
+
*/
|
|
227
|
+
resolveHeld(refused?: SyncRefusal[]): string[];
|
|
146
228
|
/** Every node that participates in the sync, by our id. */
|
|
147
229
|
private participants;
|
|
148
230
|
/** A link for every participant whose mapping names its version field and that carries one. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/sync/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/sync/engine.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,aAAa,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACtE,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAyB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIjF,OAAO,EAIL,KAAK,cAAc,EAEnB,KAAK,YAAY,EAGjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,SAAS,EACf,MAAM,YAAY,CAAC;AAEpB,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;CAAE,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,2DAA2D;IAC3D,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,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