@mistriwork/engine 0.0.0 → 1.0.0-rc.11
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 +16 -1
- package/dist/adapters/adapter.d.ts +726 -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 +441 -0
- package/dist/adapters/postgres.js +1841 -0
- package/dist/adapters/postgresCatalog.d.ts +107 -0
- package/dist/adapters/postgresCatalog.js +421 -0
- package/dist/adapters/postgresCatalogDigest.d.ts +30 -0
- package/dist/adapters/postgresCatalogDigest.js +93 -0
- package/dist/adapters/postgresCatalogRows.d.ts +64 -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/postgresWriteAhead.d.ts +47 -0
- package/dist/adapters/postgresWriteAhead.js +209 -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 +179 -0
- package/dist/adapters/scoped/keyTypes.d.ts +34 -0
- package/dist/adapters/scoped/keyTypes.js +66 -0
- package/dist/adapters/scoped/postgresScopeCatalog.d.ts +34 -0
- package/dist/adapters/scoped/postgresScopeCatalog.js +457 -0
- package/dist/adapters/scoped/postgresTriggers.d.ts +137 -0
- package/dist/adapters/scoped/postgresTriggers.js +1545 -0
- package/dist/adapters/scoped/scopeTriggers.d.ts +122 -0
- package/dist/adapters/scoped/scopeTriggers.js +131 -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 +22 -0
- package/dist/adapters/scoped/scopedReads.js +192 -0
- package/dist/adapters/scoped/scopedTransaction.d.ts +159 -0
- package/dist/adapters/scoped/scopedTransaction.js +547 -0
- package/dist/adapters/scoped/sqliteScopeCatalog.d.ts +32 -0
- package/dist/adapters/scoped/sqliteScopeCatalog.js +420 -0
- package/dist/adapters/scoped/sqliteTriggerSession.d.ts +64 -0
- package/dist/adapters/scoped/sqliteTriggerSession.js +245 -0
- package/dist/adapters/scoped/sqliteTriggers.d.ts +20 -0
- package/dist/adapters/scoped/sqliteTriggers.js +822 -0
- package/dist/adapters/scoped/storedText.d.ts +45 -0
- package/dist/adapters/scoped/storedText.js +61 -0
- package/dist/adapters/scoped/triggerEffects.d.ts +98 -0
- package/dist/adapters/scoped/triggerEffects.js +189 -0
- package/dist/adapters/scoped/triggerProof.d.ts +124 -0
- package/dist/adapters/scoped/triggerProof.js +366 -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/snapshotRead.d.ts +8 -0
- package/dist/adapters/snapshotRead.js +37 -0
- package/dist/adapters/sqlite.d.ts +273 -0
- package/dist/adapters/sqlite.js +1557 -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 +51 -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 +133 -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 +80 -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 +182 -0
- package/dist/server/cli/args.js +348 -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 +106 -0
- package/dist/server/columnGrants.js +741 -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/config/profile.d.ts +123 -0
- package/dist/server/config/profile.js +236 -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 +358 -0
- package/dist/server/connections.js +988 -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 +244 -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 +75 -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 +102 -0
- package/dist/server/migrate/cli.js +702 -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 +413 -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 +115 -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/aggregate.d.ts +49 -0
- package/dist/shared/aggregate.js +107 -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 +570 -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/decimals.d.ts +37 -0
- package/dist/shared/decimals.js +148 -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 +543 -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 +238 -0
- package/dist/shared/filter.js +332 -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 +53 -0
- package/dist/shared/money.js +98 -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 +80 -0
- package/dist/shared/refusal.js +184 -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 +529 -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 +472 -0
- package/dist/shared/servedApp.d.ts +686 -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 +266 -3
- package/schema/model.d.ts +298 -0
- package/schema/theme.d.ts +587 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keys whose text a reader reads: a caption, wherever the definition holds
|
|
3
|
+
* one. Every one takes `msg()` (packages/mistri/schema/app.d.ts, held by test/app-messages.test.ts),
|
|
4
|
+
* said by the loader however deep it sits, and `mistri messages extract`
|
|
5
|
+
* lists those still written as literal text. `text` is a caption except where
|
|
6
|
+
* it names a column: `ui.messages`' `fields`, a composer's `templates`.
|
|
7
|
+
*/
|
|
8
|
+
export const CAPTION_KEYS = new Set([
|
|
9
|
+
'label',
|
|
10
|
+
'title',
|
|
11
|
+
'tab',
|
|
12
|
+
'description',
|
|
13
|
+
'heading',
|
|
14
|
+
'tagline',
|
|
15
|
+
'subtitle',
|
|
16
|
+
'placeholder',
|
|
17
|
+
'empty',
|
|
18
|
+
'hint',
|
|
19
|
+
'help',
|
|
20
|
+
'submitLabel',
|
|
21
|
+
'lead',
|
|
22
|
+
'next',
|
|
23
|
+
'skip',
|
|
24
|
+
'question',
|
|
25
|
+
'answer',
|
|
26
|
+
'text',
|
|
27
|
+
'noun',
|
|
28
|
+
'unit',
|
|
29
|
+
'total',
|
|
30
|
+
'eyebrow',
|
|
31
|
+
'alt',
|
|
32
|
+
'message',
|
|
33
|
+
'note',
|
|
34
|
+
'before',
|
|
35
|
+
'after',
|
|
36
|
+
]);
|
|
37
|
+
/** Whether the value under `key`, in an object found under `parent`, is a caption. */
|
|
38
|
+
export const isCaptionKey = (key, parent) => CAPTION_KEYS.has(key) && !(key === 'text' && (parent === 'fields' || parent === 'templates'));
|
|
39
|
+
/** A message's key: dotted words, `lead.title`, `people.payRate`. */
|
|
40
|
+
export const MESSAGE_KEY = /^[A-Za-z][A-Za-z0-9_-]*(?:\.[A-Za-z][A-Za-z0-9_-]*)+$/;
|
|
41
|
+
/** An ICU argument's name: no dot, so a path is bound explicitly. */
|
|
42
|
+
const MESSAGE_ARG = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
43
|
+
const MESSAGE_PATH = /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
44
|
+
/** The arguments the framework supplies itself: a count, a flow notify step's words, a transition's state. */
|
|
45
|
+
export const FRAMEWORK_ARGS = ['count', 'message', 'to'];
|
|
46
|
+
const plain = (value) => Boolean(value) &&
|
|
47
|
+
typeof value === 'object' &&
|
|
48
|
+
!Array.isArray(value) &&
|
|
49
|
+
[Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
50
|
+
/**
|
|
51
|
+
* Whether a value is what `msg()` made: `{ message }` with a key, and `args`
|
|
52
|
+
* of names bound to paths. Nothing else in a definition has that shape — a
|
|
53
|
+
* text rule's or a form's `message` is a sentence, which is never a dotted key
|
|
54
|
+
* alone in its object.
|
|
55
|
+
*/
|
|
56
|
+
export function isMessageRef(raw) {
|
|
57
|
+
if (!plain(raw) || typeof raw.message !== 'string' || !MESSAGE_KEY.test(raw.message))
|
|
58
|
+
return false;
|
|
59
|
+
const keys = Object.keys(raw);
|
|
60
|
+
if (keys.some((key) => key !== 'message' && key !== 'args'))
|
|
61
|
+
return false;
|
|
62
|
+
if (raw.args === undefined)
|
|
63
|
+
return true;
|
|
64
|
+
return (plain(raw.args) &&
|
|
65
|
+
Object.entries(raw.args).every(([name, path]) => MESSAGE_ARG.test(name) && typeof path === 'string' && MESSAGE_PATH.test(path)));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A caption as a parser reads it: text, trimmed. The loader has said every
|
|
69
|
+
* `msg()` by now (localizeDefinition); one that reaches a parser was given to
|
|
70
|
+
* it directly, with no catalog to say it from.
|
|
71
|
+
*/
|
|
72
|
+
export function parseCaption(raw, at) {
|
|
73
|
+
if (isMessageRef(raw))
|
|
74
|
+
throw new Error(`[message-missing] ${at}: msg('${raw.message}') is said from the App's messages/ catalogs, which only a loaded App has.`);
|
|
75
|
+
if (typeof raw !== 'string' || !raw.trim())
|
|
76
|
+
throw new Error(`Invalid caption at ${at}: it must be non-empty text.`);
|
|
77
|
+
return raw.trim();
|
|
78
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a record is called: the resource's `noun` (appModel.ts), said the way
|
|
3
|
+
* each place needs it — New mid-sentence ("New issue"), a split's detail and
|
|
4
|
+
* a page as a heading ("Issue"), a list that names nothing as several
|
|
5
|
+
* ("Issues"). One rule, read by the parsers and the client alike, so a word an
|
|
6
|
+
* author wrote once is never guessed back out of a label.
|
|
7
|
+
*/
|
|
8
|
+
import { type AppNoun } from './model.js';
|
|
9
|
+
/** The regular plural of a noun an author wrote: "issue" → "issues", "category" → "categories",
|
|
10
|
+
"address" → "addresses". One no rule makes is written out as `{ one, many }`. */
|
|
11
|
+
export declare function pluralOf(one: string): string;
|
|
12
|
+
/** A noun where a heading starts with it: "issue" → "Issue"; "API key" stays. */
|
|
13
|
+
export declare const headingOf: (noun: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* One record's word, mid-sentence: the resource's `noun`, else its table's
|
|
16
|
+
* name as a person says it ("work_order" → "work order"). Never a list's
|
|
17
|
+
* label, which may name a layout ("Task calendar") or a workspace ("Inbox"),
|
|
18
|
+
* and never singularised by rule: a table named in the plural keeps its name
|
|
19
|
+
* until the resource says its noun.
|
|
20
|
+
*/
|
|
21
|
+
export declare function recordNoun(noun: AppNoun | undefined, tableName: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a record is called: the resource's `noun` (appModel.ts), said the way
|
|
3
|
+
* each place needs it — New mid-sentence ("New issue"), a split's detail and
|
|
4
|
+
* a page as a heading ("Issue"), a list that names nothing as several
|
|
5
|
+
* ("Issues"). One rule, read by the parsers and the client alike, so a word an
|
|
6
|
+
* author wrote once is never guessed back out of a label.
|
|
7
|
+
*/
|
|
8
|
+
import { humanName } from './model.js';
|
|
9
|
+
/** The regular plural of a noun an author wrote: "issue" → "issues", "category" → "categories",
|
|
10
|
+
"address" → "addresses". One no rule makes is written out as `{ one, many }`. */
|
|
11
|
+
export function pluralOf(one) {
|
|
12
|
+
if (/[^aeiou]y$/i.test(one))
|
|
13
|
+
return `${one.slice(0, -1)}ies`;
|
|
14
|
+
if (/(s|x|z|ch|sh)$/i.test(one))
|
|
15
|
+
return `${one}es`;
|
|
16
|
+
return `${one}s`;
|
|
17
|
+
}
|
|
18
|
+
/** A noun where a heading starts with it: "issue" → "Issue"; "API key" stays. */
|
|
19
|
+
export const headingOf = (noun) => noun.charAt(0).toUpperCase() + noun.slice(1);
|
|
20
|
+
/**
|
|
21
|
+
* One record's word, mid-sentence: the resource's `noun`, else its table's
|
|
22
|
+
* name as a person says it ("work_order" → "work order"). Never a list's
|
|
23
|
+
* label, which may name a layout ("Task calendar") or a workspace ("Inbox"),
|
|
24
|
+
* and never singularised by rule: a table named in the plural keeps its name
|
|
25
|
+
* until the resource says its noun.
|
|
26
|
+
*/
|
|
27
|
+
export function recordNoun(noun, tableName) {
|
|
28
|
+
if (noun)
|
|
29
|
+
return noun.one;
|
|
30
|
+
const said = humanName(tableName) || tableName;
|
|
31
|
+
return /^[A-Z][a-z]/.test(said) ? said.charAt(0).toLowerCase() + said.slice(1) : said;
|
|
32
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export type AutoUnit = 'day' | 'week' | 'month' | 'quarter';
|
|
2
|
+
/** The key of a `by` written `auto <column>`, wherever it stands in the list: its place and its column. */
|
|
3
|
+
export declare function autoKeyOf(by: string | undefined): {
|
|
4
|
+
index: number;
|
|
5
|
+
column: string;
|
|
6
|
+
} | null;
|
|
7
|
+
/** The `by` with its `auto` key written as the unit the chart chose, which is the word the grammar reads. */
|
|
8
|
+
export declare function withUnit(by: string, unit: AutoUnit): string;
|
|
9
|
+
/**
|
|
10
|
+
* The days a section's query asks about on its `over` column — `created_at = last 90 days`, `this month` — or null
|
|
11
|
+
* where it sets no window the date grammar can bound (the data's own extent is then the span).
|
|
12
|
+
*/
|
|
13
|
+
export declare function spanDaysOf(query: string | undefined, over: string | undefined, now: Date): number | null;
|
|
14
|
+
/** The phrase a query windows its `over` column by — `last 90 days` in `due_on = last 90 days` — or null. */
|
|
15
|
+
export declare function windowPhraseOf(query: string | undefined, over: string | undefined): string | null;
|
|
16
|
+
/** The days between two dates the data holds, both ends counted. Null where either is not a date. */
|
|
17
|
+
export declare function spanDaysBetween(min: unknown, max: unknown): number | null;
|
|
18
|
+
/** The unit a span of this many days is drawn in, before the data is looked at. */
|
|
19
|
+
export declare function unitForSpan(days: number): AutoUnit;
|
|
20
|
+
/**
|
|
21
|
+
* The unit the read asks the server for. Where the measure adds up again, a day or a week is read as days and
|
|
22
|
+
* bucketed here: a week crosses a month's edge, so weeks read from the server could not be coarsened into months
|
|
23
|
+
* without handing a whole week to one of them. Months and quarters nest, so those are read as they are drawn.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readUnit(base: AutoUnit, addsUp: boolean): AutoUnit;
|
|
26
|
+
/** The label of the period a day, month or quarter label falls in, spelled as the server spells it. */
|
|
27
|
+
export declare function bucketKey(key: string, unit: AutoUnit, weekStart?: number): string;
|
|
28
|
+
/**
|
|
29
|
+
* A trend's points over its window: the periods that held no rows put back as zero, from the window's first period
|
|
30
|
+
* 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
|
|
31
|
+
* drawn through only the days that had rows said a quiet week was a steady one; three busy days of a week drew no
|
|
32
|
+
* 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
|
|
33
|
+
* unit does not spell are left as they came.
|
|
34
|
+
*/
|
|
35
|
+
export declare function trendPoints<R extends {
|
|
36
|
+
key: unknown;
|
|
37
|
+
value: unknown;
|
|
38
|
+
}>(rows: readonly R[], read: AutoUnit, unit: AutoUnit, measure: string | undefined, window: {
|
|
39
|
+
start: Date;
|
|
40
|
+
end: Date;
|
|
41
|
+
} | undefined, now: Date): Array<{
|
|
42
|
+
key: unknown;
|
|
43
|
+
value: unknown;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* The unit a chart is drawn in: the span's, stepped up while the data is sparse in it.
|
|
47
|
+
*
|
|
48
|
+
* `keys` are the labels of the buckets that hold data, as read (days, or months or quarters, per `readUnit`).
|
|
49
|
+
* `addsUp` is whether the measure can be re-aggregated; without it the span alone decides.
|
|
50
|
+
*/
|
|
51
|
+
export declare function chooseUnit({ spanDays, base: given, keys, addsUp, weekStart, }: {
|
|
52
|
+
/** The span in days; or the `base` already chosen for it, where the caller has kept one. */
|
|
53
|
+
spanDays?: number;
|
|
54
|
+
base?: AutoUnit;
|
|
55
|
+
keys: readonly string[];
|
|
56
|
+
addsUp: boolean;
|
|
57
|
+
weekStart?: number;
|
|
58
|
+
}): {
|
|
59
|
+
base: AutoUnit;
|
|
60
|
+
unit: AutoUnit;
|
|
61
|
+
};
|
|
62
|
+
type Combine = 'add' | 'min' | 'max';
|
|
63
|
+
export interface MeasurePlan {
|
|
64
|
+
/** What to read per bucket, in the grammar's words: each aggregate the measure is made of, once. */
|
|
65
|
+
reads: string[];
|
|
66
|
+
/** How the same aggregate of two buckets becomes one of their union. */
|
|
67
|
+
combine: Combine[];
|
|
68
|
+
/** The measure's value from its aggregates, null where it has none (a ratio over nothing). */
|
|
69
|
+
value(terms: readonly (number | null)[]): number | null;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A measure as the aggregates it is made of, or null where it cannot be added up again: a median, a distinct
|
|
73
|
+
* count, a `when` count, or words this does not read. `avg x` is `sum x` over `count x`, which can.
|
|
74
|
+
*/
|
|
75
|
+
export declare function planMeasure(measure: string | undefined): MeasurePlan | null;
|
|
76
|
+
/** One bucket as read: its label, the second key's value where the chart has one, and one number per aggregate the plan reads. */
|
|
77
|
+
interface ReadBucket {
|
|
78
|
+
key: string;
|
|
79
|
+
series?: string;
|
|
80
|
+
terms: readonly (number | null)[];
|
|
81
|
+
}
|
|
82
|
+
/** The read buckets cut into the chosen unit, each aggregate added up (or min'd, or max'd) across the ones it takes in. */
|
|
83
|
+
export declare function coarsen(buckets: readonly ReadBucket[], plan: MeasurePlan, unit: AutoUnit, weekStart?: number): Array<{
|
|
84
|
+
key: string;
|
|
85
|
+
series?: string;
|
|
86
|
+
value: number;
|
|
87
|
+
}>;
|
|
88
|
+
/** The most days a window may span before a fixed `day` chart over it is worth a word. */
|
|
89
|
+
export declare const DAY_BARS_ADVISED = 90;
|
|
90
|
+
/**
|
|
91
|
+
* The days a dashboard window phrase covers, as it would be said ("last 12 months" is 365): the nominal length of a
|
|
92
|
+
* `last N unit`, else the dates the phrase resolves to, or null where it is not one the date grammar bounds. (A
|
|
93
|
+
* resolved `last N` runs to tomorrow, a day more than it is called, which a count of bars should not repeat.)
|
|
94
|
+
*/
|
|
95
|
+
export declare function windowDays(phrase: string, now: Date): number | null;
|
|
96
|
+
/** Whether a chart's `by` cuts days: `day created_at`, in any position. */
|
|
97
|
+
export declare const cutsDays: (by: string | undefined) => boolean;
|
|
98
|
+
export {};
|
|
@@ -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
|
+
}
|