@wirecat/notion-cli 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +69 -0
- package/README.md +14 -4
- package/contracts/wirecat.json +698 -1
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/{all-profiles-OETMCOLN.js → all-profiles-4IONYZB6.js} +10 -10
- package/dist/bundle/{anthropic-5Y3O2TYM.js → anthropic-OXF74J4P.js} +6 -6
- package/dist/bundle/{app-server-IVWBIVHC.js → app-server-M2VF6ABM.js} +61 -52
- package/dist/bundle/{bun-EO636SAD.js → bun-DLA6QRLL.js} +2 -2
- package/dist/bundle/{bun-sqlite-C2T7QJ2M.js → bun-sqlite-F4BYLW3F.js} +7 -7
- package/dist/bundle/{chunk-QBC23NHD.js → chunk-2MHMKNWD.js} +1 -1
- package/dist/bundle/{chunk-TSCIIXN3.js → chunk-4KUJTSHG.js} +2 -2
- package/dist/bundle/{chunk-24FAYAML.js → chunk-4TQVZXOV.js} +3 -3
- package/dist/bundle/{chunk-FF4DDBCB.js → chunk-5LBJNTEJ.js} +6 -6
- package/dist/bundle/chunk-5UA2TYMI.js +29 -0
- package/dist/bundle/{chunk-DIM5YWBU.js → chunk-5XP4KQ2F.js} +1 -1
- package/dist/bundle/{chunk-WM7663C2.js → chunk-6GN7KU7X.js} +9 -9
- package/dist/bundle/chunk-6JBLIQQN.js +16 -0
- package/dist/bundle/{chunk-CLG2ISQH.js → chunk-7NF3V5L2.js} +4 -4
- package/dist/bundle/{chunk-TR7R5DL4.js → chunk-7NGFGFE5.js} +12 -63
- package/dist/bundle/{chunk-YA4LSSDZ.js → chunk-7NVPM55S.js} +2913 -2371
- package/dist/bundle/{chunk-XC5CKHX2.js → chunk-7YZPBAQX.js} +1 -1
- package/dist/bundle/{chunk-RSIS7BR7.js → chunk-AYU5TFDU.js} +21 -21
- package/dist/bundle/{chunk-64D5VUZ4.js → chunk-BEPFGITI.js} +68 -64
- package/dist/bundle/{chunk-HRTIRRXR.js → chunk-CBGBFAYJ.js} +41 -6
- package/dist/bundle/{chunk-QC3KOJT4.js → chunk-CDGZZNGY.js} +6 -6
- package/dist/bundle/{chunk-JK44XO2S.js → chunk-CIVXTBJY.js} +56 -56
- package/dist/bundle/{chunk-OWJDC4CB.js → chunk-COH7OEER.js} +14 -13
- package/dist/bundle/{chunk-XL2HXHP3.js → chunk-D6RCRBDH.js} +2 -2
- package/dist/bundle/{chunk-47R43UVJ.js → chunk-EQPAZ33O.js} +19 -19
- package/dist/bundle/{chunk-AE2KQ37N.js → chunk-EY6S7FV3.js} +6 -6
- package/dist/bundle/chunk-FEMHUSGO.js +88 -0
- package/dist/bundle/{chunk-NLDYZBTC.js → chunk-FSJHASRQ.js} +1146 -2555
- package/dist/bundle/chunk-GBFEEHQC.js +385 -0
- package/dist/bundle/{chunk-IQWEJEB5.js → chunk-GCCPFKSU.js} +26264 -21086
- package/dist/bundle/{chunk-RDZ7SVBZ.js → chunk-GK4GLPG2.js} +3 -3
- package/dist/bundle/{chunk-B2XKEEFX.js → chunk-GSNE7OB4.js} +4 -4
- package/dist/bundle/{chunk-UWW24JQF.js → chunk-HTKSCSJU.js} +4 -4
- package/dist/bundle/{chunk-7FII4DCE.js → chunk-IJMFG7HB.js} +7 -7
- package/dist/bundle/{chunk-WVZFXI36.js → chunk-JIRRF6BM.js} +4 -4
- package/dist/bundle/{chunk-ST2UC7FS.js → chunk-JODE2XED.js} +31 -27
- package/dist/bundle/{chunk-CWVAYQXI.js → chunk-K5I64ZVI.js} +9 -9
- package/dist/bundle/chunk-KFVDL2QS.js +146 -0
- package/dist/bundle/{chunk-JKIN5TOU.js → chunk-KL3P5TQK.js} +4 -4
- package/dist/bundle/chunk-L62XTC7N.js +726 -0
- package/dist/bundle/chunk-L6H7PY4X.js +170 -0
- package/dist/bundle/{chunk-F6MLJ3V5.js → chunk-LIQMUDIZ.js} +2 -2
- package/dist/bundle/{chunk-HWRKURQH.js → chunk-M2EEIYBU.js} +2 -2
- package/dist/bundle/chunk-M6DGZ2O6.js +823 -0
- package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
- package/dist/bundle/{chunk-UWIA2G6Q.js → chunk-MRA62W5K.js} +404 -537
- package/dist/bundle/{chunk-XYIT2XB3.js → chunk-MVA5HVKL.js} +20 -0
- package/dist/bundle/{chunk-GA3URWIF.js → chunk-NO2LIHWA.js} +1 -1
- package/dist/bundle/{chunk-ESZT4WW3.js → chunk-OCDJ4FFA.js} +4 -4
- package/dist/bundle/{chunk-B4B65XIO.js → chunk-OI5DWZJG.js} +3 -3
- package/dist/bundle/chunk-P3P6DA6K.js +259 -0
- package/dist/bundle/chunk-QX3TPFEX.js +1977 -0
- package/dist/bundle/{chunk-EU5WCOMQ.js → chunk-R6SDRSZK.js} +76 -35
- package/dist/bundle/{chunk-K5TWMQSY.js → chunk-RMJMID5D.js} +8 -8
- package/dist/bundle/{chunk-RLSFOR2D.js → chunk-SGBS5QCU.js} +4 -4
- package/dist/bundle/{chunk-3D3PFXBP.js → chunk-T5UNSFES.js} +10 -15
- package/dist/bundle/{chunk-RAZKIHGH.js → chunk-TFNRCCGR.js} +4 -4
- package/dist/bundle/{chunk-WK3OSDNV.js → chunk-TJCPTRYD.js} +7 -7
- package/dist/bundle/{chunk-BWICUW7W.js → chunk-TXONV3HW.js} +2 -2
- package/dist/bundle/{chunk-AQZO3ITW.js → chunk-TZ2QJ53V.js} +2 -2
- package/dist/bundle/{chunk-35K5T6WV.js → chunk-UKE3CGHK.js} +1 -1
- package/dist/bundle/{chunk-7N5QB6NL.js → chunk-UROEWCOG.js} +5 -3
- package/dist/bundle/chunk-WHJWURZB.js +335 -0
- package/dist/bundle/{chunk-R6ZM45NF.js → chunk-WU3XHGOB.js} +185 -57
- package/dist/bundle/{chunk-2YR3RYT4.js → chunk-WZEEEQGC.js} +3 -3
- package/dist/bundle/{chunk-B2WFKFYL.js → chunk-XCTOCVMW.js} +20 -116
- package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
- package/dist/bundle/{chunk-EGTBL3MJ.js → chunk-Y5LAJWR5.js} +1 -1
- package/dist/bundle/{chunk-66PL7P4C.js → chunk-YAPDU3SV.js} +1 -1
- package/dist/bundle/{chunk-WWMB4UHF.js → chunk-YFWLHTNO.js} +1 -1
- package/dist/bundle/{chunk-KHOVVPLC.js → chunk-YGCI3DHS.js} +1 -1
- package/dist/bundle/{chunk-4GC5DBHW.js → chunk-Z53LYX4M.js} +3 -3
- package/dist/bundle/{chunk-EPAZ7DJB.js → chunk-ZC6ZQQ55.js} +48 -45
- package/dist/bundle/command-contract-UBXS6NHI.js +38 -0
- package/dist/bundle/{command-server-entry-A66DJ3MH.js → command-server-entry-2SORMVRM.js} +27 -24
- package/dist/bundle/decode-5O7IEFPN.js +297 -0
- package/dist/bundle/{dispatch-FEKU5UXC.js → dispatch-YHQX6FEJ.js} +8 -8
- package/dist/bundle/{dist-YFKABFFF.js → dist-ILNOLGYN.js} +1 -1
- package/dist/bundle/{echarts-XD2JSWU4.js → echarts-ARLMVQC7.js} +2 -2
- package/dist/bundle/{embed-F3HYGAF7.js → embed-FUDUKQ3K.js} +7 -7
- package/dist/bundle/{embedder-GSEDDUH7.js → embedder-HDRV7GX3.js} +10 -10
- package/dist/bundle/{failure-HDJLR2YJ.js → failure-JHXICWIL.js} +3 -3
- package/dist/bundle/first-run-BGEFTXOE.js +29 -0
- package/dist/bundle/first-screen-F5F3VS6Y.js +38 -0
- package/dist/bundle/{instructions-NZGJ4FW5.js → instructions-MEFIKCDI.js} +1 -1
- package/dist/bundle/{mcp-VFIOZDVY.js → mcp-VMS6PBCU.js} +2 -2
- package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
- package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
- package/dist/bundle/meeting-combined-HNSS3FQY.js +24 -0
- package/dist/bundle/meeting-model-REZVYGQW.js +26 -0
- package/dist/bundle/meeting-semantic-R4CSLVRG.js +22 -0
- package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
- package/dist/bundle/{node-RPKPDYQS.js → node-MAQALPLA.js} +2 -2
- package/dist/bundle/{node-sqlite-KH2UUYVO.js → node-sqlite-J7IJYNBO.js} +8 -8
- package/dist/bundle/notion.js +14 -14
- package/dist/bundle/{oauth-NKAI7TQD.js → oauth-AMV4YGJD.js} +8 -8
- package/dist/bundle/{open-WSAEAA2V.js → open-AB27MTGR.js} +6 -6
- package/dist/bundle/{openai-JPVDGHG5.js → openai-D77MU5XV.js} +31 -29
- package/dist/bundle/{process-5ZFVKOQX.js → process-SIOWTRJ6.js} +1 -1
- package/dist/bundle/{program-M3D56D6T.js → program-QC5MX4ZJ.js} +7533 -1997
- package/dist/bundle/{prompt-FROYQ5LV.js → prompt-W77YDHA6.js} +6 -6
- package/dist/bundle/{recognize-NYCHQMCX.js → recognize-3JAXQQ36.js} +5 -5
- package/dist/bundle/{remote-4OERF3Z4.js → remote-PSOJXCXO.js} +11 -11
- package/dist/bundle/{rerank-TEGXFUWY.js → rerank-EE44ZTGL.js} +8 -8
- package/dist/bundle/{schemas-MZNNOEYN.js → schemas-LBYUMBC6.js} +2 -2
- package/dist/bundle/{serve-HLYYBAXY.js → serve-XJMGAMFW.js} +10 -10
- package/dist/bundle/{server-D5OYNEUW.js → server-ASU6CP5R.js} +53 -44
- package/dist/bundle/server-WSPQ5EOA.js +72 -0
- package/dist/bundle/services-PT4PA4J6.js +588 -0
- package/dist/bundle/{sqlite-runtime-H2S5RR2F.js → sqlite-runtime-YHXRTVXE.js} +7 -7
- package/dist/bundle/{state-OPOXCDZL.js → state-T6ZKFWGD.js} +7 -7
- package/dist/bundle/{store-NHMXEJPD.js → store-3MUCZEI3.js} +20 -14
- package/dist/bundle/{store-Y3KRLCJ7.js → store-E5EE25FY.js} +30 -21
- package/dist/bundle/store-maintenance-command-ZZ55BBBG.js +63 -0
- package/dist/commands/api.d.ts.map +1 -1
- package/dist/commands/api.js +13 -4
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/documents.d.ts +10 -1
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +175 -5
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/library.d.ts +10 -0
- package/dist/commands/library.d.ts.map +1 -0
- package/dist/commands/library.js +470 -0
- package/dist/commands/library.js.map +1 -0
- package/dist/commands/session.d.ts.map +1 -1
- package/dist/commands/session.js +4 -3
- package/dist/commands/session.js.map +1 -1
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +73 -5
- package/dist/config.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +15 -3
- package/dist/context.js.map +1 -1
- package/dist/generated/types.d.ts +485 -375
- package/dist/generated/types.d.ts.map +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +1 -0
- package/dist/identity.js.map +1 -1
- package/dist/knowledge.d.ts +27 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +87 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/library.d.ts +44 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +149 -0
- package/dist/library.js.map +1 -0
- package/dist/notion/client.d.ts +4 -1
- package/dist/notion/client.d.ts.map +1 -1
- package/dist/notion/client.js +5 -2
- package/dist/notion/client.js.map +1 -1
- package/dist/notion/errors.d.ts +5 -0
- package/dist/notion/errors.d.ts.map +1 -1
- package/dist/notion/errors.js +33 -1
- package/dist/notion/errors.js.map +1 -1
- package/dist/notion/reads.d.ts +4 -0
- package/dist/notion/reads.d.ts.map +1 -1
- package/dist/notion/writes.d.ts +40 -0
- package/dist/notion/writes.d.ts.map +1 -0
- package/dist/notion/writes.js +112 -0
- package/dist/notion/writes.js.map +1 -0
- package/dist/program.js +2 -2
- package/dist/program.js.map +1 -1
- package/dist/sync/cursor.d.ts +93 -0
- package/dist/sync/cursor.d.ts.map +1 -1
- package/dist/sync/cursor.js +63 -2
- package/dist/sync/cursor.js.map +1 -1
- package/dist/sync/files.d.ts +87 -0
- package/dist/sync/files.d.ts.map +1 -0
- package/dist/sync/files.js +31 -0
- package/dist/sync/files.js.map +1 -0
- package/dist/sync/markdown.d.ts +4 -1
- package/dist/sync/markdown.d.ts.map +1 -1
- package/dist/sync/markdown.js +8 -6
- package/dist/sync/markdown.js.map +1 -1
- package/dist/sync/source.d.ts +6 -59
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +650 -271
- package/dist/sync/source.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/skills/notion-cli/SKILL.md +18 -1
- package/dist/bundle/command-contract-6G5DC2FN.js +0 -35
- package/dist/bundle/decode-7XOFRAAT.js +0 -163
- package/dist/bundle/first-run-TXNTIUSP.js +0 -28
- package/dist/bundle/first-screen-JZPJND7J.js +0 -33
- package/dist/bundle/server-LWZGVMNW.js +0 -62
- package/dist/bundle/store-maintenance-command-D4W7WSLQ.js +0 -53
- package/dist/commands/comments.d.ts +0 -3
- package/dist/commands/comments.d.ts.map +0 -1
- package/dist/commands/comments.js +0 -114
- package/dist/commands/comments.js.map +0 -1
- package/dist/sample/comments.d.ts +0 -61
- package/dist/sample/comments.d.ts.map +0 -1
- package/dist/sample/comments.js +0 -39
- package/dist/sample/comments.js.map +0 -1
- package/dist/sample/records.d.ts +0 -16
- package/dist/sample/records.d.ts.map +0 -1
- package/dist/sample/records.js +0 -22
- package/dist/sample/records.js.map +0 -1
- package/dist/sample/transport.d.ts +0 -42
- package/dist/sample/transport.d.ts.map +0 -1
- package/dist/sample/transport.js +0 -153
- package/dist/sample/transport.js.map +0 -1
- /package/dist/bundle/{chunk-ZI3YTXSF.js → chunk-SHTHNBHG.js} +0 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Client } from "@notionhq/client";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
export declare const pageSchema: v.StrictObjectSchema<{
|
|
4
|
+
readonly id: v.StringSchema<undefined>;
|
|
5
|
+
readonly title: v.StringSchema<undefined>;
|
|
6
|
+
readonly url: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
7
|
+
readonly in_trash: v.BooleanSchema<undefined>;
|
|
8
|
+
readonly last_edited_time: v.NullableSchema<v.StringSchema<undefined>, undefined>;
|
|
9
|
+
}, undefined>;
|
|
10
|
+
export type WrittenPage = v.InferOutput<typeof pageSchema>;
|
|
11
|
+
/** Every Notion write the commands make, each answer checked against its documented shape. */
|
|
12
|
+
export declare const liveWrites: (client: Client) => {
|
|
13
|
+
/** A new page under `parent`; with no title, Notion takes the Markdown's first `# heading`. */
|
|
14
|
+
create: ({ parent, title, markdown }: {
|
|
15
|
+
parent: string;
|
|
16
|
+
title?: string | undefined;
|
|
17
|
+
markdown?: string;
|
|
18
|
+
}) => Promise<{
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
url: string | null;
|
|
22
|
+
in_trash: boolean;
|
|
23
|
+
last_edited_time: string | null;
|
|
24
|
+
}>;
|
|
25
|
+
/** The whole text replaced; a child page or database left out is deleted only when `allowDeleting` is set. */
|
|
26
|
+
replace: (id: string, markdown: string, allowDeleting: boolean) => Promise<{
|
|
27
|
+
id: string;
|
|
28
|
+
warnings: string[];
|
|
29
|
+
}>;
|
|
30
|
+
/** Notion has no permanent delete in its API: a page goes to the trash and comes back from it ([trash a page](https://developers.notion.com/reference/trash-page)). */
|
|
31
|
+
trash: (id: string, inTrash: boolean) => Promise<{
|
|
32
|
+
id: string;
|
|
33
|
+
title: string;
|
|
34
|
+
url: string | null;
|
|
35
|
+
in_trash: boolean;
|
|
36
|
+
last_edited_time: string | null;
|
|
37
|
+
}>;
|
|
38
|
+
};
|
|
39
|
+
export type LiveWrites = ReturnType<typeof liveWrites>;
|
|
40
|
+
//# sourceMappingURL=writes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.d.ts","sourceRoot":"","sources":["../../src/notion/writes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAiC5B,eAAO,MAAM,UAAU;;;;;;aAMrB,CAAA;AACF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,UAAU,CAAC,CAAA;AA8D1D,8FAA8F;AAC9F,eAAO,MAAM,UAAU,WAAY,MAAM;IACvC,+FAA+F;IAC/F,MAAM,gCAAgC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE;;;;;;;IAavG,8GAA8G;IAC9G,OAAO,OAAO,MAAM,YAAY,MAAM,iBAAiB,OAAO;;;;IAoB9D,uKAAuK;IACvK,KAAK,OAAO,MAAM,WAAW,OAAO;;;;;;;CAEpC,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAA"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
|
+
import * as v from "valibot";
|
|
3
|
+
import { mapped, NOTION } from "./errors.js";
|
|
4
|
+
// Each wire name is from Notion's reference, linked at its schema; the strict fake in src/testing/fake-notion.ts
|
|
5
|
+
// refuses any other. No wire type leaves this file (WC-ARCH-3).
|
|
6
|
+
/** [Page](https://developers.notion.com/reference/page): the fields a write's answer reports. */
|
|
7
|
+
const wirePage = v.looseObject({
|
|
8
|
+
object: v.literal("page"),
|
|
9
|
+
id: v.string(),
|
|
10
|
+
url: v.optional(v.string()),
|
|
11
|
+
in_trash: v.optional(v.boolean()),
|
|
12
|
+
last_edited_time: v.optional(v.string()),
|
|
13
|
+
properties: v.optional(v.record(v.string(), v.looseObject({ type: v.string(), title: v.optional(v.array(v.unknown())) }))),
|
|
14
|
+
});
|
|
15
|
+
/** [Update a page's content as Markdown](https://developers.notion.com/reference/update-page-markdown). */
|
|
16
|
+
const wireUpdated = v.looseObject({
|
|
17
|
+
object: v.literal("page_markdown"),
|
|
18
|
+
id: v.string(),
|
|
19
|
+
warnings: v.optional(v.array(v.looseObject({ code: v.string(), message: v.string() }))),
|
|
20
|
+
});
|
|
21
|
+
const parsed = (schema, value) => {
|
|
22
|
+
const result = v.safeParse(schema, value);
|
|
23
|
+
if (result.success)
|
|
24
|
+
return result.output;
|
|
25
|
+
throw new CliError("invalid_response", `${NOTION}'s answer does not have the documented shape`, {
|
|
26
|
+
reason: "notion.invalid-response",
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
export const pageSchema = v.strictObject({
|
|
30
|
+
id: v.string(),
|
|
31
|
+
title: v.string(),
|
|
32
|
+
url: v.nullable(v.string()),
|
|
33
|
+
in_trash: v.boolean(),
|
|
34
|
+
last_edited_time: v.nullable(v.string()),
|
|
35
|
+
});
|
|
36
|
+
const titleOf = (properties) => {
|
|
37
|
+
const title = Object.values(properties ?? {}).find((property) => property.type === "title")?.title ?? [];
|
|
38
|
+
return title.map((part) => part.plain_text ?? "").join("");
|
|
39
|
+
};
|
|
40
|
+
const pageOf = (answer) => {
|
|
41
|
+
const page = parsed(wirePage, answer);
|
|
42
|
+
return {
|
|
43
|
+
id: page.id,
|
|
44
|
+
title: titleOf(page.properties),
|
|
45
|
+
url: page.url ?? null,
|
|
46
|
+
in_trash: page.in_trash ?? false,
|
|
47
|
+
last_edited_time: page.last_edited_time ?? null,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
/** A title as the rich text a page's `title` property takes ([page properties](https://developers.notion.com/reference/page-property-values#title)). */
|
|
51
|
+
const titleProperty = (title) => ({ title: { title: [{ type: "text", text: { content: title } }] } });
|
|
52
|
+
/**
|
|
53
|
+
* Notion refuses a Markdown update that would drop a child page or database with a `validation_error`, unless the
|
|
54
|
+
* update allows it ([protecting child pages](https://developers.notion.com/reference/update-page-markdown)). Its
|
|
55
|
+
* message names the pages but may quote other people's titles, so the refusal says what to do instead (WC-SECR-6).
|
|
56
|
+
*/
|
|
57
|
+
const withContentHint = (error) => isCliError(error) && error.code === "validation_error" && error.details.reason === "notion.refused"
|
|
58
|
+
? new CliError("validation_error", `${NOTION} refused the new text. Most often it leaves out a child page or database, which Notion would ` +
|
|
59
|
+
"delete: keep its <page> or <database> tag, or add --allow-deleting-content. Text over 5,000 blocks is " +
|
|
60
|
+
"refused too", { ...error.details, reason: "notion.text-refused" })
|
|
61
|
+
: error;
|
|
62
|
+
const UNANSWERED = new Set(["network_error", "timeout", "invalid_response", "provider_unavailable"]);
|
|
63
|
+
/**
|
|
64
|
+
* A write Notion may have carried out is `outcome_unknown`, never retried (WC-LIFE-9): no answer, an answer that cannot
|
|
65
|
+
* be read, or a 5xx, which Notion also gives a request it ended after 60 s
|
|
66
|
+
* ([status codes](https://developers.notion.com/reference/status-codes)). A refusal, a 429 and anything not sent
|
|
67
|
+
* keep their own code.
|
|
68
|
+
*/
|
|
69
|
+
const outcomeOf = (error) => {
|
|
70
|
+
const known = isCliError(error);
|
|
71
|
+
if (known && (error.details.sent === false || !UNANSWERED.has(error.code)))
|
|
72
|
+
return error;
|
|
73
|
+
return new CliError("outcome_unknown", `${NOTION} did not confirm the write; check the page before repeating it`, {
|
|
74
|
+
...(known ? { status: error.details.status, notion_code: error.details.notion_code, cause_code: error.code } : {}),
|
|
75
|
+
retryable: false,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const writing = async (call) => {
|
|
79
|
+
try {
|
|
80
|
+
return await call();
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
throw outcomeOf(error);
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
/** Every Notion write the commands make, each answer checked against its documented shape. */
|
|
87
|
+
export const liveWrites = (client) => ({
|
|
88
|
+
/** A new page under `parent`; with no title, Notion takes the Markdown's first `# heading`. */
|
|
89
|
+
create: ({ parent, title, markdown }) => writing(async () => pageOf(await mapped(() => client.pages.create({
|
|
90
|
+
parent: { page_id: parent },
|
|
91
|
+
...(title === undefined ? {} : { properties: titleProperty(title) }),
|
|
92
|
+
...(markdown === undefined ? {} : { markdown, markdown_version: "v2" }),
|
|
93
|
+
})))),
|
|
94
|
+
/** The whole text replaced; a child page or database left out is deleted only when `allowDeleting` is set. */
|
|
95
|
+
replace: (id, markdown, allowDeleting) => writing(async () => {
|
|
96
|
+
try {
|
|
97
|
+
const answer = parsed(wireUpdated, await mapped(() => client.pages.updateMarkdown({
|
|
98
|
+
page_id: id,
|
|
99
|
+
markdown_version: "v2",
|
|
100
|
+
type: "replace_content",
|
|
101
|
+
replace_content: { new_str: markdown, ...(allowDeleting ? { allow_deleting_content: true } : {}) },
|
|
102
|
+
})));
|
|
103
|
+
return { id: answer.id, warnings: (answer.warnings ?? []).map(({ code }) => code) };
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
throw allowDeleting ? error : withContentHint(error);
|
|
107
|
+
}
|
|
108
|
+
}),
|
|
109
|
+
/** Notion has no permanent delete in its API: a page goes to the trash and comes back from it ([trash a page](https://developers.notion.com/reference/trash-page)). */
|
|
110
|
+
trash: (id, inTrash) => writing(async () => pageOf(await mapped(() => client.pages.update({ page_id: id, in_trash: inTrash })))),
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=writes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writes.js","sourceRoot":"","sources":["../../src/notion/writes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAE5C,iHAAiH;AACjH,gEAAgE;AAEhE,iGAAiG;AACjG,MAAM,QAAQ,G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,MAAM,MAAM,CAAC,GAAG,EAAE,CAChB,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC;gBAC1B,OAAO,EAAE,EAAE;gBACX,gBAAgB,EAAE,IAAI;gBACtB,IAAI,EAAE,iBAAiB;gBACvB,eAAe,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aACnG,CAAC,CACH,CACF,CAAA;YACD,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAA;QACrF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QACtD,CAAC;IACH,CAAC,CAAC;IAEJ,uKAAuK;IACvK,KAAK,EAAE,CAAC,EAAU,EAAE,OAAgB,EAAE,EAAE,CACtC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,MAAM,CAAC,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;CAC3G,CAAC,CAAA"}
|
package/dist/program.js
CHANGED
|
@@ -4,7 +4,7 @@ import { appDoctorCommand, appMcpCommand, commandsCommand, configCommand, create
|
|
|
4
4
|
import { appUpdate } from "@wirecat/cli-core/update";
|
|
5
5
|
import { apiCommand } from "./commands/api.js";
|
|
6
6
|
import { databasesCommand } from "./commands/databases.js";
|
|
7
|
-
import {
|
|
7
|
+
import { libraryCommands } from "./commands/library.js";
|
|
8
8
|
import { sessionCommand } from "./commands/session.js";
|
|
9
9
|
import { configuration } from "./config.js";
|
|
10
10
|
import { IDENTITY, PACKAGE, SKILL } from "./identity.js";
|
|
@@ -41,7 +41,7 @@ export const definition = () => ({
|
|
|
41
41
|
commands: () => [
|
|
42
42
|
commandsCommand(IDENTITY),
|
|
43
43
|
sessionCommand(),
|
|
44
|
-
|
|
44
|
+
...libraryCommands(),
|
|
45
45
|
databasesCommand(),
|
|
46
46
|
apiCommand(),
|
|
47
47
|
appDoctorCommand(IDENTITY, configuration, { packageName: PACKAGE }),
|
package/dist/program.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,SAAS,EACT,iBAAiB,EAIjB,GAAG,IAAI,SAAS,EAChB,WAAW,EACX,YAAY,EACZ,cAAc,GACf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"program.js","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,aAAa,EACb,aAAa,IAAI,mBAAmB,EACpC,SAAS,EACT,iBAAiB,EAIjB,G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,CAAC;QACtC,WAAW,CAAC,QAAQ,CAAC;KACtB;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAwB,EAAW,EAAE,CAAC,mBAAmB,CAAC,UAAU,EAAE,EAAE,OAAO,CAAC,CAAA;AAE9G,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,IAAc,EAAE,OAAoB,EAAmB,EAAE,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,OAAO,CAAC,CAAA"}
|
package/dist/sync/cursor.d.ts
CHANGED
|
@@ -2,16 +2,44 @@ import * as v from "valibot";
|
|
|
2
2
|
declare const Task: v.VariantSchema<"t", [v.ObjectSchema<{
|
|
3
3
|
readonly t: v.LiteralSchema<"search", undefined>;
|
|
4
4
|
readonly kind: v.PicklistSchema<["page", "data_source"], undefined>;
|
|
5
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
6
|
+
/** Everything search gives, for the top of a workspace walk, not only what was edited since the mark. */
|
|
7
|
+
readonly full: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
8
|
+
}, undefined>, v.ObjectSchema<{
|
|
9
|
+
readonly t: v.LiteralSchema<"database", undefined>;
|
|
10
|
+
readonly id: v.StringSchema<undefined>;
|
|
11
|
+
readonly walk: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
12
|
+
}, undefined>, v.ObjectSchema<{
|
|
13
|
+
readonly t: v.LiteralSchema<"confirm", undefined>;
|
|
14
|
+
readonly container: v.StringSchema<undefined>;
|
|
15
|
+
readonly ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
5
16
|
}, undefined>, v.ObjectSchema<{
|
|
6
17
|
readonly t: v.LiteralSchema<"rows", undefined>;
|
|
7
18
|
readonly database: v.StringSchema<undefined>;
|
|
8
19
|
readonly source: v.StringSchema<undefined>;
|
|
20
|
+
/** The next query reads the rows created from this time on. */
|
|
9
21
|
readonly after: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
22
|
+
/** Only while more than a page of rows share the minute `after`: the query's own position inside it. */
|
|
23
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
24
|
+
/** The rows of that minute read so far. */
|
|
25
|
+
readonly seen: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
10
26
|
/** Every row, not only those edited since the mark: part of a full walk. */
|
|
11
27
|
readonly full: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
12
28
|
}, undefined>, v.ObjectSchema<{
|
|
13
29
|
readonly t: v.LiteralSchema<"walk", undefined>;
|
|
14
30
|
readonly id: v.StringSchema<undefined>;
|
|
31
|
+
readonly kind: v.OptionalSchema<v.PicklistSchema<["page", "database", "row", "workspace"], undefined>, undefined>;
|
|
32
|
+
/** Blocks still to list, the page first, then the blocks inside it that hold more; each from its own position. */
|
|
33
|
+
readonly blocks: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
34
|
+
readonly id: v.StringSchema<undefined>;
|
|
35
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
36
|
+
}, undefined>, undefined>, undefined>;
|
|
37
|
+
/** The children listed so far; a known child not among them is read directly once the listing ends. */
|
|
38
|
+
readonly seen: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
39
|
+
}, undefined>, v.ObjectSchema<{
|
|
40
|
+
readonly t: v.LiteralSchema<"child", undefined>;
|
|
41
|
+
readonly id: v.StringSchema<undefined>;
|
|
42
|
+
readonly container: v.StringSchema<undefined>;
|
|
15
43
|
}, undefined>], undefined>;
|
|
16
44
|
declare const Cursor: v.ObjectSchema<{
|
|
17
45
|
readonly v: v.LiteralSchema<1, undefined>;
|
|
@@ -32,17 +60,47 @@ declare const Cursor: v.ObjectSchema<{
|
|
|
32
60
|
readonly tasks: v.ArraySchema<v.VariantSchema<"t", [v.ObjectSchema<{
|
|
33
61
|
readonly t: v.LiteralSchema<"search", undefined>;
|
|
34
62
|
readonly kind: v.PicklistSchema<["page", "data_source"], undefined>;
|
|
63
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
64
|
+
/** Everything search gives, for the top of a workspace walk, not only what was edited since the mark. */
|
|
65
|
+
readonly full: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
66
|
+
}, undefined>, v.ObjectSchema<{
|
|
67
|
+
readonly t: v.LiteralSchema<"database", undefined>;
|
|
68
|
+
readonly id: v.StringSchema<undefined>;
|
|
69
|
+
readonly walk: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
70
|
+
}, undefined>, v.ObjectSchema<{
|
|
71
|
+
readonly t: v.LiteralSchema<"confirm", undefined>;
|
|
72
|
+
readonly container: v.StringSchema<undefined>;
|
|
73
|
+
readonly ids: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
35
74
|
}, undefined>, v.ObjectSchema<{
|
|
36
75
|
readonly t: v.LiteralSchema<"rows", undefined>;
|
|
37
76
|
readonly database: v.StringSchema<undefined>;
|
|
38
77
|
readonly source: v.StringSchema<undefined>;
|
|
78
|
+
/** The next query reads the rows created from this time on. */
|
|
39
79
|
readonly after: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
80
|
+
/** Only while more than a page of rows share the minute `after`: the query's own position inside it. */
|
|
81
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
82
|
+
/** The rows of that minute read so far. */
|
|
83
|
+
readonly seen: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
40
84
|
/** Every row, not only those edited since the mark: part of a full walk. */
|
|
41
85
|
readonly full: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
42
86
|
}, undefined>, v.ObjectSchema<{
|
|
43
87
|
readonly t: v.LiteralSchema<"walk", undefined>;
|
|
44
88
|
readonly id: v.StringSchema<undefined>;
|
|
89
|
+
readonly kind: v.OptionalSchema<v.PicklistSchema<["page", "database", "row", "workspace"], undefined>, undefined>;
|
|
90
|
+
/** Blocks still to list, the page first, then the blocks inside it that hold more; each from its own position. */
|
|
91
|
+
readonly blocks: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
92
|
+
readonly id: v.StringSchema<undefined>;
|
|
93
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
94
|
+
}, undefined>, undefined>, undefined>;
|
|
95
|
+
/** The children listed so far; a known child not among them is read directly once the listing ends. */
|
|
96
|
+
readonly seen: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
97
|
+
}, undefined>, v.ObjectSchema<{
|
|
98
|
+
readonly t: v.LiteralSchema<"child", undefined>;
|
|
99
|
+
readonly id: v.StringSchema<undefined>;
|
|
100
|
+
readonly container: v.StringSchema<undefined>;
|
|
45
101
|
}, undefined>], undefined>, undefined>;
|
|
102
|
+
/** The containers resolved so far, so that a step the deadline cut does not read them again. */
|
|
103
|
+
readonly parents: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.StringSchema<undefined>, undefined>, undefined>;
|
|
46
104
|
}, undefined>, undefined>;
|
|
47
105
|
}, undefined>;
|
|
48
106
|
export type SyncCursor = v.InferOutput<typeof Cursor>;
|
|
@@ -50,5 +108,40 @@ export type SyncTask = v.InferOutput<typeof Task>;
|
|
|
50
108
|
export type SyncPass = NonNullable<SyncCursor["pass"]>;
|
|
51
109
|
export declare const encodeCursor: (cursor: SyncCursor) => string;
|
|
52
110
|
export declare const decodeCursor: (token: string) => SyncCursor;
|
|
111
|
+
declare const ListPosition: v.VariantSchema<"k", [v.ObjectSchema<{
|
|
112
|
+
readonly k: v.LiteralSchema<"rows", undefined>;
|
|
113
|
+
/** The data sources left, the one being read first. */
|
|
114
|
+
readonly sources: v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
115
|
+
readonly after: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
116
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
117
|
+
readonly seen: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
|
|
118
|
+
}, undefined>, v.ObjectSchema<{
|
|
119
|
+
readonly k: v.LiteralSchema<"blocks", undefined>;
|
|
120
|
+
readonly blocks: v.SchemaWithPipe<readonly [v.ArraySchema<v.ObjectSchema<{
|
|
121
|
+
readonly id: v.StringSchema<undefined>;
|
|
122
|
+
readonly start: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
123
|
+
}, undefined>, undefined>, v.MinLengthAction<{
|
|
124
|
+
id: string;
|
|
125
|
+
start?: string | undefined;
|
|
126
|
+
}[], 1, undefined>]>;
|
|
127
|
+
readonly seen: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
128
|
+
}, undefined>], undefined>;
|
|
129
|
+
/** Where a folder's listing stopped, kept by the engine's walk between its steps. */
|
|
130
|
+
export type ListPosition = v.InferOutput<typeof ListPosition>;
|
|
131
|
+
export declare const encodeListPosition: (position: ListPosition) => string;
|
|
132
|
+
/** A position this code cannot read is one Notion would not take either: the engine lists the folder again. */
|
|
133
|
+
export declare const decodeListPosition: (token: string) => ListPosition;
|
|
134
|
+
export interface RowPosition {
|
|
135
|
+
after?: string;
|
|
136
|
+
start?: string;
|
|
137
|
+
seen?: string[];
|
|
138
|
+
}
|
|
139
|
+
export interface BlockPosition {
|
|
140
|
+
blocks: {
|
|
141
|
+
id: string;
|
|
142
|
+
start?: string;
|
|
143
|
+
}[];
|
|
144
|
+
seen: string[];
|
|
145
|
+
}
|
|
53
146
|
export {};
|
|
54
147
|
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../../src/sync/cursor.ts"],"names":[],"mappings":"AACA,OAAO,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MAAM,kBAAkB,UAAW,MAAM,KAAG,YAelD,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACxC,IAAI,EAAE,MAAM,EAAE,CAAA;CACf"}
|
package/dist/sync/cursor.js
CHANGED
|
@@ -2,16 +2,40 @@ import { CliError } from "@wirecat/cli-base";
|
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
const PREFIX = "notion1.";
|
|
4
4
|
const Task = v.variant("t", [
|
|
5
|
-
v.object({
|
|
5
|
+
v.object({
|
|
6
|
+
t: v.literal("search"),
|
|
7
|
+
kind: v.picklist(["page", "data_source"]),
|
|
8
|
+
start: v.optional(v.string()),
|
|
9
|
+
/** Everything search gives, for the top of a workspace walk, not only what was edited since the mark. */
|
|
10
|
+
full: v.optional(v.boolean()),
|
|
11
|
+
}),
|
|
12
|
+
v.object({ t: v.literal("database"), id: v.string(), walk: v.optional(v.boolean()) }),
|
|
13
|
+
/** Known children of a container that its listing has not shown yet, each read directly at the end of the pass. */
|
|
14
|
+
v.object({ t: v.literal("confirm"), container: v.string(), ids: v.array(v.string()) }),
|
|
6
15
|
v.object({
|
|
7
16
|
t: v.literal("rows"),
|
|
8
17
|
database: v.string(),
|
|
9
18
|
source: v.string(),
|
|
19
|
+
/** The next query reads the rows created from this time on. */
|
|
10
20
|
after: v.optional(v.string()),
|
|
21
|
+
/** Only while more than a page of rows share the minute `after`: the query's own position inside it. */
|
|
22
|
+
start: v.optional(v.string()),
|
|
23
|
+
/** The rows of that minute read so far. */
|
|
24
|
+
seen: v.optional(v.array(v.string())),
|
|
11
25
|
/** Every row, not only those edited since the mark: part of a full walk. */
|
|
12
26
|
full: v.optional(v.boolean()),
|
|
13
27
|
}),
|
|
14
|
-
v.object({
|
|
28
|
+
v.object({
|
|
29
|
+
t: v.literal("walk"),
|
|
30
|
+
id: v.string(),
|
|
31
|
+
kind: v.optional(v.picklist(["page", "database", "row", "workspace"])),
|
|
32
|
+
/** Blocks still to list, the page first, then the blocks inside it that hold more; each from its own position. */
|
|
33
|
+
blocks: v.optional(v.array(v.object({ id: v.string(), start: v.optional(v.string()) }))),
|
|
34
|
+
/** The children listed so far; a known child not among them is read directly once the listing ends. */
|
|
35
|
+
seen: v.optional(v.array(v.string())),
|
|
36
|
+
}),
|
|
37
|
+
/** A database a page's listing named, read on its own: a linked view of a database elsewhere answers 404. */
|
|
38
|
+
v.object({ t: v.literal("child"), id: v.string(), container: v.string() }),
|
|
15
39
|
]);
|
|
16
40
|
const Cursor = v.object({
|
|
17
41
|
v: v.literal(1),
|
|
@@ -27,6 +51,8 @@ const Cursor = v.object({
|
|
|
27
51
|
startedAt: v.number(),
|
|
28
52
|
walk: v.boolean(),
|
|
29
53
|
tasks: v.array(Task),
|
|
54
|
+
/** The containers resolved so far, so that a step the deadline cut does not read them again. */
|
|
55
|
+
parents: v.optional(v.record(v.string(), v.string())),
|
|
30
56
|
})),
|
|
31
57
|
});
|
|
32
58
|
export const encodeCursor = (cursor) => `${PREFIX}${Buffer.from(JSON.stringify(cursor)).toString("base64url")}`;
|
|
@@ -49,4 +75,39 @@ export const decodeCursor = (token) => {
|
|
|
49
75
|
});
|
|
50
76
|
return result.output;
|
|
51
77
|
};
|
|
78
|
+
const LIST_PREFIX = "notion-list1.";
|
|
79
|
+
const ListPosition = v.variant("k", [
|
|
80
|
+
v.object({
|
|
81
|
+
k: v.literal("rows"),
|
|
82
|
+
/** The data sources left, the one being read first. */
|
|
83
|
+
sources: v.pipe(v.array(v.string()), v.minLength(1)),
|
|
84
|
+
after: v.optional(v.string()),
|
|
85
|
+
start: v.optional(v.string()),
|
|
86
|
+
seen: v.optional(v.array(v.string())),
|
|
87
|
+
}),
|
|
88
|
+
v.object({
|
|
89
|
+
k: v.literal("blocks"),
|
|
90
|
+
blocks: v.pipe(v.array(v.object({ id: v.string(), start: v.optional(v.string()) })), v.minLength(1)),
|
|
91
|
+
seen: v.array(v.string()),
|
|
92
|
+
}),
|
|
93
|
+
]);
|
|
94
|
+
export const encodeListPosition = (position) => `${LIST_PREFIX}${Buffer.from(JSON.stringify(position)).toString("base64url")}`;
|
|
95
|
+
/** A position this code cannot read is one Notion would not take either: the engine lists the folder again. */
|
|
96
|
+
export const decodeListPosition = (token) => {
|
|
97
|
+
let parsed;
|
|
98
|
+
try {
|
|
99
|
+
parsed = token.startsWith(LIST_PREFIX)
|
|
100
|
+
? JSON.parse(Buffer.from(token.slice(LIST_PREFIX.length), "base64url").toString("utf8"))
|
|
101
|
+
: undefined;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
parsed = undefined;
|
|
105
|
+
}
|
|
106
|
+
const result = v.safeParse(ListPosition, parsed);
|
|
107
|
+
if (!result.success)
|
|
108
|
+
throw new CliError("not_found", "the saved listing position is not one this version reads; it is listed again", {
|
|
109
|
+
reason: "notion.listing-stale",
|
|
110
|
+
});
|
|
111
|
+
return result.output;
|
|
112
|
+
};
|
|
52
113
|
//# sourceMappingURL=cursor.js.map
|
package/dist/sync/cursor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.js","sourceRoot":"","sources":["../../src/sync/cursor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,MAAM,MAAM,GAAG,UAAU,CAAA;AAEzB,MAAM,IAAI,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;IAC1B,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"cursor.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AQ,CAAC,WAAW,EAAE,8EAA8E,EAAE;YAC9G,MAAM,EAAE,sBAAsB;SAC/B,CAAC,CAAA;IACJ,OAAO,MAAM,CAAC,MAAM,CAAA;AACtB,CAAC,CAAA"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { CliError } from "@wirecat/cli-base";
|
|
2
|
+
import type { Deadline } from "@wirecat/cli-core/background";
|
|
3
|
+
import type { SourceFile } from "@wirecat/cli-core/documents";
|
|
4
|
+
import type { NotionParent } from "../notion/reads.js";
|
|
5
|
+
import type { FrontMatterValue } from "./front-matter.js";
|
|
6
|
+
/** The folder that stands for everything the token sees, the scope when no folder is chosen. */
|
|
7
|
+
export declare const WORKSPACE_ROOT = "notion-workspace";
|
|
8
|
+
export declare const parentId: (parent: NotionParent) => string;
|
|
9
|
+
export type NotionKind = "workspace" | "page" | "row" | "database";
|
|
10
|
+
export interface NotionIdentity {
|
|
11
|
+
id: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
/** `author`, `editor`, or `property:<name>` for a people property. */
|
|
14
|
+
role: string;
|
|
15
|
+
}
|
|
16
|
+
export interface NotionMetadata {
|
|
17
|
+
kind: NotionKind;
|
|
18
|
+
/** Notion's own parent. `parents` holds the container the sync files it under, which differs for a page in a block. */
|
|
19
|
+
parent?: {
|
|
20
|
+
type: NotionParent["type"];
|
|
21
|
+
id: string;
|
|
22
|
+
};
|
|
23
|
+
dataSources?: {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}[];
|
|
27
|
+
createdBy?: string;
|
|
28
|
+
lastEditedBy?: string;
|
|
29
|
+
/** Set by `content()` only. */
|
|
30
|
+
frontMatter?: Record<string, FrontMatterValue>;
|
|
31
|
+
people?: NotionIdentity[];
|
|
32
|
+
missingBlocks?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface NotionFile extends SourceFile {
|
|
35
|
+
providerMetadata: NotionMetadata;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Every page may hold sub-pages, so every page is a folder; a root must be one too. A row stays a plain file: listing
|
|
39
|
+
* the children of every row would cost a request per row.
|
|
40
|
+
*/
|
|
41
|
+
export declare const isNotionFolder: (file: NotionFile) => boolean;
|
|
42
|
+
/** A page is a folder and a document at once: the engine walks its children and imports its text. */
|
|
43
|
+
export declare const isNotionDocument: (file: NotionFile) => boolean;
|
|
44
|
+
/** A page may have an empty title, and every catalog entry needs a name. */
|
|
45
|
+
export declare const UNTITLED = "Untitled";
|
|
46
|
+
export interface NotionSourceOptions {
|
|
47
|
+
/** Chosen pages and databases; none means everything the token sees. */
|
|
48
|
+
roots?: string[];
|
|
49
|
+
/**
|
|
50
|
+
* What the sync already holds (the state's documents and folders), to tell a missed page from a deleted one. Read
|
|
51
|
+
* once: a source serves one sync run.
|
|
52
|
+
*/
|
|
53
|
+
known?: () => Iterable<NotionFile>;
|
|
54
|
+
/** How far back each pass reads before the mark; at least two minutes. */
|
|
55
|
+
overlapMs?: number;
|
|
56
|
+
walkEveryMs?: number;
|
|
57
|
+
/** Requests one `changes()` call may make before it returns what it has and a cursor to go on from. */
|
|
58
|
+
maxRequests?: number;
|
|
59
|
+
/** This computer's clock, for the walk schedule only; Notion's timestamps are never compared with it. */
|
|
60
|
+
now?: () => number;
|
|
61
|
+
/** An item or a step left out of this sync, and why; the sync went on without it. */
|
|
62
|
+
warn?: (warning: SyncWarning) => void;
|
|
63
|
+
/**
|
|
64
|
+
* The run's hard limit: `changes()` stops before it, less its margin and the slowest request so far, and saves the
|
|
65
|
+
* pass for the next sync. Read on `clock`, the wall clock by default.
|
|
66
|
+
*/
|
|
67
|
+
deadline?: Deadline;
|
|
68
|
+
clock?: () => number;
|
|
69
|
+
}
|
|
70
|
+
export interface SyncWarning {
|
|
71
|
+
id?: string;
|
|
72
|
+
code: CliError["code"];
|
|
73
|
+
/** What happened, as a dotted id: `meta.issues` names it. */
|
|
74
|
+
reason: string;
|
|
75
|
+
message: string;
|
|
76
|
+
retry_after_ms?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface Listing {
|
|
79
|
+
files: NotionFile[];
|
|
80
|
+
/** Known items confirmed deleted, trashed or unshared by a direct read. */
|
|
81
|
+
gone: string[];
|
|
82
|
+
/** Known items that are still there, under another parent. */
|
|
83
|
+
moved: NotionFile[];
|
|
84
|
+
}
|
|
85
|
+
/** A database's data sources as a set, as Notion may list them in any order. */
|
|
86
|
+
export declare const sourceIds: (file: NotionFile | undefined) => string | undefined;
|
|
87
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/sync/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAC7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AAEzD,gGAAgG;AAChG,eAAO,MAAM,cAAc,qBAAqB,CAAA;AAEhD,eAAO,MAAM,QAAQ,WAAY,YAAY,WAa5C,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,UAAU,CAAA;AAElE,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sEAAsE;IACtE,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAA;IAChB,uHAAuH;IACvH,MAAM,CAAC,EAAE;QAAE,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACnD,WAAW,C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ACtB,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,8DAA8D;IAC9D,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB;AAED,gFAAgF;AAChF,eAAO,MAAM,SAAS,SAAU,UAAU,GAAG,SAAS,uBAI3C,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** The folder that stands for everything the token sees, the scope when no folder is chosen. */
|
|
2
|
+
export const WORKSPACE_ROOT = "notion-workspace";
|
|
3
|
+
export const parentId = (parent) => {
|
|
4
|
+
switch (parent.type) {
|
|
5
|
+
case "workspace":
|
|
6
|
+
return WORKSPACE_ROOT;
|
|
7
|
+
case "page_id":
|
|
8
|
+
return parent.page_id;
|
|
9
|
+
case "data_source_id":
|
|
10
|
+
return parent.data_source_id;
|
|
11
|
+
case "database_id":
|
|
12
|
+
return parent.database_id;
|
|
13
|
+
case "block_id":
|
|
14
|
+
return parent.block_id;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Every page may hold sub-pages, so every page is a folder; a root must be one too. A row stays a plain file: listing
|
|
19
|
+
* the children of every row would cost a request per row.
|
|
20
|
+
*/
|
|
21
|
+
export const isNotionFolder = (file) => file.providerMetadata.kind !== "row";
|
|
22
|
+
/** A page is a folder and a document at once: the engine walks its children and imports its text. */
|
|
23
|
+
export const isNotionDocument = (file) => file.providerMetadata.kind === "page";
|
|
24
|
+
/** A page may have an empty title, and every catalog entry needs a name. */
|
|
25
|
+
export const UNTITLED = "Untitled";
|
|
26
|
+
/** A database's data sources as a set, as Notion may list them in any order. */
|
|
27
|
+
export const sourceIds = (file) => file?.providerMetadata.dataSources
|
|
28
|
+
?.map((item) => item.id)
|
|
29
|
+
.sort()
|
|
30
|
+
.join();
|
|
31
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/sync/files.ts"],"names":[],"mappings":"AAMA,gGAAgG;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAEhD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAoB,EAAE,EAAE;IAC/C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,WAAW;YACd,OAAO,cAAc,CAAA;QACvB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,OAAO,CAAA;QACvB,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,cAAc,CAAA;QAC9B,KAAK,aAAa;YAChB,OAAO,MAAM,CAAC,WAAW,CAAA;QAC3B,KAAK,UAAU;YACb,OAAO,MAAM,CAAC,QAAQ,CAAA;IAC1B,CAAC;AACH,CAAC,CAAA;AA4BD;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,KAAK,CAAA;AAExF,qGAAqG;AACrG,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAgB,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,KAAK,MAAM,CAAA;AAE3F,4EAA4E;AAC5E,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAA;AA4ClC,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,IAA4B,EAAE,EAAE,CACxD,IAAI,EAAE,gBAAgB,CAAC,WAAW;IAChC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;KACvB,IAAI,EAAE;KACN,IAAI,EAAE,CAAA"}
|
package/dist/sync/markdown.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { type CliError } from "@wirecat/cli-base";
|
|
1
2
|
import type { NotionReads } from "../notion/reads.js";
|
|
2
3
|
export interface PageText {
|
|
3
4
|
markdown: string;
|
|
4
5
|
/** Blocks Notion would not give: not shared with this token, or still truncated after the re-fetches. */
|
|
5
6
|
missing: number;
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
/** A block left out of the text: unshared (404), or one the token may not read (403). */
|
|
9
|
+
export type SkippedBlock = (id: string, code: CliError["code"]) => void;
|
|
10
|
+
export declare const pageText: (reads: NotionReads, id: string, skipped?: SkippedBlock) => Promise<PageText>;
|
|
8
11
|
//# sourceMappingURL=markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/sync/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/sync/markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,MAAM,mBAAmB,CAAA;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAOrD,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,yGAAyG;IACzG,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,yFAAyF;AACzF,MAAM,MAAM,YAAY,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;AAkCvE,eAAO,MAAM,QAAQ,UACZ,WAAW,MACd,MAAM,YACD,YAAY,KACpB,OAAO,CAAC,QAAQ,CAIlB,CAAA"}
|