@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,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The time unit a chart cuts its dates into when its author did not fix one: `chart('Signups', 'account', 'auto
|
|
3
|
+
* created_at', { over: 'created_at' })`.
|
|
4
|
+
*
|
|
5
|
+
* A fixed unit is right for one window and wrong for the next: `day` over 34 days with three days of data drew 34
|
|
6
|
+
* bars, 31 of them empty, and `day` over a year draws 365. The right unit depends on the window the reader picks and
|
|
7
|
+
* on how the data falls, so `auto` is decided where both are known, on the client, before the read. It is not a SQL
|
|
8
|
+
* bucket: the server never sees the word (`withUnit` writes the unit in), and the grammar's `DATE_UNITS` is unchanged.
|
|
9
|
+
*
|
|
10
|
+
* Two rules choose the unit, both pure so a table of cases can hold them:
|
|
11
|
+
* 1. The span picks a base unit: up to 45 days a day, up to 26 weeks a week, up to 36 months a month, past that a
|
|
12
|
+
* quarter.
|
|
13
|
+
* 2. Where the measure can be added up again (count, sum, min, max, avg as sum over count, and arithmetic of those),
|
|
14
|
+
* the base answer is coarsened locally while fewer than a third of its buckets hold data, as long as at least four
|
|
15
|
+
* buckets would remain. No second read. A median cannot be added up from its parts, so it follows the span only.
|
|
16
|
+
*/
|
|
17
|
+
import { dateWindow } from './queryDates.js';
|
|
18
|
+
/** Finest to coarsest: the order a sparse chart steps up through. */
|
|
19
|
+
const AUTO_UNITS = ['day', 'week', 'month', 'quarter'];
|
|
20
|
+
/** A bucket needs a third of its periods to hold data before the chart is left at the unit the span chose. */
|
|
21
|
+
const DENSE = 1 / 3;
|
|
22
|
+
/** Stepping up stops before the chart is left with fewer buckets than this. */
|
|
23
|
+
const FEWEST_BUCKETS = 4;
|
|
24
|
+
/* ---------- the word in a `by` ---------- */
|
|
25
|
+
const AUTO_KEY = /^auto\s+([\w.$+]+)(\s+as\s+[\w$]+)?$/i;
|
|
26
|
+
/** The key of a `by` written `auto <column>`, wherever it stands in the list: its place and its column. */
|
|
27
|
+
export function autoKeyOf(by) {
|
|
28
|
+
const keys = (by ?? '').split(',');
|
|
29
|
+
for (const [index, key] of keys.entries()) {
|
|
30
|
+
const m = AUTO_KEY.exec(key.trim());
|
|
31
|
+
if (m)
|
|
32
|
+
return { index, column: m[1] };
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
/** The `by` with its `auto` key written as the unit the chart chose, which is the word the grammar reads. */
|
|
37
|
+
export function withUnit(by, unit) {
|
|
38
|
+
const at = autoKeyOf(by);
|
|
39
|
+
if (!at)
|
|
40
|
+
return by;
|
|
41
|
+
return by
|
|
42
|
+
.split(',')
|
|
43
|
+
.map((key, index) => (index === at.index ? key.trim().replace(/^auto/i, unit) : key.trim()))
|
|
44
|
+
.join(', ');
|
|
45
|
+
}
|
|
46
|
+
/* ---------- the span ---------- */
|
|
47
|
+
const DAY = 86_400_000;
|
|
48
|
+
/**
|
|
49
|
+
* The days a section's query asks about on its `over` column — `created_at = last 90 days`, `this month` — or null
|
|
50
|
+
* where it sets no window the date grammar can bound (the data's own extent is then the span).
|
|
51
|
+
*/
|
|
52
|
+
export function spanDaysOf(query, over, now) {
|
|
53
|
+
const phrase = windowPhraseOf(query, over);
|
|
54
|
+
const window = phrase ? dateWindow(phrase, now) : undefined;
|
|
55
|
+
return window ? Math.max(1, Math.round((window.end.getTime() - window.start.getTime()) / DAY)) : null;
|
|
56
|
+
}
|
|
57
|
+
/** The phrase a query windows its `over` column by — `last 90 days` in `due_on = last 90 days` — or null. */
|
|
58
|
+
export function windowPhraseOf(query, over) {
|
|
59
|
+
if (!query || !over)
|
|
60
|
+
return null;
|
|
61
|
+
const escaped = over.replace(/[.$+]/g, '\\$&');
|
|
62
|
+
const found = new RegExp(`(?:^|[\\s(])${escaped}\\s*=\\s*(.+?)(?=\\s+(?:and|or)\\b|\\)|$)`, 'i').exec(query);
|
|
63
|
+
return found ? found[1].trim() : null;
|
|
64
|
+
}
|
|
65
|
+
/** The days between two dates the data holds, both ends counted. Null where either is not a date. */
|
|
66
|
+
export function spanDaysBetween(min, max) {
|
|
67
|
+
const from = dayNumber(String(min ?? '').slice(0, 10));
|
|
68
|
+
const to = dayNumber(String(max ?? '').slice(0, 10));
|
|
69
|
+
return from === null || to === null || to < from ? null : to - from + 1;
|
|
70
|
+
}
|
|
71
|
+
/** The unit a span of this many days is drawn in, before the data is looked at. */
|
|
72
|
+
export function unitForSpan(days) {
|
|
73
|
+
if (days <= 45)
|
|
74
|
+
return 'day';
|
|
75
|
+
if (days <= 26 * 7)
|
|
76
|
+
return 'week';
|
|
77
|
+
if (days <= 36 * 30.4375)
|
|
78
|
+
return 'month';
|
|
79
|
+
return 'quarter';
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The unit the read asks the server for. Where the measure adds up again, a day or a week is read as days and
|
|
83
|
+
* bucketed here: a week crosses a month's edge, so weeks read from the server could not be coarsened into months
|
|
84
|
+
* without handing a whole week to one of them. Months and quarters nest, so those are read as they are drawn.
|
|
85
|
+
*/
|
|
86
|
+
export function readUnit(base, addsUp) {
|
|
87
|
+
return addsUp && (base === 'day' || base === 'week') ? 'day' : base;
|
|
88
|
+
}
|
|
89
|
+
/* ---------- periods, by their labels ---------- */
|
|
90
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
91
|
+
function dayNumber(key) {
|
|
92
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(key);
|
|
93
|
+
return m ? Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])) / DAY : null;
|
|
94
|
+
}
|
|
95
|
+
const dayKey = (n) => {
|
|
96
|
+
const d = new Date(n * DAY);
|
|
97
|
+
return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())}`;
|
|
98
|
+
};
|
|
99
|
+
/** The label of the period a day, month or quarter label falls in, spelled as the server spells it. */
|
|
100
|
+
export function bucketKey(key, unit, weekStart = 1) {
|
|
101
|
+
if (unit === 'day')
|
|
102
|
+
return key;
|
|
103
|
+
if (unit === 'week') {
|
|
104
|
+
const n = dayNumber(key);
|
|
105
|
+
if (n === null)
|
|
106
|
+
return key;
|
|
107
|
+
/* ISO weekday 1..7; a day is that many days past its week's first. */
|
|
108
|
+
const weekday = ((new Date(n * DAY).getUTCDay() + 6) % 7) + 1;
|
|
109
|
+
return dayKey(n - ((weekday - weekStart + 7) % 7));
|
|
110
|
+
}
|
|
111
|
+
const month = Number(key.slice(5, 7));
|
|
112
|
+
if (unit === 'month')
|
|
113
|
+
return key.slice(0, 7);
|
|
114
|
+
return /Q[1-4]$/.test(key) ? key : `${key.slice(0, 4)}-Q${Math.ceil(month / 3)}`;
|
|
115
|
+
}
|
|
116
|
+
function nextKey(key, unit) {
|
|
117
|
+
if (unit === 'day' || unit === 'week')
|
|
118
|
+
return dayKey((dayNumber(key) ?? 0) + (unit === 'week' ? 7 : 1));
|
|
119
|
+
if (unit === 'month') {
|
|
120
|
+
const [y, m] = [Number(key.slice(0, 4)), Number(key.slice(5, 7))];
|
|
121
|
+
return m === 12 ? `${y + 1}-01` : `${y}-${pad(m + 1)}`;
|
|
122
|
+
}
|
|
123
|
+
const [y, q] = [Number(key.slice(0, 4)), Number(key.slice(6))];
|
|
124
|
+
return q === 4 ? `${y + 1}-Q1` : `${y}-Q${q + 1}`;
|
|
125
|
+
}
|
|
126
|
+
const SPELLED = {
|
|
127
|
+
day: /^\d{4}-\d{2}-\d{2}$/,
|
|
128
|
+
week: /^\d{4}-\d{2}-\d{2}$/,
|
|
129
|
+
month: /^\d{4}-\d{2}$/,
|
|
130
|
+
quarter: /^\d{4}-Q[1-4]$/,
|
|
131
|
+
};
|
|
132
|
+
/** The local calendar day of a date, as the server spells a day. */
|
|
133
|
+
const localDay = (d) => `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
|
|
134
|
+
/**
|
|
135
|
+
* A trend's points over its window: the periods that held no rows put back as zero, from the window's first period
|
|
136
|
+
* to today's, and the read periods added up into the unit the span is drawn in. A count of nothing is 0, and a line
|
|
137
|
+
* drawn through only the days that had rows said a quiet week was a steady one; three busy days of a week drew no
|
|
138
|
+
* line at all. Only a count or a sum adds up so: any other measure's points are drawn as read, and labels the read
|
|
139
|
+
* unit does not spell are left as they came.
|
|
140
|
+
*/
|
|
141
|
+
export function trendPoints(rows, read, unit, measure, window, now) {
|
|
142
|
+
if (!/^(count|sum\s+[\w.$+]+)(\s+as\s+[\w$]+)?$/i.test((measure ?? 'count').trim()))
|
|
143
|
+
return [...rows];
|
|
144
|
+
const keys = rows.map((row) => String(row.key ?? ''));
|
|
145
|
+
if (keys.some((key) => !SPELLED[read].test(key)))
|
|
146
|
+
return [...rows];
|
|
147
|
+
const ends = window ? [window.start, new Date(Math.min(window.end.getTime() - 1, now.getTime()))] : [];
|
|
148
|
+
const sorted = [...keys, ...ends.map((d) => bucketKey(localDay(d), read))].sort();
|
|
149
|
+
if (!sorted.length)
|
|
150
|
+
return [...rows];
|
|
151
|
+
const held = new Map(rows.map((row) => [String(row.key), Number(row.value) || 0]));
|
|
152
|
+
const into = new Map();
|
|
153
|
+
for (let key = sorted[0], n = 0; key <= sorted[sorted.length - 1] && n < 5000; key = nextKey(key, read), n++) {
|
|
154
|
+
const label = bucketKey(key, unit);
|
|
155
|
+
into.set(label, (into.get(label) ?? 0) + (held.get(key) ?? 0));
|
|
156
|
+
}
|
|
157
|
+
return [...into].map(([key, value]) => ({ key, value }));
|
|
158
|
+
}
|
|
159
|
+
/** How many periods of the unit run from the first label to the last, both ends counted. */
|
|
160
|
+
function periodsBetween(first, last, unit) {
|
|
161
|
+
let count = 1;
|
|
162
|
+
for (let key = first; key < last && count < 5000; key = nextKey(key, unit))
|
|
163
|
+
count++;
|
|
164
|
+
return count;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* The unit a chart is drawn in: the span's, stepped up while the data is sparse in it.
|
|
168
|
+
*
|
|
169
|
+
* `keys` are the labels of the buckets that hold data, as read (days, or months or quarters, per `readUnit`).
|
|
170
|
+
* `addsUp` is whether the measure can be re-aggregated; without it the span alone decides.
|
|
171
|
+
*/
|
|
172
|
+
export function chooseUnit({ spanDays, base: given, keys, addsUp, weekStart = 1, }) {
|
|
173
|
+
const base = given ?? unitForSpan(spanDays ?? 0);
|
|
174
|
+
if (!addsUp || !keys.length || base === 'quarter')
|
|
175
|
+
return { base, unit: base };
|
|
176
|
+
const at = (unit) => {
|
|
177
|
+
const labels = [...new Set(keys.map((k) => bucketKey(k, unit, weekStart)))].sort();
|
|
178
|
+
return { filled: labels.length, total: periodsBetween(labels[0], labels[labels.length - 1], unit) };
|
|
179
|
+
};
|
|
180
|
+
let unit = base;
|
|
181
|
+
for (;;) {
|
|
182
|
+
const here = at(unit);
|
|
183
|
+
if (here.filled / here.total >= DENSE)
|
|
184
|
+
break;
|
|
185
|
+
const next = AUTO_UNITS[AUTO_UNITS.indexOf(unit) + 1];
|
|
186
|
+
if (!next || at(next).total < FEWEST_BUCKETS)
|
|
187
|
+
break;
|
|
188
|
+
unit = next;
|
|
189
|
+
}
|
|
190
|
+
return { base, unit };
|
|
191
|
+
}
|
|
192
|
+
const TERM = /^(count|sum|avg|min|max)\s*([\w.$+]+)?$/i;
|
|
193
|
+
/**
|
|
194
|
+
* A measure as the aggregates it is made of, or null where it cannot be added up again: a median, a distinct
|
|
195
|
+
* count, a `when` count, or words this does not read. `avg x` is `sum x` over `count x`, which can.
|
|
196
|
+
*/
|
|
197
|
+
export function planMeasure(measure) {
|
|
198
|
+
const text = (measure ?? 'count').replace(/\s+as\s+[\w$]+\s*$/i, '').trim();
|
|
199
|
+
if (/\b(distinct|when|median)\b|[,[\]()]/i.test(text))
|
|
200
|
+
return null;
|
|
201
|
+
const parts = text.split(/\s+([+\-*/])\s+/);
|
|
202
|
+
const reads = [];
|
|
203
|
+
const combine = [];
|
|
204
|
+
const read = (aggregate, how) => {
|
|
205
|
+
const at = reads.indexOf(aggregate);
|
|
206
|
+
if (at >= 0)
|
|
207
|
+
return at;
|
|
208
|
+
reads.push(aggregate);
|
|
209
|
+
combine.push(how);
|
|
210
|
+
return reads.length - 1;
|
|
211
|
+
};
|
|
212
|
+
const operands = [];
|
|
213
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
214
|
+
const part = parts[i].trim();
|
|
215
|
+
if (/^\d+(?:\.\d+)?$/.test(part)) {
|
|
216
|
+
operands.push({ number: Number(part) });
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
const m = TERM.exec(part);
|
|
220
|
+
if (!m)
|
|
221
|
+
return null;
|
|
222
|
+
const fn = m[1].toLowerCase();
|
|
223
|
+
const column = m[2];
|
|
224
|
+
if (fn !== 'count' && !column)
|
|
225
|
+
return null;
|
|
226
|
+
if (fn === 'avg')
|
|
227
|
+
operands.push({ ratio: [read(`sum ${column}`, 'add'), read(`count ${column}`, 'add')] });
|
|
228
|
+
else
|
|
229
|
+
operands.push({ term: read(column ? `${fn} ${column}` : fn, fn === 'min' ? 'min' : fn === 'max' ? 'max' : 'add') });
|
|
230
|
+
}
|
|
231
|
+
const ops = parts.filter((_, i) => i % 2 === 1);
|
|
232
|
+
const value = (terms) => {
|
|
233
|
+
const values = operands.map((o) => {
|
|
234
|
+
if ('number' in o)
|
|
235
|
+
return o.number;
|
|
236
|
+
if ('term' in o)
|
|
237
|
+
return terms[o.term];
|
|
238
|
+
const [sum, count] = [terms[o.ratio[0]], terms[o.ratio[1]]];
|
|
239
|
+
return sum === null || !count ? null : sum / count;
|
|
240
|
+
});
|
|
241
|
+
/* SQL's precedence: `*` and `/` bind first; a division by zero is null, as the server's is. */
|
|
242
|
+
const sums = [values[0]];
|
|
243
|
+
const signs = [];
|
|
244
|
+
for (const [i, op] of ops.entries()) {
|
|
245
|
+
const right = values[i + 1];
|
|
246
|
+
const left = sums[sums.length - 1];
|
|
247
|
+
if (op === '*' || op === '/') {
|
|
248
|
+
sums[sums.length - 1] =
|
|
249
|
+
left === null || right === null || (op === '/' && right === 0) ? null : op === '*' ? left * right : left / right;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
sums.push(right);
|
|
253
|
+
signs.push(op);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
return sums.reduce((acc, v, i) => {
|
|
257
|
+
if (i === 0)
|
|
258
|
+
return v;
|
|
259
|
+
return acc === null || v === null ? null : signs[i - 1] === '+' ? acc + v : acc - v;
|
|
260
|
+
}, sums[0] === undefined ? null : sums[0]);
|
|
261
|
+
};
|
|
262
|
+
return { reads, combine, value };
|
|
263
|
+
}
|
|
264
|
+
/** The read buckets cut into the chosen unit, each aggregate added up (or min'd, or max'd) across the ones it takes in. */
|
|
265
|
+
export function coarsen(buckets, plan, unit, weekStart = 1) {
|
|
266
|
+
/* A chart over a second key (a line or a stack per value) is coarsened per value: a cross is the period and the series. */
|
|
267
|
+
const into = new Map();
|
|
268
|
+
const SPLIT = '\u0000';
|
|
269
|
+
for (const bucket of buckets) {
|
|
270
|
+
const key = `${bucketKey(bucket.key, unit, weekStart)}${bucket.series === undefined ? '' : SPLIT + bucket.series}`;
|
|
271
|
+
const held = into.get(key);
|
|
272
|
+
if (!held) {
|
|
273
|
+
into.set(key, [...bucket.terms]);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
plan.combine.forEach((how, i) => {
|
|
277
|
+
const [a, b] = [held[i], bucket.terms[i]];
|
|
278
|
+
held[i] = a === null ? b : b === null ? a : how === 'add' ? a + b : how === 'min' ? Math.min(a, b) : Math.max(a, b);
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
return [...into.entries()]
|
|
282
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
283
|
+
.flatMap(([joined, terms]) => {
|
|
284
|
+
const value = plan.value(terms);
|
|
285
|
+
const [key, series] = joined.split(SPLIT);
|
|
286
|
+
return value === null || !Number.isFinite(value) ? [] : [{ key, ...(series === undefined ? {} : { series }), value }];
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
/* ---------- what a section asks, for the check ---------- */
|
|
290
|
+
/** The most days a window may span before a fixed `day` chart over it is worth a word. */
|
|
291
|
+
export const DAY_BARS_ADVISED = 90;
|
|
292
|
+
/**
|
|
293
|
+
* The days a dashboard window phrase covers, as it would be said ("last 12 months" is 365): the nominal length of a
|
|
294
|
+
* `last N unit`, else the dates the phrase resolves to, or null where it is not one the date grammar bounds. (A
|
|
295
|
+
* resolved `last N` runs to tomorrow, a day more than it is called, which a count of bars should not repeat.)
|
|
296
|
+
*/
|
|
297
|
+
export function windowDays(phrase, now) {
|
|
298
|
+
const last = /^last\s+(\d+)\s+(day|week|month|year)s?$/i.exec(phrase.trim());
|
|
299
|
+
if (last)
|
|
300
|
+
return Math.round(Number(last[1]) * { day: 1, week: 7, month: 365 / 12, year: 365 }[last[2].toLowerCase()]);
|
|
301
|
+
const window = dateWindow(phrase, now);
|
|
302
|
+
return window ? Math.round((window.end.getTime() - window.start.getTime()) / DAY) : null;
|
|
303
|
+
}
|
|
304
|
+
/** Whether a chart's `by` cuts days: `day created_at`, in any position. */
|
|
305
|
+
export const cutsDays = (by) => (by ?? '').split(',').some((key) => /^day\s+[\w.$+]+/i.test(key.trim()));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The values a form or a fixed action fills in rather than states: the day
|
|
3
|
+
* (`today`), the moment (`now`) and the signed-in person (`me`). They are
|
|
4
|
+
* written as the constants `@mistriwork/mistri/app` exports — `defaults: { due_on:
|
|
5
|
+
* today, owner_id: me }`, `set: { resolved_at: now }` — which are
|
|
6
|
+
* `{ auto: 'today' }` and so on in JSON, so a word can never be read out of
|
|
7
|
+
* a literal: a status of "now" is not the moment, and a text column's "me"
|
|
8
|
+
* is not an email.
|
|
9
|
+
*
|
|
10
|
+
* The model carries the word, as it always has (formDefaults.ts in the
|
|
11
|
+
* client, appStamps.ts on the server read it), so the word itself is
|
|
12
|
+
* reserved there: a literal that spells one is refused here, since past
|
|
13
|
+
* this point it would be read as the value filled in.
|
|
14
|
+
*/
|
|
15
|
+
type AutoWord = 'today' | 'now' | 'me';
|
|
16
|
+
/**
|
|
17
|
+
* An authored default or `set` value, as the model carries it: a filled-in
|
|
18
|
+
* value becomes its word, and a literal passes through. `words` are the ones
|
|
19
|
+
* this place fills in — a fixed action writes `now` and `me`, a form also
|
|
20
|
+
* `today`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function authoredValue(value: unknown, at: string, words?: readonly AutoWord[]): unknown;
|
|
23
|
+
/** The authored spelling of a model value: its word back as `{ auto }`, any other value as itself. */
|
|
24
|
+
export declare function authoredSpelling(value: unknown, words?: readonly AutoWord[]): unknown;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const AUTO_WORDS = ['today', 'now', 'me'];
|
|
2
|
+
const said = (word) => `${word} ({ auto: '${word}' })`;
|
|
3
|
+
/**
|
|
4
|
+
* An authored default or `set` value, as the model carries it: a filled-in
|
|
5
|
+
* value becomes its word, and a literal passes through. `words` are the ones
|
|
6
|
+
* this place fills in — a fixed action writes `now` and `me`, a form also
|
|
7
|
+
* `today`.
|
|
8
|
+
*/
|
|
9
|
+
export function authoredValue(value, at, words = AUTO_WORDS) {
|
|
10
|
+
if (value && typeof value === 'object' && !Array.isArray(value) && Object.hasOwn(value, 'auto')) {
|
|
11
|
+
const auto = value.auto;
|
|
12
|
+
if (Object.keys(value).length !== 1 || typeof auto !== 'string' || !words.includes(auto)) {
|
|
13
|
+
throw new Error(`${at} fills in ${JSON.stringify(auto)}; this place fills in ${words.map(said).join(', ')}.`);
|
|
14
|
+
}
|
|
15
|
+
return auto;
|
|
16
|
+
}
|
|
17
|
+
if (typeof value === 'string' && AUTO_WORDS.includes(value)) {
|
|
18
|
+
throw new Error(`${at} is the text '${value}', which reads as the value filled in: write the constant ${said(value)}, or another literal.`);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
/** The authored spelling of a model value: its word back as `{ auto }`, any other value as itself. */
|
|
23
|
+
export function authoredSpelling(value, words = AUTO_WORDS) {
|
|
24
|
+
return typeof value === 'string' && words.includes(value) ? { auto: value } : value;
|
|
25
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counting things by something: GROUP BY, as a shape rather than as text.
|
|
3
|
+
*
|
|
4
|
+
* This was the last real hole in the query language. "How many invoices per
|
|
5
|
+
* month", "which countries have the most customers", "what does each status
|
|
6
|
+
* add up to" are the questions anybody asks of a database in the first ten
|
|
7
|
+
* minutes, and until now the only way to ask them here was to drop into `sql`
|
|
8
|
+
* — which means an agent leaves the checked path exactly where the question
|
|
9
|
+
* gets interesting, and a person leaves the tool.
|
|
10
|
+
*
|
|
11
|
+
* A breakdown is deliberately *not* a view with a `groupBy` bolted on. A view
|
|
12
|
+
* promises one row per base record, and every part of it — the correlated
|
|
13
|
+
* aggregates, the LEFT JOIN rule, the row-click that opens a record — leans on
|
|
14
|
+
* that promise. Grouping breaks it: the rows that come back are not records
|
|
15
|
+
* and cannot be opened, and a column that is neither a key nor an aggregate is
|
|
16
|
+
* a bug on two engines and a silent wrong answer on the third. So it is a
|
|
17
|
+
* sibling type with its own compiler, sharing the parts that are genuinely the
|
|
18
|
+
* same: path resolution, the join planner, and `buildWhere`.
|
|
19
|
+
*
|
|
20
|
+
* invoice count by status
|
|
21
|
+
* invoice sum total by month invoice_date
|
|
22
|
+
* invoice count, avg total by customer_id.country_code.name sort count desc
|
|
23
|
+
*
|
|
24
|
+
* Two rules the shape enforces, both of which SQL leaves to the author:
|
|
25
|
+
*
|
|
26
|
+
* - **Every selected expression is a key or a measure.** There is nowhere to
|
|
27
|
+
* put a third thing, so `SELECT status, name, COUNT(*) … GROUP BY status`
|
|
28
|
+
* — which a lenient engine would answer with an arbitrary `name` — cannot be
|
|
29
|
+
* written.
|
|
30
|
+
* - **The result is bounded like every other read.** A breakdown over a
|
|
31
|
+
* high-cardinality column is a million-row answer, and `sort count desc
|
|
32
|
+
* limit 20` is what somebody meant anyway.
|
|
33
|
+
*/
|
|
34
|
+
import { type DateUnit, type SqlStyle } from './filter.js';
|
|
35
|
+
import { type DatabaseSchema, type ForeignKey } from './schema.js';
|
|
36
|
+
import { type ViewFilter } from './view.js';
|
|
37
|
+
import { type RowScope } from './rowScope.js';
|
|
38
|
+
import { type ViewDef } from './viewPaths.js';
|
|
39
|
+
import type { ComputedPath } from './rollups.js';
|
|
40
|
+
/** What a measure can do. `count` is the only one that needs no column. `median` is PostgreSQL's
|
|
41
|
+
`percentile_cont(0.5)`: SQLite has no median aggregate, so it is refused there. */
|
|
42
|
+
export type MeasureFn = 'count' | 'sum' | 'avg' | 'min' | 'max' | 'median';
|
|
43
|
+
export declare const MEASURE_FUNCTIONS: MeasureFn[];
|
|
44
|
+
/** The arithmetic a computed measure joins its terms with. SQL's precedence: `*` and `/` before `+` and `-`. */
|
|
45
|
+
export type MeasureOp = '+' | '-' | '*' | '/';
|
|
46
|
+
export declare const MEASURE_OPS: readonly MeasureOp[];
|
|
47
|
+
/** Why a dialect cannot answer a measure function, or undefined when it can. */
|
|
48
|
+
export declare function measureRefusal(fn: MeasureFn, dialect: string | undefined): string | undefined;
|
|
49
|
+
/** The periods a date key can be cut into. */
|
|
50
|
+
export declare const DATE_UNITS: DateUnit[];
|
|
51
|
+
/**
|
|
52
|
+
* One thing to group by: a path, optionally cut down to a period.
|
|
53
|
+
*
|
|
54
|
+
* The path is a reference path like a view's, so "customers by country name"
|
|
55
|
+
* is `customer … by country_code.name` and needs no join written by hand.
|
|
56
|
+
*/
|
|
57
|
+
export interface BreakdownKey {
|
|
58
|
+
path: string;
|
|
59
|
+
/** Cut a date or timestamp down to a period. Refused on anything else. */
|
|
60
|
+
bucket?: DateUnit;
|
|
61
|
+
alias?: string;
|
|
62
|
+
}
|
|
63
|
+
/** One aggregate: a function and the column it reads. */
|
|
64
|
+
export interface MeasureTerm {
|
|
65
|
+
fn: MeasureFn;
|
|
66
|
+
/** The column to measure. Absent means `COUNT(*)`, and is only valid there. */
|
|
67
|
+
path?: string;
|
|
68
|
+
/** COUNT DISTINCT. Meaningless on the others and refused there. */
|
|
69
|
+
distinct?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* `count when [status = open]`: only the rows that hold these conditions are counted, in the same statement as the
|
|
72
|
+
* other measures (`COUNT(CASE WHEN … THEN 1 END)`), so a funnel's stages are one snapshot and can never disagree.
|
|
73
|
+
* Only a bare `count` takes it. `when` is the conditions as written; `where` is what they parsed to, which is what
|
|
74
|
+
* runs: the parser fills it, and a request's own is held to the same shape a filter is (resourceReadOperations.ts).
|
|
75
|
+
*/
|
|
76
|
+
when?: string;
|
|
77
|
+
where?: ViewFilter;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A measure: one aggregate, or a computed measure — aggregates and numbers
|
|
81
|
+
* joined by arithmetic, `sum paid / sum total`, `sum total - sum cost`. A
|
|
82
|
+
* ratio is the `/` case, not a function of its own. A division never
|
|
83
|
+
* truncates and never fails: its divisor is read as a decimal and a zero
|
|
84
|
+
* one answers null.
|
|
85
|
+
*/
|
|
86
|
+
export interface Measure extends MeasureTerm {
|
|
87
|
+
alias?: string;
|
|
88
|
+
/** The terms after the first, each with the operator before it. */
|
|
89
|
+
steps?: {
|
|
90
|
+
op: MeasureOp;
|
|
91
|
+
term: MeasureTerm | number;
|
|
92
|
+
}[];
|
|
93
|
+
}
|
|
94
|
+
/** A measure as it is written: `sum paid / sum total as rate`. */
|
|
95
|
+
export declare function measureToText(m: Measure): string;
|
|
96
|
+
/** The name a measure answers under when it has no alias: `sum(total)`, `sum(paid) / sum(total)`. */
|
|
97
|
+
export declare function measureName(m: Measure, path?: string | undefined): string;
|
|
98
|
+
/** Every column a measure reads. */
|
|
99
|
+
export declare function measurePaths(m: Measure): string[];
|
|
100
|
+
/** Every `when` among a breakdown's measures, in order: what a reader's grants and the stitched-read check must also hold. */
|
|
101
|
+
export declare const measureConditions: (measures: readonly Measure[] | undefined) => ViewFilter[];
|
|
102
|
+
/** The paths a filter's conditions walk, and the paths they compare against. */
|
|
103
|
+
export declare const filterPaths: (filter: ViewFilter | undefined) => string[];
|
|
104
|
+
export interface BreakdownOrder {
|
|
105
|
+
/** A key's or a measure's output name. Breakdowns sort by what they show. */
|
|
106
|
+
name: string;
|
|
107
|
+
direction: 'asc' | 'desc';
|
|
108
|
+
/** On a key: this entry only moves the empty group (a null key) after every other, whatever the entries after it
|
|
109
|
+
say; it orders nothing else, so `direction` is not read. The groups of a grouped list use it to draw "No sprint"
|
|
110
|
+
last under any sort — done in the query because the groups are paged, so no page could place it by itself. */
|
|
111
|
+
emptyLast?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export interface BreakdownDef {
|
|
114
|
+
base: string;
|
|
115
|
+
by: BreakdownKey[];
|
|
116
|
+
/** `table.column` of text columns an App declares dates (declaredDates.ts), which this catalog reads as TEXT:
|
|
117
|
+
a period bucket over one is allowed. Carried by the App's resource facade, never taken from a request. */
|
|
118
|
+
dateColumns?: string[];
|
|
119
|
+
measures: Measure[];
|
|
120
|
+
filter?: ViewFilter;
|
|
121
|
+
orderBy?: BreakdownOrder[];
|
|
122
|
+
limit?: number;
|
|
123
|
+
/** The breakdown written down, when it came from text. */
|
|
124
|
+
text?: string;
|
|
125
|
+
/** The ISO weekday a `week` bucket's weeks start on, 1 (Monday) to 7 (Sunday); Monday when unsaid. An App's
|
|
126
|
+
server sets it from `ui.locale` (weekStart.ts), whatever a request carried. */
|
|
127
|
+
weekStart?: number;
|
|
128
|
+
/**
|
|
129
|
+
* The rollups its paths name (rollups.ts), by path — a measure `sum
|
|
130
|
+
* on_hand`, a key, a condition. Filled by the server from the App's
|
|
131
|
+
* catalog (withBreakdownComputed), never taken from a request, and read
|
|
132
|
+
* by the compiler where the adapter's catalog does not carry them.
|
|
133
|
+
*/
|
|
134
|
+
computed?: Record<string, ComputedPath>;
|
|
135
|
+
/** The computed columns its paths name (computed.ts), pinned the same way. */
|
|
136
|
+
expressions?: ViewDef['expressions'];
|
|
137
|
+
/** The record tags its conditions ask (`tags has vpn`, tagLists.ts), pinned the same way: a filter rail's
|
|
138
|
+
counts under a tags filter ask them where the adapter's catalog has no tags. */
|
|
139
|
+
tagged?: ViewDef['tagged'];
|
|
140
|
+
/** The App's declared references it may walk, as a view carries them (ViewDef.references); never a request's. */
|
|
141
|
+
references?: ForeignKey[];
|
|
142
|
+
/**
|
|
143
|
+
* The keys that are references, each with the path of the name of the
|
|
144
|
+
* record it points at (`customer_id` → `customer_id.name`): a group of
|
|
145
|
+
* `customer_id` is a customer, and is said by the customer's name, as a
|
|
146
|
+
* grid's cell says it. Each such key answers that name in a `label` column
|
|
147
|
+
* after the measures. Filled by the server from the catalog
|
|
148
|
+
* (withBreakdownComputed), never taken from a request, as are `labels`,
|
|
149
|
+
* the record-name templates a `$label` name needs (a view's `labels`).
|
|
150
|
+
*/
|
|
151
|
+
names?: Record<string, string>;
|
|
152
|
+
labels?: Record<string, string>;
|
|
153
|
+
}
|
|
154
|
+
export interface CompiledMeasure {
|
|
155
|
+
name: string;
|
|
156
|
+
/** A key, a measure, or a key's record name (`of` names the key). */
|
|
157
|
+
kind: 'key' | 'measure' | 'label';
|
|
158
|
+
of?: string;
|
|
159
|
+
fn?: MeasureFn;
|
|
160
|
+
/** The path this came from, for the interface to label it with. */
|
|
161
|
+
path?: string;
|
|
162
|
+
/** What the values are, as far as the schema knows. */
|
|
163
|
+
type: string;
|
|
164
|
+
bucket?: DateUnit;
|
|
165
|
+
}
|
|
166
|
+
interface CompiledBreakdown {
|
|
167
|
+
text: string;
|
|
168
|
+
params: unknown[];
|
|
169
|
+
columns: CompiledMeasure[];
|
|
170
|
+
limit: number;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Compile a breakdown to one parameterised SELECT.
|
|
174
|
+
*
|
|
175
|
+
* The order of work matches `compileView`'s and for the same reason: keys,
|
|
176
|
+
* then measures, then the filter, then the sort — so aliases are handed out in
|
|
177
|
+
* first-use order and the same breakdown always compiles to the same text.
|
|
178
|
+
*/
|
|
179
|
+
export declare function compileBreakdown(schema: DatabaseSchema, def: BreakdownDef, style: SqlStyle, offset?: number | unknown, scope?: RowScope): CompiledBreakdown;
|
|
180
|
+
/** Who says a catalog cannot change, beside the scope catalog's own captures. */
|
|
181
|
+
export declare function keepBreakdownsAgainst(fixed: (schema: DatabaseSchema) => boolean): void;
|
|
182
|
+
/** For tests: how many breakdowns were compiled rather than found. */
|
|
183
|
+
export declare function breakdownsCompiledSoFar(): number;
|
|
184
|
+
/**
|
|
185
|
+
* The breakdown with the rollups its paths name, read from a catalog that
|
|
186
|
+
* serves them (an App's) — and with any it arrived with dropped, as
|
|
187
|
+
* withViewComputed does for a view: which rows a number sums is the
|
|
188
|
+
* catalog's to say, never a request's.
|
|
189
|
+
*/
|
|
190
|
+
export declare function withBreakdownComputed(schema: DatabaseSchema, def: BreakdownDef): BreakdownDef;
|
|
191
|
+
/**
|
|
192
|
+
* How many groups there are, ignoring the page.
|
|
193
|
+
*
|
|
194
|
+
* `SELECT COUNT(*) FROM (the grouped statement)` — the only honest way to
|
|
195
|
+
* count groups, because the number is a property of the grouping rather than
|
|
196
|
+
* of the base table. Without the limit and offset, which is the whole point of
|
|
197
|
+
* asking.
|
|
198
|
+
*/
|
|
199
|
+
export declare function compileBreakdownCount(schema: DatabaseSchema, def: BreakdownDef, style: SqlStyle, scope?: RowScope, limit?: number): {
|
|
200
|
+
text: string;
|
|
201
|
+
params: unknown[];
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* Render a breakdown as the SQL it will become, values inline.
|
|
205
|
+
*
|
|
206
|
+
* The exact counterpart of `explainView`, and here for the same reason: the
|
|
207
|
+
* SQL pane is how somebody learns what a line of the language did on their
|
|
208
|
+
* behalf, and a statement full of `?` teaches nothing about the filter that
|
|
209
|
+
* produced it. It also has to be a statement that runs, because the pane
|
|
210
|
+
* offers to open it in the SQL editor.
|
|
211
|
+
*/
|
|
212
|
+
export declare function explainBreakdown(schema: DatabaseSchema, def: BreakdownDef, style: SqlStyle, offset?: number | unknown): string;
|
|
213
|
+
/** A breakdown's groups said by name: key column → the key's value as text → the record's name. */
|
|
214
|
+
export type GroupNames = Record<string, Record<string, string>>;
|
|
215
|
+
/**
|
|
216
|
+
* The answer as its readers take it — the keys first and the measures after,
|
|
217
|
+
* by position — with each reference key's names (compileBreakdown's `label`
|
|
218
|
+
* columns) lifted out beside it: a chart reads its key and measure by index,
|
|
219
|
+
* a board its count last, and a name among them would be read as either.
|
|
220
|
+
*/
|
|
221
|
+
export declare function withGroupNames<R extends {
|
|
222
|
+
columns: string[];
|
|
223
|
+
rows: Record<string, unknown>[];
|
|
224
|
+
resolved: CompiledMeasure[];
|
|
225
|
+
}>(result: R): R & {
|
|
226
|
+
names?: GroupNames;
|
|
227
|
+
};
|
|
228
|
+
export {};
|