@bastani/atomic 0.10.11-alpha.3 → 0.10.11-alpha.4

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 (288) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/_shared/dist-KOELCESV.js +2 -2
  3. package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
  4. package/dist/_shared/lib-4PES5P4V.js +2 -2
  5. package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +4 -4
  6. package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +4 -4
  7. package/dist/_shared/mode-shared-2QJSCUM6.js +4 -4
  8. package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
  9. package/dist/_shared/p1b-elig-TVB5CBLL.js +22 -6
  10. package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -1
  11. package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
  12. package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
  13. package/dist/_shared/runtime-O4KCSG4C.js +2 -2
  14. package/dist/_shared/sdk-B5LEWGGI.js +899 -515
  15. package/dist/_shared/sdk-B5LEWGGI.js.map +1 -1
  16. package/dist/_shared/session-data-AHTU7IS6.js +2 -2
  17. package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
  18. package/dist/_shared/{startup-0-0-EZUKEP4Q.js → startup-0-0-XJJDOIEC.js} +6 -12
  19. package/dist/_shared/{startup-0-0-EZUKEP4Q.js.map → startup-0-0-XJJDOIEC.js.map} +1 -1
  20. package/dist/_shared/{startup-0-1-RTOHJFDJ.js → startup-0-1-M6OWAYHH.js} +354 -103
  21. package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
  22. package/dist/_shared/startup-0-2-5QHPCEON.js +18 -9
  23. package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
  24. package/dist/_shared/startup-0-3-4ZYBYQNM.js +4 -4
  25. package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
  26. package/dist/_shared/startup-0-5-YDW47QX6.js +4 -4
  27. package/dist/_shared/startup-10-0-TDQNBDDL.js +4 -4
  28. package/dist/_shared/startup-12-0-55AAXBJZ.js +1 -1
  29. package/dist/_shared/startup-14-0-MLX36RBG.js +2 -2
  30. package/dist/_shared/startup-15-0-YUKGAC63.js +2 -2
  31. package/dist/_shared/startup-15-1-4S7FLMNG.js +4 -4
  32. package/dist/_shared/startup-8-0-34CBHPZH.js +2114 -235
  33. package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
  34. package/dist/_shared/startup-8-1-LZFXSD3Z.js +12 -12
  35. package/dist/_shared/storage-command-7MGXLJGZ.js +6 -6
  36. package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
  37. package/dist/_shared/storage-status-K7PX2RXA.js +2 -2
  38. package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
  39. package/dist/_shared/team-DOQKICG2.js +1 -1
  40. package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
  41. package/dist/builtin/intercom/CHANGELOG.md +19 -0
  42. package/dist/builtin/intercom/broker/broker.bundle.mjs +1020 -108
  43. package/dist/builtin/intercom/broker/client.ts +8 -0
  44. package/dist/builtin/intercom/broker/database-wake-up-bus.ts +91 -14
  45. package/dist/builtin/intercom/broker/multinode-router.ts +102 -17
  46. package/dist/builtin/intercom/broker/multinode-state-store.ts +41 -2
  47. package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
  48. package/dist/builtin/intercom/broker/sql-add-column.ts +22 -1
  49. package/dist/builtin/intercom/broker/sql-lease-store.ts +304 -48
  50. package/dist/builtin/intercom/broker/sql-outbox-store.ts +541 -50
  51. package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +239 -8
  52. package/dist/builtin/intercom/broker/sql-retention.ts +11 -2
  53. package/dist/builtin/intercom/broker/sql-schema.ts +42 -8
  54. package/dist/builtin/intercom/index.bundle.mjs +13 -2
  55. package/dist/builtin/intercom/package.json +1 -1
  56. package/dist/builtin/mcp/index.bundle.mjs +1 -1
  57. package/dist/builtin/mcp/package.json +1 -1
  58. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  59. package/dist/builtin/subagents/package.json +1 -1
  60. package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +8 -1
  61. package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
  62. package/dist/builtin/web-access/index.bundle.mjs +1 -1
  63. package/dist/builtin/web-access/package.json +1 -1
  64. package/dist/cli/args.js +2 -2
  65. package/dist/cli/auth-cli.code.js +2 -2
  66. package/dist/cli/auth-cli.impl.js +3 -3
  67. package/dist/cli/auth-cli.js +3 -3
  68. package/dist/cli/blueprint-command.code.js +1 -1
  69. package/dist/cli/blueprint-command.impl.js +3 -3
  70. package/dist/cli/blueprint-command.js +3 -3
  71. package/dist/cli/intercom-command.code.js +2 -2
  72. package/dist/cli/intercom-command.impl.js +3 -3
  73. package/dist/cli/intercom-command.js +3 -3
  74. package/dist/cli/list-models.code.js +2 -2
  75. package/dist/cli/list-models.impl.js +3 -3
  76. package/dist/cli/list-models.js +3 -3
  77. package/dist/cli/session-picker.code.js +1 -1
  78. package/dist/cli/session-picker.impl.js +3 -3
  79. package/dist/cli/session-picker.js +3 -3
  80. package/dist/cli/startup-ui.code.js +1 -1
  81. package/dist/cli/startup-ui.impl.js +3 -3
  82. package/dist/cli/startup-ui.js +3 -3
  83. package/dist/cli/storage-command.impl.js +3 -3
  84. package/dist/cli/storage-command.js +3 -3
  85. package/dist/cli/storage-search-session.code.js +1 -1
  86. package/dist/cli/storage-search-session.impl.js +3 -3
  87. package/dist/cli/storage-search-session.js +3 -3
  88. package/dist/cli/team-command.code.js +1 -1
  89. package/dist/cli/team-command.impl.js +3 -3
  90. package/dist/cli/team-command.js +3 -3
  91. package/dist/cli.js +2 -2
  92. package/dist/core/debug.impl.js +3 -3
  93. package/dist/core/debug.js +3 -3
  94. package/dist/core/export-html/card-projection.impl.js +3 -3
  95. package/dist/core/export-html/card-projection.js +3 -3
  96. package/dist/core/export-html/index.code.js +4 -4
  97. package/dist/core/export-html/index.code.js.map +1 -1
  98. package/dist/core/export-html/index.impl.js +3 -3
  99. package/dist/core/export-html/index.js +3 -3
  100. package/dist/core/export-html/json-spans.impl.js +3 -3
  101. package/dist/core/export-html/json-spans.js +3 -3
  102. package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
  103. package/dist/core/export-html/oversized-render-inputs.js +3 -3
  104. package/dist/core/export-html/tool-renderer.impl.js +3 -3
  105. package/dist/core/export-html/tool-renderer.js +3 -3
  106. package/dist/core/extensions/jiti-loader.impl.js +3 -3
  107. package/dist/core/extensions/jiti-loader.js +3 -3
  108. package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
  109. package/dist/core/extensions/jiti-static-loader.js +3 -3
  110. package/dist/core/extensions/loader-host-modules.code.js +1 -1
  111. package/dist/core/extensions/loader-host-modules.impl.js +3 -3
  112. package/dist/core/extensions/loader-host-modules.js +3 -3
  113. package/dist/core/extensions/loader-virtual-modules.js +1 -1
  114. package/dist/core/extensions/runner-context.js +1 -1
  115. package/dist/core/intercom-broker-control-host.impl.js +3 -3
  116. package/dist/core/intercom-broker-control-host.js +3 -3
  117. package/dist/core/intercom-broker-control.code.js +3 -3
  118. package/dist/core/intercom-broker-control.impl.js +3 -3
  119. package/dist/core/intercom-broker-control.js +3 -3
  120. package/dist/core/package-manager-storage-adapters.impl.js +3 -3
  121. package/dist/core/package-manager-storage-adapters.js +3 -3
  122. package/dist/core/process-start-token.d.ts +5 -4
  123. package/dist/core/sdk.code.js +2 -2
  124. package/dist/core/sdk.impl.js +3 -3
  125. package/dist/core/sdk.js +3 -3
  126. package/dist/core/session-manager-core.js +4 -4
  127. package/dist/core/session-manager-list.impl.js +3 -3
  128. package/dist/core/session-manager-list.js +3 -3
  129. package/dist/core/session-manager.code.js +1 -1
  130. package/dist/core/session-manager.impl.js +3 -3
  131. package/dist/core/session-manager.js +3 -3
  132. package/dist/core/session-storage.impl.js +3 -3
  133. package/dist/core/session-storage.js +3 -3
  134. package/dist/core/storage/database.d.ts +6 -0
  135. package/dist/core/storage/database.js.map +1 -1
  136. package/dist/core/storage/fenced-paths.d.ts +7 -6
  137. package/dist/core/storage/fenced-paths.js +7 -6
  138. package/dist/core/storage/fenced-paths.js.map +1 -1
  139. package/dist/core/storage/index.js +2 -2
  140. package/dist/core/storage/node-sqlite-thread.js +209 -19
  141. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  142. package/dist/core/storage/node-sqlite.js +435 -71
  143. package/dist/core/storage/node-sqlite.js.map +1 -1
  144. package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
  145. package/dist/core/storage/offline-snapshot-file.js +3 -3
  146. package/dist/core/storage/provider.js +2 -2
  147. package/dist/core/storage/schema-catalog.d.ts +69 -7
  148. package/dist/core/storage/schema-catalog.js +352 -61
  149. package/dist/core/storage/schema-catalog.js.map +1 -1
  150. package/dist/core/storage/selection.js +2 -2
  151. package/dist/core/storage/session/branch-fork-source.code.js +2 -2
  152. package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
  153. package/dist/core/storage/session/branch-fork-source.js +3 -3
  154. package/dist/core/storage/session/card-view.impl.js +3 -3
  155. package/dist/core/storage/session/card-view.js +3 -3
  156. package/dist/core/storage/session/child-reader.code.js +3 -3
  157. package/dist/core/storage/session/child-reader.impl.js +3 -3
  158. package/dist/core/storage/session/child-reader.js +3 -3
  159. package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
  160. package/dist/core/storage/session/chunked-resume-projection.js +3 -3
  161. package/dist/core/storage/session/expanded-child-details.code.js +2 -2
  162. package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
  163. package/dist/core/storage/session/expanded-child-details.js +3 -3
  164. package/dist/core/storage/session/fork-detach.d.ts +11 -1
  165. package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
  166. package/dist/core/storage/session/fork-row-bytes.js +3 -3
  167. package/dist/core/storage/session/fork-row-index.impl.js +3 -3
  168. package/dist/core/storage/session/fork-row-index.js +3 -3
  169. package/dist/core/storage/session/fork-staging.code.js +1 -1
  170. package/dist/core/storage/session/fork-staging.impl.js +3 -3
  171. package/dist/core/storage/session/fork-staging.js +3 -3
  172. package/dist/core/storage/session/fork-sweep.js +31 -7
  173. package/dist/core/storage/session/fork-sweep.js.map +1 -1
  174. package/dist/core/storage/session/fork-window.code.js +3 -3
  175. package/dist/core/storage/session/fork-window.impl.js +3 -3
  176. package/dist/core/storage/session/fork-window.js +3 -3
  177. package/dist/core/storage/session/history-pages.impl.js +3 -3
  178. package/dist/core/storage/session/history-pages.js +3 -3
  179. package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
  180. package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
  181. package/dist/core/storage/session/jsonl-session-lock.d.ts +100 -0
  182. package/dist/core/storage/session/jsonl-session-store.d.ts +41 -23
  183. package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
  184. package/dist/core/storage/session/jsonl-session-store.js +3 -3
  185. package/dist/core/storage/session/memory-session-store.impl.js +3 -3
  186. package/dist/core/storage/session/memory-session-store.js +3 -3
  187. package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
  188. package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
  189. package/dist/core/storage/session/pinned-branch-resume.js +3 -3
  190. package/dist/core/storage/session/released-history-files.code.js +8 -8
  191. package/dist/core/storage/session/released-history-files.code.js.map +1 -1
  192. package/dist/core/storage/session/released-history-files.impl.js +3 -3
  193. package/dist/core/storage/session/released-history-files.js +3 -3
  194. package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
  195. package/dist/core/storage/session/resident-fork-rows.js +3 -3
  196. package/dist/core/storage/session/session-resume.impl.js +3 -3
  197. package/dist/core/storage/session/session-resume.js +3 -3
  198. package/dist/core/storage/session/session-search-index.d.ts +9 -1
  199. package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
  200. package/dist/core/storage/session/snapshot-cut.js +3 -3
  201. package/dist/core/storage/session/snapshot-history.code.js +3 -3
  202. package/dist/core/storage/session/snapshot-history.impl.js +3 -3
  203. package/dist/core/storage/session/snapshot-history.js +3 -3
  204. package/dist/core/storage/session/sql-session-store.d.ts +51 -7
  205. package/dist/core/storage/session/sql-session-store.impl.js +3 -3
  206. package/dist/core/storage/session/sql-session-store.js +3 -3
  207. package/dist/core/storage/session/tree-outline.impl.js +3 -3
  208. package/dist/core/storage/session/tree-outline.js +3 -3
  209. package/dist/core/storage/session/tree-presentation.impl.js +3 -3
  210. package/dist/core/storage/session/tree-presentation.js +3 -3
  211. package/dist/core/storage/sqlite-facade.d.ts +6 -0
  212. package/dist/core/storage/sqlite-facade.js +309 -33
  213. package/dist/core/storage/sqlite-facade.js.map +1 -1
  214. package/dist/core/storage/sqlite-open-batch.js +10 -0
  215. package/dist/core/storage/sqlite-open-batch.js.map +1 -0
  216. package/dist/core/storage/storage-status.impl.js +3 -3
  217. package/dist/core/storage/storage-status.js +3 -3
  218. package/dist/core/storage/team.impl.js +3 -3
  219. package/dist/core/storage/team.js +3 -3
  220. package/dist/core/structured-output/index.impl.js +3 -3
  221. package/dist/core/structured-output/index.js +3 -3
  222. package/dist/core/tasks/task-completion-entry.impl.js +3 -3
  223. package/dist/core/tasks/task-completion-entry.js +3 -3
  224. package/dist/core/tasks/task-file-history.code.js +3 -3
  225. package/dist/core/tasks/task-file-history.impl.js +3 -3
  226. package/dist/core/tasks/task-file-history.js +3 -3
  227. package/dist/core/tasks/task-reference-archive.code.js +3 -3
  228. package/dist/core/tasks/task-reference-archive.js +3 -3
  229. package/dist/core/tasks/task-reference-identity.js +3 -3
  230. package/dist/core/tasks/task-reference-stream.impl.js +3 -3
  231. package/dist/core/tasks/task-reference-stream.js +3 -3
  232. package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
  233. package/dist/core/tasks/task-unsaved-answer.js +3 -3
  234. package/dist/core/tasks/task-view-source.impl.js +3 -3
  235. package/dist/core/tasks/task-view-source.js +3 -3
  236. package/dist/core/tools/read-url.code.js +2 -2
  237. package/dist/core/tools/read-url.impl.js +3 -3
  238. package/dist/core/tools/read-url.js +3 -3
  239. package/dist/core/worktree-snapshot/blob-store.d.ts +5 -3
  240. package/dist/core/worktree-snapshot/blob-store.js +151 -21
  241. package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
  242. package/dist/core/worktree-snapshot/errors.code.js +2 -2
  243. package/dist/core/worktree-snapshot/errors.impl.js +3 -3
  244. package/dist/core/worktree-snapshot/errors.js +3 -3
  245. package/dist/core/worktree-snapshot/fork-snapshot-index.js +158 -41
  246. package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
  247. package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
  248. package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
  249. package/dist/extensions/codemode/execute.code.js +1 -1
  250. package/dist/extensions/codemode/execute.impl.js +3 -3
  251. package/dist/extensions/codemode/execute.js +3 -3
  252. package/dist/extensions/codemode/renderer.code.js +1 -1
  253. package/dist/extensions/codemode/renderer.impl.js +3 -3
  254. package/dist/extensions/codemode/renderer.js +3 -3
  255. package/dist/extensions/mcp/cli.code.js +1 -1
  256. package/dist/extensions/mcp/cli.impl.js +3 -3
  257. package/dist/extensions/mcp/cli.js +3 -3
  258. package/dist/extensions/mcp/cli.lazy.code.js +2 -2
  259. package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
  260. package/dist/extensions/mcp/cli.lazy.js +3 -3
  261. package/dist/extensions/mcp/runtime.impl.js +3 -3
  262. package/dist/extensions/mcp/runtime.js +3 -3
  263. package/dist/index.js +2 -2
  264. package/dist/main-first-time-setup.code.js +1 -1
  265. package/dist/main-first-time-setup.impl.js +3 -3
  266. package/dist/main-first-time-setup.js +3 -3
  267. package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
  268. package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
  269. package/dist/modes/interactive/components/stored-tree-view.js +3 -3
  270. package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
  271. package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
  272. package/dist/package-manager-cli.code.js +4 -4
  273. package/dist/package-manager-cli.impl.js +3 -3
  274. package/dist/package-manager-cli.js +3 -3
  275. package/dist/rpc-entry.js +1 -1
  276. package/dist/startup-files.json +1 -1
  277. package/dist/startup-stages/3.js +1 -1
  278. package/dist/startup-stages/5.js +1 -1
  279. package/dist/utils/startup-database-spare.code.js +2 -2
  280. package/dist/utils/startup-database-spare.impl.js +3 -3
  281. package/dist/utils/startup-database-spare.js +3 -3
  282. package/dist/utils/tools-manager.code.js +1 -1
  283. package/dist/utils/tools-manager.impl.js +3 -3
  284. package/dist/utils/tools-manager.js +3 -3
  285. package/docs/changelog.mdx +49 -0
  286. package/docs/storage/jsonl.md +3 -3
  287. package/package.json +8 -8
  288. package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +0 -1
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.3`;
9
+ const key = `${root.href}#0.10.11-alpha.4`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.4") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -6,7 +6,7 @@ try {
6
6
  } catch (error) {
7
7
  const root = new URL("../../", import.meta.url);
8
8
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
9
- const key = `${root.href}#0.10.11-alpha.3`;
9
+ const key = `${root.href}#0.10.11-alpha.4`;
10
10
  let release = releases.get(key);
11
11
  if (release === undefined) {
12
12
  const current = (async () => {
@@ -27,8 +27,8 @@ try {
27
27
  release = current;
28
28
  }
29
29
  const running = await release;
30
- if (running === undefined || running.version === "0.10.11-alpha.3") throw error;
31
- throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.3 while this session was running; restart it to keep using session storage.", {
30
+ if (running === undefined || running.version === "0.10.11-alpha.4") throw error;
31
+ throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11-alpha.4 while this session was running; restart it to keep using session storage.", {
32
32
  cause: error,
33
33
  });
34
34
  }
@@ -443,7 +443,7 @@ function __atomicOnDemandFailed(error, feature) {
443
443
  return (async () => {
444
444
  const root = new URL("../../", import.meta.url);
445
445
  const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
446
- const key = `${root.href}#0.10.11-alpha.3`;
446
+ const key = `${root.href}#0.10.11-alpha.4`;
447
447
  let release = releases.get(key);
448
448
  if (release === undefined) {
449
449
  const current = (async () => {
@@ -471,7 +471,7 @@ function __atomicOnDemandFailed(error, feature) {
471
471
  } catch {
472
472
  // No installation to read, as in a bundle of the package: the release the process runs decides.
473
473
  }
474
- const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.3" ? installed : running !== undefined && running.version !== "0.10.11-alpha.3" ? "0.10.11-alpha.3" : undefined;
474
+ const updatedTo = typeof installed === "string" && installed !== "0.10.11-alpha.4" ? installed : running !== undefined && running.version !== "0.10.11-alpha.4" ? "0.10.11-alpha.4" : undefined;
475
475
  if (updatedTo === undefined) throw error;
476
476
  const application = typeof running?.name === "string" ? running.name : "atomic";
477
477
  const restart = new Error(`${application} was updated to ${updatedTo} while this session was running; restart it to keep using ${feature}.`, {
@@ -1,4 +1,5 @@
1
1
  import type { SqliteDatabase, SqliteExecutor } from "./database.js";
2
+ import type { SequencedStatement } from "./statement-sequence.js";
2
3
  /**
3
4
  * What a schema held when one open read it: its relations, triggers and columns, and on PostgreSQL the versions its
4
5
  * ledger records. Only a positive answer is final: the schema only moves forward, so what existed then still exists,
@@ -43,7 +44,7 @@ export interface SqliteSchemaStamp {
43
44
  * @internal Stamps each of `stamps`, in the transaction `tx` that ran their setups, with the schema version as that
44
45
  * transaction leaves it: a later open believes their revisions until the schema changes again (#6560). Creates the
45
46
  * stamps table first, unless `options.tableExists`, so its own creation is part of the version recorded. With
46
- * `options.last`, the stamps are the transaction's last statement: where its connection is pipelined, they go out with
47
+ * `options.last`, the stamps are the transaction's last statements: where its connection is pipelined, they go out with
47
48
  * its commit. SQLite only; every stamp must share a ledger.
48
49
  */
49
50
  export declare function recordSqliteSchemaStamps(tx: SqliteExecutor, stamps: readonly SqliteSchemaStamp[], options?: {
@@ -57,6 +58,56 @@ export declare function recordSqliteSchemaStamps(tx: SqliteExecutor, stamps: rea
57
58
  * when a read fails: the stores then check each object themselves.
58
59
  */
59
60
  export declare function readStorageSchemaCatalog(database: SqliteDatabase, ledger: string): Promise<StorageSchemaCatalog | undefined>;
61
+ /** @internal Context passed to a queued SQLite schema setup inside an open's single write transaction (#6709). */
62
+ export interface SqliteSchemaBatchContext {
63
+ /** The write transaction executor. */
64
+ readonly tx: SqliteExecutor;
65
+ /** The live schema catalog read at the start of the write transaction, authoritative under the write lock. */
66
+ readonly catalog: StorageSchemaCatalog | undefined;
67
+ /**
68
+ * Queues a SQLite write statement or multi-statement SQL script to run in order inside the transaction. Consecutive
69
+ * queued writes go out together to the connection thread, and the final run goes out with `COMMIT`. When
70
+ * `options.ignoreError` returns true for a statement's failure, that error is ignored.
71
+ */
72
+ enqueue(statement: string | SequencedStatement, options?: {
73
+ readonly ignoreError?: (error: unknown) => boolean;
74
+ }): void;
75
+ /** Executes any writes queued so far; call before issuing a read on `tx` that depends on them. */
76
+ flushWrites(): Promise<void>;
77
+ /** Notes that this transaction added `column` to `table`, so a later queued setup does not add it again. */
78
+ noteColumnAdded(table: string, column: string): void;
79
+ /** Whether `table` already has `column` in `catalog` or added earlier in this transaction. */
80
+ hasColumn(table: string, column: string): boolean;
81
+ /** Notes that this transaction created `table`. */
82
+ noteTableCreated(table: string): void;
83
+ /** Whether `table` was created earlier in this transaction. */
84
+ createdTable(table: string): boolean;
85
+ /** Whether `table` already existed in `catalog` before this transaction began. */
86
+ tableExisted(table: string): boolean;
87
+ }
88
+ /** @internal A SQLite schema setup queued inside an open scope (`withStorageSchemaCatalog`) to run in one transaction. */
89
+ export interface SqliteSchemaBatchSetup {
90
+ /** Stamp recorded for this setup once the batched transaction commits, when the store uses SQLite schema stamps. */
91
+ readonly stamp?: SqliteSchemaStamp;
92
+ /** Whether the schema already holds everything this setup creates (for DDL-only setups without row seeds). */
93
+ readonly verify?: (catalog: StorageSchemaCatalog) => boolean;
94
+ /**
95
+ * Checks outside any write lock whether another host completed this setup while we waited on `tryMaintenance`.
96
+ * Throwing (such as `StorageSchemaVersionError` for a newer build's database) immediately rejects the open.
97
+ */
98
+ readonly done?: (catalog: StorageSchemaCatalog, stamps: ReadonlyMap<string, number> | undefined) => boolean | Promise<boolean>;
99
+ /** Reset any mutable per-attempt JS state before each transaction attempt or retry. */
100
+ readonly reset?: () => void;
101
+ /** Runs this setup inside the batched write transaction. */
102
+ readonly run: (context: SqliteSchemaBatchContext) => Promise<void> | void;
103
+ /**
104
+ * Optional setup (such as an FTS5 search index): if the transaction fails, the open retries with optional setups
105
+ * isolated in savepoints, calling `onFailure` instead of failing the open.
106
+ */
107
+ readonly optional?: boolean;
108
+ /** Called when an optional setup fails and its savepoint rolls back. */
109
+ readonly onFailure?: () => void;
110
+ }
60
111
  /** @internal How the end of an open stamps a store's setup: see {@link restampStorageSchemaAtOpenEnd}. */
61
112
  export interface SchemaStampAtOpenEnd {
62
113
  /**
@@ -79,8 +130,9 @@ export interface SchemaStampAtOpenEnd {
79
130
  /**
80
131
  * Runs `body`, an open of one or more stores on `database`, with one catalog read for all of them: the schema checks
81
132
  * of the stores it opens ({@link schemaCatalogOf}) answer from it, so an open whose schema is current runs no schema
82
- * transaction and takes no lock. Opens on `database` that overlap share the read. `views` are other handles on the
83
- * same connection, such as a borrowed view, whose checks answer from the same read.
133
+ * transaction and takes no lock. Opens on `database` that overlap share the read. On SQLite, setups queued inside the
134
+ * open ({@link queueSqliteSchemaSetup}) run in one write transaction before the root open returns (#6709). `views` are
135
+ * other handles on the same connection, such as a borrowed view, whose checks answer from the same read.
84
136
  */
85
137
  export declare function withStorageSchemaCatalog<T>(database: SqliteDatabase, ledger: string, body: () => Promise<T>, views?: readonly SqliteDatabase[]): Promise<T>;
86
138
  /**
@@ -105,15 +157,25 @@ export declare function schemaCatalogOf(database: SqliteDatabase, ledger?: strin
105
157
  * question reads them after the open's catalog, and only where it holds their table.
106
158
  */
107
159
  export declare function sqliteSchemaStampsOf(database: SqliteDatabase, ledger: string): Promise<ReadonlyMap<string, number> | undefined>;
160
+ /**
161
+ * @internal Queues `setup` into the active SQLite open scope (`withStorageSchemaCatalog`) so that all needed setups of
162
+ * the open execute in one write transaction before the open returns (#6709). Returns `false` outside a SQLite open
163
+ * scope (or for a different `ledger`), in which case the caller runs `setup` immediately.
164
+ */
165
+ export declare function queueSqliteSchemaSetup(database: SqliteDatabase, ledger: string | undefined, setup: SqliteSchemaBatchSetup): boolean;
166
+ /**
167
+ * @internal Executes and commits any SQLite schema setups queued so far in the active open scope, before the open
168
+ * needs their committed tables or evaluated outcomes (#6709). No-op when nothing is queued or outside a SQLite open.
169
+ */
170
+ export declare function flushStorageSchemaSetups(database: SqliteDatabase, ledger?: string): Promise<void>;
108
171
  /**
109
172
  * @internal Tells the open of `database` in progress that it checked `setup`, the schema setup `stamp` names, without
110
173
  * its stamp (SQLite only): it ran it in a transaction that stamped it, found every object it creates in the
111
174
  * catalog (with `verify`), or leaves it to the end (`deferred`). A schema change later in the same open, such as the
112
175
  * next store's setup or a column it adds, leaves a stamp behind the schema version, and a store found in the catalog has
113
- * none that is current, so the next open would check it again. The open's end reads the stamps once more and, where any
114
- * of these is behind, checks or runs them in one transaction and stamps them all with the version it leaves: the next
115
- * open of a current schema then takes no write lock and answers every such store from its stamp (#6560). False, and
116
- * nothing is kept, outside such an open: the caller then runs `setup` as it would without stamps.
176
+ * none that is current, so the next open would check it again. The open's end checks or runs them in one transaction
177
+ * and stamps them all with the version it leaves: the next open of a current schema then takes no write lock and answers
178
+ * every such store from its stamp (#6560, #6709). False, and nothing is kept, outside such an open.
117
179
  */
118
180
  export declare function restampStorageSchemaAtOpenEnd(database: SqliteDatabase, stamp: SqliteSchemaStamp, setup: (tx: SqliteExecutor) => Promise<unknown>, options?: SchemaStampAtOpenEnd): boolean;
119
181
  //# sourceMappingURL=schema-catalog.d.ts.map