@graview/core 0.1.57 → 0.1.59
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/archived-seen.d.ts.map +1 -1
- package/dist/archived-seen.js +7 -3
- package/dist/archived-seen.js.map +1 -1
- package/dist/catalog.js +1 -1
- package/dist/catalog.js.map +1 -1
- package/dist/cli/check/field-sight.d.ts.map +1 -1
- package/dist/cli/check/field-sight.js +3 -1
- package/dist/cli/check/field-sight.js.map +1 -1
- package/dist/cli/document-schema.js +1 -1
- package/dist/cli/document-schema.js.map +1 -1
- package/dist/document/brand.js +3 -3
- package/dist/document/brand.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 +22 -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/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/schema.d.ts +5 -5
- package/dist/document.schema.json +243 -98
- package/dist/field-sight.js +4 -2
- package/dist/field-sight.js.map +1 -1
- package/dist/fresh.d.ts +26 -0
- package/dist/fresh.d.ts.map +1 -0
- package/dist/fresh.js +33 -0
- package/dist/fresh.js.map +1 -0
- package/dist/friction.d.ts +7 -0
- package/dist/friction.d.ts.map +1 -1
- package/dist/friction.js +2 -1
- package/dist/friction.js.map +1 -1
- package/dist/import/rows.d.ts.map +1 -1
- package/dist/import/rows.js +20 -10
- package/dist/import/rows.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/linked.d.ts.map +1 -1
- package/dist/linked.js +7 -1
- package/dist/linked.js.map +1 -1
- package/dist/mutations/define-mutation.d.ts +14 -0
- package/dist/mutations/define-mutation.d.ts.map +1 -1
- package/dist/mutations/define-mutation.js +9 -4
- package/dist/mutations/define-mutation.js.map +1 -1
- 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 +17 -5
- package/dist/mutations/derive-edits.js.map +1 -1
- package/dist/mutations/derive-repeats.d.ts +8 -0
- package/dist/mutations/derive-repeats.d.ts.map +1 -1
- package/dist/mutations/derive-repeats.js +29 -4
- package/dist/mutations/derive-repeats.js.map +1 -1
- package/dist/mutations/type-text.d.ts +6 -1
- package/dist/mutations/type-text.d.ts.map +1 -1
- package/dist/mutations/type-text.js +8 -1
- package/dist/mutations/type-text.js.map +1 -1
- package/dist/mutations/types.d.ts +10 -0
- package/dist/mutations/types.d.ts.map +1 -1
- package/dist/ops/lineage.d.ts +12 -1
- package/dist/ops/lineage.d.ts.map +1 -1
- package/dist/ops/lineage.js +9 -2
- package/dist/ops/lineage.js.map +1 -1
- package/dist/ops/log.d.ts +23 -0
- package/dist/ops/log.d.ts.map +1 -1
- package/dist/ops/log.js +7 -0
- package/dist/ops/log.js.map +1 -1
- package/dist/ops/undo.d.ts.map +1 -1
- package/dist/ops/undo.js +9 -0
- package/dist/ops/undo.js.map +1 -1
- package/dist/permissions/sight.d.ts +8 -0
- package/dist/permissions/sight.d.ts.map +1 -1
- package/dist/permissions/sight.js +8 -0
- package/dist/permissions/sight.js.map +1 -1
- package/dist/publish.d.ts +7 -2
- package/dist/publish.d.ts.map +1 -1
- package/dist/publish.js.map +1 -1
- package/dist/publishing.d.ts +4 -1
- package/dist/publishing.d.ts.map +1 -1
- package/dist/publishing.js +59 -14
- package/dist/publishing.js.map +1 -1
- package/dist/scaffold/from-template.d.ts.map +1 -1
- package/dist/scaffold/from-template.js +4 -3
- package/dist/scaffold/from-template.js.map +1 -1
- package/dist/scaffold/names.d.ts +10 -0
- package/dist/scaffold/names.d.ts.map +1 -1
- package/dist/scaffold/names.js +20 -1
- package/dist/scaffold/names.js.map +1 -1
- package/dist/scaffold/ui.d.ts.map +1 -1
- package/dist/scaffold/ui.js +9 -8
- package/dist/scaffold/ui.js.map +1 -1
- package/dist/schema/figures.d.ts +9 -2
- package/dist/schema/figures.d.ts.map +1 -1
- package/dist/schema/figures.js +38 -9
- package/dist/schema/figures.js.map +1 -1
- package/dist/schema/linked.d.ts +7 -1
- package/dist/schema/linked.d.ts.map +1 -1
- package/dist/schema/linked.js.map +1 -1
- package/dist/schema/types.d.ts +10 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/seen.d.ts.map +1 -1
- package/dist/seen.js +21 -2
- package/dist/seen.js.map +1 -1
- package/dist/store.d.ts +29 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +158 -31
- package/dist/store.js.map +1 -1
- package/dist/subscriptions.d.ts +12 -0
- package/dist/subscriptions.d.ts.map +1 -1
- package/dist/subscriptions.js +10 -1
- package/dist/subscriptions.js.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/mcp.d.ts +8 -0
- package/dist/sync/mcp.d.ts.map +1 -1
- package/dist/sync/mcp.js +2 -0
- package/dist/sync/mcp.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/text/typing-hook.d.ts +2 -2
- package/dist/text/typing-hook.d.ts.map +1 -1
- package/dist/theme/fonts.d.ts +10 -0
- package/dist/theme/fonts.d.ts.map +1 -1
- package/dist/theme/fonts.js +25 -1
- package/dist/theme/fonts.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/views/kept.d.ts.map +1 -1
- package/dist/views/kept.js +3 -0
- package/dist/views/kept.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { deriveMutations } from "../mutations/derive-edits.js";
|
|
2
|
+
import { relationActName } from "../mutations/derived-names.js";
|
|
2
3
|
import { withArticle } from "../schema/define-node.js";
|
|
3
4
|
import { CONNECTION_TAG, GOOGLE_COLORS } from "../sync/connection-filter.js";
|
|
5
|
+
import { creatingActFor } from "../sync/creating-act.js";
|
|
6
|
+
import { NOTION_FITS, NOTION_INFERABLE, NOTION_READ_ONLY, NOTION_SECRET, notionFits } from "../sync/notion-types.js";
|
|
4
7
|
import { error, warning } from "./findings.js";
|
|
5
8
|
import { ConnectionSpec } from "./connection-spec.js";
|
|
6
9
|
/*
|
|
7
10
|
* A DECLARED CONNECTION, JUDGED (`connections.<name>`): what its shape
|
|
8
11
|
* cannot say — that the kind and its fields are this document's and of the
|
|
9
|
-
* types a calendar event's parts
|
|
10
|
-
*
|
|
12
|
+
* types a calendar event's parts or a Notion database's properties are,
|
|
13
|
+
* that a filter is one color Google names or one tag, that no secret is
|
|
14
|
+
* written in it, and, given the compiled app, that the acts an inbound
|
|
11
15
|
* change lands through are there. Each is a sentence `graview check` says
|
|
12
16
|
* at the place it is wrong.
|
|
13
17
|
*/
|
|
@@ -18,31 +22,64 @@ export function connectionFindings(document, app) {
|
|
|
18
22
|
const findings = [];
|
|
19
23
|
for (const [name, raw] of Object.entries(document.connections ?? {})) {
|
|
20
24
|
const at = `connections.${name}`;
|
|
25
|
+
// A secret written into the declaration is refused before anything else is said of it, and never repeated.
|
|
26
|
+
const secret = secretIn(raw, at);
|
|
27
|
+
if (secret) {
|
|
28
|
+
findings.push(error("connection-secret", secret, "this is an integration's secret, and a secret is never written in the app: it would travel with every copy and export of it", 'keep it in the host\'s environment (NOTION_TOKEN, or the variable "auth": { "env" } names) and take it out of here'));
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
21
31
|
// The shape first, said as the compiler says a document's: a connection that is not one is judged no further.
|
|
22
32
|
const parsed = ConnectionSpec.safeParse(raw);
|
|
23
33
|
if (!parsed.success) {
|
|
24
|
-
findings.push(...parsed.error.issues.map((issue) => shapeFinding(at, issue)));
|
|
34
|
+
findings.push(...parsed.error.issues.map((issue) => shapeFinding(at, raw, issue)));
|
|
25
35
|
continue;
|
|
26
36
|
}
|
|
27
|
-
|
|
37
|
+
const connection = parsed.data;
|
|
38
|
+
findings.push(...(connection.system === "notion" ? notionConnection(at, connection, document, app) : googleConnection(at, connection, document, app)));
|
|
28
39
|
}
|
|
29
40
|
return findings;
|
|
30
41
|
}
|
|
42
|
+
/** Where in a connection a string reads as a Notion integration's secret, if anywhere. */
|
|
43
|
+
function secretIn(value, at) {
|
|
44
|
+
if (typeof value === "string")
|
|
45
|
+
return NOTION_SECRET.test(value) ? at : undefined;
|
|
46
|
+
if (!value || typeof value !== "object")
|
|
47
|
+
return undefined;
|
|
48
|
+
for (const [key, inner] of Object.entries(value)) {
|
|
49
|
+
if (NOTION_SECRET.test(key))
|
|
50
|
+
return at;
|
|
51
|
+
const found = secretIn(inner, `${at}.${key}`);
|
|
52
|
+
if (found)
|
|
53
|
+
return found;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
const KEYS = {
|
|
58
|
+
"google-calendar": "system, calendar, auth, kind, fields, filter, direction, conflicts, every, paused and description",
|
|
59
|
+
notion: "system, database, source, auth, kind, properties, direction, conflicts, every, paused and description",
|
|
60
|
+
};
|
|
31
61
|
/** A shape the connection does not have, at its place: an unknown key, or a value of the wrong kind. */
|
|
32
|
-
function shapeFinding(at, issue) {
|
|
62
|
+
function shapeFinding(at, raw, issue) {
|
|
33
63
|
const path = [at, ...issue.path.map(String)].join(".");
|
|
34
64
|
if (issue.code === "unrecognized_keys" && issue.keys) {
|
|
35
|
-
|
|
65
|
+
const system = String(raw?.system ?? "");
|
|
66
|
+
return error("unknown-key", path, `${issue.keys.map((key) => `"${key}"`).join(", ")} ${issue.keys.length === 1 ? "is" : "are"} not part of a${system === "notion" ? " Notion" : system === "google-calendar" ? " Google calendar" : ""} connection`, `a connection says ${KEYS[system] ?? KEYS["google-calendar"]}`);
|
|
67
|
+
}
|
|
68
|
+
// A system that is none of them is said at `system`, as every other wrong value is said at its key.
|
|
69
|
+
if (issue.code === "invalid_union" && issue.path.length === 0 && issue.note === "No matching discriminator") {
|
|
70
|
+
return error("shape", `${at}.system`, issue.message);
|
|
36
71
|
}
|
|
37
72
|
return error("shape", path, issue.message);
|
|
38
73
|
}
|
|
39
|
-
|
|
74
|
+
/** No such kind, said once for the connection. */
|
|
75
|
+
function noKind(at, document, kind, what) {
|
|
76
|
+
return error("connection-kind", `${at}.kind`, `there is no kind called ${kind} for ${what} to be`, `name one of ${Object.keys(document.kinds).join(", ")}`);
|
|
77
|
+
}
|
|
78
|
+
function googleConnection(at, connection, document, app) {
|
|
40
79
|
const findings = [];
|
|
41
80
|
const kind = document.kinds[connection.kind];
|
|
42
|
-
if (!kind)
|
|
43
|
-
|
|
44
|
-
return [error("connection-kind", `${at}.kind`, `there is no kind called ${connection.kind} for the calendar's events to be`, `name one of ${kinds.join(", ")}`)];
|
|
45
|
-
}
|
|
81
|
+
if (!kind)
|
|
82
|
+
return [noKind(at, document, connection.kind, "the calendar's events")];
|
|
46
83
|
const typeOf = (field) => kind.fields[field]?.type;
|
|
47
84
|
const mapped = Object.entries(connection.fields).filter((entry) => typeof entry[1] === "string");
|
|
48
85
|
const seen = new Map();
|
|
@@ -87,24 +124,151 @@ function oneConnection(at, connection, document, app) {
|
|
|
87
124
|
if (filter.keep !== undefined && !filter.tag)
|
|
88
125
|
findings.push(error("connection-filter", `${at}.filter.keep`, "keep says whether a title keeps its tag, and the filter has no tag", "drop keep, or add a tag"));
|
|
89
126
|
}
|
|
90
|
-
if (app)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
127
|
+
if (app)
|
|
128
|
+
findings.push(...landing(at, connection.kind, mapped.map(([, ours]) => ours).filter((ours) => kind.fields[ours]), { made: "an event made in the calendar", fields: "the event's fields", change: "a change in the calendar", deleted: "an event deleted in the calendar" }, app));
|
|
129
|
+
return findings;
|
|
130
|
+
}
|
|
131
|
+
function notionConnection(at, connection, document, app) {
|
|
132
|
+
const findings = [];
|
|
133
|
+
const kind = document.kinds[connection.kind];
|
|
134
|
+
if (!kind)
|
|
135
|
+
return [noKind(at, document, connection.kind, "the database's pages")];
|
|
136
|
+
let mapped;
|
|
137
|
+
const relations = [];
|
|
138
|
+
if (connection.properties) {
|
|
139
|
+
mapped = [];
|
|
140
|
+
const seen = new Map();
|
|
141
|
+
const edges = kind.edges ?? {};
|
|
142
|
+
for (const [field, property] of Object.entries(connection.properties)) {
|
|
143
|
+
const path = `${at}.properties.${field}`;
|
|
144
|
+
const name = typeof property === "string" ? property : property.name;
|
|
145
|
+
const declared = typeof property === "string" ? undefined : property.type;
|
|
146
|
+
if (!kind.fields[field] && !edges[field]) {
|
|
147
|
+
const names = [...Object.keys(kind.fields), ...Object.keys(edges)];
|
|
148
|
+
findings.push(error("connection-field", path, `${connection.kind} has no field or relation called ${field} to hold the property ${name}`, `name one of ${names.join(", ")}`));
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const twice = seen.get(name);
|
|
152
|
+
if (twice)
|
|
153
|
+
findings.push(error("connection-field", path, `the property ${name} is already held by ${twice}, and one property is held by one field or relation`, "give each property a field or relation of its own"));
|
|
154
|
+
seen.set(name, field);
|
|
155
|
+
if (!kind.fields[field]) {
|
|
156
|
+
// One of the kind's relations, held by a relation property: its pages are records another Notion connection keeps.
|
|
157
|
+
if (declared && declared !== "relation") {
|
|
158
|
+
findings.push(error("connection-relation", path, `${field} is a relation of ${connection.kind}, and the property ${name} is a ${declared}: a relation is held by a relation property, the pages it links`, `name a relation property, or map a field of ${connection.kind} to ${name}`));
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const problem = relationTarget(connection.kind, field, edges[field].to, document);
|
|
162
|
+
if (problem) {
|
|
163
|
+
findings.push(error("connection-relation-target", path, problem.message, problem.fix));
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
relations.push(field);
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (declared === "relation") {
|
|
170
|
+
findings.push(error("connection-relation", path, `the property ${name} is a relation, the pages it links, and ${field} is a field of ${connection.kind}, which holds one value`, `declare a relation of ${connection.kind} to the kind those pages are, and map it to ${name}`));
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
mapped.push(field);
|
|
174
|
+
const type = kind.fields[field].type;
|
|
175
|
+
if (typeof property === "string") {
|
|
176
|
+
if (!NOTION_INFERABLE.has(type))
|
|
177
|
+
findings.push(error("connection-field-type", path, `${field} is a ${type} field, and no Notion property a connection keeps in step is held in one`, `name a field of another type, or leave ${field} out`));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (!notionFits(property.type, type)) {
|
|
181
|
+
findings.push(error("connection-field-type", path, `the property ${name} is a ${property.type}, and ${field} is a ${type} field`, `name a ${NOTION_FITS[property.type].join(", ")} field`));
|
|
182
|
+
}
|
|
183
|
+
else if (NOTION_READ_ONLY.has(property.type) && connection.direction === "both") {
|
|
184
|
+
findings.push(warning("connection-read-only", path, `${name} is a people property, which is read from Notion and never written: a change to ${field} here stays here`));
|
|
185
|
+
}
|
|
97
186
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const unwritten = mapped.map(([, ours]) => ours).filter((ours) => kind.fields[ours] && !writes.has(ours));
|
|
101
|
-
if (unwritten.length > 0) {
|
|
102
|
-
findings.push(error("connection-edit", `${at}.fields`, `a change in the calendar lands through edit-${connection.kind}, which does not write ${unwritten.join(", ")}: another act declares ${unwritten.length === 1 ? "it" : "them"}`, `let edit-${connection.kind} write ${unwritten.length === 1 ? "it" : "them"} (drop "writes" of ${unwritten.length === 1 ? "it" : "them"} from the other act), or leave ${unwritten.length === 1 ? "it" : "them"} out of the connection`));
|
|
187
|
+
if (mapped.length === 0 && Object.keys(connection.properties).length === 0) {
|
|
188
|
+
findings.push(error("connection-properties", `${at}.properties`, "the connection maps no property, so nothing would be kept in step", "map a field to a property, or drop properties to match them by name"));
|
|
103
189
|
}
|
|
104
|
-
|
|
105
|
-
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
mapped = Object.entries(kind.fields).filter(([, spec]) => NOTION_INFERABLE.has(spec.type)).map(([field]) => field);
|
|
193
|
+
if (mapped.length === 0)
|
|
194
|
+
findings.push(error("connection-properties", `${at}.kind`, `${connection.kind} has no field a Notion property could be held in`, "give it a string, number, date, enum, list or boolean field"));
|
|
195
|
+
}
|
|
196
|
+
if (app && mapped.length > 0)
|
|
197
|
+
findings.push(...landing(at, connection.kind, mapped, { made: "a page made in the database", fields: "the page's fields", change: "a change in Notion", deleted: "a page archived in Notion" }, app));
|
|
198
|
+
if (app)
|
|
199
|
+
findings.push(...linking(at, connection.kind, relations, document, app));
|
|
200
|
+
return findings;
|
|
201
|
+
}
|
|
202
|
+
/** Why a relation cannot be kept in step: what it reaches is no kind a Notion connection of this app keeps. */
|
|
203
|
+
function relationTarget(kindName, relation, to, document) {
|
|
204
|
+
const kept = new Set(Object.values(document.connections ?? {})
|
|
205
|
+
.map((raw) => raw)
|
|
206
|
+
.filter((raw) => raw.system === "notion" && typeof raw.kind === "string")
|
|
207
|
+
.map((raw) => String(raw.kind)));
|
|
208
|
+
const keptBy = kept.size > 0 ? `the Notion connections here keep ${[...kept].join(", ")}` : "no other Notion connection is declared";
|
|
209
|
+
if (to === "*")
|
|
210
|
+
return { message: `${kindName}'s ${relation} reaches any kind, and a Notion relation links the pages of one database`, fix: `say the kind it reaches with "to", and keep that kind with a Notion connection of its own` };
|
|
211
|
+
const outside = to.filter((target) => !kept.has(target));
|
|
212
|
+
if (outside.length === 0)
|
|
213
|
+
return undefined;
|
|
214
|
+
return {
|
|
215
|
+
message: `${kindName}'s ${relation} reaches ${outside.join(" and ")}, which no Notion connection of this app keeps, so a page it links would have no record here (${keptBy})`,
|
|
216
|
+
fix: `declare a Notion connection for ${outside.join(" and ")}'s database, or leave ${relation} out of properties`,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/** That the acts a link made or taken away in Notion lands through are there: `connect-<kind>-<relation>` and `disconnect-<kind>-<relation>`. */
|
|
220
|
+
function linking(at, kindName, relations, document, app) {
|
|
221
|
+
if (relations.length === 0)
|
|
222
|
+
return [];
|
|
223
|
+
const findings = [];
|
|
224
|
+
const declared = app.mutations ?? [];
|
|
225
|
+
const acts = new Set([...declared, ...deriveMutations(app.schema, declared)].map((mutation) => mutation.name));
|
|
226
|
+
for (const relation of relations) {
|
|
227
|
+
const path = `${at}.properties.${relation}`;
|
|
228
|
+
const connect = relationActName("connect", kindName, relation);
|
|
229
|
+
const disconnect = relationActName("disconnect", kindName, relation);
|
|
230
|
+
if (!acts.has(connect)) {
|
|
231
|
+
findings.push(error("connection-connect", path, `a link made in Notion lands through ${connect}, and this app has no such act: the relation declares no acts, or an act of its own replaces it`, `let ${kindName}'s ${relation} be given its derived acts, or leave ${relation} out of properties`));
|
|
232
|
+
}
|
|
233
|
+
else if (!acts.has(disconnect)) {
|
|
234
|
+
const appendOnly = document.kinds[kindName]?.edges?.[relation]?.appendOnly === true;
|
|
235
|
+
findings.push(warning("connection-disconnect", path, `no act takes ${kindName}'s ${relation} away${appendOnly ? " (it is append-only)" : ""}, so a link taken away in Notion stays here`));
|
|
106
236
|
}
|
|
107
237
|
}
|
|
108
238
|
return findings;
|
|
109
239
|
}
|
|
240
|
+
/** That the acts an inbound change lands through are there: one that makes the kind from the mapped fields alone, `edit-<kind>` writing every mapped field, `remove-<kind>`. */
|
|
241
|
+
function landing(at, kindName, fields, said, app) {
|
|
242
|
+
const findings = [];
|
|
243
|
+
// The acts the store will hold: the declared ones and those derived from them (`edit-<kind>`, `remove-<kind>`).
|
|
244
|
+
const declared = app.mutations ?? [];
|
|
245
|
+
const acts = new Map([...declared, ...deriveMutations(app.schema, declared)].map((mutation) => [mutation.name, mutation]));
|
|
246
|
+
// The act a record is made through takes no subject and asks only for what the connection maps (`creatingActFor`), as the connection chooses it.
|
|
247
|
+
const making = creatingActFor(declared, kindName, fields);
|
|
248
|
+
if (!making.creates) {
|
|
249
|
+
findings.push(error("connection-creates", `${at}.kind`, `no act makes ${withArticle(kindName)}, so ${said.made} has nothing to become here`, `declare an act with "creates": "${kindName}"`));
|
|
250
|
+
}
|
|
251
|
+
else if (!making.act) {
|
|
252
|
+
const why = making.unfit.map((act) => act.on ? `${act.name} acts on ${act.on.length > 0 ? act.on.map(withArticle).join(" or ") : "a record"}` : `${act.name} asks for ${act.asks.join(", ")}, which the connection does not map`);
|
|
253
|
+
findings.push(error("connection-creates", `${at}.kind`, `${said.made} becomes ${withArticle(kindName)} through an act that makes one from ${said.fields} alone, and ${why.join("; ")}`, `declare an act with "creates": "${kindName}" and no "on", whose required arguments are fields the connection maps (add-${kindName} is the one looked for first)`));
|
|
254
|
+
}
|
|
255
|
+
const edit = acts.get(`edit-${kindName}`);
|
|
256
|
+
const writes = new Set(edit?.writes ?? []);
|
|
257
|
+
const unwritten = fields.filter((field) => !writes.has(field));
|
|
258
|
+
if (unwritten.length > 0) {
|
|
259
|
+
const them = unwritten.length === 1 ? "it" : "them";
|
|
260
|
+
// The derived edit writes every field a connection maps (`keptInStep`), so what it leaves out is fixed, or the app declares its own edit.
|
|
261
|
+
const own = edit !== undefined && !edit.derived;
|
|
262
|
+
const fixed = unwritten.filter((field) => field in (app.schema.tryDefinition(kindName)?.fixed ?? {}));
|
|
263
|
+
findings.push(error("connection-edit", `${at}.${said.change.includes("calendar") ? "fields" : "properties"}`, own
|
|
264
|
+
? `${said.change} lands through edit-${kindName}, which does not write ${unwritten.join(", ")}: the app declares its own edit-${kindName}`
|
|
265
|
+
: `${said.change} lands through edit-${kindName}, which does not write ${unwritten.join(", ")}: ${fixed.length > 0 ? `${fixed.join(", ")} ${fixed.length === 1 ? "is" : "are"} fixed` : `no edit-${kindName} is there`}`, own
|
|
266
|
+
? `let edit-${kindName} write ${them}, or take it out so the derived edit, which writes every field a connection maps, is given, or leave ${them} out of the connection`
|
|
267
|
+
: `leave ${them} out of the connection, or let ${them} change`));
|
|
268
|
+
}
|
|
269
|
+
if (!acts.has(`remove-${kindName}`)) {
|
|
270
|
+
findings.push(warning("connection-remove", `${at}.kind`, `no act removes ${withArticle(kindName)}, so ${said.deleted} stays here, no longer kept in step`));
|
|
271
|
+
}
|
|
272
|
+
return findings;
|
|
273
|
+
}
|
|
110
274
|
//# sourceMappingURL=connection-findings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-findings.js","sourceRoot":"","sources":["../../src/document/connection-findings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,OAAO,EAAgB,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD;;;;;;;GAOG;AAEH,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACzC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAE3C,sEAAsE;AACtE,MAAM,UAAU,kBAAkB,CAAC,QAAyB,EAAE,GAAgB;IAC5E,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,CAAC;QACrE,MAAM,EAAE,GAAG,eAAe,IAAI,EAAE,CAAC;QACjC,8GAA8G;QAC9G,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,QAAQ,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,YAAY,CAA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,CAAC,QAAQ,IAAI,CAAC,OAAO,qCAAqC,CAAC,CAAC,CAAC;IAC9J,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import * as z from "../schema/zod.js";
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* A CONNECTION: the app kept in step with another system, declared rather
|
|
4
|
+
* than wired in code (`connections.<name>`) — a Google calendar or a Notion
|
|
5
|
+
* database. It never holds a secret.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ConnectionSpec: z.ZodMiniLazy<z.ZodMiniDiscriminatedUnion<[z.ZodMiniObject<{
|
|
3
8
|
system: z.ZodMiniLiteral<"google-calendar">;
|
|
4
9
|
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
5
10
|
calendar: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
@@ -33,6 +38,41 @@ export declare const ConnectionSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
33
38
|
}>>;
|
|
34
39
|
every: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
35
40
|
paused: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
36
|
-
}, z.core.$strict
|
|
41
|
+
}, z.core.$strict>, z.ZodMiniObject<{
|
|
42
|
+
system: z.ZodMiniLiteral<"notion">;
|
|
43
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
|
+
database: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
45
|
+
env: z.ZodMiniString<string>;
|
|
46
|
+
}, z.core.$strict>]>;
|
|
47
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
48
|
+
auth: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
49
|
+
env: z.ZodMiniString<string>;
|
|
50
|
+
file: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
51
|
+
}, z.core.$strict>>;
|
|
52
|
+
kind: z.ZodMiniString<string>;
|
|
53
|
+
properties: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniObject<{
|
|
54
|
+
name: z.ZodMiniString<string>;
|
|
55
|
+
type: z.ZodMiniEnum<{
|
|
56
|
+
[x: string]: string;
|
|
57
|
+
}>;
|
|
58
|
+
}, z.core.$strict>]>>>;
|
|
59
|
+
direction: z.ZodMiniEnum<{
|
|
60
|
+
read: "read";
|
|
61
|
+
both: "both";
|
|
62
|
+
}>;
|
|
63
|
+
conflicts: z.ZodMiniOptional<z.ZodMiniEnum<{
|
|
64
|
+
report: "report";
|
|
65
|
+
theirs: "theirs";
|
|
66
|
+
ours: "ours";
|
|
67
|
+
}>>;
|
|
68
|
+
every: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
69
|
+
paused: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
70
|
+
}, z.core.$strict>], "system">>;
|
|
37
71
|
export type ConnectionSpec = z.infer<typeof ConnectionSpec>;
|
|
72
|
+
export type GoogleCalendarConnectionSpec = Extract<ConnectionSpec, {
|
|
73
|
+
system: "google-calendar";
|
|
74
|
+
}>;
|
|
75
|
+
export type NotionConnectionSpec = Extract<ConnectionSpec, {
|
|
76
|
+
system: "notion";
|
|
77
|
+
}>;
|
|
38
78
|
//# sourceMappingURL=connection-spec.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-spec.d.ts","sourceRoot":"","sources":["../../src/document/connection-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"connection-spec.d.ts","sourceRoot":"","sources":["../../src/document/connection-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AA6FtC;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAAoC,CAAC;AAChE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC5D,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,MAAM,EAAE,iBAAiB,CAAA;CAAE,CAAC,CAAC;AAClG,MAAM,MAAM,oBAAoB,GAAG,OAAO,CAAC,cAAc,EAAE;IAAE,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as z from "../schema/zod.js";
|
|
2
|
-
import {
|
|
2
|
+
import { NOTION_FITS, NOTION_ID } from "../sync/notion-types.js";
|
|
3
|
+
import { EDGE_NAME, FIELD_NAME, NAME } from "./schema.js";
|
|
3
4
|
/*
|
|
4
5
|
* A CONNECTION'S SHAPE, apart from the document's: a page that draws an app
|
|
5
6
|
* reads `connections` loosely and never runs one, so this is reached only by
|
|
@@ -12,38 +13,82 @@ function build() {
|
|
|
12
13
|
const sentence = str(1, 500);
|
|
13
14
|
const kindName = z.string().check(z.regex(NAME, 'kind names are kebab-case, lower-case words joined by hyphens like "tool-note"'));
|
|
14
15
|
const fieldName = z.string().check(z.regex(FIELD_NAME, 'field names are one word or camelCase, like "dueDate"'));
|
|
16
|
+
const envName = z.string().check(z.regex(/^[A-Z][A-Z0-9_]*$/, 'an environment variable is upper-case words joined by underscores, like "GOOGLE"'));
|
|
17
|
+
/* Where the credentials are read from: environment variables under `env`, failing that the KEY=value file `file` names. */
|
|
18
|
+
const auth = z.optional(z.strictObject({ env: envName, file: z.optional(str(1, 500)) }));
|
|
19
|
+
/* "read": the other system owns these records and acts here that would change them are refused. "both": changes go both ways. */
|
|
20
|
+
const direction = z.enum(["read", "both"], 'a connection\'s direction is "read" (the other system owns these records) or "both"');
|
|
21
|
+
const conflicts = z.optional(z.enum(["report", "theirs", "ours"], 'a conflict is held for somebody ("report"), or settled for the other system ("theirs") or for this app ("ours")'));
|
|
22
|
+
/* Seconds between passes; a change made here starts one sooner. */
|
|
23
|
+
const every = z.optional(z.number().check(z.int(), z.minimum(2), z.maximum(86_400)));
|
|
15
24
|
/**
|
|
16
|
-
* A
|
|
17
|
-
* than wired in code (`connections.<name>`). Today the one system is a
|
|
18
|
-
* Google calendar: which calendar, which kind its events are and which
|
|
25
|
+
* A GOOGLE CALENDAR: which calendar, which kind its events are and which
|
|
19
26
|
* fields say what, which of its events (all of them, one color, or those
|
|
20
|
-
* whose title carries a tag)
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* the
|
|
24
|
-
* `<env>_REFRESH_TOKEN`), unless the host hands a token itself.
|
|
27
|
+
* whose title carries a tag). The calendar may be named by an environment
|
|
28
|
+
* variable, and `auth` says where the credentials are read from
|
|
29
|
+
* (`<env>_CLIENT_ID`, `<env>_CLIENT_SECRET`, `<env>_REFRESH_TOKEN`; GOOGLE
|
|
30
|
+
* by default), unless the host hands a token itself.
|
|
25
31
|
*/
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
system: z.literal("google-calendar", 'the one system a connection reaches today is "google-calendar"'),
|
|
32
|
+
const GoogleCalendar = z.strictObject({
|
|
33
|
+
system: z.literal("google-calendar"),
|
|
29
34
|
description: z.optional(sentence),
|
|
30
35
|
/* The calendar's id ("primary", or "…@group.calendar.google.com"), or the environment variable that holds it. */
|
|
31
36
|
calendar: z.union([str(1, 300), z.strictObject({ env: envName })]),
|
|
32
|
-
auth
|
|
37
|
+
auth,
|
|
33
38
|
kind: kindName,
|
|
34
39
|
/* Google's side → this kind's field. A date field is an all-day event's day; a datetime field, a timed event's instant. */
|
|
35
40
|
fields: z.strictObject({ summary: fieldName, start: fieldName, end: fieldName, location: z.optional(fieldName), description: z.optional(fieldName) }),
|
|
36
41
|
/* Absent: the whole calendar. `{ color }`: the events of one of Google's colors, by name. `{ tag }`: those whose title carries a word like "#graview", kept in the title here or not (`keep`). */
|
|
37
42
|
filter: z.optional(z.strictObject({ color: z.optional(str(1, 40)), tag: z.optional(str(1, 40)), keep: z.optional(z.boolean()) })),
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/* Seconds between passes; a change made here starts one sooner. */
|
|
42
|
-
every: z.optional(z.number().check(z.int(), z.minimum(2), z.maximum(86_400))),
|
|
43
|
+
direction,
|
|
44
|
+
conflicts,
|
|
45
|
+
every,
|
|
43
46
|
paused: z.optional(z.boolean()),
|
|
44
47
|
});
|
|
45
|
-
|
|
48
|
+
/**
|
|
49
|
+
* A NOTION DATABASE: one database, each of its pages a record of one kind.
|
|
50
|
+
* The database is named by its id or by an environment variable; the
|
|
51
|
+
* internal integration's secret is read from `<env>_TOKEN` (NOTION_TOKEN by
|
|
52
|
+
* default) or handed by the host, never written here. `properties` maps a
|
|
53
|
+
* field to a property by name, with the property's type when the checker
|
|
54
|
+
* should judge it; absent, every field whose name a property has is kept
|
|
55
|
+
* in step, and the kind's name field is the database's title. A database
|
|
56
|
+
* that holds several data sources (Notion's tables under one name) says
|
|
57
|
+
* which with `source`, its name or id; one of a single source needs none.
|
|
58
|
+
*
|
|
59
|
+
* A key of `properties` may name one of the kind's RELATIONS (edges) in
|
|
60
|
+
* place of a field, held by a Notion relation property: its links are the
|
|
61
|
+
* pages the property reaches, each a record another Notion connection of
|
|
62
|
+
* the app keeps (`"reindeer": "Reindeer Fleet"`, or with
|
|
63
|
+
* `"type": "relation"`). Matched by name, a relation whose name a
|
|
64
|
+
* relation property has is kept too.
|
|
65
|
+
*/
|
|
66
|
+
const notionTypes = [...Object.keys(NOTION_FITS), "relation"];
|
|
67
|
+
const keptName = z.string().check(z.regex(EDGE_NAME, 'a key of properties is one of the kind\'s fields or relations, like "dueDate" or "reindeer"'));
|
|
68
|
+
const notionType = z.enum(notionTypes, `a property's type is one a connection keeps in step: ${notionTypes.join(", ")}`);
|
|
69
|
+
const Notion = z.strictObject({
|
|
70
|
+
system: z.literal("notion"),
|
|
71
|
+
description: z.optional(sentence),
|
|
72
|
+
/* The database's id (the 32 characters in its link, before ?v=), or the environment variable that holds it. */
|
|
73
|
+
database: z.union([z.string().check(z.regex(NOTION_ID, "a Notion database's id is the 32 characters in its link, before ?v=")), z.strictObject({ env: envName })]),
|
|
74
|
+
/* The data source, by its name in Notion or its id, when the database holds several. */
|
|
75
|
+
source: z.optional(str(1, 200)),
|
|
76
|
+
auth,
|
|
77
|
+
kind: kindName,
|
|
78
|
+
/* This kind's field or relation → the database's property, by its name in Notion, or `{ name, type }` with its type. */
|
|
79
|
+
properties: z.optional(z.record(keptName, z.union([str(1, 100), z.strictObject({ name: str(1, 100), type: notionType })]))),
|
|
80
|
+
direction,
|
|
81
|
+
conflicts,
|
|
82
|
+
every,
|
|
83
|
+
paused: z.optional(z.boolean()),
|
|
84
|
+
});
|
|
85
|
+
return z.discriminatedUnion("system", [GoogleCalendar, Notion], 'a connection\'s system is "google-calendar" or "notion"');
|
|
46
86
|
}
|
|
47
87
|
let built;
|
|
88
|
+
/**
|
|
89
|
+
* A CONNECTION: the app kept in step with another system, declared rather
|
|
90
|
+
* than wired in code (`connections.<name>`) — a Google calendar or a Notion
|
|
91
|
+
* database. It never holds a secret.
|
|
92
|
+
*/
|
|
48
93
|
export const ConnectionSpec = z.lazy(() => (built ??= build()));
|
|
49
94
|
//# sourceMappingURL=connection-spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection-spec.js","sourceRoot":"","sources":["../../src/document/connection-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"connection-spec.js","sourceRoot":"","sources":["../../src/document/connection-spec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,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C,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3H,SAAS;QACT,SAAS;QACT,KAAK;QACL,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;KAChC,CAAC,CAAC;IAEH,OAAO,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,EAAE,yDAAyD,CAAC,CAAC;AAC7H,CAAC;AACD,IAAI,KAA2C,CAAC;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,KAAK,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Kind → the fields of it a declared connection maps, in the kind's own order. */
|
|
2
|
+
export declare function fieldsKeptInStep(connections: unknown, kinds: Readonly<Record<string, {
|
|
3
|
+
readonly fields: Readonly<Record<string, {
|
|
4
|
+
readonly type: string;
|
|
5
|
+
}>>;
|
|
6
|
+
}>>): ReadonlyMap<string, readonly string[]>;
|
|
7
|
+
//# sourceMappingURL=kept-in-step.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kept-in-step.d.ts","sourceRoot":"","sources":["../../src/document/kept-in-step.ts"],"names":[],"mappings":"AAcA,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,CAAA;CAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAkBxM"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { NOTION_INFERABLE } from "../sync/notion-types.js";
|
|
2
|
+
/** Kind → the fields of it a declared connection maps, in the kind's own order. */
|
|
3
|
+
export function fieldsKeptInStep(connections, kinds) {
|
|
4
|
+
const kept = new Map();
|
|
5
|
+
if (!connections || typeof connections !== "object")
|
|
6
|
+
return new Map();
|
|
7
|
+
for (const raw of Object.values(connections)) {
|
|
8
|
+
if (!raw || typeof raw !== "object" || typeof raw.kind !== "string")
|
|
9
|
+
continue;
|
|
10
|
+
const fields = kinds[raw.kind]?.fields;
|
|
11
|
+
if (!fields)
|
|
12
|
+
continue;
|
|
13
|
+
let mapped = [];
|
|
14
|
+
if (raw.system === "google-calendar" && raw.fields && typeof raw.fields === "object") {
|
|
15
|
+
mapped = Object.values(raw.fields).filter((field) => typeof field === "string");
|
|
16
|
+
}
|
|
17
|
+
else if (raw.system === "notion") {
|
|
18
|
+
mapped = raw.properties && typeof raw.properties === "object" ? Object.keys(raw.properties) : Object.keys(fields).filter((field) => NOTION_INFERABLE.has(fields[field].type));
|
|
19
|
+
}
|
|
20
|
+
const set = kept.get(raw.kind) ?? new Set();
|
|
21
|
+
for (const field of mapped)
|
|
22
|
+
if (Object.hasOwn(fields, field))
|
|
23
|
+
set.add(field);
|
|
24
|
+
kept.set(raw.kind, set);
|
|
25
|
+
}
|
|
26
|
+
return new Map([...kept].filter(([, set]) => set.size > 0).map(([kind, set]) => [kind, Object.keys(kinds[kind].fields).filter((field) => set.has(field))]));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=kept-in-step.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kept-in-step.js","sourceRoot":"","sources":["../../src/document/kept-in-step.ts"],"names":[],"mappings":"AAAA,OAA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AAK,CAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACjL,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,GAAG,EAAU,CAAC;QACpD,KAAK,MAAM,KAAK,IAAI,MAAM;YAAE,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC;gBAAE,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC7E,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/J,CAAC"}
|
|
@@ -39,10 +39,10 @@ export declare const FieldSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
39
39
|
duration: "duration";
|
|
40
40
|
text: "text";
|
|
41
41
|
list: "list";
|
|
42
|
+
phone: "phone";
|
|
42
43
|
image: "image";
|
|
43
44
|
video: "video";
|
|
44
45
|
"app-link": "app-link";
|
|
45
|
-
phone: "phone";
|
|
46
46
|
place: "place";
|
|
47
47
|
}>;
|
|
48
48
|
required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
@@ -118,10 +118,10 @@ export declare const KindSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
118
118
|
duration: "duration";
|
|
119
119
|
text: "text";
|
|
120
120
|
list: "list";
|
|
121
|
+
phone: "phone";
|
|
121
122
|
image: "image";
|
|
122
123
|
video: "video";
|
|
123
124
|
"app-link": "app-link";
|
|
124
|
-
phone: "phone";
|
|
125
125
|
place: "place";
|
|
126
126
|
}>;
|
|
127
127
|
required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
@@ -258,10 +258,10 @@ export declare const ActSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
258
258
|
duration: "duration";
|
|
259
259
|
text: "text";
|
|
260
260
|
list: "list";
|
|
261
|
+
phone: "phone";
|
|
261
262
|
image: "image";
|
|
262
263
|
video: "video";
|
|
263
264
|
"app-link": "app-link";
|
|
264
|
-
phone: "phone";
|
|
265
265
|
place: "place";
|
|
266
266
|
}>;
|
|
267
267
|
required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
@@ -472,10 +472,10 @@ export declare const DocumentSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
472
472
|
duration: "duration";
|
|
473
473
|
text: "text";
|
|
474
474
|
list: "list";
|
|
475
|
+
phone: "phone";
|
|
475
476
|
image: "image";
|
|
476
477
|
video: "video";
|
|
477
478
|
"app-link": "app-link";
|
|
478
|
-
phone: "phone";
|
|
479
479
|
place: "place";
|
|
480
480
|
}>;
|
|
481
481
|
required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
@@ -599,10 +599,10 @@ export declare const DocumentSpec: z.ZodMiniLazy<z.ZodMiniObject<{
|
|
|
599
599
|
duration: "duration";
|
|
600
600
|
text: "text";
|
|
601
601
|
list: "list";
|
|
602
|
+
phone: "phone";
|
|
602
603
|
image: "image";
|
|
603
604
|
video: "video";
|
|
604
605
|
"app-link": "app-link";
|
|
605
|
-
phone: "phone";
|
|
606
606
|
place: "place";
|
|
607
607
|
}>;
|
|
608
608
|
required: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|