@wirecat/notion-cli 0.2.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.
Files changed (160) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +6 -2
  3. package/contracts/wirecat.json +48 -0
  4. package/dist/bin/notion.js +2 -2
  5. package/dist/bundle/{all-profiles-JGYLQZ5C.js → all-profiles-4IONYZB6.js} +10 -10
  6. package/dist/bundle/{anthropic-S2VSMIKQ.js → anthropic-OXF74J4P.js} +6 -6
  7. package/dist/bundle/{app-server-SASYDBCA.js → app-server-M2VF6ABM.js} +59 -59
  8. package/dist/bundle/{bun-LU5LP3JI.js → bun-DLA6QRLL.js} +2 -2
  9. package/dist/bundle/{bun-sqlite-JBSINB4O.js → bun-sqlite-F4BYLW3F.js} +7 -7
  10. package/dist/bundle/{chunk-4HWJOU7N.js → chunk-2MHMKNWD.js} +1 -1
  11. package/dist/bundle/{chunk-SHJQ6JKG.js → chunk-4KUJTSHG.js} +2 -2
  12. package/dist/bundle/{chunk-SWAOWNKW.js → chunk-4TQVZXOV.js} +3 -3
  13. package/dist/bundle/{chunk-ODBZNSZ6.js → chunk-5LBJNTEJ.js} +6 -6
  14. package/dist/bundle/{chunk-SZOVLP44.js → chunk-5UA2TYMI.js} +2 -2
  15. package/dist/bundle/{chunk-22QQUKWA.js → chunk-5XP4KQ2F.js} +1 -1
  16. package/dist/bundle/{chunk-4IPURN72.js → chunk-6GN7KU7X.js} +9 -9
  17. package/dist/bundle/{chunk-X4TIMMKJ.js → chunk-6JBLIQQN.js} +1 -1
  18. package/dist/bundle/{chunk-4ZTVJHWU.js → chunk-7NF3V5L2.js} +4 -4
  19. package/dist/bundle/{chunk-OTV53F34.js → chunk-7NGFGFE5.js} +9 -60
  20. package/dist/bundle/{chunk-VBHETQVV.js → chunk-7NVPM55S.js} +1908 -1013
  21. package/dist/bundle/{chunk-Z56QFOBR.js → chunk-7YZPBAQX.js} +1 -1
  22. package/dist/bundle/{chunk-3AL7QUS3.js → chunk-AYU5TFDU.js} +20 -20
  23. package/dist/bundle/{chunk-FPY6EJ7B.js → chunk-BEPFGITI.js} +55 -55
  24. package/dist/bundle/{chunk-VCIALTEM.js → chunk-CBGBFAYJ.js} +12 -4
  25. package/dist/bundle/{chunk-NQWV4WQO.js → chunk-CDGZZNGY.js} +6 -6
  26. package/dist/bundle/{chunk-DH5PRHT4.js → chunk-CIVXTBJY.js} +13 -13
  27. package/dist/bundle/{chunk-B26TQZKZ.js → chunk-COH7OEER.js} +14 -13
  28. package/dist/bundle/{chunk-XF26XKTS.js → chunk-D6RCRBDH.js} +2 -2
  29. package/dist/bundle/{chunk-YMYUBZWT.js → chunk-EQPAZ33O.js} +17 -17
  30. package/dist/bundle/{chunk-LAYPFBOM.js → chunk-EY6S7FV3.js} +6 -6
  31. package/dist/bundle/chunk-FEMHUSGO.js +88 -0
  32. package/dist/bundle/{chunk-FWVBPRL4.js → chunk-FSJHASRQ.js} +79 -62
  33. package/dist/bundle/{chunk-TPX2M45D.js → chunk-GBFEEHQC.js} +10 -10
  34. package/dist/bundle/{chunk-5IYKVRH2.js → chunk-GCCPFKSU.js} +434 -343
  35. package/dist/bundle/{chunk-3Z4YTSRY.js → chunk-GK4GLPG2.js} +3 -3
  36. package/dist/bundle/{chunk-GZOUFX3C.js → chunk-GSNE7OB4.js} +4 -4
  37. package/dist/bundle/{chunk-TSDBSIFM.js → chunk-HTKSCSJU.js} +4 -4
  38. package/dist/bundle/{chunk-5NFK5EM2.js → chunk-IJMFG7HB.js} +7 -7
  39. package/dist/bundle/{chunk-D7QSEEYW.js → chunk-JIRRF6BM.js} +4 -4
  40. package/dist/bundle/{chunk-5RSC54NA.js → chunk-JODE2XED.js} +25 -25
  41. package/dist/bundle/{chunk-RV64YUQX.js → chunk-K5I64ZVI.js} +9 -9
  42. package/dist/bundle/{chunk-AOCUKEAX.js → chunk-KL3P5TQK.js} +4 -4
  43. package/dist/bundle/{chunk-2LWO3PDX.js → chunk-L62XTC7N.js} +11 -11
  44. package/dist/bundle/{chunk-LLG2POQ7.js → chunk-L6H7PY4X.js} +3 -3
  45. package/dist/bundle/{chunk-5RDNBG7D.js → chunk-LIQMUDIZ.js} +2 -2
  46. package/dist/bundle/{chunk-WF4D56CA.js → chunk-M2EEIYBU.js} +2 -2
  47. package/dist/bundle/{chunk-MZU2YFBZ.js → chunk-M6DGZ2O6.js} +8 -8
  48. package/dist/bundle/{chunk-FXEJY4OL.js → chunk-MRA62W5K.js} +233 -167
  49. package/dist/bundle/{chunk-XYIT2XB3.js → chunk-MVA5HVKL.js} +20 -0
  50. package/dist/bundle/{chunk-YVI5SQPY.js → chunk-NO2LIHWA.js} +1 -1
  51. package/dist/bundle/{chunk-WCSOH4JS.js → chunk-OCDJ4FFA.js} +4 -4
  52. package/dist/bundle/{chunk-2F4QQ7WB.js → chunk-OI5DWZJG.js} +3 -3
  53. package/dist/bundle/{chunk-EUIVXFLJ.js → chunk-P3P6DA6K.js} +6 -6
  54. package/dist/bundle/{chunk-MY742GAD.js → chunk-QX3TPFEX.js} +37 -37
  55. package/dist/bundle/{chunk-6RA3EABS.js → chunk-R6SDRSZK.js} +62 -32
  56. package/dist/bundle/{chunk-5QIQEUOG.js → chunk-RMJMID5D.js} +8 -8
  57. package/dist/bundle/{chunk-BNPTZ5ZB.js → chunk-SGBS5QCU.js} +4 -4
  58. package/dist/bundle/{chunk-YNTLT3Z3.js → chunk-T5UNSFES.js} +8 -8
  59. package/dist/bundle/{chunk-M7S2NDWB.js → chunk-TFNRCCGR.js} +4 -4
  60. package/dist/bundle/{chunk-B7ON6KPT.js → chunk-TJCPTRYD.js} +7 -7
  61. package/dist/bundle/{chunk-KM6WHPHI.js → chunk-TXONV3HW.js} +2 -2
  62. package/dist/bundle/{chunk-NOQ7B5N7.js → chunk-TZ2QJ53V.js} +2 -2
  63. package/dist/bundle/{chunk-KGERXYTV.js → chunk-UKE3CGHK.js} +1 -1
  64. package/dist/bundle/{chunk-6EVKHZKN.js → chunk-UROEWCOG.js} +3 -3
  65. package/dist/bundle/{chunk-WJHZMR2W.js → chunk-WHJWURZB.js} +6 -6
  66. package/dist/bundle/{chunk-G3EZFRSS.js → chunk-WU3XHGOB.js} +112 -42
  67. package/dist/bundle/{chunk-2F6VO5HA.js → chunk-WZEEEQGC.js} +3 -3
  68. package/dist/bundle/{chunk-M3KB25D3.js → chunk-XCTOCVMW.js} +14 -14
  69. package/dist/bundle/{chunk-FT3LN3HP.js → chunk-Y5LAJWR5.js} +1 -1
  70. package/dist/bundle/{chunk-ZZ32DXTH.js → chunk-YAPDU3SV.js} +1 -1
  71. package/dist/bundle/{chunk-HL52XXZX.js → chunk-YFWLHTNO.js} +1 -1
  72. package/dist/bundle/{chunk-P7CUM5IB.js → chunk-YGCI3DHS.js} +1 -1
  73. package/dist/bundle/{chunk-KCLOUUYF.js → chunk-Z53LYX4M.js} +3 -3
  74. package/dist/bundle/{chunk-ZKAEZXUP.js → chunk-ZC6ZQQ55.js} +36 -37
  75. package/dist/bundle/command-contract-UBXS6NHI.js +38 -0
  76. package/dist/bundle/{command-server-entry-UFSG7KRO.js → command-server-entry-2SORMVRM.js} +27 -27
  77. package/dist/bundle/{decode-7LLWTSPT.js → decode-5O7IEFPN.js} +6 -6
  78. package/dist/bundle/{dispatch-2GY6JIJH.js → dispatch-YHQX6FEJ.js} +8 -8
  79. package/dist/bundle/{echarts-BXX4OQWC.js → echarts-ARLMVQC7.js} +2 -2
  80. package/dist/bundle/{embed-JXFNBTKH.js → embed-FUDUKQ3K.js} +7 -7
  81. package/dist/bundle/{embedder-57YZ44KO.js → embedder-HDRV7GX3.js} +10 -10
  82. package/dist/bundle/{failure-MYT4HPE3.js → failure-JHXICWIL.js} +3 -3
  83. package/dist/bundle/first-run-BGEFTXOE.js +29 -0
  84. package/dist/bundle/first-screen-F5F3VS6Y.js +38 -0
  85. package/dist/bundle/{instructions-2VECIDXF.js → instructions-MEFIKCDI.js} +1 -1
  86. package/dist/bundle/{mcp-O6ACR2DX.js → mcp-VMS6PBCU.js} +2 -2
  87. package/dist/bundle/meeting-combined-HNSS3FQY.js +24 -0
  88. package/dist/bundle/meeting-model-REZVYGQW.js +26 -0
  89. package/dist/bundle/{meeting-semantic-ETN3A4BJ.js → meeting-semantic-R4CSLVRG.js} +7 -7
  90. package/dist/bundle/{node-MPEQSFI3.js → node-MAQALPLA.js} +2 -2
  91. package/dist/bundle/{node-sqlite-WA32MYSJ.js → node-sqlite-J7IJYNBO.js} +8 -8
  92. package/dist/bundle/notion.js +14 -14
  93. package/dist/bundle/{oauth-IAFZG3IR.js → oauth-AMV4YGJD.js} +8 -8
  94. package/dist/bundle/{open-M3JQUC5G.js → open-AB27MTGR.js} +6 -6
  95. package/dist/bundle/{openai-HXUEHUSD.js → openai-D77MU5XV.js} +17 -17
  96. package/dist/bundle/{process-F6TKXWWA.js → process-SIOWTRJ6.js} +1 -1
  97. package/dist/bundle/{program-Y7JAB6TG.js → program-QC5MX4ZJ.js} +2816 -1645
  98. package/dist/bundle/{prompt-IMUQLZD2.js → prompt-W77YDHA6.js} +6 -6
  99. package/dist/bundle/{recognize-2MZAYHAA.js → recognize-3JAXQQ36.js} +5 -5
  100. package/dist/bundle/{remote-OV4LB6VR.js → remote-PSOJXCXO.js} +11 -11
  101. package/dist/bundle/{rerank-ZIULUS34.js → rerank-EE44ZTGL.js} +8 -8
  102. package/dist/bundle/{schemas-DIVZS6TU.js → schemas-LBYUMBC6.js} +2 -2
  103. package/dist/bundle/{serve-YU7QBP6L.js → serve-XJMGAMFW.js} +10 -10
  104. package/dist/bundle/{server-LGMNONSB.js → server-ASU6CP5R.js} +51 -51
  105. package/dist/bundle/server-WSPQ5EOA.js +72 -0
  106. package/dist/bundle/{services-5WY4DCPJ.js → services-PT4PA4J6.js} +46 -39
  107. package/dist/bundle/{sqlite-runtime-5MXZDETH.js → sqlite-runtime-YHXRTVXE.js} +7 -7
  108. package/dist/bundle/{state-LWMZH2KI.js → state-T6ZKFWGD.js} +7 -7
  109. package/dist/bundle/{store-EPZYV4VW.js → store-3MUCZEI3.js} +20 -18
  110. package/dist/bundle/{store-QE6FEIZD.js → store-E5EE25FY.js} +24 -20
  111. package/dist/bundle/store-maintenance-command-ZZ55BBBG.js +63 -0
  112. package/dist/commands/api.d.ts.map +1 -1
  113. package/dist/commands/api.js +13 -4
  114. package/dist/commands/api.js.map +1 -1
  115. package/dist/commands/documents.d.ts +8 -0
  116. package/dist/commands/documents.d.ts.map +1 -1
  117. package/dist/commands/documents.js +173 -3
  118. package/dist/commands/documents.js.map +1 -1
  119. package/dist/commands/library.d.ts.map +1 -1
  120. package/dist/commands/library.js +3 -1
  121. package/dist/commands/library.js.map +1 -1
  122. package/dist/config.d.ts +19 -0
  123. package/dist/config.d.ts.map +1 -1
  124. package/dist/config.js +73 -5
  125. package/dist/config.js.map +1 -1
  126. package/dist/context.d.ts +3 -0
  127. package/dist/context.d.ts.map +1 -1
  128. package/dist/context.js +3 -0
  129. package/dist/context.js.map +1 -1
  130. package/dist/generated/types.d.ts +485 -375
  131. package/dist/generated/types.d.ts.map +1 -1
  132. package/dist/notion/errors.d.ts +5 -0
  133. package/dist/notion/errors.d.ts.map +1 -1
  134. package/dist/notion/errors.js +7 -0
  135. package/dist/notion/errors.js.map +1 -1
  136. package/dist/notion/writes.d.ts +40 -0
  137. package/dist/notion/writes.d.ts.map +1 -0
  138. package/dist/notion/writes.js +112 -0
  139. package/dist/notion/writes.js.map +1 -0
  140. package/dist/sync/cursor.d.ts +12 -0
  141. package/dist/sync/cursor.d.ts.map +1 -1
  142. package/dist/sync/files.d.ts +10 -0
  143. package/dist/sync/files.d.ts.map +1 -1
  144. package/dist/sync/files.js +19 -0
  145. package/dist/sync/files.js.map +1 -1
  146. package/dist/sync/source.d.ts.map +1 -1
  147. package/dist/sync/source.js +43 -25
  148. package/dist/sync/source.js.map +1 -1
  149. package/dist/version.d.ts +1 -1
  150. package/dist/version.js +1 -1
  151. package/package.json +3 -3
  152. package/skills/notion-cli/SKILL.md +6 -0
  153. package/dist/bundle/command-contract-JS5V27NX.js +0 -38
  154. package/dist/bundle/first-run-3PF7T74J.js +0 -29
  155. package/dist/bundle/first-screen-7BEROEQR.js +0 -36
  156. package/dist/bundle/meeting-combined-PPUQ3KBR.js +0 -24
  157. package/dist/bundle/meeting-model-ZNMYKMCD.js +0 -26
  158. package/dist/bundle/server-FKQET4ZO.js +0 -71
  159. package/dist/bundle/store-maintenance-command-ZUUUFCHL.js +0 -62
  160. /package/dist/bundle/{chunk-VKE77B3F.js → chunk-SHTHNBHG.js} +0 -0
