@wirecat/notion-cli 0.3.0 → 0.5.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 +48 -0
- package/README.md +3 -0
- package/contracts/wirecat.json +49 -0
- package/dist/bin/notion.js +2 -2
- package/dist/bundle/{all-profiles-4IONYZB6.js → all-profiles-V37KCXH3.js} +9 -9
- package/dist/bundle/{anthropic-OXF74J4P.js → anthropic-Q4S3BYXD.js} +5 -5
- package/dist/bundle/{app-server-M2VF6ABM.js → app-server-43SR3ACI.js} +54 -54
- package/dist/bundle/{bun-DLA6QRLL.js → bun-M3J2QTR3.js} +2 -2
- package/dist/bundle/{bun-sqlite-F4BYLW3F.js → bun-sqlite-EJ3W2PSV.js} +6 -6
- package/dist/bundle/{chunk-7NGFGFE5.js → chunk-2FJNMADN.js} +7 -7
- package/dist/bundle/{chunk-RMJMID5D.js → chunk-3RL2MIUF.js} +8 -8
- package/dist/bundle/{chunk-GCCPFKSU.js → chunk-5P5TXU2K.js} +462 -392
- package/dist/bundle/{chunk-L62XTC7N.js → chunk-6EOZTUHT.js} +10 -10
- package/dist/bundle/{chunk-4TQVZXOV.js → chunk-AT5I34AN.js} +3 -3
- package/dist/bundle/{chunk-CBGBFAYJ.js → chunk-B3FSLAIU.js} +6 -4
- package/dist/bundle/{chunk-7NVPM55S.js → chunk-BBSFQ3PU.js} +1262 -1048
- package/dist/bundle/{chunk-JIRRF6BM.js → chunk-BNEE35WD.js} +4 -4
- package/dist/bundle/{chunk-HTKSCSJU.js → chunk-BWLBSQSU.js} +3 -3
- package/dist/bundle/{chunk-T5UNSFES.js → chunk-C32AKHTY.js} +8 -8
- package/dist/bundle/{chunk-GK4GLPG2.js → chunk-CDK5E45T.js} +3 -3
- package/dist/bundle/{chunk-NO2LIHWA.js → chunk-CWXOXIWS.js} +1 -1
- package/dist/bundle/{chunk-LIQMUDIZ.js → chunk-DB2XKHI4.js} +2 -2
- package/dist/bundle/{chunk-Z53LYX4M.js → chunk-DBEQI5YM.js} +3 -3
- package/dist/bundle/{chunk-2MHMKNWD.js → chunk-DFCHHR5M.js} +1 -1
- package/dist/bundle/{chunk-OI5DWZJG.js → chunk-DO7BLXO3.js} +3 -3
- package/dist/bundle/{chunk-5UA2TYMI.js → chunk-DSP36YHQ.js} +2 -2
- package/dist/bundle/{chunk-WZEEEQGC.js → chunk-E2AFUJDR.js} +3 -3
- package/dist/bundle/{chunk-YFWLHTNO.js → chunk-E5WLE7BM.js} +1 -1
- package/dist/bundle/{chunk-P3P6DA6K.js → chunk-ECC2UX7X.js} +6 -6
- package/dist/bundle/{chunk-GSNE7OB4.js → chunk-ECEZOLOD.js} +4 -4
- package/dist/bundle/{chunk-CIVXTBJY.js → chunk-FBZI4Z3Z.js} +41 -41
- package/dist/bundle/{chunk-5XP4KQ2F.js → chunk-FKA7DOCK.js} +1 -1
- package/dist/bundle/chunk-FPUGMDJV.js +7 -0
- package/dist/bundle/{chunk-OCDJ4FFA.js → chunk-G2MJYXZG.js} +3 -3
- package/dist/bundle/{chunk-5LBJNTEJ.js → chunk-GCZ6MAEN.js} +6 -6
- package/dist/bundle/{chunk-M2EEIYBU.js → chunk-GTY6N5KZ.js} +2 -2
- package/dist/bundle/{chunk-TJCPTRYD.js → chunk-H3E2PZ5Y.js} +7 -7
- package/dist/bundle/{chunk-FSJHASRQ.js → chunk-HHVFIXDO.js} +304 -265
- package/dist/bundle/{chunk-6JBLIQQN.js → chunk-HZRQLAHO.js} +1 -1
- package/dist/bundle/{chunk-WU3XHGOB.js → chunk-J3NKZ6MO.js} +17 -15
- package/dist/bundle/{chunk-QX3TPFEX.js → chunk-JCKWQGCD.js} +36 -36
- package/dist/bundle/{chunk-4KUJTSHG.js → chunk-KHWOLBHQ.js} +2 -2
- package/dist/bundle/{chunk-R6SDRSZK.js → chunk-KHZ2RGXI.js} +33 -32
- package/dist/bundle/{chunk-SGBS5QCU.js → chunk-LBYGJKXW.js} +4 -4
- package/dist/bundle/{chunk-EY6S7FV3.js → chunk-MNRMKWCN.js} +6 -6
- package/dist/bundle/{chunk-TFNRCCGR.js → chunk-N2XADGL4.js} +3 -3
- package/dist/bundle/{chunk-IJMFG7HB.js → chunk-NA6QLHBZ.js} +7 -7
- package/dist/bundle/{chunk-TXONV3HW.js → chunk-NE43YXKL.js} +2 -2
- package/dist/bundle/{chunk-TZ2QJ53V.js → chunk-NHHJHXMQ.js} +2 -2
- package/dist/bundle/{chunk-K5I64ZVI.js → chunk-NTG657MI.js} +8 -8
- package/dist/bundle/{chunk-YAPDU3SV.js → chunk-O3DYRCIT.js} +1 -1
- package/dist/bundle/{chunk-KL3P5TQK.js → chunk-O5YB7FQD.js} +4 -4
- package/dist/bundle/{chunk-WHJWURZB.js → chunk-ONZVPE24.js} +5 -5
- package/dist/bundle/{chunk-7NF3V5L2.js → chunk-P5BHKKBI.js} +4 -4
- package/dist/bundle/{chunk-GBFEEHQC.js → chunk-PAW6RRCW.js} +11 -26
- package/dist/bundle/{chunk-D6RCRBDH.js → chunk-PPHBRESD.js} +2 -2
- package/dist/bundle/{chunk-MRA62W5K.js → chunk-PWRRDDMZ.js} +182 -170
- package/dist/bundle/{chunk-COH7OEER.js → chunk-QIG55MZH.js} +12 -12
- package/dist/bundle/{chunk-L6H7PY4X.js → chunk-QWYMXFKM.js} +3 -3
- package/dist/bundle/{chunk-M6DGZ2O6.js → chunk-QYXWRKNA.js} +7 -7
- package/dist/bundle/{chunk-JODE2XED.js → chunk-RIGE67FR.js} +24 -24
- package/dist/bundle/{chunk-ZC6ZQQ55.js → chunk-RJMQGG3P.js} +30 -30
- package/dist/bundle/{chunk-BEPFGITI.js → chunk-TD2JZ25O.js} +59 -56
- package/dist/bundle/{chunk-EQPAZ33O.js → chunk-TDNURSU6.js} +17 -17
- package/dist/bundle/{chunk-6GN7KU7X.js → chunk-TOSCB4SO.js} +14 -8
- package/dist/bundle/{chunk-Y5LAJWR5.js → chunk-TP7GDWVF.js} +1 -1
- package/dist/bundle/{chunk-UROEWCOG.js → chunk-UZSBGECU.js} +3 -3
- package/dist/bundle/{chunk-7YZPBAQX.js → chunk-W53EJOFQ.js} +1 -1
- package/dist/bundle/{chunk-AYU5TFDU.js → chunk-W5JZMXGW.js} +29 -20
- package/dist/bundle/{chunk-UKE3CGHK.js → chunk-W7HM2VGO.js} +1 -1
- package/dist/bundle/{chunk-FEMHUSGO.js → chunk-WE4UFASG.js} +1 -1
- package/dist/bundle/{chunk-XCTOCVMW.js → chunk-WPP76PSX.js} +14 -14
- package/dist/bundle/{chunk-YGCI3DHS.js → chunk-X2M6NIQG.js} +1 -1
- package/dist/bundle/{chunk-CDGZZNGY.js → chunk-XUPN2EHR.js} +21 -7
- package/dist/bundle/command-contract-TVRFW2IX.js +38 -0
- package/dist/bundle/{command-server-entry-2SORMVRM.js → command-server-entry-LJ627ZUA.js} +26 -26
- package/dist/bundle/{decode-5O7IEFPN.js → decode-PX2LZ5Y2.js} +5 -5
- package/dist/bundle/{dispatch-YHQX6FEJ.js → dispatch-KOISQ5QJ.js} +8 -8
- package/dist/bundle/{echarts-ARLMVQC7.js → echarts-FVTUDXDU.js} +2 -2
- package/dist/bundle/{embed-FUDUKQ3K.js → embed-CCSDK43I.js} +6 -6
- package/dist/bundle/{embedder-HDRV7GX3.js → embedder-VHI4DHB7.js} +9 -9
- package/dist/bundle/{failure-JHXICWIL.js → failure-FZ6VYKEQ.js} +2 -2
- package/dist/bundle/{first-run-BGEFTXOE.js → first-run-7JKE5AHN.js} +12 -12
- package/dist/bundle/first-screen-ZROHOEYJ.js +38 -0
- package/dist/bundle/{instructions-MEFIKCDI.js → instructions-HET7BCYK.js} +1 -1
- package/dist/bundle/{mcp-VMS6PBCU.js → mcp-RGNRW77S.js} +2 -2
- package/dist/bundle/meeting-combined-SSTOJUIJ.js +24 -0
- package/dist/bundle/{meeting-model-REZVYGQW.js → meeting-model-K7TPS4S5.js} +12 -12
- package/dist/bundle/{meeting-semantic-R4CSLVRG.js → meeting-semantic-UD26T37N.js} +6 -6
- package/dist/bundle/{node-MAQALPLA.js → node-CXZIFHZC.js} +2 -2
- package/dist/bundle/{node-sqlite-J7IJYNBO.js → node-sqlite-ME7KMORI.js} +7 -7
- package/dist/bundle/notion.js +13 -13
- package/dist/bundle/{oauth-AMV4YGJD.js → oauth-XBTROXHB.js} +7 -7
- package/dist/bundle/{open-AB27MTGR.js → open-HA6D3SXR.js} +5 -5
- package/dist/bundle/{openai-D77MU5XV.js → openai-H5AJPZBX.js} +16 -16
- package/dist/bundle/{process-SIOWTRJ6.js → process-5RUXWGYS.js} +1 -1
- package/dist/bundle/{program-QC5MX4ZJ.js → program-F3NBTZ7J.js} +1961 -994
- package/dist/bundle/{prompt-W77YDHA6.js → prompt-6XSUOLHK.js} +5 -5
- package/dist/bundle/{recognize-3JAXQQ36.js → recognize-2Y7AUVGG.js} +4 -4
- package/dist/bundle/{remote-PSOJXCXO.js → remote-KCABPXQ3.js} +10 -10
- package/dist/bundle/{rerank-EE44ZTGL.js → rerank-BTN7LUVA.js} +7 -7
- package/dist/bundle/{schemas-LBYUMBC6.js → schemas-VVLTLMXS.js} +1 -1
- package/dist/bundle/{serve-XJMGAMFW.js → serve-CYEMVRFC.js} +9 -9
- package/dist/bundle/server-UC2FNNXX.js +72 -0
- package/dist/bundle/{server-ASU6CP5R.js → server-WFIICGMI.js} +46 -46
- package/dist/bundle/{services-PT4PA4J6.js → services-L4W6ZWDG.js} +41 -41
- package/dist/bundle/{sqlite-runtime-YHXRTVXE.js → sqlite-runtime-IKMYLRQC.js} +6 -6
- package/dist/bundle/{state-T6ZKFWGD.js → state-LMUP636P.js} +6 -6
- package/dist/bundle/{store-3MUCZEI3.js → store-A2QZFBOX.js} +19 -17
- package/dist/bundle/{store-E5EE25FY.js → store-W2JC2JP4.js} +19 -19
- package/dist/bundle/store-maintenance-command-LRGQJPSZ.js +63 -0
- package/dist/commands/comments.d.ts +4 -0
- package/dist/commands/comments.d.ts.map +1 -0
- package/dist/commands/comments.js +80 -0
- package/dist/commands/comments.js.map +1 -0
- package/dist/commands/documents.d.ts.map +1 -1
- package/dist/commands/documents.js +5 -102
- package/dist/commands/documents.js.map +1 -1
- package/dist/commands/files.d.ts +4 -0
- package/dist/commands/files.d.ts.map +1 -0
- package/dist/commands/files.js +57 -0
- package/dist/commands/files.js.map +1 -0
- package/dist/commands/library.d.ts.map +1 -1
- package/dist/commands/library.js +56 -12
- package/dist/commands/library.js.map +1 -1
- package/dist/commands/writing.d.ts +32 -0
- package/dist/commands/writing.d.ts.map +1 -0
- package/dist/commands/writing.js +126 -0
- package/dist/commands/writing.js.map +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/generated/manifest.d.ts +4 -1
- package/dist/generated/manifest.d.ts.map +1 -1
- package/dist/generated/manifest.js +20 -0
- package/dist/generated/manifest.js.map +1 -1
- package/dist/knowledge.d.ts +1 -0
- package/dist/knowledge.d.ts.map +1 -1
- package/dist/knowledge.js +68 -2
- package/dist/knowledge.js.map +1 -1
- package/dist/library.d.ts +4 -1
- package/dist/library.d.ts.map +1 -1
- package/dist/library.js +11 -0
- package/dist/library.js.map +1 -1
- package/dist/notion/errors.d.ts.map +1 -1
- package/dist/notion/errors.js +2 -0
- package/dist/notion/errors.js.map +1 -1
- package/dist/notion/notion.d.ts +38 -0
- package/dist/notion/notion.d.ts.map +1 -1
- package/dist/notion/notion.js +43 -0
- package/dist/notion/notion.js.map +1 -1
- package/dist/notion/port.d.ts.map +1 -1
- package/dist/notion/port.js +1 -0
- package/dist/notion/port.js.map +1 -1
- package/dist/notion/reads.d.ts +13 -1
- package/dist/notion/reads.d.ts.map +1 -1
- package/dist/notion/reads.js +1 -1
- package/dist/notion/writes.d.ts +38 -0
- package/dist/notion/writes.d.ts.map +1 -1
- package/dist/notion/writes.js +73 -0
- package/dist/notion/writes.js.map +1 -1
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +21 -2
- package/dist/program.js.map +1 -1
- package/dist/sync/browse.d.ts +30 -0
- package/dist/sync/browse.d.ts.map +1 -0
- package/dist/sync/browse.js +67 -0
- package/dist/sync/browse.js.map +1 -0
- package/dist/sync/cursor.d.ts +17 -0
- package/dist/sync/cursor.d.ts.map +1 -1
- package/dist/sync/cursor.js +28 -0
- package/dist/sync/cursor.js.map +1 -1
- package/dist/sync/files.d.ts +8 -0
- package/dist/sync/files.d.ts.map +1 -1
- package/dist/sync/files.js +10 -0
- package/dist/sync/files.js.map +1 -1
- package/dist/sync/source.d.ts +4 -4
- package/dist/sync/source.d.ts.map +1 -1
- package/dist/sync/source.js +49 -60
- package/dist/sync/source.js.map +1 -1
- package/dist/sync/users.d.ts +9 -0
- package/dist/sync/users.d.ts.map +1 -0
- package/dist/sync/users.js +76 -0
- package/dist/sync/users.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/dist/bundle/chunk-SHTHNBHG.js +0 -2
- package/dist/bundle/command-contract-UBXS6NHI.js +0 -38
- package/dist/bundle/first-screen-F5F3VS6Y.js +0 -38
- package/dist/bundle/meeting-combined-HNSS3FQY.js +0 -24
- package/dist/bundle/server-WSPQ5EOA.js +0 -72
- package/dist/bundle/store-maintenance-command-ZZ55BBBG.js +0 -63
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
snapshotProjectAnnotations,
|
|
9
9
|
storeDamageReport,
|
|
10
10
|
storeHealth
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-TDNURSU6.js";
|
|
12
12
|
import {
|
|
13
13
|
note
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BWLBSQSU.js";
|
|
15
15
|
import {
|
|
16
16
|
ADDED_KINDS,
|
|
17
17
|
ALWAYS_SHOWN,
|
|
@@ -97,10 +97,10 @@ import {
|
|
|
97
97
|
validateEvidenceFindings,
|
|
98
98
|
waitingPointer,
|
|
99
99
|
withoutField
|
|
100
|
-
} from "./chunk-
|
|
101
|
-
import "./chunk-
|
|
102
|
-
import "./chunk-
|
|
103
|
-
import "./chunk-
|
|
100
|
+
} from "./chunk-BBSFQ3PU.js";
|
|
101
|
+
import "./chunk-C32AKHTY.js";
|
|
102
|
+
import "./chunk-QYXWRKNA.js";
|
|
103
|
+
import "./chunk-HZRQLAHO.js";
|
|
104
104
|
import {
|
|
105
105
|
BUSINESS_KINDS,
|
|
106
106
|
CLOSED_STATES,
|
|
@@ -130,33 +130,33 @@ import {
|
|
|
130
130
|
readJournalMark,
|
|
131
131
|
recordDeepCheck,
|
|
132
132
|
reminder
|
|
133
|
-
} from "./chunk-
|
|
134
|
-
import "./chunk-
|
|
135
|
-
import "./chunk-
|
|
133
|
+
} from "./chunk-JCKWQGCD.js";
|
|
134
|
+
import "./chunk-UZSBGECU.js";
|
|
135
|
+
import "./chunk-DSP36YHQ.js";
|
|
136
136
|
import {
|
|
137
137
|
FACT_TYPES,
|
|
138
138
|
PAYMENT_DIRECTIONS,
|
|
139
139
|
PAYMENT_STATES,
|
|
140
140
|
paymentTitle,
|
|
141
141
|
validatePayment
|
|
142
|
-
} from "./chunk-
|
|
143
|
-
import "./chunk-
|
|
144
|
-
import "./chunk-
|
|
142
|
+
} from "./chunk-HHVFIXDO.js";
|
|
143
|
+
import "./chunk-H3E2PZ5Y.js";
|
|
144
|
+
import "./chunk-FPUGMDJV.js";
|
|
145
145
|
import {
|
|
146
146
|
storePath
|
|
147
|
-
} from "./chunk-
|
|
147
|
+
} from "./chunk-GTY6N5KZ.js";
|
|
148
148
|
import {
|
|
149
149
|
openCache
|
|
150
|
-
} from "./chunk-
|
|
150
|
+
} from "./chunk-MNRMKWCN.js";
|
|
151
151
|
import {
|
|
152
152
|
PRAGMAS
|
|
153
|
-
} from "./chunk-
|
|
154
|
-
import "./chunk-
|
|
155
|
-
import "./chunk-
|
|
153
|
+
} from "./chunk-DFCHHR5M.js";
|
|
154
|
+
import "./chunk-W5JZMXGW.js";
|
|
155
|
+
import "./chunk-TOSCB4SO.js";
|
|
156
156
|
import "./chunk-MVA5HVKL.js";
|
|
157
157
|
import "./chunk-Y5E2WNWB.js";
|
|
158
|
-
import "./chunk-
|
|
159
|
-
import "./chunk-
|
|
158
|
+
import "./chunk-DB2XKHI4.js";
|
|
159
|
+
import "./chunk-TP7GDWVF.js";
|
|
160
160
|
import "./chunk-ZVVMGPBJ.js";
|
|
161
161
|
export {
|
|
162
162
|
ADDED_KINDS,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __bundleRequire } from "node:module";
|
|
2
|
+
const require = __bundleRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
addStoreMaintenanceCommands,
|
|
5
|
+
buildStems,
|
|
6
|
+
storeMaintenanceCommands,
|
|
7
|
+
storeSummary
|
|
8
|
+
} from "./chunk-TD2JZ25O.js";
|
|
9
|
+
import "./chunk-WPP76PSX.js";
|
|
10
|
+
import "./chunk-6EOZTUHT.js";
|
|
11
|
+
import "./chunk-DBEQI5YM.js";
|
|
12
|
+
import "./chunk-PPHBRESD.js";
|
|
13
|
+
import "./chunk-EH6ZEJGT.js";
|
|
14
|
+
import "./chunk-5P5TXU2K.js";
|
|
15
|
+
import "./chunk-FBZI4Z3Z.js";
|
|
16
|
+
import "./chunk-WE4UFASG.js";
|
|
17
|
+
import "./chunk-G2MJYXZG.js";
|
|
18
|
+
import "./chunk-CWXOXIWS.js";
|
|
19
|
+
import "./chunk-N2XADGL4.js";
|
|
20
|
+
import "./chunk-ECC2UX7X.js";
|
|
21
|
+
import "./chunk-PAW6RRCW.js";
|
|
22
|
+
import "./chunk-QWYMXFKM.js";
|
|
23
|
+
import "./chunk-DO7BLXO3.js";
|
|
24
|
+
import "./chunk-PWRRDDMZ.js";
|
|
25
|
+
import "./chunk-NA6QLHBZ.js";
|
|
26
|
+
import "./chunk-AT5I34AN.js";
|
|
27
|
+
import "./chunk-ONZVPE24.js";
|
|
28
|
+
import "./chunk-W53EJOFQ.js";
|
|
29
|
+
import "./chunk-TDNURSU6.js";
|
|
30
|
+
import "./chunk-BWLBSQSU.js";
|
|
31
|
+
import "./chunk-BBSFQ3PU.js";
|
|
32
|
+
import "./chunk-C32AKHTY.js";
|
|
33
|
+
import "./chunk-QYXWRKNA.js";
|
|
34
|
+
import "./chunk-HZRQLAHO.js";
|
|
35
|
+
import "./chunk-JCKWQGCD.js";
|
|
36
|
+
import "./chunk-UZSBGECU.js";
|
|
37
|
+
import "./chunk-DSP36YHQ.js";
|
|
38
|
+
import "./chunk-HHVFIXDO.js";
|
|
39
|
+
import "./chunk-NTG657MI.js";
|
|
40
|
+
import "./chunk-E2AFUJDR.js";
|
|
41
|
+
import "./chunk-H3E2PZ5Y.js";
|
|
42
|
+
import "./chunk-GCZ6MAEN.js";
|
|
43
|
+
import "./chunk-BNEE35WD.js";
|
|
44
|
+
import "./chunk-O3DYRCIT.js";
|
|
45
|
+
import "./chunk-FPUGMDJV.js";
|
|
46
|
+
import "./chunk-XUPN2EHR.js";
|
|
47
|
+
import "./chunk-D72URWJE.js";
|
|
48
|
+
import "./chunk-GTY6N5KZ.js";
|
|
49
|
+
import "./chunk-MNRMKWCN.js";
|
|
50
|
+
import "./chunk-DFCHHR5M.js";
|
|
51
|
+
import "./chunk-W5JZMXGW.js";
|
|
52
|
+
import "./chunk-TOSCB4SO.js";
|
|
53
|
+
import "./chunk-MVA5HVKL.js";
|
|
54
|
+
import "./chunk-Y5E2WNWB.js";
|
|
55
|
+
import "./chunk-DB2XKHI4.js";
|
|
56
|
+
import "./chunk-TP7GDWVF.js";
|
|
57
|
+
import "./chunk-ZVVMGPBJ.js";
|
|
58
|
+
export {
|
|
59
|
+
addStoreMaintenanceCommands,
|
|
60
|
+
buildStems,
|
|
61
|
+
storeMaintenanceCommands,
|
|
62
|
+
storeSummary
|
|
63
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/commands/comments.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAU,MAAM,WAAW,CAAA;AAyG3C,6DAA6D;AAC7D,eAAO,MAAM,eAAe,eAKG,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
2
|
+
import { answerEntity, commandPath, itemOf, listOf, outputFor, positiveCount, REMOTE_READ, REMOTE_WRITE, renderAnswer, secretInput, } from "@wirecat/cli-core/cli";
|
|
3
|
+
import { Command, Option } from "commander";
|
|
4
|
+
import { withNotion } from "../context.js";
|
|
5
|
+
import { IDENTITY } from "../identity.js";
|
|
6
|
+
import { notionId } from "../notion/ids.js";
|
|
7
|
+
import { commentSchema } from "../notion/notion.js";
|
|
8
|
+
import { markdownOf, write } from "./writing.js";
|
|
9
|
+
const CLI = IDENTITY.command;
|
|
10
|
+
/** Notion's page size: a default of 100, which is also its most ([pagination](https://developers.notion.com/reference/pagination)). */
|
|
11
|
+
const LARGEST_PAGE = 100;
|
|
12
|
+
const DEFAULT_PAGE = 50;
|
|
13
|
+
const listCommand = () => answerEntity(annotate(new Command("list"), {
|
|
14
|
+
effects: REMOTE_READ,
|
|
15
|
+
offline: false,
|
|
16
|
+
examples: [`${CLI} personal comments list PAGE_ID`, `${CLI} personal comments list PAGE_ID --limit 20 --json`],
|
|
17
|
+
}), "notion_comment", commentSchema)
|
|
18
|
+
.summary("list the open comments on a Notion page or block, live")
|
|
19
|
+
.description("list the comments on a Notion page or block, live. Notion's API lists only unresolved comments: a resolved " +
|
|
20
|
+
"discussion is not shown. Reply to one with comments reply and its discussion_id")
|
|
21
|
+
.argument("<page>", "the page's or block's id, or its Notion link")
|
|
22
|
+
.option("--limit <n>", `at most this many, up to ${LARGEST_PAGE}; ${DEFAULT_PAGE} if not given`, positiveCount("--limit"))
|
|
23
|
+
.option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it")
|
|
24
|
+
.action(async function (page) {
|
|
25
|
+
const block = notionId(page);
|
|
26
|
+
const { limit = DEFAULT_PAGE, cursor } = this.opts();
|
|
27
|
+
const size = Math.min(limit, LARGEST_PAGE);
|
|
28
|
+
const found = await withNotion(this, (notion) => notion.comments({ block, limit: size, cursor }));
|
|
29
|
+
renderAnswer(this, outputFor(this), listOf(commandPath(this), {
|
|
30
|
+
items: found.items,
|
|
31
|
+
limit: size,
|
|
32
|
+
has_more: found.hasMore,
|
|
33
|
+
paging: "cursor",
|
|
34
|
+
...(found.cursor === undefined ? {} : { cursor: found.cursor }),
|
|
35
|
+
args: { page: block },
|
|
36
|
+
}));
|
|
37
|
+
});
|
|
38
|
+
/** The comment's text never reaches a run record, whatever the owner's `record_input`. */
|
|
39
|
+
const withText = (command) => command
|
|
40
|
+
.addOption(secretInput(new Option("--text <text>", "the comment, as Markdown: bold, italic, code, links")))
|
|
41
|
+
.option("--file <file>", "read the comment from this file; - reads stdin");
|
|
42
|
+
const COMMENT = "the comment's text";
|
|
43
|
+
const createCommand = () => withText(annotate(new Command("create"), {
|
|
44
|
+
effects: REMOTE_WRITE,
|
|
45
|
+
offline: false,
|
|
46
|
+
examples: [
|
|
47
|
+
`${CLI} personal comments create PAGE_ID --text "Looks good"`,
|
|
48
|
+
`${CLI} personal comments create PAGE_ID --file note.md --dry-run`,
|
|
49
|
+
],
|
|
50
|
+
})
|
|
51
|
+
.summary("comment on a Notion page")
|
|
52
|
+
.description("start a discussion on a Notion page with a comment. Notion keeps inline Markdown only: bold, italic, " +
|
|
53
|
+
"strikethrough, code and links")
|
|
54
|
+
.argument("<page>", "the page's id or its Notion link")).action(async function (page, args) {
|
|
55
|
+
const id = notionId(page);
|
|
56
|
+
const markdown = (await markdownOf(this, args, true, COMMENT)) ?? "";
|
|
57
|
+
const { operationId, done } = await write(this, [], (notion) => notion.comment({ page: id }, markdown));
|
|
58
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, comment: done }));
|
|
59
|
+
});
|
|
60
|
+
const replyCommand = () => withText(annotate(new Command("reply"), {
|
|
61
|
+
effects: REMOTE_WRITE,
|
|
62
|
+
offline: false,
|
|
63
|
+
examples: [`${CLI} personal comments reply DISCUSSION_ID --text "Done"`],
|
|
64
|
+
})
|
|
65
|
+
.summary("reply in a Notion discussion")
|
|
66
|
+
.description("add a comment to a discussion that comments list shows, by its discussion_id. It checks comments.create " +
|
|
67
|
+
"too, so denying that stops replies as well")
|
|
68
|
+
.argument("<discussion>", "the discussion_id from comments list")).action(async function (discussion, args) {
|
|
69
|
+
const id = notionId(discussion, "discussion");
|
|
70
|
+
const markdown = (await markdownOf(this, args, true, COMMENT)) ?? "";
|
|
71
|
+
const { operationId, done } = await write(this, [], (notion) => notion.comment({ discussion: id }, markdown));
|
|
72
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, comment: done }));
|
|
73
|
+
});
|
|
74
|
+
/** `comments list|create|reply`: Notion's comments, live. */
|
|
75
|
+
export const commentsCommand = () => annotate(new Command("comments"), { effects: REMOTE_READ })
|
|
76
|
+
.description("read and write the comments on Notion pages, live")
|
|
77
|
+
.addCommand(listCommand())
|
|
78
|
+
.addCommand(createCommand())
|
|
79
|
+
.addCommand(replyCommand());
|
|
80
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/commands/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EACL,YAAY,EACZ,WAAW,EACX,MAAM,EACN,MAAM,EACN,SAAS,EACT,aAAa,EACb,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,WAAW,GACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE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AAE,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAA;IAC7G,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC3F,CAAC,CAAC,CAAA;AAEJ,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAClC,QAAQ,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;KACxD,WAAW,CAAC,mDAAmD,CAAC;KAChE,UAAU,CAAC,WAAW,EAAE,CAAC;KACzB,UAAU,CAAC,aAAa,EAAE,CAAC;KAC3B,UAAU,CAAC,YAAY,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUnC,2FAA2F;AAC3F,eAAO,MAAM,UAAU,eAyCjB,CAAA;AAEN,qEAAqE;AACrE,eAAO,MAAM,aAAa,eA0BpB,CAAA;AAEN,0DAA0D;AAC1D,eAAO,MAAM,aAAa,eAmCpB,CAAA;AAeN,4FAA4F;AAC5F,eAAO,MAAM,aAAa,eAMrB,CAAA;AAEL,qDAAqD;AACrD,eAAO,MAAM,cAAc,eAGoE,CAAA"}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CliError, visibleControls } from "@wirecat/cli-base";
|
|
1
|
+
import { visibleControls } from "@wirecat/cli-base";
|
|
3
2
|
import { annotate } from "@wirecat/cli-base/commands";
|
|
4
|
-
import { answerEntity,
|
|
5
|
-
import { guardedWrite, guardFor, keyedGuard, levelFor, newOperationId, refusedPlace } from "@wirecat/cli-core/sends";
|
|
3
|
+
import { answerEntity, itemOf, outputFor, REMOTE_READ, REMOTE_WRITE, renderAnswer } from "@wirecat/cli-core/cli";
|
|
6
4
|
import { Command } from "commander";
|
|
7
|
-
import { DELETE_KEY
|
|
8
|
-
import {
|
|
5
|
+
import { DELETE_KEY } from "../config.js";
|
|
6
|
+
import { withNotion } from "../context.js";
|
|
9
7
|
import { IDENTITY } from "../identity.js";
|
|
10
8
|
import { notionId } from "../notion/ids.js";
|
|
11
9
|
import { documentSchema } from "../notion/notion.js";
|
|
10
|
+
import { markdownOf, TEXT_OPTIONS, write } from "./writing.js";
|
|
12
11
|
const CLI = IDENTITY.command;
|
|
13
12
|
/** `documents get`: one page live, beside the shared commands that read the local copy. */
|
|
14
13
|
export const getCommand = () => answerEntity(annotate(new Command("get"), {
|
|
@@ -41,102 +40,6 @@ export const getCommand = () => answerEntity(annotate(new Command("get"), {
|
|
|
41
40
|
if (issues.length > 0 && output.format !== "json" && output.format !== "jsonl")
|
|
42
41
|
output.renderer.warn(`the page is incomplete: ${why}`);
|
|
43
42
|
});
|
|
44
|
-
/**
|
|
45
|
-
* Every page write's one path, as the template's sample (WC-PERM-13): the level of the command's key and of each
|
|
46
|
-
* extra key refuses or asks once, the send journal records the attempt and never its content (WC-PERM-17), and the
|
|
47
|
-
* answer carries `operation_id` (WC-OUT-10). cli-core has already answered `--dry-run` and refused under
|
|
48
|
-
* `WCNOTION_READ_ONLY`. Never retried: a write that got no answer is `outcome_unknown` (WC-LIFE-9).
|
|
49
|
-
*/
|
|
50
|
-
const write = async (command, extra, act) => {
|
|
51
|
-
const context = contextOf(command);
|
|
52
|
-
const { settings, env, renderer } = context;
|
|
53
|
-
const path = commandPath(command);
|
|
54
|
-
const key = path.replaceAll(" ", ".");
|
|
55
|
-
const token = tokenOf(command);
|
|
56
|
-
const operationId = newOperationId();
|
|
57
|
-
const levelOf = (one) => levelFor(settings.permissions, one, permissions.defaults).level;
|
|
58
|
-
const guard = keyedGuard((ask) => guardFor(IDENTITY,
|
|
59
|
-
// Notion limits its own rate, so this guard keeps the levels and the journal, not a send cap.
|
|
60
|
-
{ ...settings, sendsPerHour: Number.MAX_SAFE_INTEGER, permissionDefaults: permissions.defaults }, renderer.warn, env, ask), terminalAsker(command), levelOf, [...(PAGE_WRITE_KEYS[path] ?? []), ...extra]);
|
|
61
|
-
const request = { chatId: null, kind: "edit", key, operationId };
|
|
62
|
-
guard.refuse(request);
|
|
63
|
-
try {
|
|
64
|
-
const done = await guardedWrite(guard, request, () => context.run((events) => act(notionWritesFor(command, token, events))));
|
|
65
|
-
return { operationId, done };
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (error instanceof CliError && error.code === "outcome_unknown")
|
|
69
|
-
throw new CliError("outcome_unknown", error.message, { ...error.details, operation_id: operationId });
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const realOf = (path) => {
|
|
74
|
-
try {
|
|
75
|
-
return realpathSync(path);
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const refusedFile = (file) => new CliError("validation_error", `${file} is not read: only a regular file goes to Notion, never a link, a system file, a credential file, a ` +
|
|
82
|
-
"browser profile or a WireCat folder", { reason: "file.refused-place", sent: false });
|
|
83
|
-
/**
|
|
84
|
-
* One open, then every check on what was opened: a link as the last part is refused (O_NOFOLLOW), so the path
|
|
85
|
-
* cannot be swapped between the check and the read, and a FIFO does not block the open (O_NONBLOCK). An agent steered
|
|
86
|
-
* by a page's text must not publish a key, the process's environment or another tool's settings into Notion.
|
|
87
|
-
* cli-core's readUpload checks the path and reads it later, so it is not used here.
|
|
88
|
-
*/
|
|
89
|
-
const readOwnFile = (file, env) => {
|
|
90
|
-
const outside = (path) => path !== undefined && refusedPlace(path, IDENTITY, env);
|
|
91
|
-
if (outside(file))
|
|
92
|
-
throw refusedFile(file);
|
|
93
|
-
let fd;
|
|
94
|
-
try {
|
|
95
|
-
fd = openSync(file, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
const code = error.code;
|
|
99
|
-
if (code === "ELOOP" || code === "EMLINK")
|
|
100
|
-
throw refusedFile(file);
|
|
101
|
-
throw new CliError("validation_error", `${file}: ${code === "ENOENT" ? "no such file" : "it cannot be read"}`, {
|
|
102
|
-
sent: false,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
// On Linux the open descriptor names the file it really is, whatever happened to the path since the check.
|
|
107
|
-
const opened = process.platform === "linux" ? realOf(`/proc/self/fd/${fd}`) : undefined;
|
|
108
|
-
if (!fstatSync(fd).isFile() || outside(opened))
|
|
109
|
-
throw refusedFile(file);
|
|
110
|
-
return readFileSync(fd, "utf8");
|
|
111
|
-
}
|
|
112
|
-
finally {
|
|
113
|
-
closeSync(fd);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
/** The page's new text: `--text`, or `--file`, where `-` is stdin. */
|
|
117
|
-
const markdownOf = async (command, args, required) => {
|
|
118
|
-
if (args.text !== undefined && args.file !== undefined)
|
|
119
|
-
throw new CliError("validation_error", "give the text with --text or --file, not both", { sent: false });
|
|
120
|
-
if (args.text !== undefined)
|
|
121
|
-
return args.text;
|
|
122
|
-
if (args.file === "-") {
|
|
123
|
-
const { environment } = contextOf(command);
|
|
124
|
-
const input = await bufferedInput(environment.stdin ?? process.stdin, {
|
|
125
|
-
maxBytes: MAX_BUFFERED_INPUT,
|
|
126
|
-
...(environment.signal ? { signal: environment.signal } : {}),
|
|
127
|
-
});
|
|
128
|
-
return input.toString("utf8");
|
|
129
|
-
}
|
|
130
|
-
if (args.file !== undefined)
|
|
131
|
-
return readOwnFile(args.file, contextOf(command).env);
|
|
132
|
-
if (required)
|
|
133
|
-
throw new CliError("validation_error", "give the page's new text with --text or --file", { sent: false });
|
|
134
|
-
return undefined;
|
|
135
|
-
};
|
|
136
|
-
const TEXT_OPTIONS = {
|
|
137
|
-
text: "the text, as Notion-flavoured Markdown",
|
|
138
|
-
file: "read the text from this file; - reads stdin",
|
|
139
|
-
};
|
|
140
43
|
/** `documents create`: a new page under a page the token can see. */
|
|
141
44
|
export const createCommand = () => annotate(new Command("create"), {
|
|
142
45
|
effects: REMOTE_WRITE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../../src/commands/documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAChH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAiB,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAE9D,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAA;AAE5B,2FAA2F;AAC3F,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAC7B,YAAY,CACV,QAAQ,CAAC,IAAI,OA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AE,OAAO,CAAC,CAAC,CAAA;IAC1F,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AACxF,CAAC,CAAC,CAAA;AAEN,4FAA4F;AAC5F,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE,CAChC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC;KACzB,OAAO,CAAC,iCAAiC,CAAC;KAC1C,WAAW,CACV,iHAAiH;IAC/G,yFAAyF,CAC5F,CAAA;AAEL,qDAAqD;AACrD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CACjC,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC;KAC3B,OAAO,CAAC,yCAAyC,CAAC;KAClD,WAAW,CAAC,6EAA6E,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsDnC,uDAAuD;AACvD,eAAO,MAAM,YAAY,eAGO,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { closeSync, readSync } from "node:fs";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { CliError } from "@wirecat/cli-base";
|
|
4
|
+
import { annotate } from "@wirecat/cli-base/commands";
|
|
5
|
+
import { itemOf, outputFor, REMOTE_WRITE, renderAnswer } from "@wirecat/cli-core/cli";
|
|
6
|
+
import { Command } from "commander";
|
|
7
|
+
import { contextOf } from "../context.js";
|
|
8
|
+
import { IDENTITY } from "../identity.js";
|
|
9
|
+
import { notionId } from "../notion/ids.js";
|
|
10
|
+
import { PART_BYTES, SINGLE_PART_BYTES } from "../notion/writes.js";
|
|
11
|
+
import { openOwnFile, write } from "./writing.js";
|
|
12
|
+
const CLI = IDENTITY.command;
|
|
13
|
+
const MB = 1024 * 1024;
|
|
14
|
+
const uploadCommand = () => annotate(new Command("upload"), {
|
|
15
|
+
effects: REMOTE_WRITE,
|
|
16
|
+
offline: false,
|
|
17
|
+
examples: [
|
|
18
|
+
`${CLI} personal files upload report.pdf --parent PAGE_ID`,
|
|
19
|
+
`${CLI} personal files upload photo.png --parent PAGE_ID --dry-run`,
|
|
20
|
+
],
|
|
21
|
+
})
|
|
22
|
+
.summary("upload a file to the end of a Notion page")
|
|
23
|
+
.description(`upload a file and add it to the end of a Notion page, as an image, video, audio, PDF or file block by its ` +
|
|
24
|
+
`type. Up to ${SINGLE_PART_BYTES / MB} MB goes in one request, a larger file in parts of ` +
|
|
25
|
+
`${PART_BYTES / MB} MB. Notion's plan limits the size; a file too large for it is refused. Only a regular ` +
|
|
26
|
+
"file is sent, never a link, a system file or a credential file")
|
|
27
|
+
.argument("<file>", "the file to upload")
|
|
28
|
+
.requiredOption("--parent <id>", "the page to add the file to: its id or its Notion link")
|
|
29
|
+
.action(async function (file, args) {
|
|
30
|
+
const page = notionId(args.parent);
|
|
31
|
+
const { fd, size } = openOwnFile(file, contextOf(this).env);
|
|
32
|
+
try {
|
|
33
|
+
const read = (offset, length) => {
|
|
34
|
+
const bytes = new Uint8Array(length);
|
|
35
|
+
let filled = 0;
|
|
36
|
+
while (filled < length) {
|
|
37
|
+
const got = readSync(fd, bytes, filled, length - filled, offset + filled);
|
|
38
|
+
if (got === 0)
|
|
39
|
+
throw new CliError("validation_error", `${file} changed while it was read; upload it again`, {
|
|
40
|
+
sent: false,
|
|
41
|
+
});
|
|
42
|
+
filled += got;
|
|
43
|
+
}
|
|
44
|
+
return bytes;
|
|
45
|
+
};
|
|
46
|
+
const { operationId, done } = await write(this, [], (notion) => notion.upload({ page, filename: basename(file), size, read }));
|
|
47
|
+
renderAnswer(this, outputFor(this), itemOf({ operation_id: operationId, page: { id: page }, ...done }));
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
closeSync(fd);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
/** `files upload`: a local file onto a Notion page. */
|
|
54
|
+
export const filesCommand = () => annotate(new Command("files"), { effects: REMOTE_WRITE })
|
|
55
|
+
.description("upload files to Notion pages")
|
|
56
|
+
.addCommand(uploadCommand());
|
|
57
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../src/commands/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACrF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAA;AAC5B,MAAM,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtB,MAAM,aAAa,GAAG,GAAG,EAAE,CACzB,QAAQ,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,EAAE;IAC9B,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE;QACR,GA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AE,EAAE,CAC7D,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAC9D,CAAA;QACD,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAA;IACzG,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAA;IACf,CAAC;AACH,CAAC,CAAC,CAAA;AAEN,uDAAuD;AACvD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE,CAC/B,QAAQ,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;KACtD,WAAW,CAAC,8BAA8B,CAAC;KAC3C,UAAU,CAAC,aAAa,EAAE,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/commands/library.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"library.d.ts","sourceRoot":"","sources":["../../src/commands/library.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAA;AAEzF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAsCnC,eAAO,MAAM,YAAY,EAAE,aAkB1B,CAAA;AAsDD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAO,OAAO,EA+czC,CAAA"}
|
package/dist/commands/library.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliError, isCliError } from "@wirecat/cli-base";
|
|
2
2
|
import { annotate, metaOf } from "@wirecat/cli-base/commands";
|
|
3
3
|
import { progressOf } from "@wirecat/cli-core/background";
|
|
4
|
-
import { actorOf, answerEntity, FETCH, itemOf, listOf, outputFor, REMOTE_READ, refuseOffline, renderAnswer, resolveAISettings, writesOwnerFiles, } from "@wirecat/cli-core/cli";
|
|
4
|
+
import { actorOf, answerEntity, FETCH, itemOf, listOf, outputFor, positiveCount, REMOTE_READ, refuseOffline, renderAnswer, resolveAISettings, writesOwnerFiles, } from "@wirecat/cli-core/cli";
|
|
5
5
|
import { catalogFiles, syncDocuments } from "@wirecat/cli-core/documents";
|
|
6
6
|
import { addDocumentCommands } from "@wirecat/cli-core/documents/cli";
|
|
7
7
|
import { modelGateway, modelTarget } from "@wirecat/cli-core/models";
|
|
@@ -10,7 +10,7 @@ import * as v from "valibot";
|
|
|
10
10
|
import { contextOf, notionReadsFor, tokenOf } from "../context.js";
|
|
11
11
|
import { IDENTITY } from "../identity.js";
|
|
12
12
|
import { ingestionOf, knowledgeOf } from "../knowledge.js";
|
|
13
|
-
import { chosenFolders, claimAccount, foldersChangedAt, knownOf, MAX_ENTRIES, PROVIDER, principalOf, readSnapshot, rootsOf, saveFolders, syncState, TEXT_LIMIT, walkUnderWay, withProfileLock, withStore, } from "../library.js";
|
|
13
|
+
import { chosenFolders, claimAccount, foldersChangedAt, knownOf, MAX_ENTRIES, PROVIDER, principalOf, readSnapshot, rootsOf, saveFolders, saveUserAccess, syncState, TEXT_LIMIT, walkUnderWay, withProfileLock, withStore, } from "../library.js";
|
|
14
14
|
import { notionId } from "../notion/ids.js";
|
|
15
15
|
import { isNotionDocument, isNotionFolder, notionSource, passUnderWay, WORKSPACE_ROOT, } from "../sync/source.js";
|
|
16
16
|
import { VERSION } from "../version.js";
|
|
@@ -47,13 +47,26 @@ const documentRow = (file, reference) => ({
|
|
|
47
47
|
created_at: file.createdAt ?? null,
|
|
48
48
|
reference,
|
|
49
49
|
});
|
|
50
|
-
const
|
|
50
|
+
const BROWSE_LIMIT = 100;
|
|
51
|
+
const browseRow = v.strictObject({
|
|
51
52
|
id: v.string(),
|
|
52
53
|
name: v.string(),
|
|
53
54
|
kind: v.picklist(["page", "database"]),
|
|
54
55
|
url: v.string(),
|
|
55
|
-
|
|
56
|
+
parent: v.nullable(v.string()),
|
|
57
|
+
added: v.boolean(),
|
|
56
58
|
});
|
|
59
|
+
const BROWSE_HELP = `
|
|
60
|
+
Each item, one level of the tree (--json prints them under "items"):
|
|
61
|
+
id page or database id to pass to --parent or to folders add
|
|
62
|
+
name its title in Notion
|
|
63
|
+
kind page or database; a database lists no folders inside, as its rows are not folders
|
|
64
|
+
url its Notion link
|
|
65
|
+
parent the --parent given, or null at the top of the workspace
|
|
66
|
+
added whether sync already copies it (folders add)
|
|
67
|
+
The top of the workspace holds its top-level pages and databases, and those whose parent the token cannot see.
|
|
68
|
+
A level comes a page at a time: when page.has_more is true, run it again with --cursor from page.next_cursor.
|
|
69
|
+
A page can come back with fewer items than --limit, or none, and still have more.`;
|
|
57
70
|
/** An issue names its source and why; the id and the words stay in the answer's `warnings`. */
|
|
58
71
|
const issuesOf = (warnings) => {
|
|
59
72
|
const seen = new Set();
|
|
@@ -142,6 +155,7 @@ export const libraryCommands = () => {
|
|
|
142
155
|
};
|
|
143
156
|
const sourceFor = (reads, held = false, deadline) => notionSource(reads, {
|
|
144
157
|
roots: rootsOf(env(), profile()),
|
|
158
|
+
userAccess: (access) => saveUserAccess(env(), profile(), access),
|
|
145
159
|
...(held ? { known: () => knownOf(syncState(env(), profile(), "").read()) } : {}),
|
|
146
160
|
warn: (warning) => warnings.push(warning),
|
|
147
161
|
...(deadline ? { deadline } : {}),
|
|
@@ -202,25 +216,51 @@ export const libraryCommands = () => {
|
|
|
202
216
|
answerEntity(annotate(folders.command("browse"), {
|
|
203
217
|
effects: REMOTE_READ,
|
|
204
218
|
offline: false,
|
|
205
|
-
examples: [
|
|
219
|
+
examples: [
|
|
220
|
+
`${CLI} personal folders browse`,
|
|
221
|
+
`${CLI} personal folders browse --parent PAGE_ID --json`,
|
|
222
|
+
`${CLI} personal folders browse --limit 20 --cursor CURSOR`,
|
|
223
|
+
],
|
|
206
224
|
}), "notion_folder", browseRow)
|
|
207
225
|
.summary("list Notion pages and databases one level at a time, live")
|
|
208
226
|
.description("list Notion pages and databases one level at a time, live, to choose one for folders add")
|
|
209
227
|
.option("--parent <id>", "page id or Notion link to list inside; the top of the workspace without it")
|
|
228
|
+
.option("--limit <n>", `at most this many; ${BROWSE_LIMIT} if not given`, positiveCount("--limit"))
|
|
229
|
+
.option("--cursor <cursor>", "go on from where the last page stopped; page.next gives it, with the same --parent")
|
|
230
|
+
.addHelpText("after", BROWSE_HELP)
|
|
210
231
|
.action(async (args) => {
|
|
211
232
|
const parent = args.parent === undefined ? WORKSPACE_ROOT : notionId(args.parent);
|
|
233
|
+
const limit = args.limit ?? BROWSE_LIMIT;
|
|
212
234
|
const chosen = new Set(chosenFolders(env(), profile()));
|
|
213
|
-
const
|
|
214
|
-
const items =
|
|
235
|
+
const level = await withNotionReads((reads) => sourceFor(reads).browse(parent, limit, args.cursor));
|
|
236
|
+
const items = level.files
|
|
215
237
|
.filter((file) => file.providerMetadata.kind === "page" || file.providerMetadata.kind === "database")
|
|
216
238
|
.map((file) => ({
|
|
217
239
|
id: file.id,
|
|
218
240
|
name: file.name,
|
|
219
241
|
kind: file.providerMetadata.kind,
|
|
220
242
|
url: file.url,
|
|
221
|
-
|
|
243
|
+
parent: args.parent === undefined ? null : parent,
|
|
244
|
+
added: chosen.has(file.id),
|
|
245
|
+
}));
|
|
246
|
+
output(listOf("folders browse", {
|
|
247
|
+
items,
|
|
248
|
+
limit,
|
|
249
|
+
has_more: level.cursor !== undefined,
|
|
250
|
+
paging: "cursor",
|
|
251
|
+
...(level.cursor ? { cursor: level.cursor } : {}),
|
|
252
|
+
args: args.parent === undefined ? {} : { parent },
|
|
253
|
+
...(level.cut
|
|
254
|
+
? {
|
|
255
|
+
missing: [
|
|
256
|
+
{
|
|
257
|
+
field: "items",
|
|
258
|
+
why: "Notion's search gave only its 10,000 most recently edited results; older top-level pages or databases may be missing",
|
|
259
|
+
},
|
|
260
|
+
],
|
|
261
|
+
}
|
|
262
|
+
: {}),
|
|
222
263
|
}));
|
|
223
|
-
output(listOf("folders browse", { items, limit: Math.max(1, items.length), has_more: false }));
|
|
224
264
|
});
|
|
225
265
|
},
|
|
226
266
|
},
|
|
@@ -249,6 +289,7 @@ export const libraryCommands = () => {
|
|
|
249
289
|
},
|
|
250
290
|
state: syncState(env(), name, live),
|
|
251
291
|
principal: live,
|
|
292
|
+
profile: name,
|
|
252
293
|
roots,
|
|
253
294
|
textLimit: TEXT_LIMIT,
|
|
254
295
|
max: limit,
|
|
@@ -272,8 +313,11 @@ export const libraryCommands = () => {
|
|
|
272
313
|
}));
|
|
273
314
|
});
|
|
274
315
|
// The engine counts a round of changes as done; Notion's own pass may still have tasks for the next sync.
|
|
275
|
-
|
|
276
|
-
|
|
316
|
+
// A cut listing leaves its cursor on the engine's pending plan until the plan's pages are saved.
|
|
317
|
+
const held = syncState(env(), name, "").read();
|
|
318
|
+
const underWay = passUnderWay(held.pending?.cursor ?? held.cursor);
|
|
319
|
+
// As cli-core's own step: a page that keeps failing would make "sync again" an endless loop.
|
|
320
|
+
if (underWay && !result.errors.length)
|
|
277
321
|
next = [syncAgain(limit)];
|
|
278
322
|
return {
|
|
279
323
|
...result,
|
|
@@ -291,7 +335,7 @@ export const libraryCommands = () => {
|
|
|
291
335
|
const changed = foldersChangedAt(env(), name);
|
|
292
336
|
// Until the plan is made, or while Notion's own pass goes on, nothing says how much is left.
|
|
293
337
|
const unplanned = walkUnderWay(env(), name) ||
|
|
294
|
-
passUnderWay(held.cursor) ||
|
|
338
|
+
passUnderWay(held.pending?.cursor ?? held.cursor) ||
|
|
295
339
|
(changed !== undefined && (!held.lastSync || Date.parse(changed) > Date.parse(held.lastSync)));
|
|
296
340
|
return {
|
|
297
341
|
profile: name,
|