@mistriwork/engine 0.0.0-stage → 1.0.0-rc.10
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 +17 -2
- 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 +64 -0
- package/dist/shared/keysetPage.js +161 -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 +261 -4
- package/schema/model.d.ts +298 -0
- package/schema/theme.d.ts +587 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The read snapshot a trusted owner is lent (postgres.ts `readSnapshot`): one `REPEATABLE READ, READ ONLY` transaction
|
|
3
|
+
* on a leased reader, with its prologue sent in the BEGIN's own message, an `ahead` form whose first statements leave
|
|
4
|
+
* behind the BEGIN, a `whole` form that is a single round trip, and the `finish` that commits it and reads a fence in a
|
|
5
|
+
* fresh snapshot. Apart from the adapter because it needs nothing of it but the reader pool and its introspection.
|
|
6
|
+
*/
|
|
7
|
+
import { Refusal, TransactionOutcomeUnknown } from './adapter.js';
|
|
8
|
+
import { pipelinesAs } from './postgresPool.js';
|
|
9
|
+
import { toJsonSafe, withBytes } from './postgresValues.js';
|
|
10
|
+
const BEGIN_SNAPSHOT = 'BEGIN ISOLATION LEVEL REPEATABLE READ READ ONLY';
|
|
11
|
+
/**
|
|
12
|
+
* Run `run` in a snapshot on `connections`' reader. `describe` is the adapter's own introspection on the leased
|
|
13
|
+
* client; `onCheckout` says it is a pinned owner's, whose introspection is the class's and not an instance's.
|
|
14
|
+
*/
|
|
15
|
+
export async function readSnapshotOn(connections, describe, run, observeCheckout, prologue, ahead, whole) {
|
|
16
|
+
if (typeof run !== 'function' ||
|
|
17
|
+
(prologue !== undefined && (typeof prologue !== 'string' || !prologue.trim())) ||
|
|
18
|
+
(ahead && (observeCheckout || prologue === undefined)) ||
|
|
19
|
+
(whole && (observeCheckout || ahead || prologue === undefined))) {
|
|
20
|
+
throw new Refusal('This read snapshot is unavailable.');
|
|
21
|
+
}
|
|
22
|
+
/* The answer is final once `run` returns: a read-only transaction's
|
|
23
|
+
COMMIT changes nothing it showed. So the caller has it then, and the
|
|
24
|
+
COMMIT finishes on the lease, which goes back to the pool (or is
|
|
25
|
+
discarded, should the COMMIT fail) only after it. Against a server a
|
|
26
|
+
round trip away that is one round trip off every snapshot. Not for an
|
|
27
|
+
observed checkout: its owner hands its response off inside the
|
|
28
|
+
snapshot (postgresReadCatalog.ts), so a COMMIT it never heard
|
|
29
|
+
acknowledged is an uncertain outcome it must be told of. */
|
|
30
|
+
let deliver;
|
|
31
|
+
const answered = new Promise((resolve) => {
|
|
32
|
+
deliver = resolve;
|
|
33
|
+
});
|
|
34
|
+
const work = async (client, checkout) => {
|
|
35
|
+
let out;
|
|
36
|
+
let active = true;
|
|
37
|
+
const current = () => {
|
|
38
|
+
if (!active || !checkout)
|
|
39
|
+
throw new Refusal('The read snapshot is unavailable.');
|
|
40
|
+
checkout();
|
|
41
|
+
};
|
|
42
|
+
/* The owner's prologue rides with BEGIN in one simple-protocol
|
|
43
|
+
message: statements without parameters (its LOCK, its first query),
|
|
44
|
+
so the snapshot is still taken where the owner put its first query,
|
|
45
|
+
and the owner is handed their results. A failure here, as of BEGIN
|
|
46
|
+
alone, discards the client, and the server rolls back with it. */
|
|
47
|
+
/* Asked ahead, the owner is handed the snapshot with its BEGIN in
|
|
48
|
+
flight rather than answered, so its own first statements leave in
|
|
49
|
+
the same flight on a reader that pipelines: one round trip where
|
|
50
|
+
BEGIN and each of them were one each. The owner waits on the BEGIN's
|
|
51
|
+
answer before it trusts anything; a BEGIN that failed fails what was
|
|
52
|
+
sent behind it, and the owner hears the BEGIN's failure first. */
|
|
53
|
+
const begun = client.query(prologue === undefined ? BEGIN_SNAPSHOT : `${BEGIN_SNAPSHOT}; ${prologue}${whole ? '; COMMIT' : ''}`).then((opened) => Object.freeze(prologue === undefined
|
|
54
|
+
? []
|
|
55
|
+
: (Array.isArray(opened) ? opened : [opened]).slice(1, whole ? -1 : undefined)));
|
|
56
|
+
let results;
|
|
57
|
+
if (ahead)
|
|
58
|
+
void begun.catch(() => { });
|
|
59
|
+
else
|
|
60
|
+
results = await begun;
|
|
61
|
+
/* Committed already (`whole`, `finish`): there is no snapshot left to ask of, and no COMMIT to send. */
|
|
62
|
+
let ended = whole;
|
|
63
|
+
/* The client otherwise, until the snapshot has ended: a statement asked after `finish` would run outside any
|
|
64
|
+
transaction, on a connection the snapshot no longer holds. It pipelines where the client does (postgresPool.ts). */
|
|
65
|
+
const asked = Object.freeze({
|
|
66
|
+
query: ((...args) => ended
|
|
67
|
+
? Promise.reject(new Refusal('The read snapshot is unavailable.'))
|
|
68
|
+
: client.query(...args)),
|
|
69
|
+
});
|
|
70
|
+
pipelinesAs(asked, client);
|
|
71
|
+
const finish = async (next) => {
|
|
72
|
+
if (ended || typeof next !== 'string' || !next.trim())
|
|
73
|
+
throw new Refusal('The read snapshot is unavailable.');
|
|
74
|
+
ended = true;
|
|
75
|
+
if (ahead)
|
|
76
|
+
await begun;
|
|
77
|
+
const closed = (await client.query(`COMMIT; ${BEGIN_SNAPSHOT}; ${next}; COMMIT`));
|
|
78
|
+
return Object.freeze((Array.isArray(closed) ? closed : [closed]).slice(2, -1));
|
|
79
|
+
};
|
|
80
|
+
try {
|
|
81
|
+
out = await run(Object.freeze({
|
|
82
|
+
client: asked,
|
|
83
|
+
...(results === undefined ? {} : prologue === undefined ? {} : { prologue: results }),
|
|
84
|
+
...(ahead ? { opened: begun } : {}),
|
|
85
|
+
...(checkout ? { assertCurrent: current } : { ...(whole ? {} : { finish }) }),
|
|
86
|
+
describe: () => describe(asked, checkout !== undefined),
|
|
87
|
+
execute: async (statement, hint) => {
|
|
88
|
+
if (ended)
|
|
89
|
+
throw new Refusal('The read snapshot is unavailable.');
|
|
90
|
+
const started = performance.now();
|
|
91
|
+
const result = await asked.query(statement.text, statement.params);
|
|
92
|
+
return {
|
|
93
|
+
columns: result.fields.map((field) => field.name),
|
|
94
|
+
rows: result.rows.map(hint?.binary ? withBytes : toJsonSafe),
|
|
95
|
+
ms: Math.round(performance.now() - started),
|
|
96
|
+
sql: { text: statement.text, params: statement.params },
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
}));
|
|
100
|
+
// Never an answer from a snapshot whose BEGIN failed, whether or not its owner waited to hear.
|
|
101
|
+
if (ahead)
|
|
102
|
+
await begun;
|
|
103
|
+
if (checkout)
|
|
104
|
+
current();
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
active = false;
|
|
108
|
+
/* A BEGIN that failed is the failure, as it is when awaited first: no
|
|
109
|
+
transaction to roll back, and the client is discarded. */
|
|
110
|
+
if (ahead) {
|
|
111
|
+
const failed = await begun.then(() => undefined, (reason) => ({ reason }));
|
|
112
|
+
if (failed)
|
|
113
|
+
throw failed.reason;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
await client.query('ROLLBACK');
|
|
117
|
+
}
|
|
118
|
+
catch (rollback) {
|
|
119
|
+
throw new TransactionOutcomeUnknown(rollback);
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
active = false;
|
|
124
|
+
if (!observeCheckout)
|
|
125
|
+
deliver(out);
|
|
126
|
+
if (!ended)
|
|
127
|
+
await client.query('COMMIT');
|
|
128
|
+
return out;
|
|
129
|
+
};
|
|
130
|
+
const leased = observeCheckout ? connections.withObservedReadClient(work) : connections.withReadClient(work, false, true);
|
|
131
|
+
// Whichever settles first: the answer, or a failure before there was one.
|
|
132
|
+
return Promise.race([answered, leased]);
|
|
133
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const SCHEMA_EPOCH_TABLE = "schema_epoch";
|
|
2
|
+
export declare const EPOCHLESS_TTL_MS = 5000;
|
|
3
|
+
export declare const epochlessEpoch: () => string;
|
|
4
|
+
/** Whether a statement failed for a table (42P01) or column (42703) that is not there: the kept catalog is wrong. */
|
|
5
|
+
export declare function schemaMoved(error: unknown): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The statement that reads the epoch: one row, or none when the store is not
|
|
8
|
+
* whole (trigger disabled or gone). No parameters, so it rides in the
|
|
9
|
+
* message that begins a transaction. A missing store makes the statement
|
|
10
|
+
* fail, which the caller treats as a miss.
|
|
11
|
+
*/
|
|
12
|
+
export declare function schemaEpochStatement(): string;
|
|
13
|
+
/** The epoch an epoch statement answered, or undefined when the store is not whole. */
|
|
14
|
+
export declare function schemaEpochOf(result: {
|
|
15
|
+
rows: readonly Record<string, unknown>[];
|
|
16
|
+
} | undefined): string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Explicit maintenance, under the shared migration lock: creates the store
|
|
19
|
+
* where none exists, changes nothing where it is whole, refuses a partial
|
|
20
|
+
* one. Needs a role that may create event triggers.
|
|
21
|
+
*/
|
|
22
|
+
export declare function provisionPostgresSchemaEpoch(url: string): Promise<{
|
|
23
|
+
provisioned: boolean;
|
|
24
|
+
}>;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PostgreSQL catalog's epoch: one row that moves whenever the schema does.
|
|
3
|
+
*
|
|
4
|
+
* Every transaction that trusts catalog metadata — the command journal's
|
|
5
|
+
* layout, the tables a row scope pins, a table's columns and key — used to
|
|
6
|
+
* read it again (six to eight catalog statements a command), or read the
|
|
7
|
+
* catalog digest (postgresCatalogDigest.ts), one statement that walks every
|
|
8
|
+
* catalog row and costs milliseconds of server time. With this store
|
|
9
|
+
* provisioned, the transaction reads one row instead, and every catalog
|
|
10
|
+
* answer is kept in memory under the epoch it was read at (epochCache.ts).
|
|
11
|
+
*
|
|
12
|
+
* How it moves: an event trigger on `ddl_command_end` appends a row inside
|
|
13
|
+
* the DDL's own transaction, so the change is visible exactly when the DDL
|
|
14
|
+
* commits, and the epoch is a digest of the rows there are, each with its row
|
|
15
|
+
* version (`xmin`). Appending rather than bumping one counter is deliberate:
|
|
16
|
+
* an UPDATE of one row would make every DDL transaction in the database wait
|
|
17
|
+
* on every other, and two migrations that each touch the other's table would
|
|
18
|
+
* then deadlock where today one simply waits. Inserts never wait on each
|
|
19
|
+
* other, and the trigger keeps the newest 64 rows, deleting older ones with
|
|
20
|
+
* SKIP LOCKED so that it never waits either. Any committed DDL adds a row the
|
|
21
|
+
* digest has not seen, and a row put back by hand has a new version, so an
|
|
22
|
+
* old epoch can never come round again. The function is SECURITY DEFINER,
|
|
23
|
+
* owned by whoever provisioned it, so DDL by a role that cannot write the
|
|
24
|
+
* table still moves the epoch — nobody's DDL fails because of this store.
|
|
25
|
+
* ENABLE ALWAYS keeps it firing under `session_replication_role = replica`.
|
|
26
|
+
*
|
|
27
|
+
* What the epoch statement reads besides the rows, so that nothing that could
|
|
28
|
+
* make a cached answer wrong goes unseen:
|
|
29
|
+
* - the event trigger (present, `ENABLE ALWAYS`, on `ddl_command_end`) and its
|
|
30
|
+
* function's row version: dropped, disabled or replaced, and the statement
|
|
31
|
+
* answers nothing, which is a miss;
|
|
32
|
+
* - role membership and the attributes privileges depend on: roles are
|
|
33
|
+
* shared objects, and event triggers do not fire for them.
|
|
34
|
+
*
|
|
35
|
+
* Outside the contract, as for the digest: a superuser who turns event
|
|
36
|
+
* triggers off in a session (`event_triggers = off`) and changes the schema
|
|
37
|
+
* there. That is the superuser deliberately stepping around the database's
|
|
38
|
+
* own notification; a restart, or any other DDL, moves the epoch again.
|
|
39
|
+
*
|
|
40
|
+
* Provisioning is explicit maintenance, never startup (like the journal and
|
|
41
|
+
* the inbox), and needs a role that may create event triggers — a superuser
|
|
42
|
+
* on PostgreSQL 16. Where it is absent, the adapter reads the digest per
|
|
43
|
+
* transaction as before: slower, never less correct.
|
|
44
|
+
*/
|
|
45
|
+
import { Refusal } from './adapter.js';
|
|
46
|
+
import { withPostgresMaintenanceTransaction } from './postgresMaintenance.js';
|
|
47
|
+
import { RUNTIME_SCHEMA, runtimeTable } from '../shared/runtimeTables.js';
|
|
48
|
+
export const SCHEMA_EPOCH_TABLE = 'schema_epoch';
|
|
49
|
+
/* The function sits in the runtime schema beside the table (RUNTIME_SCHEMA_FUNCTIONS allows it there).
|
|
50
|
+
An event trigger belongs to the whole database, not to a schema, so its name keeps the reserved prefix. */
|
|
51
|
+
const FUNCTION = 'schema_epoch_bump';
|
|
52
|
+
const TRIGGER = '__mistri_schema_epoch';
|
|
53
|
+
const definitions = [
|
|
54
|
+
`CREATE TABLE ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} (
|
|
55
|
+
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
56
|
+
at timestamptz NOT NULL DEFAULT now()
|
|
57
|
+
)`,
|
|
58
|
+
`INSERT INTO ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} DEFAULT VALUES`,
|
|
59
|
+
`CREATE FUNCTION ${runtimeTable('postgres', FUNCTION)}() RETURNS event_trigger LANGUAGE plpgsql
|
|
60
|
+
SECURITY DEFINER SET search_path = pg_catalog, pg_temp AS $$
|
|
61
|
+
DECLARE
|
|
62
|
+
temporary boolean;
|
|
63
|
+
BEGIN
|
|
64
|
+
-- A session's own temporary objects are nobody else's catalog (the digest
|
|
65
|
+
-- skips them too); anything else, or a command that names nothing, moves it.
|
|
66
|
+
SELECT count(*) > 0 AND bool_and(c.schema_name = 'pg_temp') INTO temporary FROM pg_event_trigger_ddl_commands() c;
|
|
67
|
+
IF temporary THEN RETURN; END IF;
|
|
68
|
+
INSERT INTO ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} DEFAULT VALUES;
|
|
69
|
+
DELETE FROM ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} WHERE id IN (
|
|
70
|
+
SELECT id FROM ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} ORDER BY id DESC OFFSET 64 FOR UPDATE SKIP LOCKED);
|
|
71
|
+
END
|
|
72
|
+
$$`,
|
|
73
|
+
`REVOKE ALL ON FUNCTION ${runtimeTable('postgres', FUNCTION)}() FROM PUBLIC`,
|
|
74
|
+
`CREATE EVENT TRIGGER "${TRIGGER}" ON ddl_command_end EXECUTE FUNCTION ${runtimeTable('postgres', FUNCTION)}()`,
|
|
75
|
+
`ALTER EVENT TRIGGER "${TRIGGER}" ENABLE ALWAYS`,
|
|
76
|
+
];
|
|
77
|
+
/* With no epoch store a write has no version to file its catalog answers under and asked again every time.
|
|
78
|
+
They are filed under the clock instead: a column changed elsewhere goes unnoticed this long, unless a
|
|
79
|
+
write fails on a missing table or column (schemaMoved), which forgets them at once. The tenant read sources keep a
|
|
80
|
+
passed catalog attestation this long too (tenantReadSource.ts, tenantPlatformSource.ts). */
|
|
81
|
+
export const EPOCHLESS_TTL_MS = 5_000;
|
|
82
|
+
export const epochlessEpoch = () => `ttl:${Math.floor(Date.now() / EPOCHLESS_TTL_MS)}`;
|
|
83
|
+
/** Whether a statement failed for a table (42P01) or column (42703) that is not there: the kept catalog is wrong. */
|
|
84
|
+
export function schemaMoved(error) {
|
|
85
|
+
const code = error?.code;
|
|
86
|
+
return code === '42P01' || code === '42703';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The statement that reads the epoch: one row, or none when the store is not
|
|
90
|
+
* whole (trigger disabled or gone). No parameters, so it rides in the
|
|
91
|
+
* message that begins a transaction. A missing store makes the statement
|
|
92
|
+
* fail, which the caller treats as a miss.
|
|
93
|
+
*/
|
|
94
|
+
export function schemaEpochStatement() {
|
|
95
|
+
return `SELECT md5((SELECT coalesce(string_agg(e.id || ':' || e.xmin, ',' ORDER BY e.id), '') FROM ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)} e)
|
|
96
|
+
|| '|' || t.xmin::text || '|' || f.xmin::text
|
|
97
|
+
|| '|' || (SELECT coalesce(string_agg(m.roleid || '>' || m.member || ':' || m.xmin, ',' ORDER BY m.roleid, m.member), '')
|
|
98
|
+
FROM pg_catalog.pg_auth_members m)
|
|
99
|
+
|| '|' || (SELECT coalesce(string_agg(r.oid || ':' || r.rolname || ':' || r.rolsuper || ':' || r.rolinherit || ':' || r.rolbypassrls, ',' ORDER BY r.oid), '')
|
|
100
|
+
FROM pg_catalog.pg_roles r)
|
|
101
|
+
|| '|' || current_user) AS epoch
|
|
102
|
+
FROM pg_catalog.pg_event_trigger t
|
|
103
|
+
JOIN pg_catalog.pg_proc f ON f.oid = t.evtfoid AND f.proname = '${FUNCTION}' AND f.pronamespace = (SELECT n.oid FROM pg_catalog.pg_namespace n WHERE n.nspname = '${RUNTIME_SCHEMA}')
|
|
104
|
+
WHERE t.evtname = '${TRIGGER}' AND t.evtevent = 'ddl_command_end' AND t.evtenabled = 'A'`;
|
|
105
|
+
}
|
|
106
|
+
/** The epoch an epoch statement answered, or undefined when the store is not whole. */
|
|
107
|
+
export function schemaEpochOf(result) {
|
|
108
|
+
const value = result?.rows.length === 1 ? result.rows[0].epoch : undefined;
|
|
109
|
+
return typeof value === 'string' && value ? value : undefined;
|
|
110
|
+
}
|
|
111
|
+
/** Whether this database holds the epoch store, whole. */
|
|
112
|
+
async function postgresSchemaEpochReady(client) {
|
|
113
|
+
try {
|
|
114
|
+
return schemaEpochOf(await client.query(schemaEpochStatement())) !== undefined;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Explicit maintenance, under the shared migration lock: creates the store
|
|
122
|
+
* where none exists, changes nothing where it is whole, refuses a partial
|
|
123
|
+
* one. Needs a role that may create event triggers.
|
|
124
|
+
*/
|
|
125
|
+
export async function provisionPostgresSchemaEpoch(url) {
|
|
126
|
+
if (typeof url !== 'string' || !/^postgres(ql)?:\/\//i.test(url))
|
|
127
|
+
throw new Refusal('Schema epoch provisioning requires a postgres:// URL.');
|
|
128
|
+
return withPostgresMaintenanceTransaction(url, async (client) => {
|
|
129
|
+
const present = await client.query(`SELECT to_regclass('${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)}') IS NOT NULL AS table,
|
|
130
|
+
EXISTS (SELECT 1 FROM pg_catalog.pg_event_trigger WHERE evtname = '${TRIGGER}') AS trigger,
|
|
131
|
+
EXISTS (SELECT 1 FROM pg_catalog.pg_proc WHERE proname = '${FUNCTION}' AND pronamespace = (SELECT n.oid FROM pg_catalog.pg_namespace n WHERE n.nspname = '${RUNTIME_SCHEMA}')) AS function`);
|
|
132
|
+
const found = present.rows[0];
|
|
133
|
+
let provisioned = false;
|
|
134
|
+
if (!found.table && !found.trigger && !found.function) {
|
|
135
|
+
try {
|
|
136
|
+
for (const ddl of definitions)
|
|
137
|
+
await client.query(ddl);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw new Refusal(`The schema epoch needs a role that may create event triggers (a superuser on PostgreSQL 16): ${error.message}`);
|
|
141
|
+
}
|
|
142
|
+
provisioned = true;
|
|
143
|
+
}
|
|
144
|
+
if (!(await postgresSchemaEpochReady(client))) {
|
|
145
|
+
throw new Refusal(`The schema epoch store is partial or disabled: drop ${runtimeTable('postgres', SCHEMA_EPOCH_TABLE)}, its function and event trigger, then provision again.`);
|
|
146
|
+
}
|
|
147
|
+
return { provisioned };
|
|
148
|
+
});
|
|
149
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One transaction's own handle on a leased PostgreSQL client.
|
|
3
|
+
*
|
|
4
|
+
* A writer's client is pooled: the same object serves one transaction after
|
|
5
|
+
* another. Something true of one transaction only — the membership rows its
|
|
6
|
+
* fence locked, held to its end (tenantWriteSource.ts) — must
|
|
7
|
+
* therefore be kept on an object that is that transaction's alone: made at
|
|
8
|
+
* its BEGIN, used for every statement it sends, dropped with it. Never on the
|
|
9
|
+
* client, and never keyed by a pool connection.
|
|
10
|
+
*
|
|
11
|
+
* It also counts the rollbacks that pass through it. A `ROLLBACK TO
|
|
12
|
+
* SAVEPOINT` undoes everything since the savepoint, the locks taken there
|
|
13
|
+
* included, so whatever was established before it is no longer vouched for.
|
|
14
|
+
* Any statement that says ROLLBACK anywhere counts, a string literal
|
|
15
|
+
* included: a false count only costs a repeated check.
|
|
16
|
+
*/
|
|
17
|
+
import { type PgQuery, type PgResult } from './postgresPool.js';
|
|
18
|
+
/** What became of a transaction's statements sent ahead. */
|
|
19
|
+
export interface AheadReport {
|
|
20
|
+
/** Sent before their turn. */
|
|
21
|
+
sent: number;
|
|
22
|
+
/** Of those, the ones a later identical query took. */
|
|
23
|
+
taken: number;
|
|
24
|
+
/** Statements asked in their turn while answers sent ahead were still waiting: each cost a round trip one sent ahead might have saved. */
|
|
25
|
+
missed: number;
|
|
26
|
+
/** Answers sent ahead that nothing took before they were dropped, by what each said. */
|
|
27
|
+
left: string[];
|
|
28
|
+
/** Times the transaction began again without them, because one failed. */
|
|
29
|
+
redone: number;
|
|
30
|
+
/** Reads answered from a row read ahead (holdAhead) instead of being sent. */
|
|
31
|
+
answered: number;
|
|
32
|
+
/** What was asked in its turn while answers sent ahead were waiting, by its first words: the missed, and what dropped them. */
|
|
33
|
+
asked: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function transactionHandle(client: PgQuery, origin?: object): PgQuery;
|
|
36
|
+
/**
|
|
37
|
+
* Send statements now that the transaction will ask for later, so they leave
|
|
38
|
+
* in the flight already going out (behind its BEGIN) instead of each in a
|
|
39
|
+
* round trip of its own. Each answer is kept for the first later query that
|
|
40
|
+
* says exactly the same thing, and given to it once; the query then sends
|
|
41
|
+
* nothing. Only reads and locks are sent ahead, in the order the transaction
|
|
42
|
+
* would ask them, and every kept answer is dropped the moment the transaction
|
|
43
|
+
* sends anything else — a write of its own, a rollback to a savepoint — so a
|
|
44
|
+
* read after this transaction's own change is always asked again.
|
|
45
|
+
*
|
|
46
|
+
* The caller awaits the returned answers before it relies on any of them: one
|
|
47
|
+
* that failed has aborted the transaction, which then begins again without
|
|
48
|
+
* them (nothing has used them yet). On a client that does not pipeline
|
|
49
|
+
* nothing is sent: each would cost its own round trip either way.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sendAhead(client: PgQuery, statements: readonly PipelinedStatement[]): Promise<unknown>[];
|
|
52
|
+
/**
|
|
53
|
+
* Whether an answer sent ahead still waits for exactly `statement`: asking it
|
|
54
|
+
* then sends nothing. False once a statement of the transaction's own has
|
|
55
|
+
* dropped it, or where nothing was sent ahead.
|
|
56
|
+
*/
|
|
57
|
+
export declare function waitsAhead(client: PgQuery, statement: Readonly<{
|
|
58
|
+
text: string;
|
|
59
|
+
values?: readonly unknown[];
|
|
60
|
+
}>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Send a read now that a caller will answer later reads from itself (a row
|
|
63
|
+
* read in full, answered by projection: scoped/keyRows.ts), rather than the
|
|
64
|
+
* handle answering one identical query with it. `take` says it answered one,
|
|
65
|
+
* so a read never used is reported left like any statement sent ahead.
|
|
66
|
+
* Undefined where the client does not pipeline.
|
|
67
|
+
*/
|
|
68
|
+
export declare function holdAhead(client: PgQuery, statement: PipelinedStatement): {
|
|
69
|
+
answer: Promise<PgResult<Record<string, unknown>>>;
|
|
70
|
+
take(): void;
|
|
71
|
+
} | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The transaction's statement generation: a number that moves with every
|
|
74
|
+
* statement sent through its handle that is not a read or a lock (a write, a
|
|
75
|
+
* savepoint, a rollback, a notification) and with every one that fails.
|
|
76
|
+
* Something read while it stood still was read in a transaction that has
|
|
77
|
+
* changed nothing since. Undefined for anything that is not a handle.
|
|
78
|
+
*/
|
|
79
|
+
export declare const generationOf: (client: PgQuery) => number | undefined;
|
|
80
|
+
/** Whether statements sent ahead on this transaction leave in one flight: its client pipelines. */
|
|
81
|
+
export declare const sendsAhead: (client: PgQuery) => boolean;
|
|
82
|
+
/**
|
|
83
|
+
* A COMMIT that the server answered as a ROLLBACK, because a write sent in
|
|
84
|
+
* front of it in the same flight (beforeCommit) failed: nothing committed.
|
|
85
|
+
* `cause` is that write's own failure.
|
|
86
|
+
*/
|
|
87
|
+
export declare class RolledBackAtCommit extends Error {
|
|
88
|
+
readonly cause: unknown;
|
|
89
|
+
constructor(cause: unknown);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Queue writes whose answers nothing reads before COMMIT (a receipt, its
|
|
93
|
+
* audit, a live change and its notification), to leave with the next
|
|
94
|
+
* statement the transaction sends — its COMMIT, at best — in the same flight
|
|
95
|
+
* instead of a round trip each. A write that fails then fails what it was
|
|
96
|
+
* sent with: the statement behind it throws the write's own failure, and a
|
|
97
|
+
* COMMIT throws RolledBackAtCommit (nothing committed). False where the
|
|
98
|
+
* client does not pipeline or is not a transaction's handle: the caller sends
|
|
99
|
+
* them in their turn.
|
|
100
|
+
*/
|
|
101
|
+
export declare function beforeCommit(client: PgQuery, statements: readonly PipelinedStatement[]): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Run `ride` the moment the transaction sends a statement `match` accepts (a
|
|
104
|
+
* write the caller is about to wait on), so what `ride` sends leaves right
|
|
105
|
+
* behind it, in its flight, and reads what it wrote. Answers a withdraw: true
|
|
106
|
+
* when `ride` had not run (it never will now). Undefined where the client
|
|
107
|
+
* does not pipeline: the caller asks in its turn.
|
|
108
|
+
*/
|
|
109
|
+
export declare function behindWrite(client: PgQuery, match: (text: string) => boolean, ride: () => void): (() => boolean) | undefined;
|
|
110
|
+
/** Drop every answer sent ahead and not yet taken, and count a beginning again without them (one failed). */
|
|
111
|
+
export declare function redoWithoutAhead(client: PgQuery): void;
|
|
112
|
+
/** What became of this transaction's statements sent ahead, those still waiting counted as left; undefined for anything else. */
|
|
113
|
+
export declare function aheadReport(client: PgQuery): AheadReport | undefined;
|
|
114
|
+
/** The same transaction seen through `query`, which must send every
|
|
115
|
+
* statement on through `client` (a caller's checkpoints around each one):
|
|
116
|
+
* so the rollbacks are still counted by the handle, and what the transaction
|
|
117
|
+
* has established is still found. On a bare client, a bare view. */
|
|
118
|
+
export declare function transactionView(client: PgQuery, query: PgQuery['query']): PgQuery;
|
|
119
|
+
/** The transaction a handle or view belongs to, as an object only they
|
|
120
|
+
* share; undefined for a bare client, so nothing is kept on one. */
|
|
121
|
+
export declare function transactionOf(client: PgQuery): object | undefined;
|
|
122
|
+
/** A statement failed for a table, column or privilege that is not what it was, or a reference that broke: a runtime store may have moved. */
|
|
123
|
+
export declare function suspectsStores(error: unknown): boolean;
|
|
124
|
+
export declare const attestedOn: (origin: object, key: string) => boolean;
|
|
125
|
+
export declare function keepAttestedOn(origin: object, key: string): void;
|
|
126
|
+
export declare const forgetAttestations: (origin: object, client?: PgQuery, error?: unknown) => void;
|
|
127
|
+
/** Whether a message may change the catalog: DDL, or code that may run it. */
|
|
128
|
+
export declare const changesCatalog: (text: string) => boolean;
|
|
129
|
+
/** Say the exact catalog version `client`'s transaction read, before anything it attests: its digest or its epoch.
|
|
130
|
+
* `reread` reads it again, for a transaction whose statements each see the latest commit (READ COMMITTED); a
|
|
131
|
+
* snapshot's needs none. Undefined unsays it, for a transaction begun again on the same client that read none. */
|
|
132
|
+
export declare function noteCatalogVersion(client: PgQuery, database: string, version: string | undefined, reread?: () => Promise<string | undefined>): void;
|
|
133
|
+
/** How a transaction on `origin`'s handles reads an exact catalog version of `database` when it has read none. */
|
|
134
|
+
export declare function readsCatalogVersion(origin: object, database: string, read: (client: PgQuery) => Promise<string>): void;
|
|
135
|
+
/**
|
|
136
|
+
* Attest a runtime store in full (`full`, which refuses) unless the adapter
|
|
137
|
+
* this transaction runs on attested it under `key` already, or any transaction
|
|
138
|
+
* on the same database did under the exact catalog version this one read
|
|
139
|
+
* (sharedAttestations) — read now, if it read none and its adapter says how —
|
|
140
|
+
* and its meta row still binds it (`rebound`, without which nothing is shared).
|
|
141
|
+
* Otherwise, off a handle or on one made without an adapter, always in full.
|
|
142
|
+
*/
|
|
143
|
+
export declare function attestOnce(client: PgQuery, key: string, full: () => Promise<void>, rebound?: () => Promise<boolean>): Promise<void>;
|
|
144
|
+
/** How many rollbacks have passed through this transaction's handle; undefined
|
|
145
|
+
* for anything that is not one. */
|
|
146
|
+
export declare function transactionRollbacks(client: PgQuery): number | undefined;
|
|
147
|
+
/** A statement for pipelined(): bare text goes by the simple protocol, which may carry several. */
|
|
148
|
+
export type PipelinedStatement = string | Readonly<{
|
|
149
|
+
text: string;
|
|
150
|
+
values?: readonly unknown[];
|
|
151
|
+
}>;
|
|
152
|
+
/**
|
|
153
|
+
* Statements asked together and answered in order, on a transaction's handle
|
|
154
|
+
* or view: one round trip where its client pipelines (a writer's,
|
|
155
|
+
* postgresPool.ts), one each where it does not, with the same answers.
|
|
156
|
+
*
|
|
157
|
+
* Only inside the transaction — the handle's BEGIN sent first, on this handle
|
|
158
|
+
* or as the first statement here. There a statement that fails aborts the
|
|
159
|
+
* transaction, and every one sent behind it fails without effect ("current
|
|
160
|
+
* transaction is aborted"), so nothing runs that depended on one that did not;
|
|
161
|
+
* outside a transaction block each would commit on its own, which is why a
|
|
162
|
+
* bare client is refused. Every answer is awaited before this returns or
|
|
163
|
+
* throws, so the connection is never left mid-pipeline, and the first failure
|
|
164
|
+
* in order is the one thrown: the ones behind it only say it happened.
|
|
165
|
+
*
|
|
166
|
+
* `check` reads each answer as it arrives, in order, before the next one is
|
|
167
|
+
* read: a check that throws is the failure (the caller rolls the transaction
|
|
168
|
+
* back), and no later answer reaches a check. Behind a transaction-mode pooler
|
|
169
|
+
* (PgBouncer) a pipeline stays on its one server connection: the server says
|
|
170
|
+
* it is idle only after the COMMIT or ROLLBACK that ends the transaction, which
|
|
171
|
+
* this never sends ahead of a statement that could still fail.
|
|
172
|
+
*/
|
|
173
|
+
export declare function pipelined(client: PgQuery, statements: readonly PipelinedStatement[], check?: (result: PgResult<Record<string, unknown>> | PgResult<Record<string, unknown>>[], index: number) => void): Promise<Array<PgResult<Record<string, unknown>> | PgResult<Record<string, unknown>>[]>>;
|