@@ -21,4 +21,9 @@ export declare const blocked: (base?: Record<string, unknown>) => CliError;
21
21
  export declare const failureOf: (error: unknown) => unknown;
22
22
  /** An SDK call with its failure mapped; a CliError from the fetch chain passes through as it is. */
23
23
  export declare const mapped: <T>(call: () => Promise<T>) => Promise<T>;
24
+ export declare const isNotFound: (error: unknown) => boolean;
25
+ /** Answers about one item, not the sync: a linked database view answers 404 by design, a restricted page 403. */
26
+ export declare const isItemError: (error: unknown) => boolean;
27
+ /** Notion's own 400, such as a list position it no longer takes; not this code's refusals, which carry no status. */
28
+ export declare const isRefused: (error: unknown) => boolean;
24
29
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/notion/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,MAAM,mBAAmB,CAAA;AAIxD,gIAAgI;AAChI,eAAO,MAAM,OAAO;;;;;;GAyCnB,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,OAAO,UAAuC,CAAA;AAE3D,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,8GAA8G;AAC9G,eAAO,MAAM,OAAO,+BAA+B,CAAA;AAEnD,eAAO,MAAM,OAAO,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAQ,QAK1D,CAAA;AASH;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,KAAG,OA8D1C,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,MAAM,GAAU,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAMjE,CAAA"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/notion/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAc,MAAM,mBAAmB,CAAA;AAIxD,gIAAgI;AAChI,eAAO,MAAM,OAAO;;;;;;GA2CnB,CAAA;AAED,uGAAuG;AACvG,eAAO,MAAM,OAAO,UAAuC,CAAA;AAE3D,eAAO,MAAM,MAAM,WAAW,CAAA;AAE9B,8GAA8G;AAC9G,eAAO,MAAM,OAAO,+BAA+B,CAAA;AAEnD,eAAO,MAAM,OAAO,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAQ,QAK1D,CAAA;AASH;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,OAAO,KAAG,OA8D1C,CAAA;AAED,oGAAoG;AACpG,eAAO,MAAM,MAAM,GAAU,CAAC,QAAQ,MAAM,OAAO,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAMjE,CAAA;AAED,eAAO,MAAM,UAAU,UAAW,OAAO,YAAoD,CAAA;AAC7F,iHAAiH;AACjH,eAAO,MAAM,WAAW,UAAW,OAAO,YAC8C,CAAA;AACxF,qHAAqH;AACrH,eAAO,MAAM,SAAS,UAAW,OAAO,YACgD,CAAA"}
@@ -10,6 +10,8 @@ export const REASONS = defineReasons([
10
10
  ["notion.not-shared", "not_found", "no such page or database, or it is not shared with this token"],
11
11
  ["notion.refused", "validation_error", "Notion refused the request as it was sent"],
12
12
  ["notion.conflict", "conflict", "Notion could not save it because it changed at the same time"],
13
+ ["file.refused-place", "validation_error", "a credential file or a WireCat folder is never sent to Notion"],
14
+ ["notion.text-refused", "validation_error", "Notion refused the new text of a page"],
13
15
  ["notion.rate-limited", "rate_limited", "Notion asked to slow down"],
14
16
  ["notion.unavailable", "provider_unavailable", "Notion is down or overloaded"],
15
17
  ["notion.invalid-response", "invalid_response", "Notion's answer does not have the documented shape"],
@@ -124,4 +126,9 @@ export const mapped = async (call) => {
124
126
  throw failureOf(error);
125
127
  }
126
128
  };
129
+ export const isNotFound = (error) => isCliError(error) && error.code === "not_found";
130
+ /** Answers about one item, not the sync: a linked database view answers 404 by design, a restricted page 403. */
131
+ export const isItemError = (error) => isCliError(error) && (error.code === "not_found" || error.code === "permission_error");
132
+ /** Notion's own 400, such as a list position it no longer takes; not this code's refusals, which carry no status. */
133
+ export const isRefused = (error) => isCliError(error) && error.code === "validation_error" && error.details.status === 400;
127
134
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/notion/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3D,gIAAgI;AAChI,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAEhC;IACE,CAAC,sBAAsB,EAAE,sBAAsB,EAAE,0BAA0B,CAAC;IAC5E,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,uCAAuC,CAAC;IAClF,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,oDAAoD,CAAC;IAC5F,CAAC,mBAAmB,EAAE,WAAW,EAAE,+DAA+D,CAAC;IACnG,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,2CAA2C,CAAC;IACnF,CAAC,iBAAiB,EAAE,UAAU,EAAE,8DAA8D,CAAC;IAC/F,CAAC,qBAAqB,EAAE,cA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ACpE,IAAI,CAAC;QACH,OAAO,MAAM,IAAI,EAAE,CAAA;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,SAAS,CAAC,KAAK,CAAC,CAAA;IACxB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAA;AAC7F,iHAAiH;AACjH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAE,EAAE,CAC5C,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,WAAW,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,CAAC,CAAA;AACxF,qHAAqH;AACrH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAE,EAAE,CAC1C,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,kBAAkB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,GAAG,CAAA"}
@@ -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,GAAG,CAAC,CAAC,WAAW,CAAC;IAC7B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACzB,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjC,gBAAgB,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAA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,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"}
@@ -131,5 +131,17 @@ export type ListPosition = v.InferOutput<typeof ListPosition>;
131
131
  export declare const encodeListPosition: (position: ListPosition) => string;
132
132
  /** A position this code cannot read is one Notion would not take either: the engine lists the folder again. */
133
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
+ }
134
146
  export {};
