@wirecat/notion-cli 0.0.0-stage → 0.1.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 +33 -0
- package/LICENSE +204 -0
- package/README.md +36 -2
- package/contracts/wirecat.json +1315 -0
- package/dist/bin/notion.d.ts +3 -0
- package/dist/bin/notion.d.ts.map +1 -0
- package/dist/bin/notion.js +40 -0
- package/dist/bin/notion.js.map +1 -0
- package/dist/bundle/all-profiles-OETMCOLN.js +278 -0
- package/dist/bundle/anthropic-5Y3O2TYM.js +91 -0
- package/dist/bundle/app-server-IVWBIVHC.js +231 -0
- package/dist/bundle/bun-EO636SAD.js +169 -0
- package/dist/bundle/bun-sqlite-C2T7QJ2M.js +76 -0
- package/dist/bundle/chunk-24FAYAML.js +52 -0
- package/dist/bundle/chunk-2YR3RYT4.js +73 -0
- package/dist/bundle/chunk-35K5T6WV.js +24 -0
- package/dist/bundle/chunk-3D3PFXBP.js +2315 -0
- package/dist/bundle/chunk-47R43UVJ.js +1068 -0
- package/dist/bundle/chunk-4GC5DBHW.js +100 -0
- package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
- package/dist/bundle/chunk-64D5VUZ4.js +9564 -0
- package/dist/bundle/chunk-66PL7P4C.js +23 -0
- package/dist/bundle/chunk-7FII4DCE.js +362 -0
- package/dist/bundle/chunk-7N5QB6NL.js +156 -0
- package/dist/bundle/chunk-AE2KQ37N.js +95 -0
- package/dist/bundle/chunk-AQZO3ITW.js +58 -0
- package/dist/bundle/chunk-B2WFKFYL.js +1488 -0
- package/dist/bundle/chunk-B2XKEEFX.js +230 -0
- package/dist/bundle/chunk-B4B65XIO.js +73 -0
- package/dist/bundle/chunk-BWICUW7W.js +288 -0
- package/dist/bundle/chunk-CLG2ISQH.js +206 -0
- package/dist/bundle/chunk-CWVAYQXI.js +185 -0
- package/dist/bundle/chunk-D72URWJE.js +532 -0
- package/dist/bundle/chunk-DFDN6AUB.js +21 -0
- package/dist/bundle/chunk-DIM5YWBU.js +53 -0
- package/dist/bundle/chunk-EGTBL3MJ.js +6848 -0
- package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
- package/dist/bundle/chunk-EPAZ7DJB.js +783 -0
- package/dist/bundle/chunk-ESZT4WW3.js +142 -0
- package/dist/bundle/chunk-EU5WCOMQ.js +4001 -0
- package/dist/bundle/chunk-F6MLJ3V5.js +72 -0
- package/dist/bundle/chunk-FF4DDBCB.js +1028 -0
- package/dist/bundle/chunk-GA3URWIF.js +46 -0
- package/dist/bundle/chunk-HRTIRRXR.js +3112 -0
- package/dist/bundle/chunk-HWRKURQH.js +54 -0
- package/dist/bundle/chunk-IQWEJEB5.js +39724 -0
- package/dist/bundle/chunk-JK44XO2S.js +392 -0
- package/dist/bundle/chunk-JKIN5TOU.js +131 -0
- package/dist/bundle/chunk-K5TWMQSY.js +188 -0
- package/dist/bundle/chunk-KHOVVPLC.js +18 -0
- package/dist/bundle/chunk-NLDYZBTC.js +5862 -0
- package/dist/bundle/chunk-OWJDC4CB.js +217 -0
- package/dist/bundle/chunk-QBC23NHD.js +38 -0
- package/dist/bundle/chunk-QC3KOJT4.js +300 -0
- package/dist/bundle/chunk-R6ZM45NF.js +1239 -0
- package/dist/bundle/chunk-RAZKIHGH.js +76 -0
- package/dist/bundle/chunk-RDZ7SVBZ.js +731 -0
- package/dist/bundle/chunk-RLSFOR2D.js +161 -0
- package/dist/bundle/chunk-RSIS7BR7.js +2778 -0
- package/dist/bundle/chunk-ST2UC7FS.js +1324 -0
- package/dist/bundle/chunk-TR7R5DL4.js +370 -0
- package/dist/bundle/chunk-TSCIIXN3.js +106 -0
- package/dist/bundle/chunk-UWIA2G6Q.js +12737 -0
- package/dist/bundle/chunk-UWW24JQF.js +66 -0
- package/dist/bundle/chunk-WK3OSDNV.js +1197 -0
- package/dist/bundle/chunk-WM7663C2.js +1221 -0
- package/dist/bundle/chunk-WVZFXI36.js +274 -0
- package/dist/bundle/chunk-WWMB4UHF.js +78 -0
- package/dist/bundle/chunk-XC5CKHX2.js +63 -0
- package/dist/bundle/chunk-XL2HXHP3.js +82 -0
- package/dist/bundle/chunk-XQUUANA2.js +24600 -0
- package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
- package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
- package/dist/bundle/chunk-YA4LSSDZ.js +64499 -0
- package/dist/bundle/chunk-ZI3YTXSF.js +2 -0
- package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
- package/dist/bundle/command-contract-6G5DC2FN.js +35 -0
- package/dist/bundle/command-server-entry-A66DJ3MH.js +164 -0
- package/dist/bundle/decode-7XOFRAAT.js +163 -0
- package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
- package/dist/bundle/dispatch-FEKU5UXC.js +411 -0
- package/dist/bundle/dist-YFKABFFF.js +7577 -0
- package/dist/bundle/echarts-XD2JSWU4.js +42501 -0
- package/dist/bundle/embed-F3HYGAF7.js +38 -0
- package/dist/bundle/embedder-GSEDDUH7.js +111 -0
- package/dist/bundle/failure-HDJLR2YJ.js +25 -0
- package/dist/bundle/first-run-TXNTIUSP.js +28 -0
- package/dist/bundle/first-screen-JZPJND7J.js +33 -0
- package/dist/bundle/instructions-NZGJ4FW5.js +11 -0
- package/dist/bundle/mcp-VFIOZDVY.js +167 -0
- package/dist/bundle/node-KM3CUABH.js +2340 -0
- package/dist/bundle/node-RPKPDYQS.js +176 -0
- package/dist/bundle/node-TLZSIHIJ.js +21 -0
- package/dist/bundle/node-sqlite-KH2UUYVO.js +74 -0
- package/dist/bundle/notion.js +185 -0
- package/dist/bundle/oauth-NKAI7TQD.js +20 -0
- package/dist/bundle/open-WSAEAA2V.js +23 -0
- package/dist/bundle/openai-JPVDGHG5.js +238 -0
- package/dist/bundle/process-5ZFVKOQX.js +91 -0
- package/dist/bundle/program-M3D56D6T.js +28854 -0
- package/dist/bundle/prompt-FROYQ5LV.js +17 -0
- package/dist/bundle/recognize-NYCHQMCX.js +26 -0
- package/dist/bundle/remote-4OERF3Z4.js +32 -0
- package/dist/bundle/rerank-TEGXFUWY.js +52 -0
- package/dist/bundle/schemas-MZNNOEYN.js +12214 -0
- package/dist/bundle/serve-HLYYBAXY.js +199 -0
- package/dist/bundle/server-D5OYNEUW.js +193 -0
- package/dist/bundle/server-LWZGVMNW.js +62 -0
- package/dist/bundle/sqlite-runtime-H2S5RR2F.js +20 -0
- package/dist/bundle/state-OPOXCDZL.js +36 -0
- package/dist/bundle/store-NHMXEJPD.js +164 -0
- package/dist/bundle/store-Y3KRLCJ7.js +281 -0
- package/dist/bundle/store-maintenance-command-D4W7WSLQ.js +53 -0
- package/dist/commands/api.d.ts +4 -0
- package/dist/commands/api.d.ts.map +1 -0
- package/dist/commands/api.js +140 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/comments.d.ts +3 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +114 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/databases.d.ts +3 -0
- package/dist/commands/databases.d.ts.map +1 -0
- package/dist/commands/databases.js +65 -0
- package/dist/commands/databases.js.map +1 -0
- package/dist/commands/documents.d.ts +3 -0
- package/dist/commands/documents.d.ts.map +1 -0
- package/dist/commands/documents.js +41 -0
- package/dist/commands/documents.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +104 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +46 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +58 -0
- package/dist/context.js.map +1 -0
- package/dist/generated/definitions.d.ts +3 -0
- package/dist/generated/definitions.d.ts.map +1 -0
- package/dist/generated/definitions.js +45603 -0
- package/dist/generated/definitions.js.map +1 -0
- package/dist/generated/manifest.d.ts +3 -0
- package/dist/generated/manifest.d.ts.map +1 -0
- package/dist/generated/manifest.js +2089 -0
- package/dist/generated/manifest.js.map +1 -0
- package/dist/generated/metadata.d.ts +6 -0
- package/dist/generated/metadata.d.ts.map +1 -0
- package/dist/generated/metadata.js +24 -0
- package/dist/generated/metadata.js.map +1 -0
- package/dist/generated/schemas.d.ts +1223 -0
- package/dist/generated/schemas.d.ts.map +1 -0
- package/dist/generated/schemas.js +11557 -0
- package/dist/generated/schemas.js.map +1 -0
- package/dist/generated/types.d.ts +11120 -0
- package/dist/generated/types.d.ts.map +1 -0
- package/dist/generated/types.js +5 -0
- package/dist/generated/types.js.map +1 -0
- package/dist/identity.d.ts +7 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +29 -0
- package/dist/identity.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/notion/client.d.ts +42 -0
- package/dist/notion/client.d.ts.map +1 -0
- package/dist/notion/client.js +118 -0
- package/dist/notion/client.js.map +1 -0
- package/dist/notion/errors.d.ts +24 -0
- package/dist/notion/errors.d.ts.map +1 -0
- package/dist/notion/errors.js +102 -0
- package/dist/notion/errors.js.map +1 -0
- package/dist/notion/ids.d.ts +7 -0
- package/dist/notion/ids.d.ts.map +1 -0
- package/dist/notion/ids.js +37 -0
- package/dist/notion/ids.js.map +1 -0
- package/dist/notion/links.d.ts +6 -0
- package/dist/notion/links.d.ts.map +1 -0
- package/dist/notion/links.js +22 -0
- package/dist/notion/links.js.map +1 -0
- package/dist/notion/notion.d.ts +95 -0
- package/dist/notion/notion.d.ts.map +1 -0
- package/dist/notion/notion.js +269 -0
- package/dist/notion/notion.js.map +1 -0
- package/dist/notion/port.d.ts +13 -0
- package/dist/notion/port.d.ts.map +1 -0
- package/dist/notion/port.js +60 -0
- package/dist/notion/port.js.map +1 -0
- package/dist/notion/read-posts.d.ts +36 -0
- package/dist/notion/read-posts.d.ts.map +1 -0
- package/dist/notion/read-posts.js +24 -0
- package/dist/notion/read-posts.js.map +1 -0
- package/dist/notion/reads.d.ts +327 -0
- package/dist/notion/reads.d.ts.map +1 -0
- package/dist/notion/reads.js +18 -0
- package/dist/notion/reads.js.map +1 -0
- package/dist/program.d.ts +6 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +62 -0
- package/dist/program.js.map +1 -0
- package/dist/sample/comments.d.ts +61 -0
- package/dist/sample/comments.d.ts.map +1 -0
- package/dist/sample/comments.js +39 -0
- package/dist/sample/comments.js.map +1 -0
- package/dist/sample/records.d.ts +16 -0
- package/dist/sample/records.d.ts.map +1 -0
- package/dist/sample/records.js +22 -0
- package/dist/sample/records.js.map +1 -0
- package/dist/sample/transport.d.ts +42 -0
- package/dist/sample/transport.d.ts.map +1 -0
- package/dist/sample/transport.js +153 -0
- package/dist/sample/transport.js.map +1 -0
- package/dist/sync/cursor.d.ts +54 -0
- package/dist/sync/cursor.d.ts.map +1 -0
- package/dist/sync/cursor.js +52 -0
- package/dist/sync/cursor.js.map +1 -0
- package/dist/sync/front-matter.d.ts +10 -0
- package/dist/sync/front-matter.d.ts.map +1 -0
- package/dist/sync/front-matter.js +114 -0
- package/dist/sync/front-matter.js.map +1 -0
- package/dist/sync/markdown.d.ts +8 -0
- package/dist/sync/markdown.d.ts.map +1 -0
- package/dist/sync/markdown.js +40 -0
- package/dist/sync/markdown.js.map +1 -0
- package/dist/sync/source.d.ts +64 -0
- package/dist/sync/source.d.ts.map +1 -0
- package/dist/sync/source.js +634 -0
- package/dist/sync/source.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +2 -0
- package/dist/version.js.map +1 -0
- package/dist/wcat.d.ts +3 -0
- package/dist/wcat.d.ts.map +1 -0
- package/dist/wcat.js +4 -0
- package/dist/wcat.js.map +1 -0
- package/package.json +85 -4
- package/skills/notion-cli/SKILL.md +34 -0
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reads the incremental sync needs from Notion, and nothing more. The real client implements it; the sync's tests
|
|
3
|
+
* implement it with a strict fake. Shapes are the subset of Notion's own JSON (API version 2026-03-11) the sync reads,
|
|
4
|
+
* so an implementation passes Notion's answers through instead of converting them.
|
|
5
|
+
*
|
|
6
|
+
* Errors, after the implementation's own retries and pacing:
|
|
7
|
+
* - `CliError("not_found")` for 404 `object_not_found`: deleted for good, or not shared with this token. Notion does
|
|
8
|
+
* not say which, and the sync treats both as gone.
|
|
9
|
+
* - `CliError("permission_error")` for 403 `restricted_resource`.
|
|
10
|
+
* - `CliError("rate_limited", …, { retry_after_ms })` for a 429 or 529 the implementation stopped retrying.
|
|
11
|
+
* - `CliError("validation_error")` for a 400, for example a start cursor Notion no longer accepts.
|
|
12
|
+
* - A list answer cut at Notion's 10,000-result cap carries `request_status.type: "incomplete"`; search too.
|
|
13
|
+
*
|
|
14
|
+
* Endpoint pages: https://developers.notion.com/reference/post-search, /query-a-data-source, /retrieve-a-page,
|
|
15
|
+
* /retrieve-a-database, /retrieve-a-block, /get-block-children, /retrieve-page-markdown, /get-self.
|
|
16
|
+
*/
|
|
17
|
+
export interface NotionUser {
|
|
18
|
+
object: "user";
|
|
19
|
+
id: string;
|
|
20
|
+
/** Partial users carry only the id. */
|
|
21
|
+
name?: string | null;
|
|
22
|
+
}
|
|
23
|
+
export type NotionParent = {
|
|
24
|
+
type: "workspace";
|
|
25
|
+
workspace: true;
|
|
26
|
+
} | {
|
|
27
|
+
type: "page_id";
|
|
28
|
+
page_id: string;
|
|
29
|
+
} | {
|
|
30
|
+
type: "data_source_id";
|
|
31
|
+
data_source_id: string;
|
|
32
|
+
database_id: string;
|
|
33
|
+
} | {
|
|
34
|
+
type: "database_id";
|
|
35
|
+
database_id: string;
|
|
36
|
+
} | {
|
|
37
|
+
type: "block_id";
|
|
38
|
+
block_id: string;
|
|
39
|
+
};
|
|
40
|
+
export interface NotionRichText {
|
|
41
|
+
plain_text: string;
|
|
42
|
+
href?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export interface NotionDate {
|
|
45
|
+
start: string;
|
|
46
|
+
end?: string | null;
|
|
47
|
+
time_zone?: string | null;
|
|
48
|
+
}
|
|
49
|
+
interface NotionFileValue {
|
|
50
|
+
name: string;
|
|
51
|
+
type?: "file" | "external" | "file_upload";
|
|
52
|
+
file?: {
|
|
53
|
+
url: string;
|
|
54
|
+
expiry_time?: string;
|
|
55
|
+
};
|
|
56
|
+
external?: {
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A value as a page or a query row carries it (https://developers.notion.com/reference/page-property-values). Notion
|
|
62
|
+
* adds types over time, so a reader must expect a `type` outside this list and skip it.
|
|
63
|
+
*/
|
|
64
|
+
export type NotionPropertyValue = {
|
|
65
|
+
id?: string;
|
|
66
|
+
} & ({
|
|
67
|
+
type: "title";
|
|
68
|
+
title: NotionRichText[];
|
|
69
|
+
} | {
|
|
70
|
+
type: "rich_text";
|
|
71
|
+
rich_text: NotionRichText[];
|
|
72
|
+
} | {
|
|
73
|
+
type: "number";
|
|
74
|
+
number: number | null;
|
|
75
|
+
} | {
|
|
76
|
+
type: "select";
|
|
77
|
+
select: {
|
|
78
|
+
name: string;
|
|
79
|
+
} | null;
|
|
80
|
+
} | {
|
|
81
|
+
type: "status";
|
|
82
|
+
status: {
|
|
83
|
+
name: string;
|
|
84
|
+
} | null;
|
|
85
|
+
} | {
|
|
86
|
+
type: "multi_select";
|
|
87
|
+
multi_select: {
|
|
88
|
+
name: string;
|
|
89
|
+
}[];
|
|
90
|
+
} | {
|
|
91
|
+
type: "date";
|
|
92
|
+
date: NotionDate | null;
|
|
93
|
+
} | {
|
|
94
|
+
type: "people";
|
|
95
|
+
people: NotionUser[];
|
|
96
|
+
} | {
|
|
97
|
+
type: "files";
|
|
98
|
+
files: NotionFileValue[];
|
|
99
|
+
} | {
|
|
100
|
+
type: "checkbox";
|
|
101
|
+
checkbox: boolean;
|
|
102
|
+
} | {
|
|
103
|
+
type: "url";
|
|
104
|
+
url: string | null;
|
|
105
|
+
} | {
|
|
106
|
+
type: "email";
|
|
107
|
+
email: string | null;
|
|
108
|
+
} | {
|
|
109
|
+
type: "phone_number";
|
|
110
|
+
phone_number: string | null;
|
|
111
|
+
} | {
|
|
112
|
+
type: "formula";
|
|
113
|
+
formula: NotionFormula;
|
|
114
|
+
} | {
|
|
115
|
+
type: "relation";
|
|
116
|
+
relation: {
|
|
117
|
+
id: string;
|
|
118
|
+
}[];
|
|
119
|
+
has_more?: boolean;
|
|
120
|
+
} | {
|
|
121
|
+
type: "rollup";
|
|
122
|
+
rollup: NotionRollup;
|
|
123
|
+
} | {
|
|
124
|
+
type: "created_time";
|
|
125
|
+
created_time: string;
|
|
126
|
+
} | {
|
|
127
|
+
type: "last_edited_time";
|
|
128
|
+
last_edited_time: string;
|
|
129
|
+
} | {
|
|
130
|
+
type: "created_by";
|
|
131
|
+
created_by: NotionUser;
|
|
132
|
+
} | {
|
|
133
|
+
type: "last_edited_by";
|
|
134
|
+
last_edited_by: NotionUser;
|
|
135
|
+
} | {
|
|
136
|
+
type: "unique_id";
|
|
137
|
+
unique_id: {
|
|
138
|
+
number: number | null;
|
|
139
|
+
prefix: string | null;
|
|
140
|
+
};
|
|
141
|
+
} | {
|
|
142
|
+
type: "verification";
|
|
143
|
+
verification: {
|
|
144
|
+
state: string;
|
|
145
|
+
verified_by?: NotionUser | null;
|
|
146
|
+
} | null;
|
|
147
|
+
} | {
|
|
148
|
+
type: "place";
|
|
149
|
+
place: {
|
|
150
|
+
name?: string | null;
|
|
151
|
+
address?: string | null;
|
|
152
|
+
} | null;
|
|
153
|
+
} | {
|
|
154
|
+
type: "button";
|
|
155
|
+
button: Record<string, never>;
|
|
156
|
+
});
|
|
157
|
+
export type NotionFormula = {
|
|
158
|
+
type: "string";
|
|
159
|
+
string: string | null;
|
|
160
|
+
} | {
|
|
161
|
+
type: "number";
|
|
162
|
+
number: number | null;
|
|
163
|
+
} | {
|
|
164
|
+
type: "boolean";
|
|
165
|
+
boolean: boolean | null;
|
|
166
|
+
} | {
|
|
167
|
+
type: "date";
|
|
168
|
+
date: NotionDate | null;
|
|
169
|
+
};
|
|
170
|
+
export type NotionRollup = {
|
|
171
|
+
type: "number";
|
|
172
|
+
number: number | null;
|
|
173
|
+
} | {
|
|
174
|
+
type: "date";
|
|
175
|
+
date: NotionDate | null;
|
|
176
|
+
} | {
|
|
177
|
+
type: "array";
|
|
178
|
+
array: NotionPropertyValue[];
|
|
179
|
+
} | {
|
|
180
|
+
type: "incomplete" | "unsupported";
|
|
181
|
+
};
|
|
182
|
+
export interface NotionPage {
|
|
183
|
+
object: "page";
|
|
184
|
+
id: string;
|
|
185
|
+
created_time: string;
|
|
186
|
+
/** Notion rounds it to the minute (not checked live). */
|
|
187
|
+
last_edited_time: string;
|
|
188
|
+
created_by?: NotionUser;
|
|
189
|
+
last_edited_by?: NotionUser;
|
|
190
|
+
in_trash: boolean;
|
|
191
|
+
parent: NotionParent;
|
|
192
|
+
url: string;
|
|
193
|
+
properties: Record<string, NotionPropertyValue>;
|
|
194
|
+
}
|
|
195
|
+
export interface NotionDataSource {
|
|
196
|
+
object: "data_source";
|
|
197
|
+
id: string;
|
|
198
|
+
/** An externally synced source can sit under another source; both forms name the database. */
|
|
199
|
+
parent: {
|
|
200
|
+
type: "database_id";
|
|
201
|
+
database_id: string;
|
|
202
|
+
} | {
|
|
203
|
+
type: "data_source_id";
|
|
204
|
+
data_source_id: string;
|
|
205
|
+
database_id: string;
|
|
206
|
+
};
|
|
207
|
+
last_edited_time: string;
|
|
208
|
+
in_trash: boolean;
|
|
209
|
+
}
|
|
210
|
+
export interface NotionDatabase {
|
|
211
|
+
object: "database";
|
|
212
|
+
id: string;
|
|
213
|
+
title: NotionRichText[];
|
|
214
|
+
parent: NotionParent;
|
|
215
|
+
created_time: string;
|
|
216
|
+
last_edited_time: string;
|
|
217
|
+
in_trash: boolean;
|
|
218
|
+
url: string;
|
|
219
|
+
data_sources: {
|
|
220
|
+
id: string;
|
|
221
|
+
name: string;
|
|
222
|
+
}[];
|
|
223
|
+
}
|
|
224
|
+
export interface NotionBlock {
|
|
225
|
+
object: "block";
|
|
226
|
+
id: string;
|
|
227
|
+
type: string;
|
|
228
|
+
has_children: boolean;
|
|
229
|
+
in_trash?: boolean;
|
|
230
|
+
parent: NotionParent;
|
|
231
|
+
child_page?: {
|
|
232
|
+
title: string;
|
|
233
|
+
};
|
|
234
|
+
child_database?: {
|
|
235
|
+
title: string;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
export interface NotionList<T> {
|
|
239
|
+
results: T[];
|
|
240
|
+
next_cursor: string | null;
|
|
241
|
+
has_more: boolean;
|
|
242
|
+
/** `incomplete` on every page of a query Notion cut at 10,000 results. */
|
|
243
|
+
request_status?: {
|
|
244
|
+
type: "complete" | "incomplete";
|
|
245
|
+
incomplete_reason?: string;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
export interface NotionSearchRequest {
|
|
249
|
+
filter: {
|
|
250
|
+
property: "object";
|
|
251
|
+
value: "page" | "data_source";
|
|
252
|
+
};
|
|
253
|
+
sort: {
|
|
254
|
+
timestamp: "last_edited_time";
|
|
255
|
+
direction: "ascending" | "descending";
|
|
256
|
+
};
|
|
257
|
+
start_cursor?: string;
|
|
258
|
+
page_size?: number;
|
|
259
|
+
}
|
|
260
|
+
export type NotionTimestampFilter = {
|
|
261
|
+
timestamp: "last_edited_time";
|
|
262
|
+
last_edited_time: {
|
|
263
|
+
on_or_after: string;
|
|
264
|
+
};
|
|
265
|
+
} | {
|
|
266
|
+
timestamp: "created_time";
|
|
267
|
+
created_time: {
|
|
268
|
+
on_or_after: string;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
export interface NotionQueryRequest {
|
|
272
|
+
filter?: NotionTimestampFilter | {
|
|
273
|
+
and: NotionTimestampFilter[];
|
|
274
|
+
};
|
|
275
|
+
sorts?: {
|
|
276
|
+
timestamp: "created_time" | "last_edited_time";
|
|
277
|
+
direction: "ascending" | "descending";
|
|
278
|
+
}[];
|
|
279
|
+
start_cursor?: string;
|
|
280
|
+
page_size?: number;
|
|
281
|
+
}
|
|
282
|
+
export interface NotionPageMarkdown {
|
|
283
|
+
/** Markdown v2 (`markdown_version=v2`). */
|
|
284
|
+
markdown: string;
|
|
285
|
+
truncated: boolean;
|
|
286
|
+
/** Truncated and unshared blocks alike; a re-fetch of an unshared one is a 404. */
|
|
287
|
+
unknown_block_ids: string[];
|
|
288
|
+
}
|
|
289
|
+
/** The token's bot user; a personal access token has one too, owned by the person who made it. */
|
|
290
|
+
export interface NotionSelf {
|
|
291
|
+
object: "user";
|
|
292
|
+
id: string;
|
|
293
|
+
type: "bot" | "person";
|
|
294
|
+
name?: string | null;
|
|
295
|
+
bot?: {
|
|
296
|
+
workspace_id?: string;
|
|
297
|
+
workspace_name?: string | null;
|
|
298
|
+
owner?: {
|
|
299
|
+
type: "workspace" | "user";
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
export interface NotionReads {
|
|
304
|
+
/** `GET /v1/users/me`. */
|
|
305
|
+
self(): Promise<NotionSelf>;
|
|
306
|
+
/** `POST /v1/search`, without a text query. */
|
|
307
|
+
search(request: NotionSearchRequest): Promise<NotionList<NotionPage | NotionDataSource>>;
|
|
308
|
+
/** `POST /v1/data_sources/{id}/query`. */
|
|
309
|
+
queryDataSource(id: string, request: NotionQueryRequest): Promise<NotionList<NotionPage>>;
|
|
310
|
+
/** `GET /v1/pages/{id}`. A trashed page answers with `in_trash: true`. */
|
|
311
|
+
retrievePage(id: string): Promise<NotionPage>;
|
|
312
|
+
/** `GET /v1/databases/{id}`, with its data sources. */
|
|
313
|
+
retrieveDatabase(id: string): Promise<NotionDatabase>;
|
|
314
|
+
/** `GET /v1/blocks/{id}`, to climb from a page whose parent is a block to the page that holds it. */
|
|
315
|
+
retrieveBlock(id: string): Promise<NotionBlock>;
|
|
316
|
+
/** `GET /v1/blocks/{id}/children`, one page of up to 100. */
|
|
317
|
+
blockChildren(id: string, startCursor?: string): Promise<NotionList<NotionBlock>>;
|
|
318
|
+
/** `GET /v1/pages/{id}/markdown?markdown_version=v2`; a block id fetches that block's subtree. */
|
|
319
|
+
pageMarkdown(id: string): Promise<NotionPageMarkdown>;
|
|
320
|
+
/**
|
|
321
|
+
* Notion's clock: the `Date` header of its latest answer, in milliseconds, or undefined before any answer. Not a
|
|
322
|
+
* request. The sync compares Notion's timestamps with it, never with this computer's clock.
|
|
323
|
+
*/
|
|
324
|
+
serverTime?(): number | undefined;
|
|
325
|
+
}
|
|
326
|
+
export {};
|
|
327
|
+
//# sourceMappingURL=reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.d.ts","sourceRoot":"","sources":["../../src/notion/reads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,uCAAuC;IACvC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CACrB;AAED,MAAM,MAAM,YAAY,GACpB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,gBAAgB,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAE1C,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAA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AE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;IAC/C,6DAA6D;IAC7D,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAA;IACjF,kGAAkG;IAClG,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;IACrD;;;OAGG;IACH,UAAU,CAAC,IAAI,MAAM,GAAG,SAAS,CAAA;CAClC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reads the incremental sync needs from Notion, and nothing more. The real client implements it; the sync's tests
|
|
3
|
+
* implement it with a strict fake. Shapes are the subset of Notion's own JSON (API version 2026-03-11) the sync reads,
|
|
4
|
+
* so an implementation passes Notion's answers through instead of converting them.
|
|
5
|
+
*
|
|
6
|
+
* Errors, after the implementation's own retries and pacing:
|
|
7
|
+
* - `CliError("not_found")` for 404 `object_not_found`: deleted for good, or not shared with this token. Notion does
|
|
8
|
+
* not say which, and the sync treats both as gone.
|
|
9
|
+
* - `CliError("permission_error")` for 403 `restricted_resource`.
|
|
10
|
+
* - `CliError("rate_limited", …, { retry_after_ms })` for a 429 or 529 the implementation stopped retrying.
|
|
11
|
+
* - `CliError("validation_error")` for a 400, for example a start cursor Notion no longer accepts.
|
|
12
|
+
* - A list answer cut at Notion's 10,000-result cap carries `request_status.type: "incomplete"`; search too.
|
|
13
|
+
*
|
|
14
|
+
* Endpoint pages: https://developers.notion.com/reference/post-search, /query-a-data-source, /retrieve-a-page,
|
|
15
|
+
* /retrieve-a-database, /retrieve-a-block, /get-block-children, /retrieve-page-markdown, /get-self.
|
|
16
|
+
*/
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=reads.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reads.js","sourceRoot":"","sources":["../../src/notion/reads.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ProgramDefinition, type ProgramOptions, type RunOptions } from "@wirecat/cli-core/cli";
|
|
2
|
+
import type { Command } from "commander";
|
|
3
|
+
export declare const definition: () => ProgramDefinition;
|
|
4
|
+
export declare const createProgram: (options?: ProgramOptions) => Command;
|
|
5
|
+
export declare const run: (argv: string[], options?: RunOptions) => Promise<number>;
|
|
6
|
+
//# sourceMappingURL=program.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"program.d.ts","sourceRoot":"","sources":["../src/program.ts"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,UAAU,EAKhB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAuCxC,eAAO,MAAM,UAAU,QAAO,iBAsB5B,CAAA;AAEF,eAAO,MAAM,aAAa,aAAc,cAAc,KAAG,OAAqD,CAAA;AAE9G,eAAO,MAAM,GAAG,SAAU,MAAM,EAAE,YAAY,UAAU,KAAG,OAAO,CAAC,MAAM,CAA2C,CAAA"}
|
package/dist/program.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { resolvePaths } from "@wirecat/cli-base";
|
|
3
|
+
import { appDoctorCommand, appMcpCommand, commandsCommand, configCommand, createProgram as createSharedProgram, outputFor, ProfileTokenStore, run as runShared, runsCommand, skillCommand, upgradeCommand, } from "@wirecat/cli-core/cli";
|
|
4
|
+
import { appUpdate } from "@wirecat/cli-core/update";
|
|
5
|
+
import { apiCommand } from "./commands/api.js";
|
|
6
|
+
import { databasesCommand } from "./commands/databases.js";
|
|
7
|
+
import { documentsCommand } from "./commands/documents.js";
|
|
8
|
+
import { sessionCommand } from "./commands/session.js";
|
|
9
|
+
import { configuration } from "./config.js";
|
|
10
|
+
import { IDENTITY, PACKAGE, SKILL } from "./identity.js";
|
|
11
|
+
const update = appUpdate({
|
|
12
|
+
packageName: PACKAGE,
|
|
13
|
+
command: IDENTITY.command,
|
|
14
|
+
version: IDENTITY.version,
|
|
15
|
+
entry: import.meta.url,
|
|
16
|
+
statePath: (env) => join(resolvePaths({ appName: IDENTITY.appName, prefix: IDENTITY.envPrefix, env }).state, "update-check.json"),
|
|
17
|
+
// biome-ignore lint/plugin/no-own-settings: the update check runs before any command exists to give baseContext
|
|
18
|
+
enabled: (env) => configuration.resolveSettings({}, { env, needsProfile: false }).updateCheck,
|
|
19
|
+
offVariables: [`${IDENTITY.envPrefix}_NO_UPDATE_CHECK`],
|
|
20
|
+
});
|
|
21
|
+
const mcpCommand = () => appMcpCommand(IDENTITY, configuration, {
|
|
22
|
+
name: "Notion",
|
|
23
|
+
// Pages and databases are shared: other members write their text, titles and options (WC-MCP-11).
|
|
24
|
+
untrusted: [
|
|
25
|
+
"page text",
|
|
26
|
+
"page and database titles",
|
|
27
|
+
"database descriptions",
|
|
28
|
+
"property names and options",
|
|
29
|
+
"links",
|
|
30
|
+
"comment text",
|
|
31
|
+
"author names",
|
|
32
|
+
],
|
|
33
|
+
permissionExample: "documents.get=deny",
|
|
34
|
+
skill: SKILL,
|
|
35
|
+
signedIn: (profile, env, keyring) => new ProfileTokenStore({ app: IDENTITY, env, ...(keyring ? { keyring } : {}) }).signedIn(profile),
|
|
36
|
+
});
|
|
37
|
+
export const definition = () => ({
|
|
38
|
+
app: IDENTITY,
|
|
39
|
+
// The whole object: cli-core refuses a command by its key only when it gets the permission table too.
|
|
40
|
+
configuration,
|
|
41
|
+
commands: () => [
|
|
42
|
+
commandsCommand(IDENTITY),
|
|
43
|
+
sessionCommand(),
|
|
44
|
+
documentsCommand(),
|
|
45
|
+
databasesCommand(),
|
|
46
|
+
apiCommand(),
|
|
47
|
+
appDoctorCommand(IDENTITY, configuration, { packageName: PACKAGE }),
|
|
48
|
+
skillCommand(IDENTITY, SKILL),
|
|
49
|
+
mcpCommand(),
|
|
50
|
+
upgradeCommand(IDENTITY, PACKAGE, (command) => ({
|
|
51
|
+
...outputFor(command),
|
|
52
|
+
installer: () => update.installer({}),
|
|
53
|
+
latest: () => update.latest({}),
|
|
54
|
+
install: (argv) => update.runUpdate(argv, {}),
|
|
55
|
+
})),
|
|
56
|
+
configCommand(IDENTITY, configuration),
|
|
57
|
+
runsCommand(IDENTITY),
|
|
58
|
+
],
|
|
59
|
+
});
|
|
60
|
+
export const createProgram = (options) => createSharedProgram(definition(), options);
|
|
61
|
+
export const run = (argv, options) => runShared(argv, definition(), options);
|
|
62
|
+
//# sourceMappingURL=program.js.map
|
|
@@ -0,0 +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,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAExD,MAAM,MAAM,GAAG,SAAS,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EAAE,QAAQ;IACb,sGAAsG;IACtG,aAAa;IACb,QAAQ,EAAE,GAAG,EAAE,CAAC;QACd,eAAe,CAAC,QAAQ,CAAC;QACzB,cAAc,EAAE;QAChB,gBAAgB,EAAE;QAClB,gBAAgB,EAAE;QAClB,UAAU,EAAE;QACZ,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;QACnE,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC;QAC7B,UAAU,EAAE;QACZ,cAAc,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;YAC9C,GAAG,SAAS,CAAC,OAAO,CAAC;YACrB,SAAS,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YACrC,MAAM,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC;SAC9C,CAAC,CAAC;QACH,aAAa,CAAC,QAAQ,EAAE,aAAa,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"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import type { Transport } from "./transport.js";
|
|
3
|
+
declare const wireComment: v.ObjectSchema<{
|
|
4
|
+
readonly id: v.StringSchema<undefined>;
|
|
5
|
+
readonly body: v.StringSchema<undefined>;
|
|
6
|
+
readonly authorName: v.StringSchema<undefined>;
|
|
7
|
+
readonly createdAt: v.StringSchema<undefined>;
|
|
8
|
+
}, undefined>;
|
|
9
|
+
/**
|
|
10
|
+
* The answer's own shape, in snake_case (WC-OUT-12). `answerEntity` publishes it, so `--json=id,text` and the MCP
|
|
11
|
+
* schema both come from here (WC-CMD-19). No wire type leaves this file (WC-ARCH-3).
|
|
12
|
+
*/
|
|
13
|
+
export declare const commentSchema: v.StrictObjectSchema<{
|
|
14
|
+
readonly id: v.StringSchema<undefined>;
|
|
15
|
+
readonly text: v.StringSchema<undefined>;
|
|
16
|
+
readonly author: v.StringSchema<undefined>;
|
|
17
|
+
readonly created_at: v.StringSchema<undefined>;
|
|
18
|
+
}, undefined>;
|
|
19
|
+
export type Comment = v.InferOutput<typeof commentSchema>;
|
|
20
|
+
export declare const commentOf: (wire: v.InferOutput<typeof wireComment>) => Comment;
|
|
21
|
+
/** Every call the sample makes: a method, a path template and only the fields the service documents. */
|
|
22
|
+
export declare const commentsService: (api: Transport) => {
|
|
23
|
+
me: () => Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
}>;
|
|
27
|
+
list: ({ limit, offset, author }: {
|
|
28
|
+
limit: number;
|
|
29
|
+
offset: number;
|
|
30
|
+
author?: string | undefined;
|
|
31
|
+
}) => Promise<{
|
|
32
|
+
items: {
|
|
33
|
+
id: string;
|
|
34
|
+
text: string;
|
|
35
|
+
author: string;
|
|
36
|
+
created_at: string;
|
|
37
|
+
}[];
|
|
38
|
+
hasMore: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
show: (id: string) => Promise<{
|
|
41
|
+
id: string;
|
|
42
|
+
text: string;
|
|
43
|
+
author: string;
|
|
44
|
+
created_at: string;
|
|
45
|
+
}>;
|
|
46
|
+
create: (text: string) => Promise<{
|
|
47
|
+
id: string;
|
|
48
|
+
text: string;
|
|
49
|
+
author: string;
|
|
50
|
+
created_at: string;
|
|
51
|
+
}>;
|
|
52
|
+
update: (id: string, text: string) => Promise<{
|
|
53
|
+
id: string;
|
|
54
|
+
text: string;
|
|
55
|
+
author: string;
|
|
56
|
+
created_at: string;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
export type CommentsService = ReturnType<typeof commentsService>;
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/sample/comments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAI/C,QAAA,MAAM,WAAW;;;;;aAKf,CAAA;AAIF;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;aAKxB,CAAA;AACF,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,aAAa,CAAC,CAAA;AAEzD,eAAO,MAAM,SAAS,SAAU,CAAC,CAAC,WAAW,CAAC,OAAO,WAAW,CAAC,KAAG,OAKlE,CAAA;AAEF,wGAAwG;AACxG,eAAO,MAAM,eAAe,QAAS,SAAS;IAC5C,EAAE;;;;IACF,IAAI,8BAAoC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;;;;;;;;;IAItG,IAAI,OAAa,MAAM;;;;;;IAEvB,MAAM,SAAe,MAAM;;;;;;IAE3B,MAAM,OAAa,MAAM,QAAQ,MAAM;;;;;;CAIvC,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
// SAMPLE: replace these shapes with your service's. Each wire name comes from the service's docs or a captured answer,
|
|
3
|
+
// never from memory; the strict fake in src/testing/fake-comments.ts refuses any other.
|
|
4
|
+
const wireComment = v.object({
|
|
5
|
+
id: v.string(),
|
|
6
|
+
body: v.string(),
|
|
7
|
+
authorName: v.string(),
|
|
8
|
+
createdAt: v.string(),
|
|
9
|
+
});
|
|
10
|
+
const wirePage = v.object({ comments: v.array(wireComment), hasMore: v.boolean() });
|
|
11
|
+
const wireUser = v.object({ id: v.string(), name: v.string() });
|
|
12
|
+
/**
|
|
13
|
+
* The answer's own shape, in snake_case (WC-OUT-12). `answerEntity` publishes it, so `--json=id,text` and the MCP
|
|
14
|
+
* schema both come from here (WC-CMD-19). No wire type leaves this file (WC-ARCH-3).
|
|
15
|
+
*/
|
|
16
|
+
export const commentSchema = v.strictObject({
|
|
17
|
+
id: v.string(),
|
|
18
|
+
text: v.string(),
|
|
19
|
+
author: v.string(),
|
|
20
|
+
created_at: v.string(),
|
|
21
|
+
});
|
|
22
|
+
export const commentOf = (wire) => ({
|
|
23
|
+
id: wire.id,
|
|
24
|
+
text: wire.body,
|
|
25
|
+
author: wire.authorName,
|
|
26
|
+
created_at: wire.createdAt,
|
|
27
|
+
});
|
|
28
|
+
/** Every call the sample makes: a method, a path template and only the fields the service documents. */
|
|
29
|
+
export const commentsService = (api) => ({
|
|
30
|
+
me: () => api.send({ method: "GET", path: "me" }, wireUser),
|
|
31
|
+
list: async ({ limit, offset, author }) => {
|
|
32
|
+
const page = await api.send({ method: "GET", path: "comments", query: { limit, offset, by: author } }, wirePage);
|
|
33
|
+
return { items: page.comments.map(commentOf), hasMore: page.hasMore };
|
|
34
|
+
},
|
|
35
|
+
show: async (id) => commentOf(await api.send({ method: "GET", path: "comments/{id}", ids: { id } }, wireComment)),
|
|
36
|
+
create: async (text) => commentOf(await api.send({ method: "POST", path: "comments", body: { body: text } }, wireComment)),
|
|
37
|
+
update: async (id, text) => commentOf(await api.send({ method: "PATCH", path: "comments/{id}", ids: { id }, body: { body: text } }, wireComment)),
|
|
38
|
+
});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,OAAO,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,WAAW,CAAC,CAC3G;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type IngestReceipt } from "@wirecat/cli-core/services";
|
|
2
|
+
import type { MessageStore } from "@wirecat/cli-core/store";
|
|
3
|
+
import type { Comment } from "./comments.js";
|
|
4
|
+
export interface RecordsSource {
|
|
5
|
+
provider: string;
|
|
6
|
+
account: string;
|
|
7
|
+
batchId: string;
|
|
8
|
+
}
|
|
9
|
+
/** The JSONL a records import reads, ready for a file or stdout: the header line, then one record per line. */
|
|
10
|
+
export declare function commentLines(source: RecordsSource, comments: AsyncIterable<Comment> | Iterable<Comment>): AsyncGenerator<string, void, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* Takes a JSONL file or stdin into the shared store one line at a time, so memory does not grow with the file. The
|
|
13
|
+
* header's `source.account` must be `account`, or every record is refused.
|
|
14
|
+
*/
|
|
15
|
+
export declare const importRecords: (store: Pick<MessageStore, "records">, input: NodeJS.ReadableStream, account: string) => Promise<IngestReceipt>;
|
|
16
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../../src/sample/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAA2B,MAAM,4BAA4B,CAAA;AACxF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAM5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,+GAA+G;AAC/G,wBAAuB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,CAAC,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,yCAa9G;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,UACjB,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,SAC7B,MAAM,CAAC,cAAc,WACnB,MAAM,KACd,OAAO,CAAC,aAAa,CAAuD,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ingestLines, jsonlLines } from "@wirecat/cli-core/services";
|
|
2
|
+
/** The JSONL a records import reads, ready for a file or stdout: the header line, then one record per line. */
|
|
3
|
+
export async function* commentLines(source, comments) {
|
|
4
|
+
yield `${JSON.stringify({
|
|
5
|
+
schema_version: 1,
|
|
6
|
+
source: { provider: source.provider, account: source.account, batch_id: source.batchId },
|
|
7
|
+
})}\n`;
|
|
8
|
+
for await (const comment of comments)
|
|
9
|
+
yield `${JSON.stringify({
|
|
10
|
+
key: comment.id,
|
|
11
|
+
type: "custom:comment",
|
|
12
|
+
external_id: comment.id,
|
|
13
|
+
operation: "upsert",
|
|
14
|
+
fields: { text: comment.text, author: comment.author, created_at: comment.created_at },
|
|
15
|
+
})}\n`;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Takes a JSONL file or stdin into the shared store one line at a time, so memory does not grow with the file. The
|
|
19
|
+
* header's `source.account` must be `account`, or every record is refused.
|
|
20
|
+
*/
|
|
21
|
+
export const importRecords = (store, input, account) => ingestLines(store, jsonlLines(input), { account });
|
|
22
|
+
//# sourceMappingURL=records.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.js","sourceRoot":"","sources":["../../src/sample/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,WAAW,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAcxF,+GAA+G;AAC/G,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,YAAY,CAAC,MAAqB,EAAE,QAAoD;IAC7G,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;QACtB,cAAc,EAAE,CAAC;QACjB,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,OAAO,EAAE;KACzF,CAAC,IAAI,CAAA;IACN,IAAI,KAAK,EAAE,MAAM,OAAO,IAAI,QAAQ;QAClC,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC;YACtB,GAAG,EAAE,OAAO,CAAC,EAAE;YACf,IAAI,EAAE,gBAAgB;YACtB,WAAW,EAAE,OAAO,CAAC,EAAE;YACvB,SAAS,EAAE,QAAQ;YACnB,MAAM,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE;SACvF,CAAC,IAAI,CAAA;AACV,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAoC,EACpC,KAA4B,EAC5B,OAAe,EACS,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CliError, type SleepLike } from "@wirecat/cli-base";
|
|
2
|
+
import { type EventSink } from "@wirecat/cli-core/cli";
|
|
3
|
+
import type { Pacer } from "@wirecat/cli-core/sends";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
export declare const SERVICE_URL = "https://comments.example.invalid/v1/";
|
|
6
|
+
export declare const SERVICE = "Example Comments";
|
|
7
|
+
export interface Request {
|
|
8
|
+
method: "GET" | "POST" | "PATCH";
|
|
9
|
+
/** The path as a template, `comments/{id}`: the run record keeps the template, never an id. */
|
|
10
|
+
path: string;
|
|
11
|
+
ids?: Record<string, string>;
|
|
12
|
+
query?: Record<string, string | number | undefined>;
|
|
13
|
+
body?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface TransportOptions {
|
|
16
|
+
token: string;
|
|
17
|
+
fetch?: typeof fetch;
|
|
18
|
+
signal?: AbortSignal | undefined;
|
|
19
|
+
/** The run's sink from `baseContext(...).run(events => …)`, so each request lands in the run record (WC-LIFE-15). */
|
|
20
|
+
events?: EventSink;
|
|
21
|
+
/** cli-core's per-profile pace, shared by every process of the profile through a file. */
|
|
22
|
+
pacer?: Pacer;
|
|
23
|
+
sleep?: SleepLike;
|
|
24
|
+
now?: () => number;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A refusal as a CliError with cli-base's code for its status. The service's own message is never repeated: it can
|
|
29
|
+
* quote what was sent (WC-SECR-6). A write that failed on the service's side may have happened, so it is
|
|
30
|
+
* `outcome_unknown` and never retryable (WC-OUT-20, WC-LIFE-9).
|
|
31
|
+
*/
|
|
32
|
+
export declare const failureOf: (status: number, writes: boolean, retryAfterMs?: number) => CliError;
|
|
33
|
+
/**
|
|
34
|
+
* The only code that holds the token: it goes in the Authorization header, never in an address, an error or a run
|
|
35
|
+
* record (WC-SECR-7). Nothing here retries. A read the caller may run again; a write is never sent twice, since the
|
|
36
|
+
* first may have landed (WC-OUT-20).
|
|
37
|
+
*/
|
|
38
|
+
export declare const transport: (options: TransportOptions) => {
|
|
39
|
+
send: <T>(request: Request, answer: v.GenericSchema<unknown, T>) => Promise<T>;
|
|
40
|
+
};
|
|
41
|
+
export type Transport = ReturnType<typeof transport>;
|
|
42
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/sample/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,KAAK,SAAS,EAAa,MAAM,mBAAmB,CAAA;AAE9F,OAAO,EAAE,KAAK,SAAS,EA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