@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,517 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tablewalk migrate`: change a database's schema with versioned SQL files in
|
|
3
|
+
* Flyway's format, and keep the App that reads it honest.
|
|
4
|
+
*
|
|
5
|
+
* tablewalk rides on the database; it does not become a database tool. So
|
|
6
|
+
* this is a small runner of the format a team may already use, with no Java
|
|
7
|
+
* to install (`npx tablewalk` has no build step), and `--tool flyway` hands
|
|
8
|
+
* the same files and history to a real Flyway. What no generic tool can do
|
|
9
|
+
* is the part tied to the App: after `up` its schema types are regenerated
|
|
10
|
+
* and `mistri check` names the view, page or command a dropped or renamed
|
|
11
|
+
* column breaks; `status` says when the types are older than the database;
|
|
12
|
+
* and a database changed by hand is said as drift.
|
|
13
|
+
*
|
|
14
|
+
* That App part is the App framework's, handed in as a `MigrateHost` by the
|
|
15
|
+
* main that has one (cli/appTargets.ts): what an App binds, its types and its
|
|
16
|
+
* check, and the commands only an App has (`stores`, `files`). This file reads
|
|
17
|
+
* the flags and the database; with no host, `--app` is refused and those
|
|
18
|
+
* commands are not offered.
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync } from 'node:fs';
|
|
21
|
+
import { dirname, relative, resolve } from 'node:path';
|
|
22
|
+
import { Registry, redact } from '../connections.js';
|
|
23
|
+
import { parseArgs } from '../cli/args.js';
|
|
24
|
+
import { readStartupConfig } from '../cli/config.js';
|
|
25
|
+
import { CACHE_SECTIONS } from '../cacheService.js';
|
|
26
|
+
import { dialectOf } from './database.js';
|
|
27
|
+
import { atlasBinary, defaultSchemaFile, diffHeader, firstHeader, firstMigration, pendingSql, squashInto } from './desired.js';
|
|
28
|
+
import { compareVersions, newMigration, readMigrations } from './files.js';
|
|
29
|
+
import { FLYWAY_COMMANDS, runFlyway } from './flyway.js';
|
|
30
|
+
import { migrateBaseline, migrateRepair, migrateUp, migrateValidate, migrationStatus, recordAround } from './runner.js';
|
|
31
|
+
import { sayChange } from './snapshot.js';
|
|
32
|
+
import { resolveTarget, targetDir } from './target.js';
|
|
33
|
+
import { product } from '../product.js';
|
|
34
|
+
const migrateUsage = () => product() +
|
|
35
|
+
' migrate <new <name> | diff <name> | check | squash | status | up | validate | baseline | repair> [--app <dir>] ' +
|
|
36
|
+
'[<db> | --db <target> | --config <path>] [--connection <name>] [--schema <name>] [--migrations <dir>] [--history-table <name>] ' +
|
|
37
|
+
'[--schema-file <path>] [--dev-url <url>] [--dry-run] [--tool flyway] [--repeatable]';
|
|
38
|
+
/** The exit codes: what went wrong, for CI. */
|
|
39
|
+
const EXIT = { ok: 0, couldNot: 1, invalid: 2, failed: 3, app: 4 };
|
|
40
|
+
const COMMANDS = ['new', 'diff', 'check', 'squash', 'status', 'up', 'validate', 'baseline', 'repair'];
|
|
41
|
+
/** The commands that compare the migrations with the desired schema.sql (desired.ts). */
|
|
42
|
+
const DESIRED = ['diff', 'check', 'squash'];
|
|
43
|
+
/* The start's own flags this command takes, and whether each has a value;
|
|
44
|
+
anything else is a mode of the server and no business of a migration. */
|
|
45
|
+
const PASSED = {
|
|
46
|
+
'--db': true,
|
|
47
|
+
'-d': true,
|
|
48
|
+
'--config': true,
|
|
49
|
+
'--no-config': false,
|
|
50
|
+
'--schema': true,
|
|
51
|
+
'--app-entry': true,
|
|
52
|
+
'--policy': true,
|
|
53
|
+
/* The App's commands module, where it is not the commands.ts beside the manifest: its journal is a store. */
|
|
54
|
+
'--commands': true,
|
|
55
|
+
};
|
|
56
|
+
const shown = (path) => {
|
|
57
|
+
const near = relative(process.cwd(), path);
|
|
58
|
+
return !near ? '.' : near.startsWith('..') ? path : near;
|
|
59
|
+
};
|
|
60
|
+
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
|
|
61
|
+
export async function runMigrate(argv, write = (line) => process.stdout.write(`${line}\n`), sections = CACHE_SECTIONS, host) {
|
|
62
|
+
const hosted = host?.commands ?? {};
|
|
63
|
+
const fail = (why, code = EXIT.couldNot) => {
|
|
64
|
+
console.error(`${product()} migrate: ${why}`);
|
|
65
|
+
return code;
|
|
66
|
+
};
|
|
67
|
+
if (!argv.length || argv[0] === '--help' || argv[0] === '-h') {
|
|
68
|
+
write(`${migrateUsage()}\n\n` +
|
|
69
|
+
"Versioned SQL files in Flyway's format (V3__add_payoff_quote.sql, R__views.sql), in migrations/ inside the App\n" +
|
|
70
|
+
'by default, run forward only, each in its own transaction.\n' +
|
|
71
|
+
' new <name> write the next V file (--repeatable: an R__ file)\n' +
|
|
72
|
+
' diff <name> write the next V file from schema.sql: what the migrations still lack to build it (Atlas;\n' +
|
|
73
|
+
' the first is schema.sql itself, with no download)\n' +
|
|
74
|
+
' check the migrations, applied to a scratch database, build schema.sql (exit 2 if not)\n' +
|
|
75
|
+
' squash fold the V files into one V1__baseline.sql holding schema.sql, before a database worth keeping exists\n' +
|
|
76
|
+
" status what is applied and pending, drift made outside migrations, and whether the App's types are older than the database\n" +
|
|
77
|
+
' (exit 2 while nothing was ever applied)\n' +
|
|
78
|
+
" up apply what is pending; with --app, regenerate the App's types and check it\n" +
|
|
79
|
+
' validate applied files unchanged, nothing pending, nothing failed, no drift (exit 2 if not)\n' +
|
|
80
|
+
' baseline record an existing database as version 0, and its schema beside the migrations\n' +
|
|
81
|
+
' repair remove failed entries, accept changed files, mark missing ones deleted\n' +
|
|
82
|
+
Object.entries(hosted)
|
|
83
|
+
.map(([word, each]) => ` ${word.padEnd(11)} ${each.says}: ${each.usage.replace(`${product()} migrate `, '')}\n`)
|
|
84
|
+
.join('') +
|
|
85
|
+
'Exit codes: 1 could not run, 2 files and history disagree, 3 a migration failed, 4 applied but the App no longer checks.\n' +
|
|
86
|
+
'mistri docs migrate is the guide.');
|
|
87
|
+
return EXIT.ok;
|
|
88
|
+
}
|
|
89
|
+
const command = argv[0];
|
|
90
|
+
const own = Object.hasOwn(hosted, argv[0]) ? hosted[argv[0]] : undefined;
|
|
91
|
+
if (!COMMANDS.includes(command) && !own)
|
|
92
|
+
return fail(`"${argv[0]}" is not a migrate command. ${migrateUsage()}`);
|
|
93
|
+
let name;
|
|
94
|
+
let app;
|
|
95
|
+
let migrations;
|
|
96
|
+
let table;
|
|
97
|
+
let connection;
|
|
98
|
+
let tool;
|
|
99
|
+
let dryRun = false;
|
|
100
|
+
let repeatable = false;
|
|
101
|
+
let schemaFile;
|
|
102
|
+
let devUrl;
|
|
103
|
+
let sub;
|
|
104
|
+
const ownFlags = {};
|
|
105
|
+
const rest = [];
|
|
106
|
+
const value = (i, flag) => {
|
|
107
|
+
const given = argv[i + 1];
|
|
108
|
+
if (given === undefined || given.startsWith('-'))
|
|
109
|
+
throw new Error(`${flag} needs a value. ${migrateUsage()}`);
|
|
110
|
+
return given;
|
|
111
|
+
};
|
|
112
|
+
try {
|
|
113
|
+
if (own) {
|
|
114
|
+
sub = argv[1];
|
|
115
|
+
if (sub === undefined)
|
|
116
|
+
throw new Error(`${own.needs} ${own.usage}`);
|
|
117
|
+
}
|
|
118
|
+
for (let i = own ? 2 : 1; i < argv.length; i++) {
|
|
119
|
+
const arg = argv[i];
|
|
120
|
+
const theirs = Object.entries(hosted).find(([, each]) => Object.hasOwn(each.takes, arg));
|
|
121
|
+
if (theirs) {
|
|
122
|
+
if (!own || !Object.hasOwn(own.takes, arg))
|
|
123
|
+
throw new Error(`${arg} is for ${theirs[0]}.`);
|
|
124
|
+
ownFlags[arg] = own.takes[arg] ? value(i++, arg) : true;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (arg === '--app') {
|
|
128
|
+
if (app !== undefined)
|
|
129
|
+
throw new Error('--app may be supplied only once.');
|
|
130
|
+
app = value(i++, arg);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (arg === '--migrations') {
|
|
134
|
+
migrations = value(i++, arg);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (arg === '--history-table') {
|
|
138
|
+
table = value(i++, arg);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (arg === '--connection') {
|
|
142
|
+
connection = value(i++, arg);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (arg === '--tool') {
|
|
146
|
+
tool = value(i++, arg);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (arg === '--schema-file') {
|
|
150
|
+
schemaFile = value(i++, arg);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (arg === '--dev-url') {
|
|
154
|
+
devUrl = value(i++, arg);
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (arg === '--dry-run') {
|
|
158
|
+
dryRun = true;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (arg === '--repeatable') {
|
|
162
|
+
repeatable = true;
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if ((command === 'new' || command === 'diff') && name === undefined && !arg.startsWith('-')) {
|
|
166
|
+
name = arg;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const flag = arg.split('=')[0];
|
|
170
|
+
if (flag in PASSED) {
|
|
171
|
+
rest.push(arg);
|
|
172
|
+
if (PASSED[flag] && !arg.includes('='))
|
|
173
|
+
rest.push(value(i++, arg));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (arg.startsWith('-'))
|
|
177
|
+
throw new Error(`"${arg}" is not an option of migrate. ${migrateUsage()}`);
|
|
178
|
+
rest.push(arg);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
return fail(error.message);
|
|
183
|
+
}
|
|
184
|
+
if (tool !== undefined && tool !== 'flyway')
|
|
185
|
+
return fail(`--tool takes flyway, the one other runner it can hand the files to; "${tool}" is not it.`);
|
|
186
|
+
if ((command === 'new' || command === 'diff') && !name)
|
|
187
|
+
return fail(`${command} needs a name: ${product()} migrate ${command} add_payoff_quote`);
|
|
188
|
+
if ((schemaFile !== undefined || devUrl !== undefined) && !DESIRED.includes(command))
|
|
189
|
+
return fail(`--schema-file and --dev-url are for diff, check and squash; ${command} does not read schema.sql.`);
|
|
190
|
+
if (DESIRED.includes(command) && (tool !== undefined || dryRun || repeatable))
|
|
191
|
+
return fail(`${command} takes no --tool, --dry-run or --repeatable: it compares schema.sql with the migrations on scratch databases.`);
|
|
192
|
+
if (own && (migrations !== undefined || table !== undefined || tool !== undefined || repeatable || (dryRun && !own.dryRun))) {
|
|
193
|
+
return fail(`${command} takes no migration-file options. ${own.usage}`);
|
|
194
|
+
}
|
|
195
|
+
if (repeatable && command !== 'new')
|
|
196
|
+
return fail('--repeatable is for new: it names the file R__<name>.sql.');
|
|
197
|
+
if (dryRun && !own && !['up', 'baseline', 'repair'].includes(command))
|
|
198
|
+
return fail(`--dry-run is for up, baseline and repair; ${command} changes nothing.`);
|
|
199
|
+
if (tool && (command === 'new' || dryRun))
|
|
200
|
+
return fail(command === 'new'
|
|
201
|
+
? 'new writes a file; no tool is needed for it.'
|
|
202
|
+
: "Flyway's dry run is not in its free edition: drop --tool flyway to see the SQL.");
|
|
203
|
+
const opts = parseArgs(rest);
|
|
204
|
+
if (opts.unknown)
|
|
205
|
+
return fail(`unknown option "${opts.unknown}". ${migrateUsage()}`);
|
|
206
|
+
const appDir = app !== undefined ? resolve(app) : undefined;
|
|
207
|
+
if (appDir !== undefined && !host)
|
|
208
|
+
return fail("--app reads an App, which is the App framework's part: " +
|
|
209
|
+
product() +
|
|
210
|
+
' migrates a database alone. Run npx @mistriwork/mistri migrate --app, or drop --app.');
|
|
211
|
+
if (appDir !== undefined && !existsSync(appDir))
|
|
212
|
+
return fail(`${app} is not a directory.`);
|
|
213
|
+
/* The database, read the way a start reads it. Its narration is not this
|
|
214
|
+
command's to print: stdout is what the migrations did. */
|
|
215
|
+
const registry = new Registry();
|
|
216
|
+
const log = console.log;
|
|
217
|
+
console.log = () => { };
|
|
218
|
+
try {
|
|
219
|
+
const config = await readStartupConfig(opts, registry, sections);
|
|
220
|
+
const argument = opts.target
|
|
221
|
+
? registry.add({ name: redact(opts.target), url: opts.target, schemas: opts.schemas, source: 'argument' }).id
|
|
222
|
+
: undefined;
|
|
223
|
+
let loaded;
|
|
224
|
+
if (appDir !== undefined) {
|
|
225
|
+
try {
|
|
226
|
+
loaded = await host.app(appDir, { opts, config, command, flags: ownFlags });
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
return fail(error.message);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const flags = { connection, argument, migrations, table, schemas: opts.schemas };
|
|
233
|
+
if (own) {
|
|
234
|
+
return await own.run({
|
|
235
|
+
sub: sub,
|
|
236
|
+
flags: ownFlags,
|
|
237
|
+
registry,
|
|
238
|
+
config,
|
|
239
|
+
opts,
|
|
240
|
+
sections,
|
|
241
|
+
...(appDir !== undefined ? { appDir } : {}),
|
|
242
|
+
...(loaded ? { app: loaded } : {}),
|
|
243
|
+
...(connection !== undefined ? { connection } : {}),
|
|
244
|
+
...(argument !== undefined ? { argument } : {}),
|
|
245
|
+
schemas: opts.schemas,
|
|
246
|
+
dryRun,
|
|
247
|
+
}, write);
|
|
248
|
+
}
|
|
249
|
+
if (command === 'new') {
|
|
250
|
+
const path = newMigration(targetDir(registry, config, flags, appDir, loaded?.binding), name, repeatable);
|
|
251
|
+
write(`wrote ${shown(path)}`);
|
|
252
|
+
return EXIT.ok;
|
|
253
|
+
}
|
|
254
|
+
const target = await resolveTarget(registry, config, flags, appDir, loaded?.binding);
|
|
255
|
+
if (DESIRED.includes(command)) {
|
|
256
|
+
const file = schemaFile !== undefined ? resolve(schemaFile) : defaultSchemaFile(target.dir);
|
|
257
|
+
/* The first migration is schema.sql itself: written before any diff tool
|
|
258
|
+
is fetched, since the quickstart's first diff was a 40 MB download to
|
|
259
|
+
copy one file into another. */
|
|
260
|
+
if (command === 'diff' && !readMigrations(target.dir).files.some((each) => each.kind === 'versioned')) {
|
|
261
|
+
const sql = firstMigration(file, dialectOf(target.url), target.schemas);
|
|
262
|
+
const path = newMigration(target.dir, name, false, new Date(), `${firstHeader()}${sql}`);
|
|
263
|
+
write(`wrote ${shown(path)}:`);
|
|
264
|
+
write(sql.trimEnd());
|
|
265
|
+
return EXIT.ok;
|
|
266
|
+
}
|
|
267
|
+
/* The pinned binary is the project's: beside tablewalk.json, else the App, else here. */
|
|
268
|
+
const project = config.configPath ? dirname(config.configPath) : (appDir ?? process.cwd());
|
|
269
|
+
const atlas = await atlasBinary(project, (line) => console.error(`${product()} migrate: ${line}`));
|
|
270
|
+
const options = { schemaFile: file, atlas, ...(devUrl !== undefined ? { devUrl } : {}) };
|
|
271
|
+
return await runDesired(command, target, options, name, write);
|
|
272
|
+
}
|
|
273
|
+
const dialect = dialectOf(target.url);
|
|
274
|
+
const appFlag = appDir !== undefined ? ` --app ${shown(appDir)}` : '';
|
|
275
|
+
const where = `${target.connection.name} (${dialect}), history in ${target.table}, migrations in ${shown(target.dir)}`;
|
|
276
|
+
if (tool) {
|
|
277
|
+
write(`Running flyway ${FLYWAY_COMMANDS[command]} on ${where}`);
|
|
278
|
+
const run = () => runFlyway(command, target, dialect, write);
|
|
279
|
+
const code = command === 'up' || command === 'baseline' || command === 'repair' ? await recordAround(target, run) : await run();
|
|
280
|
+
if (code !== 0)
|
|
281
|
+
return command === 'up' ? EXIT.failed : command === 'validate' ? EXIT.invalid : EXIT.couldNot;
|
|
282
|
+
if (command === 'up' && loaded)
|
|
283
|
+
return (await loaded.check(rest, write)) ? EXIT.ok : EXIT.app;
|
|
284
|
+
return EXIT.ok;
|
|
285
|
+
}
|
|
286
|
+
if (command === 'status') {
|
|
287
|
+
const status = await migrationStatus(target);
|
|
288
|
+
write(`Migrations of ${where}`);
|
|
289
|
+
sayStatus(status, write);
|
|
290
|
+
if (loaded)
|
|
291
|
+
await loaded.types(registry, write);
|
|
292
|
+
/* Never applied is not a state to report and pass: a deploy script that
|
|
293
|
+
reads status before serving would serve an App with no tables. */
|
|
294
|
+
if (!status.started) {
|
|
295
|
+
if (!status.holds && !status.plan.pending.length)
|
|
296
|
+
write(`No migrations to apply: ${product()} migrate diff init${appFlag} writes the first from schema.sql.`);
|
|
297
|
+
return EXIT.invalid;
|
|
298
|
+
}
|
|
299
|
+
return EXIT.ok;
|
|
300
|
+
}
|
|
301
|
+
if (command === 'validate') {
|
|
302
|
+
const { status, valid } = await migrateValidate(target);
|
|
303
|
+
write(`Validating ${where}`);
|
|
304
|
+
sayProblems(status, write);
|
|
305
|
+
if (!status.started)
|
|
306
|
+
write(' no migration history yet: ' + product() + ' migrate up, or baseline for a database that has tables');
|
|
307
|
+
for (const file of status.plan.pending)
|
|
308
|
+
write(` pending: ${file.script} is not applied`);
|
|
309
|
+
sayDrift(status, write);
|
|
310
|
+
write(valid ? `Valid: ${plural(status.plan.history.versioned.size, 'migration')} applied, nothing pending, no drift.` : 'Not valid.');
|
|
311
|
+
return valid ? EXIT.ok : EXIT.invalid;
|
|
312
|
+
}
|
|
313
|
+
if (command === 'baseline') {
|
|
314
|
+
const result = await migrateBaseline(target, { dryRun });
|
|
315
|
+
if (result.refused)
|
|
316
|
+
return fail(result.refused, EXIT.invalid);
|
|
317
|
+
if (result.already) {
|
|
318
|
+
write(`${target.connection.name} is already ${result.already}; nothing to do.`);
|
|
319
|
+
return EXIT.ok;
|
|
320
|
+
}
|
|
321
|
+
const tables = Object.keys(result.objects).filter((key) => key.startsWith('table ')).length;
|
|
322
|
+
const objects = Object.keys(result.objects).length;
|
|
323
|
+
if (dryRun) {
|
|
324
|
+
write(`Would record ${where} as version 0: ${plural(tables, 'table')}, ${plural(objects, 'object')} in all, and write ${shown(result.file)}.`);
|
|
325
|
+
return EXIT.ok;
|
|
326
|
+
}
|
|
327
|
+
write(`Recorded ${target.connection.name} as version 0: ${plural(tables, 'table')}, ${plural(objects, 'object')} in all. Nothing in it was changed; migrations from V1 on change it.`);
|
|
328
|
+
write(result.wrote
|
|
329
|
+
? `wrote ${shown(result.file)} (read-only, never run): the schema as it was`
|
|
330
|
+
: `kept ${shown(result.file)}, the snapshot an earlier baseline wrote`);
|
|
331
|
+
return EXIT.ok;
|
|
332
|
+
}
|
|
333
|
+
if (command === 'repair') {
|
|
334
|
+
const { actions } = await migrateRepair(target, { dryRun });
|
|
335
|
+
write(`${dryRun ? 'Would repair' : 'Repairing'} ${where}`);
|
|
336
|
+
for (const action of actions)
|
|
337
|
+
write(` ${action}`);
|
|
338
|
+
write(actions.length
|
|
339
|
+
? dryRun
|
|
340
|
+
? `${plural(actions.length, 'change')} to make.`
|
|
341
|
+
: `Repaired: ${plural(actions.length, 'change')}.`
|
|
342
|
+
: 'Nothing to repair.');
|
|
343
|
+
return EXIT.ok;
|
|
344
|
+
}
|
|
345
|
+
// up
|
|
346
|
+
/* Nothing to apply and nothing ever applied is no schema at all, not "up to date". */
|
|
347
|
+
if (!readMigrations(target.dir).files.length) {
|
|
348
|
+
const status = await migrationStatus(target);
|
|
349
|
+
if (!status.started && !status.holds)
|
|
350
|
+
return fail(`there are no migrations in ${shown(target.dir)} and none was ever applied, so the schema never was. Write the first from schema.sql with ${product()} migrate diff init${appFlag}, then run ${product()} migrate up${appFlag} again.`, EXIT.invalid);
|
|
351
|
+
}
|
|
352
|
+
const result = await migrateUp(target, { dryRun, waiting: () => write('waiting for another migration run to finish…') });
|
|
353
|
+
write(`${dryRun ? 'Dry run of' : 'Migrating'} ${where}`);
|
|
354
|
+
if (result.refused)
|
|
355
|
+
return fail(result.refused, EXIT.invalid);
|
|
356
|
+
if (result.status.plan.problems.length) {
|
|
357
|
+
sayProblems(result.status, write);
|
|
358
|
+
write('Nothing was applied.');
|
|
359
|
+
return EXIT.invalid;
|
|
360
|
+
}
|
|
361
|
+
if (result.wouldRun) {
|
|
362
|
+
if (!result.wouldRun.length) {
|
|
363
|
+
write('Nothing to apply.');
|
|
364
|
+
return EXIT.ok;
|
|
365
|
+
}
|
|
366
|
+
for (const file of result.wouldRun) {
|
|
367
|
+
const how = file.transactional ? 'in one transaction' : 'statement by statement, outside a transaction';
|
|
368
|
+
write(`-- ${file.script}, ${how}`);
|
|
369
|
+
write(file.sql.trimEnd());
|
|
370
|
+
write(`-- then its row in ${target.table}: ${file.version !== undefined ? `version ${file.version}` : 'repeatable'}, "${file.description}", checksum ${file.checksum}`);
|
|
371
|
+
write('');
|
|
372
|
+
}
|
|
373
|
+
write(`${plural(result.wouldRun.length, 'migration')} would be applied.`);
|
|
374
|
+
return EXIT.ok;
|
|
375
|
+
}
|
|
376
|
+
for (const { file, ms } of result.applied)
|
|
377
|
+
write(` applied ${file.script} (${ms} ms)`);
|
|
378
|
+
if (result.failure) {
|
|
379
|
+
write(` failed ${result.failure.file.script}: ${result.failure.message}`);
|
|
380
|
+
write(`${plural(result.applied.length, 'migration')} applied before it; the run stopped there.`);
|
|
381
|
+
return EXIT.failed;
|
|
382
|
+
}
|
|
383
|
+
if (!result.applied.length) {
|
|
384
|
+
write(`Nothing to apply: up to date${sayVersion(result.status)}.`);
|
|
385
|
+
return EXIT.ok;
|
|
386
|
+
}
|
|
387
|
+
write(`Applied ${plural(result.applied.length, 'migration')}: now${sayVersion(result.status)}.`);
|
|
388
|
+
sayDrift(result.status, write);
|
|
389
|
+
if (loaded)
|
|
390
|
+
return (await loaded.check(rest, write)) ? EXIT.ok : EXIT.app;
|
|
391
|
+
return EXIT.ok;
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
return fail(error.message);
|
|
395
|
+
}
|
|
396
|
+
finally {
|
|
397
|
+
console.log = log;
|
|
398
|
+
await registry.closeAll();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
/** diff, check and squash: the migrations against schema.sql, on scratch databases. */
|
|
402
|
+
async function runDesired(command, target, options, name, write) {
|
|
403
|
+
const file = shown(options.schemaFile);
|
|
404
|
+
const sql = await pendingSql(target, options);
|
|
405
|
+
if (command === 'check') {
|
|
406
|
+
if (!sql) {
|
|
407
|
+
write(`${file} matches the migrations in ${shown(target.dir)}.`);
|
|
408
|
+
return EXIT.ok;
|
|
409
|
+
}
|
|
410
|
+
write(`${file} and the migrations in ${shown(target.dir)} disagree. What the migrations still lack:`);
|
|
411
|
+
write(sql.replace(/^/gm, ' '));
|
|
412
|
+
write('Write it with: ' + product() + ' migrate diff <name>, or change schema.sql back.');
|
|
413
|
+
return EXIT.invalid;
|
|
414
|
+
}
|
|
415
|
+
if (command === 'diff') {
|
|
416
|
+
if (!sql) {
|
|
417
|
+
write(`Nothing to write: the migrations already build ${file}.`);
|
|
418
|
+
return EXIT.ok;
|
|
419
|
+
}
|
|
420
|
+
const path = newMigration(target.dir, name, false, new Date(), `${diffHeader()}${sql}\n`);
|
|
421
|
+
write(`wrote ${shown(path)}:`);
|
|
422
|
+
write(sql);
|
|
423
|
+
if (/\bDROP\b/i.test(sql))
|
|
424
|
+
write('note: it drops something. If that is a rename, rewrite it as RENAME: a diff cannot tell a rename from a drop and an add.');
|
|
425
|
+
return EXIT.ok;
|
|
426
|
+
}
|
|
427
|
+
// squash
|
|
428
|
+
if (sql) {
|
|
429
|
+
write(`${file} and the migrations disagree, so there is nothing settled to squash. What they still lack:`);
|
|
430
|
+
write(sql.replace(/^/gm, ' '));
|
|
431
|
+
write('Write it with ' + product() + ' migrate diff <name> first, or change schema.sql back.');
|
|
432
|
+
return EXIT.invalid;
|
|
433
|
+
}
|
|
434
|
+
const versioned = readMigrations(target.dir).files.filter((each) => each.kind === 'versioned');
|
|
435
|
+
if (versioned.length < 2) {
|
|
436
|
+
write(`Nothing to squash: ${shown(target.dir)} holds ${plural(versioned.length, 'versioned migration')}.`);
|
|
437
|
+
return EXIT.ok;
|
|
438
|
+
}
|
|
439
|
+
const { removed, wrote } = squashInto(target.dir, options.schemaFile, dialectOf(target.url));
|
|
440
|
+
write(`Squashed ${plural(removed.length, 'migration')} into ${shown(wrote)}: ${removed.join(', ')} (git holds them).`);
|
|
441
|
+
const again = await pendingSql(target, options);
|
|
442
|
+
if (again) {
|
|
443
|
+
write('The baseline does not build schema.sql on its own; what it lacks:');
|
|
444
|
+
write(again.replace(/^/gm, ' '));
|
|
445
|
+
return EXIT.invalid;
|
|
446
|
+
}
|
|
447
|
+
write(`It builds ${file}. A database migrated with the old files no longer matches its history: rebuild it, or ${product()} migrate repair.`);
|
|
448
|
+
return EXIT.ok;
|
|
449
|
+
}
|
|
450
|
+
function sayVersion(status) {
|
|
451
|
+
const versions = [...status.plan.history.versioned.keys()];
|
|
452
|
+
const at = versions.length ? versions[versions.length - 1] : (status.plan.history.baseline?.version ?? undefined);
|
|
453
|
+
return at !== undefined && at !== null ? ` at version ${at}` : '';
|
|
454
|
+
}
|
|
455
|
+
function sayProblems(status, write) {
|
|
456
|
+
for (const file of status.directory.ignored)
|
|
457
|
+
write(` warning: ${file} is not named as a migration (V<version>__<name>.sql or R__<name>.sql), so it is not run`);
|
|
458
|
+
for (const note of status.plan.notes)
|
|
459
|
+
write(` note: ${note}`);
|
|
460
|
+
for (const problem of status.plan.problems)
|
|
461
|
+
write(` error: ${problem}`);
|
|
462
|
+
}
|
|
463
|
+
function sayDrift(status, write) {
|
|
464
|
+
if (status.behind) {
|
|
465
|
+
write(` note: ${plural(status.behind, 'migration')} ${status.behind === 1 ? 'was' : 'were'} applied by another runner after the schema was last recorded, so ${status.behind === 1 ? 'its' : 'their'} changes read as drift: ${product()} migrate repair records it again.`);
|
|
466
|
+
}
|
|
467
|
+
if (!status.drift)
|
|
468
|
+
return;
|
|
469
|
+
if (!status.drift.length)
|
|
470
|
+
return;
|
|
471
|
+
write(` Drift: ${plural(status.drift.length, 'change')} made outside migrations since they last ran. Adopt each in a migration, or undo it:`);
|
|
472
|
+
for (const change of status.drift)
|
|
473
|
+
write(` ${sayChange(change)}`);
|
|
474
|
+
}
|
|
475
|
+
function sayStatus(status, write) {
|
|
476
|
+
const { history, pending } = status.plan;
|
|
477
|
+
/* Versions in version order, then the repeatables by description, as they
|
|
478
|
+
run; not the order they happened to be installed in. */
|
|
479
|
+
const versioned = [];
|
|
480
|
+
const repeatable = [];
|
|
481
|
+
if (history.baseline)
|
|
482
|
+
versioned.push([history.baseline.version ?? '', history.baseline.description, history.baseline.installed_on, 'baseline']);
|
|
483
|
+
for (const row of [...history.versioned.values()].sort((a, b) => compareVersions(a.version, b.version)))
|
|
484
|
+
versioned.push([row.version, row.description, row.installed_on, 'applied']);
|
|
485
|
+
for (const row of history.failed)
|
|
486
|
+
versioned.push([row.version ?? 'R', row.description, row.installed_on, 'failed']);
|
|
487
|
+
for (const file of pending.filter((each) => each.version !== undefined))
|
|
488
|
+
versioned.push([file.version, file.description, '', 'pending']);
|
|
489
|
+
for (const row of [...history.repeatable.values()].sort((a, b) => (a.description < b.description ? -1 : 1))) {
|
|
490
|
+
const changed = pending.some((file) => file.version === undefined && file.description === row.description);
|
|
491
|
+
repeatable.push(['R', row.description, row.installed_on, changed ? 'pending (changed)' : 'applied']);
|
|
492
|
+
}
|
|
493
|
+
for (const file of pending.filter((each) => each.version === undefined && !history.repeatable.has(each.description)))
|
|
494
|
+
repeatable.push(['R', file.description, '', 'pending']);
|
|
495
|
+
const rows = [...versioned, ...repeatable];
|
|
496
|
+
if (!status.started)
|
|
497
|
+
write(status.holds
|
|
498
|
+
? ` no migration history yet, and the database already holds ${status.holds} table${status.holds === 1 ? '' : 's'} or view${status.holds === 1 ? '' : 's'}: ${product()} migrate baseline records it as it is`
|
|
499
|
+
: ' no migration history yet');
|
|
500
|
+
if (rows.length) {
|
|
501
|
+
const widths = [7, 11, 19].map((min, i) => Math.max(min, ...rows.map((row) => row[i].length)));
|
|
502
|
+
write(` ${'version'.padEnd(widths[0])} ${'description'.padEnd(widths[1])} ${'installed'.padEnd(widths[2])} state`);
|
|
503
|
+
for (const row of rows)
|
|
504
|
+
write(` ${row[0].padEnd(widths[0])} ${row[1].padEnd(widths[1])} ${row[2].padEnd(widths[2])} ${row[3]}`);
|
|
505
|
+
}
|
|
506
|
+
sayProblems(status, write);
|
|
507
|
+
sayDrift(status, write);
|
|
508
|
+
if (status.drift && !status.drift.length)
|
|
509
|
+
write(' No drift: the schema is what the migrations made it.');
|
|
510
|
+
if (status.started && !status.snapshot)
|
|
511
|
+
write(' note: no schema recorded by ' + product() + ' yet, so drift cannot be told: ' + product() + ' migrate repair records it as it is.');
|
|
512
|
+
write(pending.length
|
|
513
|
+
? `${plural(pending.length, 'migration')} pending: ${product()} migrate up`
|
|
514
|
+
: status.started
|
|
515
|
+
? `Up to date${sayVersion(status)}.`
|
|
516
|
+
: 'Nothing applied yet.');
|
|
517
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type Dialect = 'sqlite' | 'postgres';
|
|
2
|
+
export interface MigrationDb {
|
|
3
|
+
readonly dialect: Dialect;
|
|
4
|
+
/** Where the history lives: a PostgreSQL schema; none on SQLite. */
|
|
5
|
+
readonly home: string | undefined;
|
|
6
|
+
/** The account the history says installed a migration. */
|
|
7
|
+
readonly user: string;
|
|
8
|
+
/** A statement with `?` parameters, its rows. */
|
|
9
|
+
all<Row = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<Row[]>;
|
|
10
|
+
run(sql: string, params?: unknown[]): Promise<void>;
|
|
11
|
+
/** A script's whole text, every statement in it. */
|
|
12
|
+
script(sql: string): Promise<void>;
|
|
13
|
+
/** Hold the run's lock (a no-op on SQLite, whose lock is each step's write transaction). */
|
|
14
|
+
lock(table: string, waitMs: number, waiting: () => void): Promise<void>;
|
|
15
|
+
close(): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare const quoteIdent: (_dialect: Dialect, name: string) => string;
|
|
18
|
+
/** The advisory lock Flyway takes on PostgreSQL for this history table (PostgreSQLAdvisoryLockTemplate). */
|
|
19
|
+
export declare function flywayLockNumber(schema: string, table: string): bigint;
|
|
20
|
+
export declare function dialectOf(url: string): Dialect;
|
|
21
|
+
export declare const sqlitePath: (url: string) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Open the run's connection. `create` lets `up` start a SQLite file that is
|
|
24
|
+
* not there yet (a fresh database migrated from nothing); every other command
|
|
25
|
+
* refuses a path with nothing at it, which is a typo far more often.
|
|
26
|
+
* `schemas` is the run's scope: on PostgreSQL the first is where the history
|
|
27
|
+
* lives and the search path is set to them, as Flyway's `schemas` does.
|
|
28
|
+
*/
|
|
29
|
+
export declare function openMigrationDb(url: string, schemas: readonly string[], create: boolean): Promise<MigrationDb>;
|
|
30
|
+
/**
|
|
31
|
+
* A PostgreSQL script as its statements, for a file that must run outside a
|
|
32
|
+
* transaction: `CREATE INDEX CONCURRENTLY` refuses a multi-statement query,
|
|
33
|
+
* which PostgreSQL runs as one implicit transaction. Reads quotes, quoted
|
|
34
|
+
* names, dollar quotes and both kinds of comment, and cuts at the semicolons
|
|
35
|
+
* outside them.
|
|
36
|
+
*/
|
|
37
|
+
export declare function splitPostgres(sql: string): string[];
|