@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,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one connection a migration run holds, on each engine, and the lock that
|
|
3
|
+
* keeps two deploys from migrating at once.
|
|
4
|
+
*
|
|
5
|
+
* Not the adapters: those read, through pools, in read-only transactions.
|
|
6
|
+
* A migration writes DDL on one private connection and holds it for the run.
|
|
7
|
+
*
|
|
8
|
+
* - SQLite: node:sqlite, with foreign keys off as the SQLite manual's table
|
|
9
|
+
* rebuild asks and as Flyway's driver leaves them; each migration's
|
|
10
|
+
* transaction checks them before it commits instead. The lock is SQLite's
|
|
11
|
+
* own: every step is a `BEGIN IMMEDIATE` that re-reads the history.
|
|
12
|
+
* - PostgreSQL: `pg`, a session advisory lock held for the run, on the number
|
|
13
|
+
* Flyway derives from the same history table, so tablewalk and Flyway
|
|
14
|
+
* exclude each other as well as themselves.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync } from 'node:fs';
|
|
17
|
+
import { DatabaseSync } from 'node:sqlite';
|
|
18
|
+
import { MYSQL_REFUSAL } from '../../adapters/connect.js';
|
|
19
|
+
import { postgresPoolDefaults } from '../../adapters/postgresPool.js';
|
|
20
|
+
import { pgConnectionOptions } from '../../adapters/postgresValues.js';
|
|
21
|
+
import { product } from '../product.js';
|
|
22
|
+
export const quoteIdent = (_dialect, name) => `"${name.replace(/"/g, '""')}"`;
|
|
23
|
+
/** Java's String.hashCode, which Flyway's advisory lock number is built on. */
|
|
24
|
+
function javaHash(text) {
|
|
25
|
+
let hash = 0;
|
|
26
|
+
for (let i = 0; i < text.length; i++)
|
|
27
|
+
hash = (Math.imul(hash, 31) + text.charCodeAt(i)) | 0;
|
|
28
|
+
return hash;
|
|
29
|
+
}
|
|
30
|
+
/** The advisory lock Flyway takes on PostgreSQL for this history table (PostgreSQLAdvisoryLockTemplate). */
|
|
31
|
+
export function flywayLockNumber(schema, table) {
|
|
32
|
+
return 77431708279161n + BigInt(javaHash(`${quoteIdent('postgres', schema)}.${quoteIdent('postgres', table)}`));
|
|
33
|
+
}
|
|
34
|
+
const sleep = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
35
|
+
/** How long a PostgreSQL migration's statement waits for a lock before its file is rolled back and tried again. */
|
|
36
|
+
const MIGRATION_LOCK_TIMEOUT_MS = 5_000;
|
|
37
|
+
/* What a migration needs from the session it runs on: its lock, held across
|
|
38
|
+
the steps' transactions, and the --schema path. */
|
|
39
|
+
const SESSION_NEEDED = 'a migration holds a session lock, which a transaction-mode pooler does not keep; run it on a URL that reaches PostgreSQL directly or through a session-mode pool';
|
|
40
|
+
export function dialectOf(url) {
|
|
41
|
+
if (/^postgres(ql)?:\/\//i.test(url))
|
|
42
|
+
return 'postgres';
|
|
43
|
+
if (/^(mysql|mariadb):\/\//i.test(url))
|
|
44
|
+
throw new Error(MYSQL_REFUSAL);
|
|
45
|
+
if (/^[a-z][\w+.-]*:\/\//i.test(url))
|
|
46
|
+
throw new Error(product() + ' migrate runs on SQLite and PostgreSQL; this connection is neither.');
|
|
47
|
+
return 'sqlite';
|
|
48
|
+
}
|
|
49
|
+
export const sqlitePath = (url) => url.replace(/^sqlite:(\/\/)?/i, '');
|
|
50
|
+
/**
|
|
51
|
+
* Open the run's connection. `create` lets `up` start a SQLite file that is
|
|
52
|
+
* not there yet (a fresh database migrated from nothing); every other command
|
|
53
|
+
* refuses a path with nothing at it, which is a typo far more often.
|
|
54
|
+
* `schemas` is the run's scope: on PostgreSQL the first is where the history
|
|
55
|
+
* lives and the search path is set to them, as Flyway's `schemas` does.
|
|
56
|
+
*/
|
|
57
|
+
export async function openMigrationDb(url, schemas, create) {
|
|
58
|
+
const dialect = dialectOf(url);
|
|
59
|
+
if (dialect === 'sqlite') {
|
|
60
|
+
const path = sqlitePath(url);
|
|
61
|
+
if (!create && !existsSync(path))
|
|
62
|
+
throw new Error(`there is no SQLite database at ${path}`);
|
|
63
|
+
const db = new DatabaseSync(path, { enableForeignKeyConstraints: false, timeout: 60_000 });
|
|
64
|
+
return {
|
|
65
|
+
dialect,
|
|
66
|
+
home: undefined,
|
|
67
|
+
user: '',
|
|
68
|
+
async all(sql, params = []) {
|
|
69
|
+
return db.prepare(sql).all(...params);
|
|
70
|
+
},
|
|
71
|
+
async run(sql, params = []) {
|
|
72
|
+
db.prepare(sql).run(...params);
|
|
73
|
+
},
|
|
74
|
+
async script(sql) {
|
|
75
|
+
db.exec(sql);
|
|
76
|
+
},
|
|
77
|
+
async lock() {
|
|
78
|
+
/* Each step's BEGIN IMMEDIATE is the lock. */
|
|
79
|
+
},
|
|
80
|
+
async close() {
|
|
81
|
+
db.close();
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const specifier = 'pg';
|
|
86
|
+
const pg = (await import(specifier).catch(() => {
|
|
87
|
+
throw new Error('PostgreSQL support needs the "pg" package. Install it with: npm install pg');
|
|
88
|
+
}));
|
|
89
|
+
const Client = pg.Client ?? pg.default?.Client;
|
|
90
|
+
if (!Client)
|
|
91
|
+
throw new Error('Could not find a Client export in the "pg" package.');
|
|
92
|
+
const client = new Client({ ...pgConnectionOptions(url), connectionTimeoutMillis: 15_000 });
|
|
93
|
+
// An idle connection that drops is an 'error' event; unheard it ends the process. The next statement rejects with the loss.
|
|
94
|
+
client.on('error', () => { });
|
|
95
|
+
await client.connect().catch(() => {
|
|
96
|
+
throw new Error('the PostgreSQL database could not be opened');
|
|
97
|
+
});
|
|
98
|
+
try {
|
|
99
|
+
const [{ current, user }] = (await client.query('SELECT current_schema() AS current, current_user AS user')).rows;
|
|
100
|
+
const home = schemas[0] ?? current;
|
|
101
|
+
if (!home)
|
|
102
|
+
throw new Error('the connection has no current schema (an empty search_path): name one with --schema');
|
|
103
|
+
/* Behind a transaction-mode pooler (`--pooler transaction`) a session
|
|
104
|
+
setting stays on whichever server connection the pooler lent and
|
|
105
|
+
follows it to the pooler's next client: the lock wait below would
|
|
106
|
+
reach the App's own statements. The serve-time readers of the
|
|
107
|
+
migration tables (the Console, governance, analytics provisioning)
|
|
108
|
+
set nothing there; what needs the session refuses. */
|
|
109
|
+
const pooled = postgresPoolDefaults().pooler === 'transaction';
|
|
110
|
+
if (schemas.length) {
|
|
111
|
+
if (pooled)
|
|
112
|
+
throw new Error(SESSION_NEEDED);
|
|
113
|
+
await client.query(`SET search_path TO ${schemas.map((schema) => quoteIdent('postgres', schema)).join(', ')}`);
|
|
114
|
+
}
|
|
115
|
+
/* A migration's DDL waits for the tables it changes, and while it waits
|
|
116
|
+
every App statement on those tables queues behind it: an ALTER TABLE
|
|
117
|
+
stuck behind one long transaction stops the App. So it gives up after
|
|
118
|
+
MIGRATION_LOCK_TIMEOUT_MS and tries again (runner.ts apply). */
|
|
119
|
+
if (!pooled)
|
|
120
|
+
await client.query(`SET lock_timeout = '${MIGRATION_LOCK_TIMEOUT_MS}ms'`);
|
|
121
|
+
let held;
|
|
122
|
+
const numbered = (sql) => {
|
|
123
|
+
let n = 0;
|
|
124
|
+
return sql.replace(/\?/g, () => `$${++n}`);
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
dialect,
|
|
128
|
+
home,
|
|
129
|
+
user,
|
|
130
|
+
async all(sql, params = []) {
|
|
131
|
+
return (await client.query(numbered(sql), params)).rows;
|
|
132
|
+
},
|
|
133
|
+
async run(sql, params = []) {
|
|
134
|
+
await client.query(numbered(sql), params);
|
|
135
|
+
},
|
|
136
|
+
// The simple protocol: a script of many statements in one round trip.
|
|
137
|
+
async script(sql) {
|
|
138
|
+
await client.query(sql);
|
|
139
|
+
},
|
|
140
|
+
async lock(table, waitMs, waiting) {
|
|
141
|
+
if (pooled)
|
|
142
|
+
throw new Error(SESSION_NEEDED);
|
|
143
|
+
const key = flywayLockNumber(home, table);
|
|
144
|
+
const started = Date.now();
|
|
145
|
+
let said = false;
|
|
146
|
+
for (;;) {
|
|
147
|
+
const [{ locked }] = (await client.query('SELECT pg_try_advisory_lock($1::bigint) AS locked', [String(key)])).rows;
|
|
148
|
+
if (locked) {
|
|
149
|
+
held = key;
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (Date.now() - started > waitMs)
|
|
153
|
+
throw new Error(`another migration of ${home}.${table} has held its lock for ${Math.round(waitMs / 1000)}s; try again when it has finished`);
|
|
154
|
+
if (!said) {
|
|
155
|
+
waiting();
|
|
156
|
+
said = true;
|
|
157
|
+
}
|
|
158
|
+
await sleep(250);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
async close() {
|
|
162
|
+
if (held !== undefined)
|
|
163
|
+
await client.query('SELECT pg_advisory_unlock($1::bigint)', [String(held)]).catch(() => { });
|
|
164
|
+
await client.end().catch(() => { });
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
await client.end().catch(() => { });
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A PostgreSQL script as its statements, for a file that must run outside a
|
|
175
|
+
* transaction: `CREATE INDEX CONCURRENTLY` refuses a multi-statement query,
|
|
176
|
+
* which PostgreSQL runs as one implicit transaction. Reads quotes, quoted
|
|
177
|
+
* names, dollar quotes and both kinds of comment, and cuts at the semicolons
|
|
178
|
+
* outside them.
|
|
179
|
+
*/
|
|
180
|
+
export function splitPostgres(sql) {
|
|
181
|
+
const out = [];
|
|
182
|
+
let start = 0;
|
|
183
|
+
let i = 0;
|
|
184
|
+
const n = sql.length;
|
|
185
|
+
while (i < n) {
|
|
186
|
+
const c = sql[i];
|
|
187
|
+
if (c === '-' && sql[i + 1] === '-') {
|
|
188
|
+
const end = sql.indexOf('\n', i);
|
|
189
|
+
i = end < 0 ? n : end + 1;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (c === '/' && sql[i + 1] === '*') {
|
|
193
|
+
let depth = 1;
|
|
194
|
+
i += 2;
|
|
195
|
+
while (i < n && depth) {
|
|
196
|
+
if (sql[i] === '/' && sql[i + 1] === '*') {
|
|
197
|
+
depth++;
|
|
198
|
+
i += 2;
|
|
199
|
+
}
|
|
200
|
+
else if (sql[i] === '*' && sql[i + 1] === '/') {
|
|
201
|
+
depth--;
|
|
202
|
+
i += 2;
|
|
203
|
+
}
|
|
204
|
+
else
|
|
205
|
+
i++;
|
|
206
|
+
}
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
if (c === "'" || c === '"') {
|
|
210
|
+
const escaped = c === "'" && /[eE]/.test(sql[i - 1] ?? '') && !/\w/.test(sql[i - 2] ?? '');
|
|
211
|
+
i++;
|
|
212
|
+
while (i < n) {
|
|
213
|
+
if (escaped && sql[i] === '\\') {
|
|
214
|
+
i += 2;
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
if (sql[i] === c) {
|
|
218
|
+
if (sql[i + 1] === c) {
|
|
219
|
+
i += 2;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
i++;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
i++;
|
|
226
|
+
}
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (c === '$') {
|
|
230
|
+
const tag = /^\$(?:[A-Za-z_][A-Za-z0-9_]*)?\$/.exec(sql.slice(i));
|
|
231
|
+
if (tag && !/\w/.test(sql[i - 1] ?? '')) {
|
|
232
|
+
const end = sql.indexOf(tag[0], i + tag[0].length);
|
|
233
|
+
i = end < 0 ? n : end + tag[0].length;
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (c === ';') {
|
|
238
|
+
out.push(sql.slice(start, i));
|
|
239
|
+
start = i + 1;
|
|
240
|
+
}
|
|
241
|
+
i++;
|
|
242
|
+
}
|
|
243
|
+
out.push(sql.slice(start));
|
|
244
|
+
return out
|
|
245
|
+
.map((statement) => statement.trim())
|
|
246
|
+
.filter((statement) => statement && !/^(--[^\n]*\n?|\/\*[\s\S]*?\*\/|\s)*$/.test(statement));
|
|
247
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type MigrateTarget } from './runner.js';
|
|
2
|
+
/** The pinned build. A new version is a new line here and new checksums, reviewed like any dependency. */
|
|
3
|
+
export declare const ATLAS_VERSION = "v1.3.0";
|
|
4
|
+
/** Where the binary lives: local to the project, ignored by git, named by its version so a bump fetches again. */
|
|
5
|
+
export declare const atlasPath: (projectDir: string) => string;
|
|
6
|
+
/** The desired schema, by default: `schema.sql` beside the migrations directory (`db/migrations` → `db/schema.sql`). */
|
|
7
|
+
export declare const defaultSchemaFile: (migrationsDir: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* The Atlas binary to run: `MISTRI_ATLAS` (`TABLEWALK_ATLAS` under the browser, product.ts) when set (an Atlas the team
|
|
10
|
+
* installed itself, taken as it is), else the pinned build, fetched once and
|
|
11
|
+
* checked against its sha256 before it is ever made executable.
|
|
12
|
+
*/
|
|
13
|
+
export declare function atlasBinary(projectDir: string, say: (line: string) => void, fetcher?: (url: string) => Promise<Uint8Array>, platform?: string, pins?: Readonly<Record<string, string>>): Promise<string>;
|
|
14
|
+
/**
|
|
15
|
+
* A database URL as Atlas reads it, and the environment that carries its
|
|
16
|
+
* password: never on argv, where every user of the machine can read it in
|
|
17
|
+
* the process list. Atlas's PostgreSQL driver honours `PGPASSWORD` as libpq
|
|
18
|
+
* does. Scoped to one schema, so `--exclude` names tables and nothing else of
|
|
19
|
+
* a shared database is compared.
|
|
20
|
+
*/
|
|
21
|
+
export declare function atlasUrl(url: string, schema?: string): {
|
|
22
|
+
url: string;
|
|
23
|
+
env: Record<string, string>;
|
|
24
|
+
};
|
|
25
|
+
interface DesiredOptions {
|
|
26
|
+
/** The desired schema: `schema.sql` beside the migrations unless named. */
|
|
27
|
+
readonly schemaFile: string;
|
|
28
|
+
/** A PostgreSQL server where two scratch databases may be made and dropped; the connection's own by default. */
|
|
29
|
+
readonly devUrl?: string;
|
|
30
|
+
readonly atlas: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What the migrations still lack to reach `schema.sql`, as SQL: empty when
|
|
34
|
+
* they agree. tablewalk's own tables (`__mistri_*`, and the history table
|
|
35
|
+
* if it is named otherwise) are left out of the comparison: they move through
|
|
36
|
+
* tablewalk, not through schema.sql.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pendingSql(target: MigrateTarget, options: DesiredOptions): Promise<string>;
|
|
39
|
+
/**
|
|
40
|
+
* schema.sql as SQLite is to read it. PostgreSQL numbers a `serial` column
|
|
41
|
+
* from a sequence; SQLite takes any word as a type, so `id serial primary key`
|
|
42
|
+
* is accepted as a plain nullable column, Atlas writes it back as
|
|
43
|
+
* `` `id` serial NULL ``, and every new row's id is NULL. SQLite numbers only
|
|
44
|
+
* an `integer` primary key (the rowid's other name), so a serial primary key
|
|
45
|
+
* is read as one here, and one schema.sql serves both databases — the
|
|
46
|
+
* quickstart's and the home page's do. A serial column that is not declared
|
|
47
|
+
* the primary key on its own line has nothing on SQLite to number it, and is
|
|
48
|
+
* refused by name rather than left to come out NULL.
|
|
49
|
+
*/
|
|
50
|
+
export declare function sqliteDesired(text: string): string;
|
|
51
|
+
/** The header a written migration carries: where it came from, and what a diff cannot know. */
|
|
52
|
+
export declare const diffHeader: () => string;
|
|
53
|
+
/**
|
|
54
|
+
* The first versioned migration: what an empty database lacks to reach
|
|
55
|
+
* `schema.sql` is `schema.sql`, so it is written as it stands — comments and
|
|
56
|
+
* all, as a squash writes it — and no diff tool is fetched for it. On SQLite
|
|
57
|
+
* it is schema.sql as SQLite reads it (`sqliteDesired`). `migrate up` is what
|
|
58
|
+
* proves it runs; the next `migrate diff` compares the two as any other does.
|
|
59
|
+
*/
|
|
60
|
+
export declare function firstMigration(schemaFile: string, dialect: string, schemas: readonly string[]): string;
|
|
61
|
+
/** The header the first migration carries: it is schema.sql, not a diff. */
|
|
62
|
+
export declare const firstHeader: () => string;
|
|
63
|
+
/**
|
|
64
|
+
* Fold the versioned chain into one `V1__baseline.sql` holding `schema.sql`
|
|
65
|
+
* itself — comments and all, since the check has just shown the two build the
|
|
66
|
+
* same schema. Repeatable files stay. Only before a database worth keeping
|
|
67
|
+
* exists: one migrated with the old chain no longer matches its history.
|
|
68
|
+
* On SQLite it is schema.sql as SQLite reads it (`sqliteDesired`), so the
|
|
69
|
+
* baseline numbers its ids as the diff's files did. Returns the files
|
|
70
|
+
* removed and the one written.
|
|
71
|
+
*/
|
|
72
|
+
export declare function squashInto(dir: string, schemaFile: string, dialect?: string): {
|
|
73
|
+
removed: string[];
|
|
74
|
+
wrote: string;
|
|
75
|
+
};
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tablewalk migrate diff | check | squash`: the schema a team wants, written
|
|
3
|
+
* once in `schema.sql`, and the versioned files that get a database there.
|
|
4
|
+
*
|
|
5
|
+
* tablewalk stays database-first: nothing here comes from the App's DSL. The
|
|
6
|
+
* person edits `schema.sql` the way they would write it by hand; `diff`
|
|
7
|
+
* writes the next `V<n>__<name>.sql` holding what the migrations so far lack,
|
|
8
|
+
* for review; `check` fails when the migrations and `schema.sql` disagree, so
|
|
9
|
+
* neither drifts from the other in a commit; `squash` folds the chain into
|
|
10
|
+
* one baseline before a database worth keeping exists.
|
|
11
|
+
*
|
|
12
|
+
* The comparison is Atlas's (the Apache-2.0 community build), not ours: a
|
|
13
|
+
* schema differ is a database tool, and tablewalk rides on the database
|
|
14
|
+
* rather than becoming one. It is fetched pinned — a version and a sha256 per
|
|
15
|
+
* platform — into `.mistri/bin` (`.tablewalk/bin` for the browser) beside the project, on the first `diff` or
|
|
16
|
+
* `check` and said aloud, never while serving, and run with its update check
|
|
17
|
+
* off. Stripe's pg-schema-diff was tried first and set aside: it cannot leave
|
|
18
|
+
* tablewalk's `__mistri_*` tables out (only whole schemas), so a diff would
|
|
19
|
+
* drop the migration history, and its plans use `CREATE INDEX CONCURRENTLY`
|
|
20
|
+
* and `SET SESSION`, which do not fit one transaction per file.
|
|
21
|
+
*
|
|
22
|
+
* Both sides are real databases: the migrations are applied to a scratch one
|
|
23
|
+
* by tablewalk's own runner (the runner a deploy uses, so the chain is judged
|
|
24
|
+
* as it will run), and Atlas reads `schema.sql` into a second, empty one. On
|
|
25
|
+
* PostgreSQL both are created on the connection's server (or `--dev-url`'s)
|
|
26
|
+
* and dropped after, which needs `CREATEDB`; on SQLite one is a temporary file
|
|
27
|
+
* and the other is in memory. Neither is the connection's own database.
|
|
28
|
+
*/
|
|
29
|
+
import { execFile } from 'node:child_process';
|
|
30
|
+
import { createHash, randomBytes } from 'node:crypto';
|
|
31
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
32
|
+
import { tmpdir } from 'node:os';
|
|
33
|
+
import { dirname, join, resolve } from 'node:path';
|
|
34
|
+
import { RUNTIME_TABLE_PREFIXES } from '../../shared/runtimeTables.js';
|
|
35
|
+
import { dialectOf, openMigrationDb, quoteIdent, sqlitePath } from './database.js';
|
|
36
|
+
import { readMigrations } from './files.js';
|
|
37
|
+
import { migrateUp } from './runner.js';
|
|
38
|
+
import { envName, product, productEnv } from '../product.js';
|
|
39
|
+
/** The pinned build. A new version is a new line here and new checksums, reviewed like any dependency. */
|
|
40
|
+
export const ATLAS_VERSION = 'v1.3.0';
|
|
41
|
+
const ATLAS_SHA256 = {
|
|
42
|
+
'darwin-arm64': '4e5ffdc10b2b4fd3a06074aba72848150907d5316cacad7b19bae6c6ae3db991',
|
|
43
|
+
'darwin-amd64': '650981a024301775ec964e5134e2d5712b7ef1b25fec4b2ec54bad762b4bdf6f',
|
|
44
|
+
'linux-amd64': '10d7913e3dce43ab99b8d71534a4cbadaf11a16dc293adf3b91d10e83a0ac70b',
|
|
45
|
+
'linux-arm64': '082188c57a53439596a3ee52173b12e785aa83ec718505674e2052db0fec0c4c',
|
|
46
|
+
};
|
|
47
|
+
/** Where the binary lives: local to the project, ignored by git, named by its version so a bump fetches again. */
|
|
48
|
+
export const atlasPath = (projectDir) => join(projectDir, `.${product()}`, 'bin', `atlas-${ATLAS_VERSION}`);
|
|
49
|
+
/** The desired schema, by default: `schema.sql` beside the migrations directory (`db/migrations` → `db/schema.sql`). */
|
|
50
|
+
export const defaultSchemaFile = (migrationsDir) => join(dirname(resolve(migrationsDir)), 'schema.sql');
|
|
51
|
+
/**
|
|
52
|
+
* The Atlas binary to run: `MISTRI_ATLAS` (`TABLEWALK_ATLAS` under the browser, product.ts) when set (an Atlas the team
|
|
53
|
+
* installed itself, taken as it is), else the pinned build, fetched once and
|
|
54
|
+
* checked against its sha256 before it is ever made executable.
|
|
55
|
+
*/
|
|
56
|
+
export async function atlasBinary(projectDir, say, fetcher = download, platform = `${process.platform}-${process.arch === 'x64' ? 'amd64' : process.arch}`, pins = ATLAS_SHA256) {
|
|
57
|
+
const own = productEnv('ATLAS');
|
|
58
|
+
if (own)
|
|
59
|
+
return own;
|
|
60
|
+
const path = atlasPath(projectDir);
|
|
61
|
+
const want = pins[platform];
|
|
62
|
+
if (!want)
|
|
63
|
+
throw new Error(`there is no pinned Atlas build for ${platform}. Install Atlas ${ATLAS_VERSION} (community edition) and set ${envName('ATLAS')} to its path.`);
|
|
64
|
+
/* Checked again on every run, not only when fetched: the file sits in the project, where anything that writes there
|
|
65
|
+
(a dependency's install script, a checkout of someone's branch) could replace what this then executes. */
|
|
66
|
+
if (existsSync(path)) {
|
|
67
|
+
if (createHash('sha256').update(readFileSync(path)).digest('hex') === want)
|
|
68
|
+
return path;
|
|
69
|
+
say(`The Atlas binary in ${join(`.${product()}`, 'bin')} is not the pinned build; fetching it again.`);
|
|
70
|
+
rmSync(path, { force: true });
|
|
71
|
+
}
|
|
72
|
+
const url = `https://release.ariga.io/atlas/atlas-community-${platform}-${ATLAS_VERSION}`;
|
|
73
|
+
say(`Fetching Atlas community ${ATLAS_VERSION} (${platform}, about 40 MB) into ${join(`.${product()}`, 'bin')}, once.`);
|
|
74
|
+
const bytes = await fetcher(url);
|
|
75
|
+
const got = createHash('sha256').update(bytes).digest('hex');
|
|
76
|
+
if (got !== want)
|
|
77
|
+
throw new Error(`the Atlas download from ${url} is not the pinned build (sha256 ${got}); nothing was installed.`);
|
|
78
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
79
|
+
const part = `${path}.part`;
|
|
80
|
+
writeFileSync(part, bytes);
|
|
81
|
+
chmodSync(part, 0o755);
|
|
82
|
+
renameSync(part, path);
|
|
83
|
+
/* An older pin's binary is dead weight once the version moves. */
|
|
84
|
+
for (const old of readdirSync(dirname(path)))
|
|
85
|
+
if (old.startsWith('atlas-') && old !== `atlas-${ATLAS_VERSION}`)
|
|
86
|
+
rmSync(join(dirname(path), old), { force: true });
|
|
87
|
+
return path;
|
|
88
|
+
}
|
|
89
|
+
async function download(url) {
|
|
90
|
+
const response = await fetch(url);
|
|
91
|
+
if (!response.ok)
|
|
92
|
+
throw new Error(`could not fetch Atlas from ${url}: HTTP ${response.status}.`);
|
|
93
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A database URL as Atlas reads it, and the environment that carries its
|
|
97
|
+
* password: never on argv, where every user of the machine can read it in
|
|
98
|
+
* the process list. Atlas's PostgreSQL driver honours `PGPASSWORD` as libpq
|
|
99
|
+
* does. Scoped to one schema, so `--exclude` names tables and nothing else of
|
|
100
|
+
* a shared database is compared.
|
|
101
|
+
*/
|
|
102
|
+
export function atlasUrl(url, schema) {
|
|
103
|
+
if (dialectOf(url) === 'sqlite') {
|
|
104
|
+
const path = sqlitePath(url);
|
|
105
|
+
return { url: path.startsWith('file:') || path.includes('?') ? `sqlite://${path}` : `sqlite://${resolve(path)}`, env: {} };
|
|
106
|
+
}
|
|
107
|
+
const parsed = new URL(url);
|
|
108
|
+
const password = parsed.password ? decodeURIComponent(parsed.password) : undefined;
|
|
109
|
+
parsed.password = '';
|
|
110
|
+
parsed.protocol = 'postgres:';
|
|
111
|
+
/* node-postgres speaks plain TCP unless told otherwise; Atlas would insist on TLS. Keep the connection's choice. */
|
|
112
|
+
if (!parsed.searchParams.has('sslmode'))
|
|
113
|
+
parsed.searchParams.set('sslmode', 'disable');
|
|
114
|
+
if (schema !== undefined)
|
|
115
|
+
parsed.searchParams.set('search_path', schema);
|
|
116
|
+
return { url: parsed.toString(), env: password !== undefined ? { PGPASSWORD: password } : {} };
|
|
117
|
+
}
|
|
118
|
+
/** Run Atlas, its update check off, its edition notice dropped; resolves to stdout, rejects with what it said. */
|
|
119
|
+
function runAtlas(binary, args, env = {}) {
|
|
120
|
+
return new Promise((done, fail) => {
|
|
121
|
+
execFile(binary, args, { env: { ...process.env, ...env, ATLAS_NO_UPDATE_NOTIFIER: '1' }, maxBuffer: 64 * 1024 * 1024 }, (error, stdout, stderr) => {
|
|
122
|
+
if (!error)
|
|
123
|
+
return done(stdout);
|
|
124
|
+
const said = String(stderr)
|
|
125
|
+
.replace(/^Notice: This Atlas[\s\S]*?docs#installation\s*/m, '')
|
|
126
|
+
.trim();
|
|
127
|
+
fail(new Error(error.code === 'ENOENT'
|
|
128
|
+
? `Atlas is not at ${binary}${productEnv('ATLAS') ? ` (${envName('ATLAS')})` : ''}.`
|
|
129
|
+
: `Atlas: ${said || error.message}`));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** Two throwaway databases beside the connection's (or `devUrl`'s) server, never the connection's own. */
|
|
134
|
+
async function scratch(url, devUrl) {
|
|
135
|
+
const dialect = dialectOf(url);
|
|
136
|
+
if (devUrl !== undefined && dialectOf(devUrl) !== dialect)
|
|
137
|
+
throw new Error(`--dev-url must be the same kind of database as the connection (${dialect}).`);
|
|
138
|
+
if (dialect === 'sqlite') {
|
|
139
|
+
const dir = mkdtempSync(join(tmpdir(), 'tablewalk-schema-'));
|
|
140
|
+
return {
|
|
141
|
+
built: join(dir, 'built.db'),
|
|
142
|
+
dev: 'sqlite://dev?mode=memory',
|
|
143
|
+
drop: async () => rmSync(dir, { recursive: true, force: true }),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const server = devUrl ?? url;
|
|
147
|
+
const stem = `tablewalk_schema_${process.pid}_${randomBytes(3).toString('hex')}`;
|
|
148
|
+
const names = [`${stem}_built`, `${stem}_dev`];
|
|
149
|
+
const admin = await openMigrationDb(server, [], false);
|
|
150
|
+
const at = (name) => {
|
|
151
|
+
const parsed = new URL(server);
|
|
152
|
+
parsed.pathname = `/${name}`;
|
|
153
|
+
return parsed.toString();
|
|
154
|
+
};
|
|
155
|
+
const made = [];
|
|
156
|
+
const drop = async () => {
|
|
157
|
+
for (const name of made)
|
|
158
|
+
await admin.run(`DROP DATABASE IF EXISTS ${quoteIdent('postgres', name)} WITH (FORCE)`).catch(() => { });
|
|
159
|
+
await admin.close();
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
for (const name of names) {
|
|
163
|
+
await admin.run(`CREATE DATABASE ${quoteIdent('postgres', name)}`);
|
|
164
|
+
made.push(name);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
await drop();
|
|
169
|
+
throw new Error(`could not create a scratch database on that server (${error.message}). The role needs CREATEDB, or name a server where it has it with --dev-url.`);
|
|
170
|
+
}
|
|
171
|
+
return { built: at(names[0]), dev: at(names[1]), drop };
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* What the migrations still lack to reach `schema.sql`, as SQL: empty when
|
|
175
|
+
* they agree. tablewalk's own tables (`__mistri_*`, and the history table
|
|
176
|
+
* if it is named otherwise) are left out of the comparison: they move through
|
|
177
|
+
* tablewalk, not through schema.sql.
|
|
178
|
+
*/
|
|
179
|
+
export async function pendingSql(target, options) {
|
|
180
|
+
if (!existsSync(options.schemaFile))
|
|
181
|
+
throw new Error(`there is no ${options.schemaFile}: write the schema you want there, or name it with --schema-file.`);
|
|
182
|
+
if (target.schemas.length > 1)
|
|
183
|
+
throw new Error(`migrate diff compares one schema, and this run owns ${target.schemas.join(', ')}: name one with --schema.`);
|
|
184
|
+
const dialect = dialectOf(target.url);
|
|
185
|
+
const db = await scratch(target.url, options.devUrl);
|
|
186
|
+
try {
|
|
187
|
+
const built = { ...target, url: db.built };
|
|
188
|
+
const result = await migrateUp(built);
|
|
189
|
+
if (result.refused)
|
|
190
|
+
throw new Error(result.refused);
|
|
191
|
+
if (result.status.plan.problems.length)
|
|
192
|
+
throw new Error(result.status.plan.problems.join(' '));
|
|
193
|
+
if (result.failure)
|
|
194
|
+
throw new Error(`${result.failure.file.script} failed on a scratch database: ${result.failure.message}`);
|
|
195
|
+
const schema = dialect === 'postgres' ? (target.schemas[0] ?? 'public') : undefined;
|
|
196
|
+
/* Atlas reads schema.sql into the scoped schema of the dev database, and will not make it. */
|
|
197
|
+
if (schema !== undefined && schema !== 'public') {
|
|
198
|
+
const dev = await openMigrationDb(db.dev, [], false);
|
|
199
|
+
try {
|
|
200
|
+
await dev.run(`CREATE SCHEMA IF NOT EXISTS ${quoteIdent('postgres', schema)}`);
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
await dev.close();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
const from = atlasUrl(db.built, schema);
|
|
207
|
+
const dev = dialect === 'postgres' ? atlasUrl(db.dev, schema) : { url: db.dev, env: {} };
|
|
208
|
+
/* SQLite reads a copy with PostgreSQL's serial primary keys in its own spelling; the file itself when nothing changed. */
|
|
209
|
+
let to = resolve(options.schemaFile);
|
|
210
|
+
if (dialect === 'sqlite') {
|
|
211
|
+
const text = readFileSync(to, 'utf8');
|
|
212
|
+
const read = sqliteDesired(text);
|
|
213
|
+
if (read !== text)
|
|
214
|
+
writeFileSync((to = join(dirname(db.built), 'schema.sql')), read);
|
|
215
|
+
}
|
|
216
|
+
const excludes = [...new Set([...RUNTIME_TABLE_PREFIXES.map((prefix) => `${prefix}*`), target.table])].flatMap((pattern) => [
|
|
217
|
+
'--exclude',
|
|
218
|
+
pattern,
|
|
219
|
+
]);
|
|
220
|
+
const sql = await runAtlas(options.atlas, ['schema', 'diff', '--from', from.url, '--to', `file://${to}`, '--dev-url', dev.url, ...excludes, '--format', '{{ sql . " " }}'], { ...from.env, ...dev.env });
|
|
221
|
+
return sql.trim();
|
|
222
|
+
}
|
|
223
|
+
finally {
|
|
224
|
+
await db.drop();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* schema.sql as SQLite is to read it. PostgreSQL numbers a `serial` column
|
|
229
|
+
* from a sequence; SQLite takes any word as a type, so `id serial primary key`
|
|
230
|
+
* is accepted as a plain nullable column, Atlas writes it back as
|
|
231
|
+
* `` `id` serial NULL ``, and every new row's id is NULL. SQLite numbers only
|
|
232
|
+
* an `integer` primary key (the rowid's other name), so a serial primary key
|
|
233
|
+
* is read as one here, and one schema.sql serves both databases — the
|
|
234
|
+
* quickstart's and the home page's do. A serial column that is not declared
|
|
235
|
+
* the primary key on its own line has nothing on SQLite to number it, and is
|
|
236
|
+
* refused by name rather than left to come out NULL.
|
|
237
|
+
*/
|
|
238
|
+
export function sqliteDesired(text) {
|
|
239
|
+
const read = text.replace(/\b(?:small|big)?serial(\s+(?:not\s+null\s+)?primary\s+key)\b/gi, 'integer$1');
|
|
240
|
+
const bare = read.replace(/--[^\n]*|\/\*[\s\S]*?\*\//g, '');
|
|
241
|
+
/* Not before `(`: that is a table or an index named serial, not a column's type. */
|
|
242
|
+
const left = /([A-Za-z_][\w$]*|"[^"]+"|`[^`]+`)\s+((?:small|big)?serial)\b(?!\s*\()/i.exec(bare);
|
|
243
|
+
if (left)
|
|
244
|
+
throw new Error(`${left[1]} is ${left[2]}, which SQLite does not number. On SQLite only the primary key is numbered: write it \`${left[1]} ${left[2]} primary key\` (read as integer primary key), or give it another type.`);
|
|
245
|
+
return read;
|
|
246
|
+
}
|
|
247
|
+
/** The header a written migration carries: where it came from, and what a diff cannot know. */
|
|
248
|
+
export const diffHeader = () => '-- Written by ' +
|
|
249
|
+
product() +
|
|
250
|
+
' migrate diff from schema.sql. Review it before committing:\n' +
|
|
251
|
+
'-- a rename comes out as DROP and ADD, and a backfill or data step is not here.\n';
|
|
252
|
+
/**
|
|
253
|
+
* The first versioned migration: what an empty database lacks to reach
|
|
254
|
+
* `schema.sql` is `schema.sql`, so it is written as it stands — comments and
|
|
255
|
+
* all, as a squash writes it — and no diff tool is fetched for it. On SQLite
|
|
256
|
+
* it is schema.sql as SQLite reads it (`sqliteDesired`). `migrate up` is what
|
|
257
|
+
* proves it runs; the next `migrate diff` compares the two as any other does.
|
|
258
|
+
*/
|
|
259
|
+
export function firstMigration(schemaFile, dialect, schemas) {
|
|
260
|
+
if (!existsSync(schemaFile))
|
|
261
|
+
throw new Error(`there is no ${schemaFile}: write the schema you want there, or name it with --schema-file.`);
|
|
262
|
+
if (schemas.length > 1)
|
|
263
|
+
throw new Error(`migrate diff compares one schema, and this run owns ${schemas.join(', ')}: name one with --schema.`);
|
|
264
|
+
const text = readFileSync(schemaFile, 'utf8');
|
|
265
|
+
return dialect === 'sqlite' ? sqliteDesired(text) : text;
|
|
266
|
+
}
|
|
267
|
+
/** The header the first migration carries: it is schema.sql, not a diff. */
|
|
268
|
+
export const firstHeader = () => '-- Written by ' + product() + ' migrate diff: schema.sql as it stands, the first migration. Review it before committing.\n';
|
|
269
|
+
/**
|
|
270
|
+
* Fold the versioned chain into one `V1__baseline.sql` holding `schema.sql`
|
|
271
|
+
* itself — comments and all, since the check has just shown the two build the
|
|
272
|
+
* same schema. Repeatable files stay. Only before a database worth keeping
|
|
273
|
+
* exists: one migrated with the old chain no longer matches its history.
|
|
274
|
+
* On SQLite it is schema.sql as SQLite reads it (`sqliteDesired`), so the
|
|
275
|
+
* baseline numbers its ids as the diff's files did. Returns the files
|
|
276
|
+
* removed and the one written.
|
|
277
|
+
*/
|
|
278
|
+
export function squashInto(dir, schemaFile, dialect) {
|
|
279
|
+
const { files } = readMigrations(dir);
|
|
280
|
+
const versioned = files.filter((file) => file.kind === 'versioned');
|
|
281
|
+
const removed = [];
|
|
282
|
+
for (const file of versioned) {
|
|
283
|
+
rmSync(file.path);
|
|
284
|
+
if (existsSync(`${file.path}.conf`))
|
|
285
|
+
rmSync(`${file.path}.conf`);
|
|
286
|
+
removed.push(file.script);
|
|
287
|
+
}
|
|
288
|
+
const text = readFileSync(schemaFile, 'utf8');
|
|
289
|
+
const wrote = join(dir, 'V1__baseline.sql');
|
|
290
|
+
writeFileSync(wrote, `-- The migrations up to here, squashed by ${product()} migrate squash: the schema.sql they built.\n${dialect === 'sqlite' ? sqliteDesired(text) : text}`);
|
|
291
|
+
return { removed, wrote };
|
|
292
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface MigrationFile {
|
|
2
|
+
readonly kind: 'versioned' | 'repeatable';
|
|
3
|
+
/** Flyway's spelling of the version: the name's digits, `_` read as `.`. Absent for a repeatable. */
|
|
4
|
+
readonly version?: string;
|
|
5
|
+
/** The name after `__`, underscores as spaces: what the history's description says. */
|
|
6
|
+
readonly description: string;
|
|
7
|
+
/** The path under the directory, `/`-separated: the history's script. */
|
|
8
|
+
readonly script: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly sql: string;
|
|
11
|
+
readonly checksum: number;
|
|
12
|
+
/** False only where the file's `.conf` says `executeInTransaction=false`. */
|
|
13
|
+
readonly transactional: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface MigrationDirectory {
|
|
16
|
+
readonly dir: string;
|
|
17
|
+
readonly files: readonly MigrationFile[];
|
|
18
|
+
/** Files that look meant as migrations and are not (`V1_add.sql`): said, never run. */
|
|
19
|
+
readonly ignored: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/** Flyway's checksum of a script's text. */
|
|
22
|
+
export declare function flywayChecksum(text: string): number;
|
|
23
|
+
/** Flyway's order of versions: dotted parts compared as numbers, a missing part as 0. */
|
|
24
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
25
|
+
/** Every migration under `dir`, versioned ones in version order, then the repeatables by description. */
|
|
26
|
+
export declare function readMigrations(dir: string): MigrationDirectory;
|
|
27
|
+
/**
|
|
28
|
+
* Write the next migration's file, empty but for a line that says what the
|
|
29
|
+
* runner will do with it. The version is one past the highest the directory
|
|
30
|
+
* holds, in the directory's own style: a team that numbers by timestamp gets a
|
|
31
|
+
* timestamp. `body` is the file's text when something already wrote it
|
|
32
|
+
* (`migrate diff`).
|
|
33
|
+
*/
|
|
34
|
+
export declare function newMigration(dir: string, name: string, repeatable: boolean, now?: Date, body?: string): string;
|