@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,52 @@
|
|
|
1
|
+
import { type NetworkPolicy } from '../net/networkPolicy.js';
|
|
2
|
+
export declare class CacheUnavailable extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
type RespValue = string | number | null | RespValue[];
|
|
6
|
+
interface RespOptions {
|
|
7
|
+
host: string;
|
|
8
|
+
port: number;
|
|
9
|
+
tls: boolean;
|
|
10
|
+
username?: string;
|
|
11
|
+
password?: string;
|
|
12
|
+
db?: number;
|
|
13
|
+
policy: NetworkPolicy;
|
|
14
|
+
connectTimeoutMs?: number;
|
|
15
|
+
commandTimeoutMs?: number;
|
|
16
|
+
retryAfterMs?: number;
|
|
17
|
+
}
|
|
18
|
+
/** One command as RESP: an array of bulk strings. */
|
|
19
|
+
export declare function encodeCommand(args: ReadonlyArray<string | number>): Buffer;
|
|
20
|
+
/** A server's error reply (`-ERR …`), kept apart from the transport's. */
|
|
21
|
+
export declare class RespReplyError extends Error {
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One reply from the front of `buffer`: the value and where it ended, or
|
|
25
|
+
* undefined when the reply has not fully arrived. An error reply is returned
|
|
26
|
+
* as a RespReplyError value for the caller to reject with.
|
|
27
|
+
*/
|
|
28
|
+
export declare function decodeReply(buffer: Buffer, start?: number): {
|
|
29
|
+
value: RespValue | RespReplyError;
|
|
30
|
+
end: number;
|
|
31
|
+
} | undefined;
|
|
32
|
+
export declare class RespClient {
|
|
33
|
+
private readonly options;
|
|
34
|
+
private socket?;
|
|
35
|
+
private opening?;
|
|
36
|
+
private buffer;
|
|
37
|
+
private readonly waiting;
|
|
38
|
+
private quietUntil;
|
|
39
|
+
private lastFailure;
|
|
40
|
+
private closed;
|
|
41
|
+
constructor(options: RespOptions);
|
|
42
|
+
private get where();
|
|
43
|
+
/** Send one command and wait for its reply. Rejects with CacheUnavailable, or RespReplyError for the server's own refusal. */
|
|
44
|
+
command(...args: Array<string | number>): Promise<RespValue>;
|
|
45
|
+
close(): Promise<void>;
|
|
46
|
+
private write;
|
|
47
|
+
private fail;
|
|
48
|
+
private connected;
|
|
49
|
+
private open;
|
|
50
|
+
private read;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small RESP2 client for a Valkey (or Redis) cache.
|
|
3
|
+
*
|
|
4
|
+
* Built in rather than a dependency for one reason: the socket has to go
|
|
5
|
+
* where the operator's config said and nowhere else, so its host resolves
|
|
6
|
+
* through the shared network policy (networkPolicy.ts) — the address checked
|
|
7
|
+
* is the address connected — and a client library opens its own sockets. It
|
|
8
|
+
* speaks only what the cache needs: AUTH, SELECT, GET, SET … PX, DEL, EVAL,
|
|
9
|
+
* PING. Commands pipeline over one connection in order.
|
|
10
|
+
*
|
|
11
|
+
* A cache is never a source of truth, so every failure is one kind of
|
|
12
|
+
* error, `CacheUnavailable`, and its message never carries the credential.
|
|
13
|
+
* After a failure the client stays quiet for a moment (`retryAfterMs`) and
|
|
14
|
+
* answers at once with the same error, so an outage costs a miss, not a
|
|
15
|
+
* connect timeout on every request.
|
|
16
|
+
*/
|
|
17
|
+
import { connect as netConnect } from 'node:net';
|
|
18
|
+
import { connect as tlsConnect } from 'node:tls';
|
|
19
|
+
import { checkedLookup, refusedLiteral } from '../net/networkPolicy.js';
|
|
20
|
+
export class CacheUnavailable extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'CacheUnavailable';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const CRLF = Buffer.from('\r\n');
|
|
27
|
+
/** One command as RESP: an array of bulk strings. */
|
|
28
|
+
export function encodeCommand(args) {
|
|
29
|
+
const parts = [Buffer.from(`*${args.length}\r\n`)];
|
|
30
|
+
for (const arg of args) {
|
|
31
|
+
const bytes = Buffer.from(String(arg), 'utf8');
|
|
32
|
+
parts.push(Buffer.from(`$${bytes.byteLength}\r\n`), bytes, CRLF);
|
|
33
|
+
}
|
|
34
|
+
return Buffer.concat(parts);
|
|
35
|
+
}
|
|
36
|
+
/** A server's error reply (`-ERR …`), kept apart from the transport's. */
|
|
37
|
+
export class RespReplyError extends Error {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One reply from the front of `buffer`: the value and where it ended, or
|
|
41
|
+
* undefined when the reply has not fully arrived. An error reply is returned
|
|
42
|
+
* as a RespReplyError value for the caller to reject with.
|
|
43
|
+
*/
|
|
44
|
+
export function decodeReply(buffer, start = 0) {
|
|
45
|
+
if (start >= buffer.length)
|
|
46
|
+
return undefined;
|
|
47
|
+
const line = buffer.indexOf(CRLF, start);
|
|
48
|
+
if (line < 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
const type = String.fromCharCode(buffer[start]);
|
|
51
|
+
const head = buffer.toString('utf8', start + 1, line);
|
|
52
|
+
const next = line + 2;
|
|
53
|
+
switch (type) {
|
|
54
|
+
case '+':
|
|
55
|
+
return { value: head, end: next };
|
|
56
|
+
case '-':
|
|
57
|
+
return { value: new RespReplyError(head), end: next };
|
|
58
|
+
case ':':
|
|
59
|
+
return { value: Number(head), end: next };
|
|
60
|
+
case '$': {
|
|
61
|
+
const size = Number(head);
|
|
62
|
+
if (size < 0)
|
|
63
|
+
return { value: null, end: next };
|
|
64
|
+
if (buffer.length < next + size + 2)
|
|
65
|
+
return undefined;
|
|
66
|
+
return { value: buffer.toString('utf8', next, next + size), end: next + size + 2 };
|
|
67
|
+
}
|
|
68
|
+
case '*': {
|
|
69
|
+
const count = Number(head);
|
|
70
|
+
if (count < 0)
|
|
71
|
+
return { value: null, end: next };
|
|
72
|
+
const items = [];
|
|
73
|
+
let at = next;
|
|
74
|
+
for (let i = 0; i < count; i++) {
|
|
75
|
+
const item = decodeReply(buffer, at);
|
|
76
|
+
if (!item)
|
|
77
|
+
return undefined;
|
|
78
|
+
if (item.value instanceof RespReplyError)
|
|
79
|
+
return { value: item.value, end: item.end };
|
|
80
|
+
items.push(item.value);
|
|
81
|
+
at = item.end;
|
|
82
|
+
}
|
|
83
|
+
return { value: items, end: at };
|
|
84
|
+
}
|
|
85
|
+
default:
|
|
86
|
+
throw new CacheUnavailable(`the cache answered something that is not RESP ("${type}").`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export class RespClient {
|
|
90
|
+
options;
|
|
91
|
+
socket;
|
|
92
|
+
opening;
|
|
93
|
+
buffer = Buffer.alloc(0);
|
|
94
|
+
waiting = [];
|
|
95
|
+
quietUntil = 0;
|
|
96
|
+
lastFailure = '';
|
|
97
|
+
closed = false;
|
|
98
|
+
constructor(options) {
|
|
99
|
+
this.options = options;
|
|
100
|
+
}
|
|
101
|
+
get where() {
|
|
102
|
+
return `${this.options.host}:${this.options.port}`;
|
|
103
|
+
}
|
|
104
|
+
/** Send one command and wait for its reply. Rejects with CacheUnavailable, or RespReplyError for the server's own refusal. */
|
|
105
|
+
async command(...args) {
|
|
106
|
+
if (this.closed)
|
|
107
|
+
throw new CacheUnavailable('the cache connection is closed.');
|
|
108
|
+
if (Date.now() < this.quietUntil)
|
|
109
|
+
throw new CacheUnavailable(this.lastFailure);
|
|
110
|
+
const socket = await this.connected();
|
|
111
|
+
return this.write(socket, args);
|
|
112
|
+
}
|
|
113
|
+
async close() {
|
|
114
|
+
this.closed = true;
|
|
115
|
+
const socket = this.socket;
|
|
116
|
+
this.socket = undefined;
|
|
117
|
+
if (socket) {
|
|
118
|
+
try {
|
|
119
|
+
await this.write(socket, ['QUIT']);
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
/* already gone */
|
|
123
|
+
}
|
|
124
|
+
socket.destroy();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
write(socket, args) {
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
const timer = setTimeout(() => this.fail(`${this.where} did not answer within ${(this.options.commandTimeoutMs ?? 1_000) / 1000} s.`), this.options.commandTimeoutMs ?? 1_000);
|
|
130
|
+
this.waiting.push({
|
|
131
|
+
resolve: (value) => {
|
|
132
|
+
clearTimeout(timer);
|
|
133
|
+
resolve(value);
|
|
134
|
+
},
|
|
135
|
+
reject: (error) => {
|
|
136
|
+
clearTimeout(timer);
|
|
137
|
+
reject(error);
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
socket.write(encodeCommand(args));
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/* Every waiting command fails with the transport's reason, the socket is
|
|
144
|
+
dropped, and the client stays quiet for a moment before dialing again. */
|
|
145
|
+
fail(message) {
|
|
146
|
+
this.lastFailure = message;
|
|
147
|
+
this.quietUntil = Date.now() + (this.options.retryAfterMs ?? 2_000);
|
|
148
|
+
const socket = this.socket;
|
|
149
|
+
this.socket = undefined;
|
|
150
|
+
this.buffer = Buffer.alloc(0);
|
|
151
|
+
socket?.destroy();
|
|
152
|
+
for (const waiting of this.waiting.splice(0))
|
|
153
|
+
waiting.reject(new CacheUnavailable(message));
|
|
154
|
+
}
|
|
155
|
+
connected() {
|
|
156
|
+
if (this.socket)
|
|
157
|
+
return Promise.resolve(this.socket);
|
|
158
|
+
return (this.opening ??= this.open().finally(() => {
|
|
159
|
+
this.opening = undefined;
|
|
160
|
+
}));
|
|
161
|
+
}
|
|
162
|
+
async open() {
|
|
163
|
+
const { host, port, tls, policy } = this.options;
|
|
164
|
+
const literal = refusedLiteral(host, policy);
|
|
165
|
+
if (literal) {
|
|
166
|
+
this.lastFailure = `${this.where}: the address ${literal} is one this connection may not reach.`;
|
|
167
|
+
this.quietUntil = Date.now() + (this.options.retryAfterMs ?? 2_000);
|
|
168
|
+
throw new CacheUnavailable(this.lastFailure);
|
|
169
|
+
}
|
|
170
|
+
const lookup = checkedLookup(policy, (name, addresses) => new CacheUnavailable(`${name} resolves only to addresses this connection may not reach (${addresses.join(', ')}).`));
|
|
171
|
+
const socket = await new Promise((resolve, reject) => {
|
|
172
|
+
const timeoutMs = this.options.connectTimeoutMs ?? 2_000;
|
|
173
|
+
const opened = tls ? tlsConnect({ host, port, servername: host, lookup }) : netConnect({ host, port, lookup });
|
|
174
|
+
const timer = setTimeout(() => {
|
|
175
|
+
opened.destroy();
|
|
176
|
+
reject(new CacheUnavailable(`${this.where} did not accept a connection within ${timeoutMs / 1000} s.`));
|
|
177
|
+
}, timeoutMs);
|
|
178
|
+
opened.once(tls ? 'secureConnect' : 'connect', () => {
|
|
179
|
+
clearTimeout(timer);
|
|
180
|
+
resolve(opened);
|
|
181
|
+
});
|
|
182
|
+
opened.once('error', (error) => {
|
|
183
|
+
clearTimeout(timer);
|
|
184
|
+
reject(error instanceof CacheUnavailable ? error : new CacheUnavailable(`${this.where}: ${error.code ?? 'the connection failed'}.`));
|
|
185
|
+
});
|
|
186
|
+
}).catch((error) => {
|
|
187
|
+
this.lastFailure = error.message;
|
|
188
|
+
this.quietUntil = Date.now() + (this.options.retryAfterMs ?? 2_000);
|
|
189
|
+
throw error;
|
|
190
|
+
});
|
|
191
|
+
socket.setNoDelay(true);
|
|
192
|
+
socket.on('data', (chunk) => this.read(chunk));
|
|
193
|
+
socket.on('error', (error) => this.fail(`${this.where}: ${error.code ?? 'the connection failed'}.`));
|
|
194
|
+
socket.on('close', () => {
|
|
195
|
+
if (this.socket === socket)
|
|
196
|
+
this.fail(`${this.where} closed the connection.`);
|
|
197
|
+
});
|
|
198
|
+
this.socket = socket;
|
|
199
|
+
try {
|
|
200
|
+
if (this.options.password !== undefined) {
|
|
201
|
+
await this.write(socket, this.options.username ? ['AUTH', this.options.username, this.options.password] : ['AUTH', this.options.password]);
|
|
202
|
+
}
|
|
203
|
+
if (this.options.db)
|
|
204
|
+
await this.write(socket, ['SELECT', this.options.db]);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
/* The server's own words for a bad password name the password's
|
|
208
|
+
owner at most; still, only the fact is kept. */
|
|
209
|
+
const message = error instanceof RespReplyError ? `${this.where} refused the connection's credential or database.` : error.message;
|
|
210
|
+
this.fail(message);
|
|
211
|
+
throw new CacheUnavailable(message);
|
|
212
|
+
}
|
|
213
|
+
return socket;
|
|
214
|
+
}
|
|
215
|
+
read(chunk) {
|
|
216
|
+
this.buffer = this.buffer.length ? Buffer.concat([this.buffer, chunk]) : chunk;
|
|
217
|
+
for (;;) {
|
|
218
|
+
let reply;
|
|
219
|
+
try {
|
|
220
|
+
reply = decodeReply(this.buffer);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
return this.fail(error.message);
|
|
224
|
+
}
|
|
225
|
+
if (!reply)
|
|
226
|
+
return;
|
|
227
|
+
this.buffer = this.buffer.subarray(reply.end);
|
|
228
|
+
const waiting = this.waiting.shift();
|
|
229
|
+
if (!waiting)
|
|
230
|
+
continue;
|
|
231
|
+
if (reply.value instanceof RespReplyError)
|
|
232
|
+
waiting.reject(reply.value);
|
|
233
|
+
else
|
|
234
|
+
waiting.resolve(reply.value);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class CommandInputError extends Error {
|
|
2
|
+
readonly code = "invalid_input";
|
|
3
|
+
readonly field?: string;
|
|
4
|
+
constructor(field?: string);
|
|
5
|
+
}
|
|
6
|
+
/** The bound on one command request, envelope included. */
|
|
7
|
+
export declare const MAX_COMMAND_BYTES = 65536;
|
|
8
|
+
/** Names that belong to Object.prototype, never to data. */
|
|
9
|
+
export declare const reservedKeys: ReadonlySet<string>;
|
|
10
|
+
export type Json = null | boolean | number | string | readonly Json[] | {
|
|
11
|
+
readonly [key: string]: Json;
|
|
12
|
+
};
|
|
13
|
+
/** Read descriptors once, producing the serialized bytes and immutable snapshot together. */
|
|
14
|
+
export declare function snapshot(value: unknown, maxBytes: number): {
|
|
15
|
+
json: string;
|
|
16
|
+
value: Json;
|
|
17
|
+
};
|
|
18
|
+
/** Deterministic JSON, with UTF-16 lexically sorted object keys and JSON number spelling. */
|
|
19
|
+
export declare function canonicalCommandJson(value: unknown, maxBytes?: number): string;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Canonical JSON: the one bounded walk that reads a command request, and the
|
|
3
|
+
* one spelling (sorted keys, JSON number spelling) that the command journals,
|
|
4
|
+
* event stores, job stores and auth store digest and compare. It refuses what
|
|
5
|
+
* JSON.stringify would run or drop quietly (getters, proxies, cycles, foreign
|
|
6
|
+
* prototypes, reserved keys) without invoking any of it. It sits with the
|
|
7
|
+
* stores, below the command runtime, because both read by it.
|
|
8
|
+
*/
|
|
9
|
+
import { types } from 'node:util';
|
|
10
|
+
import { COMMAND_FIELD_PATH } from '../../shared/commandFieldPath.js';
|
|
11
|
+
export class CommandInputError extends Error {
|
|
12
|
+
code = 'invalid_input';
|
|
13
|
+
/* Where in the envelope the request was refused — `key`, `idempotencyKey`,
|
|
14
|
+
`keys[3]`, `key.tenant_id`. The message stays fixed, as every refusal's
|
|
15
|
+
does; this is the part that tells a caller which of a dozen members to
|
|
16
|
+
look at, and without it an agent could not tell a malformed request from
|
|
17
|
+
a broken platform. It is always one of the envelope's own member names or
|
|
18
|
+
a name from the App's declaration — never a key the request invented,
|
|
19
|
+
which would echo text the caller chose into whatever reads a refusal.
|
|
20
|
+
The path is held to the same bound a handler's refusal is. */
|
|
21
|
+
field;
|
|
22
|
+
constructor(field) {
|
|
23
|
+
super('The command request is invalid.');
|
|
24
|
+
this.name = 'CommandInputError';
|
|
25
|
+
if (typeof field === 'string' && field.length <= 200 && COMMAND_FIELD_PATH.test(field))
|
|
26
|
+
this.field = field;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The bound on one command request, envelope included. */
|
|
30
|
+
export const MAX_COMMAND_BYTES = 65_536;
|
|
31
|
+
const MAX_DEPTH = 16;
|
|
32
|
+
const MAX_NODES = 10_000;
|
|
33
|
+
/** Names that belong to Object.prototype, never to data. */
|
|
34
|
+
export const reservedKeys = new Set([...Object.getOwnPropertyNames(Object.prototype), 'prototype']);
|
|
35
|
+
const invalid = () => {
|
|
36
|
+
throw new CommandInputError();
|
|
37
|
+
};
|
|
38
|
+
/** Read descriptors once, producing the serialized bytes and immutable snapshot together. */
|
|
39
|
+
export function snapshot(value, maxBytes) {
|
|
40
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0)
|
|
41
|
+
return invalid();
|
|
42
|
+
const active = new WeakSet();
|
|
43
|
+
const tokens = [];
|
|
44
|
+
let bytes = 0;
|
|
45
|
+
let nodes = 0;
|
|
46
|
+
const append = (token) => {
|
|
47
|
+
bytes += Buffer.byteLength(token, 'utf8');
|
|
48
|
+
if (bytes > maxBytes)
|
|
49
|
+
invalid();
|
|
50
|
+
tokens.push(token);
|
|
51
|
+
};
|
|
52
|
+
const string = (text) => {
|
|
53
|
+
// Refuse oversized strings before allocating their escaped JSON representation.
|
|
54
|
+
if (Buffer.byteLength(text, 'utf8') > maxBytes - bytes)
|
|
55
|
+
invalid();
|
|
56
|
+
append(JSON.stringify(text));
|
|
57
|
+
};
|
|
58
|
+
const visit = (item, depth) => {
|
|
59
|
+
if (++nodes > MAX_NODES || depth > MAX_DEPTH)
|
|
60
|
+
return invalid();
|
|
61
|
+
if (item === null) {
|
|
62
|
+
append('null');
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
if (typeof item === 'string') {
|
|
66
|
+
string(item);
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
if (typeof item === 'boolean') {
|
|
70
|
+
append(item ? 'true' : 'false');
|
|
71
|
+
return item;
|
|
72
|
+
}
|
|
73
|
+
if (typeof item === 'number') {
|
|
74
|
+
if (!Number.isFinite(item))
|
|
75
|
+
return invalid();
|
|
76
|
+
append(JSON.stringify(item));
|
|
77
|
+
return Object.is(item, -0) ? 0 : item;
|
|
78
|
+
}
|
|
79
|
+
if (typeof item !== 'object' || types.isProxy(item) || active.has(item))
|
|
80
|
+
return invalid();
|
|
81
|
+
const array = Array.isArray(item);
|
|
82
|
+
const prototype = Object.getPrototypeOf(item);
|
|
83
|
+
if (prototype !== null && prototype !== (array ? Array.prototype : Object.prototype))
|
|
84
|
+
return invalid();
|
|
85
|
+
const length = array ? Object.getOwnPropertyDescriptor(item, 'length').value : 0;
|
|
86
|
+
if (array && (!Number.isSafeInteger(length) || length < 0 || length > MAX_NODES - nodes))
|
|
87
|
+
return invalid();
|
|
88
|
+
active.add(item);
|
|
89
|
+
try {
|
|
90
|
+
const descriptors = Object.getOwnPropertyDescriptors(item);
|
|
91
|
+
const keys = Reflect.ownKeys(descriptors);
|
|
92
|
+
if (array) {
|
|
93
|
+
if (keys.length !== length + 1)
|
|
94
|
+
return invalid();
|
|
95
|
+
for (const key of keys) {
|
|
96
|
+
if (key === 'length')
|
|
97
|
+
continue;
|
|
98
|
+
if (typeof key !== 'string' || !/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= length)
|
|
99
|
+
return invalid();
|
|
100
|
+
}
|
|
101
|
+
const copy = [];
|
|
102
|
+
append('[');
|
|
103
|
+
for (let index = 0; index < length; index++) {
|
|
104
|
+
const descriptor = descriptors[index];
|
|
105
|
+
if (!descriptor || !descriptor.enumerable || !('value' in descriptor))
|
|
106
|
+
return invalid();
|
|
107
|
+
if (index)
|
|
108
|
+
append(',');
|
|
109
|
+
copy.push(visit(descriptor.value, depth + 1));
|
|
110
|
+
}
|
|
111
|
+
append(']');
|
|
112
|
+
return Object.freeze(copy);
|
|
113
|
+
}
|
|
114
|
+
if (keys.length > MAX_NODES - nodes)
|
|
115
|
+
return invalid();
|
|
116
|
+
const names = [];
|
|
117
|
+
for (const key of keys) {
|
|
118
|
+
if (typeof key !== 'string' || reservedKeys.has(key))
|
|
119
|
+
return invalid();
|
|
120
|
+
const descriptor = descriptors[key];
|
|
121
|
+
if (!descriptor.enumerable || !('value' in descriptor))
|
|
122
|
+
return invalid();
|
|
123
|
+
names.push(key);
|
|
124
|
+
}
|
|
125
|
+
names.sort();
|
|
126
|
+
const copy = Object.create(null);
|
|
127
|
+
append('{');
|
|
128
|
+
for (let index = 0; index < names.length; index++) {
|
|
129
|
+
const name = names[index];
|
|
130
|
+
if (index)
|
|
131
|
+
append(',');
|
|
132
|
+
string(name);
|
|
133
|
+
append(':');
|
|
134
|
+
copy[name] = visit(descriptors[name].value, depth + 1);
|
|
135
|
+
}
|
|
136
|
+
append('}');
|
|
137
|
+
return Object.freeze(copy);
|
|
138
|
+
}
|
|
139
|
+
finally {
|
|
140
|
+
active.delete(item);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
const copy = visit(value, 0);
|
|
144
|
+
return { json: tokens.join(''), value: copy };
|
|
145
|
+
}
|
|
146
|
+
/** Deterministic JSON, with UTF-16 lexically sorted object keys and JSON number spelling. */
|
|
147
|
+
export function canonicalCommandJson(value, maxBytes = MAX_COMMAND_BYTES) {
|
|
148
|
+
try {
|
|
149
|
+
return snapshot(value, maxBytes).json;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return invalid();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn whatever the user typed into an adapter.
|
|
3
|
+
*
|
|
4
|
+
* There is exactly one place that decides which dialect a string means, so
|
|
5
|
+
* adding a database later is a case here rather than a search through
|
|
6
|
+
* the server.
|
|
7
|
+
*/
|
|
8
|
+
import type { Adapter } from './adapter.js';
|
|
9
|
+
import type { PgConnectionOptions } from './postgresPool.js';
|
|
10
|
+
import type { NetworkPolicy } from './net/networkPolicy.js';
|
|
11
|
+
interface ConnectOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Restrict Postgres introspection to these schemas.
|
|
14
|
+
*/
|
|
15
|
+
schemas?: string[];
|
|
16
|
+
/** Display name; defaults to something derived and password-free. */
|
|
17
|
+
label?: string;
|
|
18
|
+
/** A PostgreSQL connection's pool, as its config entry sizes it; the
|
|
19
|
+
* process defaults fill the rest. Every other dialect ignores it. */
|
|
20
|
+
postgres?: PgConnectionOptions;
|
|
21
|
+
/** Read replicas of a PostgreSQL database, already resolved: lag-tolerant reads go to them (replicas.ts). */
|
|
22
|
+
replicas?: readonly string[];
|
|
23
|
+
/** Set when an untrusted client typed the address: it is dialled sealed, through this policy (net/untrustedDatabase.ts). */
|
|
24
|
+
network?: NetworkPolicy;
|
|
25
|
+
}
|
|
26
|
+
/** What a mysql:// or mariadb:// address, or a config that names one, is told. */
|
|
27
|
+
export declare const MYSQL_REFUSAL = "MySQL is not supported; use PostgreSQL or SQLite.";
|
|
28
|
+
export declare function connect(target: string, options?: ConnectOptions): Adapter;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SqliteAdapter } from './sqlite.js';
|
|
2
|
+
import { PostgresAdapter } from './postgres.js';
|
|
3
|
+
/** What a mysql:// or mariadb:// address, or a config that names one, is told. */
|
|
4
|
+
export const MYSQL_REFUSAL = 'MySQL is not supported; use PostgreSQL or SQLite.';
|
|
5
|
+
export function connect(target, options = {}) {
|
|
6
|
+
const replicas = options.replicas?.length ? options.replicas : undefined;
|
|
7
|
+
if (/^postgres(ql)?:\/\//i.test(target)) {
|
|
8
|
+
if (replicas?.some((url) => !/^postgres(ql)?:\/\//i.test(url)))
|
|
9
|
+
throw new Error("A PostgreSQL connection's replicas are postgres://… URLs.");
|
|
10
|
+
const pool = replicas || options.network ? { ...options.postgres, ...(replicas ? { replicas } : {}), network: options.network } : options.postgres;
|
|
11
|
+
return new PostgresAdapter(target, options.label, options.schemas ?? [], undefined, pool);
|
|
12
|
+
}
|
|
13
|
+
/* Said by name rather than as an unknown scheme: MySQL and MariaDB were never in 1.0, and a config that
|
|
14
|
+
still names one should hear that, not "don't know how to open". */
|
|
15
|
+
if (/^(mysql|mariadb):\/\//i.test(target))
|
|
16
|
+
throw new Error(MYSQL_REFUSAL);
|
|
17
|
+
/* Said before the file is opened: a SQLite file is read where it lies,
|
|
18
|
+
and a copy of it elsewhere would be another database, not a replica. */
|
|
19
|
+
if (replicas && (/^sqlite:/i.test(target) || /\.(db|sqlite|sqlite3)$/i.test(target) || !target.includes('://')))
|
|
20
|
+
throw new Error('SQLite has no replicas: a file is read where it is. Remove "replicas".');
|
|
21
|
+
if (/^sqlite:/i.test(target)) {
|
|
22
|
+
const file = target.replace(/^sqlite:(\/\/)?/i, '');
|
|
23
|
+
return new SqliteAdapter(file, options.label ?? file);
|
|
24
|
+
}
|
|
25
|
+
// A bare path is a SQLite file. This is the common case for the demo and
|
|
26
|
+
// for anyone poking at an app's local database, so it needs no scheme.
|
|
27
|
+
if (/\.(db|sqlite|sqlite3)$/i.test(target) || !target.includes('://')) {
|
|
28
|
+
return new SqliteAdapter(target, options.label ?? target);
|
|
29
|
+
}
|
|
30
|
+
/* The scheme, not the target.
|
|
31
|
+
|
|
32
|
+
`target` here is the *resolved* connection string — the password has
|
|
33
|
+
already been expanded into it — and this message was stored on the
|
|
34
|
+
connection entry and served to the browser from then on. The scheme is
|
|
35
|
+
the whole of the useful content anyway: what is wrong is the protocol,
|
|
36
|
+
and repeating the credentials does not help anyone fix it. */
|
|
37
|
+
const scheme = target.match(/^([a-z][\w+.-]*):\/\//i)?.[1];
|
|
38
|
+
throw new Error(`Don't know how to open ${scheme ? `a "${scheme}://" connection` : 'that connection'}. ` +
|
|
39
|
+
'Supported: a SQLite file path, sqlite:<path>, or postgres://…');
|
|
40
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How many connections this process can hold against each PostgreSQL
|
|
3
|
+
* database, and whether the server would let it.
|
|
4
|
+
*
|
|
5
|
+
* Every pool is sized for the process it lives in and knows nothing of the
|
|
6
|
+
* others: the read and write pools (`--read-pool`, `--write-pool`), the
|
|
7
|
+
* background writer, a LISTEN connection, the auth store's pool. A second
|
|
8
|
+
* replica multiplies all of them, and the server's limit (the role's, or
|
|
9
|
+
* `max_connections`) is the first anyone hears of the product — as a 53300
|
|
10
|
+
* under load. So each holder says what it may open when it is made
|
|
11
|
+
* (`holdConnections`), the totals are read by database, and a start compares
|
|
12
|
+
* them with what the server says it allows (`adviseConnectionLimits`).
|
|
13
|
+
* `mistri check --deploy` does the same sum before anything runs
|
|
14
|
+
* (`processConnections`), for as many replicas as the operator names.
|
|
15
|
+
*
|
|
16
|
+
* Counted: pools at their `max`, whether or not they have opened yet — a
|
|
17
|
+
* ceiling, not a reading. Not counted: the short-lived client that cancels a
|
|
18
|
+
* statement (pg_cancel_backend) and the one-shot clients of migrations and
|
|
19
|
+
* maintenance, which run beside a stopped or starting server.
|
|
20
|
+
*/
|
|
21
|
+
/** The one thing the advice needs of a connection: a query. */
|
|
22
|
+
interface Asks {
|
|
23
|
+
query(text: string): Promise<{
|
|
24
|
+
rows: Array<Record<string, unknown>>;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/** The connections a manager of PostgreSQL pools may hold: its readers, its writers and the one background writer. */
|
|
28
|
+
export declare const managerConnections: (readers: number, writers: number) => number;
|
|
29
|
+
/**
|
|
30
|
+
* What a short-lived store manager asks for (a retention prune's, a command line's): one reader and one writer.
|
|
31
|
+
*/
|
|
32
|
+
export declare const SMALL_STORE_POOL: Readonly<{
|
|
33
|
+
readers: 1;
|
|
34
|
+
writers: 1;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* The one manager the server's own stores share on a database (postgresPool.ts sharedPgConnections): the jobs host
|
|
38
|
+
* with its workflow and event-delivery stores, the effects host, the mail outbox, the integrations store, the
|
|
39
|
+
* decisions, assistant and API event stores. Two readers and two writers, whatever the App's pools, sized for their
|
|
40
|
+
* short statements and kept apart from the pools a person's reads and saves use, where a burst of job claims could
|
|
41
|
+
* otherwise queue ahead of a save. Not all of them are background: the assistant store, a tenant's decision
|
|
42
|
+
* suggestions and the API event feed answer a person, and share the two readers and two writers with job claims
|
|
43
|
+
* and completions, the mail outbox and the integrations. That is deliberate (no connection is added for them) and
|
|
44
|
+
* bounded by the pool's own queue, which answers busy. A job's own command and every delivery run as background
|
|
45
|
+
* work, on the one background writer, whose line is bounded the same way (postgresPool.ts). `mistri check --deploy`
|
|
46
|
+
* counts the same size (servedHosts.ts), so they cannot drift.
|
|
47
|
+
*/
|
|
48
|
+
export declare const RUNTIME_STORE_POOL: Readonly<{
|
|
49
|
+
readers: 2;
|
|
50
|
+
writers: 2;
|
|
51
|
+
}>;
|
|
52
|
+
/** `host:port/database` of a connection string, without its credentials: what two URLs share when they name one database. */
|
|
53
|
+
export declare function databaseOf(url: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Record that this process may now hold up to `count` connections to `url`'s database. Returns the release, called
|
|
56
|
+
* when the holder closes; calling it twice is harmless.
|
|
57
|
+
*/
|
|
58
|
+
export declare function holdConnections(url: string, count: number, ask?: () => Promise<Asks>): () => void;
|
|
59
|
+
/** Up to how many connections this process holds now, by database. */
|
|
60
|
+
export declare function heldConnections(): ReadonlyMap<string, number>;
|
|
61
|
+
/** What one App's serving holds against its database, per process. */
|
|
62
|
+
interface ProcessShape {
|
|
63
|
+
readers: number;
|
|
64
|
+
writers: number;
|
|
65
|
+
/** Read replicas of the database, each a reader pool of the same size on another server. */
|
|
66
|
+
replicas?: number;
|
|
67
|
+
/** Whether the live-sync LISTEN connection is held (not behind a transaction-mode pooler). */
|
|
68
|
+
listen?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** The connections one process may hold on the primary: its manager, plus the LISTEN connection. */
|
|
71
|
+
export declare const primaryConnections: (shape: ProcessShape) => number;
|
|
72
|
+
export interface DatabaseBudget {
|
|
73
|
+
database: string;
|
|
74
|
+
/** What one process may hold against it. */
|
|
75
|
+
perProcess: number;
|
|
76
|
+
processes: number;
|
|
77
|
+
total: number;
|
|
78
|
+
/** The most the server was told to allow, when the operator said (`--connection-limit`). */
|
|
79
|
+
limit?: number;
|
|
80
|
+
/** The cores the pool defaults were sized for, when they decided any size (`--cpus`). */
|
|
81
|
+
cpus?: number;
|
|
82
|
+
/** What one process's total is made of, term by term. */
|
|
83
|
+
parts?: ReadonlyArray<{
|
|
84
|
+
host: string;
|
|
85
|
+
connections: number;
|
|
86
|
+
}>;
|
|
87
|
+
}
|
|
88
|
+
/** One database's line for `mistri check --deploy`: "3 processes × 41 connections = 123". */
|
|
89
|
+
export declare function sayBudget(budget: DatabaseBudget): string;
|
|
90
|
+
/** The smaller of the limits that apply to this role, or undefined when neither is set. */
|
|
91
|
+
export declare function effectiveLimit(roleLimit: number | undefined, usable: number | undefined): number | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* One line a database whose holders may open more connections than its server allows this role, naming both
|
|
94
|
+
* numbers and the flags that lower them. Never refuses and never throws: one round trip per database, started
|
|
95
|
+
* after the first connection is open, whose failure (a pooler that answers no catalog, a role that may not read
|
|
96
|
+
* it) is silent.
|
|
97
|
+
*/
|
|
98
|
+
export declare function adviseConnectionLimits(say: (line: string) => void): Promise<void>;
|
|
99
|
+
/** The warning for one database given a connection to ask, or undefined when it fits. Exported for tests. */
|
|
100
|
+
export declare function limitAdvice(database: string, held: number, connection: Asks): Promise<string | undefined>;
|
|
101
|
+
export {};
|