@bastani/atomic 0.10.11-alpha.2 → 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.
- package/CHANGELOG.md +150 -0
- package/README.md +5 -8
- package/dist/_shared/dist-KOELCESV.js +2 -2
- package/dist/_shared/fork-row-index-UAUAQRD5.js +2 -2
- package/dist/_shared/lib-4PES5P4V.js +2 -2
- package/dist/_shared/mode-interactive-sdk-7KXUFI2F.js +6 -6
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +5 -5
- package/dist/_shared/mode-shared-2QJSCUM6.js +6 -6
- package/dist/_shared/p0-cli-BB45ZQY6.js +46 -67
- package/dist/_shared/p0-cli-BB45ZQY6.js.map +1 -1
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +7 -8
- package/dist/_shared/p1a-prewarm-XIU57JHF.js.map +1 -1
- package/dist/_shared/{p1b-elig-ENCUPKKJ.js → p1b-elig-TVB5CBLL.js} +36 -8
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -0
- package/dist/_shared/p2-shell-main-B2WIALFD.js +6 -3
- package/dist/_shared/p2-shell-main-B2WIALFD.js.map +1 -1
- package/dist/_shared/runtime-O4KCSG4C.js +3 -3
- package/dist/_shared/{sdk-IQMULKFU.js → sdk-B5LEWGGI.js} +1218 -657
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -0
- package/dist/_shared/session-data-AHTU7IS6.js +2 -2
- package/dist/_shared/session-manager-list-2BLEEZVG.js +1 -1
- package/dist/_shared/{startup-0-0-3IXNMFM2.js → startup-0-0-XJJDOIEC.js} +50 -48
- package/dist/_shared/startup-0-0-XJJDOIEC.js.map +1 -0
- package/dist/_shared/{startup-0-1-7T2IAE7J.js → startup-0-1-M6OWAYHH.js} +540 -136
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +47 -48
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +5 -5
- package/dist/_shared/startup-0-4-ZMJV547D.js +12 -7
- package/dist/_shared/startup-0-4-ZMJV547D.js.map +1 -1
- package/dist/_shared/startup-0-5-YDW47QX6.js +7 -7
- package/dist/_shared/startup-0-5-YDW47QX6.js.map +1 -1
- package/dist/_shared/startup-10-0-TDQNBDDL.js +6 -6
- package/dist/_shared/startup-12-0-55AAXBJZ.js +2 -2
- package/dist/_shared/startup-14-0-MLX36RBG.js +4 -5
- package/dist/_shared/startup-14-0-MLX36RBG.js.map +1 -1
- package/dist/_shared/startup-15-0-YUKGAC63.js +4 -4
- package/dist/_shared/startup-15-1-4S7FLMNG.js +19 -27
- package/dist/_shared/startup-15-1-4S7FLMNG.js.map +1 -1
- package/dist/_shared/startup-8-0-34CBHPZH.js +2144 -249
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/{startup-8-1-X32CYSXB.js → startup-8-1-LZFXSD3Z.js} +98 -1184
- package/dist/_shared/startup-8-1-LZFXSD3Z.js.map +1 -0
- package/dist/_shared/storage-command-7MGXLJGZ.js +188 -37
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +557 -0
- package/dist/_shared/storage-status-K7PX2RXA.js.map +1 -0
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +376 -0
- package/dist/_shared/team-DOQKICG2.js.map +1 -0
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +42 -0
- package/dist/builtin/intercom/README.md +2 -2
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1917 -381
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +324 -68
- package/dist/builtin/intercom/broker/multinode-router.ts +256 -39
- package/dist/builtin/intercom/broker/multinode-state-store.ts +71 -5
- package/dist/builtin/intercom/broker/open-broker-state.ts +14 -0
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +50 -5
- package/dist/builtin/intercom/broker/sql-ended-child-queue-store.ts +3 -2
- package/dist/builtin/intercom/broker/sql-held-send-store.ts +2 -2
- package/dist/builtin/intercom/broker/sql-known-session-store.ts +43 -19
- package/dist/builtin/intercom/broker/sql-lease-store.ts +473 -121
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +821 -79
- package/dist/builtin/intercom/broker/sql-pending-ask-store.ts +8 -5
- package/dist/builtin/intercom/broker/sql-released-ask-store.ts +12 -5
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +256 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +150 -0
- package/dist/builtin/intercom/broker/sql-schema.ts +175 -24
- package/dist/builtin/intercom/broker/sql-sent-message-authority.ts +74 -19
- package/dist/builtin/intercom/broker/wake-up-bus.ts +6 -0
- package/dist/builtin/intercom/index.bundle.mjs +14 -4
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/index.bundle.mjs +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +8 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +1 -1
- package/dist/builtin/web-access/index.bundle.mjs +2 -10
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/bun/bundled-sqlite.js +41 -0
- package/dist/bun/bundled-sqlite.js.map +1 -0
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +4 -4
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +3 -3
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +3 -3
- package/dist/cli/intercom-command.code.js.map +1 -1
- package/dist/cli/intercom-command.impl.js +3 -3
- package/dist/cli/intercom-command.js +3 -3
- package/dist/cli/list-models.code.js +2 -2
- package/dist/cli/list-models.impl.js +3 -3
- package/dist/cli/list-models.js +3 -3
- package/dist/cli/session-picker.code.js +1 -1
- package/dist/cli/session-picker.impl.js +3 -3
- package/dist/cli/session-picker.js +3 -3
- package/dist/cli/startup-ui.code.js +1 -1
- package/dist/cli/startup-ui.impl.js +3 -3
- package/dist/cli/startup-ui.js +3 -3
- package/dist/cli/storage-command.impl.js +3 -3
- package/dist/cli/storage-command.js +3 -3
- package/dist/cli/storage-search-session.code.js +3 -3
- package/dist/cli/storage-search-session.impl.js +3 -3
- package/dist/cli/storage-search-session.js +3 -3
- package/dist/cli/team-command.code.js +19 -113
- package/dist/cli/team-command.code.js.map +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +5 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-rehydrate-errors.d.ts +4 -9
- package/dist/core/compaction/compactor.d.ts +3 -3
- package/dist/core/debug.code.js +1 -1
- package/dist/core/debug.impl.js +3 -3
- package/dist/core/debug.js +3 -3
- package/dist/core/export-html/card-projection.impl.js +3 -3
- package/dist/core/export-html/card-projection.js +3 -3
- package/dist/core/export-html/index.code.js +4 -4
- package/dist/core/export-html/index.code.js.map +1 -1
- package/dist/core/export-html/index.impl.js +3 -3
- package/dist/core/export-html/index.js +3 -3
- package/dist/core/export-html/json-spans.impl.js +3 -3
- package/dist/core/export-html/json-spans.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.impl.js +3 -3
- package/dist/core/export-html/oversized-render-inputs.js +3 -3
- package/dist/core/export-html/tool-renderer.impl.js +3 -3
- package/dist/core/export-html/tool-renderer.js +3 -3
- package/dist/core/extensions/jiti-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-loader.js +3 -3
- package/dist/core/extensions/jiti-static-loader.impl.js +3 -3
- package/dist/core/extensions/jiti-static-loader.js +3 -3
- package/dist/core/extensions/loader-host-modules.code.js +1 -1
- package/dist/core/extensions/loader-host-modules.impl.js +3 -3
- package/dist/core/extensions/loader-host-modules.js +3 -3
- package/dist/core/extensions/loader-virtual-modules.js +1 -1
- package/dist/core/extensions/runner-context.js +2 -2
- package/dist/core/intercom-broker-control-host.code.js +2 -2
- package/dist/core/intercom-broker-control-host.impl.js +3 -3
- package/dist/core/intercom-broker-control-host.js +3 -3
- package/dist/core/intercom-broker-control.code.js +3 -3
- package/dist/core/intercom-broker-control.impl.js +3 -3
- package/dist/core/intercom-broker-control.js +3 -3
- package/dist/core/package-manager-storage-adapters.code.js +1 -1
- package/dist/core/package-manager-storage-adapters.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +12 -3
- package/dist/core/process-tree-containment.d.ts +16 -0
- package/dist/core/sdk-types.d.ts +1 -2
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.code.js +3 -3
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +5 -5
- package/dist/core/session-manager-list.impl.js +3 -3
- package/dist/core/session-manager-list.js +3 -3
- package/dist/core/session-manager.code.js +1 -1
- package/dist/core/session-manager.impl.js +3 -3
- package/dist/core/session-manager.js +3 -3
- package/dist/core/session-storage.code.js +1 -1
- package/dist/core/session-storage.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/settings-schema.d.ts +0 -3
- package/dist/core/storage/added-exports-0-10-11.js +19 -0
- package/dist/core/storage/added-exports-0-10-11.js.map +1 -0
- package/dist/core/storage/creation-time.js +105 -0
- package/dist/core/storage/creation-time.js.map +1 -0
- package/dist/core/storage/database.d.ts +25 -5
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/dialect.d.ts +1 -1
- package/dist/core/storage/dialect.js +1 -1
- package/dist/core/storage/dialect.js.map +1 -1
- package/dist/core/storage/errors.d.ts +13 -13
- package/dist/core/storage/errors.js +10 -16
- package/dist/core/storage/errors.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +18 -6
- package/dist/core/storage/fenced-paths.js +18 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/file-identity.d.ts +2 -0
- package/dist/core/storage/file-identity.js +24 -8
- package/dist/core/storage/file-identity.js.map +1 -1
- package/dist/core/storage/index.d.ts +3 -2
- package/dist/core/storage/index.js +5 -3
- package/dist/core/storage/index.js.map +1 -1
- package/dist/core/storage/libsql-removed.d.ts +71 -0
- package/dist/core/storage/libsql-removed.js +123 -0
- package/dist/core/storage/libsql-removed.js.map +1 -0
- package/dist/core/storage/migrations.d.ts +78 -14
- package/dist/core/storage/migrations.js +375 -49
- package/dist/core/storage/migrations.js.map +1 -1
- package/dist/core/storage/node-sqlite-file-gate.js +0 -15
- package/dist/core/storage/node-sqlite-file-gate.js.map +1 -1
- package/dist/core/storage/node-sqlite-thread.js +215 -30
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +484 -72
- package/dist/core/storage/node-sqlite.js.map +1 -1
- package/dist/core/storage/offline-snapshot-file.impl.js +3 -3
- package/dist/core/storage/offline-snapshot-file.js +3 -3
- package/dist/core/storage/prefix.d.ts +1 -1
- package/dist/core/storage/prefix.js +9 -2
- package/dist/core/storage/prefix.js.map +1 -1
- package/dist/core/storage/process-selection.d.ts +5 -5
- package/dist/core/storage/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +76 -15
- package/dist/core/storage/schema-catalog.js +359 -68
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.d.ts +7 -82
- package/dist/core/storage/selection.js +20 -235
- package/dist/core/storage/selection.js.map +1 -1
- package/dist/core/storage/session/branch-fork-source.code.js +2 -2
- package/dist/core/storage/session/branch-fork-source.impl.js +3 -3
- package/dist/core/storage/session/branch-fork-source.js +3 -3
- package/dist/core/storage/session/card-view.impl.js +3 -3
- package/dist/core/storage/session/card-view.js +3 -3
- package/dist/core/storage/session/child-reader.code.js +3 -3
- package/dist/core/storage/session/child-reader.impl.js +3 -3
- package/dist/core/storage/session/child-reader.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.impl.js +3 -3
- package/dist/core/storage/session/chunked-resume-projection.js +3 -3
- package/dist/core/storage/session/expanded-child-details.code.js +2 -2
- package/dist/core/storage/session/expanded-child-details.impl.js +3 -3
- package/dist/core/storage/session/expanded-child-details.js +3 -3
- package/dist/core/storage/session/fork-detach.d.ts +11 -1
- package/dist/core/storage/session/fork-row-bytes.impl.js +3 -3
- package/dist/core/storage/session/fork-row-bytes.js +3 -3
- package/dist/core/storage/session/fork-row-index.impl.js +3 -3
- package/dist/core/storage/session/fork-row-index.js +3 -3
- package/dist/core/storage/session/fork-staging.code.js +4 -7
- package/dist/core/storage/session/fork-staging.code.js.map +1 -1
- package/dist/core/storage/session/fork-staging.impl.js +3 -3
- package/dist/core/storage/session/fork-staging.js +3 -3
- package/dist/core/storage/session/fork-sweep.js +31 -7
- package/dist/core/storage/session/fork-sweep.js.map +1 -1
- package/dist/core/storage/session/fork-window.code.js +3 -3
- package/dist/core/storage/session/fork-window.impl.js +3 -3
- package/dist/core/storage/session/fork-window.js +3 -3
- package/dist/core/storage/session/history-pages.impl.js +3 -3
- package/dist/core/storage/session/history-pages.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.impl.js +3 -3
- package/dist/core/storage/session/jsonl-entry-projection.js +3 -3
- package/dist/core/storage/session/jsonl-session-lock.d.ts +100 -0
- package/dist/core/storage/session/jsonl-session-store.d.ts +46 -24
- package/dist/core/storage/session/jsonl-session-store.impl.js +3 -3
- package/dist/core/storage/session/jsonl-session-store.js +3 -3
- package/dist/core/storage/session/memory-session-store.impl.js +3 -3
- package/dist/core/storage/session/memory-session-store.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.code.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.impl.js +3 -3
- package/dist/core/storage/session/pinned-branch-resume.js +3 -3
- package/dist/core/storage/session/released-history-files.code.js +9 -9
- package/dist/core/storage/session/released-history-files.code.js.map +1 -1
- package/dist/core/storage/session/released-history-files.impl.js +3 -3
- package/dist/core/storage/session/released-history-files.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.impl.js +3 -3
- package/dist/core/storage/session/resident-fork-rows.js +3 -3
- package/dist/core/storage/session/session-resume.impl.js +3 -3
- package/dist/core/storage/session/session-resume.js +3 -3
- package/dist/core/storage/session/session-search-index.d.ts +52 -5
- package/dist/core/storage/session/snapshot-cut.impl.js +3 -3
- package/dist/core/storage/session/snapshot-cut.js +3 -3
- package/dist/core/storage/session/snapshot-history.code.js +3 -3
- package/dist/core/storage/session/snapshot-history.impl.js +3 -3
- package/dist/core/storage/session/snapshot-history.js +3 -3
- package/dist/core/storage/session/sql-session-store.code.js +1 -1
- package/dist/core/storage/session/sql-session-store.d.ts +99 -18
- package/dist/core/storage/session/sql-session-store.impl.js +3 -3
- package/dist/core/storage/session/sql-session-store.js +3 -3
- package/dist/core/storage/session/tree-outline.impl.js +3 -3
- package/dist/core/storage/session/tree-outline.js +3 -3
- package/dist/core/storage/session/tree-presentation.impl.js +3 -3
- package/dist/core/storage/session/tree-presentation.js +3 -3
- package/dist/core/storage/sqlite-facade.d.ts +12 -1
- package/dist/core/storage/sqlite-facade.js +310 -33
- package/dist/core/storage/sqlite-facade.js.map +1 -1
- package/dist/core/storage/sqlite-open-batch.js +10 -0
- package/dist/core/storage/sqlite-open-batch.js.map +1 -0
- package/dist/core/storage/storage-status.code.js +1 -1
- package/dist/core/storage/storage-status.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.code.js +1 -1
- package/dist/core/storage/team.d.ts +26 -115
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- package/dist/core/structured-output/index.code.js +1 -1
- package/dist/core/structured-output/index.impl.js +3 -3
- package/dist/core/structured-output/index.js +3 -3
- package/dist/core/tasks/task-completion-entry.impl.js +3 -3
- package/dist/core/tasks/task-completion-entry.js +3 -3
- package/dist/core/tasks/task-file-history.code.js +3 -3
- package/dist/core/tasks/task-file-history.impl.js +3 -3
- package/dist/core/tasks/task-file-history.js +3 -3
- package/dist/core/tasks/task-reference-archive.code.js +4 -4
- package/dist/core/tasks/task-reference-archive.js +3 -3
- package/dist/core/tasks/task-reference-identity.js +3 -3
- package/dist/core/tasks/task-reference-stream.impl.js +3 -3
- package/dist/core/tasks/task-reference-stream.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.impl.js +3 -3
- package/dist/core/tasks/task-unsaved-answer.js +3 -3
- package/dist/core/tasks/task-view-source.code.js +1 -1
- package/dist/core/tasks/task-view-source.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/history-tasks.d.ts +3 -2
- package/dist/core/tools/read-url.code.js +4 -4
- package/dist/core/tools/read-url.impl.js +3 -3
- package/dist/core/tools/read-url.js +3 -3
- package/dist/core/worktree-snapshot/blob-store.d.ts +44 -5
- package/dist/core/worktree-snapshot/blob-store.js +553 -30
- package/dist/core/worktree-snapshot/blob-store.js.map +1 -1
- package/dist/core/worktree-snapshot/errors.code.js +2 -2
- package/dist/core/worktree-snapshot/errors.impl.js +3 -3
- package/dist/core/worktree-snapshot/errors.js +3 -3
- package/dist/core/worktree-snapshot/fork-blob-guard.js +81 -0
- package/dist/core/worktree-snapshot/fork-blob-guard.js.map +1 -0
- package/dist/core/worktree-snapshot/fork-snapshot-index.js +208 -50
- package/dist/core/worktree-snapshot/fork-snapshot-index.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.code.js +4 -0
- package/dist/core/worktree-snapshot/session-index-reset.code.js.map +1 -1
- package/dist/core/worktree-snapshot/session-index-reset.impl.js +3 -3
- package/dist/core/worktree-snapshot/session-index-reset.js +3 -3
- package/dist/extensions/codemode/execute.code.js +1 -1
- package/dist/extensions/codemode/execute.impl.js +3 -3
- package/dist/extensions/codemode/execute.js +3 -3
- package/dist/extensions/codemode/renderer.code.js +2 -2
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +3 -3
- package/dist/extensions/mcp/cli.impl.js +3 -3
- package/dist/extensions/mcp/cli.js +3 -3
- package/dist/extensions/mcp/cli.lazy.code.js +2 -2
- package/dist/extensions/mcp/cli.lazy.impl.js +3 -3
- package/dist/extensions/mcp/cli.lazy.js +3 -3
- package/dist/extensions/mcp/runtime.code.js +1 -1
- package/dist/extensions/mcp/runtime.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -5
- package/dist/main-first-time-setup.code.js +1 -1
- package/dist/main-first-time-setup.impl.js +3 -3
- package/dist/main-first-time-setup.js +3 -3
- package/dist/main.js +1 -1
- package/dist/modes/interactive/components/stored-tree-view.code.js +2 -2
- package/dist/modes/interactive/components/stored-tree-view.impl.js +3 -3
- package/dist/modes/interactive/components/stored-tree-view.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.impl.js +3 -3
- package/dist/modes/interactive/components/user-message-selector-archive.js +3 -3
- package/dist/modes/interactive/startup-shell-eligibility.js +1 -1
- package/dist/modes/interactive-engine/engine-prewarm.d.ts +1 -1
- package/dist/modes/print-mode.js +1 -1
- package/dist/package-manager-cli.code.js +6 -6
- package/dist/package-manager-cli.impl.js +3 -3
- package/dist/package-manager-cli.js +3 -3
- package/dist/rpc-entry.js +1 -1
- package/dist/startup-files.json +1 -1
- package/dist/startup-stages/10.js +1 -1
- package/dist/startup-stages/11.js +1 -1
- package/dist/startup-stages/12.js +1 -1
- package/dist/startup-stages/2.js +2 -4
- package/dist/startup-stages/3.js +1 -3
- package/dist/startup-stages/4.js +1 -2
- package/dist/startup-stages/5.js +1 -1
- package/dist/startup-stages/6.js +5 -7
- package/dist/startup-stages/7.js +3 -10
- package/dist/startup-stages/8.js +7 -2
- package/dist/startup-stages/9.js +1 -7
- package/dist/startup-stages/stages.json +1 -1
- package/dist/utils/compile-cache-deferral.js +8 -13
- package/dist/utils/compile-cache-deferral.js.map +1 -1
- package/dist/utils/compile-cache-warmup-host.js +3 -4
- package/dist/utils/compile-cache-warmup-host.js.map +1 -1
- package/dist/utils/compile-cache.js +12 -100
- package/dist/utils/compile-cache.js.map +1 -1
- package/dist/utils/startup-database-spare.code.js +2 -2
- package/dist/utils/startup-database-spare.impl.js +3 -3
- package/dist/utils/startup-database-spare.js +3 -3
- package/dist/utils/tools-manager.code.js +1 -1
- package/dist/utils/tools-manager.impl.js +3 -3
- package/dist/utils/tools-manager.js +3 -3
- package/dist/utils/worker-threads.js +2 -15
- package/dist/utils/worker-threads.js.map +1 -1
- package/docs/build.md +3 -3
- package/docs/changelog.mdx +1470 -69
- package/docs/compaction/reference.md +5 -5
- package/docs/compaction.md +7 -9
- package/docs/containerization.md +2 -2
- package/docs/custom-provider/api-reference.md +1 -1
- package/docs/docs.json +37 -10
- package/docs/environment-variables.md +0 -2
- package/docs/extensions/api-reference.md +4 -4
- package/docs/getting-started/installation.md +3 -0
- package/docs/guides/configuration.md +1 -1
- package/docs/guides/non-interactive.md +1 -1
- package/docs/guides/resume-on-any-machine.md +14 -22
- package/docs/guides/team-setup.md +56 -83
- package/docs/guides.md +2 -4
- package/docs/herdr.md +1 -1
- package/docs/index.md +1 -1
- package/docs/intercom/operations.md +26 -21
- package/docs/intercom/reference.md +2 -2
- package/docs/intercom.md +1 -1
- package/docs/libraries/storage-postgres.md +9 -9
- package/docs/libraries.md +2 -3
- package/docs/models-configuration.md +2 -2
- package/docs/models.md +2 -3
- package/docs/packages/authoring.md +7 -7
- package/docs/packages.md +1 -1
- package/docs/programmatic.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/reference/cli.md +6 -11
- package/docs/reference.md +2 -2
- package/docs/rpc/extension-ui.md +2 -2
- package/docs/sdk/reference.md +5 -4
- package/docs/sdk/storage.md +8 -92
- package/docs/sdk/structured-decisions.md +1 -1
- package/docs/sdk/web-server.md +3 -3
- package/docs/sdk.md +14 -4
- package/docs/security.md +1 -1
- package/docs/session-format.md +5 -5
- package/docs/sessions.md +29 -49
- package/docs/settings.md +7 -8
- package/docs/storage/custom-adapters.md +255 -0
- package/docs/storage/jsonl.md +117 -0
- package/docs/{guides/postgres-pgbouncer.md → storage/postgres/pgbouncer.md} +66 -68
- package/docs/storage/postgres/tuning.md +337 -0
- package/docs/storage/postgres.md +556 -0
- package/docs/storage/sqlite.md +99 -0
- package/docs/storage.md +326 -990
- package/docs/subagents/authoring.md +1 -1
- package/docs/subagents.md +2 -2
- package/docs/tools.md +1 -1
- package/docs/worktree-snapshots.md +2 -2
- package/package.json +9 -9
- package/schemas/models.schema.json +2 -2
- package/schemas/settings.schema.json +0 -14
- package/dist/_shared/p1b-elig-ENCUPKKJ.js.map +0 -1
- package/dist/_shared/sdk-IQMULKFU.js.map +0 -1
- package/dist/_shared/startup-0-0-3IXNMFM2.js.map +0 -1
- package/dist/_shared/startup-0-1-7T2IAE7J.js.map +0 -1
- package/dist/_shared/startup-8-1-X32CYSXB.js.map +0 -1
- package/dist/core/intercom-broker-control.d.ts +0 -129
- package/dist/startup-stages/13.js +0 -1
- package/docs/guides/postgres-tuning.md +0 -311
- package/docs/libraries/storage-libsql.md +0 -97
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../../src/core/storage/dialect.ts"],"names":[],"mappings":"AAsMA,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C,+GAA+G;AAC/G,SAAS,QAAQ,CAAC,IAAuB;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACjF,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,IAAI,CAAC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IAChF,KAAK,EAAE,CAAC,OAAe,EAAE,EAAE,CAAC,mBAAmB,SAAS,CAAC,OAAO,CAAC,EAAE;IACnE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACzD,IAAI,EAAE,CAAC,SAAiB,EAAE,EAAE,CAAC,IAAI,SAAS,QAAQ;IAClD,cAAc,EAAE,CAAC,KAAa,EAAE,OAA0B,EAAE,MAAc,EAAE,EAAE,CAC7E,eAAe,KAAK,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,yBAAyB;IAC/E,eAAe,EAAE,CAAC,KAAa,EAAE,OAA0B,EAAE,GAAsB,EAAE,MAAc,EAAE,EAAE,CACtG,eAAe,KAAK,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,MAAM,gBAAgB,UAAU,CAAC,GAAG,CAAC,kBAAkB,OAAO;SAC3G,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACzC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,eAAe,MAAM,EAAE,CAAC;SACjD,IAAI,CAAC,IAAI,CAAC,EAAE;CACf,CAAC,CAAC;AAEH,uHAAuH;AACvH,MAAM,UAAU,SAAS,CAAC,QAA+C;IACxE,OAAO,QAAQ,CAAC,OAAO,IAAI,aAAa,CAAC;AAC1C,CAAC","sourcesContent":["import type { SqliteStatement } from \"./database.js\";\n\n/** The database engines a store's SQL is written for. */\nexport type StorageDialectName = \"sqlite\" | \"postgres\";\n\n/**\n * A row lock a `fenced` transaction takes on the rows it reads: see `StorageDialect.lockClause`. `key-share` excludes\n * only deleting the row or locking it `update`, not an update of its other columns.\n */\nexport type StorageLockKind = \"update\" | \"share\" | \"update-skip-locked\" | \"key-share\";\n\n/** A JSON type, named as SQLite's `json_type` names it: see `StorageDialect.jsonHasType`. */\nexport type StorageJsonType = \"null\" | \"text\" | \"object\" | \"array\";\n\n/** Column types, in each engine's spelling. */\nexport interface StorageDialectTypes {\n\t/** A 64-bit integer: `INTEGER` on SQLite, `BIGINT` on Postgres, whose `INTEGER` is 32-bit. */\n\treadonly int: string;\n\treadonly real: string;\n\treadonly text: string;\n\treadonly blob: string;\n\t/** A primary key the database assigns, in increasing order: the whole column definition after its name. */\n\treadonly serialKey: string;\n\t/**\n\t * Like `serialKey`, without its promise never to reuse the key of a deleted last row: SQLite's `INTEGER PRIMARY KEY`.\n\t */\n\treadonly rowKey: string;\n}\n\n/**\n * The SQL constructs that differ between the engines a store runs on. Stores write one SQL text and ask the dialect\n * for these pieces; they never branch on `name`. Every member renders SQL text, never values: parameters stay `?`,\n * and the Postgres driver numbers them.\n */\nexport interface StorageDialect {\n\treadonly name: StorageDialectName;\n\treadonly types: StorageDialectTypes;\n\t/**\n\t * Appended after a text column's type so it compares and sorts in UTF-8 byte order, whatever the database's\n\t * collation: `\"\"` on SQLite, whose default `BINARY` collation already does; `' COLLATE \"C\"'` on Postgres.\n\t */\n\treadonly byteOrderCollation: string;\n\t/** Appended after a `CREATE TABLE`'s closing parenthesis: `\" STRICT\"` on SQLite, `\"\"` on Postgres. */\n\treadonly tableOptions: string;\n\t/** Like `tableOptions`, for a table keyed only by its primary key: `\" STRICT, WITHOUT ROWID\"` on SQLite. */\n\treadonly withoutRowidTableOptions: string;\n\t/** An expression: integer milliseconds since the epoch on the database's clock, at the time it is evaluated. */\n\treadonly nowMs: string;\n\t/** An expression: whole seconds since the epoch on the database's clock, rounded down. */\n\treadonly nowSeconds: string;\n\t/**\n\t * Select-list items whose values change whenever any connection commits a write to the database, and the `FROM`\n\t * clause they need (with a leading space; `\"\"` when none). A change token built from them may change without a\n\t * write, never the reverse: `SELECT ${columns}, (SELECT count(*) FROM t) AS rows${from}`.\n\t */\n\treadonly changeMarkers: { readonly columns: string; readonly from: string };\n\t/** Whether `applyStorageMigrations` records applied versions in a ledger table (else steps are idempotent). */\n\treadonly versionedMigrations: boolean;\n\t/** The text at `path` (object keys) inside the JSON text in `column`; SQL `NULL` when absent. */\n\tjsonText(column: string, ...path: readonly string[]): string;\n\t/** A predicate: the JSON value at `path` inside `column` has `type`. */\n\tjsonHasType(type: StorageJsonType, column: string, ...path: readonly string[]): string;\n\t/** A predicate: `column` holds well-formed JSON text. */\n\tjsonValid(column: string): string;\n\ttextByteLength(expression: string): string;\n\t/**\n\t * A table expression for `FROM`: the elements of the JSON array in `source`, a bound parameter (`?`) or a column whose\n\t * JSON text the store wrote, as one column named `value`. On Postgres the values are text. Use it once per query and\n\t * do not alias it.\n\t */\n\tjsonValues(source: string): string;\n\t/** The larger of two values: scalar `MAX(a, b)` on SQLite, `GREATEST(a, b)` on Postgres. */\n\tgreatest(a: string, b: string): string;\n\t/** The smaller of two values: scalar `MIN(a, b)` on SQLite, `LEAST(a, b)` on Postgres. */\n\tleast(a: string, b: string): string;\n\t/** Appended to a `SELECT` in a `fenced` transaction: `\"\"` on SQLite, whose transactions already serialize. */\n\tlockClause(kind: StorageLockKind): string;\n\t/**\n\t * The column that orders a table's rows by insertion: `rowid` on SQLite, the identity column `row_order` on\n\t * Postgres, which a table declares with `rowOrderColumn`.\n\t */\n\trowOrder(alias?: string): string;\n\t/**\n\t * Appended to the column list of a `CREATE TABLE` whose rows a store orders by `rowOrder()`: `\"\"` on SQLite, where\n\t * `rowid` is implicit; `\", row_order BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE\"` on Postgres.\n\t */\n\treadonly rowOrderColumn: string;\n\t/**\n\t * The longest identifier the database keeps whole, in bytes: 63 on Postgres, which truncates longer ones; undefined\n\t * on SQLite, which has no limit. A store that adds its own words to a prefixed name keeps them short where it is set.\n\t */\n\treadonly maxIdentifierBytes: number | undefined;\n\t/**\n\t * The name the database knows `name` by. Every name fits on SQLite. On Postgres a name longer than\n\t * `maxIdentifierBytes` becomes its head and a hash of the whole name, so it is never truncated or merged with\n\t * another; every shorter name is itself. The dialect's catalog probes and trigger statements use it, so they agree.\n\t */\n\tidentifier(name: string): string;\n\t/** A query that returns one row when `table` exists in the current database (or schema). */\n\ttableExists(table: string): SqliteStatement;\n\t/**\n\t * A query that returns a row `{ name }` for each of `tables` that keeps its rows in its primary key's b-tree: a\n\t * SQLite `WITHOUT ROWID` table. None on Postgres, whose tables are heaps with indexes of their own.\n\t */\n\twithoutRowidTables(tables: readonly string[]): SqliteStatement;\n\t/**\n\t * An aggregate: the values of `expression` joined by `separator` (SQL text), in `orderBy` order. SQLite's\n\t * `group_concat` takes the order of its input, so callers also feed it rows already ordered by `orderBy`.\n\t */\n\torderedConcat(expression: string, separator: string, orderBy: string): string;\n\t/** A query that returns one row `{ name, default_value }` when `table` has `column`. */\n\tcolumnExists(table: string, column: string): SqliteStatement;\n\t/**\n\t * The statements, `;`-terminated, that create `trigger` unless it exists (SQLite) or create or replace it\n\t * (Postgres: a plpgsql function `<name>_fn` and a `FOR EACH ROW` trigger that runs it). Run them with `exec`.\n\t */\n\trenderTrigger(trigger: StorageTrigger): string;\n\t/** Drops the trigger `name` on `table`, optionally removing its PostgreSQL function when it is retired. */\n\tdropTrigger(name: string, table: string, dropFunction?: boolean): string;\n\t/**\n\t * A query that returns a row `{ name }` for each of `names` that is a table, index or trigger in the database, named\n\t * as in `names`.\n\t */\n\tschemaObjects(names: readonly string[]): SqliteStatement;\n\t/**\n\t * The type of the JSON value at `path` in `column`, as SQLite's `json_type` names it (`'null'`, `'true'`, `'false'`,\n\t * `'integer'`, `'real'`, `'text'`, `'array'`, `'object'`); SQL `NULL` when absent.\n\t */\n\tjsonType(column: string, ...path: readonly string[]): string;\n\t/**\n\t * A table expression for `FROM`, named `alias`: one row per element of the JSON array at `path` in `source`. A\n\t * later `source` of `{ column, element: alias }` reads inside each element. SQLite also iterates an object's values.\n\t */\n\tjsonEach(source: StorageJsonSource, alias: string, ...path: readonly string[]): string;\n\t/** The JSON value at `path` in `source`, as SQLite's `json_extract` returns it; text on Postgres. */\n\tjsonAt(source: StorageJsonSource, ...path: readonly string[]): string;\n\t/** A predicate: the JSON value at `path` in `source` is a string. */\n\tjsonAtIsText(source: StorageJsonSource, ...path: readonly string[]): string;\n\t/** A predicate: `needle` occurs in the text `haystack`. */\n\tcontains(haystack: string, needle: string): string;\n\t/** A predicate: `a` and `b` differ, a `NULL` differing from every value but `NULL`. */\n\tisDistinct(a: string, b: string): string;\n\t/** A predicate: `a` and `b` are equal, or both `NULL`: SQLite's `a IS b`. */\n\tisNotDistinct(a: string, b: string): string;\n\t/**\n\t * A JSON object of `entries` (each a key, an identifier, and a SQL value), as text when selected. A text value is\n\t * a JSON string, a value from `jsonObject`, `jsonArray` or `jsonGroupArray` is nested as JSON. Postgres must know\n\t * each value's type: cast a bound parameter, as `CAST(? AS ${types.int})`.\n\t */\n\tjsonObject(entries: readonly (readonly [key: string, value: string])[]): string;\n\t/** A JSON array of `values`, typed as for `jsonObject`. */\n\tjsonArray(values: readonly string[]): string;\n\t/**\n\t * An aggregate: a JSON array of `expression` over the group's rows, in `orderBy` order when given; `[]` for no\n\t * rows. SQLite's `json_group_array` takes the order of its input, so callers also feed it rows already ordered.\n\t */\n\tjsonGroupArray(expression: string, orderBy?: string): string;\n\t/**\n\t * Like `jsonText`, in a form an index expression may use: Postgres indexes only immutable expressions, which\n\t * `jsonText`'s read is not. Reads the same text for every key whose value has no NUL or surrogate escape.\n\t */\n\tjsonIndexText(column: string, ...path: readonly string[]): string;\n\t/** A query that returns `{ foreign_keys: 1 }` when the connection enforces foreign keys, as Postgres always does. */\n\treadonly foreignKeysCheck: SqliteStatement;\n\t/** A trigger statement (`StorageTrigger.statements`) that aborts the statement that fired it with `message`. */\n\tabort(message: string): string;\n\t/** Boolean literals that conditions compare and combine: `1` and `0` on SQLite, `true` and `false` on Postgres. */\n\treadonly literals: { readonly true: string; readonly false: string };\n\t/** The predicate `predicate` as an integer, 1 or 0, for an integer column. */\n\tflag(predicate: string): string;\n\t/** Inserts the rows of `select` into `table`'s `columns`, skipping each row that violates a unique constraint. */\n\tinsertOrIgnore(table: string, columns: readonly string[], select: string): string;\n\t/**\n\t * Inserts the rows of `select` into `table`'s `columns`, each replacing the row with its `key` (the primary key).\n\t * `table` must have no other unique constraint, and no row of `select` may repeat a key.\n\t */\n\tinsertOrReplace(table: string, columns: readonly string[], key: readonly string[], select: string): string;\n}\n\n/** A row trigger: `timing` `event` on `table`, it runs `statements` in order for each row where `when` holds. */\nexport interface StorageTrigger {\n\treadonly name: string;\n\treadonly table: string;\n\treadonly timing: \"BEFORE\" | \"AFTER\";\n\t/** `INSERT`, `DELETE`, `UPDATE`, or `UPDATE OF <column>`. */\n\treadonly event: string;\n\t/** A condition on the row, as `NEW` and `OLD`. */\n\treadonly when?: string;\n\t/** Statements that refer to the row as `NEW` and `OLD`. */\n\treadonly statements: readonly string[];\n}\n\n/** JSON text a query reads: the column `column`, or, with `element`, an element `jsonEach` named so yields from it. */\nexport interface StorageJsonSource {\n\treadonly column: string;\n\treadonly element?: string;\n}\n\nconst JSON_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Path keys are identifiers written in store code; anything else is a programming error, never user input. */\nfunction jsonPath(path: readonly string[]): readonly string[] {\n\tif (path.length === 0) throw new TypeError(\"A JSON path needs at least one key\");\n\tfor (const key of path) if (!JSON_KEY.test(key)) throw new TypeError(`Invalid JSON path key: ${key}`);\n\treturn path;\n}\n\nfunction sqlitePath(path: readonly string[]): string {\n\treturn `'$.${jsonPath(path).join(\".\")}'`;\n}\n\nfunction qualified(column: string, alias: string | undefined): string {\n\treturn alias === undefined ? column : `${alias}.${column}`;\n}\n\n/** `json_extract`'s path inside `source`: from the document's root, or from the element `jsonEach` yields. */\nfunction sqliteSourcePath(source: StorageJsonSource, path: readonly string[]): string {\n\tconst keys = `.${jsonPath(path).join(\".\")}`;\n\treturn source.element === undefined ? `'$${keys}'` : `${source.element}.fullkey || '${keys}'`;\n}\n\nconst sqliteJsonAt = (source: StorageJsonSource, ...path: readonly string[]) =>\n\t`json_extract(${source.column}, ${sqliteSourcePath(source, path)})`;\n\n/** A SQL string literal of `text`, which store code writes (never user input). */\nconst sqlString = (text: string) => `'${text.replaceAll(\"'\", \"''\")}'`;\n\n/** `json_object`'s arguments: each key, an identifier, as a string literal, then its value. */\nconst jsonEntries = (entries: readonly (readonly [string, string])[]) =>\n\tentries.map(([key, value]) => `${sqlString(jsonPath([key])[0]!)}, ${value}`).join(\", \");\n\nconst columnList = (columns: readonly string[]) => `(${columns.join(\", \")})`;\n\nconst namedPlaceholders = (names: readonly string[]) => names.map(() => \"?\").join(\", \");\n\n/** SQLite and libSQL: renders exactly the SQL the stores have always run, so schemas and statements stay unchanged. */\nexport const sqliteDialect: StorageDialect = Object.freeze({\n\tname: \"sqlite\",\n\ttextByteLength: (expression: string) => `length(CAST(${expression} AS BLOB))`,\n\ttypes: Object.freeze({\n\t\tint: \"INTEGER\",\n\t\treal: \"REAL\",\n\t\ttext: \"TEXT\",\n\t\tblob: \"BLOB\",\n\t\tserialKey: \"INTEGER PRIMARY KEY AUTOINCREMENT\",\n\t\trowKey: \"INTEGER PRIMARY KEY\",\n\t}),\n\tbyteOrderCollation: \"\",\n\ttableOptions: \" STRICT\",\n\twithoutRowidTableOptions: \" STRICT, WITHOUT ROWID\",\n\tnowMs: \"CAST(round((julianday('now') - 2440587.5) * 86400000) AS INTEGER)\",\n\tnowSeconds: \"unixepoch()\",\n\tchangeMarkers: Object.freeze({\n\t\tcolumns: \"data_version, total_changes() AS changes\",\n\t\tfrom: \" FROM pragma_data_version\",\n\t}),\n\tversionedMigrations: false,\n\tjsonText: (column: string, ...path: readonly string[]) => `json_extract(${column}, ${sqlitePath(path)})`,\n\tjsonHasType: (type: StorageJsonType, column: string, ...path: readonly string[]) =>\n\t\t`json_type(${column}, ${sqlitePath(path)}) = '${type}'`,\n\tjsonValid: (column: string) => `json_valid(${column})`,\n\tjsonValues: (source: string) => `json_each(${source})`,\n\tgreatest: (a: string, b: string) => `MAX(${a}, ${b})`,\n\tleast: (a: string, b: string) => `MIN(${a}, ${b})`,\n\tlockClause: (_kind: StorageLockKind) => \"\",\n\trowOrder: (alias?: string) => qualified(\"rowid\", alias),\n\trowOrderColumn: \"\",\n\tmaxIdentifierBytes: undefined,\n\tidentifier: (name: string) => name,\n\ttableExists: (table: string) => ({\n\t\tsql: \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?\",\n\t\tparams: [table],\n\t}),\n\twithoutRowidTables: (tables: readonly string[]) => ({\n\t\tsql: `SELECT name FROM pragma_table_list WHERE schema = 'main' AND type = 'table' AND wr = 1 AND name IN (${namedPlaceholders(tables)})`,\n\t\tparams: [...tables],\n\t}),\n\torderedConcat: (expression: string, separator: string, _orderBy: string) =>\n\t\t`group_concat(${expression}, ${separator})`,\n\tcolumnExists: (table: string, column: string) => ({\n\t\tsql: \"SELECT name, dflt_value AS default_value FROM pragma_table_info(?) WHERE name = ?\",\n\t\tparams: [table, column],\n\t}),\n\trenderTrigger: ({ name, table, timing, event, when, statements }: StorageTrigger) =>\n\t\t`CREATE TRIGGER IF NOT EXISTS ${name} ${timing} ${event} ON ${table}${when === undefined ? \"\" : ` WHEN ${when}`} BEGIN ${statements.join(\"; \")}; END;`,\n\tdropTrigger: (name: string, _table: string) => `DROP TRIGGER IF EXISTS ${name}`,\n\tschemaObjects: (names: readonly string[]) => ({\n\t\tsql: `SELECT name FROM sqlite_schema WHERE name IN (${namedPlaceholders(names)})`,\n\t\tparams: [...names],\n\t}),\n\tjsonType: (column: string, ...path: readonly string[]) => `json_type(${column}, ${sqlitePath(path)})`,\n\tjsonEach: (source: StorageJsonSource, alias: string, ...path: readonly string[]) =>\n\t\t`json_each(${source.column}, ${sqliteSourcePath(source, path)}) AS ${alias}`,\n\tjsonAt: sqliteJsonAt,\n\tjsonAtIsText: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\t`typeof(${sqliteJsonAt(source, ...path)}) = 'text'`,\n\tcontains: (haystack: string, needle: string) => `instr(${haystack}, ${needle}) > 0`,\n\tisDistinct: (a: string, b: string) => `${a} IS NOT ${b}`,\n\tisNotDistinct: (a: string, b: string) => `${a} IS ${b}`,\n\tjsonObject: (entries: readonly (readonly [string, string])[]) => `json_object(${jsonEntries(entries)})`,\n\tjsonArray: (values: readonly string[]) => `json_array(${values.join(\", \")})`,\n\tjsonGroupArray: (expression: string, _orderBy?: string) => `json_group_array(${expression})`,\n\tjsonIndexText: (column: string, ...path: readonly string[]) => `json_extract(${column}, ${sqlitePath(path)})`,\n\tforeignKeysCheck: Object.freeze({ sql: \"PRAGMA foreign_keys\", params: [] }),\n\tabort: (message: string) => `SELECT RAISE(ABORT, ${sqlString(message)})`,\n\tliterals: Object.freeze({ true: \"1\", false: \"0\" }),\n\tflag: (predicate: string) => predicate,\n\tinsertOrIgnore: (table: string, columns: readonly string[], select: string) =>\n\t\t`INSERT OR IGNORE INTO ${table} ${columnList(columns)} ${select}`,\n\tinsertOrReplace: (table: string, columns: readonly string[], _key: readonly string[], select: string) =>\n\t\t`INSERT OR REPLACE INTO ${table} ${columnList(columns)} ${select}`,\n});\n\nconst POSTGRES_JSON_TYPES: Readonly<Record<StorageJsonType, string>> = {\n\tnull: \"null\",\n\ttext: \"string\",\n\tobject: \"object\",\n\tarray: \"array\",\n};\n\nconst POSTGRES_LOCKS: Readonly<Record<StorageLockKind, string>> = {\n\tupdate: \" FOR UPDATE\",\n\tshare: \" FOR SHARE\",\n\t\"update-skip-locked\": \" FOR UPDATE SKIP LOCKED\",\n\t\"key-share\": \" FOR KEY SHARE\",\n};\n\n/**\n * A `\\u0000` or UTF-16 surrogate escape in JSON text, after an even number of backslashes, so not the text `\\u…` after\n * an escaped `\\`.\n */\nconst POSTGRES_UNREPRESENTABLE_ESCAPE = String.raw`'(?<!\\\\)((?:\\\\\\\\)*)\\\\u(?:0000|[dD][89abcdefABCDEF][0-9a-fA-F]{2})'`;\n\n/**\n * The JSON text in `column` as `jsonb`. SQLite reads any well-formed JSON, but Postgres's `jsonb` (and its `json`\n * operators) reject a whole document with a `\\u0000` escape or a lone surrogate escape anywhere in it, even outside\n * the value read. Such a document reads with each NUL and surrogate escape as U+FFFD, so a write whose JSON carries\n * one never fails on a query or trigger that reads it, and every other value reads as on SQLite. A document without\n * an escape, or that `jsonb` accepts, reads unchanged.\n */\nexport function postgresJsonb(column: string): string {\n\treturn String.raw`(CASE WHEN strpos(${column}, '\\u') = 0 OR pg_input_is_valid(${column}, 'jsonb') THEN ${column} ELSE regexp_replace(${column}, ${POSTGRES_UNREPRESENTABLE_ESCAPE}, '\\1\\\\ufffd', 'g') END)::jsonb`;\n}\n\n/** The value at `path` in the `jsonb` expression `document`: as text with `text`, else as `jsonb`. */\nfunction postgresJson(document: string, path: readonly string[], text: boolean): string {\n\tconst keys = jsonPath(path);\n\tconst operator = text ? \">>\" : \">\";\n\treturn keys.length === 1\n\t\t? `(${document} -${operator} '${keys[0]}')`\n\t\t: `(${document} #${operator} '{${keys.join(\",\")}}')`;\n}\n\n/** The `jsonb` document `source` names: its column's JSON text, or the `value` of the element `jsonEach` yields. */\nconst postgresDocument = (source: StorageJsonSource) =>\n\tsource.element === undefined ? postgresJsonb(source.column) : `${source.element}.value`;\n\n/** Postgres truncates longer identifiers, so two long names could become one. Names are ASCII. */\nconst POSTGRES_IDENTIFIER_BYTES = 63;\n/**\n * Hex digits of the hash that ends a shortened Postgres identifier: the whole 64 bits. Names that share their head\n * differ only in it, and 32 bits of FNV-1a made two such names under a valid prefix one (#5219).\n */\nconst POSTGRES_IDENTIFIER_HASH_DIGITS = 16;\n/** Hex digits of the 32-bit hash earlier builds ended a shortened identifier with, which an upgrade drops (#5219). */\nconst LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS = 8;\n\nconst FNV_OFFSET = 0xcbf29ce484222325n;\nconst FNV_PRIME = 0x100000001b3n;\nconst U64 = (1n << 64n) - 1n;\n\n/**\n * 64-bit FNV-1a of `name`'s characters: computed in plain JavaScript so storage modules stay free of runtime-specific\n * imports. Names are ASCII, written in store code.\n */\nfunction fnv1a64(name: string): bigint {\n\tlet hash = FNV_OFFSET;\n\tfor (let index = 0; index < name.length; index++) hash = ((hash ^ BigInt(name.charCodeAt(index))) * FNV_PRIME) & U64;\n\treturn hash;\n}\n\nfunction postgresIdentifier(name: string): string {\n\tif (name.length <= POSTGRES_IDENTIFIER_BYTES) return name;\n\tconst hash = fnv1a64(name).toString(16).padStart(POSTGRES_IDENTIFIER_HASH_DIGITS, \"0\");\n\treturn `${name.slice(0, POSTGRES_IDENTIFIER_BYTES - POSTGRES_IDENTIFIER_HASH_DIGITS - 1)}_${hash}`;\n}\n\n/**\n * The name an earlier build gave `name` when it did not fit (its first 54 characters and the 64-bit hash folded to 32\n * bits), or undefined when it fits. Two names could get the same one, so a trigger installed under it may be missing\n * (#5219): installing a trigger drops it, so no trigger an earlier build installed stays beside its replacement.\n */\nfunction legacyPostgresIdentifier(name: string): string | undefined {\n\tif (name.length <= POSTGRES_IDENTIFIER_BYTES) return undefined;\n\tconst hash = fnv1a64(name);\n\tconst folded = ((hash ^ (hash >> 32n)) & 0xffffffffn)\n\t\t.toString(16)\n\t\t.padStart(LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS, \"0\");\n\treturn `${name.slice(0, POSTGRES_IDENTIFIER_BYTES - LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS - 1)}_${folded}`;\n}\n\n/** Drops the trigger an earlier build installed as `name` on `table` under its shortened name, if it had one (#5219). */\nfunction dropLegacyTrigger(name: string, table: string): string {\n\tconst legacy = legacyPostgresIdentifier(name);\n\treturn legacy === undefined ? \"\" : `;\\nDROP TRIGGER IF EXISTS ${legacy} ON ${table}`;\n}\n\nfunction postgresSchemaObjects(names: readonly string[]): SqliteStatement {\n\tconst physical = names.map(postgresIdentifier);\n\tif (physical.every((name, index) => name === names[index]))\n\t\treturn {\n\t\t\tsql: `SELECT relname AS name FROM pg_catalog.pg_class WHERE relnamespace = current_schema()::regnamespace AND relname IN (${namedPlaceholders(names)}) UNION ALL SELECT tgname AS name FROM pg_catalog.pg_trigger JOIN pg_catalog.pg_class ON pg_class.oid = tgrelid WHERE relnamespace = current_schema()::regnamespace AND NOT tgisinternal AND tgname IN (${namedPlaceholders(names)})`,\n\t\t\tparams: [...names, ...names],\n\t\t};\n\t// A shortened name is found by the name Postgres knows, and reported by the one asked for.\n\treturn {\n\t\tsql: `SELECT v.name FROM (VALUES ${names.map(() => \"(?, ?)\").join(\", \")}) AS v(name, physical) WHERE v.physical IN (SELECT relname::text FROM pg_catalog.pg_class WHERE relnamespace = current_schema()::regnamespace) OR v.physical IN (SELECT tgname::text FROM pg_catalog.pg_trigger JOIN pg_catalog.pg_class ON pg_class.oid = tgrelid WHERE relnamespace = current_schema()::regnamespace AND NOT tgisinternal)`,\n\t\tparams: names.flatMap((name, index) => [name, physical[index]!]),\n\t};\n}\n\nfunction postgresTrigger({ name, table, timing, event, when, statements }: StorageTrigger): string {\n\tconst fn = postgresIdentifier(`${name}_fn`);\n\tconst body = statements.map((statement) => `${statement};`).join(\" \");\n\tconst row = timing === \"AFTER\" ? \"NULL\" : event === \"DELETE\" ? \"OLD\" : \"NEW\";\n\t// The function an earlier build named otherwise (#5219), once no trigger runs it; one another trigger of that build\n\t// still runs is dropped when that trigger is installed again.\n\tconst legacyFn = legacyPostgresIdentifier(`${name}_fn`);\n\tconst dropLegacyFn =\n\t\tlegacyFn === undefined\n\t\t\t? \"\"\n\t\t\t: `\\nDO $legacy$ BEGIN DROP FUNCTION IF EXISTS ${legacyFn}(); EXCEPTION WHEN dependent_objects_still_exist THEN NULL; END $legacy$;`;\n\treturn `CREATE OR REPLACE FUNCTION ${fn}() RETURNS trigger LANGUAGE plpgsql AS $trigger$ BEGIN ${when === undefined ? body : `IF (${when}) THEN ${body} END IF;`} RETURN ${row}; END $trigger$${dropLegacyTrigger(name, table)};\nCREATE OR REPLACE TRIGGER ${postgresIdentifier(name)} ${timing} ${event} ON ${table} FOR EACH ROW EXECUTE FUNCTION ${fn}();${dropLegacyFn}`;\n}\n\n/** `value`'s type as SQLite's `json_type` names it, for a `jsonb` expression. */\nfunction postgresSqliteJsonType(value: string): string {\n\treturn `(CASE jsonb_typeof(${value}) WHEN 'string' THEN 'text' WHEN 'boolean' THEN (${value})::text WHEN 'number' THEN CASE WHEN (${value})::text ~ '^-?[0-9]+$' THEN 'integer' ELSE 'real' END ELSE jsonb_typeof(${value}) END)`;\n}\n\n/**\n * PostgreSQL (14 and later; `jsonValid` and every JSON read need 16, for `IS JSON` and `pg_input_is_valid`). Tables\n * a store orders by `rowOrder()` carry an explicit identity column, `row_order` (not `seq`, which several tables\n * already use for their own sequence numbers).\n */\nexport const postgresDialect: StorageDialect = Object.freeze({\n\tname: \"postgres\",\n\ttextByteLength: (expression: string) => `octet_length(${expression})`,\n\ttypes: Object.freeze({\n\t\tint: \"BIGINT\",\n\t\treal: \"DOUBLE PRECISION\",\n\t\ttext: \"TEXT\",\n\t\tblob: \"BYTEA\",\n\t\tserialKey: \"BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY\",\n\t\trowKey: \"BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY\",\n\t}),\n\tbyteOrderCollation: ' COLLATE \"C\"',\n\ttableOptions: \"\",\n\twithoutRowidTableOptions: \"\",\n\tnowMs: \"(floor(extract(epoch from clock_timestamp()) * 1000))::bigint\",\n\tnowSeconds: \"(floor(extract(epoch from clock_timestamp())))::bigint\",\n\tchangeMarkers: Object.freeze({ columns: \"pg_current_snapshot()::text AS snapshot\", from: \"\" }),\n\tversionedMigrations: true,\n\tjsonText: (column: string, ...path: readonly string[]) => postgresJson(postgresJsonb(column), path, true),\n\tjsonHasType: (type: StorageJsonType, column: string, ...path: readonly string[]) =>\n\t\t`jsonb_typeof${postgresJson(postgresJsonb(column), path, false)} = '${POSTGRES_JSON_TYPES[type]}'`,\n\tjsonValid: (column: string) => `((${column}) IS JSON)`,\n\tjsonValues: (source: string) => `jsonb_array_elements_text((${source})::jsonb) AS json_values(value)`,\n\tgreatest: (a: string, b: string) => `GREATEST(${a}, ${b})`,\n\tleast: (a: string, b: string) => `LEAST(${a}, ${b})`,\n\tlockClause: (kind: StorageLockKind) => POSTGRES_LOCKS[kind],\n\trowOrder: (alias?: string) => qualified(\"row_order\", alias),\n\trowOrderColumn: \", row_order BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE\",\n\tmaxIdentifierBytes: POSTGRES_IDENTIFIER_BYTES,\n\tidentifier: postgresIdentifier,\n\ttableExists: (table: string) => ({\n\t\t// The catalog, not information_schema, which hides a table the role has no privilege on: a role missing a grant\n\t\t// must not take an existing table for one to create (#5218).\n\t\tsql: \"SELECT c.relname AS name FROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relkind IN ('r', 'p', 'v', 'm', 'f') AND c.relname = ?\",\n\t\tparams: [postgresIdentifier(table)],\n\t}),\n\twithoutRowidTables: (_tables: readonly string[]) => ({\n\t\tsql: \"SELECT relname AS name FROM pg_catalog.pg_class WHERE false\",\n\t\tparams: [],\n\t}),\n\torderedConcat: (expression: string, separator: string, orderBy: string) =>\n\t\t`string_agg(${expression}, ${separator} ORDER BY ${orderBy})`,\n\tcolumnExists: (table: string, column: string) => ({\n\t\tsql: \"SELECT column_name AS name, column_default AS default_value FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = ? AND column_name = ?\",\n\t\tparams: [postgresIdentifier(table), column],\n\t}),\n\trenderTrigger: postgresTrigger,\n\tdropTrigger: (name: string, table: string, dropFunction = false) =>\n\t\t`DROP TRIGGER IF EXISTS ${postgresIdentifier(name)} ON ${table}${dropLegacyTrigger(name, table)}${dropFunction ? `;\\nDROP FUNCTION IF EXISTS ${postgresIdentifier(`${name}_fn`)}()` : \"\"}`,\n\tschemaObjects: postgresSchemaObjects,\n\tjsonType: (column: string, ...path: readonly string[]) =>\n\t\tpostgresSqliteJsonType(postgresJson(postgresJsonb(column), path, false)),\n\tjsonEach: (source: StorageJsonSource, alias: string, ...path: readonly string[]) =>\n\t\t`jsonb_path_query(${postgresDocument(source)}, '$.${jsonPath(path)\n\t\t\t.map((key) => `\"${key}\"`)\n\t\t\t.join(\".\")}[*]') AS ${alias}(value)`,\n\tjsonAt: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\tpostgresJson(postgresDocument(source), path, true),\n\tjsonAtIsText: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\t`jsonb_typeof${postgresJson(postgresDocument(source), path, false)} = 'string'`,\n\tcontains: (haystack: string, needle: string) => `strpos(${haystack}, ${needle}) > 0`,\n\tisDistinct: (a: string, b: string) => `${a} IS DISTINCT FROM ${b}`,\n\tisNotDistinct: (a: string, b: string) => `${a} IS NOT DISTINCT FROM ${b}`,\n\tjsonObject: (entries: readonly (readonly [string, string])[]) => `json_build_object(${jsonEntries(entries)})`,\n\tjsonArray: (values: readonly string[]) => `json_build_array(${values.join(\", \")})`,\n\tjsonGroupArray: (expression: string, orderBy?: string) =>\n\t\t`COALESCE(json_agg(${expression}${orderBy === undefined ? \"\" : ` ORDER BY ${orderBy}`}), '[]'::json)`,\n\tjsonIndexText: (column: string, ...path: readonly string[]) =>\n\t\tpostgresJson(\n\t\t\t`(regexp_replace(${column}, ${POSTGRES_UNREPRESENTABLE_ESCAPE}, '\\\\1\\\\\\\\ufffd', 'g'))::jsonb`,\n\t\t\tpath,\n\t\t\ttrue,\n\t\t),\n\tforeignKeysCheck: Object.freeze({ sql: \"SELECT 1 AS foreign_keys\", params: [] }),\n\tabort: (message: string) => `RAISE EXCEPTION ${sqlString(message)}`,\n\tliterals: Object.freeze({ true: \"true\", false: \"false\" }),\n\tflag: (predicate: string) => `(${predicate})::int`,\n\tinsertOrIgnore: (table: string, columns: readonly string[], select: string) =>\n\t\t`INSERT INTO ${table} ${columnList(columns)} ${select} ON CONFLICT DO NOTHING`,\n\tinsertOrReplace: (table: string, columns: readonly string[], key: readonly string[], select: string) =>\n\t\t`INSERT INTO ${table} ${columnList(columns)} ${select} ON CONFLICT ${columnList(key)} DO UPDATE SET ${columns\n\t\t\t.filter((column) => !key.includes(column))\n\t\t\t.map((column) => `${column} = excluded.${column}`)\n\t\t\t.join(\", \")}`,\n});\n\n/** The dialect a database speaks: its own, or SQLite's for a database that names none (every adapter before #4793). */\nexport function dialectOf(database: { readonly dialect?: StorageDialect }): StorageDialect {\n\treturn database.dialect ?? sqliteDialect;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dialect.js","sourceRoot":"","sources":["../../../src/core/storage/dialect.ts"],"names":[],"mappings":"AAsMA,MAAM,QAAQ,GAAG,0BAA0B,CAAC;AAE5C,+GAA+G;AAC/G,SAAS,QAAQ,CAAC,IAAuB;IACxC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,oCAAoC,CAAC,CAAC;IACjF,KAAK,MAAM,GAAG,IAAI,IAAI;QAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,SAAS,CAAC,0BAA0B,GAAG,EAAE,CAAC,CAAC;IACtG,OAAO,IAAI,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,IAAuB;IAC1C,OAAO,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;AAC1C,CAAC;AAED,SAAS,SAAS,CAAC,MAAc,EAAE,KAAyB;IAC3D,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,MAAM,EAAE,CAAC;AAC5D,CAAC;AAED,8GAA8G;AAC9G,SAAS,gBAAgB,CAAC,MAAyB,EAAE,IAAuB;IAC3E,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAC5C,OAAO,MAAM,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,GA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MAAM,CAAC,CAAC;SACzC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,eAAe,MAAM,EAAE,CAAC;SACjD,IAAI,CAAC,IAAI,CAAC,EAAE;CACf,CAAC,CAAC;AAEH,uHAAuH;AACvH,MAAM,UAAU,SAAS,CAAC,QAA+C;IACxE,OAAO,QAAQ,CAAC,OAAO,IAAI,aAAa,CAAC;AAC1C,CAAC","sourcesContent":["import type { SqliteStatement } from \"./database.js\";\n\n/** The database engines a store's SQL is written for. */\nexport type StorageDialectName = \"sqlite\" | \"postgres\";\n\n/**\n * A row lock a `fenced` transaction takes on the rows it reads: see `StorageDialect.lockClause`. `key-share` excludes\n * only deleting the row or locking it `update`, not an update of its other columns.\n */\nexport type StorageLockKind = \"update\" | \"share\" | \"update-skip-locked\" | \"key-share\";\n\n/** A JSON type, named as SQLite's `json_type` names it: see `StorageDialect.jsonHasType`. */\nexport type StorageJsonType = \"null\" | \"text\" | \"object\" | \"array\";\n\n/** Column types, in each engine's spelling. */\nexport interface StorageDialectTypes {\n\t/** A 64-bit integer: `INTEGER` on SQLite, `BIGINT` on Postgres, whose `INTEGER` is 32-bit. */\n\treadonly int: string;\n\treadonly real: string;\n\treadonly text: string;\n\treadonly blob: string;\n\t/** A primary key the database assigns, in increasing order: the whole column definition after its name. */\n\treadonly serialKey: string;\n\t/**\n\t * Like `serialKey`, without its promise never to reuse the key of a deleted last row: SQLite's `INTEGER PRIMARY KEY`.\n\t */\n\treadonly rowKey: string;\n}\n\n/**\n * The SQL constructs that differ between the engines a store runs on. Stores write one SQL text and ask the dialect\n * for these pieces; they never branch on `name`. Every member renders SQL text, never values: parameters stay `?`,\n * and the Postgres driver numbers them.\n */\nexport interface StorageDialect {\n\treadonly name: StorageDialectName;\n\treadonly types: StorageDialectTypes;\n\t/**\n\t * Appended after a text column's type so it compares and sorts in UTF-8 byte order, whatever the database's\n\t * collation: `\"\"` on SQLite, whose default `BINARY` collation already does; `' COLLATE \"C\"'` on Postgres.\n\t */\n\treadonly byteOrderCollation: string;\n\t/** Appended after a `CREATE TABLE`'s closing parenthesis: `\" STRICT\"` on SQLite, `\"\"` on Postgres. */\n\treadonly tableOptions: string;\n\t/** Like `tableOptions`, for a table keyed only by its primary key: `\" STRICT, WITHOUT ROWID\"` on SQLite. */\n\treadonly withoutRowidTableOptions: string;\n\t/** An expression: integer milliseconds since the epoch on the database's clock, at the time it is evaluated. */\n\treadonly nowMs: string;\n\t/** An expression: whole seconds since the epoch on the database's clock, rounded down. */\n\treadonly nowSeconds: string;\n\t/**\n\t * Select-list items whose values change whenever any connection commits a write to the database, and the `FROM`\n\t * clause they need (with a leading space; `\"\"` when none). A change token built from them may change without a\n\t * write, never the reverse: `SELECT ${columns}, (SELECT count(*) FROM t) AS rows${from}`.\n\t */\n\treadonly changeMarkers: { readonly columns: string; readonly from: string };\n\t/** Whether `applyStorageMigrations` records applied versions in a ledger table (else steps are idempotent). */\n\treadonly versionedMigrations: boolean;\n\t/** The text at `path` (object keys) inside the JSON text in `column`; SQL `NULL` when absent. */\n\tjsonText(column: string, ...path: readonly string[]): string;\n\t/** A predicate: the JSON value at `path` inside `column` has `type`. */\n\tjsonHasType(type: StorageJsonType, column: string, ...path: readonly string[]): string;\n\t/** A predicate: `column` holds well-formed JSON text. */\n\tjsonValid(column: string): string;\n\ttextByteLength(expression: string): string;\n\t/**\n\t * A table expression for `FROM`: the elements of the JSON array in `source`, a bound parameter (`?`) or a column whose\n\t * JSON text the store wrote, as one column named `value`. On Postgres the values are text. Use it once per query and\n\t * do not alias it.\n\t */\n\tjsonValues(source: string): string;\n\t/** The larger of two values: scalar `MAX(a, b)` on SQLite, `GREATEST(a, b)` on Postgres. */\n\tgreatest(a: string, b: string): string;\n\t/** The smaller of two values: scalar `MIN(a, b)` on SQLite, `LEAST(a, b)` on Postgres. */\n\tleast(a: string, b: string): string;\n\t/** Appended to a `SELECT` in a `fenced` transaction: `\"\"` on SQLite, whose transactions already serialize. */\n\tlockClause(kind: StorageLockKind): string;\n\t/**\n\t * The column that orders a table's rows by insertion: `rowid` on SQLite, the identity column `row_order` on\n\t * Postgres, which a table declares with `rowOrderColumn`.\n\t */\n\trowOrder(alias?: string): string;\n\t/**\n\t * Appended to the column list of a `CREATE TABLE` whose rows a store orders by `rowOrder()`: `\"\"` on SQLite, where\n\t * `rowid` is implicit; `\", row_order BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE\"` on Postgres.\n\t */\n\treadonly rowOrderColumn: string;\n\t/**\n\t * The longest identifier the database keeps whole, in bytes: 63 on Postgres, which truncates longer ones; undefined\n\t * on SQLite, which has no limit. A store that adds its own words to a prefixed name keeps them short where it is set.\n\t */\n\treadonly maxIdentifierBytes: number | undefined;\n\t/**\n\t * The name the database knows `name` by. Every name fits on SQLite. On Postgres a name longer than\n\t * `maxIdentifierBytes` becomes its head and a hash of the whole name, so it is never truncated or merged with\n\t * another; every shorter name is itself. The dialect's catalog probes and trigger statements use it, so they agree.\n\t */\n\tidentifier(name: string): string;\n\t/** A query that returns one row when `table` exists in the current database (or schema). */\n\ttableExists(table: string): SqliteStatement;\n\t/**\n\t * A query that returns a row `{ name }` for each of `tables` that keeps its rows in its primary key's b-tree: a\n\t * SQLite `WITHOUT ROWID` table. None on Postgres, whose tables are heaps with indexes of their own.\n\t */\n\twithoutRowidTables(tables: readonly string[]): SqliteStatement;\n\t/**\n\t * An aggregate: the values of `expression` joined by `separator` (SQL text), in `orderBy` order. SQLite's\n\t * `group_concat` takes the order of its input, so callers also feed it rows already ordered by `orderBy`.\n\t */\n\torderedConcat(expression: string, separator: string, orderBy: string): string;\n\t/** A query that returns one row `{ name, default_value }` when `table` has `column`. */\n\tcolumnExists(table: string, column: string): SqliteStatement;\n\t/**\n\t * The statements, `;`-terminated, that create `trigger` unless it exists (SQLite) or create or replace it\n\t * (Postgres: a plpgsql function `<name>_fn` and a `FOR EACH ROW` trigger that runs it). Run them with `exec`.\n\t */\n\trenderTrigger(trigger: StorageTrigger): string;\n\t/** Drops the trigger `name` on `table`, optionally removing its PostgreSQL function when it is retired. */\n\tdropTrigger(name: string, table: string, dropFunction?: boolean): string;\n\t/**\n\t * A query that returns a row `{ name }` for each of `names` that is a table, index or trigger in the database, named\n\t * as in `names`.\n\t */\n\tschemaObjects(names: readonly string[]): SqliteStatement;\n\t/**\n\t * The type of the JSON value at `path` in `column`, as SQLite's `json_type` names it (`'null'`, `'true'`, `'false'`,\n\t * `'integer'`, `'real'`, `'text'`, `'array'`, `'object'`); SQL `NULL` when absent.\n\t */\n\tjsonType(column: string, ...path: readonly string[]): string;\n\t/**\n\t * A table expression for `FROM`, named `alias`: one row per element of the JSON array at `path` in `source`. A\n\t * later `source` of `{ column, element: alias }` reads inside each element. SQLite also iterates an object's values.\n\t */\n\tjsonEach(source: StorageJsonSource, alias: string, ...path: readonly string[]): string;\n\t/** The JSON value at `path` in `source`, as SQLite's `json_extract` returns it; text on Postgres. */\n\tjsonAt(source: StorageJsonSource, ...path: readonly string[]): string;\n\t/** A predicate: the JSON value at `path` in `source` is a string. */\n\tjsonAtIsText(source: StorageJsonSource, ...path: readonly string[]): string;\n\t/** A predicate: `needle` occurs in the text `haystack`. */\n\tcontains(haystack: string, needle: string): string;\n\t/** A predicate: `a` and `b` differ, a `NULL` differing from every value but `NULL`. */\n\tisDistinct(a: string, b: string): string;\n\t/** A predicate: `a` and `b` are equal, or both `NULL`: SQLite's `a IS b`. */\n\tisNotDistinct(a: string, b: string): string;\n\t/**\n\t * A JSON object of `entries` (each a key, an identifier, and a SQL value), as text when selected. A text value is\n\t * a JSON string, a value from `jsonObject`, `jsonArray` or `jsonGroupArray` is nested as JSON. Postgres must know\n\t * each value's type: cast a bound parameter, as `CAST(? AS ${types.int})`.\n\t */\n\tjsonObject(entries: readonly (readonly [key: string, value: string])[]): string;\n\t/** A JSON array of `values`, typed as for `jsonObject`. */\n\tjsonArray(values: readonly string[]): string;\n\t/**\n\t * An aggregate: a JSON array of `expression` over the group's rows, in `orderBy` order when given; `[]` for no\n\t * rows. SQLite's `json_group_array` takes the order of its input, so callers also feed it rows already ordered.\n\t */\n\tjsonGroupArray(expression: string, orderBy?: string): string;\n\t/**\n\t * Like `jsonText`, in a form an index expression may use: Postgres indexes only immutable expressions, which\n\t * `jsonText`'s read is not. Reads the same text for every key whose value has no NUL or surrogate escape.\n\t */\n\tjsonIndexText(column: string, ...path: readonly string[]): string;\n\t/** A query that returns `{ foreign_keys: 1 }` when the connection enforces foreign keys, as Postgres always does. */\n\treadonly foreignKeysCheck: SqliteStatement;\n\t/** A trigger statement (`StorageTrigger.statements`) that aborts the statement that fired it with `message`. */\n\tabort(message: string): string;\n\t/** Boolean literals that conditions compare and combine: `1` and `0` on SQLite, `true` and `false` on Postgres. */\n\treadonly literals: { readonly true: string; readonly false: string };\n\t/** The predicate `predicate` as an integer, 1 or 0, for an integer column. */\n\tflag(predicate: string): string;\n\t/** Inserts the rows of `select` into `table`'s `columns`, skipping each row that violates a unique constraint. */\n\tinsertOrIgnore(table: string, columns: readonly string[], select: string): string;\n\t/**\n\t * Inserts the rows of `select` into `table`'s `columns`, each replacing the row with its `key` (the primary key).\n\t * `table` must have no other unique constraint, and no row of `select` may repeat a key.\n\t */\n\tinsertOrReplace(table: string, columns: readonly string[], key: readonly string[], select: string): string;\n}\n\n/** A row trigger: `timing` `event` on `table`, it runs `statements` in order for each row where `when` holds. */\nexport interface StorageTrigger {\n\treadonly name: string;\n\treadonly table: string;\n\treadonly timing: \"BEFORE\" | \"AFTER\";\n\t/** `INSERT`, `DELETE`, `UPDATE`, or `UPDATE OF <column>`. */\n\treadonly event: string;\n\t/** A condition on the row, as `NEW` and `OLD`. */\n\treadonly when?: string;\n\t/** Statements that refer to the row as `NEW` and `OLD`. */\n\treadonly statements: readonly string[];\n}\n\n/** JSON text a query reads: the column `column`, or, with `element`, an element `jsonEach` named so yields from it. */\nexport interface StorageJsonSource {\n\treadonly column: string;\n\treadonly element?: string;\n}\n\nconst JSON_KEY = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/** Path keys are identifiers written in store code; anything else is a programming error, never user input. */\nfunction jsonPath(path: readonly string[]): readonly string[] {\n\tif (path.length === 0) throw new TypeError(\"A JSON path needs at least one key\");\n\tfor (const key of path) if (!JSON_KEY.test(key)) throw new TypeError(`Invalid JSON path key: ${key}`);\n\treturn path;\n}\n\nfunction sqlitePath(path: readonly string[]): string {\n\treturn `'$.${jsonPath(path).join(\".\")}'`;\n}\n\nfunction qualified(column: string, alias: string | undefined): string {\n\treturn alias === undefined ? column : `${alias}.${column}`;\n}\n\n/** `json_extract`'s path inside `source`: from the document's root, or from the element `jsonEach` yields. */\nfunction sqliteSourcePath(source: StorageJsonSource, path: readonly string[]): string {\n\tconst keys = `.${jsonPath(path).join(\".\")}`;\n\treturn source.element === undefined ? `'$${keys}'` : `${source.element}.fullkey || '${keys}'`;\n}\n\nconst sqliteJsonAt = (source: StorageJsonSource, ...path: readonly string[]) =>\n\t`json_extract(${source.column}, ${sqliteSourcePath(source, path)})`;\n\n/** A SQL string literal of `text`, which store code writes (never user input). */\nconst sqlString = (text: string) => `'${text.replaceAll(\"'\", \"''\")}'`;\n\n/** `json_object`'s arguments: each key, an identifier, as a string literal, then its value. */\nconst jsonEntries = (entries: readonly (readonly [string, string])[]) =>\n\tentries.map(([key, value]) => `${sqlString(jsonPath([key])[0]!)}, ${value}`).join(\", \");\n\nconst columnList = (columns: readonly string[]) => `(${columns.join(\", \")})`;\n\nconst namedPlaceholders = (names: readonly string[]) => names.map(() => \"?\").join(\", \");\n\n/** SQLite: renders exactly the SQL the stores have always run, so schemas and statements stay unchanged. */\nexport const sqliteDialect: StorageDialect = Object.freeze({\n\tname: \"sqlite\",\n\ttextByteLength: (expression: string) => `length(CAST(${expression} AS BLOB))`,\n\ttypes: Object.freeze({\n\t\tint: \"INTEGER\",\n\t\treal: \"REAL\",\n\t\ttext: \"TEXT\",\n\t\tblob: \"BLOB\",\n\t\tserialKey: \"INTEGER PRIMARY KEY AUTOINCREMENT\",\n\t\trowKey: \"INTEGER PRIMARY KEY\",\n\t}),\n\tbyteOrderCollation: \"\",\n\ttableOptions: \" STRICT\",\n\twithoutRowidTableOptions: \" STRICT, WITHOUT ROWID\",\n\tnowMs: \"CAST(round((julianday('now') - 2440587.5) * 86400000) AS INTEGER)\",\n\tnowSeconds: \"unixepoch()\",\n\tchangeMarkers: Object.freeze({\n\t\tcolumns: \"data_version, total_changes() AS changes\",\n\t\tfrom: \" FROM pragma_data_version\",\n\t}),\n\tversionedMigrations: false,\n\tjsonText: (column: string, ...path: readonly string[]) => `json_extract(${column}, ${sqlitePath(path)})`,\n\tjsonHasType: (type: StorageJsonType, column: string, ...path: readonly string[]) =>\n\t\t`json_type(${column}, ${sqlitePath(path)}) = '${type}'`,\n\tjsonValid: (column: string) => `json_valid(${column})`,\n\tjsonValues: (source: string) => `json_each(${source})`,\n\tgreatest: (a: string, b: string) => `MAX(${a}, ${b})`,\n\tleast: (a: string, b: string) => `MIN(${a}, ${b})`,\n\tlockClause: (_kind: StorageLockKind) => \"\",\n\trowOrder: (alias?: string) => qualified(\"rowid\", alias),\n\trowOrderColumn: \"\",\n\tmaxIdentifierBytes: undefined,\n\tidentifier: (name: string) => name,\n\ttableExists: (table: string) => ({\n\t\tsql: \"SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?\",\n\t\tparams: [table],\n\t}),\n\twithoutRowidTables: (tables: readonly string[]) => ({\n\t\tsql: `SELECT name FROM pragma_table_list WHERE schema = 'main' AND type = 'table' AND wr = 1 AND name IN (${namedPlaceholders(tables)})`,\n\t\tparams: [...tables],\n\t}),\n\torderedConcat: (expression: string, separator: string, _orderBy: string) =>\n\t\t`group_concat(${expression}, ${separator})`,\n\tcolumnExists: (table: string, column: string) => ({\n\t\tsql: \"SELECT name, dflt_value AS default_value FROM pragma_table_info(?) WHERE name = ?\",\n\t\tparams: [table, column],\n\t}),\n\trenderTrigger: ({ name, table, timing, event, when, statements }: StorageTrigger) =>\n\t\t`CREATE TRIGGER IF NOT EXISTS ${name} ${timing} ${event} ON ${table}${when === undefined ? \"\" : ` WHEN ${when}`} BEGIN ${statements.join(\"; \")}; END;`,\n\tdropTrigger: (name: string, _table: string) => `DROP TRIGGER IF EXISTS ${name}`,\n\tschemaObjects: (names: readonly string[]) => ({\n\t\tsql: `SELECT name FROM sqlite_schema WHERE name IN (${namedPlaceholders(names)})`,\n\t\tparams: [...names],\n\t}),\n\tjsonType: (column: string, ...path: readonly string[]) => `json_type(${column}, ${sqlitePath(path)})`,\n\tjsonEach: (source: StorageJsonSource, alias: string, ...path: readonly string[]) =>\n\t\t`json_each(${source.column}, ${sqliteSourcePath(source, path)}) AS ${alias}`,\n\tjsonAt: sqliteJsonAt,\n\tjsonAtIsText: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\t`typeof(${sqliteJsonAt(source, ...path)}) = 'text'`,\n\tcontains: (haystack: string, needle: string) => `instr(${haystack}, ${needle}) > 0`,\n\tisDistinct: (a: string, b: string) => `${a} IS NOT ${b}`,\n\tisNotDistinct: (a: string, b: string) => `${a} IS ${b}`,\n\tjsonObject: (entries: readonly (readonly [string, string])[]) => `json_object(${jsonEntries(entries)})`,\n\tjsonArray: (values: readonly string[]) => `json_array(${values.join(\", \")})`,\n\tjsonGroupArray: (expression: string, _orderBy?: string) => `json_group_array(${expression})`,\n\tjsonIndexText: (column: string, ...path: readonly string[]) => `json_extract(${column}, ${sqlitePath(path)})`,\n\tforeignKeysCheck: Object.freeze({ sql: \"PRAGMA foreign_keys\", params: [] }),\n\tabort: (message: string) => `SELECT RAISE(ABORT, ${sqlString(message)})`,\n\tliterals: Object.freeze({ true: \"1\", false: \"0\" }),\n\tflag: (predicate: string) => predicate,\n\tinsertOrIgnore: (table: string, columns: readonly string[], select: string) =>\n\t\t`INSERT OR IGNORE INTO ${table} ${columnList(columns)} ${select}`,\n\tinsertOrReplace: (table: string, columns: readonly string[], _key: readonly string[], select: string) =>\n\t\t`INSERT OR REPLACE INTO ${table} ${columnList(columns)} ${select}`,\n});\n\nconst POSTGRES_JSON_TYPES: Readonly<Record<StorageJsonType, string>> = {\n\tnull: \"null\",\n\ttext: \"string\",\n\tobject: \"object\",\n\tarray: \"array\",\n};\n\nconst POSTGRES_LOCKS: Readonly<Record<StorageLockKind, string>> = {\n\tupdate: \" FOR UPDATE\",\n\tshare: \" FOR SHARE\",\n\t\"update-skip-locked\": \" FOR UPDATE SKIP LOCKED\",\n\t\"key-share\": \" FOR KEY SHARE\",\n};\n\n/**\n * A `\\u0000` or UTF-16 surrogate escape in JSON text, after an even number of backslashes, so not the text `\\u…` after\n * an escaped `\\`.\n */\nconst POSTGRES_UNREPRESENTABLE_ESCAPE = String.raw`'(?<!\\\\)((?:\\\\\\\\)*)\\\\u(?:0000|[dD][89abcdefABCDEF][0-9a-fA-F]{2})'`;\n\n/**\n * The JSON text in `column` as `jsonb`. SQLite reads any well-formed JSON, but Postgres's `jsonb` (and its `json`\n * operators) reject a whole document with a `\\u0000` escape or a lone surrogate escape anywhere in it, even outside\n * the value read. Such a document reads with each NUL and surrogate escape as U+FFFD, so a write whose JSON carries\n * one never fails on a query or trigger that reads it, and every other value reads as on SQLite. A document without\n * an escape, or that `jsonb` accepts, reads unchanged.\n */\nexport function postgresJsonb(column: string): string {\n\treturn String.raw`(CASE WHEN strpos(${column}, '\\u') = 0 OR pg_input_is_valid(${column}, 'jsonb') THEN ${column} ELSE regexp_replace(${column}, ${POSTGRES_UNREPRESENTABLE_ESCAPE}, '\\1\\\\ufffd', 'g') END)::jsonb`;\n}\n\n/** The value at `path` in the `jsonb` expression `document`: as text with `text`, else as `jsonb`. */\nfunction postgresJson(document: string, path: readonly string[], text: boolean): string {\n\tconst keys = jsonPath(path);\n\tconst operator = text ? \">>\" : \">\";\n\treturn keys.length === 1\n\t\t? `(${document} -${operator} '${keys[0]}')`\n\t\t: `(${document} #${operator} '{${keys.join(\",\")}}')`;\n}\n\n/** The `jsonb` document `source` names: its column's JSON text, or the `value` of the element `jsonEach` yields. */\nconst postgresDocument = (source: StorageJsonSource) =>\n\tsource.element === undefined ? postgresJsonb(source.column) : `${source.element}.value`;\n\n/** Postgres truncates longer identifiers, so two long names could become one. Names are ASCII. */\nconst POSTGRES_IDENTIFIER_BYTES = 63;\n/**\n * Hex digits of the hash that ends a shortened Postgres identifier: the whole 64 bits. Names that share their head\n * differ only in it, and 32 bits of FNV-1a made two such names under a valid prefix one (#5219).\n */\nconst POSTGRES_IDENTIFIER_HASH_DIGITS = 16;\n/** Hex digits of the 32-bit hash earlier builds ended a shortened identifier with, which an upgrade drops (#5219). */\nconst LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS = 8;\n\nconst FNV_OFFSET = 0xcbf29ce484222325n;\nconst FNV_PRIME = 0x100000001b3n;\nconst U64 = (1n << 64n) - 1n;\n\n/**\n * 64-bit FNV-1a of `name`'s characters: computed in plain JavaScript so storage modules stay free of runtime-specific\n * imports. Names are ASCII, written in store code.\n */\nfunction fnv1a64(name: string): bigint {\n\tlet hash = FNV_OFFSET;\n\tfor (let index = 0; index < name.length; index++) hash = ((hash ^ BigInt(name.charCodeAt(index))) * FNV_PRIME) & U64;\n\treturn hash;\n}\n\nfunction postgresIdentifier(name: string): string {\n\tif (name.length <= POSTGRES_IDENTIFIER_BYTES) return name;\n\tconst hash = fnv1a64(name).toString(16).padStart(POSTGRES_IDENTIFIER_HASH_DIGITS, \"0\");\n\treturn `${name.slice(0, POSTGRES_IDENTIFIER_BYTES - POSTGRES_IDENTIFIER_HASH_DIGITS - 1)}_${hash}`;\n}\n\n/**\n * The name an earlier build gave `name` when it did not fit (its first 54 characters and the 64-bit hash folded to 32\n * bits), or undefined when it fits. Two names could get the same one, so a trigger installed under it may be missing\n * (#5219): installing a trigger drops it, so no trigger an earlier build installed stays beside its replacement.\n */\nfunction legacyPostgresIdentifier(name: string): string | undefined {\n\tif (name.length <= POSTGRES_IDENTIFIER_BYTES) return undefined;\n\tconst hash = fnv1a64(name);\n\tconst folded = ((hash ^ (hash >> 32n)) & 0xffffffffn)\n\t\t.toString(16)\n\t\t.padStart(LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS, \"0\");\n\treturn `${name.slice(0, POSTGRES_IDENTIFIER_BYTES - LEGACY_POSTGRES_IDENTIFIER_HASH_DIGITS - 1)}_${folded}`;\n}\n\n/** Drops the trigger an earlier build installed as `name` on `table` under its shortened name, if it had one (#5219). */\nfunction dropLegacyTrigger(name: string, table: string): string {\n\tconst legacy = legacyPostgresIdentifier(name);\n\treturn legacy === undefined ? \"\" : `;\\nDROP TRIGGER IF EXISTS ${legacy} ON ${table}`;\n}\n\nfunction postgresSchemaObjects(names: readonly string[]): SqliteStatement {\n\tconst physical = names.map(postgresIdentifier);\n\tif (physical.every((name, index) => name === names[index]))\n\t\treturn {\n\t\t\tsql: `SELECT relname AS name FROM pg_catalog.pg_class WHERE relnamespace = current_schema()::regnamespace AND relname IN (${namedPlaceholders(names)}) UNION ALL SELECT tgname AS name FROM pg_catalog.pg_trigger JOIN pg_catalog.pg_class ON pg_class.oid = tgrelid WHERE relnamespace = current_schema()::regnamespace AND NOT tgisinternal AND tgname IN (${namedPlaceholders(names)})`,\n\t\t\tparams: [...names, ...names],\n\t\t};\n\t// A shortened name is found by the name Postgres knows, and reported by the one asked for.\n\treturn {\n\t\tsql: `SELECT v.name FROM (VALUES ${names.map(() => \"(?, ?)\").join(\", \")}) AS v(name, physical) WHERE v.physical IN (SELECT relname::text FROM pg_catalog.pg_class WHERE relnamespace = current_schema()::regnamespace) OR v.physical IN (SELECT tgname::text FROM pg_catalog.pg_trigger JOIN pg_catalog.pg_class ON pg_class.oid = tgrelid WHERE relnamespace = current_schema()::regnamespace AND NOT tgisinternal)`,\n\t\tparams: names.flatMap((name, index) => [name, physical[index]!]),\n\t};\n}\n\nfunction postgresTrigger({ name, table, timing, event, when, statements }: StorageTrigger): string {\n\tconst fn = postgresIdentifier(`${name}_fn`);\n\tconst body = statements.map((statement) => `${statement};`).join(\" \");\n\tconst row = timing === \"AFTER\" ? \"NULL\" : event === \"DELETE\" ? \"OLD\" : \"NEW\";\n\t// The function an earlier build named otherwise (#5219), once no trigger runs it; one another trigger of that build\n\t// still runs is dropped when that trigger is installed again.\n\tconst legacyFn = legacyPostgresIdentifier(`${name}_fn`);\n\tconst dropLegacyFn =\n\t\tlegacyFn === undefined\n\t\t\t? \"\"\n\t\t\t: `\\nDO $legacy$ BEGIN DROP FUNCTION IF EXISTS ${legacyFn}(); EXCEPTION WHEN dependent_objects_still_exist THEN NULL; END $legacy$;`;\n\treturn `CREATE OR REPLACE FUNCTION ${fn}() RETURNS trigger LANGUAGE plpgsql AS $trigger$ BEGIN ${when === undefined ? body : `IF (${when}) THEN ${body} END IF;`} RETURN ${row}; END $trigger$${dropLegacyTrigger(name, table)};\nCREATE OR REPLACE TRIGGER ${postgresIdentifier(name)} ${timing} ${event} ON ${table} FOR EACH ROW EXECUTE FUNCTION ${fn}();${dropLegacyFn}`;\n}\n\n/** `value`'s type as SQLite's `json_type` names it, for a `jsonb` expression. */\nfunction postgresSqliteJsonType(value: string): string {\n\treturn `(CASE jsonb_typeof(${value}) WHEN 'string' THEN 'text' WHEN 'boolean' THEN (${value})::text WHEN 'number' THEN CASE WHEN (${value})::text ~ '^-?[0-9]+$' THEN 'integer' ELSE 'real' END ELSE jsonb_typeof(${value}) END)`;\n}\n\n/**\n * PostgreSQL (14 and later; `jsonValid` and every JSON read need 16, for `IS JSON` and `pg_input_is_valid`). Tables\n * a store orders by `rowOrder()` carry an explicit identity column, `row_order` (not `seq`, which several tables\n * already use for their own sequence numbers).\n */\nexport const postgresDialect: StorageDialect = Object.freeze({\n\tname: \"postgres\",\n\ttextByteLength: (expression: string) => `octet_length(${expression})`,\n\ttypes: Object.freeze({\n\t\tint: \"BIGINT\",\n\t\treal: \"DOUBLE PRECISION\",\n\t\ttext: \"TEXT\",\n\t\tblob: \"BYTEA\",\n\t\tserialKey: \"BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY\",\n\t\trowKey: \"BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY\",\n\t}),\n\tbyteOrderCollation: ' COLLATE \"C\"',\n\ttableOptions: \"\",\n\twithoutRowidTableOptions: \"\",\n\tnowMs: \"(floor(extract(epoch from clock_timestamp()) * 1000))::bigint\",\n\tnowSeconds: \"(floor(extract(epoch from clock_timestamp())))::bigint\",\n\tchangeMarkers: Object.freeze({ columns: \"pg_current_snapshot()::text AS snapshot\", from: \"\" }),\n\tversionedMigrations: true,\n\tjsonText: (column: string, ...path: readonly string[]) => postgresJson(postgresJsonb(column), path, true),\n\tjsonHasType: (type: StorageJsonType, column: string, ...path: readonly string[]) =>\n\t\t`jsonb_typeof${postgresJson(postgresJsonb(column), path, false)} = '${POSTGRES_JSON_TYPES[type]}'`,\n\tjsonValid: (column: string) => `((${column}) IS JSON)`,\n\tjsonValues: (source: string) => `jsonb_array_elements_text((${source})::jsonb) AS json_values(value)`,\n\tgreatest: (a: string, b: string) => `GREATEST(${a}, ${b})`,\n\tleast: (a: string, b: string) => `LEAST(${a}, ${b})`,\n\tlockClause: (kind: StorageLockKind) => POSTGRES_LOCKS[kind],\n\trowOrder: (alias?: string) => qualified(\"row_order\", alias),\n\trowOrderColumn: \", row_order BIGINT GENERATED ALWAYS AS IDENTITY UNIQUE\",\n\tmaxIdentifierBytes: POSTGRES_IDENTIFIER_BYTES,\n\tidentifier: postgresIdentifier,\n\ttableExists: (table: string) => ({\n\t\t// The catalog, not information_schema, which hides a table the role has no privilege on: a role missing a grant\n\t\t// must not take an existing table for one to create (#5218).\n\t\tsql: \"SELECT c.relname AS name FROM pg_catalog.pg_class c WHERE c.relnamespace = current_schema()::regnamespace AND c.relkind IN ('r', 'p', 'v', 'm', 'f') AND c.relname = ?\",\n\t\tparams: [postgresIdentifier(table)],\n\t}),\n\twithoutRowidTables: (_tables: readonly string[]) => ({\n\t\tsql: \"SELECT relname AS name FROM pg_catalog.pg_class WHERE false\",\n\t\tparams: [],\n\t}),\n\torderedConcat: (expression: string, separator: string, orderBy: string) =>\n\t\t`string_agg(${expression}, ${separator} ORDER BY ${orderBy})`,\n\tcolumnExists: (table: string, column: string) => ({\n\t\tsql: \"SELECT column_name AS name, column_default AS default_value FROM information_schema.columns WHERE table_schema = current_schema() AND table_name = ? AND column_name = ?\",\n\t\tparams: [postgresIdentifier(table), column],\n\t}),\n\trenderTrigger: postgresTrigger,\n\tdropTrigger: (name: string, table: string, dropFunction = false) =>\n\t\t`DROP TRIGGER IF EXISTS ${postgresIdentifier(name)} ON ${table}${dropLegacyTrigger(name, table)}${dropFunction ? `;\\nDROP FUNCTION IF EXISTS ${postgresIdentifier(`${name}_fn`)}()` : \"\"}`,\n\tschemaObjects: postgresSchemaObjects,\n\tjsonType: (column: string, ...path: readonly string[]) =>\n\t\tpostgresSqliteJsonType(postgresJson(postgresJsonb(column), path, false)),\n\tjsonEach: (source: StorageJsonSource, alias: string, ...path: readonly string[]) =>\n\t\t`jsonb_path_query(${postgresDocument(source)}, '$.${jsonPath(path)\n\t\t\t.map((key) => `\"${key}\"`)\n\t\t\t.join(\".\")}[*]') AS ${alias}(value)`,\n\tjsonAt: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\tpostgresJson(postgresDocument(source), path, true),\n\tjsonAtIsText: (source: StorageJsonSource, ...path: readonly string[]) =>\n\t\t`jsonb_typeof${postgresJson(postgresDocument(source), path, false)} = 'string'`,\n\tcontains: (haystack: string, needle: string) => `strpos(${haystack}, ${needle}) > 0`,\n\tisDistinct: (a: string, b: string) => `${a} IS DISTINCT FROM ${b}`,\n\tisNotDistinct: (a: string, b: string) => `${a} IS NOT DISTINCT FROM ${b}`,\n\tjsonObject: (entries: readonly (readonly [string, string])[]) => `json_build_object(${jsonEntries(entries)})`,\n\tjsonArray: (values: readonly string[]) => `json_build_array(${values.join(\", \")})`,\n\tjsonGroupArray: (expression: string, orderBy?: string) =>\n\t\t`COALESCE(json_agg(${expression}${orderBy === undefined ? \"\" : ` ORDER BY ${orderBy}`}), '[]'::json)`,\n\tjsonIndexText: (column: string, ...path: readonly string[]) =>\n\t\tpostgresJson(\n\t\t\t`(regexp_replace(${column}, ${POSTGRES_UNREPRESENTABLE_ESCAPE}, '\\\\1\\\\\\\\ufffd', 'g'))::jsonb`,\n\t\t\tpath,\n\t\t\ttrue,\n\t\t),\n\tforeignKeysCheck: Object.freeze({ sql: \"SELECT 1 AS foreign_keys\", params: [] }),\n\tabort: (message: string) => `RAISE EXCEPTION ${sqlString(message)}`,\n\tliterals: Object.freeze({ true: \"true\", false: \"false\" }),\n\tflag: (predicate: string) => `(${predicate})::int`,\n\tinsertOrIgnore: (table: string, columns: readonly string[], select: string) =>\n\t\t`INSERT INTO ${table} ${columnList(columns)} ${select} ON CONFLICT DO NOTHING`,\n\tinsertOrReplace: (table: string, columns: readonly string[], key: readonly string[], select: string) =>\n\t\t`INSERT INTO ${table} ${columnList(columns)} ${select} ON CONFLICT ${columnList(key)} DO UPDATE SET ${columns\n\t\t\t.filter((column) => !key.includes(column))\n\t\t\t.map((column) => `${column} = excluded.${column}`)\n\t\t\t.join(\", \")}`,\n});\n\n/** The dialect a database speaks: its own, or SQLite's for a database that names none (every adapter before #4793). */\nexport function dialectOf(database: { readonly dialect?: StorageDialect }): StorageDialect {\n\treturn database.dialect ?? sqliteDialect;\n}\n"]}
|
|
@@ -90,9 +90,8 @@ export interface StoragePayloadTooLargeOptions {
|
|
|
90
90
|
/** Recognizes a response refusal without inspecting the adapter's rejection (which can even be a revoked proxy). */
|
|
91
91
|
export declare function isStorageResponseRefusal(error: unknown): error is StoragePayloadTooLargeError;
|
|
92
92
|
/**
|
|
93
|
-
* The backend refused a payload larger than it accepts: a bound or computed value or row (
|
|
94
|
-
*
|
|
95
|
-
* server's `RESPONSE_TOO_LARGE`). Permanent: the same write fails again, so it is never `retryable` and never a
|
|
93
|
+
* The backend refused a payload larger than it accepts: a bound or computed value or row (SQLite's `SQLITE_TOOBIG`,
|
|
94
|
+
* Postgres's `54000`), or a statement's response, as a custom adapter can report. Permanent: the same write fails again, so it is never `retryable` and never a
|
|
96
95
|
* `StorageUnavailableError` (#4954). `limitBytes` is the backend's default limit when the backend does not report its
|
|
97
96
|
* own; `actualBytes` is the largest value the statement bound, or 0 when unknown (a response). A value refused while
|
|
98
97
|
* the largest bound value is within the limit is one the backend built running the statement, a row of several values
|
|
@@ -101,7 +100,7 @@ export declare function isStorageResponseRefusal(error: unknown): error is Stora
|
|
|
101
100
|
export declare class StoragePayloadTooLargeError extends StorageError {
|
|
102
101
|
readonly code: "payload-too-large";
|
|
103
102
|
readonly retryable: false;
|
|
104
|
-
readonly hint = "Retrying does not help: store less in one value, or raise the backend's limit
|
|
103
|
+
readonly hint = "Retrying does not help: store less in one value, or raise the backend's limit";
|
|
105
104
|
readonly limitBytes: number;
|
|
106
105
|
readonly actualBytes: number;
|
|
107
106
|
readonly kind: StoragePayloadKind;
|
|
@@ -116,7 +115,7 @@ export type StoragePayloadLimits = Readonly<Partial<Record<StoragePayloadKind, n
|
|
|
116
115
|
export declare const SQLITE_PAYLOAD_LIMITS: StoragePayloadLimits;
|
|
117
116
|
/**
|
|
118
117
|
* The kind of payload `failure`, or a cause of it, says the backend refused as too large, if it says so: read from
|
|
119
|
-
* codes, never from a message
|
|
118
|
+
* codes, never from a message.
|
|
120
119
|
*/
|
|
121
120
|
export declare function payloadTooLargeKind(failure: StorageFailureCause | Error): StoragePayloadKind | undefined;
|
|
122
121
|
/** The byte size of the largest text or binary value in `params`, as UTF-8 for text. */
|
|
@@ -386,9 +385,7 @@ export declare function isSessionSpillError(value: unknown): value is SessionSpi
|
|
|
386
385
|
export declare function isStorageError(value: unknown): value is StorageError;
|
|
387
386
|
/** The write-lock timeout anywhere in an error's cause chain, for failures that wrap it. */
|
|
388
387
|
export declare function findStorageWriteLockTimeoutError(error: unknown): StorageWriteLockTimeoutError | undefined;
|
|
389
|
-
/** The command that joins
|
|
390
|
-
export declare const SHARED_STORAGE_JOIN_HINT = "atomic team join <url> --token-file <path>";
|
|
391
|
-
/** The command that joins a machine to a shared PostgreSQL database, which `atomic team join` refuses (#5218). */
|
|
388
|
+
/** The command that joins a machine to a shared PostgreSQL database (#5218). */
|
|
392
389
|
export declare const POSTGRES_STORAGE_JOIN_HINT = "atomic storage join <postgres-url> --password-file <path>";
|
|
393
390
|
/** Whether a storage error in the cause chain says the operation may succeed if tried again later. */
|
|
394
391
|
export declare function isRetryableStorageError(error: unknown): boolean;
|
|
@@ -421,8 +418,11 @@ export declare function serializeStorageError(error: StorageError): SerializedSt
|
|
|
421
418
|
export declare function rehydrateStorageError(serialized: SerializedStorageError): StorageError;
|
|
422
419
|
/** Why a team setup operation failed after its inputs were accepted. */
|
|
423
420
|
export type TeamProfileErrorCode = "settings-unreadable" | "adapter-not-installed" | "connection-failed" | "connection-timeout" | "auth-unavailable" | "token-write-failed" | "settings-write-failed" | "settings-locked" | "broker-restart-failed" | "token-delete-failed";
|
|
424
|
-
/**
|
|
425
|
-
|
|
421
|
+
/**
|
|
422
|
+
* Why a shared-database input was rejected: a CLI argument or SDK option, or, with `libsql-removed`, a libSQL URL or a
|
|
423
|
+
* variable of the removed `ATOMIC_PROFILE=ci` team profile.
|
|
424
|
+
*/
|
|
425
|
+
export type TeamProfileConfigErrorCode = "libsql-removed" | "unknown-profile" | "incomplete-profile" | "missing-url" | "unsupported-url" | "relative-file-url" | "credential-in-url" | "missing-token" | "conflicting-token" | "unreadable-token-file" | "relative-token-file" | "empty-token" | "unsupported-auth" | "unsupported-option" | "invalid-prefix" | "unknown-command" | "unknown-option" | "missing-value" | "unexpected-argument";
|
|
426
426
|
export declare const TEAM_PROFILE_ERROR_CODES: ReadonlySet<TeamProfileErrorCode>;
|
|
427
427
|
export declare const TEAM_PROFILE_CONFIG_ERROR_CODES: ReadonlySet<TeamProfileConfigErrorCode>;
|
|
428
428
|
/** The facts a {@link TeamProfileError} carries; every field is JSON-safe and holds no credential. */
|
|
@@ -464,7 +464,7 @@ export declare class TeamProfileTimeoutError extends TeamProfileError {
|
|
|
464
464
|
}
|
|
465
465
|
export interface TeamProfileConfigErrorFields {
|
|
466
466
|
readonly source: "sdk" | "cli" | "env";
|
|
467
|
-
/** The option, argument or variable, for example
|
|
467
|
+
/** The option, argument or variable, for example `--password-file`, `<url>` or `ATOMIC_PROFILE`. */
|
|
468
468
|
readonly field: string;
|
|
469
469
|
readonly hint: string;
|
|
470
470
|
/** The token file the input names, when the failure is about that file. */
|
|
@@ -474,8 +474,8 @@ export interface TeamProfileConfigErrorFields {
|
|
|
474
474
|
readonly cause?: Error;
|
|
475
475
|
}
|
|
476
476
|
/**
|
|
477
|
-
* An invalid
|
|
478
|
-
* handle invalid `ATOMIC_STORAGE` values handle
|
|
477
|
+
* An invalid shared-database input. It is a {@link StorageConfigError} whose `reason` equals `code`, so hosts that
|
|
478
|
+
* already handle invalid `ATOMIC_STORAGE` values handle it the same way.
|
|
479
479
|
*/
|
|
480
480
|
export declare class TeamProfileConfigError extends StorageConfigError {
|
|
481
481
|
readonly name: "TeamProfileConfigError";
|
|
@@ -112,7 +112,7 @@ export class StorageOutcomeUnknownError extends StorageError {
|
|
|
112
112
|
this.key = key;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
const PAYLOAD_TOO_LARGE_HINT = "Retrying does not help: store less in one value, or raise the backend's limit
|
|
115
|
+
const PAYLOAD_TOO_LARGE_HINT = "Retrying does not help: store less in one value, or raise the backend's limit";
|
|
116
116
|
function byteCount(bytes) {
|
|
117
117
|
return `${bytes.toLocaleString("en-US")} bytes`;
|
|
118
118
|
}
|
|
@@ -122,9 +122,8 @@ export function isStorageResponseRefusal(error) {
|
|
|
122
122
|
return responseRefusals?.has(error) === true;
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
-
* The backend refused a payload larger than it accepts: a bound or computed value or row (
|
|
126
|
-
*
|
|
127
|
-
* server's `RESPONSE_TOO_LARGE`). Permanent: the same write fails again, so it is never `retryable` and never a
|
|
125
|
+
* The backend refused a payload larger than it accepts: a bound or computed value or row (SQLite's `SQLITE_TOOBIG`,
|
|
126
|
+
* Postgres's `54000`), or a statement's response, as a custom adapter can report. Permanent: the same write fails again, so it is never `retryable` and never a
|
|
128
127
|
* `StorageUnavailableError` (#4954). `limitBytes` is the backend's default limit when the backend does not report its
|
|
129
128
|
* own; `actualBytes` is the largest value the statement bound, or 0 when unknown (a response). A value refused while
|
|
130
129
|
* the largest bound value is within the limit is one the backend built running the statement, a row of several values
|
|
@@ -167,18 +166,14 @@ const SQLITE_TOOBIG = 18;
|
|
|
167
166
|
export const SQLITE_PAYLOAD_LIMITS = Object.freeze({ value: 1_000_000_000 });
|
|
168
167
|
/**
|
|
169
168
|
* The kind of payload `failure`, or a cause of it, says the backend refused as too large, if it says so: read from
|
|
170
|
-
* codes, never from a message
|
|
169
|
+
* codes, never from a message.
|
|
171
170
|
*/
|
|
172
171
|
export function payloadTooLargeKind(failure) {
|
|
173
172
|
let current = failure;
|
|
174
173
|
for (let depth = 0; depth < MAX_STORAGE_CAUSE_DEPTH && typeof current === "object" && current !== null; depth++) {
|
|
175
|
-
const { code, errcode,
|
|
176
|
-
if (code === "RESPONSE_TOO_LARGE")
|
|
177
|
-
return "response";
|
|
174
|
+
const { code, errcode, cause } = current;
|
|
178
175
|
if (code === "SQLITE_TOOBIG" || code === "54000")
|
|
179
176
|
return "value";
|
|
180
|
-
if (code === "ARGS_INVALID" && typeof message === "string" && /too big/i.test(message))
|
|
181
|
-
return "value";
|
|
182
177
|
if (typeof errcode === "number" && (errcode & 0xff) === SQLITE_TOOBIG)
|
|
183
178
|
return "value";
|
|
184
179
|
current = cause;
|
|
@@ -387,7 +382,7 @@ export const SESSION_BLOB_ERROR_CODES = [
|
|
|
387
382
|
"blob-incomplete",
|
|
388
383
|
];
|
|
389
384
|
const SESSION_BLOB_HINTS = {
|
|
390
|
-
"blobs-unsupported": "Keep the session in a SQLite or
|
|
385
|
+
"blobs-unsupported": "Keep the session in a SQLite or PostgreSQL session store (the default sessions database, --session-store <path>, or a sessions.storage selection), or give a custom store putBlob and getBlob",
|
|
391
386
|
"blob-missing": "The session no longer holds this output; run the tool again to see it",
|
|
392
387
|
"blob-corrupt": "The exported session was changed after it was written; export it again from its source",
|
|
393
388
|
"blob-incomplete": "The store lost part of this output; run the tool again to see it",
|
|
@@ -569,9 +564,7 @@ export function findStorageWriteLockTimeoutError(error) {
|
|
|
569
564
|
return undefined;
|
|
570
565
|
}
|
|
571
566
|
const MAX_CAUSE_DEPTH = 8;
|
|
572
|
-
/** The command that joins
|
|
573
|
-
export const SHARED_STORAGE_JOIN_HINT = "atomic team join <url> --token-file <path>";
|
|
574
|
-
/** The command that joins a machine to a shared PostgreSQL database, which `atomic team join` refuses (#5218). */
|
|
567
|
+
/** The command that joins a machine to a shared PostgreSQL database (#5218). */
|
|
575
568
|
export const POSTGRES_STORAGE_JOIN_HINT = "atomic storage join <postgres-url> --password-file <path>";
|
|
576
569
|
function hasCode(value, name, codes) {
|
|
577
570
|
if (typeof value !== "object" || value === null)
|
|
@@ -791,6 +784,7 @@ export const TEAM_PROFILE_ERROR_CODES = new Set([
|
|
|
791
784
|
"token-delete-failed",
|
|
792
785
|
]);
|
|
793
786
|
export const TEAM_PROFILE_CONFIG_ERROR_CODES = new Set([
|
|
787
|
+
"libsql-removed",
|
|
794
788
|
"unknown-profile",
|
|
795
789
|
"incomplete-profile",
|
|
796
790
|
"missing-url",
|
|
@@ -873,8 +867,8 @@ export class TeamProfileTimeoutError extends TeamProfileError {
|
|
|
873
867
|
}
|
|
874
868
|
}
|
|
875
869
|
/**
|
|
876
|
-
* An invalid
|
|
877
|
-
* handle invalid `ATOMIC_STORAGE` values handle
|
|
870
|
+
* An invalid shared-database input. It is a {@link StorageConfigError} whose `reason` equals `code`, so hosts that
|
|
871
|
+
* already handle invalid `ATOMIC_STORAGE` values handle it the same way.
|
|
878
872
|
*/
|
|
879
873
|
export class TeamProfileConfigError extends StorageConfigError {
|
|
880
874
|
name = "TeamProfileConfigError";
|