135
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,KAAK,CAAC,MAAM,SAAS,CAAA;AAI5B,QAAA,MAAM,IAAI;;;;IAKN,yGAAyG;;;;;;;;;;;;;;IAUzG,+DAA+D;;IAE/D,wGA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E,MAAM,CAAA;KAAE,EAAE,CAAA;IACxC,IAAI,EAAE,MAAM,EAAE,CAAA;CACf"}
@@ -5,6 +5,7 @@ import type { NotionParent } from "../notion/reads.js";
5
5
  import type { FrontMatterValue } from "./front-matter.js";
6
6
  /** The folder that stands for everything the token sees, the scope when no folder is chosen. */
7
7
  export declare const WORKSPACE_ROOT = "notion-workspace";
8
+ export declare const parentId: (parent: NotionParent) => string;
8
9
  export type NotionKind = "workspace" | "page" | "row" | "database";
9
10
  export interface NotionIdentity {
10
11
  id: string;
@@ -74,4 +75,13 @@ export interface SyncWarning {
74
75
  message: string;
75
76
  retry_after_ms?: number;
76
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;
77
87
  //# sourceMappingURL=files.d.ts.map
@@ -1 +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,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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MAAM,CAAC,CAAA;IACtB,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"}
@@ -1,5 +1,19 @@
1
1
  /** The folder that stands for everything the token sees, the scope when no folder is chosen. */
2
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
+ };
3
17
  /**
4
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
5
19
  * the children of every row would cost a request per row.
@@ -9,4 +23,9 @@ export const isNotionFolder = (file) => file.providerMetadata.kind !== "row";
9
23
  export const isNotionDocument = (file) => file.providerMetadata.kind === "page";
10
24
  /** A page may have an empty title, and every catalog entry needs a name. */
11
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();
12
31
  //# sourceMappingURL=files.js.map
@@ -1 +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;AA4BhD;;;GAGG;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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"}
@@ -1 +1 @@
1
- {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/sync/source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAA+B,MAAM,6BAA6B,CAAA;AAE9F,OAAO,KAAK,EAOV,WAAW,EAEZ,MAAM,oBAAoB,CAAA;AAW3B,OAAO,EACL,KAAK,UAAU,EAGf,KAAK,mBAAmB,EAGzB,MAAM,YAAY,CAAA;AAInB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAA;AAGnB,sHAAsH;AACtH,eAAO,MAAM,SAAS,QAAa,CAAA;AACnC,eAAO,MAAM,cAAc,QAAa,CAAA;AAkDxC,6FAA6F;AAC7F,eAAO,MAAM,YAAY,UAAW,MAAM,GAAG,SAAS,YAAkE,CAAA;AAExH,eAAO,MAAM,YAAY,WAAY,WAAW,YAAW,mBAAmB,KAAQ,cAAc,CAAC,UAAU,CA43B9G,CAAA"}
1
+ {"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/sync/source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAA+B,MAAM,6BAA6B,CAAA;AAG9F,OAAO,KAAK,EAOV,WAAW,EAEZ,MAAM,oBAAoB,CAAA;AAa3B,OAAO,EAEL,KAAK,UAAU,EAGf,KAAK,mBAAmB,EAKzB,MAAM,YAAY,CAAA;AAInB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAA;AAGnB,sHAAsH;AACtH,eAAO,MAAM,SAAS,QAAa,CAAA;AACnC,eAAO,MAAM,cAAc,QAAa,CAAA;AAUxC,6FAA6F;AAC7F,eAAO,MAAM,YAAY,UAAW,MAAM,GAAG,SAAS,YAAkE,CAAA;AAExH,eAAO,MAAM,YAAY,WAAY,WAAW,YAAW,mBAAmB,KAAQ,cAAc,CAAC,UAAU,CAg6B9G,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { CliError, isCliError } from "@wirecat/cli-base";
2
2
  import { deadlineMargin } from "@wirecat/cli-core/background";
3
+ import { isItemError, isNotFound, isRefused } from "../notion/errors.js";
3
4
  import { withoutSignedLinks } from "../notion/links.js";
4
5
  import { decodeCursor, decodeListPosition, encodeCursor, encodeListPosition, } from "./cursor.js";
5
- import { UNTITLED, WORKSPACE_ROOT, } from "./files.js";
6
+ import { parentId, sourceIds, UNTITLED, WORKSPACE_ROOT, } from "./files.js";
6
7
  import { frontMatter, frontMatterLines, titleOf } from "./front-matter.js";
7
8
  import { pageText } from "./markdown.js";
8
9
  export { isNotionDocument, isNotionFolder, UNTITLED, WORKSPACE_ROOT, } from "./files.js";
@@ -12,27 +13,8 @@ export const SETTLE_MS = 3 * MINUTE;
12
13
  export const MIN_OVERLAP_MS = 2 * MINUTE;
13
14
  const DEFAULTS = { overlapMs: 10 * MINUTE, walkEveryMs: 24 * 60 * MINUTE, maxRequests: 2000 };
14
15
  const PAGE_SIZE = 100;
15
- const parentId = (parent) => {
16
- switch (parent.type) {
17
- case "workspace":
18
- return WORKSPACE_ROOT;
19
- case "page_id":
20
- return parent.page_id;
21
- case "data_source_id":
22
- return parent.data_source_id;
23
- case "database_id":
24
- return parent.database_id;
25
- case "block_id":
26
- return parent.block_id;
27
- }
28
- };
29
16
  const minus = (iso, ms) => new Date(Date.parse(iso) - ms).toISOString();
30
17
  const later = (a, b) => (!a ? b : !b ? a : Date.parse(a) >= Date.parse(b) ? a : b);
31
- const isNotFound = (error) => isCliError(error) && error.code === "not_found";
32
- /** Answers about one item, not the sync: a linked database view answers 404 by design, a restricted page 403. */
33
- const isItemError = (error) => isCliError(error) && (error.code === "not_found" || error.code === "permission_error");
34
- /** Notion's own 400, such as a list position it no longer takes; not this code's refusals, which carry no status. */
35
- const isRefused = (error) => isCliError(error) && error.code === "validation_error" && error.details.status === 400;
36
18
  const text = (parts) => parts.map((part) => part.plain_text).join("");
37
19
  const OUT_OF_TIME = new Error("the run's deadline is near");
38
20
  /** Whether a Notion pass is still under way: the next `changes()` goes on with its tasks. */
@@ -576,7 +558,29 @@ export const notionSource = (notion, options = {}) => {
576
558
  // The engine walks every folder it is sent, all its rows, so a database it already holds is not sent again.
577
559
  const unheld = (file) => {
578
560
  const before = known.get(file.id);
579
- return !before || before.name !== file.name || before.parents[0] !== file.parents[0];
561
+ return (!before ||
562
+ before.name !== file.name ||
563
+ before.parents[0] !== file.parents[0] ||
564
+ sourceIds(before) !== sourceIds(file));
565
+ };
566
+ // Search still finds the rows of a data source taken out of its database; they stay out with it.
567
+ const unlistedRow = (page) => {
568
+ if (page.parent.type !== "data_source_id")
569
+ return false;
570
+ const { database_id, data_source_id } = page.parent;
571
+ const sources = known.get(database_id)?.providerMetadata.dataSources;
572
+ return sources !== undefined && !sources.some((item) => item.id === data_source_id);
573
+ };
574
+ // Rows of a data source the database no longer lists go with it. A database Notion will not show (403) lists
575
+ // nothing, so its rows stay.
576
+ const unlisted = (database) => {
577
+ const listed = new Set(database.data_sources.map((source) => source.id));
578
+ cursor.sources = cursor.sources.filter((item) => item.database !== database.id || listed.has(item.source));
579
+ for (const file of known.values())
580
+ if (file.providerMetadata.kind === "row" &&
581
+ file.parents[0] === database.id &&
582
+ !listed.has(file.providerMetadata.parent?.id ?? ""))
583
+ gone(file.id);
580
584
  };
581
585
  /** Work this run keeps even when the deadline cuts its step: a direct read or a resolved kind. */
582
586
  let kept = 0;
@@ -642,7 +646,10 @@ export const notionSource = (notion, options = {}) => {
642
646
  if (kind === "page")
643
647
  pass.next = later(pass.next, result.last_edited_time);
644
648
  if (result.object === "page") {
645
- emit(await pageFile(result));
649
+ if (!unlistedRow(result))
650
+ emit(await pageFile(result));
651
+ else if (known.has(result.id))
652
+ gone(result.id);
646
653
  continue;
647
654
  }
648
655
  const id = result.parent.database_id;
@@ -693,8 +700,11 @@ export const notionSource = (notion, options = {}) => {
693
700
  const file = await databaseFile(found);
694
701
  if (file.trashed)
695
702
  gone(task.id);
696
- else if (unheld(file))
697
- emit(file);
703
+ else {
704
+ unlisted(found);
705
+ if (unheld(file))
706
+ emit(file);
707
+ }
698
708
  if (task.walk && !file.trashed && file.parents[0] === WORKSPACE_ROOT) {
699
709
  shown(file.id);
700
710
  queue({ t: "walk", id: file.id });
@@ -729,8 +739,15 @@ export const notionSource = (notion, options = {}) => {
729
739
  if (!isNotFound(error))
730
740
  throw error;
731
741
  cursor.sources = cursor.sources.filter((item) => item.source !== task.source);
732
- if (isGone(await readDatabase(task.database)))
742
+ const database = await readDatabase(task.database);
743
+ if (isGone(database))
733
744
  gone(task.database);
745
+ else if (typeof database === "object") {
746
+ unlisted(database);
747
+ const file = await databaseFile(database);
748
+ if (unheld(file))
749
+ emit(file);
750
+ }
734
751
  return;
735
752
  }
736
753
  for (const row of page.rows)
@@ -759,6 +776,7 @@ export const notionSource = (notion, options = {}) => {
759
776
  gone(id);
760
777
  return;
761
778
  }
779
+ unlisted(database);
762
780
  for (const source of database.data_sources) {
763
781
  addSource(id, source.id);
764
782
  queue({ t: "rows", database: id, source: source.id, full: true });