@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,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A migrations directory in Flyway's format: what is in it, and what each
|
|
3
|
+
* file's history row must say.
|
|
4
|
+
*
|
|
5
|
+
* The format is Flyway's so a team already on Flyway keeps its files, and can
|
|
6
|
+
* switch either way: `V3__add_payoff_quote.sql` is version 3, "add payoff
|
|
7
|
+
* quote"; `R__views.sql` is repeatable, run again whenever it changes; the
|
|
8
|
+
* directory is read recursively and a file's script is its path under it.
|
|
9
|
+
* The checksum is Flyway's own: CRC32 over the file's lines as UTF-8, with the
|
|
10
|
+
* line breaks and a leading byte-order mark left out, as a signed 32-bit
|
|
11
|
+
* integer — checked against flyway-core 13.8 in test/migrate.test.ts, so
|
|
12
|
+
* `flyway validate` and `tablewalk migrate validate` agree about a file.
|
|
13
|
+
*
|
|
14
|
+
* A file may carry a Flyway script config beside it (`V4__index.sql.conf`)
|
|
15
|
+
* whose one understood line is `executeInTransaction=false`, for a statement
|
|
16
|
+
* PostgreSQL will not run in a transaction (`CREATE INDEX CONCURRENTLY`).
|
|
17
|
+
*/
|
|
18
|
+
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
19
|
+
import { join, relative, sep } from 'node:path';
|
|
20
|
+
import { crc32 } from 'node:zlib';
|
|
21
|
+
const VERSIONED = /^V(\d+(?:[._]\d+)*)__(.+)\.sql$/;
|
|
22
|
+
const REPEATABLE = /^R__(.+)\.sql$/;
|
|
23
|
+
/** Flyway's checksum of a script's text. */
|
|
24
|
+
export function flywayChecksum(text) {
|
|
25
|
+
const body = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
26
|
+
const lines = body.split(/\r\n|\r|\n/);
|
|
27
|
+
// A final line break ends the last line; it does not start another (Java's readLine).
|
|
28
|
+
if (lines.length && lines[lines.length - 1] === '')
|
|
29
|
+
lines.pop();
|
|
30
|
+
let sum = 0;
|
|
31
|
+
for (const line of lines)
|
|
32
|
+
sum = crc32(Buffer.from(line, 'utf8'), sum);
|
|
33
|
+
return sum | 0;
|
|
34
|
+
}
|
|
35
|
+
/** Flyway's order of versions: dotted parts compared as numbers, a missing part as 0. */
|
|
36
|
+
export function compareVersions(a, b) {
|
|
37
|
+
const left = a.split('.').map(BigInt);
|
|
38
|
+
const right = b.split('.').map(BigInt);
|
|
39
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
40
|
+
const x = left[i] ?? 0n;
|
|
41
|
+
const y = right[i] ?? 0n;
|
|
42
|
+
if (x !== y)
|
|
43
|
+
return x < y ? -1 : 1;
|
|
44
|
+
}
|
|
45
|
+
return 0;
|
|
46
|
+
}
|
|
47
|
+
function transactional(path) {
|
|
48
|
+
const conf = `${path}.conf`;
|
|
49
|
+
if (!existsSync(conf))
|
|
50
|
+
return true;
|
|
51
|
+
for (const raw of readFileSync(conf, 'utf8').split(/\r?\n/)) {
|
|
52
|
+
const line = raw.trim();
|
|
53
|
+
if (!line || line.startsWith('#'))
|
|
54
|
+
continue;
|
|
55
|
+
const match = /^executeInTransaction\s*=\s*(true|false)$/.exec(line);
|
|
56
|
+
if (!match)
|
|
57
|
+
throw new Error(`${conf}: "${line}" is not understood; the one setting a script config takes here is executeInTransaction=false.`);
|
|
58
|
+
return match[1] === 'true';
|
|
59
|
+
}
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/** Every migration under `dir`, versioned ones in version order, then the repeatables by description. */
|
|
63
|
+
export function readMigrations(dir) {
|
|
64
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory())
|
|
65
|
+
return { dir, files: [], ignored: [] };
|
|
66
|
+
const files = [];
|
|
67
|
+
const ignored = [];
|
|
68
|
+
for (const entry of readdirSync(dir, { recursive: true, withFileTypes: true })) {
|
|
69
|
+
if (!entry.isFile() || !entry.name.endsWith('.sql'))
|
|
70
|
+
continue;
|
|
71
|
+
const path = join(entry.parentPath, entry.name);
|
|
72
|
+
const script = relative(dir, path).split(sep).join('/');
|
|
73
|
+
const versioned = VERSIONED.exec(entry.name);
|
|
74
|
+
const repeatable = REPEATABLE.exec(entry.name);
|
|
75
|
+
if (!versioned && !repeatable) {
|
|
76
|
+
if (/^[VRUB]\d*_/i.test(entry.name))
|
|
77
|
+
ignored.push(script);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const sql = readFileSync(path, 'utf8');
|
|
81
|
+
files.push({
|
|
82
|
+
kind: versioned ? 'versioned' : 'repeatable',
|
|
83
|
+
...(versioned ? { version: versioned[1].replace(/_/g, '.') } : {}),
|
|
84
|
+
description: (versioned ? versioned[2] : repeatable[1]).replace(/_/g, ' '),
|
|
85
|
+
script,
|
|
86
|
+
path,
|
|
87
|
+
sql,
|
|
88
|
+
checksum: flywayChecksum(sql),
|
|
89
|
+
transactional: transactional(path),
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
files.sort((a, b) => a.kind !== b.kind
|
|
93
|
+
? a.kind === 'versioned'
|
|
94
|
+
? -1
|
|
95
|
+
: 1
|
|
96
|
+
: a.version !== undefined && b.version !== undefined
|
|
97
|
+
? compareVersions(a.version, b.version)
|
|
98
|
+
: a.description < b.description
|
|
99
|
+
? -1
|
|
100
|
+
: a.description > b.description
|
|
101
|
+
? 1
|
|
102
|
+
: 0);
|
|
103
|
+
return { dir, files, ignored };
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Write the next migration's file, empty but for a line that says what the
|
|
107
|
+
* runner will do with it. The version is one past the highest the directory
|
|
108
|
+
* holds, in the directory's own style: a team that numbers by timestamp gets a
|
|
109
|
+
* timestamp. `body` is the file's text when something already wrote it
|
|
110
|
+
* (`migrate diff`).
|
|
111
|
+
*/
|
|
112
|
+
export function newMigration(dir, name, repeatable, now = new Date(), body) {
|
|
113
|
+
const slug = name
|
|
114
|
+
.trim()
|
|
115
|
+
.replace(/[^A-Za-z0-9]+/g, '_')
|
|
116
|
+
.replace(/^_+|_+$/g, '');
|
|
117
|
+
if (!slug)
|
|
118
|
+
throw new Error(`"${name}" gives the file no name: use letters or digits, like add_payoff_quote.`);
|
|
119
|
+
mkdirSync(dir, { recursive: true });
|
|
120
|
+
const { files } = readMigrations(dir);
|
|
121
|
+
let file;
|
|
122
|
+
if (repeatable) {
|
|
123
|
+
file = `R__${slug}.sql`;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const majors = files.filter((f) => f.version !== undefined).map((f) => BigInt(f.version.split('.')[0]));
|
|
127
|
+
const highest = majors.reduce((a, b) => (b > a ? b : a), 0n);
|
|
128
|
+
// Fourteen digits or more is a yyyyMMddHHmmss scheme: keep it.
|
|
129
|
+
const stamp = BigInt(now.toISOString().replace(/\D/g, '').slice(0, 14));
|
|
130
|
+
const next = highest >= 10000000000000n ? (stamp > highest ? stamp : highest + 1n) : highest + 1n;
|
|
131
|
+
file = `V${next}__${slug}.sql`;
|
|
132
|
+
}
|
|
133
|
+
const path = join(dir, file);
|
|
134
|
+
if (existsSync(path))
|
|
135
|
+
throw new Error(`${path} already exists.`);
|
|
136
|
+
writeFileSync(path, body ??
|
|
137
|
+
(repeatable
|
|
138
|
+
? `-- Runs again, after the versioned migrations, whenever this file changes: views, functions, grants.\n`
|
|
139
|
+
: `-- Runs once, in version order. Forward only: a later migration undoes what this one does.\n`), { flag: 'wx' });
|
|
140
|
+
return path;
|
|
141
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Dialect } from './database.js';
|
|
2
|
+
import type { MigrateTarget } from './runner.js';
|
|
3
|
+
export declare const FLYWAY_COMMANDS: Readonly<Record<string, string>>;
|
|
4
|
+
/** A connection URL as Flyway's JDBC settings. */
|
|
5
|
+
export declare function flywaySettings(url: string, dialect: Dialect): Record<string, string>;
|
|
6
|
+
/** Run `flyway <command>` with the target's settings; its output passes through. Resolves to its exit code. */
|
|
7
|
+
export declare function runFlyway(command: string, target: MigrateTarget, dialect: Dialect, write: (line: string) => void): Promise<number>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `--tool flyway`: the same commands run by an installed Flyway instead of
|
|
3
|
+
* tablewalk's runner, for a team that wants the real thing. The files and the
|
|
4
|
+
* history table are the same ones either way (the layout is Flyway's and the
|
|
5
|
+
* table is named to Flyway with `FLYWAY_TABLE`), so a team can switch tools
|
|
6
|
+
* in either direction between two deploys.
|
|
7
|
+
*
|
|
8
|
+
* Everything reaches Flyway through its environment variables, never its
|
|
9
|
+
* command line: a password on argv is readable by every user of the machine
|
|
10
|
+
* in the process list. What only tablewalk can do still happens around it —
|
|
11
|
+
* the schema recorded after `up` for drift, and the App checked.
|
|
12
|
+
*/
|
|
13
|
+
import { spawn } from 'node:child_process';
|
|
14
|
+
import { resolve } from 'node:path';
|
|
15
|
+
import { sqlitePath } from './database.js';
|
|
16
|
+
import { envName, product, productEnv } from '../product.js';
|
|
17
|
+
export const FLYWAY_COMMANDS = {
|
|
18
|
+
up: 'migrate',
|
|
19
|
+
status: 'info',
|
|
20
|
+
validate: 'validate',
|
|
21
|
+
baseline: 'baseline',
|
|
22
|
+
repair: 'repair',
|
|
23
|
+
};
|
|
24
|
+
/** A connection URL as Flyway's JDBC settings. */
|
|
25
|
+
export function flywaySettings(url, dialect) {
|
|
26
|
+
if (dialect === 'sqlite')
|
|
27
|
+
return { FLYWAY_URL: `jdbc:sqlite:${resolve(sqlitePath(url))}` };
|
|
28
|
+
const parsed = new URL(url);
|
|
29
|
+
return {
|
|
30
|
+
FLYWAY_URL: `jdbc:postgresql://${parsed.host}${parsed.pathname}${parsed.search}`,
|
|
31
|
+
...(parsed.username ? { FLYWAY_USER: decodeURIComponent(parsed.username) } : {}),
|
|
32
|
+
...(parsed.password ? { FLYWAY_PASSWORD: decodeURIComponent(parsed.password) } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Run `flyway <command>` with the target's settings; its output passes through. Resolves to its exit code. */
|
|
36
|
+
export function runFlyway(command, target, dialect, write) {
|
|
37
|
+
const env = {
|
|
38
|
+
...process.env,
|
|
39
|
+
...flywaySettings(target.url, dialect),
|
|
40
|
+
FLYWAY_LOCATIONS: `filesystem:${target.dir}`,
|
|
41
|
+
FLYWAY_TABLE: target.table,
|
|
42
|
+
FLYWAY_BASELINE_VERSION: '0',
|
|
43
|
+
...(target.schemas.length ? { FLYWAY_SCHEMAS: target.schemas.join(',') } : {}),
|
|
44
|
+
};
|
|
45
|
+
return new Promise((done) => {
|
|
46
|
+
const child = spawn(productEnv('FLYWAY') ?? 'flyway', [FLYWAY_COMMANDS[command]], { env, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
47
|
+
let pending = '';
|
|
48
|
+
const forward = (chunk) => {
|
|
49
|
+
pending += String(chunk);
|
|
50
|
+
const lines = pending.split('\n');
|
|
51
|
+
pending = lines.pop() ?? '';
|
|
52
|
+
for (const line of lines)
|
|
53
|
+
write(` flyway: ${line}`);
|
|
54
|
+
};
|
|
55
|
+
child.stdout.on('data', forward);
|
|
56
|
+
child.stderr.on('data', forward);
|
|
57
|
+
child.once('error', (error) => {
|
|
58
|
+
write(error.code === 'ENOENT'
|
|
59
|
+
? `Flyway is not installed where this can find it: put flyway on the PATH (or set ${envName('FLYWAY')} to its path), or drop --tool flyway to use ${product()}'s own runner.`
|
|
60
|
+
: `Flyway could not be started: ${error.message}`);
|
|
61
|
+
done(127);
|
|
62
|
+
});
|
|
63
|
+
child.once('close', (code) => {
|
|
64
|
+
if (pending)
|
|
65
|
+
write(` flyway: ${pending}`);
|
|
66
|
+
done(code ?? 1);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The history table: Flyway's layout, column for column and engine by engine,
|
|
3
|
+
* so Flyway reads what tablewalk wrote and tablewalk reads what Flyway wrote.
|
|
4
|
+
* Only the name is tablewalk's: `__mistri_schema_history` by default, a
|
|
5
|
+
* reserved runtime table (shared/runtimeTables.ts), so an App never lists it,
|
|
6
|
+
* a tenant App's database may hold it, and it is never another team's
|
|
7
|
+
* `flyway_schema_history`. Naming theirs is how a team moves over from Flyway,
|
|
8
|
+
* and it is said, never assumed.
|
|
9
|
+
*/
|
|
10
|
+
import { type MigrationDb } from './database.js';
|
|
11
|
+
import { type MigrationFile } from './files.js';
|
|
12
|
+
export declare const DEFAULT_HISTORY_TABLE = "__mistri_schema_history";
|
|
13
|
+
interface HistoryRow {
|
|
14
|
+
readonly installed_rank: number;
|
|
15
|
+
readonly version: string | null;
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly type: string;
|
|
18
|
+
readonly script: string;
|
|
19
|
+
readonly checksum: number | null;
|
|
20
|
+
readonly installed_by: string;
|
|
21
|
+
readonly installed_on: string;
|
|
22
|
+
readonly execution_time: number;
|
|
23
|
+
readonly success: boolean;
|
|
24
|
+
}
|
|
25
|
+
export declare const BASELINE_DESCRIPTION = "<< Flyway Baseline >>";
|
|
26
|
+
export declare function qualified(db: MigrationDb, table: string): string;
|
|
27
|
+
/** The DDL Flyway itself runs for this table (its createMetaDataTable.sql per engine). */
|
|
28
|
+
export declare function historyDdl(db: MigrationDb, table: string): string[];
|
|
29
|
+
export declare function historyExists(db: MigrationDb, table: string): Promise<boolean>;
|
|
30
|
+
/** Every row, in the order they were installed. A table in another layout is refused, never written. */
|
|
31
|
+
export declare function readHistory(db: MigrationDb, table: string): Promise<HistoryRow[]>;
|
|
32
|
+
export declare function insertHistory(db: MigrationDb, table: string, row: {
|
|
33
|
+
version: string | null;
|
|
34
|
+
description: string;
|
|
35
|
+
type: string;
|
|
36
|
+
script: string;
|
|
37
|
+
checksum: number | null;
|
|
38
|
+
executionTime: number;
|
|
39
|
+
success: boolean;
|
|
40
|
+
}): Promise<void>;
|
|
41
|
+
/** What the rows say, as Flyway reads them: a later DELETE row cancels the one it names. */
|
|
42
|
+
export interface History {
|
|
43
|
+
readonly rows: readonly HistoryRow[];
|
|
44
|
+
readonly baseline?: HistoryRow;
|
|
45
|
+
/** Each versioned migration in force, by version. */
|
|
46
|
+
readonly versioned: ReadonlyMap<string, HistoryRow>;
|
|
47
|
+
/** Each repeatable's latest run in force, by description. */
|
|
48
|
+
readonly repeatable: ReadonlyMap<string, HistoryRow>;
|
|
49
|
+
readonly failed: readonly HistoryRow[];
|
|
50
|
+
readonly lastRank: number;
|
|
51
|
+
}
|
|
52
|
+
export declare function readRows(rows: readonly HistoryRow[]): History;
|
|
53
|
+
export interface Plan {
|
|
54
|
+
readonly history: History;
|
|
55
|
+
readonly pending: readonly MigrationFile[];
|
|
56
|
+
/** What stops a run: said per file, with what to do. */
|
|
57
|
+
readonly problems: readonly string[];
|
|
58
|
+
/** Said, never a failure: an applied version newer than every file (Flyway's "future"). */
|
|
59
|
+
readonly notes: readonly string[];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Files against history, with Flyway's rules: an applied file must still be
|
|
63
|
+
* there with the same checksum and description; a failed row stops everything
|
|
64
|
+
* until it is repaired; a new version below the newest applied one is out of
|
|
65
|
+
* order and refused, since running it would apply a change out of the order
|
|
66
|
+
* the others were tested in; a repeatable is pending when it is new or has
|
|
67
|
+
* changed. A version at or below the baseline is the baseline's.
|
|
68
|
+
*/
|
|
69
|
+
export declare function plan(files: readonly MigrationFile[], history: History): Plan;
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The history table: Flyway's layout, column for column and engine by engine,
|
|
3
|
+
* so Flyway reads what tablewalk wrote and tablewalk reads what Flyway wrote.
|
|
4
|
+
* Only the name is tablewalk's: `__mistri_schema_history` by default, a
|
|
5
|
+
* reserved runtime table (shared/runtimeTables.ts), so an App never lists it,
|
|
6
|
+
* a tenant App's database may hold it, and it is never another team's
|
|
7
|
+
* `flyway_schema_history`. Naming theirs is how a team moves over from Flyway,
|
|
8
|
+
* and it is said, never assumed.
|
|
9
|
+
*/
|
|
10
|
+
import { quoteIdent } from './database.js';
|
|
11
|
+
import { compareVersions } from './files.js';
|
|
12
|
+
import { product } from '../product.js';
|
|
13
|
+
export const DEFAULT_HISTORY_TABLE = '__mistri_schema_history';
|
|
14
|
+
export const BASELINE_DESCRIPTION = '<< Flyway Baseline >>';
|
|
15
|
+
export function qualified(db, table) {
|
|
16
|
+
return db.home === undefined ? quoteIdent(db.dialect, table) : `${quoteIdent(db.dialect, db.home)}.${quoteIdent(db.dialect, table)}`;
|
|
17
|
+
}
|
|
18
|
+
/** The DDL Flyway itself runs for this table (its createMetaDataTable.sql per engine). */
|
|
19
|
+
export function historyDdl(db, table) {
|
|
20
|
+
const name = qualified(db, table);
|
|
21
|
+
const index = quoteIdent(db.dialect, `${table}_s_idx`);
|
|
22
|
+
if (db.dialect === 'sqlite') {
|
|
23
|
+
return [
|
|
24
|
+
`CREATE TABLE ${name} (
|
|
25
|
+
"installed_rank" INT NOT NULL PRIMARY KEY,
|
|
26
|
+
"version" VARCHAR(50),
|
|
27
|
+
"description" VARCHAR(200) NOT NULL,
|
|
28
|
+
"type" VARCHAR(20) NOT NULL,
|
|
29
|
+
"script" VARCHAR(1000) NOT NULL,
|
|
30
|
+
"checksum" INT,
|
|
31
|
+
"installed_by" VARCHAR(100) NOT NULL,
|
|
32
|
+
"installed_on" TEXT NOT NULL DEFAULT (strftime('%Y-%m-%d %H:%M:%f','now')),
|
|
33
|
+
"execution_time" INT NOT NULL,
|
|
34
|
+
"success" BOOLEAN NOT NULL
|
|
35
|
+
)`,
|
|
36
|
+
`CREATE INDEX ${index} ON ${name} ("success")`,
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
return [
|
|
40
|
+
`CREATE TABLE ${name} (
|
|
41
|
+
"installed_rank" INT NOT NULL,
|
|
42
|
+
"version" VARCHAR(50),
|
|
43
|
+
"description" VARCHAR(200) NOT NULL,
|
|
44
|
+
"type" VARCHAR(20) NOT NULL,
|
|
45
|
+
"script" VARCHAR(1000) NOT NULL,
|
|
46
|
+
"checksum" INTEGER,
|
|
47
|
+
"installed_by" VARCHAR(100) NOT NULL,
|
|
48
|
+
"installed_on" TIMESTAMP NOT NULL DEFAULT now(),
|
|
49
|
+
"execution_time" INTEGER NOT NULL,
|
|
50
|
+
"success" BOOLEAN NOT NULL
|
|
51
|
+
)`,
|
|
52
|
+
`ALTER TABLE ${name} ADD CONSTRAINT ${quoteIdent('postgres', `${table}_pk`)} PRIMARY KEY ("installed_rank")`,
|
|
53
|
+
`CREATE INDEX ${index} ON ${name} ("success")`,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
export async function historyExists(db, table) {
|
|
57
|
+
const rows = db.dialect === 'sqlite'
|
|
58
|
+
? await db.all("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?", [table])
|
|
59
|
+
: db.dialect === 'postgres'
|
|
60
|
+
? await db.all('SELECT 1 FROM pg_catalog.pg_tables WHERE schemaname = ? AND tablename = ?', [db.home, table])
|
|
61
|
+
: [];
|
|
62
|
+
return rows.length > 0;
|
|
63
|
+
}
|
|
64
|
+
/** Every row, in the order they were installed. A table in another layout is refused, never written. */
|
|
65
|
+
export async function readHistory(db, table) {
|
|
66
|
+
if (!(await historyExists(db, table)))
|
|
67
|
+
return [];
|
|
68
|
+
let rows;
|
|
69
|
+
try {
|
|
70
|
+
// The time as text to the second, as each engine keeps it: a Date would be read in this machine's zone.
|
|
71
|
+
const on = db.dialect === 'postgres' ? "to_char(installed_on, 'YYYY-MM-DD HH24:MI:SS')" : 'substr(installed_on, 1, 19)';
|
|
72
|
+
rows =
|
|
73
|
+
await db.all(`SELECT installed_rank, version, description, type, script, checksum, installed_by, ${on} AS installed_on, execution_time, success
|
|
74
|
+
FROM ${qualified(db, table)} ORDER BY installed_rank`);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
throw new Error(`${table} is not a Flyway-layout history table; name another with --history-table.`);
|
|
78
|
+
}
|
|
79
|
+
return rows.map((row) => ({
|
|
80
|
+
installed_rank: Number(row.installed_rank),
|
|
81
|
+
version: row.version === null ? null : String(row.version),
|
|
82
|
+
description: String(row.description),
|
|
83
|
+
type: String(row.type),
|
|
84
|
+
script: String(row.script),
|
|
85
|
+
checksum: row.checksum === null || row.checksum === undefined ? null : Number(row.checksum),
|
|
86
|
+
installed_by: String(row.installed_by ?? ''),
|
|
87
|
+
installed_on: String(row.installed_on),
|
|
88
|
+
execution_time: Number(row.execution_time),
|
|
89
|
+
success: row.success === true || row.success === 1 || row.success === '1' || row.success === 't',
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
export async function insertHistory(db, table, row) {
|
|
93
|
+
const name = qualified(db, table);
|
|
94
|
+
const [{ next }] = await db.all(`SELECT COALESCE(MAX(installed_rank), 0) + 1 AS next FROM ${name}`);
|
|
95
|
+
await db.run(`INSERT INTO ${name} (installed_rank, version, description, type, script, checksum, installed_by, execution_time, success)
|
|
96
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
97
|
+
Number(next),
|
|
98
|
+
row.version,
|
|
99
|
+
row.description,
|
|
100
|
+
row.type,
|
|
101
|
+
row.script,
|
|
102
|
+
row.checksum,
|
|
103
|
+
db.user,
|
|
104
|
+
row.executionTime,
|
|
105
|
+
db.dialect === 'postgres' ? row.success : row.success ? 1 : 0,
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
export function readRows(rows) {
|
|
109
|
+
let baseline;
|
|
110
|
+
const versioned = new Map();
|
|
111
|
+
const repeatable = new Map();
|
|
112
|
+
const failed = [];
|
|
113
|
+
for (const row of rows) {
|
|
114
|
+
if (row.type === 'BASELINE') {
|
|
115
|
+
baseline = row;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
if (row.type === 'SCHEMA')
|
|
119
|
+
continue;
|
|
120
|
+
const map = row.version === null ? repeatable : versioned;
|
|
121
|
+
const key = row.version ?? row.description;
|
|
122
|
+
if (row.type === 'DELETE') {
|
|
123
|
+
map.delete(key);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
if (!row.success) {
|
|
127
|
+
failed.push(row);
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (row.version !== null) {
|
|
131
|
+
// A version applied twice is Flyway's to have refused; the first stands.
|
|
132
|
+
if (!versioned.has(key))
|
|
133
|
+
versioned.set(key, row);
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
repeatable.set(key, row);
|
|
137
|
+
}
|
|
138
|
+
return { rows, baseline, versioned, repeatable, failed, lastRank: rows.reduce((max, row) => Math.max(max, row.installed_rank), 0) };
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Files against history, with Flyway's rules: an applied file must still be
|
|
142
|
+
* there with the same checksum and description; a failed row stops everything
|
|
143
|
+
* until it is repaired; a new version below the newest applied one is out of
|
|
144
|
+
* order and refused, since running it would apply a change out of the order
|
|
145
|
+
* the others were tested in; a repeatable is pending when it is new or has
|
|
146
|
+
* changed. A version at or below the baseline is the baseline's.
|
|
147
|
+
*/
|
|
148
|
+
export function plan(files, history) {
|
|
149
|
+
const problems = [];
|
|
150
|
+
const notes = [];
|
|
151
|
+
const baseline = history.baseline?.version ?? undefined;
|
|
152
|
+
const above = (version) => baseline === undefined || compareVersions(version, baseline) > 0;
|
|
153
|
+
const seen = new Map();
|
|
154
|
+
for (const file of files) {
|
|
155
|
+
if (file.version === undefined)
|
|
156
|
+
continue;
|
|
157
|
+
const twin = [...seen.values()].find((other) => compareVersions(other.version, file.version) === 0);
|
|
158
|
+
if (twin)
|
|
159
|
+
problems.push(`${file.script} and ${twin.script} are both version ${file.version}: give one of them the next free version.`);
|
|
160
|
+
seen.set(file.version, file);
|
|
161
|
+
}
|
|
162
|
+
for (const row of history.failed) {
|
|
163
|
+
problems.push(`${row.script} failed on ${row.installed_on}. What it did before it failed may still be there: undo or finish it by hand, then \`${product()} migrate repair\` removes the failed entry.`);
|
|
164
|
+
}
|
|
165
|
+
const byVersion = (version) => files.find((file) => file.version !== undefined && compareVersions(file.version, version) === 0);
|
|
166
|
+
const highestFile = files.reduce((max, file) => (file.version !== undefined && (max === undefined || compareVersions(file.version, max) > 0) ? file.version : max), undefined);
|
|
167
|
+
let highestApplied;
|
|
168
|
+
for (const [version, row] of history.versioned) {
|
|
169
|
+
if (highestApplied === undefined || compareVersions(version, highestApplied) > 0)
|
|
170
|
+
highestApplied = version;
|
|
171
|
+
const file = byVersion(version);
|
|
172
|
+
if (!file) {
|
|
173
|
+
if (highestFile !== undefined && compareVersions(version, highestFile) > 0)
|
|
174
|
+
notes.push(`version ${version} (${row.script}) is applied but has no file here: a newer checkout applied it.`);
|
|
175
|
+
else
|
|
176
|
+
problems.push(`${row.script} was applied on ${row.installed_on} and is not in the directory any more. Put it back, or \`${product()} migrate repair\` marks it deleted.`);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (row.checksum !== file.checksum) {
|
|
180
|
+
problems.push(`${file.script} changed after it was applied (checksum ${row.checksum} applied, ${file.checksum} now). Put it back as it was and write the change as a new migration, or \`${product()} migrate repair\` accepts the file as it is now.`);
|
|
181
|
+
}
|
|
182
|
+
else if (row.description !== file.description) {
|
|
183
|
+
problems.push(`${file.script} was applied as "${row.description}"; its name now says "${file.description}". Rename it back, or \`${product()} migrate repair\`.`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const [description, row] of history.repeatable) {
|
|
187
|
+
if (!files.some((file) => file.kind === 'repeatable' && file.description === description)) {
|
|
188
|
+
problems.push(`${row.script} was applied and is not in the directory any more. Put it back, or \`${product()} migrate repair\` marks it deleted.`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const pending = [];
|
|
192
|
+
for (const file of files) {
|
|
193
|
+
if (file.kind === 'versioned') {
|
|
194
|
+
if (history.versioned.has(file.version) || [...history.versioned.keys()].some((v) => compareVersions(v, file.version) === 0))
|
|
195
|
+
continue;
|
|
196
|
+
if (!above(file.version))
|
|
197
|
+
continue;
|
|
198
|
+
if (highestApplied !== undefined && compareVersions(file.version, highestApplied) < 0) {
|
|
199
|
+
problems.push(`${file.script} is new, but version ${highestApplied} is already applied: give it a version after ${highestApplied}.`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
pending.push(file);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
const applied = history.repeatable.get(file.description);
|
|
206
|
+
if (!applied || applied.checksum !== file.checksum)
|
|
207
|
+
pending.push(file);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return { history, pending, problems, notes };
|
|
211
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type Dialect } from './database.js';
|
|
2
|
+
import { type MigrationDirectory, type MigrationFile } from './files.js';
|
|
3
|
+
import { type Plan } from './history.js';
|
|
4
|
+
import { type Change, type Objects, type StoredSnapshot } from './snapshot.js';
|
|
5
|
+
export interface MigrateTarget {
|
|
6
|
+
/** The resolved URL or SQLite path: secrets expanded, never printed. */
|
|
7
|
+
readonly url: string;
|
|
8
|
+
/** The schemas the run owns: PostgreSQL's first is where the history lives. */
|
|
9
|
+
readonly schemas: readonly string[];
|
|
10
|
+
readonly dir: string;
|
|
11
|
+
readonly table: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Status {
|
|
14
|
+
readonly dialect: Dialect;
|
|
15
|
+
readonly home: string | undefined;
|
|
16
|
+
readonly directory: MigrationDirectory;
|
|
17
|
+
readonly plan: Plan;
|
|
18
|
+
readonly started: boolean;
|
|
19
|
+
/** Changes made outside migrations since the last run recorded the schema. */
|
|
20
|
+
readonly drift?: readonly Change[];
|
|
21
|
+
readonly snapshot?: StoredSnapshot;
|
|
22
|
+
/** History rows written after the recorded schema: another runner's, whose changes read as drift. */
|
|
23
|
+
readonly behind: number;
|
|
24
|
+
/** With no history yet: the tables and views already there, which want a baseline before anything runs. */
|
|
25
|
+
readonly holds: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function migrationStatus(target: MigrateTarget): Promise<Status>;
|
|
28
|
+
interface UpResult {
|
|
29
|
+
readonly status: Status;
|
|
30
|
+
readonly applied: ReadonlyArray<{
|
|
31
|
+
readonly file: MigrationFile;
|
|
32
|
+
readonly ms: number;
|
|
33
|
+
}>;
|
|
34
|
+
/** Set when a file failed: the run stopped there. */
|
|
35
|
+
readonly failure?: {
|
|
36
|
+
readonly file: MigrationFile;
|
|
37
|
+
readonly message: string;
|
|
38
|
+
readonly recorded: boolean;
|
|
39
|
+
};
|
|
40
|
+
/** Set when the database was refused before anything ran. */
|
|
41
|
+
readonly refused?: string;
|
|
42
|
+
/** With dryRun: what would run, in order. */
|
|
43
|
+
readonly wouldRun?: readonly MigrationFile[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Apply every pending migration. Under the run's lock the plan is read again
|
|
47
|
+
* before each file, so a second deploy that waited finds the first's work
|
|
48
|
+
* done and applies nothing twice.
|
|
49
|
+
*/
|
|
50
|
+
export declare function migrateUp(target: MigrateTarget, options?: {
|
|
51
|
+
dryRun?: boolean;
|
|
52
|
+
waiting?: () => void;
|
|
53
|
+
}): Promise<UpResult>;
|
|
54
|
+
export interface Validation {
|
|
55
|
+
readonly status: Status;
|
|
56
|
+
readonly valid: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Flyway's validate — every applied file unchanged and present, nothing
|
|
60
|
+
* pending, nothing failed — and one thing Flyway cannot see: the database
|
|
61
|
+
* is still what its migrations made it.
|
|
62
|
+
*/
|
|
63
|
+
export declare function migrateValidate(target: MigrateTarget): Promise<Validation>;
|
|
64
|
+
interface BaselineResult {
|
|
65
|
+
readonly already?: string;
|
|
66
|
+
readonly refused?: string;
|
|
67
|
+
readonly objects: Objects;
|
|
68
|
+
/** The snapshot file, and whether this run wrote it. */
|
|
69
|
+
readonly file: string;
|
|
70
|
+
readonly wrote: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Record the database as it is as version 0: nothing that exists is touched,
|
|
74
|
+
* and history starts here. The schema as read is written beside the
|
|
75
|
+
* migrations, read-only, and kept as the one migrations start from.
|
|
76
|
+
*/
|
|
77
|
+
export declare function migrateBaseline(target: MigrateTarget, options?: {
|
|
78
|
+
dryRun?: boolean;
|
|
79
|
+
}): Promise<BaselineResult>;
|
|
80
|
+
interface RepairResult {
|
|
81
|
+
readonly actions: readonly string[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Make the history agree with the files again, as Flyway's repair does:
|
|
85
|
+
* failed entries removed, an applied file's checksum and description taken
|
|
86
|
+
* from the file as it is now, a file that is gone marked deleted. And the
|
|
87
|
+
* recorded schema retaken when another runner applied migrations after it,
|
|
88
|
+
* since their changes cannot be told from drift; drift itself is never
|
|
89
|
+
* repaired away.
|
|
90
|
+
*/
|
|
91
|
+
export declare function migrateRepair(target: MigrateTarget, options?: {
|
|
92
|
+
dryRun?: boolean;
|
|
93
|
+
}): Promise<RepairResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Around a run another tool makes (`--tool flyway`): the schema read before
|
|
96
|
+
* it, and recorded after it as tablewalk's own runs record it, so drift stays
|
|
97
|
+
* measured whichever tool applied the files.
|
|
98
|
+
*/
|
|
99
|
+
export declare function recordAround(target: MigrateTarget, run: () => Promise<number>): Promise<number>;
|
|
100
|
+
export {};
|