@bastani/atomic 0.10.11-alpha.3 → 0.10.11
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 +208 -0
- 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 +4 -4
- package/dist/_shared/mode-rpc-sdk-IOPGDYR4.js +4 -4
- package/dist/_shared/mode-shared-2QJSCUM6.js +4 -4
- package/dist/_shared/p1a-prewarm-XIU57JHF.js +3 -3
- package/dist/_shared/p1b-elig-TVB5CBLL.js +22 -6
- package/dist/_shared/p1b-elig-TVB5CBLL.js.map +1 -1
- 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 +2 -2
- package/dist/_shared/sdk-B5LEWGGI.js +899 -515
- package/dist/_shared/sdk-B5LEWGGI.js.map +1 -1
- 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-EZUKEP4Q.js → startup-0-0-XJJDOIEC.js} +6 -12
- package/dist/_shared/{startup-0-0-EZUKEP4Q.js.map → startup-0-0-XJJDOIEC.js.map} +1 -1
- package/dist/_shared/{startup-0-1-RTOHJFDJ.js → startup-0-1-M6OWAYHH.js} +354 -103
- package/dist/_shared/startup-0-1-M6OWAYHH.js.map +1 -0
- package/dist/_shared/startup-0-2-5QHPCEON.js +18 -9
- package/dist/_shared/startup-0-2-5QHPCEON.js.map +1 -1
- package/dist/_shared/startup-0-3-4ZYBYQNM.js +4 -4
- package/dist/_shared/startup-0-4-ZMJV547D.js +4 -4
- package/dist/_shared/startup-0-5-YDW47QX6.js +4 -4
- package/dist/_shared/startup-10-0-TDQNBDDL.js +4 -4
- package/dist/_shared/startup-12-0-55AAXBJZ.js +1 -1
- package/dist/_shared/startup-14-0-MLX36RBG.js +2 -2
- package/dist/_shared/startup-15-0-YUKGAC63.js +2 -2
- package/dist/_shared/startup-15-1-4S7FLMNG.js +4 -4
- package/dist/_shared/startup-8-0-34CBHPZH.js +2114 -235
- package/dist/_shared/startup-8-0-34CBHPZH.js.map +1 -1
- package/dist/_shared/startup-8-1-LZFXSD3Z.js +12 -12
- package/dist/_shared/storage-command-7MGXLJGZ.js +6 -6
- package/dist/_shared/storage-command-7MGXLJGZ.js.map +1 -1
- package/dist/_shared/storage-status-K7PX2RXA.js +2 -2
- package/dist/_shared/task-unsaved-answer-VJ2KTB4V.js +2 -2
- package/dist/_shared/team-DOQKICG2.js +1 -1
- package/dist/_shared/tree-outline-MUEPK5B7.js +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +65 -0
- package/dist/builtin/intercom/broker/broker.bundle.mjs +1020 -108
- package/dist/builtin/intercom/broker/client.ts +8 -0
- package/dist/builtin/intercom/broker/database-wake-up-bus.ts +91 -14
- package/dist/builtin/intercom/broker/multinode-router.ts +102 -17
- package/dist/builtin/intercom/broker/multinode-state-store.ts +41 -2
- package/dist/builtin/intercom/broker/send-order-gate.ts +5 -2
- package/dist/builtin/intercom/broker/sql-add-column.ts +22 -1
- package/dist/builtin/intercom/broker/sql-lease-store.ts +304 -48
- package/dist/builtin/intercom/broker/sql-outbox-store.ts +541 -50
- package/dist/builtin/intercom/broker/sql-restoring-reservation-store.ts +239 -8
- package/dist/builtin/intercom/broker/sql-retention.ts +11 -2
- package/dist/builtin/intercom/broker/sql-schema.ts +42 -8
- package/dist/builtin/intercom/index.bundle.mjs +13 -2
- 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 +20 -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 +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/cli/args.js +2 -2
- package/dist/cli/auth-cli.code.js +2 -2
- package/dist/cli/auth-cli.impl.js +3 -3
- package/dist/cli/auth-cli.js +3 -3
- package/dist/cli/blueprint-command.code.js +1 -1
- package/dist/cli/blueprint-command.impl.js +3 -3
- package/dist/cli/blueprint-command.js +3 -3
- package/dist/cli/intercom-command.code.js +2 -2
- 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 +1 -1
- 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 +1 -1
- package/dist/cli/team-command.impl.js +3 -3
- package/dist/cli/team-command.js +3 -3
- package/dist/cli.js +2 -2
- 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 +1 -1
- 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.impl.js +3 -3
- package/dist/core/package-manager-storage-adapters.js +3 -3
- package/dist/core/process-start-token.d.ts +5 -4
- package/dist/core/sdk.code.js +2 -2
- package/dist/core/sdk.impl.js +3 -3
- package/dist/core/sdk.js +3 -3
- package/dist/core/session-manager-core.js +4 -4
- 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.impl.js +3 -3
- package/dist/core/session-storage.js +3 -3
- package/dist/core/storage/database.d.ts +6 -0
- package/dist/core/storage/database.js.map +1 -1
- package/dist/core/storage/fenced-paths.d.ts +7 -6
- package/dist/core/storage/fenced-paths.js +7 -6
- package/dist/core/storage/fenced-paths.js.map +1 -1
- package/dist/core/storage/index.js +2 -2
- package/dist/core/storage/node-sqlite-thread.js +209 -19
- package/dist/core/storage/node-sqlite-thread.js.map +1 -1
- package/dist/core/storage/node-sqlite.js +435 -71
- 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/provider.js +2 -2
- package/dist/core/storage/schema-catalog.d.ts +69 -7
- package/dist/core/storage/schema-catalog.js +352 -61
- package/dist/core/storage/schema-catalog.js.map +1 -1
- package/dist/core/storage/selection.js +2 -2
- 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 +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 +41 -23
- 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 +8 -8
- 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 +9 -1
- 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.d.ts +51 -7
- 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 +6 -0
- package/dist/core/storage/sqlite-facade.js +309 -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.impl.js +3 -3
- package/dist/core/storage/storage-status.js +3 -3
- package/dist/core/storage/team.impl.js +3 -3
- package/dist/core/storage/team.js +3 -3
- 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 +3 -3
- 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.impl.js +3 -3
- package/dist/core/tasks/task-view-source.js +3 -3
- package/dist/core/tools/read-url.code.js +2 -2
- 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 +5 -3
- package/dist/core/worktree-snapshot/blob-store.js +151 -21
- 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-snapshot-index.js +158 -41
- package/dist/core/worktree-snapshot/fork-snapshot-index.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 +1 -1
- package/dist/extensions/codemode/renderer.impl.js +3 -3
- package/dist/extensions/codemode/renderer.js +3 -3
- package/dist/extensions/mcp/cli.code.js +1 -1
- 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.impl.js +3 -3
- package/dist/extensions/mcp/runtime.js +3 -3
- package/dist/index.js +2 -2
- 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/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/package-manager-cli.code.js +4 -4
- 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/3.js +1 -1
- package/dist/startup-stages/5.js +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/docs/changelog.mdx +77 -0
- package/docs/storage/jsonl.md +3 -3
- package/package.json +8 -8
- package/dist/_shared/startup-0-1-RTOHJFDJ.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-facade.js","sourceRoot":"","sources":["../../../src/core/storage/sqlite-facade.ts"],"names":[],"mappings":"AAaA,OAAO,EAA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MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACpF,CAAC","sourcesContent":["import type {\n\tSqliteBatchOptions,\n\tSqliteDatabase,\n\tSqliteExecutor,\n\tSqliteRow,\n\tSqliteStatement,\n\tSqliteTransactionOptions,\n\tSqliteValue,\n\tStorageDescriptor,\n\tStorageNotifications,\n\tStorageOpenedCatalog,\n\tTransactionConcurrency,\n} from \"./database.js\";\nimport { type StorageDialect, sqliteDialect } from \"./dialect.js\";\nimport {\n\tlargestValueBytes,\n\tpayloadTooLargeKind,\n\tStorageConfigError,\n\tStorageError,\n\ttype StorageFailureCause,\n\tStorageInvalidTextError,\n\ttype StoragePayloadLimits,\n\tStoragePayloadTooLargeError,\n\tStorageRollbackError,\n\tStorageTransactionClosedError,\n\tStorageTransientError,\n\ttype StorageTransientErrorCode,\n\ttype StorageTransientHop,\n\ttype StorageTransientOutcome,\n\tStorageUnavailableError,\n\tStoreClosedError,\n} from \"./errors.js\";\nimport {\n\tMAX_SEQUENCE_REQUEST_STATEMENTS,\n\tofferFinish,\n\tofferSequences,\n\ttype SqliteSequence,\n} from \"./statement-sequence.js\";\n\ntype Awaitable<T> = T | Promise<T>;\n\n/** A value as a driver returns it. Blobs may be any binary view; the facade returns them as `Uint8Array` copies. */\nexport type SqliteDriverValue = SqliteValue | ArrayBuffer | ArrayBufferView;\n\n/** One statement's result as a driver returns it: column names, positional rows, and the rows it changed. */\nexport interface SqliteDriverResult {\n\treadonly columns: readonly string[];\n\treadonly rows: readonly ArrayLike<SqliteDriverValue>[];\n\treadonly changes: number;\n}\n\n/** Runs SQL on a driver connection or on an open driver transaction. */\nexport interface SqliteDriverExecutor {\n\t/** Runs one statement with positional `?` parameters. */\n\texecute(sql: string, params: readonly SqliteValue[]): Awaitable<SqliteDriverResult>;\n\t/** Runs zero or more statements that take no parameters. */\n\texecuteMultiple(sql: string): Awaitable<void>;\n}\n\nexport interface SqliteDriverTransaction extends SqliteDriverExecutor {\n\tcommit(): Awaitable<void>;\n\trollback(): Awaitable<void>;\n\t/** Releases the transaction after it commits or rolls back. */\n\tclose?(): Awaitable<void>;\n}\n\n/** A driver failure that passes, as `SqliteDriver.transientFailure` recognizes it. */\nexport interface SqliteDriverTransientFailure {\n\treadonly code: StorageTransientErrorCode;\n\t/**\n\t * `\"not-applied\"` when the failed request cannot have changed the database, `\"unknown\"` when the connection broke\n\t * after the server may have applied it.\n\t */\n\treadonly outcome: StorageTransientOutcome;\n\t/**\n\t * Optional. Where on the way to the server the call failed, when it did not reach the server, such as at a proxy:\n\t * `StorageTransientError` then names this hop where it would name the database server. The facade passes both texts\n\t * through `redact`.\n\t */\n\treadonly hop?: StorageTransientHop;\n}\n\n/** How the facade asks a driver to begin a transaction. */\nexport interface SqliteDriverTransactionOptions {\n\t/** @internal A consistent read snapshot without acquiring the database's writer lock. */\n\treadonly readOnly?: boolean;\n\t/** Always present when the facade calls; `{ kind: \"serial\" }` unless the transaction asked for another. */\n\treadonly concurrency: TransactionConcurrency;\n\t/** The transaction's `SqliteTransactionOptions.lockWaitMs`, when it set one. */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Optional. `SqliteTransactionOptions.leading`, with parameters snapshotted and none holding NUL: a driver with\n\t * `pipelinedTransactions` may send them with the begin and answer the transaction's first calls that make them, in\n\t * order, from what it got. A call that differs from the next of them ends the lead.\n\t */\n\treadonly leading?: readonly SqliteStatement[];\n\t/**\n\t * Optional. `SqliteTransactionOptions.leadingOnly`, set only with every statement of `leading`: a driver with\n\t * `pipelinedTransactions` may send the commit right behind them, and then fails any other call without sending it.\n\t */\n\treadonly leadingOnly?: boolean;\n\t/**\n\t * Optional. `SqliteTransactionOptions.lockIfLeadingFinds`, set only with `leading` whose first statement is the\n\t * transaction's: a driver with `pipelinedTransactions` may take a `serial` domain's locks in that statement, for the\n\t * row it returns, instead of with the begin.\n\t */\n\treadonly lockIfLeadingFinds?: boolean;\n\t/**\n\t * Optional. `SqliteTransactionOptions.relaxedDurability`, never set on a read-only transaction: the driver may answer\n\t * the commit before the transaction reaches disk.\n\t */\n\treadonly relaxedDurability?: boolean;\n}\n\n/** The driver calls `createSqliteDatabase` turns into a `SqliteDatabase`. */\nexport interface SqliteDriver extends SqliteDriverExecutor {\n\t/** Diagnostic identity. Its `location` passes through `redact` before the facade exposes it. */\n\treadonly descriptor: StorageDescriptor;\n\t/** The SQL dialect the driver speaks; SQLite when absent. The facade exposes it as `SqliteDatabase.dialect`. */\n\treadonly dialect?: StorageDialect;\n\t/**\n\t * Optional. The driver runs transactions on connections of their own, concurrently with other calls: the facade then\n\t * starts `fenced` transactions without waiting for queued calls, and any other call once no earlier unfinished call\n\t * conflicts with it (`ScopeQueue`). Otherwise every call waits its turn.\n\t */\n\treadonly concurrentTransactions?: boolean;\n\t/**\n\t * Optional. The driver runs reads on connections or streams of their own, up to this many at once: the facade then\n\t * lets read-only transactions, and statements outside a transaction that `readsOnly` accepts, run beside each other,\n\t * while every other call still waits for each call before it, as without it, and a read waits for the writes queued\n\t * before it. A positive integer; anything else runs every call in turn. A driver with `concurrentTransactions` runs at\n\t * most this many reads at once when it sets it.\n\t */\n\treadonly concurrentReads?: number;\n\t/**\n\t * Optional. Whether `sql`, run outside a transaction, only reads: with `concurrentReads` or `concurrentTransactions`,\n\t * such a statement runs beside other reads. Answer true only for a statement that can never write.\n\t */\n\treadsOnly?(sql: string): boolean;\n\t/**\n\t * Optional. A transaction's connection takes a statement before the one before it is answered, and runs them in the\n\t * order it took them (a pipelined connection): the facade then sends each call of a transaction as it is made, so a\n\t * body that makes several calls without awaiting each sends them in one round trip, and the transaction runs\n\t * statement sequences (`sequenceRunner`) that way. Otherwise each call waits for the one before it to settle.\n\t */\n\treadonly pipelinedTransactions?: boolean;\n\t/**\n\t * Begins a write transaction. With `options.concurrency` `{ kind: \"serial\" }` (the default) it holds the write lock of the whole database\n\t * or of `concurrency.domain`, like `BEGIN IMMEDIATE`; with `fenced` it may take no lock, and the body locks its rows.\n\t * A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the concurrency argument. An internal `readOnly`\n\t * request instead opens a consistent read snapshot without any writer lock.\n\t */\n\tbeginTransaction(options?: SqliteDriverTransactionOptions): Awaitable<SqliteDriverTransaction>;\n\t/**\n\t * Optional. Runs the statements in order in one write transaction, in one request: all commit or none do. Provide it\n\t * only when the driver sends the whole batch at once; the facade then offers `SqliteDatabase.batch`. `options` are the\n\t * caller's, as `SqliteDatabase.batch` took them.\n\t */\n\tbatch?(\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions?: SqliteBatchOptions,\n\t): Awaitable<readonly SqliteDriverResult[]>;\n\t/**\n\t * Optional. Opens a driver on this same database, on connections of its own, for reads: the facade offers it as\n\t * `SqliteDatabase.openReader`, with a call queue of its own, and closes it when this driver's database closes.\n\t */\n\topenReader?(): Awaitable<SqliteDriver>;\n\t/** Releases the connection. Called once, after accepted work drains. */\n\tclose(): Awaitable<void>;\n\t/** Removes credentials from diagnostic text: the descriptor location and driver failure messages and stacks. */\n\tredact?(text: string): string;\n\t/**\n\t * Optional. Recognizes a failed `batch` that found the database's write lock busy and wrote nothing: the facade sends\n\t * it again, after a randomized wait outside its call queue, for up to the caller's `lockWaitMs`. It receives the\n\t * failure the facade reports, whose `cause` chain holds the driver's own.\n\t */\n\tlockBusy?(failure: StorageFailureCause): boolean;\n\t/**\n\t * Optional. Recognizes a failure a driver call threw as one that passes, from the failure's own fields, before the\n\t * facade redacts it. The call then fails with `StorageTransientError`, and a call that wrote nothing runs again.\n\t */\n\ttransientFailure?(failure: StorageFailureCause): SqliteDriverTransientFailure | undefined;\n\t/**\n\t * Optional. The backend's payload limits in bytes, named in the `StoragePayloadTooLargeError` the facade throws when\n\t * a driver call fails because a value, row or response was too large for the backend (#4954).\n\t */\n\treadonly payloadLimits?: StoragePayloadLimits;\n\t/**\n\t * Optional. Wake-ups through the database, which the facade exposes as `SqliteDatabase.notifications`; the driver's\n\t * `close` stops its listening connection.\n\t */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * Optional. The bytes this process may still write on the file system that holds the database's file, or undefined\n\t * when the file system does not say; the facade exposes it as `SqliteDatabase.freeBytes`. Provide it only for a\n\t * database in a file this process can see, such as a local SQLite file.\n\t */\n\tfreeBytes?(): Awaitable<number | undefined>;\n\t/**\n\t * @internal Optional. Which database the driver reaches, which the facade exposes as\n\t * `SqliteDatabase.databaseIdentity`: the same string from two drivers only when each one's transactions read and write\n\t * the very tables the other's do. Undefined where that cannot be told, as for a database in memory.\n\t */\n\tdatabaseIdentity?(): string | undefined;\n\t/**\n\t * Optional. The schema the driver read in its open's own round trip, given once; the facade exposes it as\n\t * `SqliteDatabase.takeOpenedCatalog`, so the first store open does not read it again (#6560).\n\t */\n\ttakeOpenedCatalog?(): StorageOpenedCatalog | undefined;\n}\n\n/**\n * How many times the facade runs a call that a transient failure ended before it wrote anything, the first run\n * included. A transaction runs again only when its options allow it (`retryTransientFailures`).\n */\nexport const STORAGE_TRANSIENT_RETRY_ATTEMPTS = 5;\n/** The wait before the second run, in milliseconds; each later wait is twice as long as the one before. */\nconst STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS = 250;\n/** Each wait varies by up to this fraction either way, so processes that failed together do not retry together. */\nconst STORAGE_TRANSIENT_RETRY_JITTER = 0.2;\n/** The first bound on the wait before a batch that found the write lock busy is sent again; each later one doubles. */\nconst BUSY_RETRY_BASE_MS = 20;\n/** The largest bound on that wait. */\nconst BUSY_RETRY_MAX_MS = 1000;\n\n/**\n * How long the running call may run before the calls queued behind it fail without running (#5114). The facade\n * runs one call at a time, so a call that cannot complete, such as one waiting on a write lock a server keeps for a\n * stream an outage cut, would otherwise hold every call queued behind it, priority calls such as a worker host's\n * heartbeat included. A call queued behind it fails with `StorageUnavailableError` instead, having written nothing,\n * and its caller retries it as it retries any outage.\n */\nexport const STORAGE_QUEUED_CALL_MAX_WAIT_MS = 60_000;\n/**\n * The same bound for a priority call, such as a worker host's heartbeat or a work lease renewal: a third of the 30 s a\n * host's or a work lease's last write keeps it live (`FLEET_HOST_LIVE_MS`), so a priority call stuck behind a call that\n * cannot complete fails, and its caller tries it again, while the lease it renews still holds.\n */\nexport const STORAGE_PRIORITY_CALL_MAX_WAIT_MS = 10_000;\n\n/** How long the facade waits after the failed run `attempt` (1-based) before it runs the call again. */\nfunction transientRetryDelayMs(attempt: number): number {\n\tconst jitter = 1 + STORAGE_TRANSIENT_RETRY_JITTER * (2 * Math.random() - 1);\n\treturn Math.round(STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * jitter);\n}\n\n/** One run of a call: which run it is, and the first transient failure it met. */\ninterface Attempt {\n\treadonly number: number;\n\ttransient?: StorageTransientError;\n\t/**\n\t * Set once the transaction's commit was sent: a statement answered after it may have been committed with it when the\n\t * connection broke, so its failure keeps the outcome the driver gives it.\n\t */\n\tcommitting?: boolean;\n}\n\nconst REDACTED = \"[redacted]\";\n\n/** How {@link configuredSecretRedactor} matches the secrets it is given. */\nexport interface ConfiguredSecretRedactorOptions {\n\t/** Forms of a secret shorter than this are not redacted where they appear: they would match ordinary words. */\n\treadonly minLength?: number;\n}\n\n/**\n * Fewest characters of a form derived from a secret (a line of it, or an encoding) that is redacted, so short pieces\n * of a secret do not match ordinary text. A secret itself is redacted at any length its caller allows.\n */\nconst MIN_DERIVED_LENGTH = 6;\n/** Fewest base64 characters of a secret's encoding that are redacted, so short secrets do not match random base64. */\nconst MIN_BASE64_LENGTH = 7;\n\n/**\n * The base64 runs that appear wherever `secret`'s bytes are encoded, in standard and URL-safe alphabets: for each of\n * the three alignments of its first byte in a 3-byte group, the characters that only its bits decide.\n */\nfunction base64Forms(secret: string): string[] {\n\tconst bytes = Buffer.from(secret);\n\tconst forms: string[] = [];\n\tfor (let offset = 0; offset < 3; offset++) {\n\t\tconst encoded = Buffer.concat([Buffer.alloc(offset), bytes, Buffer.alloc(2)]).toString(\"base64\");\n\t\tconst form = encoded.slice(Math.ceil((8 * offset) / 6), Math.floor((8 * (offset + bytes.length)) / 6));\n\t\tif (form.length >= MIN_BASE64_LENGTH) forms.push(form, form.replaceAll(\"+\", \"-\").replaceAll(\"/\", \"_\"));\n\t}\n\treturn forms;\n}\n\n/** The JSON-escaped, URI-encoded, URI-decoded and base64 forms of `plain`. */\nfunction encodedForms(plain: string): string[] {\n\tconst forms = [JSON.stringify(plain).slice(1, -1), ...base64Forms(plain)];\n\ttry {\n\t\tforms.push(encodeURIComponent(plain));\n\t} catch {}\n\ttry {\n\t\tforms.push(decodeURIComponent(plain));\n\t} catch {}\n\treturn forms;\n}\n\n/** A line of a multi-line secret that many secrets share, such as a PEM armor line (`-----BEGIN … KEY-----`). */\nconst GENERIC_LINE = /^-----[A-Z0-9 ]+-----$|^[A-Za-z-]+: /u;\n\n/**\n * The forms a configured secret takes in output: trimmed, since a secret read from a file often ends with a line break\n * that the text around a printed secret need not repeat; each line of a multi-line secret, trimmed, that holds a letter\n * or digit and is not a line many secrets share (a PEM armor or header line); and the encodings of both. The secret as given holds its trimmed form, so overlapping matches still remove\n * it whole. Forms derived from the secret are kept only from {@link MIN_DERIVED_LENGTH} characters.\n */\nfunction secretForms(secret: string, minLength: number): string[] {\n\tconst trimmed = secret.trim();\n\tif (trimmed.length < Math.max(1, minLength)) return [];\n\tconst derivedLength = Math.max(minLength, MIN_DERIVED_LENGTH);\n\tconst lines = trimmed.includes(\"\\n\")\n\t\t? trimmed\n\t\t\t\t.split(/\\r?\\n/u)\n\t\t\t\t.map((line) => line.trim())\n\t\t\t\t.filter((line) => /[\\p{L}\\p{N}]/u.test(line) && !GENERIC_LINE.test(line))\n\t\t: [];\n\tconst derived = [...lines, ...[trimmed, ...lines].flatMap(encodedForms)];\n\treturn [trimmed, ...derived.filter((form) => form.length >= derivedLength)];\n}\n\n/** Every occurrence of each of `forms` in `text`, overlapping ones merged, as `[start, end)` ranges in order. */\nfunction secretRanges(text: string, forms: readonly string[]): [number, number][] {\n\tconst found: [number, number][] = [];\n\tfor (const form of forms) {\n\t\tfor (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) found.push([at, at + form.length]);\n\t}\n\tfound.sort((first, second) => first[0] - second[0]);\n\tconst merged: [number, number][] = [];\n\tfor (const [start, end] of found) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && start < last[1]) last[1] = Math.max(last[1], end);\n\t\telse merged.push([start, end]);\n\t}\n\treturn merged;\n}\n\n/**\n * A redactor that replaces each configured secret with `[redacted]`: its plain, trimmed and per-line forms, and their\n * JSON-escaped, URI-encoded, URI-decoded and base64 forms. Occurrences that overlap, such as two secrets that share\n * characters, are replaced together, so no part of either survives, and text around them is left as it is. A\n * `[redacted]` marker already in the text is kept as it is, so redacting twice changes nothing.\n */\nexport function configuredSecretRedactor(\n\tsecrets: Iterable<string>,\n\toptions: ConfiguredSecretRedactorOptions = {},\n): (text: string) => string {\n\tconst forms = new Set<string>();\n\tfor (const secret of secrets) for (const form of secretForms(secret, options.minLength ?? 1)) forms.add(form);\n\tconst ordered = [...forms];\n\treturn (text) =>\n\t\ttext\n\t\t\t.split(REDACTED)\n\t\t\t.map((piece) => {\n\t\t\t\tlet redacted = \"\";\n\t\t\t\tlet copied = 0;\n\t\t\t\tfor (const [start, end] of secretRanges(piece, ordered)) {\n\t\t\t\t\tredacted += piece.slice(copied, start) + REDACTED;\n\t\t\t\t\tcopied = end;\n\t\t\t\t}\n\t\t\t\treturn redacted + piece.slice(copied);\n\t\t\t})\n\t\t\t.join(REDACTED);\n}\n\n/**\n * A redactor that replaces every non-empty secret, and its trimmed, per-line, URI-encoded, URI-decoded, JSON-escaped\n * and base64 forms, with `[redacted]`. Occurrences that overlap are replaced together, so a secret that contains or\n * shares characters with another is removed whole. A `[redacted]` marker already in the text is kept as it is, so\n * redacting twice changes nothing, even for a secret that is part of the marker.\n */\nexport function redactSecrets(secrets: Iterable<string>): (text: string) => string {\n\treturn configuredSecretRedactor(secrets);\n}\n\nfunction redactCause(cause: StorageFailureCause, redact: (text: string) => string): StorageFailureCause {\n\tif (typeof cause === \"string\") return redact(cause);\n\tif (!(cause instanceof Error)) return cause;\n\tconst nested = cause.cause as StorageFailureCause;\n\tconst safeCause = redactCause(nested, redact);\n\tconst message = redact(cause.message);\n\tconst stack = cause.stack === undefined ? undefined : redact(cause.stack);\n\tif (message === cause.message && stack === cause.stack && safeCause === nested) return cause;\n\tconst safe = new StorageError(message, { cause: safeCause });\n\tsafe.stack = stack;\n\t// The code names the failure, such as a TLS error's, and holds no credential.\n\tconst code = (cause as { readonly code?: string | number }).code;\n\tif (typeof code === \"string\") Object.assign(safe, { code });\n\treturn safe;\n}\n\nfunction snapshotParams(params: readonly SqliteValue[]): SqliteValue[] {\n\treturn params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));\n}\n\nfunction normalizeValue(value: SqliteDriverValue): SqliteValue {\n\tif (typeof value === \"bigint\") {\n\t\treturn value >= -BigInt(Number.MAX_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? Number(value)\n\t\t\t: value;\n\t}\n\tif (value instanceof ArrayBuffer) return new Uint8Array(value.slice(0));\n\tif (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();\n\treturn value;\n}\n\nfunction normalizeRow(row: ArrayLike<SqliteDriverValue>, columns: readonly string[]): SqliteRow {\n\treturn Object.fromEntries(columns.map((column, index) => [column, normalizeValue(row[index] ?? null)]));\n}\n\n/** Rejects a `retryTransientFailures` that is not a boolean, before the transaction is queued. */\nfunction retriesTransientFailures(options: SqliteTransactionOptions | undefined): boolean {\n\tconst retry = options?.retryTransientFailures;\n\tif (retry !== undefined && typeof retry !== \"boolean\")\n\t\tthrow new StorageConfigError(\n\t\t\t\"sdk\",\n\t\t\t\"retryTransientFailures\",\n\t\t\t\"boolean-required\",\n\t\t\t\"Pass true or false, or omit it\",\n\t\t);\n\treturn retry === true;\n}\n\nconst SERIAL: TransactionConcurrency = Object.freeze({ kind: \"serial\" });\n\n/** Rejects a `concurrency` that is not one of the two kinds, before the transaction is queued. */\nfunction transactionConcurrency(options: SqliteTransactionOptions | undefined): TransactionConcurrency {\n\tconst concurrency = options?.concurrency;\n\tif (concurrency === undefined) return SERIAL;\n\tif (typeof concurrency !== \"object\" || concurrency === null) throw concurrencyConfigError();\n\tif (concurrency.kind === \"serial\" && (concurrency.domain === undefined || typeof concurrency.domain === \"string\"))\n\t\treturn concurrency;\n\tif (\n\t\tconcurrency.kind === \"fenced\" &&\n\t\ttypeof concurrency.audit === \"string\" &&\n\t\tconcurrency.audit !== \"\" &&\n\t\t(concurrency.excludesSerial === undefined || typeof concurrency.excludesSerial === \"boolean\")\n\t)\n\t\treturn concurrency;\n\tthrow concurrencyConfigError();\n}\n\nfunction concurrencyConfigError(): StorageConfigError {\n\treturn new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"concurrency\",\n\t\t\"kind-required\",\n\t\t'Pass { kind: \"serial\" }, { kind: \"serial\", domain }, or { kind: \"fenced\", audit: fencedPath(name) }, or omit it',\n\t);\n}\n\n/** Serializes operations in call order; a failed operation does not stop the ones queued after it. */\nclass CallQueue {\n\tprivate tail: Promise<void> = Promise.resolve();\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn this.tail;\n\t}\n}\n\n/** Starts each operation as it is pushed, so a pipelined connection receives them in push order without waiting. */\nclass PipelineQueue {\n\tprivate readonly started: Promise<unknown>[] = [];\n\n\tpush<T>(operation: () => Promise<T>): Promise<T> {\n\t\tconst result = operation();\n\t\tresult.catch(() => {});\n\t\t// A queue lasts one transaction, so it keeps every call it started.\n\t\tthis.started.push(result);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn Promise.allSettled(this.started).then(() => {});\n\t}\n\n\t/** The failure of the first call, in the order they were sent, that failed; undefined when none did. */\n\tfirstFailure(): Promise<unknown> {\n\t\treturn firstFailure(this.started);\n\t}\n}\n\ninterface QueuedCall {\n\trun(): Promise<void>;\n\tfail(error: Error): void;\n}\n\n/** A database's call queue: which call may start when, and whether any is unfinished. */\ninterface CallLanes {\n\tpush<T>(operation: () => Promise<T>, priority?: boolean, scope?: CallScope): Promise<T>;\n\tdrained(): Promise<void>;\n}\n\n/**\n * Runs operations one at a time, in call order within each lane: an operation of the priority lane runs before every\n * waiting operation of the normal lane. A failed operation does not stop the ones queued after it. Once the running\n * operation has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` without settling, every priority operation waiting behind it\n * fails with `stalled()` without running, and once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`, every other one does;\n * so does every one queued behind it after that. Each operation that starts gets full waits of its own, so a queue of\n * operations that each settle in time never fails one.\n */\nclass LaneQueue {\n\tprivate readonly normal: QueuedCall[] = [];\n\tprivate readonly priority: QueuedCall[] = [];\n\tprivate running = false;\n\t/** When the running operation started, as `Date.now()`. */\n\tprivate runningSince = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** The bound the planned check enforces, or undefined when none is planned. */\n\tprivate watchdogBound?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error) {\n\t\tthis.stalled = stalled;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\t(priority ? this.priority : this.normal).push({\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t});\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (!this.running && this.normal.length === 0 && this.priority.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\tprivate next(): void {\n\t\tif (this.running) return;\n\t\tconst operation = this.priority.shift() ?? this.normal.shift();\n\t\tif (operation === undefined) {\n\t\t\tconst idle = this.idle;\n\t\t\tthis.idle = [];\n\t\t\tfor (const resolve of idle) resolve();\n\t\t\treturn;\n\t\t}\n\t\tthis.running = true;\n\t\tthis.runningSince = Date.now();\n\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\tvoid operation.run().finally(() => {\n\t\t\tclearTimeout(this.watchdog);\n\t\t\tthis.watchdog = undefined;\n\t\t\tthis.watchdogBound = undefined;\n\t\t\tthis.running = false;\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\t/**\n\t * While operations wait behind a running one, fails the priority ones once that one has run\n\t * `STORAGE_PRIORITY_CALL_MAX_WAIT_MS`, and the others once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`. No timer\n\t * runs while nothing waits.\n\t */\n\tprivate watch(): void {\n\t\tconst bound =\n\t\t\tthis.priority.length > 0\n\t\t\t\t? STORAGE_PRIORITY_CALL_MAX_WAIT_MS\n\t\t\t\t: this.normal.length > 0\n\t\t\t\t\t? STORAGE_QUEUED_CALL_MAX_WAIT_MS\n\t\t\t\t\t: undefined;\n\t\t// A priority call queued behind ordinary ones brings the planned check forward to its own, shorter bound.\n\t\tif (bound === this.watchdogBound) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogBound = bound;\n\t\tif (bound === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogBound = undefined;\n\t\t\t\tconst ran = Date.now() - this.runningSince;\n\t\t\t\tconst failing = this.priority.splice(0);\n\t\t\t\tif (ran >= STORAGE_QUEUED_CALL_MAX_WAIT_MS) failing.push(...this.normal.splice(0));\n\t\t\t\tfor (const waiting of failing) waiting.fail(this.stalled(ran));\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, this.runningSince + bound - Date.now()),\n\t\t);\n\t\t// A stuck operation ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\n/**\n * What a call of a driver that runs transactions concurrently may run beside: `whole`, a serial transaction without a\n * domain, and `plain`, a statement or batch outside a transaction, run beside nothing; `domain`, a serial transaction\n * of one domain, beside calls of other domains and read-only transactions; `read`, a read-only transaction, beside\n * other read-only ones and the writes queued after it.\n */\ntype CallScope =\n\t| { readonly kind: \"whole\" }\n\t| { readonly kind: \"plain\" }\n\t| { readonly kind: \"read\" }\n\t| { readonly kind: \"domain\"; readonly domain: string };\n\nconst WHOLE_SCOPE: CallScope = Object.freeze({ kind: \"whole\" });\nconst PLAIN_SCOPE: CallScope = Object.freeze({ kind: \"plain\" });\nconst READ_SCOPE: CallScope = Object.freeze({ kind: \"read\" });\n\n/**\n * Whether `later` must wait for `earlier`, a call queued before it. A read-only transaction waits for the writes queued\n * before it, so it sees them, but a write queued after a read-only transaction does not wait for it.\n */\nfunction scopesConflict(earlier: CallScope, later: CallScope): boolean {\n\tif (earlier.kind === \"whole\" || earlier.kind === \"plain\" || later.kind === \"whole\" || later.kind === \"plain\")\n\t\treturn true;\n\tif (later.kind === \"read\") return earlier.kind !== \"read\";\n\treturn earlier.kind === \"domain\" && earlier.domain === later.domain;\n}\n\ninterface ScopedCall extends QueuedCall {\n\treadonly scope: CallScope;\n\treadonly priority: boolean;\n\t/** Call order within the call's lane. */\n\treadonly seq: number;\n\t/** When the call was queued, on the queue's clock of admissions and starts. */\n\treadonly admitted: number;\n\t/** When the call started, on that clock; undefined while it waits. */\n\tstarted?: number;\n\t/** When the call started, as `Date.now()`. */\n\trunningSince: number;\n}\n\n/**\n * `LaneQueue` for a driver that runs transactions or reads concurrently: a call starts once no unfinished call ahead of\n * it conflicts with it (`scopesConflict`), so calls that conflict run one at a time in call order, and the others at\n * once, reads no more than `maxReads` at a time. A priority call is ahead of every waiting call of the normal lane,\n * as there. A waiting call fails with `stalled()` once a conflicting call ahead of it, or one such a call waits for,\n * has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` (a priority call) or `STORAGE_QUEUED_CALL_MAX_WAIT_MS` without\n * settling; a read waiting for a free place waits for the reads running then.\n */\nclass ScopeQueue {\n\t/** Unfinished calls: priority ones first, then the normal lane's, each in call order. */\n\tprivate readonly calls: ScopedCall[] = [];\n\t/** How many calls of the read scope run at once at most. */\n\tprivate readonly maxReads: number;\n\tprivate seq = 0;\n\tprivate clock = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** When the planned check runs, as `Date.now()`, or undefined when none is planned. */\n\tprivate watchdogAt?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error, maxReads = Number.POSITIVE_INFINITY) {\n\t\tthis.stalled = stalled;\n\t\tthis.maxReads = maxReads;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false, scope: CallScope = PLAIN_SCOPE): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tconst call: ScopedCall = {\n\t\t\t\tscope,\n\t\t\t\tpriority,\n\t\t\t\tseq: this.seq++,\n\t\t\t\tadmitted: this.clock++,\n\t\t\t\trunningSince: 0,\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t};\n\t\t\tconst firstNormal = this.calls.findIndex((queued) => !queued.priority);\n\t\t\tif (priority && firstNormal !== -1) this.calls.splice(firstNormal, 0, call);\n\t\t\telse this.calls.push(call);\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (this.calls.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\t/** Whether `call`, still waiting, must wait for `other`. */\n\tprivate waitsFor(call: ScopedCall, other: ScopedCall): boolean {\n\t\tif (other === call) return false;\n\t\t// A read waits for a running read while as many as `maxReads` run.\n\t\tif (call.scope.kind === \"read\" && other.scope.kind === \"read\" && other.started !== undefined)\n\t\t\treturn call.started === undefined && this.runningReads() >= this.maxReads;\n\t\tif (!scopesConflict(other.scope, call.scope)) return false;\n\t\tif (other.priority === call.priority) return other.seq < call.seq;\n\t\t// A priority call goes ahead of the normal lane's waiting calls, not of those already running when it came.\n\t\treturn other.priority || (other.started !== undefined && other.started < call.admitted);\n\t}\n\n\tprivate runningReads(): number {\n\t\tlet running = 0;\n\t\tfor (const call of this.calls) if (call.scope.kind === \"read\" && call.started !== undefined) running++;\n\t\treturn running;\n\t}\n\n\tprivate next(): void {\n\t\tfor (const call of this.calls) {\n\t\t\tif (call.started !== undefined || this.calls.some((other) => this.waitsFor(call, other))) continue;\n\t\t\tcall.started = this.clock++;\n\t\t\tcall.runningSince = Date.now();\n\t\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\t\tvoid call.run().finally(() => {\n\t\t\t\tthis.calls.splice(this.calls.indexOf(call), 1);\n\t\t\t\tthis.next();\n\t\t\t\tthis.watch();\n\t\t\t});\n\t\t}\n\t\tif (this.calls.length > 0) return;\n\t\tconst idle = this.idle;\n\t\tthis.idle = [];\n\t\tfor (const resolve of idle) resolve();\n\t}\n\n\t/** Each waiting call with when the earliest running call it waits for, directly or through others, started. */\n\tprivate stuck(): Map<ScopedCall, number> {\n\t\tconst since = new Map<ScopedCall, number>();\n\t\tfor (const call of this.calls) {\n\t\t\tif (call.started !== undefined) continue;\n\t\t\tlet earliest = Number.POSITIVE_INFINITY;\n\t\t\tfor (const other of this.calls) {\n\t\t\t\tif (!this.waitsFor(call, other)) continue;\n\t\t\t\tearliest = Math.min(\n\t\t\t\t\tearliest,\n\t\t\t\t\tother.started === undefined ? (since.get(other) ?? earliest) : other.runningSince,\n\t\t\t\t);\n\t\t\t}\n\t\t\tsince.set(call, earliest);\n\t\t}\n\t\treturn since;\n\t}\n\n\tprivate static bound(call: ScopedCall): number {\n\t\treturn call.priority ? STORAGE_PRIORITY_CALL_MAX_WAIT_MS : STORAGE_QUEUED_CALL_MAX_WAIT_MS;\n\t}\n\n\t/** Plans the check that fails the waiting calls whose wait passed its bound. No timer runs while nothing waits. */\n\tprivate watch(): void {\n\t\tlet at: number | undefined;\n\t\tfor (const [call, since] of this.stuck())\n\t\t\tif (Number.isFinite(since)) at = Math.min(at ?? Number.POSITIVE_INFINITY, since + ScopeQueue.bound(call));\n\t\tif (at === this.watchdogAt) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogAt = at;\n\t\tif (at === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogAt = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst failing: [ScopedCall, number][] = [];\n\t\t\t\tfor (const [call, since] of this.stuck())\n\t\t\t\t\tif (now - since >= ScopeQueue.bound(call)) failing.push([call, now - since]);\n\t\t\t\tfor (const [call] of failing) this.calls.splice(this.calls.indexOf(call), 1);\n\t\t\t\tfor (const [call, ran] of failing) call.fail(this.stalled(ran));\n\t\t\t\tthis.next();\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, at - Date.now()),\n\t\t);\n\t\t// A stuck call ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\n/** How many reads `driver` runs at once, when it runs any beside each other (`SqliteDriver.concurrentReads`). */\nfunction concurrentReads(driver: SqliteDriver): number | undefined {\n\tconst reads = driver.concurrentReads;\n\treturn typeof reads === \"number\" && Number.isInteger(reads) && reads > 0 ? reads : undefined;\n}\n\n/**\n * The scope a transaction runs in on a driver that runs transactions or reads concurrently: a write transaction keeps\n * its domain only on a driver that runs writes concurrently (`concurrentTransactions`), and runs alone otherwise.\n */\nfunction transactionScope(\n\tconcurrency: TransactionConcurrency,\n\treadOnly: boolean,\n\tconcurrentWrites: boolean,\n): CallScope {\n\tif (readOnly) return READ_SCOPE;\n\tif (concurrentWrites && concurrency.kind === \"serial\" && concurrency.domain !== undefined)\n\t\treturn { kind: \"domain\", domain: concurrency.domain };\n\treturn WHOLE_SCOPE;\n}\n\nfunction hasInvalidText(statement: SqliteStatement): boolean {\n\treturn statement.params.some((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n}\n\n/** The failure of the first of `calls` that failed, in their order, once all settled; undefined when none did. */\nasync function firstFailure(calls: readonly Promise<unknown>[]): Promise<unknown> {\n\tfor (const outcome of await Promise.allSettled(calls)) if (outcome.status === \"rejected\") return outcome.reason;\n\treturn undefined;\n}\n\n/** `leading` with parameters snapshotted, up to the first statement that holds NUL, which the facade refuses to send. */\nfunction leadingStatements(leading: readonly SqliteStatement[] | undefined): readonly SqliteStatement[] {\n\tconst sent: SqliteStatement[] = [];\n\tfor (const statement of leading ?? []) {\n\t\tif (hasInvalidText(statement)) break;\n\t\tsent.push({ sql: statement.sql, params: snapshotParams(statement.params) });\n\t}\n\treturn sent;\n}\n\n/**\n * Runs `sequence` on a transaction of a pipelined connection: `repeat` one run at a time, since each run's changes\n * decide the next, then the statements a request's worth at a time, each request sent whole before any answer comes.\n * A statement sent behind one that failed fails too, or runs in a transaction that can no longer commit, so the\n * first failure in order is the sequence's, as when each waited for the one before. Nothing is sent after a statement\n * whose text holds NUL, which fails as `run` fails it.\n */\nasync function pipelineSequence(\n\thandle: SqliteExecutor,\n\t{ repeat, statements, signal }: SqliteSequence,\n): Promise<number> {\n\tlet repeated = 0;\n\tif (repeat !== undefined) {\n\t\tfor (let done = 0; done < repeat.times; done++) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst { changes } = await handle.run(repeat.statement.sql, ...repeat.statement.params);\n\t\t\tif (changes < repeat.minChanges) break;\n\t\t\trepeated++;\n\t\t}\n\t}\n\tconst pending = statements[Symbol.iterator]();\n\tfor (let next = pending.next(); next.done !== true; ) {\n\t\tconst sent: Promise<unknown>[] = [];\n\t\tfor (; next.done !== true && sent.length < MAX_SEQUENCE_REQUEST_STATEMENTS; next = pending.next()) {\n\t\t\tif (signal?.aborted === true) break;\n\t\t\tconst statement = next.value;\n\t\t\tsent.push(\n\t\t\t\tstatement.script === true ? handle.exec(statement.sql) : handle.run(statement.sql, ...statement.params),\n\t\t\t);\n\t\t\t// `run` refuses it without sending it, so the sequence fails with that below.\n\t\t\tif (hasInvalidText(statement)) break;\n\t\t}\n\t\tconst outcomes = await Promise.allSettled(sent);\n\t\tconst failed = outcomes.find((outcome) => outcome.status === \"rejected\");\n\t\tif (failed !== undefined) throw failed.reason;\n\t\tsignal?.throwIfAborted();\n\t}\n\treturn repeated;\n}\n\nclass DriverDatabase implements SqliteDatabase {\n\treadonly descriptor: StorageDescriptor;\n\treadonly dialect: StorageDialect;\n\tprivate readonly driver: SqliteDriver;\n\t/** Fenced transactions a concurrent driver runs outside the queue; closing waits for them. */\n\tprivate readonly concurrent = new Set<Promise<unknown>>();\n\tprivate readonly redact: (text: string) => string;\n\tprivate readonly queue: CallLanes;\n\tprivate closePromise?: Promise<void>;\n\t/** End the waits before calls run again, when closing begins during them. */\n\tprivate readonly wakeRetries = new Set<() => void>();\n\tprivate retryReported = false;\n\tprivate readonly executor: SqliteExecutor;\n\treadonly batch?: (statements: readonly SqliteStatement[], options?: SqliteBatchOptions) => Promise<SqliteRow[][]>;\n\treadonly notifications?: StorageNotifications;\n\treadonly freeBytes?: () => Promise<number | undefined>;\n\treadonly databaseIdentity?: () => string | undefined;\n\treadonly openReader?: () => Promise<SqliteDatabase>;\n\treadonly takeOpenedCatalog?: () => StorageOpenedCatalog | undefined;\n\treadonly autocommit?: (statement: SqliteStatement, concurrency: TransactionConcurrency) => Promise<SqliteRow[]>;\n\t/** Readers this database opened and that are not closed; closing closes them. */\n\tprivate readonly readers = new Set<DriverDatabase>();\n\tprivate readonly closed?: () => void;\n\n\tconstructor(driver: SqliteDriver, redact: (text: string) => string, closed?: () => void) {\n\t\tthis.driver = driver;\n\t\tthis.closed = closed;\n\t\tconst openReader = driver.openReader?.bind(driver);\n\t\tif (openReader) this.openReader = () => this.startReader(openReader);\n\t\tif (driver.notifications !== undefined) this.notifications = driver.notifications;\n\t\tconst freeBytes = driver.freeBytes?.bind(driver);\n\t\tif (freeBytes) this.freeBytes = async () => freeBytes();\n\t\tconst databaseIdentity = driver.databaseIdentity?.bind(driver);\n\t\tif (databaseIdentity) this.databaseIdentity = databaseIdentity;\n\t\tconst takeOpenedCatalog = driver.takeOpenedCatalog?.bind(driver);\n\t\tif (takeOpenedCatalog) this.takeOpenedCatalog = takeOpenedCatalog;\n\t\tthis.redact = redact;\n\t\tthis.descriptor = { adapter: driver.descriptor.adapter, location: redact(driver.descriptor.location) };\n\t\tconst stalled = (ranMs: number) =>\n\t\t\tnew StorageUnavailableError(\n\t\t\t\tthis.descriptor,\n\t\t\t\tundefined,\n\t\t\t\t`the call was queued behind an earlier call that ran ${Math.round(ranMs / 1000)} seconds without settling, and did not run; nothing was written, retry it`,\n\t\t\t);\n\t\tconst maxReads = concurrentReads(driver);\n\t\tthis.queue =\n\t\t\tdriver.concurrentTransactions === true || maxReads !== undefined\n\t\t\t\t? new ScopeQueue(stalled, maxReads)\n\t\t\t\t: new LaneQueue(stalled);\n\t\tthis.dialect = driver.dialect ?? sqliteDialect;\n\t\tconst readsOnly = driver.readsOnly?.bind(driver);\n\t\tconst scopeOf =\n\t\t\treadsOnly !== undefined && (driver.concurrentTransactions === true || maxReads !== undefined)\n\t\t\t\t? (sql: string) => (readsOnly(sql) ? READ_SCOPE : PLAIN_SCOPE)\n\t\t\t\t: () => PLAIN_SCOPE;\n\t\tthis.executor = this.createExecutor(\n\t\t\tdriver,\n\t\t\t(operation, sql) => {\n\t\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t\t\treturn this.queue.push(\n\t\t\t\t\t() => this.retrying(operation, true),\n\t\t\t\t\tfalse,\n\t\t\t\t\tsql === undefined ? PLAIN_SCOPE : scopeOf(sql),\n\t\t\t\t);\n\t\t\t},\n\t\t\ttrue,\n\t\t);\n\t\tconst batch = driver.batch?.bind(driver);\n\t\tif (batch) this.batch = (statements, options) => this.runBatch(batch, statements, options);\n\t\tif (driver.concurrentTransactions === true)\n\t\t\tthis.autocommit = (statement, concurrency) => this.runAutocommit(statement, concurrency);\n\t}\n\n\t/** `autocommit`: the statement on its own, through the driver's `execute`, in the queue scope of `concurrency`. */\n\tprivate runAutocommit(statement: SqliteStatement, concurrency: TransactionConcurrency): Promise<SqliteRow[]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet scope: CallScope;\n\t\ttry {\n\t\t\tscope = transactionScope(transactionConcurrency({ concurrency }), false, true);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst bound = snapshotParams(statement.params);\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\tconst result = await this.call(() => this.driver.execute(statement.sql, bound), attempt, true, bound);\n\t\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns));\n\t\t\t\t}, true),\n\t\t\tfalse,\n\t\t\tscope,\n\t\t);\n\t}\n\n\tprivate runBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst bound = statements.map((statement) => ({ sql: statement.sql, params: snapshotParams(statement.params) }));\n\t\tconst passed = options === undefined ? undefined : { ...options };\n\t\tconst send = () => this.sendBatch(batch, bound, passed);\n\t\tconst lockWaitMs = passed?.lockWaitMs ?? 0;\n\t\tconst busy = this.driver.lockBusy?.bind(this.driver);\n\t\tif (lockWaitMs <= 0 || busy === undefined) return send();\n\t\treturn this.whileBusy(send, busy, performance.now() + lockWaitMs);\n\t}\n\n\t/**\n\t * Sends a batch again while it finds the write lock busy, until `deadline`. Each wait is random up to a bound that\n\t * doubles from `BUSY_RETRY_BASE_MS` to `BUSY_RETRY_MAX_MS` (\"full jitter\"), so writers that failed together do not\n\t * come back together. The waits happen outside the call queue, so calls queued meanwhile, a priority batch such as\n\t * a lease renewal included, run during them.\n\t */\n\tprivate async whileBusy<T>(\n\t\tsend: () => Promise<T>,\n\t\tbusy: (failure: StorageFailureCause) => boolean,\n\t\tdeadline: number,\n\t): Promise<T> {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await send();\n\t\t\t} catch (failure) {\n\t\t\t\tif (!busy(failure as StorageFailureCause) || performance.now() >= deadline || this.closePromise)\n\t\t\t\t\tthrow failure;\n\t\t\t}\n\t\t\tconst bound = Math.min(BUSY_RETRY_MAX_MS, BUSY_RETRY_BASE_MS * 2 ** Math.min(attempt, 16));\n\t\t\tawait new Promise((resolve) =>\n\t\t\t\tsetTimeout(resolve, Math.min(Math.random() * bound, deadline - performance.now())),\n\t\t\t);\n\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t}\n\t}\n\n\tprivate sendBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tbound: readonly SqliteStatement[],\n\t\tpassed: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tfor (const statement of bound) {\n\t\t\t\t\t\tconst invalidIndex = statement.params.findIndex(\n\t\t\t\t\t\t\t(value) => typeof value === \"string\" && value.includes(\"\\0\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconst results = await this.call(\n\t\t\t\t\t\t() => batch(bound, passed),\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tbound.flatMap((statement) => statement.params),\n\t\t\t\t\t);\n\t\t\t\t\treturn results.map((result) => result.rows.map((row) => normalizeRow(row, result.columns)));\n\t\t\t\t}, true),\n\t\t\tpassed?.priority === true,\n\t\t);\n\t}\n\n\t/**\n\t * Runs `operation` again while a transient failure ended its run before it wrote anything, waiting longer before\n\t * each run, and only when `replay` allows it. Gives up with the last run's failure after\n\t * `STORAGE_TRANSIENT_RETRY_ATTEMPTS` runs, or once closing begins.\n\t */\n\tprivate async retrying<T>(operation: (attempt: Attempt) => Promise<T>, replay: boolean): Promise<T> {\n\t\tfor (let number = 1; ; number++) {\n\t\t\tconst attempt: Attempt = { number };\n\t\t\ttry {\n\t\t\t\treturn await operation(attempt);\n\t\t\t} catch (failure) {\n\t\t\t\tconst transient = attempt.transient;\n\t\t\t\tif (!replay || transient?.outcome !== \"not-applied\" || !(await this.backoff(transient))) throw failure;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Waits before the run after `failure`'s, and says whether to run again: not after the last run, nor once closing\n\t * begins, which also ends a wait under way. The first transient failure that makes the database run a call again is\n\t * emitted as a process warning.\n\t */\n\tprivate async backoff(failure: StorageTransientError): Promise<boolean> {\n\t\tif (failure.attempts >= STORAGE_TRANSIENT_RETRY_ATTEMPTS || this.closePromise) return false;\n\t\tif (!this.retryReported) {\n\t\t\tthis.retryReported = true;\n\t\t\tprocess.emitWarning(failure);\n\t\t}\n\t\tlet wake: (() => void) | undefined;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timer = setTimeout(resolve, transientRetryDelayMs(failure.attempts));\n\t\t\twake = () => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.wakeRetries.add(wake);\n\t\t});\n\t\tif (wake) this.wakeRetries.delete(wake);\n\t\treturn this.closePromise === undefined;\n\t}\n\n\t/**\n\t * Maps a driver failure to `StorageUnavailableError` with a credential-free cause: a `StorageTransientError` when\n\t * the driver recognizes it and the call belongs to an `attempt`. `applies` says whether the call commits on its\n\t * own; a failed call inside an open transaction applied nothing, whatever the driver says of the request.\n\t */\n\tprivate async call<T>(\n\t\toperation: () => Awaitable<T>,\n\t\tattempt?: Attempt,\n\t\tapplies = false,\n\t\tparams: readonly SqliteValue[] = [],\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (cause) {\n\t\t\tconst safe = redactCause(cause as StorageFailureCause, this.redact);\n\t\t\t// A payload too large for the backend fails the same way every time: permanent, never an outage (#4954).\n\t\t\tconst kind = payloadTooLargeKind(cause as StorageFailureCause);\n\t\t\tif (kind !== undefined) {\n\t\t\t\tthrow new StoragePayloadTooLargeError(\n\t\t\t\t\tthis.driver.payloadLimits?.[kind] ?? 0,\n\t\t\t\t\tkind === \"value\" ? largestValueBytes(params) : 0,\n\t\t\t\t\t{ kind, descriptor: this.descriptor, cause: safe },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (attempt !== undefined) {\n\t\t\t\tconst transient = this.driver.transientFailure?.(cause as StorageFailureCause);\n\t\t\t\tif (transient !== undefined) {\n\t\t\t\t\tconst failure = new StorageTransientError(\n\t\t\t\t\t\tthis.descriptor,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: transient.code,\n\t\t\t\t\t\t\toutcome: applies || attempt.committing === true ? transient.outcome : \"not-applied\",\n\t\t\t\t\t\t\tattempts: attempt.number,\n\t\t\t\t\t\t\t...(transient.hop === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\thop: {\n\t\t\t\t\t\t\t\t\t\t\tname: this.redact(transient.hop.name),\n\t\t\t\t\t\t\t\t\t\t\tfailure: this.redact(transient.hop.failure),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsafe,\n\t\t\t\t\t);\n\t\t\t\t\tattempt.transient ??= failure;\n\t\t\t\t\tthrow failure;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new StorageUnavailableError(this.descriptor, safe);\n\t\t}\n\t}\n\n\tprivate createExecutor(\n\t\tconnection: SqliteDriverExecutor,\n\t\tadmit: <T>(operation: (attempt: Attempt) => Promise<T>, sql?: string) => Promise<T>,\n\t\tapplies: boolean,\n\t): SqliteExecutor {\n\t\tconst statement = (sql: string, params: readonly SqliteValue[]) => {\n\t\t\tconst bound = snapshotParams(params);\n\t\t\treturn admit(async (attempt) => {\n\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\treturn this.call(() => connection.execute(sql, bound), attempt, applies, bound);\n\t\t\t}, sql);\n\t\t};\n\t\treturn {\n\t\t\texec: (sql) => admit((attempt) => this.call(() => connection.executeMultiple(sql), attempt, applies)),\n\t\t\trun: async (sql, ...params) => ({ changes: (await statement(sql, params)).changes }),\n\t\t\tget: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\tconst row = result.rows[0];\n\t\t\t\treturn row === undefined ? undefined : (normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t\tall: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t};\n\t}\n\n\texec(sql: string): Promise<void> {\n\t\treturn this.executor.exec(sql);\n\t}\n\n\trun(sql: string, ...params: readonly SqliteValue[]) {\n\t\treturn this.executor.run(sql, ...params);\n\t}\n\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {\n\t\treturn this.executor.get<T>(sql, ...params);\n\t}\n\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {\n\t\treturn this.executor.all<T>(sql, ...params);\n\t}\n\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet replay: boolean;\n\t\tlet concurrency: TransactionConcurrency;\n\t\ttry {\n\t\t\treplay = retriesTransientFailures(options);\n\t\t\tconcurrency = transactionConcurrency(options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst leading = this.driver.pipelinedTransactions === true ? leadingStatements(options?.leading) : [];\n\t\tconst begin: SqliteDriverTransactionOptions = {\n\t\t\tconcurrency,\n\t\t\t...(options?.lockWaitMs === undefined ? {} : { lockWaitMs: options.lockWaitMs }),\n\t\t\t...(options?.readOnly === true ? { readOnly: true } : {}),\n\t\t\t...(leading.length === 0 ? {} : { leading }),\n\t\t\t// Only when the callback makes nothing but calls that went with the start: a statement the facade held back is one.\n\t\t\t...(options?.leadingOnly === true && leading.length > 0 && leading.length === options.leading?.length\n\t\t\t\t? { leadingOnly: true }\n\t\t\t\t: {}),\n\t\t\t// `leading` holds the first statement whenever it holds any.\n\t\t\t...(options?.lockIfLeadingFinds === true && leading.length > 0 ? { lockIfLeadingFinds: true } : {}),\n\t\t\t...(options?.relaxedDurability === true && options.readOnly !== true ? { relaxedDurability: true } : {}),\n\t\t};\n\t\tconst run = () => this.retrying((attempt) => this.runTransaction(callback, attempt, begin), replay);\n\t\tconst concurrentWrites = this.driver.concurrentTransactions === true;\n\t\tif (concurrency.kind === \"serial\" || !concurrentWrites)\n\t\t\treturn this.queue.push(\n\t\t\t\trun,\n\t\t\t\tfalse,\n\t\t\t\ttransactionScope(concurrency, options?.readOnly === true, concurrentWrites),\n\t\t\t);\n\t\tconst result = run();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn result;\n\t}\n\n\tprivate async runTransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\tattempt: Attempt,\n\t\tbegin: SqliteDriverTransactionOptions,\n\t): Promise<T> {\n\t\tconst connection = await this.call(() => this.driver.beginTransaction(begin), attempt);\n\t\tconst pipelined = this.driver.pipelinedTransactions === true;\n\t\tconst handleQueue = pipelined ? new PipelineQueue() : new CallQueue();\n\t\tlet active = true;\n\t\tlet result: T;\n\t\t/** Set once `finish` sent the callback's last calls: the transaction takes no more. */\n\t\tlet finished = false;\n\t\tconst handle = this.createExecutor(\n\t\t\tconnection,\n\t\t\t(operation) =>\n\t\t\t\tactive && !finished\n\t\t\t\t\t? handleQueue.push(() => operation(attempt))\n\t\t\t\t\t: Promise.reject(new StorageTransactionClosedError()),\n\t\t\tfalse,\n\t\t);\n\t\tif (pipelined) {\n\t\t\tofferSequences(handle, (sequence) => pipelineSequence(handle, sequence));\n\t\t\tofferFinish(handle, (statements) => {\n\t\t\t\tif (!active || finished) return false;\n\t\t\t\tif (statements.length > MAX_SEQUENCE_REQUEST_STATEMENTS || statements.some(hasInvalidText)) return false;\n\t\t\t\t// Their failures are the transaction's, reported once the commit is answered.\n\t\t\t\tfor (const statement of statements) {\n\t\t\t\t\tconst sent =\n\t\t\t\t\t\tstatement.script === true\n\t\t\t\t\t\t\t? handle.exec(statement.sql)\n\t\t\t\t\t\t\t: handle.run(statement.sql, ...statement.params);\n\t\t\t\t\tsent.catch(() => {});\n\t\t\t\t}\n\t\t\t\tfinished = true;\n\t\t\t\treturn true;\n\t\t\t});\n\t\t}\n\t\tconst close = () => this.call(() => connection.close?.());\n\t\t// Once the callback has returned, the commit's own failure decides whether the transaction runs again: a commit\n\t\t// that may have applied, or that failed for a reason the driver does not recognize, never does, whatever the\n\t\t// callback met before it. A committed transaction never runs again either.\n\t\tconst commit = () => {\n\t\t\tattempt.transient = undefined;\n\t\t\tattempt.committing = true;\n\t\t\treturn this.call(() => connection.commit(), attempt, true);\n\t\t};\n\t\tlet returned = false;\n\t\ttry {\n\t\t\tlet committing: Promise<void> | undefined;\n\t\t\ttry {\n\t\t\t\tresult = await callback(handle);\n\t\t\t\treturned = true;\n\t\t\t\t// A pipelined connection takes the commit behind statements the callback left unanswered, such as those sent by\n\t\t\t\t// `finish`, so locks they take are held for one round trip. The driver's commit fails when one of them failed,\n\t\t\t\t// so nothing commits then, and the first of them to fail is the failure. One that the server refused lets the\n\t\t\t\t// transaction run again, having written nothing; one whose connection broke may have committed, so it does not.\n\t\t\t\tif (pipelined) {\n\t\t\t\t\tcommitting = commit();\n\t\t\t\t\tcommitting.catch(() => {});\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tactive = false;\n\t\t\t\tawait handleQueue.drained();\n\t\t\t}\n\t\t\t// A read-only transaction on a connection of its own has its answer once its reads are answered: its commit only\n\t\t\t// ends the snapshot, so the connection goes back once the commit is answered, while the caller goes on.\n\t\t\tif (\n\t\t\t\tbegin.readOnly === true &&\n\t\t\t\t(this.driver.concurrentTransactions === true || concurrentReads(this.driver) !== undefined)\n\t\t\t) {\n\t\t\t\tthis.endInBackground(committing ?? commit(), connection, close);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tawait (committing ?? commit());\n\t\t} catch (cause) {\n\t\t\tlet failure = cause as StorageFailureCause;\n\t\t\t// A commit that came back as a rollback names no reason: the statement that failed is the transaction's failure,\n\t\t\t// and whether it may run again is that failure's, as when the callback awaited it.\n\t\t\tconst unanswered =\n\t\t\t\treturned && handleQueue instanceof PipelineQueue ? await handleQueue.firstFailure() : undefined;\n\t\t\tif (unanswered !== undefined) {\n\t\t\t\tfailure = unanswered as StorageFailureCause;\n\t\t\t\tif (unanswered instanceof StorageTransientError) attempt.transient = unanswered;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait this.call(() => connection.rollback());\n\t\t\t} catch (rollbackCause) {\n\t\t\t\tfailure = new StorageRollbackError(failure, rollbackCause as StorageFailureCause);\n\t\t\t}\n\t\t\t// Cleanup must not replace a callback, commit, or rollback failure.\n\t\t\tawait close().catch(() => {});\n\t\t\tthrow failure;\n\t\t}\n\t\tawait close();\n\t\treturn result;\n\t}\n\n\t/**\n\t * Ends a read-only transaction whose reads were all answered once `committing` settles: rolls it back when the commit\n\t * failed, then closes it. Closing the database waits for it.\n\t */\n\tprivate endInBackground(\n\t\tcommitting: Promise<void>,\n\t\tconnection: SqliteDriverTransaction,\n\t\tclose: () => Promise<void>,\n\t): void {\n\t\tconst ended = committing\n\t\t\t.catch(() => this.call(() => connection.rollback()).catch(() => {}))\n\t\t\t.then(close)\n\t\t\t.catch(() => {});\n\t\tthis.concurrent.add(ended);\n\t\tvoid ended.then(() => this.concurrent.delete(ended));\n\t}\n\n\tprivate startReader(openReader: () => Awaitable<SqliteDriver>): Promise<SqliteDatabase> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst opening = this.call(openReader).then((driver) => {\n\t\t\tconst reader: DriverDatabase = new DriverDatabase(driver, this.redact, () => this.readers.delete(reader));\n\t\t\tthis.readers.add(reader);\n\t\t\tif (this.closePromise) throw new StoreClosedError(this.descriptor);\n\t\t\treturn reader;\n\t\t});\n\t\tconst settled = opening.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn opening;\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst closeReaders = () => Promise.allSettled([...this.readers].map((reader) => reader.close()));\n\t\t// Readers stop taking calls now; one that finished opening meanwhile is closed after the drain.\n\t\tthis.closePromise ??= Promise.all([this.queue.drained(), ...this.concurrent, closeReaders()])\n\t\t\t.then(closeReaders)\n\t\t\t.then(() => this.call(() => this.driver.close()))\n\t\t\t.finally(() => this.closed?.());\n\t\tfor (const wake of this.wakeRetries) wake();\n\t\treturn this.closePromise;\n\t}\n}\n\n/**\n * Wraps a SQLite-compatible driver as a `SqliteDatabase`. The facade queues operations in call order and keeps them\n * outside active transactions (on a driver that runs transactions concurrently, only operations that conflict wait for\n * each other), snapshots binary parameters at call time, rejects NUL text, returns safe-range integers\n * as numbers and blobs as `Uint8Array` copies, expires transaction handles when their callback settles, maps driver\n * failures to `StorageUnavailableError` with credentials redacted, and reports failed rollbacks with\n * `StorageRollbackError`. A failure the driver recognizes as transient is a `StorageTransientError`; a statement, a\n * batch, or a transaction whose options allow it runs again, up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` times in all,\n * while such a failure ended it before it wrote anything. Closing rejects new calls, stops those retries, drains\n * accepted work, then closes the driver once.\n */\nexport function createSqliteDatabase(driver: SqliteDriver): SqliteDatabase {\n\treturn new DriverDatabase(driver, driver.redact?.bind(driver) ?? ((text) => text));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sqlite-facade.js","sourceRoot":"","sources":["../../../src/core/storage/sqlite-facade.ts"],"names":[],"mappings":"AAaA,OAAO,EAAuB,aAAa,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EACN,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,YAAY,EAEZ,uBAAuB,EAEvB,2BAA2B,EAC3B,oBAAoB,EACpB,6BAA6B,EAC7B,qBAAqB,EAIrB,uBAAuB,EACvB,gBAAgB,GAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,+BAA+B,EAC/B,WAAW,EACX,cAAc,GAEd,MAAM,yBAAyB,CAAC;AAoLjC;;;GAGG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAClD,2GAA2G;AAC3G,MAAM,qCAAqC,GAAG,GAAG,CAAC;AAClD,mHAAmH;AACnH,MAAM,8BAA8B,GAAG,GAAG,CAAC;AAC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tSqliteTransactionOptions,\n\tSqliteValue,\n\tStorageDescriptor,\n\tStorageNotifications,\n\tStorageOpenedCatalog,\n\tTransactionConcurrency,\n} from \"./database.js\";\nimport { type StorageDialect, sqliteDialect } from \"./dialect.js\";\nimport {\n\tlargestValueBytes,\n\tpayloadTooLargeKind,\n\tStorageConfigError,\n\tStorageError,\n\ttype StorageFailureCause,\n\tStorageInvalidTextError,\n\ttype StoragePayloadLimits,\n\tStoragePayloadTooLargeError,\n\tStorageRollbackError,\n\tStorageTransactionClosedError,\n\tStorageTransientError,\n\ttype StorageTransientErrorCode,\n\ttype StorageTransientHop,\n\ttype StorageTransientOutcome,\n\tStorageUnavailableError,\n\tStoreClosedError,\n} from \"./errors.js\";\nimport {\n\tMAX_SEQUENCE_REQUEST_STATEMENTS,\n\tofferFinish,\n\tofferSequences,\n\ttype SqliteSequence,\n} from \"./statement-sequence.js\";\n\ntype Awaitable<T> = T | Promise<T>;\n\n/** A value as a driver returns it. Blobs may be any binary view; the facade returns them as `Uint8Array` copies. */\nexport type SqliteDriverValue = SqliteValue | ArrayBuffer | ArrayBufferView;\n\n/** One statement's result as a driver returns it: column names, positional rows, and the rows it changed. */\nexport interface SqliteDriverResult {\n\treadonly columns: readonly string[];\n\treadonly rows: readonly ArrayLike<SqliteDriverValue>[];\n\treadonly changes: number;\n}\n\n/** Runs SQL on a driver connection or on an open driver transaction. */\nexport interface SqliteDriverExecutor {\n\t/** Runs one statement with positional `?` parameters. */\n\texecute(sql: string, params: readonly SqliteValue[]): Awaitable<SqliteDriverResult>;\n\t/** Runs zero or more statements that take no parameters. */\n\texecuteMultiple(sql: string): Awaitable<void>;\n}\n\nexport interface SqliteDriverTransaction extends SqliteDriverExecutor {\n\tcommit(): Awaitable<void>;\n\trollback(): Awaitable<void>;\n\t/** Releases the transaction after it commits or rolls back. */\n\tclose?(): Awaitable<void>;\n}\n\n/** A driver failure that passes, as `SqliteDriver.transientFailure` recognizes it. */\nexport interface SqliteDriverTransientFailure {\n\treadonly code: StorageTransientErrorCode;\n\t/**\n\t * `\"not-applied\"` when the failed request cannot have changed the database, `\"unknown\"` when the connection broke\n\t * after the server may have applied it.\n\t */\n\treadonly outcome: StorageTransientOutcome;\n\t/**\n\t * Optional. Where on the way to the server the call failed, when it did not reach the server, such as at a proxy:\n\t * `StorageTransientError` then names this hop where it would name the database server. The facade passes both texts\n\t * through `redact`.\n\t */\n\treadonly hop?: StorageTransientHop;\n}\n\n/** How the facade asks a driver to begin a transaction. */\nexport interface SqliteDriverTransactionOptions {\n\t/** @internal A consistent read snapshot without acquiring the database's writer lock. */\n\treadonly readOnly?: boolean;\n\t/** Always present when the facade calls; `{ kind: \"serial\" }` unless the transaction asked for another. */\n\treadonly concurrency: TransactionConcurrency;\n\t/** The transaction's `SqliteTransactionOptions.lockWaitMs`, when it set one. */\n\treadonly lockWaitMs?: number;\n\t/**\n\t * Optional. `SqliteTransactionOptions.leading`, with parameters snapshotted and none holding NUL: a driver with\n\t * `pipelinedTransactions` may send them with the begin and answer the transaction's first calls that make them, in\n\t * order, from what it got. A call that differs from the next of them ends the lead.\n\t */\n\treadonly leading?: readonly SqliteStatement[];\n\t/**\n\t * Optional. `SqliteTransactionOptions.leadingOnly`, set only with every statement of `leading`: a driver with\n\t * `pipelinedTransactions` may send the commit right behind them, and then fails any other call without sending it.\n\t * A driver that writes `COMMIT` before `commit()` must invoke `onCommit?.()` immediately before writing it.\n\t */\n\treadonly leadingOnly?: boolean;\n\t/**\n\t * Optional. Invoked by a driver right before writing `COMMIT` ahead of `commit()`, as with `leadingOnly`, so any\n\t * connection loss from that point on keeps its ambiguous outcome and is never retried.\n\t */\n\treadonly onCommit?: () => void;\n\t/**\n\t * Optional. `SqliteTransactionOptions.lockIfLeadingFinds`, set only with `leading` whose first statement is the\n\t * transaction's: a driver with `pipelinedTransactions` may take a `serial` domain's locks in that statement, for the\n\t * row it returns, instead of with the begin.\n\t */\n\treadonly lockIfLeadingFinds?: boolean;\n\t/**\n\t * Optional. `SqliteTransactionOptions.relaxedDurability`, never set on a read-only transaction: the driver may answer\n\t * the commit before the transaction reaches disk.\n\t */\n\treadonly relaxedDurability?: boolean;\n}\n\n/** The driver calls `createSqliteDatabase` turns into a `SqliteDatabase`. */\nexport interface SqliteDriver extends SqliteDriverExecutor {\n\t/** Diagnostic identity. Its `location` passes through `redact` before the facade exposes it. */\n\treadonly descriptor: StorageDescriptor;\n\t/** The SQL dialect the driver speaks; SQLite when absent. The facade exposes it as `SqliteDatabase.dialect`. */\n\treadonly dialect?: StorageDialect;\n\t/**\n\t * Optional. The driver runs transactions on connections of their own, concurrently with other calls: the facade then\n\t * starts `fenced` transactions without waiting for queued calls, and any other call once no earlier unfinished call\n\t * conflicts with it (`ScopeQueue`). Otherwise every call waits its turn.\n\t */\n\treadonly concurrentTransactions?: boolean;\n\t/**\n\t * Optional. The driver runs reads on connections or streams of their own, up to this many at once: the facade then\n\t * lets read-only transactions, and statements outside a transaction that `readsOnly` accepts, run beside each other,\n\t * while every other call still waits for each call before it, as without it, and a read waits for the writes queued\n\t * before it. A positive integer; anything else runs every call in turn. A driver with `concurrentTransactions` runs at\n\t * most this many reads at once when it sets it.\n\t */\n\treadonly concurrentReads?: number;\n\t/**\n\t * Optional. Whether `sql`, run outside a transaction, only reads: with `concurrentReads` or `concurrentTransactions`,\n\t * such a statement runs beside other reads. Answer true only for a statement that can never write.\n\t */\n\treadsOnly?(sql: string): boolean;\n\t/**\n\t * Optional. A transaction's connection takes a statement before the one before it is answered, and runs them in the\n\t * order it took them (a pipelined connection): the facade then sends each call of a transaction as it is made, so a\n\t * body that makes several calls without awaiting each sends them in one round trip, and the transaction runs\n\t * statement sequences (`sequenceRunner`) that way. Otherwise each call waits for the one before it to settle.\n\t */\n\treadonly pipelinedTransactions?: boolean;\n\t/**\n\t * Begins a write transaction. With `options.concurrency` `{ kind: \"serial\" }` (the default) it holds the write lock of the whole database\n\t * or of `concurrency.domain`, like `BEGIN IMMEDIATE`; with `fenced` it may take no lock, and the body locks its rows.\n\t * A SQLite driver runs both as `BEGIN IMMEDIATE` and may ignore the concurrency argument. An internal `readOnly`\n\t * request instead opens a consistent read snapshot without any writer lock.\n\t */\n\tbeginTransaction(options?: SqliteDriverTransactionOptions): Awaitable<SqliteDriverTransaction>;\n\t/**\n\t * Optional. Runs the statements in order in one write transaction, in one request: all commit or none do. Provide it\n\t * only when the driver sends the whole batch at once; the facade then offers `SqliteDatabase.batch`. `options` are the\n\t * caller's, as `SqliteDatabase.batch` took them.\n\t */\n\tbatch?(\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions?: SqliteBatchOptions,\n\t): Awaitable<readonly SqliteDriverResult[]>;\n\t/**\n\t * Optional. Opens a driver on this same database, on connections of its own, for reads: the facade offers it as\n\t * `SqliteDatabase.openReader`, with a call queue of its own, and closes it when this driver's database closes.\n\t */\n\topenReader?(): Awaitable<SqliteDriver>;\n\t/** Releases the connection. Called once, after accepted work drains. */\n\tclose(): Awaitable<void>;\n\t/** Removes credentials from diagnostic text: the descriptor location and driver failure messages and stacks. */\n\tredact?(text: string): string;\n\t/**\n\t * Optional. Recognizes a failed `batch` that found the database's write lock busy and wrote nothing: the facade sends\n\t * it again, after a randomized wait outside its call queue, for up to the caller's `lockWaitMs`. It receives the\n\t * failure the facade reports, whose `cause` chain holds the driver's own.\n\t */\n\tlockBusy?(failure: StorageFailureCause): boolean;\n\t/**\n\t * Optional. Recognizes a failure a driver call threw as one that passes, from the failure's own fields, before the\n\t * facade redacts it. The call then fails with `StorageTransientError`, and a call that wrote nothing runs again.\n\t */\n\ttransientFailure?(failure: StorageFailureCause): SqliteDriverTransientFailure | undefined;\n\t/**\n\t * Optional. The backend's payload limits in bytes, named in the `StoragePayloadTooLargeError` the facade throws when\n\t * a driver call fails because a value, row or response was too large for the backend (#4954).\n\t */\n\treadonly payloadLimits?: StoragePayloadLimits;\n\t/**\n\t * Optional. Wake-ups through the database, which the facade exposes as `SqliteDatabase.notifications`; the driver's\n\t * `close` stops its listening connection.\n\t */\n\treadonly notifications?: StorageNotifications;\n\t/**\n\t * Optional. The bytes this process may still write on the file system that holds the database's file, or undefined\n\t * when the file system does not say; the facade exposes it as `SqliteDatabase.freeBytes`. Provide it only for a\n\t * database in a file this process can see, such as a local SQLite file.\n\t */\n\tfreeBytes?(): Awaitable<number | undefined>;\n\t/**\n\t * @internal Optional. Which database the driver reaches, which the facade exposes as\n\t * `SqliteDatabase.databaseIdentity`: the same string from two drivers only when each one's transactions read and write\n\t * the very tables the other's do. Undefined where that cannot be told, as for a database in memory.\n\t */\n\tdatabaseIdentity?(): string | undefined;\n\t/**\n\t * Optional. The schema the driver read in its open's own round trip, given once; the facade exposes it as\n\t * `SqliteDatabase.takeOpenedCatalog`, so the first store open does not read it again (#6560).\n\t */\n\ttakeOpenedCatalog?(): StorageOpenedCatalog | undefined;\n}\n\n/**\n * How many times the facade runs a call that a transient failure ended before it wrote anything, the first run\n * included. A transaction runs again only when its options allow it (`retryTransientFailures`).\n */\nexport const STORAGE_TRANSIENT_RETRY_ATTEMPTS = 5;\n/** The wait before the second run, in milliseconds; each later wait is twice as long as the one before. */\nconst STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS = 250;\n/** Each wait varies by up to this fraction either way, so processes that failed together do not retry together. */\nconst STORAGE_TRANSIENT_RETRY_JITTER = 0.2;\n/** The first bound on the wait before a batch that found the write lock busy is sent again; each later one doubles. */\nconst BUSY_RETRY_BASE_MS = 20;\n/** The largest bound on that wait. */\nconst BUSY_RETRY_MAX_MS = 1000;\n\n/**\n * How long the running call may run before the calls queued behind it fail without running (#5114). The facade\n * runs one call at a time, so a call that cannot complete, such as one waiting on a write lock a server keeps for a\n * stream an outage cut, would otherwise hold every call queued behind it, priority calls such as a worker host's\n * heartbeat included. A call queued behind it fails with `StorageUnavailableError` instead, having written nothing,\n * and its caller retries it as it retries any outage.\n */\nexport const STORAGE_QUEUED_CALL_MAX_WAIT_MS = 60_000;\n/**\n * The same bound for a priority call, such as a worker host's heartbeat or a work lease renewal: a third of the 30 s a\n * host's or a work lease's last write keeps it live (`FLEET_HOST_LIVE_MS`), so a priority call stuck behind a call that\n * cannot complete fails, and its caller tries it again, while the lease it renews still holds.\n */\nexport const STORAGE_PRIORITY_CALL_MAX_WAIT_MS = 10_000;\n\n/** How long the facade waits after the failed run `attempt` (1-based) before it runs the call again. */\nfunction transientRetryDelayMs(attempt: number): number {\n\tconst jitter = 1 + STORAGE_TRANSIENT_RETRY_JITTER * (2 * Math.random() - 1);\n\treturn Math.round(STORAGE_TRANSIENT_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1) * jitter);\n}\n\n/** One run of a call: which run it is, and the first transient failure it met. */\ninterface Attempt {\n\treadonly number: number;\n\ttransient?: StorageTransientError;\n\t/**\n\t * Set once the transaction's commit was sent: a statement answered after it may have been committed with it when the\n\t * connection broke, so its failure keeps the outcome the driver gives it.\n\t */\n\tcommitting?: boolean;\n}\n\nconst REDACTED = \"[redacted]\";\n\n/** How {@link configuredSecretRedactor} matches the secrets it is given. */\nexport interface ConfiguredSecretRedactorOptions {\n\t/** Forms of a secret shorter than this are not redacted where they appear: they would match ordinary words. */\n\treadonly minLength?: number;\n}\n\n/**\n * Fewest characters of a form derived from a secret (a line of it, or an encoding) that is redacted, so short pieces\n * of a secret do not match ordinary text. A secret itself is redacted at any length its caller allows.\n */\nconst MIN_DERIVED_LENGTH = 6;\n/** Fewest base64 characters of a secret's encoding that are redacted, so short secrets do not match random base64. */\nconst MIN_BASE64_LENGTH = 7;\n\n/**\n * The base64 runs that appear wherever `secret`'s bytes are encoded, in standard and URL-safe alphabets: for each of\n * the three alignments of its first byte in a 3-byte group, the characters that only its bits decide.\n */\nfunction base64Forms(secret: string): string[] {\n\tconst bytes = Buffer.from(secret);\n\tconst forms: string[] = [];\n\tfor (let offset = 0; offset < 3; offset++) {\n\t\tconst encoded = Buffer.concat([Buffer.alloc(offset), bytes, Buffer.alloc(2)]).toString(\"base64\");\n\t\tconst form = encoded.slice(Math.ceil((8 * offset) / 6), Math.floor((8 * (offset + bytes.length)) / 6));\n\t\tif (form.length >= MIN_BASE64_LENGTH) forms.push(form, form.replaceAll(\"+\", \"-\").replaceAll(\"/\", \"_\"));\n\t}\n\treturn forms;\n}\n\n/** The JSON-escaped, URI-encoded, URI-decoded and base64 forms of `plain`. */\nfunction encodedForms(plain: string): string[] {\n\tconst forms = [JSON.stringify(plain).slice(1, -1), ...base64Forms(plain)];\n\ttry {\n\t\tforms.push(encodeURIComponent(plain));\n\t} catch {}\n\ttry {\n\t\tforms.push(decodeURIComponent(plain));\n\t} catch {}\n\treturn forms;\n}\n\n/** A line of a multi-line secret that many secrets share, such as a PEM armor line (`-----BEGIN … KEY-----`). */\nconst GENERIC_LINE = /^-----[A-Z0-9 ]+-----$|^[A-Za-z-]+: /u;\n\n/**\n * The forms a configured secret takes in output: trimmed, since a secret read from a file often ends with a line break\n * that the text around a printed secret need not repeat; each line of a multi-line secret, trimmed, that holds a letter\n * or digit and is not a line many secrets share (a PEM armor or header line); and the encodings of both. The secret as given holds its trimmed form, so overlapping matches still remove\n * it whole. Forms derived from the secret are kept only from {@link MIN_DERIVED_LENGTH} characters.\n */\nfunction secretForms(secret: string, minLength: number): string[] {\n\tconst trimmed = secret.trim();\n\tif (trimmed.length < Math.max(1, minLength)) return [];\n\tconst derivedLength = Math.max(minLength, MIN_DERIVED_LENGTH);\n\tconst lines = trimmed.includes(\"\\n\")\n\t\t? trimmed\n\t\t\t\t.split(/\\r?\\n/u)\n\t\t\t\t.map((line) => line.trim())\n\t\t\t\t.filter((line) => /[\\p{L}\\p{N}]/u.test(line) && !GENERIC_LINE.test(line))\n\t\t: [];\n\tconst derived = [...lines, ...[trimmed, ...lines].flatMap(encodedForms)];\n\treturn [trimmed, ...derived.filter((form) => form.length >= derivedLength)];\n}\n\n/** Every occurrence of each of `forms` in `text`, overlapping ones merged, as `[start, end)` ranges in order. */\nfunction secretRanges(text: string, forms: readonly string[]): [number, number][] {\n\tconst found: [number, number][] = [];\n\tfor (const form of forms) {\n\t\tfor (let at = text.indexOf(form); at !== -1; at = text.indexOf(form, at + 1)) found.push([at, at + form.length]);\n\t}\n\tfound.sort((first, second) => first[0] - second[0]);\n\tconst merged: [number, number][] = [];\n\tfor (const [start, end] of found) {\n\t\tconst last = merged.at(-1);\n\t\tif (last !== undefined && start < last[1]) last[1] = Math.max(last[1], end);\n\t\telse merged.push([start, end]);\n\t}\n\treturn merged;\n}\n\n/**\n * A redactor that replaces each configured secret with `[redacted]`: its plain, trimmed and per-line forms, and their\n * JSON-escaped, URI-encoded, URI-decoded and base64 forms. Occurrences that overlap, such as two secrets that share\n * characters, are replaced together, so no part of either survives, and text around them is left as it is. A\n * `[redacted]` marker already in the text is kept as it is, so redacting twice changes nothing.\n */\nexport function configuredSecretRedactor(\n\tsecrets: Iterable<string>,\n\toptions: ConfiguredSecretRedactorOptions = {},\n): (text: string) => string {\n\tconst forms = new Set<string>();\n\tfor (const secret of secrets) for (const form of secretForms(secret, options.minLength ?? 1)) forms.add(form);\n\tconst ordered = [...forms];\n\treturn (text) =>\n\t\ttext\n\t\t\t.split(REDACTED)\n\t\t\t.map((piece) => {\n\t\t\t\tlet redacted = \"\";\n\t\t\t\tlet copied = 0;\n\t\t\t\tfor (const [start, end] of secretRanges(piece, ordered)) {\n\t\t\t\t\tredacted += piece.slice(copied, start) + REDACTED;\n\t\t\t\t\tcopied = end;\n\t\t\t\t}\n\t\t\t\treturn redacted + piece.slice(copied);\n\t\t\t})\n\t\t\t.join(REDACTED);\n}\n\n/**\n * A redactor that replaces every non-empty secret, and its trimmed, per-line, URI-encoded, URI-decoded, JSON-escaped\n * and base64 forms, with `[redacted]`. Occurrences that overlap are replaced together, so a secret that contains or\n * shares characters with another is removed whole. A `[redacted]` marker already in the text is kept as it is, so\n * redacting twice changes nothing, even for a secret that is part of the marker.\n */\nexport function redactSecrets(secrets: Iterable<string>): (text: string) => string {\n\treturn configuredSecretRedactor(secrets);\n}\n\nfunction redactCause(cause: StorageFailureCause, redact: (text: string) => string): StorageFailureCause {\n\tif (typeof cause === \"string\") return redact(cause);\n\tif (!(cause instanceof Error)) return cause;\n\tconst nested = cause.cause as StorageFailureCause;\n\tconst safeCause = redactCause(nested, redact);\n\tconst message = redact(cause.message);\n\tconst stack = cause.stack === undefined ? undefined : redact(cause.stack);\n\tif (message === cause.message && stack === cause.stack && safeCause === nested) return cause;\n\tconst safe = new StorageError(message, { cause: safeCause });\n\tsafe.stack = stack;\n\t// The code names the failure, such as a TLS error's, and holds no credential.\n\tconst code = (cause as { readonly code?: string | number }).code;\n\tif (typeof code === \"string\") Object.assign(safe, { code });\n\treturn safe;\n}\n\nfunction snapshotParams(params: readonly SqliteValue[]): SqliteValue[] {\n\treturn params.map((value) => (value instanceof Uint8Array ? new Uint8Array(value) : value));\n}\n\nfunction normalizeValue(value: SqliteDriverValue): SqliteValue {\n\tif (typeof value === \"bigint\") {\n\t\treturn value >= -BigInt(Number.MAX_SAFE_INTEGER) && value <= BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? Number(value)\n\t\t\t: value;\n\t}\n\tif (value instanceof ArrayBuffer) return new Uint8Array(value.slice(0));\n\tif (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength).slice();\n\treturn value;\n}\n\nfunction normalizeRow(row: ArrayLike<SqliteDriverValue>, columns: readonly string[]): SqliteRow {\n\treturn Object.fromEntries(columns.map((column, index) => [column, normalizeValue(row[index] ?? null)]));\n}\n\n/** Rejects a `retryTransientFailures` that is not a boolean, before the transaction is queued. */\nfunction retriesTransientFailures(options: SqliteTransactionOptions | undefined): boolean {\n\tconst retry = options?.retryTransientFailures;\n\tif (retry !== undefined && typeof retry !== \"boolean\")\n\t\tthrow new StorageConfigError(\n\t\t\t\"sdk\",\n\t\t\t\"retryTransientFailures\",\n\t\t\t\"boolean-required\",\n\t\t\t\"Pass true or false, or omit it\",\n\t\t);\n\treturn retry === true;\n}\n\nconst SERIAL: TransactionConcurrency = Object.freeze({ kind: \"serial\" });\n\n/** Rejects a `concurrency` that is not one of the two kinds, before the transaction is queued. */\nfunction transactionConcurrency(options: SqliteTransactionOptions | undefined): TransactionConcurrency {\n\tconst concurrency = options?.concurrency;\n\tif (concurrency === undefined) return SERIAL;\n\tif (typeof concurrency !== \"object\" || concurrency === null) throw concurrencyConfigError();\n\tif (concurrency.kind === \"serial\" && (concurrency.domain === undefined || typeof concurrency.domain === \"string\"))\n\t\treturn concurrency;\n\tif (\n\t\tconcurrency.kind === \"fenced\" &&\n\t\ttypeof concurrency.audit === \"string\" &&\n\t\tconcurrency.audit !== \"\" &&\n\t\t(concurrency.excludesSerial === undefined || typeof concurrency.excludesSerial === \"boolean\")\n\t)\n\t\treturn concurrency;\n\tthrow concurrencyConfigError();\n}\n\nfunction concurrencyConfigError(): StorageConfigError {\n\treturn new StorageConfigError(\n\t\t\"sdk\",\n\t\t\"concurrency\",\n\t\t\"kind-required\",\n\t\t'Pass { kind: \"serial\" }, { kind: \"serial\", domain }, or { kind: \"fenced\", audit: fencedPath(name) }, or omit it',\n\t);\n}\n\ntype SavepointAction =\n\t| { readonly kind: \"savepoint\"; readonly name: string }\n\t| { readonly kind: \"rollback-to\"; readonly name: string }\n\t| { readonly kind: \"release\"; readonly name: string }\n\t| { readonly kind: \"other\" };\n\nconst SAVEPOINT_KEYWORDS = /\\b(?:SAVEPOINT|ROLLBACK|RELEASE)\\b/i;\n\nfunction classifySavepointStatement(\n\ttokens: readonly { readonly text: string; readonly quoted: boolean }[],\n): SavepointAction {\n\tconst keyword = (at: number): string | undefined => {\n\t\tconst token = tokens[at];\n\t\treturn token === undefined || token.quoted ? undefined : token.text.toUpperCase();\n\t};\n\tconst identifier = (at: number): string | undefined => {\n\t\tconst token = tokens[at];\n\t\tif (token === undefined || token.text.length === 0) return undefined;\n\t\treturn token.quoted ? token.text : token.text.toLowerCase();\n\t};\n\tconst first = keyword(0);\n\tif (first === \"SAVEPOINT\" && tokens.length === 2) {\n\t\tconst name = identifier(1);\n\t\tif (name !== undefined) return { kind: \"savepoint\", name };\n\t}\n\tif (first === \"RELEASE\") {\n\t\tconst nameIndex = keyword(1) === \"SAVEPOINT\" ? 2 : 1;\n\t\tif (tokens.length === nameIndex + 1) {\n\t\t\tconst name = identifier(nameIndex);\n\t\t\tif (name !== undefined) return { kind: \"release\", name };\n\t\t}\n\t}\n\tif (first === \"ROLLBACK\") {\n\t\tlet at = 1;\n\t\tif (keyword(at) === \"WORK\" || keyword(at) === \"TRANSACTION\") at++;\n\t\tif (keyword(at) === \"TO\") {\n\t\t\tat++;\n\t\t\tif (keyword(at) === \"SAVEPOINT\") at++;\n\t\t\tif (tokens.length === at + 1) {\n\t\t\t\tconst name = identifier(at);\n\t\t\t\tif (name !== undefined) return { kind: \"rollback-to\", name };\n\t\t\t}\n\t\t}\n\t}\n\treturn { kind: \"other\" };\n}\n\n/**\n * Extracts `SAVEPOINT`, `ROLLBACK TO [SAVEPOINT]`, and `RELEASE [SAVEPOINT]` actions from `sql` in statement order,\n * ignoring comments, string literals, and dollar-quoted strings. Returns undefined when `sql` contains none.\n */\nfunction parseSavepointActions(sql: string): readonly SavepointAction[] | undefined {\n\tif (!SAVEPOINT_KEYWORDS.test(sql)) return undefined;\n\tconst actions: SavepointAction[] = [];\n\tlet index = 0;\n\tconst length = sql.length;\n\twhile (index < length) {\n\t\tconst tokens: { readonly text: string; readonly quoted: boolean }[] = [];\n\t\tlet extra = false;\n\t\twhile (index < length) {\n\t\t\tconst ch = sql[index]!;\n\t\t\tif (/\\s/.test(ch)) {\n\t\t\t\tindex++;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === \"-\" && sql[index + 1] === \"-\") {\n\t\t\t\tconst end = sql.indexOf(\"\\n\", index + 2);\n\t\t\t\tindex = end === -1 ? length : end + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === \"/\" && sql[index + 1] === \"*\") {\n\t\t\t\tlet depth = 1;\n\t\t\t\tindex += 2;\n\t\t\t\twhile (index < length && depth > 0) {\n\t\t\t\t\tif (sql.startsWith(\"/*\", index)) {\n\t\t\t\t\t\tdepth++;\n\t\t\t\t\t\tindex += 2;\n\t\t\t\t\t} else if (sql.startsWith(\"*/\", index)) {\n\t\t\t\t\t\tdepth--;\n\t\t\t\t\t\tindex += 2;\n\t\t\t\t\t} else index++;\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === \";\") {\n\t\t\t\tindex++;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (ch === \"'\") {\n\t\t\t\tconst escapes =\n\t\t\t\t\t(sql[index - 1] === \"e\" || sql[index - 1] === \"E\") &&\n\t\t\t\t\t!/[A-Za-z0-9_$\\u0080-\\uffff]/.test(sql[index - 2] ?? \"\");\n\t\t\t\tindex++;\n\t\t\t\twhile (index < length) {\n\t\t\t\t\tif (escapes && sql[index] === \"\\\\\") index += 2;\n\t\t\t\t\telse if (sql[index] !== \"'\") index++;\n\t\t\t\t\telse if (sql[index + 1] === \"'\") index += 2;\n\t\t\t\t\telse break;\n\t\t\t\t}\n\t\t\t\tindex++;\n\t\t\t\textra = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === '\"') {\n\t\t\t\tlet value = \"\";\n\t\t\t\tindex++;\n\t\t\t\twhile (index < length) {\n\t\t\t\t\tif (sql[index] === '\"') {\n\t\t\t\t\t\tif (sql[index + 1] === '\"') {\n\t\t\t\t\t\t\tvalue += '\"';\n\t\t\t\t\t\t\tindex += 2;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tindex++;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvalue += sql[index++];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (tokens.length < 5) tokens.push({ text: value, quoted: true });\n\t\t\t\telse extra = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (ch === \"$\") {\n\t\t\t\tconst tag = /^\\$(?:[A-Za-z_\\u0080-\\uffff][A-Za-z0-9_\\u0080-\\uffff]*)?\\$/.exec(sql.slice(index))?.[0];\n\t\t\t\tif (tag !== undefined) {\n\t\t\t\t\tconst close = sql.indexOf(tag, index + tag.length);\n\t\t\t\t\tindex = close === -1 ? length : close + tag.length;\n\t\t\t\t\textra = true;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (/[A-Za-z_\\u0080-\\uffff]/.test(ch)) {\n\t\t\t\tlet end = index + 1;\n\t\t\t\twhile (end < length && /[A-Za-z0-9_$\\u0080-\\uffff]/.test(sql[end]!)) end++;\n\t\t\t\tconst word = sql.slice(index, end);\n\t\t\t\tindex = end;\n\t\t\t\tif (tokens.length < 5) tokens.push({ text: word, quoted: false });\n\t\t\t\telse extra = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\textra = true;\n\t\t\tindex++;\n\t\t}\n\t\tif (tokens.length === 0 && !extra) continue;\n\t\tactions.push(extra ? { kind: \"other\" } : classifySavepointStatement(tokens));\n\t}\n\treturn actions.some((action) => action.kind !== \"other\") ? actions : undefined;\n}\n\ninterface RecordedCall {\n\treadonly actions?: readonly SavepointAction[];\n\tfailure?: { readonly reason: unknown };\n\tsettled: boolean;\n}\n\n/**\n * Tracks unrecovered failures of a transaction's calls in push order, dropping failures recovered by a fulfilled\n * `ROLLBACK TO [SAVEPOINT] <name>`. Settled prefixes fold incrementally so long transactions stay bounded in memory.\n */\nclass SavepointFailureLog {\n\tprivate readonly savepoints: { readonly name: string; readonly failureCount: number }[] = [];\n\tprivate readonly activeFailures: unknown[] = [];\n\tprivate readonly pending: RecordedCall[] = [];\n\tprivate head = 0;\n\n\ttrack(sql: string | undefined, result: Promise<unknown>): Promise<void> {\n\t\tconst entry: RecordedCall = {\n\t\t\tactions: sql === undefined ? undefined : parseSavepointActions(sql),\n\t\t\tsettled: false,\n\t\t};\n\t\tthis.pending.push(entry);\n\t\treturn result.then(\n\t\t\t() => {\n\t\t\t\tentry.settled = true;\n\t\t\t\tthis.compact();\n\t\t\t},\n\t\t\t(reason: unknown) => {\n\t\t\t\tentry.failure = { reason };\n\t\t\t\tentry.settled = true;\n\t\t\t\tthis.compact();\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate compact(): void {\n\t\twhile (this.head < this.pending.length && this.pending[this.head]!.settled) {\n\t\t\tconst entry = this.pending[this.head++]!;\n\t\t\tthis.apply(entry);\n\t\t}\n\t\tif (this.head > 0 && this.head === this.pending.length) {\n\t\t\tthis.pending.length = 0;\n\t\t\tthis.head = 0;\n\t\t}\n\t}\n\n\tprivate findLastSavepoint(name: string): number {\n\t\tfor (let index = this.savepoints.length - 1; index >= 0; index--)\n\t\t\tif (this.savepoints[index]!.name === name) return index;\n\t\treturn -1;\n\t}\n\n\tprivate apply(entry: RecordedCall): void {\n\t\tif (entry.failure === undefined) {\n\t\t\tfor (const action of entry.actions ?? []) {\n\t\t\t\tif (action.kind === \"savepoint\") {\n\t\t\t\t\tthis.savepoints.push({ name: action.name, failureCount: this.activeFailures.length });\n\t\t\t\t} else if (action.kind === \"rollback-to\") {\n\t\t\t\t\tconst index = this.findLastSavepoint(action.name);\n\t\t\t\t\tif (index !== -1) {\n\t\t\t\t\t\tthis.activeFailures.length = this.savepoints[index]!.failureCount;\n\t\t\t\t\t\tthis.savepoints.length = index + 1;\n\t\t\t\t\t}\n\t\t\t\t} else if (action.kind === \"release\") {\n\t\t\t\t\tconst index = this.findLastSavepoint(action.name);\n\t\t\t\t\tif (index !== -1) this.savepoints.length = index;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst actions = entry.actions;\n\t\tif (\n\t\t\tactions !== undefined &&\n\t\t\tactions.length > 1 &&\n\t\t\tactions[0]?.kind === \"savepoint\" &&\n\t\t\tthis.activeFailures.length === (this.savepoints.at(-1)?.failureCount ?? 0)\n\t\t) {\n\t\t\tthis.savepoints.push({ name: actions[0].name, failureCount: this.activeFailures.length });\n\t\t}\n\t\tthis.activeFailures.push(entry.failure.reason);\n\t}\n\n\tfirstFailure(): unknown {\n\t\tthis.compact();\n\t\treturn this.activeFailures[0];\n\t}\n\n\tfirstTransientFailure(): StorageTransientError | undefined {\n\t\tthis.compact();\n\t\tlet chosen: StorageTransientError | undefined;\n\t\tfor (const reason of this.activeFailures) {\n\t\t\tif (!(reason instanceof StorageTransientError)) continue;\n\t\t\tif (reason.outcome !== \"not-applied\") return reason;\n\t\t\tchosen ??= reason;\n\t\t}\n\t\treturn chosen;\n\t}\n}\n\n/** Serializes operations in call order; a failed operation does not stop the ones queued after it. */\nclass CallQueue {\n\tprivate tail: Promise<void> = Promise.resolve();\n\tprivate readonly log = new SavepointFailureLog();\n\n\tpush<T>(operation: () => Promise<T>, sql?: string): Promise<T> {\n\t\tconst result = this.tail.then(operation);\n\t\tthis.tail = this.log.track(sql, result);\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn this.tail;\n\t}\n\n\tasync firstTransientFailure(): Promise<StorageTransientError | undefined> {\n\t\tawait this.drained();\n\t\treturn this.log.firstTransientFailure();\n\t}\n}\n\n/** Starts each operation as it is pushed, so a pipelined connection receives them in push order without waiting. */\nclass PipelineQueue {\n\tprivate readonly inFlight = new Set<Promise<void>>();\n\tprivate readonly log = new SavepointFailureLog();\n\n\tpush<T>(operation: () => Promise<T>, sql?: string): Promise<T> {\n\t\tconst result = operation();\n\t\tconst tracked = this.log.track(sql, result);\n\t\tthis.inFlight.add(tracked);\n\t\tvoid tracked.then(() => this.inFlight.delete(tracked));\n\t\treturn result;\n\t}\n\n\tdrained(): Promise<void> {\n\t\treturn Promise.all(this.inFlight).then(() => {});\n\t}\n\n\t/** The failure of the first unrecovered call, in the order they were sent, that failed; undefined when none did. */\n\tasync firstFailure(): Promise<unknown> {\n\t\tawait this.drained();\n\t\treturn this.log.firstFailure();\n\t}\n\n\tasync firstTransientFailure(): Promise<StorageTransientError | undefined> {\n\t\tawait this.drained();\n\t\treturn this.log.firstTransientFailure();\n\t}\n}\n\ninterface QueuedCall {\n\trun(): Promise<void>;\n\tfail(error: Error): void;\n}\n\n/** A database's call queue: which call may start when, and whether any is unfinished. */\ninterface CallLanes {\n\tpush<T>(operation: () => Promise<T>, priority?: boolean, scope?: CallScope): Promise<T>;\n\tdrained(): Promise<void>;\n}\n\n/**\n * Runs operations one at a time, in call order within each lane: an operation of the priority lane runs before every\n * waiting operation of the normal lane. A failed operation does not stop the ones queued after it. Once the running\n * operation has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` without settling, every priority operation waiting behind it\n * fails with `stalled()` without running, and once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`, every other one does;\n * so does every one queued behind it after that. Each operation that starts gets full waits of its own, so a queue of\n * operations that each settle in time never fails one.\n */\nclass LaneQueue {\n\tprivate readonly normal: QueuedCall[] = [];\n\tprivate readonly priority: QueuedCall[] = [];\n\tprivate running = false;\n\t/** When the running operation started, as `Date.now()`. */\n\tprivate runningSince = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** The bound the planned check enforces, or undefined when none is planned. */\n\tprivate watchdogBound?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error) {\n\t\tthis.stalled = stalled;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\t(priority ? this.priority : this.normal).push({\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t});\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (!this.running && this.normal.length === 0 && this.priority.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\tprivate next(): void {\n\t\tif (this.running) return;\n\t\tconst operation = this.priority.shift() ?? this.normal.shift();\n\t\tif (operation === undefined) {\n\t\t\tconst idle = this.idle;\n\t\t\tthis.idle = [];\n\t\t\tfor (const resolve of idle) resolve();\n\t\t\treturn;\n\t\t}\n\t\tthis.running = true;\n\t\tthis.runningSince = Date.now();\n\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\tvoid operation.run().finally(() => {\n\t\t\tclearTimeout(this.watchdog);\n\t\t\tthis.watchdog = undefined;\n\t\t\tthis.watchdogBound = undefined;\n\t\t\tthis.running = false;\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\t/**\n\t * While operations wait behind a running one, fails the priority ones once that one has run\n\t * `STORAGE_PRIORITY_CALL_MAX_WAIT_MS`, and the others once it has run `STORAGE_QUEUED_CALL_MAX_WAIT_MS`. No timer\n\t * runs while nothing waits.\n\t */\n\tprivate watch(): void {\n\t\tconst bound =\n\t\t\tthis.priority.length > 0\n\t\t\t\t? STORAGE_PRIORITY_CALL_MAX_WAIT_MS\n\t\t\t\t: this.normal.length > 0\n\t\t\t\t\t? STORAGE_QUEUED_CALL_MAX_WAIT_MS\n\t\t\t\t\t: undefined;\n\t\t// A priority call queued behind ordinary ones brings the planned check forward to its own, shorter bound.\n\t\tif (bound === this.watchdogBound) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogBound = bound;\n\t\tif (bound === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogBound = undefined;\n\t\t\t\tconst ran = Date.now() - this.runningSince;\n\t\t\t\tconst failing = this.priority.splice(0);\n\t\t\t\tif (ran >= STORAGE_QUEUED_CALL_MAX_WAIT_MS) failing.push(...this.normal.splice(0));\n\t\t\t\tfor (const waiting of failing) waiting.fail(this.stalled(ran));\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, this.runningSince + bound - Date.now()),\n\t\t);\n\t\t// A stuck operation ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\n/**\n * What a call of a driver that runs transactions concurrently may run beside: `whole`, a serial transaction without a\n * domain, and `plain`, a statement or batch outside a transaction, run beside nothing; `domain`, a serial transaction\n * of one domain, beside calls of other domains and read-only transactions; `read`, a read-only transaction, beside\n * other read-only ones and the writes queued after it.\n */\ntype CallScope =\n\t| { readonly kind: \"whole\" }\n\t| { readonly kind: \"plain\" }\n\t| { readonly kind: \"read\" }\n\t| { readonly kind: \"domain\"; readonly domain: string };\n\nconst WHOLE_SCOPE: CallScope = Object.freeze({ kind: \"whole\" });\nconst PLAIN_SCOPE: CallScope = Object.freeze({ kind: \"plain\" });\nconst READ_SCOPE: CallScope = Object.freeze({ kind: \"read\" });\n\n/**\n * Whether `later` must wait for `earlier`, a call queued before it. A read-only transaction waits for the writes queued\n * before it, so it sees them, but a write queued after a read-only transaction does not wait for it.\n */\nfunction scopesConflict(earlier: CallScope, later: CallScope): boolean {\n\tif (earlier.kind === \"whole\" || earlier.kind === \"plain\" || later.kind === \"whole\" || later.kind === \"plain\")\n\t\treturn true;\n\tif (later.kind === \"read\") return earlier.kind !== \"read\";\n\treturn earlier.kind === \"domain\" && earlier.domain === later.domain;\n}\n\ninterface ScopedCall extends QueuedCall {\n\treadonly scope: CallScope;\n\treadonly priority: boolean;\n\t/** Call order within the call's lane. */\n\treadonly seq: number;\n\t/** When the call was queued, on the queue's clock of admissions and starts. */\n\treadonly admitted: number;\n\t/** When the call started, on that clock; undefined while it waits. */\n\tstarted?: number;\n\t/** When the call started, as `Date.now()`. */\n\trunningSince: number;\n}\n\n/**\n * `LaneQueue` for a driver that runs transactions or reads concurrently: a call starts once no unfinished call ahead of\n * it conflicts with it (`scopesConflict`), so calls that conflict run one at a time in call order, and the others at\n * once, reads no more than `maxReads` at a time. A priority call is ahead of every waiting call of the normal lane,\n * as there. A waiting call fails with `stalled()` once a conflicting call ahead of it, or one such a call waits for,\n * has run `STORAGE_PRIORITY_CALL_MAX_WAIT_MS` (a priority call) or `STORAGE_QUEUED_CALL_MAX_WAIT_MS` without\n * settling; a read waiting for a free place waits for the reads running then.\n */\nclass ScopeQueue {\n\t/** Unfinished calls: priority ones first, then the normal lane's, each in call order. */\n\tprivate readonly calls: ScopedCall[] = [];\n\t/** How many calls of the read scope run at once at most. */\n\tprivate readonly maxReads: number;\n\tprivate seq = 0;\n\tprivate clock = 0;\n\tprivate idle: (() => void)[] = [];\n\tprivate watchdog?: ReturnType<typeof setTimeout>;\n\t/** When the planned check runs, as `Date.now()`, or undefined when none is planned. */\n\tprivate watchdogAt?: number;\n\tprivate readonly stalled: (ranMs: number) => Error;\n\n\tconstructor(stalled: (ranMs: number) => Error, maxReads = Number.POSITIVE_INFINITY) {\n\t\tthis.stalled = stalled;\n\t\tthis.maxReads = maxReads;\n\t}\n\n\tpush<T>(operation: () => Promise<T>, priority = false, scope: CallScope = PLAIN_SCOPE): Promise<T> {\n\t\treturn new Promise<T>((resolve, reject) => {\n\t\t\tconst call: ScopedCall = {\n\t\t\t\tscope,\n\t\t\t\tpriority,\n\t\t\t\tseq: this.seq++,\n\t\t\t\tadmitted: this.clock++,\n\t\t\t\trunningSince: 0,\n\t\t\t\trun: () => Promise.resolve().then(operation).then(resolve, reject),\n\t\t\t\tfail: reject,\n\t\t\t};\n\t\t\tconst firstNormal = this.calls.findIndex((queued) => !queued.priority);\n\t\t\tif (priority && firstNormal !== -1) this.calls.splice(firstNormal, 0, call);\n\t\t\telse this.calls.push(call);\n\t\t\tthis.next();\n\t\t\tthis.watch();\n\t\t});\n\t}\n\n\tdrained(): Promise<void> {\n\t\tif (this.calls.length === 0) return Promise.resolve();\n\t\treturn new Promise((resolve) => this.idle.push(resolve));\n\t}\n\n\t/** Whether `call`, still waiting, must wait for `other`. */\n\tprivate waitsFor(call: ScopedCall, other: ScopedCall): boolean {\n\t\tif (other === call) return false;\n\t\t// A read waits for a running read while as many as `maxReads` run.\n\t\tif (call.scope.kind === \"read\" && other.scope.kind === \"read\" && other.started !== undefined)\n\t\t\treturn call.started === undefined && this.runningReads() >= this.maxReads;\n\t\tif (!scopesConflict(other.scope, call.scope)) return false;\n\t\tif (other.priority === call.priority) return other.seq < call.seq;\n\t\t// A priority call goes ahead of the normal lane's waiting calls, not of those already running when it came.\n\t\treturn other.priority || (other.started !== undefined && other.started < call.admitted);\n\t}\n\n\tprivate runningReads(): number {\n\t\tlet running = 0;\n\t\tfor (const call of this.calls) if (call.scope.kind === \"read\" && call.started !== undefined) running++;\n\t\treturn running;\n\t}\n\n\tprivate next(): void {\n\t\tfor (const call of this.calls) {\n\t\t\tif (call.started !== undefined || this.calls.some((other) => this.waitsFor(call, other))) continue;\n\t\t\tcall.started = this.clock++;\n\t\t\tcall.runningSince = Date.now();\n\t\t\t// Started on a later microtask, as a promise chain starts it, never inside the call that queued it.\n\t\t\tvoid call.run().finally(() => {\n\t\t\t\tthis.calls.splice(this.calls.indexOf(call), 1);\n\t\t\t\tthis.next();\n\t\t\t\tthis.watch();\n\t\t\t});\n\t\t}\n\t\tif (this.calls.length > 0) return;\n\t\tconst idle = this.idle;\n\t\tthis.idle = [];\n\t\tfor (const resolve of idle) resolve();\n\t}\n\n\t/** Each waiting call with when the earliest running call it waits for, directly or through others, started. */\n\tprivate stuck(): Map<ScopedCall, number> {\n\t\tconst since = new Map<ScopedCall, number>();\n\t\tfor (const call of this.calls) {\n\t\t\tif (call.started !== undefined) continue;\n\t\t\tlet earliest = Number.POSITIVE_INFINITY;\n\t\t\tfor (const other of this.calls) {\n\t\t\t\tif (!this.waitsFor(call, other)) continue;\n\t\t\t\tearliest = Math.min(\n\t\t\t\t\tearliest,\n\t\t\t\t\tother.started === undefined ? (since.get(other) ?? earliest) : other.runningSince,\n\t\t\t\t);\n\t\t\t}\n\t\t\tsince.set(call, earliest);\n\t\t}\n\t\treturn since;\n\t}\n\n\tprivate static bound(call: ScopedCall): number {\n\t\treturn call.priority ? STORAGE_PRIORITY_CALL_MAX_WAIT_MS : STORAGE_QUEUED_CALL_MAX_WAIT_MS;\n\t}\n\n\t/** Plans the check that fails the waiting calls whose wait passed its bound. No timer runs while nothing waits. */\n\tprivate watch(): void {\n\t\tlet at: number | undefined;\n\t\tfor (const [call, since] of this.stuck())\n\t\t\tif (Number.isFinite(since)) at = Math.min(at ?? Number.POSITIVE_INFINITY, since + ScopeQueue.bound(call));\n\t\tif (at === this.watchdogAt) return;\n\t\tclearTimeout(this.watchdog);\n\t\tthis.watchdog = undefined;\n\t\tthis.watchdogAt = at;\n\t\tif (at === undefined) return;\n\t\tthis.watchdog = setTimeout(\n\t\t\t() => {\n\t\t\t\tthis.watchdog = undefined;\n\t\t\t\tthis.watchdogAt = undefined;\n\t\t\t\tconst now = Date.now();\n\t\t\t\tconst failing: [ScopedCall, number][] = [];\n\t\t\t\tfor (const [call, since] of this.stuck())\n\t\t\t\t\tif (now - since >= ScopeQueue.bound(call)) failing.push([call, now - since]);\n\t\t\t\tfor (const [call] of failing) this.calls.splice(this.calls.indexOf(call), 1);\n\t\t\t\tfor (const [call, ran] of failing) call.fail(this.stalled(ran));\n\t\t\t\tthis.next();\n\t\t\t\tthis.watch();\n\t\t\t},\n\t\t\tMath.max(0, at - Date.now()),\n\t\t);\n\t\t// A stuck call ahead of the queue never keeps the process alive on its own.\n\t\tthis.watchdog.unref();\n\t}\n}\n\n/** How many reads `driver` runs at once, when it runs any beside each other (`SqliteDriver.concurrentReads`). */\nfunction concurrentReads(driver: SqliteDriver): number | undefined {\n\tconst reads = driver.concurrentReads;\n\treturn typeof reads === \"number\" && Number.isInteger(reads) && reads > 0 ? reads : undefined;\n}\n\n/**\n * The scope a transaction runs in on a driver that runs transactions or reads concurrently: a write transaction keeps\n * its domain only on a driver that runs writes concurrently (`concurrentTransactions`), and runs alone otherwise.\n */\nfunction transactionScope(\n\tconcurrency: TransactionConcurrency,\n\treadOnly: boolean,\n\tconcurrentWrites: boolean,\n): CallScope {\n\tif (readOnly) return READ_SCOPE;\n\tif (concurrentWrites && concurrency.kind === \"serial\" && concurrency.domain !== undefined)\n\t\treturn { kind: \"domain\", domain: concurrency.domain };\n\treturn WHOLE_SCOPE;\n}\n\nfunction hasInvalidText(statement: SqliteStatement): boolean {\n\treturn statement.params.some((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n}\n\n/** `leading` with parameters snapshotted, up to the first statement that holds NUL, which the facade refuses to send. */\nfunction leadingStatements(leading: readonly SqliteStatement[] | undefined): readonly SqliteStatement[] {\n\tconst sent: SqliteStatement[] = [];\n\tfor (const statement of leading ?? []) {\n\t\tif (hasInvalidText(statement)) break;\n\t\tsent.push({ sql: statement.sql, params: snapshotParams(statement.params) });\n\t}\n\treturn sent;\n}\n\n/**\n * Runs `sequence` on a transaction of a pipelined connection: `repeat` one run at a time, since each run's changes\n * decide the next, then the statements a request's worth at a time, each request sent whole before any answer comes.\n * A statement sent behind one that failed fails too, or runs in a transaction that can no longer commit, so the\n * first failure in order is the sequence's, as when each waited for the one before. Nothing is sent after a statement\n * whose text holds NUL, which fails as `run` fails it.\n */\nasync function pipelineSequence(\n\thandle: SqliteExecutor,\n\t{ repeat, statements, signal }: SqliteSequence,\n): Promise<number> {\n\tlet repeated = 0;\n\tif (repeat !== undefined) {\n\t\tfor (let done = 0; done < repeat.times; done++) {\n\t\t\tsignal?.throwIfAborted();\n\t\t\tconst { changes } = await handle.run(repeat.statement.sql, ...repeat.statement.params);\n\t\t\tif (changes < repeat.minChanges) break;\n\t\t\trepeated++;\n\t\t}\n\t}\n\tconst pending = statements[Symbol.iterator]();\n\tfor (let next = pending.next(); next.done !== true; ) {\n\t\tconst sent: Promise<unknown>[] = [];\n\t\tfor (; next.done !== true && sent.length < MAX_SEQUENCE_REQUEST_STATEMENTS; next = pending.next()) {\n\t\t\tif (signal?.aborted === true) break;\n\t\t\tconst statement = next.value;\n\t\t\tsent.push(\n\t\t\t\tstatement.script === true ? handle.exec(statement.sql) : handle.run(statement.sql, ...statement.params),\n\t\t\t);\n\t\t\t// `run` refuses it without sending it, so the sequence fails with that below.\n\t\t\tif (hasInvalidText(statement)) break;\n\t\t}\n\t\tconst outcomes = await Promise.allSettled(sent);\n\t\tconst failed = outcomes.find((outcome) => outcome.status === \"rejected\");\n\t\tif (failed !== undefined) throw failed.reason;\n\t\tsignal?.throwIfAborted();\n\t}\n\treturn repeated;\n}\n\nclass DriverDatabase implements SqliteDatabase {\n\treadonly descriptor: StorageDescriptor;\n\treadonly dialect: StorageDialect;\n\tprivate readonly driver: SqliteDriver;\n\t/** Fenced transactions a concurrent driver runs outside the queue; closing waits for them. */\n\tprivate readonly concurrent = new Set<Promise<unknown>>();\n\tprivate readonly redact: (text: string) => string;\n\tprivate readonly queue: CallLanes;\n\tprivate closePromise?: Promise<void>;\n\t/** End the waits before calls run again, when closing begins during them. */\n\tprivate readonly wakeRetries = new Set<() => void>();\n\tprivate retryReported = false;\n\tprivate readonly executor: SqliteExecutor;\n\treadonly batch?: (statements: readonly SqliteStatement[], options?: SqliteBatchOptions) => Promise<SqliteRow[][]>;\n\treadonly notifications?: StorageNotifications;\n\treadonly freeBytes?: () => Promise<number | undefined>;\n\treadonly databaseIdentity?: () => string | undefined;\n\treadonly openReader?: () => Promise<SqliteDatabase>;\n\treadonly takeOpenedCatalog?: () => StorageOpenedCatalog | undefined;\n\treadonly autocommit?: (statement: SqliteStatement, concurrency: TransactionConcurrency) => Promise<SqliteRow[]>;\n\t/** Readers this database opened and that are not closed; closing closes them. */\n\tprivate readonly readers = new Set<DriverDatabase>();\n\tprivate readonly closed?: () => void;\n\n\tconstructor(driver: SqliteDriver, redact: (text: string) => string, closed?: () => void) {\n\t\tthis.driver = driver;\n\t\tthis.closed = closed;\n\t\tconst openReader = driver.openReader?.bind(driver);\n\t\tif (openReader) this.openReader = () => this.startReader(openReader);\n\t\tif (driver.notifications !== undefined) this.notifications = driver.notifications;\n\t\tconst freeBytes = driver.freeBytes?.bind(driver);\n\t\tif (freeBytes) this.freeBytes = async () => freeBytes();\n\t\tconst databaseIdentity = driver.databaseIdentity?.bind(driver);\n\t\tif (databaseIdentity) this.databaseIdentity = databaseIdentity;\n\t\tconst takeOpenedCatalog = driver.takeOpenedCatalog?.bind(driver);\n\t\tif (takeOpenedCatalog) this.takeOpenedCatalog = takeOpenedCatalog;\n\t\tthis.redact = redact;\n\t\tthis.descriptor = { adapter: driver.descriptor.adapter, location: redact(driver.descriptor.location) };\n\t\tconst stalled = (ranMs: number) =>\n\t\t\tnew StorageUnavailableError(\n\t\t\t\tthis.descriptor,\n\t\t\t\tundefined,\n\t\t\t\t`the call was queued behind an earlier call that ran ${Math.round(ranMs / 1000)} seconds without settling, and did not run; nothing was written, retry it`,\n\t\t\t);\n\t\tconst maxReads = concurrentReads(driver);\n\t\tthis.queue =\n\t\t\tdriver.concurrentTransactions === true || maxReads !== undefined\n\t\t\t\t? new ScopeQueue(stalled, maxReads)\n\t\t\t\t: new LaneQueue(stalled);\n\t\tthis.dialect = driver.dialect ?? sqliteDialect;\n\t\tconst readsOnly = driver.readsOnly?.bind(driver);\n\t\tconst scopeOf =\n\t\t\treadsOnly !== undefined && (driver.concurrentTransactions === true || maxReads !== undefined)\n\t\t\t\t? (sql: string) => (readsOnly(sql) ? READ_SCOPE : PLAIN_SCOPE)\n\t\t\t\t: () => PLAIN_SCOPE;\n\t\tthis.executor = this.createExecutor(\n\t\t\tdriver,\n\t\t\t(operation, sql, script) => {\n\t\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t\t\treturn this.queue.push(\n\t\t\t\t\t() => this.retrying(operation, true),\n\t\t\t\t\tfalse,\n\t\t\t\t\tsql === undefined || script === true ? PLAIN_SCOPE : scopeOf(sql),\n\t\t\t\t);\n\t\t\t},\n\t\t\ttrue,\n\t\t);\n\t\tconst batch = driver.batch?.bind(driver);\n\t\tif (batch) this.batch = (statements, options) => this.runBatch(batch, statements, options);\n\t\tif (driver.concurrentTransactions === true)\n\t\t\tthis.autocommit = (statement, concurrency) => this.runAutocommit(statement, concurrency);\n\t}\n\n\t/** `autocommit`: the statement on its own, through the driver's `execute`, in the queue scope of `concurrency`. */\n\tprivate runAutocommit(statement: SqliteStatement, concurrency: TransactionConcurrency): Promise<SqliteRow[]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet scope: CallScope;\n\t\ttry {\n\t\t\tscope = transactionScope(transactionConcurrency({ concurrency }), false, true);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst bound = snapshotParams(statement.params);\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\tconst result = await this.call(() => this.driver.execute(statement.sql, bound), attempt, true, bound);\n\t\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns));\n\t\t\t\t}, true),\n\t\t\tfalse,\n\t\t\tscope,\n\t\t);\n\t}\n\n\tprivate runBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tstatements: readonly SqliteStatement[],\n\t\toptions: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst bound = statements.map((statement) => ({ sql: statement.sql, params: snapshotParams(statement.params) }));\n\t\tconst passed = options === undefined ? undefined : { ...options };\n\t\tconst send = () => this.sendBatch(batch, bound, passed);\n\t\tconst lockWaitMs = passed?.lockWaitMs ?? 0;\n\t\tconst busy = this.driver.lockBusy?.bind(this.driver);\n\t\tif (lockWaitMs <= 0 || busy === undefined) return send();\n\t\treturn this.whileBusy(send, busy, performance.now() + lockWaitMs);\n\t}\n\n\t/**\n\t * Sends a batch again while it finds the write lock busy, until `deadline`. Each wait is random up to a bound that\n\t * doubles from `BUSY_RETRY_BASE_MS` to `BUSY_RETRY_MAX_MS` (\"full jitter\"), so writers that failed together do not\n\t * come back together. The waits happen outside the call queue, so calls queued meanwhile, a priority batch such as\n\t * a lease renewal included, run during them.\n\t */\n\tprivate async whileBusy<T>(\n\t\tsend: () => Promise<T>,\n\t\tbusy: (failure: StorageFailureCause) => boolean,\n\t\tdeadline: number,\n\t): Promise<T> {\n\t\tfor (let attempt = 0; ; attempt++) {\n\t\t\ttry {\n\t\t\t\treturn await send();\n\t\t\t} catch (failure) {\n\t\t\t\tif (!busy(failure as StorageFailureCause) || performance.now() >= deadline || this.closePromise)\n\t\t\t\t\tthrow failure;\n\t\t\t}\n\t\t\tconst bound = Math.min(BUSY_RETRY_MAX_MS, BUSY_RETRY_BASE_MS * 2 ** Math.min(attempt, 16));\n\t\t\tawait new Promise((resolve) =>\n\t\t\t\tsetTimeout(resolve, Math.min(Math.random() * bound, deadline - performance.now())),\n\t\t\t);\n\t\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\t}\n\t}\n\n\tprivate sendBatch(\n\t\tbatch: NonNullable<SqliteDriver[\"batch\"]>,\n\t\tbound: readonly SqliteStatement[],\n\t\tpassed: SqliteBatchOptions | undefined,\n\t): Promise<SqliteRow[][]> {\n\t\treturn this.queue.push(\n\t\t\t() =>\n\t\t\t\tthis.retrying(async (attempt) => {\n\t\t\t\t\tfor (const statement of bound) {\n\t\t\t\t\t\tconst invalidIndex = statement.params.findIndex(\n\t\t\t\t\t\t\t(value) => typeof value === \"string\" && value.includes(\"\\0\"),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\t}\n\t\t\t\t\tconst results = await this.call(\n\t\t\t\t\t\t() => batch(bound, passed),\n\t\t\t\t\t\tattempt,\n\t\t\t\t\t\ttrue,\n\t\t\t\t\t\tbound.flatMap((statement) => statement.params),\n\t\t\t\t\t);\n\t\t\t\t\treturn results.map((result) => result.rows.map((row) => normalizeRow(row, result.columns)));\n\t\t\t\t}, true),\n\t\t\tpassed?.priority === true,\n\t\t);\n\t}\n\n\t/**\n\t * Runs `operation` again while a transient failure ended its run before it wrote anything, waiting longer before\n\t * each run, and only when `replay` allows it. Gives up with the last run's failure after\n\t * `STORAGE_TRANSIENT_RETRY_ATTEMPTS` runs, or once closing begins.\n\t */\n\tprivate async retrying<T>(operation: (attempt: Attempt) => Promise<T>, replay: boolean): Promise<T> {\n\t\tfor (let number = 1; ; number++) {\n\t\t\tconst attempt: Attempt = { number };\n\t\t\ttry {\n\t\t\t\treturn await operation(attempt);\n\t\t\t} catch (failure) {\n\t\t\t\tconst transient = attempt.transient;\n\t\t\t\tif (!replay || transient?.outcome !== \"not-applied\" || !(await this.backoff(transient))) throw failure;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Waits before the run after `failure`'s, and says whether to run again: not after the last run, nor once closing\n\t * begins, which also ends a wait under way. The first transient failure that makes the database run a call again is\n\t * emitted as a process warning.\n\t */\n\tprivate async backoff(failure: StorageTransientError): Promise<boolean> {\n\t\tif (failure.attempts >= STORAGE_TRANSIENT_RETRY_ATTEMPTS || this.closePromise) return false;\n\t\tif (!this.retryReported) {\n\t\t\tthis.retryReported = true;\n\t\t\tprocess.emitWarning(failure);\n\t\t}\n\t\tlet wake: (() => void) | undefined;\n\t\tawait new Promise<void>((resolve) => {\n\t\t\tconst timer = setTimeout(resolve, transientRetryDelayMs(failure.attempts));\n\t\t\twake = () => {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tresolve();\n\t\t\t};\n\t\t\tthis.wakeRetries.add(wake);\n\t\t});\n\t\tif (wake) this.wakeRetries.delete(wake);\n\t\treturn this.closePromise === undefined;\n\t}\n\n\t/**\n\t * Maps a driver failure to `StorageUnavailableError` with a credential-free cause: a `StorageTransientError` when\n\t * the driver recognizes it and the call belongs to an `attempt`. `applies` says whether the call commits on its\n\t * own; a failed call inside an open transaction applied nothing, whatever the driver says of the request.\n\t */\n\tprivate async call<T>(\n\t\toperation: () => Awaitable<T>,\n\t\tattempt?: Attempt,\n\t\tapplies = false,\n\t\tparams: readonly SqliteValue[] = [],\n\t): Promise<T> {\n\t\ttry {\n\t\t\treturn await operation();\n\t\t} catch (cause) {\n\t\t\tconst safe = redactCause(cause as StorageFailureCause, this.redact);\n\t\t\t// A payload too large for the backend fails the same way every time: permanent, never an outage (#4954).\n\t\t\tconst kind = payloadTooLargeKind(cause as StorageFailureCause);\n\t\t\tif (kind !== undefined) {\n\t\t\t\tthrow new StoragePayloadTooLargeError(\n\t\t\t\t\tthis.driver.payloadLimits?.[kind] ?? 0,\n\t\t\t\t\tkind === \"value\" ? largestValueBytes(params) : 0,\n\t\t\t\t\t{ kind, descriptor: this.descriptor, cause: safe },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (attempt !== undefined) {\n\t\t\t\tconst transient = this.driver.transientFailure?.(cause as StorageFailureCause);\n\t\t\t\tif (transient !== undefined) {\n\t\t\t\t\tconst failure = new StorageTransientError(\n\t\t\t\t\t\tthis.descriptor,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tcode: transient.code,\n\t\t\t\t\t\t\toutcome: applies || attempt.committing === true ? transient.outcome : \"not-applied\",\n\t\t\t\t\t\t\tattempts: attempt.number,\n\t\t\t\t\t\t\t...(transient.hop === undefined\n\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\thop: {\n\t\t\t\t\t\t\t\t\t\t\tname: this.redact(transient.hop.name),\n\t\t\t\t\t\t\t\t\t\t\tfailure: this.redact(transient.hop.failure),\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t},\n\t\t\t\t\t\tsafe,\n\t\t\t\t\t);\n\t\t\t\t\tif (\n\t\t\t\t\t\tattempt.transient === undefined ||\n\t\t\t\t\t\t(attempt.transient.outcome === \"not-applied\" && failure.outcome !== \"not-applied\")\n\t\t\t\t\t) {\n\t\t\t\t\t\tattempt.transient = failure;\n\t\t\t\t\t}\n\t\t\t\t\tthrow failure;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new StorageUnavailableError(this.descriptor, safe);\n\t\t}\n\t}\n\n\tprivate createExecutor(\n\t\tconnection: SqliteDriverExecutor,\n\t\tadmit: <T>(operation: (attempt: Attempt) => Promise<T>, sql?: string, script?: boolean) => Promise<T>,\n\t\tapplies: boolean,\n\t): SqliteExecutor {\n\t\tconst statement = (sql: string, params: readonly SqliteValue[]) => {\n\t\t\tconst bound = snapshotParams(params);\n\t\t\treturn admit(\n\t\t\t\tasync (attempt) => {\n\t\t\t\t\tconst invalidIndex = bound.findIndex((value) => typeof value === \"string\" && value.includes(\"\\0\"));\n\t\t\t\t\tif (invalidIndex !== -1) throw new StorageInvalidTextError(invalidIndex);\n\t\t\t\t\treturn this.call(() => connection.execute(sql, bound), attempt, applies, bound);\n\t\t\t\t},\n\t\t\t\tsql,\n\t\t\t\tfalse,\n\t\t\t);\n\t\t};\n\t\treturn {\n\t\t\texec: (sql) =>\n\t\t\t\tadmit((attempt) => this.call(() => connection.executeMultiple(sql), attempt, applies), sql, true),\n\t\t\trun: async (sql, ...params) => ({ changes: (await statement(sql, params)).changes }),\n\t\t\tget: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\tconst row = result.rows[0];\n\t\t\t\treturn row === undefined ? undefined : (normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t\tall: async <T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]) => {\n\t\t\t\tconst result = await statement(sql, params);\n\t\t\t\treturn result.rows.map((row) => normalizeRow(row, result.columns) as T);\n\t\t\t},\n\t\t};\n\t}\n\n\texec(sql: string): Promise<void> {\n\t\treturn this.executor.exec(sql);\n\t}\n\n\trun(sql: string, ...params: readonly SqliteValue[]) {\n\t\treturn this.executor.run(sql, ...params);\n\t}\n\n\tget<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T | undefined> {\n\t\treturn this.executor.get<T>(sql, ...params);\n\t}\n\n\tall<T extends SqliteRow>(sql: string, ...params: readonly SqliteValue[]): Promise<T[]> {\n\t\treturn this.executor.all<T>(sql, ...params);\n\t}\n\n\ttransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\toptions?: SqliteTransactionOptions,\n\t): Promise<T> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tlet replay: boolean;\n\t\tlet concurrency: TransactionConcurrency;\n\t\ttry {\n\t\t\treplay = retriesTransientFailures(options);\n\t\t\tconcurrency = transactionConcurrency(options);\n\t\t} catch (error) {\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tconst leading = this.driver.pipelinedTransactions === true ? leadingStatements(options?.leading) : [];\n\t\tconst begin: SqliteDriverTransactionOptions = {\n\t\t\tconcurrency,\n\t\t\t...(options?.lockWaitMs === undefined ? {} : { lockWaitMs: options.lockWaitMs }),\n\t\t\t...(options?.readOnly === true ? { readOnly: true } : {}),\n\t\t\t...(leading.length === 0 ? {} : { leading }),\n\t\t\t// Only when the callback makes nothing but calls that went with the start: a statement the facade held back is one.\n\t\t\t...(options?.leadingOnly === true && leading.length > 0 && leading.length === options.leading?.length\n\t\t\t\t? { leadingOnly: true }\n\t\t\t\t: {}),\n\t\t\t// `leading` holds the first statement whenever it holds any.\n\t\t\t...(options?.lockIfLeadingFinds === true && leading.length > 0 ? { lockIfLeadingFinds: true } : {}),\n\t\t\t...(options?.relaxedDurability === true && options.readOnly !== true ? { relaxedDurability: true } : {}),\n\t\t};\n\t\tconst run = () => this.retrying((attempt) => this.runTransaction(callback, attempt, begin), replay);\n\t\tconst concurrentWrites = this.driver.concurrentTransactions === true;\n\t\tif (concurrency.kind === \"serial\" || !concurrentWrites)\n\t\t\treturn this.queue.push(\n\t\t\t\trun,\n\t\t\t\tfalse,\n\t\t\t\ttransactionScope(concurrency, options?.readOnly === true, concurrentWrites),\n\t\t\t);\n\t\tconst result = run();\n\t\tconst settled = result.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn result;\n\t}\n\n\tprivate async runTransaction<T>(\n\t\tcallback: (transaction: SqliteExecutor) => Promise<T>,\n\t\tattempt: Attempt,\n\t\tbegin: SqliteDriverTransactionOptions,\n\t): Promise<T> {\n\t\tconst pipelined = this.driver.pipelinedTransactions === true;\n\t\tconst driverBegin: SqliteDriverTransactionOptions =\n\t\t\tpipelined && begin.leadingOnly === true\n\t\t\t\t? {\n\t\t\t\t\t\t...begin,\n\t\t\t\t\t\tonCommit: () => {\n\t\t\t\t\t\t\tattempt.committing = true;\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: begin;\n\t\tconst connection = await this.call(() => this.driver.beginTransaction(driverBegin), attempt);\n\t\tconst handleQueue = pipelined ? new PipelineQueue() : new CallQueue();\n\t\tlet active = true;\n\t\tlet result: T;\n\t\t/** Set once `finish` sent the callback's last calls: the transaction takes no more. */\n\t\tlet finished = false;\n\t\tconst handle = this.createExecutor(\n\t\t\tconnection,\n\t\t\t(operation, sql) =>\n\t\t\t\tactive && !finished\n\t\t\t\t\t? handleQueue.push(() => operation(attempt), sql)\n\t\t\t\t\t: Promise.reject(new StorageTransactionClosedError()),\n\t\t\tfalse,\n\t\t);\n\t\tif (pipelined) {\n\t\t\tofferSequences(handle, (sequence) => pipelineSequence(handle, sequence));\n\t\t\tofferFinish(handle, (statements) => {\n\t\t\t\tif (!active || finished) return false;\n\t\t\t\tif (statements.length > MAX_SEQUENCE_REQUEST_STATEMENTS || statements.some(hasInvalidText)) return false;\n\t\t\t\t// Their failures are the transaction's, reported once the commit is answered.\n\t\t\t\tfor (const statement of statements) {\n\t\t\t\t\tconst sent =\n\t\t\t\t\t\tstatement.script === true\n\t\t\t\t\t\t\t? handle.exec(statement.sql)\n\t\t\t\t\t\t\t: handle.run(statement.sql, ...statement.params);\n\t\t\t\t\tsent.catch(() => {});\n\t\t\t\t}\n\t\t\t\tfinished = true;\n\t\t\t\treturn true;\n\t\t\t});\n\t\t}\n\t\tconst close = () => this.call(() => connection.close?.());\n\t\t// Once the callback has returned, the commit's own failure decides whether the transaction runs again: a commit\n\t\t// that may have applied, or that failed for a reason the driver does not recognize, never does, whatever the\n\t\t// callback met before it. A committed transaction never runs again either.\n\t\tconst commit = () => {\n\t\t\tattempt.transient = undefined;\n\t\t\tattempt.committing = true;\n\t\t\treturn this.call(() => connection.commit(), attempt, true);\n\t\t};\n\t\tlet returned = false;\n\t\ttry {\n\t\t\tlet committing: Promise<void> | undefined;\n\t\t\ttry {\n\t\t\t\tresult = await callback(handle);\n\t\t\t\treturned = true;\n\t\t\t\t// A pipelined connection takes the commit behind statements the callback left unanswered, such as those sent by\n\t\t\t\t// `finish`, so locks they take are held for one round trip. The driver's commit fails when one of them failed,\n\t\t\t\t// so nothing commits then, and the first of them to fail is the failure. One that the server refused lets the\n\t\t\t\t// transaction run again, having written nothing; one whose connection broke may have committed, so it does not.\n\t\t\t\tif (pipelined) {\n\t\t\t\t\tcommitting = commit();\n\t\t\t\t\tcommitting.catch(() => {});\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tactive = false;\n\t\t\t\tawait handleQueue.drained();\n\t\t\t}\n\t\t\t// A read-only transaction on a connection of its own has its answer once its reads are answered: its commit only\n\t\t\t// ends the snapshot, so the connection goes back once the commit is answered, while the caller goes on.\n\t\t\tif (\n\t\t\t\tbegin.readOnly === true &&\n\t\t\t\t(this.driver.concurrentTransactions === true || concurrentReads(this.driver) !== undefined)\n\t\t\t) {\n\t\t\t\tthis.endInBackground(committing ?? commit(), connection, close);\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\tawait (committing ?? commit());\n\t\t} catch (cause) {\n\t\t\tlet failure = cause as StorageFailureCause;\n\t\t\tif (returned) {\n\t\t\t\tif (cause instanceof StorageTransientError) {\n\t\t\t\t\t// Keep the commit's own failure whenever the driver recognized it (especially an ambiguous outcome).\n\t\t\t\t\tattempt.transient = cause;\n\t\t\t\t} else {\n\t\t\t\t\t// A commit that came back as a rollback names no reason: the first unrecovered statement failure is\n\t\t\t\t\t// the transaction's failure, and whether it may run again is that failure's.\n\t\t\t\t\tconst unanswered = handleQueue instanceof PipelineQueue ? await handleQueue.firstFailure() : undefined;\n\t\t\t\t\tif (unanswered !== undefined) {\n\t\t\t\t\t\tfailure = unanswered as StorageFailureCause;\n\t\t\t\t\t\tattempt.transient = unanswered instanceof StorageTransientError ? unanswered : undefined;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tattempt.transient = undefined;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (!(cause instanceof StorageTransientError)) {\n\t\t\t\t// Recovered savepoint transient failures must not trigger retries for an unrelated callback failure.\n\t\t\t\tattempt.transient = await handleQueue.firstTransientFailure();\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tawait this.call(() => connection.rollback());\n\t\t\t} catch (rollbackCause) {\n\t\t\t\tfailure = new StorageRollbackError(failure, rollbackCause as StorageFailureCause);\n\t\t\t}\n\t\t\t// Cleanup must not replace a callback, commit, or rollback failure.\n\t\t\tawait close().catch(() => {});\n\t\t\tthrow failure;\n\t\t}\n\t\tawait close();\n\t\treturn result;\n\t}\n\n\t/**\n\t * Ends a read-only transaction whose reads were all answered once `committing` settles: rolls it back when the commit\n\t * failed, then closes it. Closing the database waits for it.\n\t */\n\tprivate endInBackground(\n\t\tcommitting: Promise<void>,\n\t\tconnection: SqliteDriverTransaction,\n\t\tclose: () => Promise<void>,\n\t): void {\n\t\tconst ended = committing\n\t\t\t.catch(() => this.call(() => connection.rollback()).catch(() => {}))\n\t\t\t.then(close)\n\t\t\t.catch(() => {});\n\t\tthis.concurrent.add(ended);\n\t\tvoid ended.then(() => this.concurrent.delete(ended));\n\t}\n\n\tprivate startReader(openReader: () => Awaitable<SqliteDriver>): Promise<SqliteDatabase> {\n\t\tif (this.closePromise) return Promise.reject(new StoreClosedError(this.descriptor));\n\t\tconst opening = this.call(openReader).then((driver) => {\n\t\t\tconst reader: DriverDatabase = new DriverDatabase(driver, this.redact, () => this.readers.delete(reader));\n\t\t\tthis.readers.add(reader);\n\t\t\tif (this.closePromise) throw new StoreClosedError(this.descriptor);\n\t\t\treturn reader;\n\t\t});\n\t\tconst settled = opening.then(\n\t\t\t() => {},\n\t\t\t() => {},\n\t\t);\n\t\tthis.concurrent.add(settled);\n\t\tvoid settled.then(() => this.concurrent.delete(settled));\n\t\treturn opening;\n\t}\n\n\tclose(): Promise<void> {\n\t\tconst closeReaders = () => Promise.allSettled([...this.readers].map((reader) => reader.close()));\n\t\t// Readers stop taking calls now; one that finished opening meanwhile is closed after the drain.\n\t\tthis.closePromise ??= Promise.all([this.queue.drained(), ...this.concurrent, closeReaders()])\n\t\t\t.then(closeReaders)\n\t\t\t.then(() => this.call(() => this.driver.close()))\n\t\t\t.finally(() => this.closed?.());\n\t\tfor (const wake of this.wakeRetries) wake();\n\t\treturn this.closePromise;\n\t}\n}\n\n/**\n * Wraps a SQLite-compatible driver as a `SqliteDatabase`. The facade queues operations in call order and keeps them\n * outside active transactions (on a driver that runs transactions concurrently, only operations that conflict wait for\n * each other), snapshots binary parameters at call time, rejects NUL text, returns safe-range integers\n * as numbers and blobs as `Uint8Array` copies, expires transaction handles when their callback settles, maps driver\n * failures to `StorageUnavailableError` with credentials redacted, and reports failed rollbacks with\n * `StorageRollbackError`. A failure the driver recognizes as transient is a `StorageTransientError`; a statement, a\n * batch, or a transaction whose options allow it runs again, up to `STORAGE_TRANSIENT_RETRY_ATTEMPTS` times in all,\n * while such a failure ended it before it wrote anything. Closing rejects new calls, stops those retries, drains\n * accepted work, then closes the driver once.\n */\nexport function createSqliteDatabase(driver: SqliteDriver): SqliteDatabase {\n\treturn new DriverDatabase(driver, driver.redact?.bind(driver) ?? ((text) => text));\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as schemaCatalog from "./schema-catalog.js";
|
|
2
|
+
/**
|
|
3
|
+
* `queueSqliteSchemaSetup` and `flushStorageSchemaSetups` of `schema-catalog.ts`, which copies loaded before #6709
|
|
4
|
+
* lack. Accessed from the module namespace so a process caught by an in-place update links cleanly and falls back to
|
|
5
|
+
* per-store setup transactions.
|
|
6
|
+
*/
|
|
7
|
+
const openBatch = schemaCatalog;
|
|
8
|
+
export const queueSqliteSchemaSetup = openBatch.queueSqliteSchemaSetup ?? (() => false);
|
|
9
|
+
export const flushStorageSchemaSetups = openBatch.flushStorageSchemaSetups ?? (async () => { });
|
|
10
|
+
//# sourceMappingURL=sqlite-open-batch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-open-batch.js","sourceRoot":"","sources":["../../../src/core/storage/sqlite-open-batch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,qBAAqB,CAAC;AAErD;;;;GAIG;AACH,MAAM,SAAS,GACd,aAAa,CAAC;AAIf,MAAM,CAAC,MAAM,sBAAsB,GAClC,SAAS,CAAC,sBAAsB,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,wBAAwB,GACpC,SAAS,CAAC,wBAAwB,IAAI,CAAC,KAAK,IAAI,EAAE,GAAE,CAAC,CAAC,CAAC","sourcesContent":["import * as schemaCatalog from \"./schema-catalog.js\";\n\n/**\n * `queueSqliteSchemaSetup` and `flushStorageSchemaSetups` of `schema-catalog.ts`, which copies loaded before #6709\n * lack. Accessed from the module namespace so a process caught by an in-place update links cleanly and falls back to\n * per-store setup transactions.\n */\nconst openBatch: Partial<Pick<typeof schemaCatalog, \"queueSqliteSchemaSetup\" | \"flushStorageSchemaSetups\">> =\n\tschemaCatalog;\n\nexport type { SqliteSchemaBatchContext, SqliteSchemaBatchSetup } from \"./schema-catalog.js\";\n\nexport const queueSqliteSchemaSetup: typeof schemaCatalog.queueSqliteSchemaSetup =\n\topenBatch.queueSqliteSchemaSetup ?? (() => false);\n\nexport const flushStorageSchemaSetups: typeof schemaCatalog.flushStorageSchemaSetups =\n\topenBatch.flushStorageSchemaSetups ?? (async () => {});\n"]}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11
|
|
9
|
+
const key = `${root.href}#0.10.11`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11
|
|
30
|
+
if (running === undefined || running.version === "0.10.11") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
@@ -6,7 +6,7 @@ try {
|
|
|
6
6
|
} catch (error) {
|
|
7
7
|
const root = new URL("../../", import.meta.url);
|
|
8
8
|
const releases = (globalThis[Symbol.for("atomic.in-place-update-release.v1")] ??= new Map());
|
|
9
|
-
const key = `${root.href}#0.10.11
|
|
9
|
+
const key = `${root.href}#0.10.11`;
|
|
10
10
|
let release = releases.get(key);
|
|
11
11
|
if (release === undefined) {
|
|
12
12
|
const current = (async () => {
|
|
@@ -27,8 +27,8 @@ try {
|
|
|
27
27
|
release = current;
|
|
28
28
|
}
|
|
29
29
|
const running = await release;
|
|
30
|
-
if (running === undefined || running.version === "0.10.11
|
|
31
|
-
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11
|
|
30
|
+
if (running === undefined || running.version === "0.10.11") throw error;
|
|
31
|
+
throw new Error((typeof running.name === "string" ? running.name : "atomic") + " was updated to 0.10.11 while this session was running; restart it to keep using session storage.", {
|
|
32
32
|
cause: error,
|
|
33
33
|
});
|
|
34
34
|
}
|