@mistriwork/engine 0.0.0 → 1.0.0-rc.9
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/LICENSE +21 -0
- package/README.md +16 -1
- package/dist/adapters/adapter.d.ts +693 -0
- package/dist/adapters/adapter.js +444 -0
- package/dist/adapters/cache/cacheStore.d.ts +75 -0
- package/dist/adapters/cache/cacheStore.js +160 -0
- package/dist/adapters/cache/resp.d.ts +52 -0
- package/dist/adapters/cache/resp.js +237 -0
- package/dist/adapters/commands/canonicalJson.d.ts +19 -0
- package/dist/adapters/commands/canonicalJson.js +154 -0
- package/dist/adapters/connect.d.ts +29 -0
- package/dist/adapters/connect.js +40 -0
- package/dist/adapters/connectionBudget.d.ts +101 -0
- package/dist/adapters/connectionBudget.js +128 -0
- package/dist/adapters/dbLatency.d.ts +35 -0
- package/dist/adapters/dbLatency.js +79 -0
- package/dist/adapters/epochCache.d.ts +50 -0
- package/dist/adapters/epochCache.js +85 -0
- package/dist/adapters/http/egress.d.ts +48 -0
- package/dist/adapters/http/egress.js +175 -0
- package/dist/adapters/http/httpAdapter.d.ts +71 -0
- package/dist/adapters/http/httpAdapter.js +512 -0
- package/dist/adapters/http/httpDescription.d.ts +32 -0
- package/dist/adapters/http/httpDescription.js +246 -0
- package/dist/adapters/http/openapi.d.ts +98 -0
- package/dist/adapters/http/openapi.js +487 -0
- package/dist/adapters/layoutRefusal.d.ts +24 -0
- package/dist/adapters/layoutRefusal.js +35 -0
- package/dist/adapters/net/networkPolicy.d.ts +44 -0
- package/dist/adapters/net/networkPolicy.js +123 -0
- package/dist/adapters/net/untrustedDatabase.d.ts +18 -0
- package/dist/adapters/net/untrustedDatabase.js +120 -0
- package/dist/adapters/poolAdmission.d.ts +43 -0
- package/dist/adapters/poolAdmission.js +184 -0
- package/dist/adapters/poolMetrics.d.ts +121 -0
- package/dist/adapters/poolMetrics.js +185 -0
- package/dist/adapters/postgres.d.ts +436 -0
- package/dist/adapters/postgres.js +1890 -0
- package/dist/adapters/postgresCatalog.d.ts +96 -0
- package/dist/adapters/postgresCatalog.js +387 -0
- package/dist/adapters/postgresCatalogDigest.d.ts +30 -0
- package/dist/adapters/postgresCatalogDigest.js +87 -0
- package/dist/adapters/postgresCatalogRows.d.ts +62 -0
- package/dist/adapters/postgresCatalogRows.js +37 -0
- package/dist/adapters/postgresDates.d.ts +1 -0
- package/dist/adapters/postgresDates.js +39 -0
- package/dist/adapters/postgresMaintenance.d.ts +33 -0
- package/dist/adapters/postgresMaintenance.js +179 -0
- package/dist/adapters/postgresPool.d.ts +255 -0
- package/dist/adapters/postgresPool.js +838 -0
- package/dist/adapters/postgresPooler.d.ts +28 -0
- package/dist/adapters/postgresPooler.js +267 -0
- package/dist/adapters/postgresReadCatalog.d.ts +31 -0
- package/dist/adapters/postgresReadCatalog.js +226 -0
- package/dist/adapters/postgresReadSnapshot.d.ts +46 -0
- package/dist/adapters/postgresReadSnapshot.js +133 -0
- package/dist/adapters/postgresSchemaEpoch.d.ts +24 -0
- package/dist/adapters/postgresSchemaEpoch.js +149 -0
- package/dist/adapters/postgresTransactionHandle.d.ts +173 -0
- package/dist/adapters/postgresTransactionHandle.js +524 -0
- package/dist/adapters/postgresValues.d.ts +30 -0
- package/dist/adapters/postgresValues.js +75 -0
- package/dist/adapters/replicas.d.ts +70 -0
- package/dist/adapters/replicas.js +208 -0
- package/dist/adapters/reservedSql.d.ts +38 -0
- package/dist/adapters/reservedSql.js +264 -0
- package/dist/adapters/rolePrivileges.d.ts +17 -0
- package/dist/adapters/rolePrivileges.js +22 -0
- package/dist/adapters/scoped/keyRows.d.ts +65 -0
- package/dist/adapters/scoped/keyRows.js +173 -0
- package/dist/adapters/scoped/postgresScopeCatalog.d.ts +16 -0
- package/dist/adapters/scoped/postgresScopeCatalog.js +117 -0
- package/dist/adapters/scoped/scopedCommandOperations.d.ts +5 -0
- package/dist/adapters/scoped/scopedCommandOperations.js +48 -0
- package/dist/adapters/scoped/scopedReads.d.ts +20 -0
- package/dist/adapters/scoped/scopedReads.js +174 -0
- package/dist/adapters/scoped/scopedTransaction.d.ts +89 -0
- package/dist/adapters/scoped/scopedTransaction.js +303 -0
- package/dist/adapters/scoped/sqliteScopeCatalog.d.ts +16 -0
- package/dist/adapters/scoped/sqliteScopeCatalog.js +241 -0
- package/dist/adapters/scoped/updateGuard.d.ts +3 -0
- package/dist/adapters/scoped/updateGuard.js +40 -0
- package/dist/adapters/serverSettings.d.ts +45 -0
- package/dist/adapters/serverSettings.js +46 -0
- package/dist/adapters/sqlite.d.ts +262 -0
- package/dist/adapters/sqlite.js +1434 -0
- package/dist/adapters/sqliteCostlyReads.d.ts +33 -0
- package/dist/adapters/sqliteCostlyReads.js +49 -0
- package/dist/adapters/sqliteDecimals.d.ts +22 -0
- package/dist/adapters/sqliteDecimals.js +57 -0
- package/dist/adapters/sqliteHandles.d.ts +43 -0
- package/dist/adapters/sqliteHandles.js +143 -0
- package/dist/adapters/sqliteStatementProcess.d.ts +29 -0
- package/dist/adapters/sqliteStatementProcess.js +131 -0
- package/dist/adapters/statementControl.d.ts +34 -0
- package/dist/adapters/statementControl.js +90 -0
- package/dist/adapters/storeHost.d.ts +130 -0
- package/dist/adapters/storeHost.js +13 -0
- package/dist/adapters/telemetry/drivers.d.ts +21 -0
- package/dist/adapters/telemetry/drivers.js +321 -0
- package/dist/adapters/telemetry/metrics.d.ts +63 -0
- package/dist/adapters/telemetry/metrics.js +122 -0
- package/dist/adapters/telemetry/otlp.d.ts +12 -0
- package/dist/adapters/telemetry/otlp.js +320 -0
- package/dist/adapters/telemetry/otlpEncode.d.ts +48 -0
- package/dist/adapters/telemetry/otlpEncode.js +366 -0
- package/dist/adapters/telemetry/otlpEnv.d.ts +1 -0
- package/dist/adapters/telemetry/otlpEnv.js +12 -0
- package/dist/adapters/telemetry/serverTiming.d.ts +83 -0
- package/dist/adapters/telemetry/serverTiming.js +503 -0
- package/dist/adapters/telemetry/start.d.ts +10 -0
- package/dist/adapters/telemetry/start.js +25 -0
- package/dist/adapters/telemetry/statement.d.ts +16 -0
- package/dist/adapters/telemetry/statement.js +134 -0
- package/dist/adapters/telemetry/trace.d.ts +127 -0
- package/dist/adapters/telemetry/trace.js +295 -0
- package/dist/adapters/writeAhead.d.ts +27 -0
- package/dist/adapters/writeAhead.js +46 -0
- package/dist/adapters/writeAttribution.d.ts +18 -0
- package/dist/adapters/writeAttribution.js +23 -0
- package/dist/adapters/writeCapture.d.ts +73 -0
- package/dist/adapters/writeCapture.js +20 -0
- package/dist/adapters/writeLanes.d.ts +94 -0
- package/dist/adapters/writeLanes.js +232 -0
- package/dist/engine.d.ts +15 -0
- package/dist/engine.js +13 -0
- package/dist/server/auth/credentials.d.ts +61 -0
- package/dist/server/auth/credentials.js +260 -0
- package/dist/server/cacheService.d.ts +50 -0
- package/dist/server/cacheService.js +110 -0
- package/dist/server/cli/args.d.ts +176 -0
- package/dist/server/cli/args.js +342 -0
- package/dist/server/cli/bin.d.ts +5 -0
- package/dist/server/cli/bin.js +66 -0
- package/dist/server/cli/browser.d.ts +15 -0
- package/dist/server/cli/browser.js +37 -0
- package/dist/server/cli/config.d.ts +50 -0
- package/dist/server/cli/config.js +206 -0
- package/dist/server/cli/startup.d.ts +36 -0
- package/dist/server/cli/startup.js +128 -0
- package/dist/server/cli/startupOptions.d.ts +63 -0
- package/dist/server/cli/startupOptions.js +143 -0
- package/dist/server/cli/subcommand.d.ts +28 -0
- package/dist/server/cli/subcommand.js +32 -0
- package/dist/server/cli/usage.d.ts +13 -0
- package/dist/server/cli/usage.js +31 -0
- package/dist/server/clientHttp.d.ts +184 -0
- package/dist/server/clientHttp.js +700 -0
- package/dist/server/clientSurface.d.ts +128 -0
- package/dist/server/clientSurface.js +182 -0
- package/dist/server/columnGrants.d.ts +103 -0
- package/dist/server/columnGrants.js +730 -0
- package/dist/server/compileCache.d.ts +1 -0
- package/dist/server/compileCache.js +30 -0
- package/dist/server/config/locations.d.ts +1 -0
- package/dist/server/config/locations.js +15 -0
- package/dist/server/configPaths.d.ts +7 -0
- package/dist/server/configPaths.js +34 -0
- package/dist/server/configSections.d.ts +64 -0
- package/dist/server/configSections.js +72 -0
- package/dist/server/connectionRedaction.d.ts +30 -0
- package/dist/server/connectionRedaction.js +77 -0
- package/dist/server/connections.d.ts +353 -0
- package/dist/server/connections.js +978 -0
- package/dist/server/constraints.d.ts +82 -0
- package/dist/server/constraints.js +169 -0
- package/dist/server/demo.d.ts +9 -0
- package/dist/server/demo.js +554 -0
- package/dist/server/devclient.d.ts +108 -0
- package/dist/server/devclient.js +361 -0
- package/dist/server/evidence.d.ts +55 -0
- package/dist/server/evidence.js +323 -0
- package/dist/server/hiddenColumns.d.ts +32 -0
- package/dist/server/hiddenColumns.js +238 -0
- package/dist/server/http/baselineHeaders.d.ts +24 -0
- package/dist/server/http/baselineHeaders.js +12 -0
- package/dist/server/http/captured.d.ts +35 -0
- package/dist/server/http/captured.js +73 -0
- package/dist/server/http/clock.d.ts +1 -0
- package/dist/server/http/clock.js +14 -0
- package/dist/server/http/connectionSource.d.ts +4 -0
- package/dist/server/http/connectionSource.js +48 -0
- package/dist/server/http/context.d.ts +189 -0
- package/dist/server/http/context.js +11 -0
- package/dist/server/http/crawlerText.d.ts +15 -0
- package/dist/server/http/crawlerText.js +32 -0
- package/dist/server/http/dataRoutes.d.ts +88 -0
- package/dist/server/http/dataRoutes.js +137 -0
- package/dist/server/http/door.d.ts +57 -0
- package/dist/server/http/door.js +39 -0
- package/dist/server/http/exportRoute.d.ts +15 -0
- package/dist/server/http/exportRoute.js +320 -0
- package/dist/server/http/firstPaint.d.ts +108 -0
- package/dist/server/http/firstPaint.js +262 -0
- package/dist/server/http/httpOperationRoutes.d.ts +11 -0
- package/dist/server/http/httpOperationRoutes.js +50 -0
- package/dist/server/http/pageReads.d.ts +20 -0
- package/dist/server/http/pageReads.js +205 -0
- package/dist/server/http/pageRoutes.d.ts +39 -0
- package/dist/server/http/pageRoutes.js +291 -0
- package/dist/server/http/probes.d.ts +22 -0
- package/dist/server/http/probes.js +27 -0
- package/dist/server/http/rateLimit.d.ts +131 -0
- package/dist/server/http/rateLimit.js +351 -0
- package/dist/server/http/readRoutes.d.ts +9 -0
- package/dist/server/http/readRoutes.js +131 -0
- package/dist/server/http/readRouting.d.ts +20 -0
- package/dist/server/http/readRouting.js +80 -0
- package/dist/server/http/recordCompose.d.ts +67 -0
- package/dist/server/http/recordCompose.js +167 -0
- package/dist/server/http/recordWrites.d.ts +89 -0
- package/dist/server/http/recordWrites.js +298 -0
- package/dist/server/http/refusalReport.d.ts +38 -0
- package/dist/server/http/refusalReport.js +63 -0
- package/dist/server/http/reply.d.ts +130 -0
- package/dist/server/http/reply.js +394 -0
- package/dist/server/http/requestOrigin.d.ts +11 -0
- package/dist/server/http/requestOrigin.js +8 -0
- package/dist/server/http/router.d.ts +45 -0
- package/dist/server/http/router.js +22 -0
- package/dist/server/http/serverCore.d.ts +68 -0
- package/dist/server/http/serverCore.js +177 -0
- package/dist/server/http/traceRequest.d.ts +30 -0
- package/dist/server/http/traceRequest.js +224 -0
- package/dist/server/http/trust.d.ts +261 -0
- package/dist/server/http/trust.js +472 -0
- package/dist/server/http/writeRefusal.d.ts +33 -0
- package/dist/server/http/writeRefusal.js +24 -0
- package/dist/server/httpConnection.d.ts +49 -0
- package/dist/server/httpConnection.js +170 -0
- package/dist/server/impact.d.ts +55 -0
- package/dist/server/impact.js +47 -0
- package/dist/server/journal.d.ts +134 -0
- package/dist/server/journal.js +398 -0
- package/dist/server/keysetReadHttp.d.ts +52 -0
- package/dist/server/keysetReadHttp.js +85 -0
- package/dist/server/layouts.d.ts +49 -0
- package/dist/server/layouts.js +192 -0
- package/dist/server/migrate/cli.d.ts +55 -0
- package/dist/server/migrate/cli.js +517 -0
- package/dist/server/migrate/database.d.ts +37 -0
- package/dist/server/migrate/database.js +247 -0
- package/dist/server/migrate/desired.d.ts +76 -0
- package/dist/server/migrate/desired.js +292 -0
- package/dist/server/migrate/files.d.ts +34 -0
- package/dist/server/migrate/files.js +141 -0
- package/dist/server/migrate/flyway.d.ts +7 -0
- package/dist/server/migrate/flyway.js +69 -0
- package/dist/server/migrate/history.d.ts +70 -0
- package/dist/server/migrate/history.js +211 -0
- package/dist/server/migrate/runner.d.ts +100 -0
- package/dist/server/migrate/runner.js +409 -0
- package/dist/server/migrate/snapshot.d.ts +30 -0
- package/dist/server/migrate/snapshot.js +239 -0
- package/dist/server/migrate/target.d.ts +33 -0
- package/dist/server/migrate/target.js +82 -0
- package/dist/server/openapiDraft.d.ts +25 -0
- package/dist/server/openapiDraft.js +171 -0
- package/dist/server/operations/diagnostics.d.ts +101 -0
- package/dist/server/operations/diagnostics.js +284 -0
- package/dist/server/operations/requestMetrics.d.ts +33 -0
- package/dist/server/operations/requestMetrics.js +94 -0
- package/dist/server/packageVersion.d.ts +1 -0
- package/dist/server/packageVersion.js +11 -0
- package/dist/server/poolConfig.d.ts +34 -0
- package/dist/server/poolConfig.js +114 -0
- package/dist/server/product.d.ts +20 -0
- package/dist/server/product.js +12 -0
- package/dist/server/recordHistoryOperations.d.ts +39 -0
- package/dist/server/recordHistoryOperations.js +43 -0
- package/dist/server/recordWriteOperations.d.ts +111 -0
- package/dist/server/recordWriteOperations.js +329 -0
- package/dist/server/resourceReadHttp.d.ts +81 -0
- package/dist/server/resourceReadHttp.js +606 -0
- package/dist/server/resourceReadOperations.d.ts +147 -0
- package/dist/server/resourceReadOperations.js +452 -0
- package/dist/server/scaffoldMachine.d.ts +54 -0
- package/dist/server/scaffoldMachine.js +184 -0
- package/dist/server/seed/cli.d.ts +20 -0
- package/dist/server/seed/cli.js +164 -0
- package/dist/server/seed/lexicon.d.ts +26 -0
- package/dist/server/seed/lexicon.js +585 -0
- package/dist/server/seed/seed.d.ts +70 -0
- package/dist/server/seed/seed.js +779 -0
- package/dist/server/seed/words.d.ts +21 -0
- package/dist/server/seed/words.js +164 -0
- package/dist/server/serverRequests.d.ts +6 -0
- package/dist/server/serverRequests.js +33 -0
- package/dist/server/serverTimeouts.d.ts +33 -0
- package/dist/server/serverTimeouts.js +32 -0
- package/dist/server/shapeonly.d.ts +32 -0
- package/dist/server/shapeonly.js +110 -0
- package/dist/server/startupWarnings.d.ts +32 -0
- package/dist/server/startupWarnings.js +92 -0
- package/dist/shared/addressParams.d.ts +28 -0
- package/dist/shared/addressParams.js +47 -0
- package/dist/shared/appCards.d.ts +123 -0
- package/dist/shared/appCards.js +385 -0
- package/dist/shared/appComponents.d.ts +177 -0
- package/dist/shared/appComponents.js +422 -0
- package/dist/shared/appDocuments.d.ts +43 -0
- package/dist/shared/appDocuments.js +131 -0
- package/dist/shared/appEmbeds.d.ts +21 -0
- package/dist/shared/appEmbeds.js +24 -0
- package/dist/shared/appIcons.d.ts +28 -0
- package/dist/shared/appIcons.js +223 -0
- package/dist/shared/appLinks.d.ts +17 -0
- package/dist/shared/appLinks.js +124 -0
- package/dist/shared/appListColumns.d.ts +3 -0
- package/dist/shared/appListColumns.js +66 -0
- package/dist/shared/appLocale.d.ts +36 -0
- package/dist/shared/appLocale.js +86 -0
- package/dist/shared/appMessages.d.ts +44 -0
- package/dist/shared/appMessages.js +78 -0
- package/dist/shared/appNoun.d.ts +21 -0
- package/dist/shared/appNoun.js +32 -0
- package/dist/shared/autoBucket.d.ts +98 -0
- package/dist/shared/autoBucket.js +305 -0
- package/dist/shared/autoValues.d.ts +25 -0
- package/dist/shared/autoValues.js +25 -0
- package/dist/shared/breakdown.d.ts +228 -0
- package/dist/shared/breakdown.js +557 -0
- package/dist/shared/breakdowntext.d.ts +41 -0
- package/dist/shared/breakdowntext.js +400 -0
- package/dist/shared/builtInThemes.d.ts +2 -0
- package/dist/shared/builtInThemes.js +771 -0
- package/dist/shared/chartSeparation.d.ts +11 -0
- package/dist/shared/chartSeparation.js +58 -0
- package/dist/shared/clauses.d.ts +22 -0
- package/dist/shared/clauses.js +97 -0
- package/dist/shared/columnCaption.d.ts +16 -0
- package/dist/shared/columnCaption.js +90 -0
- package/dist/shared/commandFieldPath.d.ts +2 -0
- package/dist/shared/commandFieldPath.js +7 -0
- package/dist/shared/commandWire.d.ts +26 -0
- package/dist/shared/commandWire.js +41 -0
- package/dist/shared/computed.d.ts +161 -0
- package/dist/shared/computed.js +378 -0
- package/dist/shared/computedParse.d.ts +13 -0
- package/dist/shared/computedParse.js +278 -0
- package/dist/shared/computedValue.d.ts +47 -0
- package/dist/shared/computedValue.js +191 -0
- package/dist/shared/connection.d.ts +30 -0
- package/dist/shared/connection.js +1 -0
- package/dist/shared/csv.d.ts +20 -0
- package/dist/shared/csv.js +63 -0
- package/dist/shared/dashLayout.d.ts +30 -0
- package/dist/shared/dashLayout.js +132 -0
- package/dist/shared/dashboardAsks.d.ts +93 -0
- package/dist/shared/dashboardAsks.js +129 -0
- package/dist/shared/dashboardTrend.d.ts +20 -0
- package/dist/shared/dashboardTrend.js +50 -0
- package/dist/shared/declaredReferences.d.ts +50 -0
- package/dist/shared/declaredReferences.js +202 -0
- package/dist/shared/definedFields.d.ts +63 -0
- package/dist/shared/definedFields.js +103 -0
- package/dist/shared/definedValues.d.ts +63 -0
- package/dist/shared/definedValues.js +184 -0
- package/dist/shared/displayDefaults.d.ts +135 -0
- package/dist/shared/displayDefaults.js +529 -0
- package/dist/shared/dueDate.d.ts +6 -0
- package/dist/shared/dueDate.js +6 -0
- package/dist/shared/duration.d.ts +4 -0
- package/dist/shared/duration.js +23 -0
- package/dist/shared/fileBounds.d.ts +9 -0
- package/dist/shared/fileBounds.js +9 -0
- package/dist/shared/filter.d.ts +217 -0
- package/dist/shared/filter.js +305 -0
- package/dist/shared/firstPaint.d.ts +24 -0
- package/dist/shared/firstPaint.js +33 -0
- package/dist/shared/form.d.ts +21 -0
- package/dist/shared/form.js +25 -0
- package/dist/shared/formValues.d.ts +104 -0
- package/dist/shared/formValues.js +352 -0
- package/dist/shared/funnel.d.ts +45 -0
- package/dist/shared/funnel.js +108 -0
- package/dist/shared/httpOperations.d.ts +48 -0
- package/dist/shared/httpOperations.js +9 -0
- package/dist/shared/iconGlyphs.d.ts +4 -0
- package/dist/shared/iconGlyphs.js +151 -0
- package/dist/shared/iconWeights.d.ts +3 -0
- package/dist/shared/iconWeights.js +162 -0
- package/dist/shared/imageWidths.d.ts +32 -0
- package/dist/shared/imageWidths.js +38 -0
- package/dist/shared/keysetPage.d.ts +62 -0
- package/dist/shared/keysetPage.js +159 -0
- package/dist/shared/like.d.ts +20 -0
- package/dist/shared/like.js +29 -0
- package/dist/shared/listEmpty.d.ts +12 -0
- package/dist/shared/listEmpty.js +36 -0
- package/dist/shared/listFilters.d.ts +28 -0
- package/dist/shared/listFilters.js +84 -0
- package/dist/shared/listPresentations.d.ts +199 -0
- package/dist/shared/listPresentations.js +7 -0
- package/dist/shared/listQuestion.d.ts +52 -0
- package/dist/shared/listQuestion.js +137 -0
- package/dist/shared/lookPalettes.d.ts +62 -0
- package/dist/shared/lookPalettes.js +306 -0
- package/dist/shared/maskQuoted.d.ts +24 -0
- package/dist/shared/maskQuoted.js +48 -0
- package/dist/shared/mentionLabel.d.ts +19 -0
- package/dist/shared/mentionLabel.js +38 -0
- package/dist/shared/mentionLookup.d.ts +17 -0
- package/dist/shared/mentionLookup.js +64 -0
- package/dist/shared/menuCounts.d.ts +16 -0
- package/dist/shared/menuCounts.js +74 -0
- package/dist/shared/model.d.ts +79 -0
- package/dist/shared/model.js +153 -0
- package/dist/shared/money.d.ts +44 -0
- package/dist/shared/money.js +81 -0
- package/dist/shared/moneyEntry.d.ts +7 -0
- package/dist/shared/moneyEntry.js +27 -0
- package/dist/shared/mount.d.ts +118 -0
- package/dist/shared/mount.js +248 -0
- package/dist/shared/niceTicks.d.ts +26 -0
- package/dist/shared/niceTicks.js +50 -0
- package/dist/shared/order.d.ts +59 -0
- package/dist/shared/order.js +133 -0
- package/dist/shared/page.d.ts +135 -0
- package/dist/shared/page.js +1187 -0
- package/dist/shared/pageAnatomy.d.ts +99 -0
- package/dist/shared/pageAnatomy.js +370 -0
- package/dist/shared/pageConfig.d.ts +25 -0
- package/dist/shared/pageConfig.js +1308 -0
- package/dist/shared/pageEmptyActions.d.ts +12 -0
- package/dist/shared/pageEmptyActions.js +20 -0
- package/dist/shared/pageLayouts.d.ts +72 -0
- package/dist/shared/pageLayouts.js +205 -0
- package/dist/shared/pageModel.d.ts +785 -0
- package/dist/shared/pageModel.js +121 -0
- package/dist/shared/pagePaths.d.ts +180 -0
- package/dist/shared/pagePaths.js +869 -0
- package/dist/shared/pagePlans.d.ts +52 -0
- package/dist/shared/pagePlans.js +108 -0
- package/dist/shared/pageRoutes.d.ts +9 -0
- package/dist/shared/pageRoutes.js +9 -0
- package/dist/shared/query.d.ts +166 -0
- package/dist/shared/query.js +1302 -0
- package/dist/shared/queryDates.d.ts +12 -0
- package/dist/shared/queryDates.js +101 -0
- package/dist/shared/queryOperands.d.ts +99 -0
- package/dist/shared/queryOperands.js +131 -0
- package/dist/shared/reads.d.ts +103 -0
- package/dist/shared/reads.js +154 -0
- package/dist/shared/recordLabel.d.ts +51 -0
- package/dist/shared/recordLabel.js +123 -0
- package/dist/shared/recordReadKeys.d.ts +30 -0
- package/dist/shared/recordReadKeys.js +51 -0
- package/dist/shared/recordReads.d.ts +268 -0
- package/dist/shared/recordReads.js +368 -0
- package/dist/shared/recordview.d.ts +198 -0
- package/dist/shared/recordview.js +356 -0
- package/dist/shared/referenceModel.d.ts +58 -0
- package/dist/shared/referenceModel.js +194 -0
- package/dist/shared/refusal.d.ts +64 -0
- package/dist/shared/refusal.js +144 -0
- package/dist/shared/relatedCreate.d.ts +30 -0
- package/dist/shared/relatedCreate.js +162 -0
- package/dist/shared/resourceHttp.d.ts +464 -0
- package/dist/shared/resourceHttp.js +1 -0
- package/dist/shared/richText.d.ts +85 -0
- package/dist/shared/richText.js +305 -0
- package/dist/shared/rollups.d.ts +143 -0
- package/dist/shared/rollups.js +64 -0
- package/dist/shared/rowScope.d.ts +72 -0
- package/dist/shared/rowScope.js +376 -0
- package/dist/shared/runtimeTables.d.ts +44 -0
- package/dist/shared/runtimeTables.js +79 -0
- package/dist/shared/schema.d.ts +523 -0
- package/dist/shared/schema.js +627 -0
- package/dist/shared/schematext.d.ts +38 -0
- package/dist/shared/schematext.js +101 -0
- package/dist/shared/scopeCatalog.d.ts +29 -0
- package/dist/shared/scopeCatalog.js +468 -0
- package/dist/shared/servedApp.d.ts +681 -0
- package/dist/shared/servedApp.js +45 -0
- package/dist/shared/sessionLease.d.ts +34 -0
- package/dist/shared/sessionLease.js +3 -0
- package/dist/shared/shape.d.ts +55 -0
- package/dist/shared/shape.js +168 -0
- package/dist/shared/slug.d.ts +1 -0
- package/dist/shared/slug.js +12 -0
- package/dist/shared/sortText.d.ts +14 -0
- package/dist/shared/sortText.js +26 -0
- package/dist/shared/sqlRelation.d.ts +4 -0
- package/dist/shared/sqlRelation.js +8 -0
- package/dist/shared/sqlsaved.d.ts +44 -0
- package/dist/shared/sqlsaved.js +63 -0
- package/dist/shared/stitchedPaths.d.ts +27 -0
- package/dist/shared/stitchedPaths.js +38 -0
- package/dist/shared/structuredFilter.d.ts +22 -0
- package/dist/shared/structuredFilter.js +1 -0
- package/dist/shared/subtitlePath.d.ts +20 -0
- package/dist/shared/subtitlePath.js +24 -0
- package/dist/shared/suggest.d.ts +18 -0
- package/dist/shared/suggest.js +59 -0
- package/dist/shared/tableSizing.d.ts +4 -0
- package/dist/shared/tableSizing.js +9 -0
- package/dist/shared/tagLists.d.ts +57 -0
- package/dist/shared/tagLists.js +34 -0
- package/dist/shared/textRules.d.ts +54 -0
- package/dist/shared/textRules.js +133 -0
- package/dist/shared/theme.d.ts +94 -0
- package/dist/shared/theme.js +800 -0
- package/dist/shared/themeColor.d.ts +34 -0
- package/dist/shared/themeColor.js +109 -0
- package/dist/shared/themeFaces.d.ts +30 -0
- package/dist/shared/themeFaces.js +42 -0
- package/dist/shared/themeInk.d.ts +20 -0
- package/dist/shared/themeInk.js +52 -0
- package/dist/shared/themeLooks.d.ts +9 -0
- package/dist/shared/themeLooks.js +572 -0
- package/dist/shared/themeParts.d.ts +26 -0
- package/dist/shared/themeParts.js +71 -0
- package/dist/shared/themePartsCheck.d.ts +21 -0
- package/dist/shared/themePartsCheck.js +91 -0
- package/dist/shared/themePresets.d.ts +85 -0
- package/dist/shared/themePresets.js +139 -0
- package/dist/shared/themeRecipeWords.d.ts +156 -0
- package/dist/shared/themeRecipeWords.js +156 -0
- package/dist/shared/themeRecipes.d.ts +213 -0
- package/dist/shared/themeRecipes.js +234 -0
- package/dist/shared/themeResolve.d.ts +55 -0
- package/dist/shared/themeResolve.js +52 -0
- package/dist/shared/themeTokens.d.ts +107 -0
- package/dist/shared/themeTokens.js +116 -0
- package/dist/shared/themeType.d.ts +38 -0
- package/dist/shared/themeType.js +205 -0
- package/dist/shared/unitWord.d.ts +4 -0
- package/dist/shared/unitWord.js +37 -0
- package/dist/shared/view.d.ts +195 -0
- package/dist/shared/view.js +987 -0
- package/dist/shared/viewLabels.d.ts +47 -0
- package/dist/shared/viewLabels.js +459 -0
- package/dist/shared/viewPaths.d.ts +248 -0
- package/dist/shared/viewPaths.js +294 -0
- package/dist/shared/viewtext.d.ts +57 -0
- package/dist/shared/viewtext.js +282 -0
- package/dist/shared/vocabulary.d.ts +71 -0
- package/dist/shared/vocabulary.js +249 -0
- package/dist/shared/weekStart.d.ts +7 -0
- package/dist/shared/weekStart.js +36 -0
- package/mark.svg +1 -0
- package/package.json +262 -3
- package/schema/model.d.ts +298 -0
- package/schema/theme.d.ts +587 -0
|
@@ -0,0 +1,693 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a database adapter has to provide, and — just as importantly — what it
|
|
3
|
+
* is not allowed to decide.
|
|
4
|
+
*
|
|
5
|
+
* An adapter reads a dialect's catalog and runs parameterised reads. It does
|
|
6
|
+
* not build WHERE clauses from user input, does not decide what a row is
|
|
7
|
+
* called, and never returns SQL for something upstream to concatenate. Every
|
|
8
|
+
* value the user supplies reaches the database as a bound parameter, because
|
|
9
|
+
* a browsing tool that interpolates a filter into SQL is a SQL injection
|
|
10
|
+
* vulnerability with a nice front end.
|
|
11
|
+
*/
|
|
12
|
+
import { type DatabaseSchema, type Order, type TableMeta } from '../shared/schema.js';
|
|
13
|
+
import type { CompiledColumn, CompiledJoin, ViewDef } from '../shared/view.js';
|
|
14
|
+
import type { BreakdownDef, CompiledMeasure } from '../shared/breakdown.js';
|
|
15
|
+
import type { RowScope } from '../shared/rowScope.js';
|
|
16
|
+
import type { QueryResult } from '../shared/reads.js';
|
|
17
|
+
import { type Filter, type SqlFragment, type SqlStyle } from '../shared/filter.js';
|
|
18
|
+
import type { PoolRoleStats } from './poolMetrics.js';
|
|
19
|
+
export { ANSI_STYLE, OPS, POSTGRES_STYLE, buildWhere, type Condition, type Filter, type Op, type SqlFragment, type SqlStyle, } from '../shared/filter.js';
|
|
20
|
+
export { DEFAULT_LIMIT, ESTIMATE_ABOVE, MAX_LIMIT, clampLimit, clampOffset, countStatement, countEachStatement, countEachRows, type CountResult, type QueryResult, } from '../shared/reads.js';
|
|
21
|
+
/** One count of `Adapter.countEach`: a table, and the rows of it to count. */
|
|
22
|
+
export interface CountItem {
|
|
23
|
+
table: string;
|
|
24
|
+
filter?: Filter;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether one scan can answer every item (countEachStatement's `together`):
|
|
28
|
+
* they all read one table, and the catalog says that table holds no more
|
|
29
|
+
* rows than the bound — so reading all of it costs no more than one bounded
|
|
30
|
+
* count would. Unbounded, one scan always beats one per item.
|
|
31
|
+
*/
|
|
32
|
+
export declare function countsTogether(schema: DatabaseSchema | null, items: readonly CountItem[], limit?: number): boolean;
|
|
33
|
+
export { Refusal } from '../shared/refusal.js';
|
|
34
|
+
/**
|
|
35
|
+
* A read's ORDER BY, or nothing: each column by its value, or by its declared
|
|
36
|
+
* vocabulary where the catalog has one over text (shared/schema.ts
|
|
37
|
+
* `declaredOrder`), its values bound from `startIndex`. Every adapter's plain
|
|
38
|
+
* read and a scoped read say it the same way, so a list sorts alike on all
|
|
39
|
+
* three engines.
|
|
40
|
+
*/
|
|
41
|
+
export declare function orderClause(order: readonly Order[] | undefined, table: TableMeta | undefined, style: SqlStyle, startIndex: number, quote?: (column: string) => string): SqlFragment;
|
|
42
|
+
declare const conflictBrand: unique symbol;
|
|
43
|
+
/** A conditional update matched no row and did not apply its proposed values. */
|
|
44
|
+
export declare class WriteConflict extends Error {
|
|
45
|
+
readonly [conflictBrand] = true;
|
|
46
|
+
constructor();
|
|
47
|
+
}
|
|
48
|
+
/** The native class, or a branded twin from another copy of the package. */
|
|
49
|
+
export declare function isWriteConflict(error: unknown): error is WriteConflict;
|
|
50
|
+
/** A transaction acknowledgement could not establish whether writes landed.
|
|
51
|
+
* Never inherit Refusal or driver constraint codes: callers must not turn a
|
|
52
|
+
* failed rollback of a rejected operation into permission to retry it. */
|
|
53
|
+
export declare class TransactionOutcomeUnknown extends Error {
|
|
54
|
+
readonly outcome: 'unknown';
|
|
55
|
+
constructor(cause: unknown);
|
|
56
|
+
}
|
|
57
|
+
export interface QueryRequest {
|
|
58
|
+
table: string;
|
|
59
|
+
filter?: Filter;
|
|
60
|
+
/** Column names to return. Empty means the adapter picks a sensible set. */
|
|
61
|
+
columns?: string[];
|
|
62
|
+
orderBy?: {
|
|
63
|
+
column: string;
|
|
64
|
+
direction: 'asc' | 'desc';
|
|
65
|
+
}[];
|
|
66
|
+
limit: number;
|
|
67
|
+
offset: number;
|
|
68
|
+
/** Binary columns come back as their bytes, not the `<n bytes>` label: a file download's read, never a grid's. */
|
|
69
|
+
binary?: true;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* What running a view returns.
|
|
73
|
+
*
|
|
74
|
+
* `columns` is the ordered output names, as in `QueryResult`; `resolved`
|
|
75
|
+
* carries what each of them *is* — the table and column it came from, its
|
|
76
|
+
* type, and how many references were followed to reach it. The client needs
|
|
77
|
+
* that to group a hundred fields by their table and to render a date as a
|
|
78
|
+
* date, and re-deriving it in the browser would mean a second path resolver.
|
|
79
|
+
*/
|
|
80
|
+
export interface ViewResult extends QueryResult {
|
|
81
|
+
resolved: CompiledColumn[];
|
|
82
|
+
joins: CompiledJoin[];
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What a breakdown returns.
|
|
86
|
+
*
|
|
87
|
+
* `groups` rather than `rows` everywhere else in this file would be nicer and
|
|
88
|
+
* is not worth the split: the shape is a result set, the grid renders it, and
|
|
89
|
+
* `columns` still names the output. What is different is `resolved`, which
|
|
90
|
+
* says of each column whether it is a key or a measure — the interface needs
|
|
91
|
+
* that to right-align a count and to know that a key is clickable back into
|
|
92
|
+
* the rows behind it.
|
|
93
|
+
*/
|
|
94
|
+
export interface BreakdownResult extends QueryResult {
|
|
95
|
+
resolved: CompiledMeasure[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A statement the user typed, run as they typed it.
|
|
99
|
+
*
|
|
100
|
+
* This is the one place the tool hands the database text it did not build,
|
|
101
|
+
* which makes every guarantee elsewhere in this file inapplicable: there is no
|
|
102
|
+
* `Filter` to compile, no identifier to check against the catalog, no value to
|
|
103
|
+
* bind. The safety argument has to be made somewhere else entirely.
|
|
104
|
+
*
|
|
105
|
+
* It is made in three places, none of which involve reading the statement:
|
|
106
|
+
*
|
|
107
|
+
* 1. **The connection cannot write.** A read runs inside a transaction opened
|
|
108
|
+
* READ ONLY, which Postgres will not let a statement promote
|
|
109
|
+
* from the inside; SQLite's handle is opened read-only at the file level.
|
|
110
|
+
* A `DELETE` fails with the database's own error, not with our guess about
|
|
111
|
+
* what a `DELETE` looks like.
|
|
112
|
+
* 2. **One statement per call.** Stacking is refused before anything runs, so
|
|
113
|
+
* `SELECT 1; DROP TABLE customer` cannot smuggle a second statement past a
|
|
114
|
+
* check aimed at the first.
|
|
115
|
+
* 3. **The result is bounded.** The statement is wrapped in a subquery with a
|
|
116
|
+
* LIMIT, so a bare `SELECT * FROM huge` returns a page rather than a heap.
|
|
117
|
+
*
|
|
118
|
+
* Writing is possible and is a different request: `write: true`, refused unless
|
|
119
|
+
* the connection is marked writable, and run on the write handle.
|
|
120
|
+
*/
|
|
121
|
+
export interface SqlRequest {
|
|
122
|
+
text: string;
|
|
123
|
+
/** Rows to return. Bounded by `clampLimit` like every other read. */
|
|
124
|
+
limit: number;
|
|
125
|
+
/** Run on the write handle. Refused unless the connection allows it. */
|
|
126
|
+
write?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* A cap below the default for this one statement, in milliseconds, held
|
|
129
|
+
* between a floor and STATEMENT_TIMEOUT_MS (statementControl.ts). Never
|
|
130
|
+
* raises the cap; politeness only lowers.
|
|
131
|
+
*
|
|
132
|
+
* Postgres sets it inside the statement's transaction. SQLite has no statement timeout, so it keeps
|
|
133
|
+
* this one only for a read a caller can stop — one run inside
|
|
134
|
+
* `withCancellation` — which it runs in a process it can kill; a read on
|
|
135
|
+
* the in-process handle cannot be interrupted.
|
|
136
|
+
*/
|
|
137
|
+
timeoutMs?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Refuse a statement that touches tablewalk's own runtime or sign-in tables
|
|
140
|
+
* before it runs (reservedSql.ts): the lexical check, then the engine's own
|
|
141
|
+
* account of what the statement reads where it gives one. A statement the
|
|
142
|
+
* check cannot read is refused rather than run.
|
|
143
|
+
*/
|
|
144
|
+
refuseReserved?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface SqlResult {
|
|
147
|
+
columns: string[];
|
|
148
|
+
/**
|
|
149
|
+
* Rows as arrays, not objects.
|
|
150
|
+
*
|
|
151
|
+
* `SELECT id, id FROM t` returns two columns with one name. An object keyed
|
|
152
|
+
* by column name can only hold one of them, so the second silently replaces
|
|
153
|
+
* the first and the grid shows a column of values from somewhere else. The
|
|
154
|
+
* adapters disagree about this today — SQLite builds rows with `Object.keys`
|
|
155
|
+
* and loses the duplicate outright, Postgres keeps both in the
|
|
156
|
+
* header and one in the row — and positional rows are the only shape that
|
|
157
|
+
* cannot lose data whatever the driver does.
|
|
158
|
+
*/
|
|
159
|
+
rows: unknown[][];
|
|
160
|
+
ms: number;
|
|
161
|
+
/** A row beyond the limit existed: there is more than is being shown. */
|
|
162
|
+
truncated: boolean;
|
|
163
|
+
/** The LIMIT wrap applied. False means the database did the whole job. */
|
|
164
|
+
bounded: boolean;
|
|
165
|
+
/** Rows changed, for a write. Absent for a read. */
|
|
166
|
+
affected?: number;
|
|
167
|
+
sql: {
|
|
168
|
+
text: string;
|
|
169
|
+
params: unknown[];
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
export interface ExplainRequest {
|
|
173
|
+
text: string;
|
|
174
|
+
/** Bound values for the statement's placeholders, when it has them. */
|
|
175
|
+
params?: unknown[];
|
|
176
|
+
/** As on SqlRequest: refuse a statement that touches tablewalk's own tables. */
|
|
177
|
+
refuseReserved?: boolean;
|
|
178
|
+
}
|
|
179
|
+
export interface ExplainResult {
|
|
180
|
+
/** The plan, one line per node, in the engine's own words. */
|
|
181
|
+
plan: string[];
|
|
182
|
+
ms: number;
|
|
183
|
+
}
|
|
184
|
+
export interface ColumnProfile {
|
|
185
|
+
column: string;
|
|
186
|
+
type: string;
|
|
187
|
+
/** The share of rows where this column is null, 0..1. */
|
|
188
|
+
nullFrac?: number;
|
|
189
|
+
/** Distinct non-null values — estimated where the engine estimates. */
|
|
190
|
+
distinct?: number;
|
|
191
|
+
/** The edges of the range, as the engine reports them. Approximate where
|
|
192
|
+
the numbers come from a sample rather than a scan. */
|
|
193
|
+
min?: unknown;
|
|
194
|
+
max?: unknown;
|
|
195
|
+
/** The values that repeat most, each with its share of rows. Absent when
|
|
196
|
+
nothing repeats — a unique column's most common value is noise. */
|
|
197
|
+
common?: Array<{
|
|
198
|
+
value: unknown;
|
|
199
|
+
frac: number;
|
|
200
|
+
}>;
|
|
201
|
+
}
|
|
202
|
+
export interface ProfileResult {
|
|
203
|
+
table: string;
|
|
204
|
+
/** The table's row count. An estimate where `source` says statistics;
|
|
205
|
+
exact otherwise — a sample still counts the whole table first. */
|
|
206
|
+
rows?: number;
|
|
207
|
+
columns: ColumnProfile[];
|
|
208
|
+
/** What the answer cost to make: `statistics` read numbers the planner
|
|
209
|
+
already keeps (free, sample-based, stale until the next ANALYZE);
|
|
210
|
+
`scan` computed them by reading the table; `sample` read a bounded
|
|
211
|
+
slice of a table too large to scan while a synchronous driver holds
|
|
212
|
+
the process. */
|
|
213
|
+
source: 'statistics' | 'scan' | 'sample';
|
|
214
|
+
/** How many rows the fractions are relative to, when `source` is sample. */
|
|
215
|
+
sampled?: number;
|
|
216
|
+
/**
|
|
217
|
+
* Set when value-bearing fields were withheld — a shape-only connection.
|
|
218
|
+
*
|
|
219
|
+
* Present rather than implied: a profile with no `min` and no `common`
|
|
220
|
+
* looks identical to a profile of a column that has neither, and a reader
|
|
221
|
+
* cannot tell "nothing repeats here" from "you are not allowed to know".
|
|
222
|
+
*/
|
|
223
|
+
redacted?: string;
|
|
224
|
+
ms: number;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* When a profile stops scanning and starts sampling.
|
|
228
|
+
*
|
|
229
|
+
* Overridable per call so a test can exercise the sampling path against a
|
|
230
|
+
* five-hundred-row fixture instead of manufacturing a million rows.
|
|
231
|
+
*/
|
|
232
|
+
export interface ProfileLimits {
|
|
233
|
+
/** Scan whole up to this many rows. */
|
|
234
|
+
scanAtMost?: number;
|
|
235
|
+
/** Aim for roughly this many rows when sampling. */
|
|
236
|
+
sampleSize?: number;
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Refuse anything that is more than one statement.
|
|
240
|
+
*
|
|
241
|
+
* Not a SQL parser and not trying to be one — it answers exactly one question,
|
|
242
|
+
* "is there a second statement here", and it answers it by scanning for a
|
|
243
|
+
* semicolon that has something after it. Everything that can contain a
|
|
244
|
+
* semicolon harmlessly is skipped: quoted strings and names, line comments,
|
|
245
|
+
* block comments, and Postgres's dollar-quoted bodies, which is how a function
|
|
246
|
+
* definition carries semicolons without being several statements.
|
|
247
|
+
*
|
|
248
|
+
* Each of those is read the way the dialect's own lexer reads it, because a
|
|
249
|
+
* scanner that ends a string or a comment somewhere other than where the
|
|
250
|
+
* database does can hide a real `;`: Postgres nests block comments, honours
|
|
251
|
+
* backslash escapes in an E'…' string, and reads `x$$` as one identifier
|
|
252
|
+
* rather than an opening dollar-quote. It is not the only line: Postgres runs
|
|
253
|
+
* user text on the extended protocol (postgres.ts runSql), which carries one
|
|
254
|
+
* statement, and SQLite's prepare compiles only the first.
|
|
255
|
+
*
|
|
256
|
+
* Stacking is refused rather than truncated. Running the first half of what
|
|
257
|
+
* someone typed and discarding the rest is worse than refusing both: they
|
|
258
|
+
* asked for two things and would be told about neither.
|
|
259
|
+
*
|
|
260
|
+
* Returns null when the text is a single statement, or the reason it is not.
|
|
261
|
+
*/
|
|
262
|
+
export declare function refuseStacked(text: string, dialect?: DatabaseSchema['dialect']): string | null;
|
|
263
|
+
/**
|
|
264
|
+
* Output column names, with collisions given a suffix.
|
|
265
|
+
*
|
|
266
|
+
* `SELECT id, id FROM t` names both columns `id`. Left alone, the grid draws
|
|
267
|
+
* one header twice and nothing says which value belongs to which. The suffix
|
|
268
|
+
* is the same answer `compileView` gives an explicit collision, for the same
|
|
269
|
+
* reason: one column quietly standing in for two is worse than an ugly name.
|
|
270
|
+
*/
|
|
271
|
+
export declare function dedupe(names: string[]): string[];
|
|
272
|
+
/** A statement with its trailing semicolon and surrounding space removed. */
|
|
273
|
+
export declare function trimStatement(text: string): string;
|
|
274
|
+
/**
|
|
275
|
+
* Wrap a statement so it cannot return more rows than asked for.
|
|
276
|
+
*
|
|
277
|
+
* `clampLimit` is the invariant everywhere else in this file, and it has no
|
|
278
|
+
* application point in a statement this process did not build — there is no
|
|
279
|
+
* request object to clamp. Wrapping is the equivalent: the database is asked
|
|
280
|
+
* for a bounded result rather than trusted to have been asked politely.
|
|
281
|
+
*
|
|
282
|
+
* One more row than the caller wanted, so "there is more than this" is known
|
|
283
|
+
* without a second query — the same trick `runView` uses.
|
|
284
|
+
*
|
|
285
|
+
* The limit is interpolated rather than bound, which is the one deliberate
|
|
286
|
+
* exception to the rule that nothing is interpolated. It is an integer this
|
|
287
|
+
* process computed from `clampLimit`, never a value that came from outside,
|
|
288
|
+
* and it is asserted to be one before it is used. Binding it would need a
|
|
289
|
+
* dialect-specific placeholder here, which is a lot of machinery to parameterise a number we
|
|
290
|
+
* chose ourselves.
|
|
291
|
+
*
|
|
292
|
+
* Not every statement can be wrapped — `EXPLAIN`, `PRAGMA`, a `WITH` that ends
|
|
293
|
+
* in `INSERT … RETURNING` — so the caller is told whether it applied and can
|
|
294
|
+
* fall back to running the statement bare and saying so.
|
|
295
|
+
*/
|
|
296
|
+
export declare function boundStatement(text: string, limit: number): string;
|
|
297
|
+
/**
|
|
298
|
+
* Refuse a statement that `EXPLAIN` would *execute* rather than plan.
|
|
299
|
+
*
|
|
300
|
+
* `EXPLAIN` is offered as the planner's account of a statement without
|
|
301
|
+
* running it. `EXPLAIN ANALYZE …` (Postgres) and the option
|
|
302
|
+
* form `EXPLAIN (ANALYZE) …` run the statement to measure it, so text that
|
|
303
|
+
* begins with `analyze` or `(` turned a plan-only tool into an execute tool.
|
|
304
|
+
* Both sit inside a read-only transaction, so no row could be written — but
|
|
305
|
+
* a `pg_sleep(60)` or a full scan runs all the same, and the contract said
|
|
306
|
+
* it would not. Leading comments are skipped so the check reads the
|
|
307
|
+
* statement, not a note above it.
|
|
308
|
+
*/
|
|
309
|
+
export declare function refuseAnalyze(text: string): string | null;
|
|
310
|
+
/**
|
|
311
|
+
* Whether a statement is worth trying to wrap.
|
|
312
|
+
*
|
|
313
|
+
* A conservative first token test, and deliberately not a parse. Getting this
|
|
314
|
+
* wrong in the cautious direction costs a bounded result; getting it wrong in
|
|
315
|
+
* the other direction costs a confusing syntax error from the database about a
|
|
316
|
+
* statement the user did not write. `WITH` is included because a CTE ending in
|
|
317
|
+
* a SELECT is the common case, and the wrap failing on one that does not is
|
|
318
|
+
* handled by the fallback rather than by being clever here.
|
|
319
|
+
*/
|
|
320
|
+
export declare function looksWrappable(text: string): boolean;
|
|
321
|
+
export interface DeleteRequest {
|
|
322
|
+
table: string;
|
|
323
|
+
/** The whole primary key, and nothing else. */
|
|
324
|
+
key: Record<string, string | number>;
|
|
325
|
+
}
|
|
326
|
+
export interface DeleteResult {
|
|
327
|
+
affected: number;
|
|
328
|
+
sql: {
|
|
329
|
+
text: string;
|
|
330
|
+
params: unknown[];
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
/** Create a new row. Primary-key and other unique conflicts must fail, never
|
|
334
|
+
* silently ignore, update, or replace an existing row through conflict policy.
|
|
335
|
+
* SQLite explicitly uses OR ABORT; PostgreSQL uses plain INSERT. */
|
|
336
|
+
export interface InsertRequest {
|
|
337
|
+
table: string;
|
|
338
|
+
/**
|
|
339
|
+
* Column name to value. The database fills whatever is left out — that is
|
|
340
|
+
* what defaults are for — and refuses what it must, in its own words.
|
|
341
|
+
*/
|
|
342
|
+
values: Record<string, string | number | boolean | null>;
|
|
343
|
+
}
|
|
344
|
+
export interface InsertResult {
|
|
345
|
+
/** The new row's primary key, read back from the database. */
|
|
346
|
+
key: Record<string, string | number>;
|
|
347
|
+
/**
|
|
348
|
+
* The row as the database stored it — defaults filled, types settled.
|
|
349
|
+
* Absent only where the engine gives no way to read it back.
|
|
350
|
+
*/
|
|
351
|
+
row?: Record<string, unknown>;
|
|
352
|
+
/** Values after coercion to their column types, for the caller to confirm. */
|
|
353
|
+
applied: Record<string, string | number | boolean | null>;
|
|
354
|
+
sql: {
|
|
355
|
+
text: string;
|
|
356
|
+
params: unknown[];
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* A queue of one.
|
|
361
|
+
*
|
|
362
|
+
* Every adapter here writes through a single connection, and a transaction is
|
|
363
|
+
* a span of statements on it that nothing else may enter. Node is
|
|
364
|
+
* single-threaded but `await` is not: two requests arriving together interleave
|
|
365
|
+
* at every await point, so a plain `/api/update` can land in the middle of
|
|
366
|
+
* somebody's open transaction and be rolled back with it — a write that
|
|
367
|
+
* succeeded, reported success, and then quietly did not happen.
|
|
368
|
+
*
|
|
369
|
+
* So writes queue. The cost is that two concurrent edits are applied one after
|
|
370
|
+
* the other rather than at once, which is what a single connection was always
|
|
371
|
+
* going to do anyway.
|
|
372
|
+
*/
|
|
373
|
+
export declare class Serial {
|
|
374
|
+
private tail;
|
|
375
|
+
run<T>(work: () => Promise<T>): Promise<T>;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Structured reads and writes on the same transaction connection.
|
|
379
|
+
* This is not the whole adapter: no raw SQL, DDL, or cross-source access.
|
|
380
|
+
* Reads see earlier writes from this callback. Methods expire when it ends;
|
|
381
|
+
* callers must await operations and must not retain this handle for later.
|
|
382
|
+
*/
|
|
383
|
+
export interface WriteTransaction {
|
|
384
|
+
/** Internal existing-row fence, held until this transaction ends. Call before
|
|
385
|
+
* reading stored originals or comparing an inverse image. Returns no data and
|
|
386
|
+
* grants no read/write authority. Missing keys do NOT reserve absence for a
|
|
387
|
+
* later restore. Scoped writers may omit this capability; never fall back to
|
|
388
|
+
* a plain SELECT when a fence is required. */
|
|
389
|
+
lockRecord?(request: DeleteRequest): Promise<void>;
|
|
390
|
+
query(request: QueryRequest): Promise<QueryResult>;
|
|
391
|
+
count(table: string, filter?: Filter): Promise<number>;
|
|
392
|
+
/** Non-replacing creation, including restoration: enforce InsertRequest's
|
|
393
|
+
* conflict contract in this transaction. A prior absent-key lock/read is not
|
|
394
|
+
* an absence reservation; uniqueness conflicts must still reject the insert. */
|
|
395
|
+
insert(request: InsertRequest): Promise<InsertResult>;
|
|
396
|
+
remove(request: DeleteRequest): Promise<DeleteResult>;
|
|
397
|
+
update(request: UpdateRequest): Promise<UpdateResult>;
|
|
398
|
+
/** Internal: a flow's notify step (appFlows.ts). The record's `notify` rules on `{ flow: audience }` tell their people
|
|
399
|
+
* in this transaction, as a write's rules do, with the step's words. Writes nothing to the record. Only the flows'
|
|
400
|
+
* own command reaches it, about its own target; a facade that cannot carry it omits it. */
|
|
401
|
+
tell?(request: TellRequest): Promise<void>;
|
|
402
|
+
}
|
|
403
|
+
/** What a flow's notify step tells: whom (an audience a `notify` rule names `on: { flow }`), about which record, and its words. */
|
|
404
|
+
export interface TellRequest {
|
|
405
|
+
table: string;
|
|
406
|
+
key: Record<string, string | number>;
|
|
407
|
+
audience: string;
|
|
408
|
+
message: string;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Drain accepted operations before commit/rollback, then refuse escaped handles.
|
|
412
|
+
*
|
|
413
|
+
* Each operation starts once every operation asked before it has settled
|
|
414
|
+
* (`run`), so a handler's statements reach the database in the order it asked
|
|
415
|
+
* them. Reads asked together — a handler's `Promise.all` — waited on each
|
|
416
|
+
* other all the same, a round trip each, though nothing in one could change
|
|
417
|
+
* what another reads. On a transaction told its writer sends together
|
|
418
|
+
* (`together`, a pipelining PostgreSQL writer), a read (`read`) starts beside
|
|
419
|
+
* the reads still in flight, in the order asked, so they leave in one flight;
|
|
420
|
+
* it still waits for every write asked before it, and every write waits for
|
|
421
|
+
* every read before it. Only operations in flight together overlap: one
|
|
422
|
+
* awaited before the next is asked is answered before the next starts.
|
|
423
|
+
*
|
|
424
|
+
* What a caller hears is unchanged. Each operation settles in the order asked,
|
|
425
|
+
* after the ones before it, and the first failure in that order is every later
|
|
426
|
+
* operation's failure, whether the later one had started or not — a read that
|
|
427
|
+
* ran beside a failed one is answered with that failure, never its own rows —
|
|
428
|
+
* and finish() rethrows it. Elsewhere `read` is `run`.
|
|
429
|
+
*/
|
|
430
|
+
export declare class TransactionOperations {
|
|
431
|
+
private readonly together;
|
|
432
|
+
private active;
|
|
433
|
+
private failure;
|
|
434
|
+
/** Settles once every operation asked so far has: where the next write starts, and where each one settles. */
|
|
435
|
+
private settled;
|
|
436
|
+
/** Settles once the last operation that was not a read has: where a read starts, beside the reads after it. */
|
|
437
|
+
private written;
|
|
438
|
+
constructor(together?: boolean);
|
|
439
|
+
run<T>(work: () => Promise<T>): Promise<T>;
|
|
440
|
+
/** A read: it changes nothing another operation reads, so on a transaction that sends together it starts beside reads in flight. */
|
|
441
|
+
read<T>(work: () => Promise<T>): Promise<T>;
|
|
442
|
+
private enqueue;
|
|
443
|
+
finish(): Promise<void>;
|
|
444
|
+
}
|
|
445
|
+
/** Capture before queue waits, including failures: a caught malformed lock must
|
|
446
|
+
* still poison the owning transaction just like a failed database operation. */
|
|
447
|
+
export declare function queueRecordLock(operations: TransactionOperations, input: DeleteRequest, work: (request: DeleteRequest) => Promise<void>): Promise<void>;
|
|
448
|
+
/** Catalog-attested complete key only; callers supply the writer's metadata. */
|
|
449
|
+
export declare function recordLockFilter(request: DeleteRequest, primary: string[]): Filter;
|
|
450
|
+
/** A bound private read capability. No writer, raw SQL, lifecycle owner or
|
|
451
|
+
* way to replace its server-owned scope is handed to the consumer. */
|
|
452
|
+
export interface ScopedReads {
|
|
453
|
+
query(request: QueryRequest): Promise<QueryResult>;
|
|
454
|
+
/** With `limit`, stops after that many matching rows (countStatement). */
|
|
455
|
+
count(table: string, filter?: Filter, limit?: number): Promise<number>;
|
|
456
|
+
runView(view: ViewDef, offset?: number): Promise<ViewResult>;
|
|
457
|
+
/** With `limit`, stops after that many matching rows, as `count` does. */
|
|
458
|
+
countView(view: ViewDef, limit?: number): Promise<number>;
|
|
459
|
+
runBreakdown(breakdown: BreakdownDef, offset?: number): Promise<BreakdownResult>;
|
|
460
|
+
/** With `limit`, stops after that many groups, as `count` does. */
|
|
461
|
+
countBreakdown(breakdown: BreakdownDef, limit?: number): Promise<number>;
|
|
462
|
+
/** Several `count`s in one statement, each under the scope and its own filter
|
|
463
|
+
* (a menu's badges); absent on a reader that counts one at a time. */
|
|
464
|
+
countEach?(items: readonly CountItem[], limit?: number): Promise<number[]>;
|
|
465
|
+
}
|
|
466
|
+
/** A role's reach beyond reading: each a phrase for the startup notice. */
|
|
467
|
+
export interface RolePrivileges {
|
|
468
|
+
superuser: boolean;
|
|
469
|
+
/** Write privileges within what the connection browses, e.g. "INSERT/UPDATE/DELETE on 12 tables". */
|
|
470
|
+
writes: string[];
|
|
471
|
+
/** May create objects in a browsed schema or database. */
|
|
472
|
+
create: boolean;
|
|
473
|
+
}
|
|
474
|
+
export interface Adapter {
|
|
475
|
+
readonly dialect: DatabaseSchema['dialect'];
|
|
476
|
+
/** Optional explicit capability, never fall back to ordinary reads when absent.
|
|
477
|
+
* This read-only foundation does not authorize writes or resolve identity. */
|
|
478
|
+
scopeReads?(scope: RowScope): Promise<ScopedReads>;
|
|
479
|
+
/** Private same-source row enforcement; never substitute an ordinary
|
|
480
|
+
* transaction when this capability is absent. No command journal implied.
|
|
481
|
+
* Catalog evidence is detached, immutable and read on this same transaction;
|
|
482
|
+
* permission facades must attest it before using cached field/graph grants. */
|
|
483
|
+
scopeTransaction?<T>(scope: RowScope, run: (tx: WriteTransaction, catalog: DatabaseSchema) => Promise<T>): Promise<T>;
|
|
484
|
+
/** Read the catalog once on connect. Not per request. */
|
|
485
|
+
introspect(): Promise<DatabaseSchema>;
|
|
486
|
+
/**
|
|
487
|
+
* What this connection's database role could do beyond reading. Every read
|
|
488
|
+
* here runs in a read-only transaction, which holds for everything tablewalk
|
|
489
|
+
* sends but not for a superuser (`COPY … TO PROGRAM` is a read); the role is
|
|
490
|
+
* the boundary that always holds. Absent where there is no role (SQLite).
|
|
491
|
+
*/
|
|
492
|
+
privileges?(): Promise<RolePrivileges>;
|
|
493
|
+
/**
|
|
494
|
+
* The connection pools' meters (poolMetrics.ts): checkouts, the wait for a
|
|
495
|
+
* connection, how long each was held, how many are in use and queued now.
|
|
496
|
+
* Absent where the adapter keeps no pool: SQLite, an HTTP source.
|
|
497
|
+
*/
|
|
498
|
+
poolStats?(): readonly PoolRoleStats[];
|
|
499
|
+
/**
|
|
500
|
+
* What the database thinks a table holds, without counting.
|
|
501
|
+
*
|
|
502
|
+
* Optional, and unfiltered by nature: the catalog knows roughly how many rows
|
|
503
|
+
* a table has and nothing whatever about how many match a `WHERE`. An adapter
|
|
504
|
+
* whose engine keeps no such statistic returns undefined and gets an exact
|
|
505
|
+
* count, which is the honest outcome rather than a fabricated one.
|
|
506
|
+
*
|
|
507
|
+
* The number can be wrong — badly wrong on InnoDB, which samples index dives,
|
|
508
|
+
* and stale on Postgres until the next ANALYZE. That is why it is reported as
|
|
509
|
+
* an estimate everywhere it is shown, and why the exact count stays one click
|
|
510
|
+
* away.
|
|
511
|
+
*/
|
|
512
|
+
estimateCount?(table: string): Promise<number | undefined>;
|
|
513
|
+
/**
|
|
514
|
+
* Run a statement the user wrote.
|
|
515
|
+
*
|
|
516
|
+
* Optional, because an adapter that cannot make the read genuinely read-only
|
|
517
|
+
* should not offer it at all. An implementation must:
|
|
518
|
+
*
|
|
519
|
+
* - run a read inside a transaction the statement cannot promote, not
|
|
520
|
+
* merely on a connection that is configured read-only — a session
|
|
521
|
+
* default the statement can reset is not a guarantee;
|
|
522
|
+
* - refuse `write` unless it has a separate write handle, and never run a
|
|
523
|
+
* write on the browsing connection;
|
|
524
|
+
* - report `bounded` honestly, so the caller can say "the database did the
|
|
525
|
+
* whole job" rather than implying a limit that was not applied.
|
|
526
|
+
*/
|
|
527
|
+
runSql?(request: SqlRequest): Promise<SqlResult>;
|
|
528
|
+
/**
|
|
529
|
+
* The planner's account of how a statement would run, without running it.
|
|
530
|
+
*
|
|
531
|
+
* The question a query author actually has — "does this use the index or
|
|
532
|
+
* walk the table" — and the one `runSql` cannot answer, because its bounding
|
|
533
|
+
* wrap makes the statement it explains a different statement. Plans, never
|
|
534
|
+
* executes: implementations must not allow the analysing variants that run
|
|
535
|
+
* the statement to time it, which on a write would be the write.
|
|
536
|
+
*/
|
|
537
|
+
explainSql?(request: ExplainRequest): Promise<ExplainResult>;
|
|
538
|
+
/**
|
|
539
|
+
* What a table's columns actually hold: null share, distinct count, range,
|
|
540
|
+
* and the values that repeat most.
|
|
541
|
+
*
|
|
542
|
+
* Optional because the honest cost differs by engine — Postgres reads
|
|
543
|
+
* numbers the planner already keeps, SQLite has to look — and the result
|
|
544
|
+
* says which happened, so the caller can decide whether to ask twice.
|
|
545
|
+
*/
|
|
546
|
+
profile?(table: string, limits?: ProfileLimits): Promise<ProfileResult>;
|
|
547
|
+
/** Run a read. Adapters must reject anything that is not a read. */
|
|
548
|
+
query(request: QueryRequest): Promise<QueryResult>;
|
|
549
|
+
/**
|
|
550
|
+
* Run a multi-table view.
|
|
551
|
+
*
|
|
552
|
+
* Optional, and thin by design: `compileView` in shared/view.ts does all the
|
|
553
|
+
* work — resolving paths, planning joins, numbering placeholders — so an
|
|
554
|
+
* adapter that implements this only picks its `SqlStyle`, runs the statement
|
|
555
|
+
* and maps the rows. Anything an adapter decided for itself here would be a
|
|
556
|
+
* second join builder to keep in step with the first, and the join builder
|
|
557
|
+
* is exactly where the LEFT-versus-INNER mistake lives.
|
|
558
|
+
*/
|
|
559
|
+
runView?(view: ViewDef, offset?: number): Promise<ViewResult>;
|
|
560
|
+
/**
|
|
561
|
+
* How many rows a view matches, ignoring the page.
|
|
562
|
+
*
|
|
563
|
+
* Separate from `count` because a view's WHERE clause addresses paths, not
|
|
564
|
+
* columns, so the joins have to exist for the predicate to compile at all.
|
|
565
|
+
* Optional alongside `runView`: an adapter that can run a view can count
|
|
566
|
+
* one, and one that cannot has no use for either. With `limit`, stops
|
|
567
|
+
* after that many matching rows (countStatement), as `count` does.
|
|
568
|
+
*/
|
|
569
|
+
countView?(view: ViewDef, limit?: number): Promise<number>;
|
|
570
|
+
/**
|
|
571
|
+
* Run a breakdown: counts and sums, grouped by something.
|
|
572
|
+
*
|
|
573
|
+
* Thin for the same reason `runView` is thin — `compileBreakdown` does the
|
|
574
|
+
* work and the adapter picks a style and runs the statement. The one thing
|
|
575
|
+
* it contributes is `dateBucket`, because cutting a timestamp down to a
|
|
576
|
+
* month is the single part of this that no two engines spell alike.
|
|
577
|
+
*/
|
|
578
|
+
runBreakdown?(breakdown: BreakdownDef, offset?: number): Promise<BreakdownResult>;
|
|
579
|
+
/** How many groups there are, ignoring the page. With `limit`, stops after that many. */
|
|
580
|
+
countBreakdown?(breakdown: BreakdownDef, limit?: number): Promise<number>;
|
|
581
|
+
/**
|
|
582
|
+
* Count matching rows, for pagination and the "how many point here" badge.
|
|
583
|
+
* With `limit`, stop after that many matching rows (countStatement): the
|
|
584
|
+
* answer is exact below the bound and the bound itself at or above it.
|
|
585
|
+
*/
|
|
586
|
+
count(table: string, filter?: Filter, limit?: number): Promise<number>;
|
|
587
|
+
/**
|
|
588
|
+
* Several counts in one statement (countEachStatement), in the items' order,
|
|
589
|
+
* each with `limit` as `count` takes it. A list's tab badges and a record's
|
|
590
|
+
* references were a statement — and on a pool, a round trip — apiece.
|
|
591
|
+
*
|
|
592
|
+
* Optional, and absent on every wrapper that has not said how it guards it:
|
|
593
|
+
* an access layer builds its adapter from the methods it checks, so a
|
|
594
|
+
* missing one is refused rather than passed through, and the caller falls
|
|
595
|
+
* back to `count` per item (resourceReadOperations.readCounts). A row-scoped
|
|
596
|
+
* reader has none, so its counts keep compiling under its scope one by one.
|
|
597
|
+
*/
|
|
598
|
+
countEach?(items: readonly CountItem[], limit?: number): Promise<number[]>;
|
|
599
|
+
/**
|
|
600
|
+
* The database's own stored DDL, when it keeps one.
|
|
601
|
+
*
|
|
602
|
+
* Optional on purpose. SQLite keeps the original `CREATE TABLE` text in
|
|
603
|
+
* `sqlite_master` and can hand it back exactly; Postgres does not store one
|
|
604
|
+
* (pg_dump reconstructs it too). Adapters that cannot be exact should not
|
|
605
|
+
* implement this — the caller falls back to `renderDDL` and labels the
|
|
606
|
+
* result as reconstructed, which is honest rather than convenient.
|
|
607
|
+
*/
|
|
608
|
+
ddl?(table: string): Promise<string | undefined>;
|
|
609
|
+
/**
|
|
610
|
+
* Update exactly one column of exactly one row.
|
|
611
|
+
*
|
|
612
|
+
* Optional, and separate from `query` on purpose: the read path has no way
|
|
613
|
+
* to express a write, and adding one would mean every reader had to be
|
|
614
|
+
* trusted not to. An adapter that implements this opens its own write
|
|
615
|
+
* connection lazily — the browsing connection stays read-only for the life
|
|
616
|
+
* of the process.
|
|
617
|
+
*
|
|
618
|
+
* Implementations must refuse unless the filter matches exactly one row.
|
|
619
|
+
* The danger in a cell editor is never injection; it is an UPDATE whose
|
|
620
|
+
* WHERE is broader than the author believed.
|
|
621
|
+
*/
|
|
622
|
+
update?(request: UpdateRequest): Promise<UpdateResult>;
|
|
623
|
+
/** Add one row. Absent on read-only dialects, like every other write. */
|
|
624
|
+
insert?(request: InsertRequest): Promise<InsertResult>;
|
|
625
|
+
/**
|
|
626
|
+
* Remove one row, having proved it is one row.
|
|
627
|
+
*
|
|
628
|
+
* The same contract as `update`: the exact primary key, a pre-flight count,
|
|
629
|
+
* and a refusal unless it matches exactly one. What is
|
|
630
|
+
* *not* an adapter's job is deciding whether the row should go — what
|
|
631
|
+
* references it, and what the database will do to those references, is
|
|
632
|
+
* answered above this layer where the schema is in hand.
|
|
633
|
+
*
|
|
634
|
+
* Constraint violations are left to the database. A `RESTRICT` that fires is
|
|
635
|
+
* the correct outcome reported in the engine's own words, and re-deriving
|
|
636
|
+
* that judgement here would be a second implementation of a rule the database
|
|
637
|
+
* already enforces — which is exactly how the two come to disagree.
|
|
638
|
+
*/
|
|
639
|
+
remove?(request: DeleteRequest): Promise<DeleteResult>;
|
|
640
|
+
/**
|
|
641
|
+
* Several writes as one, or none of them.
|
|
642
|
+
*
|
|
643
|
+
* A fixture is a graph — an invoice needs its customer, the customer needs
|
|
644
|
+
* its country — and inserting it one call at a time means a ten-row fixture
|
|
645
|
+
* that fails at row seven leaves six rows and a dirty database. That is
|
|
646
|
+
* worse than failing, because the database now holds something nobody
|
|
647
|
+
* designed and nothing named.
|
|
648
|
+
*
|
|
649
|
+
* The callback gets same-connection reads and writes: see `WriteTransaction`. It is run
|
|
650
|
+
* behind the same queue as every other write, so nothing outside can land
|
|
651
|
+
* inside the transaction and be rolled back with it.
|
|
652
|
+
*
|
|
653
|
+
* Optional like the writes themselves. An adapter that cannot write cannot
|
|
654
|
+
* offer this, and one that can should: the guarantee is the engine's, and
|
|
655
|
+
* all three of these engines have it.
|
|
656
|
+
*
|
|
657
|
+
* A failure after a commit attempt or without confirmed rollback must throw
|
|
658
|
+
* TransactionOutcomeUnknown. Other failures mean no callback write committed.
|
|
659
|
+
* This outcome contract is required by Undo; atomicity alone cannot establish
|
|
660
|
+
* what happened when an acknowledgement was lost.
|
|
661
|
+
*/
|
|
662
|
+
transaction?<T>(run: (tx: WriteTransaction) => Promise<T>): Promise<T>;
|
|
663
|
+
close(): Promise<void>;
|
|
664
|
+
}
|
|
665
|
+
export interface UpdateRequest {
|
|
666
|
+
table: string;
|
|
667
|
+
/** Primary key columns and their values. Must identify one row. */
|
|
668
|
+
key: Record<string, string | number>;
|
|
669
|
+
/**
|
|
670
|
+
* Column name to new value. Several at once on purpose.
|
|
671
|
+
*
|
|
672
|
+
* Editing three fields as three statements means three chances to fail
|
|
673
|
+
* half way, leaving a row in a state the user never asked for. One
|
|
674
|
+
* statement either applies or does not.
|
|
675
|
+
*/
|
|
676
|
+
values: Record<string, string | number | boolean | null>;
|
|
677
|
+
/**
|
|
678
|
+
* Set only by history's revert: a record returning to its recorded
|
|
679
|
+
* before-image is not a new transition (server/app/appTransitions.ts).
|
|
680
|
+
*/
|
|
681
|
+
restore?: true;
|
|
682
|
+
/** Original values for exactly the touched fields; checked atomically by UPDATE. */
|
|
683
|
+
expected?: Record<string, string | number | boolean | null>;
|
|
684
|
+
}
|
|
685
|
+
export interface UpdateResult {
|
|
686
|
+
affected: number;
|
|
687
|
+
/** Values after coercion to their column types, for the caller to confirm. */
|
|
688
|
+
applied: Record<string, string | number | boolean | null>;
|
|
689
|
+
sql: {
|
|
690
|
+
text: string;
|
|
691
|
+
params: unknown[];
|
|
692
|
+
};
|
|
693
|
+
}
|