@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,422 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom components, as the App definition declares them: an author's own
|
|
3
|
+
* React module, referenced by path and placed only through a declared kind —
|
|
4
|
+
* a `custom` section on a page or a dashboard, a value renderer where a
|
|
5
|
+
* display rule stands, an input where a form draws a field, a list view's
|
|
6
|
+
* rows (`customList`) or a free-form page (`definePage` in `pages/*.page.tsx`).
|
|
7
|
+
*
|
|
8
|
+
* The definition stays data. `app.ts` is evaluated in a worker and crosses
|
|
9
|
+
* back by structured clone, so a component can never be embedded as a
|
|
10
|
+
* function: `component(id, { module })` is a name and a path, and the server
|
|
11
|
+
* compiles the module beside the App (packages/mistri/src/server/app/appComponents.ts). What
|
|
12
|
+
* the component reads is declared here too — the record's own fields and
|
|
13
|
+
* named reads of rows — so it is checked, planned and authorized like every
|
|
14
|
+
* built-in section, and the module only draws what it is handed.
|
|
15
|
+
*
|
|
16
|
+
* Author code is deployment code, trusted like `commands.ts`; the server
|
|
17
|
+
* stays the only security boundary. A signed-out visitor may meet one where
|
|
18
|
+
* the public grant already lets them read — a page, a list or a value over a
|
|
19
|
+
* resource `auth.public` opens — and every read it makes is the public
|
|
20
|
+
* grant's, refused on the server like any other; what a component declares
|
|
21
|
+
* it reads there is held to that grant as the App loads, so a public page
|
|
22
|
+
* never breaks for its visitors. The landing and public forms stay a closed
|
|
23
|
+
* set of kinds that never runs markup: no component stands on either.
|
|
24
|
+
*/
|
|
25
|
+
import { allowKeys, isRecord } from './model.js';
|
|
26
|
+
export const COMPONENT_KINDS = ['section', 'value', 'input', 'list', 'page'];
|
|
27
|
+
export const COMPONENT_PROP_TYPES = ['number', 'text', 'boolean', 'choice'];
|
|
28
|
+
/** The key a component is referenced by: lowercase, the file names it is served under start with it. */
|
|
29
|
+
export const COMPONENT_ID = /^[a-z][a-z0-9-]{0,47}$/;
|
|
30
|
+
/** What a component module may be: TypeScript or JavaScript, with or without JSX. */
|
|
31
|
+
const COMPONENT_EXTENSIONS = ['.tsx', '.ts', '.jsx', '.js'];
|
|
32
|
+
/**
|
|
33
|
+
* How many named reads one custom section may declare. Its reads are asked together, one request each, so this
|
|
34
|
+
* bounds the fan-out of a single paint (the server runs one active connection per process); the section draws one
|
|
35
|
+
* skeleton until all are in, so more reads never shift the layout. Four was short of a real section (a list, its
|
|
36
|
+
* neighbours and a few tables to look names up in); eight keeps a paint at a handful of queries.
|
|
37
|
+
*/
|
|
38
|
+
export const MAX_CUSTOM_READS = 8;
|
|
39
|
+
/** The keys `component()` writes. */
|
|
40
|
+
const COMPONENT_KEYS = ['id', 'module', 'kind', 'props'];
|
|
41
|
+
/** How many columns a custom list presentation reads beside the keys. */
|
|
42
|
+
const MAX_CUSTOM_LIST_SHOW = 32;
|
|
43
|
+
/**
|
|
44
|
+
* How many aggregate reads (`figures`) one custom section may declare. Each is one breakdown, asked with the paint's
|
|
45
|
+
* other breakdowns in a single request (breakdownBatch.ts), so the bound is on the work one section adds to it.
|
|
46
|
+
*/
|
|
47
|
+
export const MAX_CUSTOM_FIGURES = 8;
|
|
48
|
+
/** The keys a declared read of rows takes, on a page and on a dashboard. */
|
|
49
|
+
export const PAGE_READ_KEYS = ['from', 'whose', 'query', 'show', 'sort', 'limit'];
|
|
50
|
+
export const DASH_READ_KEYS = ['from', 'query', 'show', 'sort', 'limit', 'over'];
|
|
51
|
+
/** The keys a declared aggregate read takes, on a page and on a dashboard. */
|
|
52
|
+
const PAGE_TOTAL_KEYS = ['from', 'measure', 'by', 'whose', 'query', 'limit'];
|
|
53
|
+
const DASH_TOTAL_KEYS = ['from', 'measure', 'by', 'query', 'over', 'limit'];
|
|
54
|
+
/** What a total measures: the breakdown grammar's aggregates over one column of the resource (count takes none). */
|
|
55
|
+
const TOTAL_FUNCTIONS = ['count', 'sum', 'avg', 'min', 'max'];
|
|
56
|
+
const TOTAL_MEASURE = /^(count|(?:sum|avg|min|max)\s+[A-Za-z_][A-Za-z0-9_]*)$/;
|
|
57
|
+
/** The most groups one total returns, and what it returns when it says none. */
|
|
58
|
+
const MAX_TOTAL_GROUPS = 500;
|
|
59
|
+
const DEFAULT_TOTAL_GROUPS = 100;
|
|
60
|
+
const PATH = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
61
|
+
const NAME = /^[A-Za-z][A-Za-z0-9_]{0,39}$/;
|
|
62
|
+
/** Whether a value is a component declaration: what a display rule or a section names in place of its own words. */
|
|
63
|
+
export function isComponentDecl(value) {
|
|
64
|
+
return isRecord(value) && typeof value.module === 'string' && typeof value.id === 'string';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* A component declaration, checked in shape. The file itself — that it
|
|
68
|
+
* exists, inside the App directory, and compiles — is the loader's to judge
|
|
69
|
+
* (it knows the directory); this is what can be said of the data alone.
|
|
70
|
+
*/
|
|
71
|
+
export function parseComponentDecl(raw, at, expected) {
|
|
72
|
+
if (!isRecord(raw))
|
|
73
|
+
throw new Error(`${at} is not a component — declare it with component('id', { module: './widgets/Thing.tsx' }).`);
|
|
74
|
+
allowKeys(raw, COMPONENT_KEYS, `${at} (a component)`);
|
|
75
|
+
const id = raw.id;
|
|
76
|
+
if (typeof id !== 'string' || !COMPONENT_ID.test(id)) {
|
|
77
|
+
throw new Error(`${at} has a component id ${JSON.stringify(id)}: lowercase letters, digits and hyphens, starting with a letter, at most 48 characters.`);
|
|
78
|
+
}
|
|
79
|
+
const module = raw.module;
|
|
80
|
+
if (typeof module !== 'string' ||
|
|
81
|
+
!module.startsWith('./') ||
|
|
82
|
+
module.includes('\\') ||
|
|
83
|
+
module.split('/').some((part) => part === '..' || part === '') ||
|
|
84
|
+
!COMPONENT_EXTENSIONS.some((ext) => module.endsWith(ext))) {
|
|
85
|
+
throw new Error(`${at}: the component "${id}" names the module ${JSON.stringify(module)}. A module is a path inside the App directory, ` +
|
|
86
|
+
`written from it — './widgets/Thing.tsx' — ending in ${COMPONENT_EXTENSIONS.join(', ')}.`);
|
|
87
|
+
}
|
|
88
|
+
const kind = raw.kind === undefined ? 'section' : raw.kind;
|
|
89
|
+
if (!COMPONENT_KINDS.includes(kind)) {
|
|
90
|
+
throw new Error(`${at}: the component "${id}" has a kind of ${JSON.stringify(kind)}. Use ${COMPONENT_KINDS.map((k) => `"${k}"`).join(' or ')}.`);
|
|
91
|
+
}
|
|
92
|
+
if (expected && kind !== expected) {
|
|
93
|
+
throw new Error(`${at} names the component "${id}", ${KIND_WORDS[kind]}. ${PLACED[expected]} takes a component of kind "${expected}": ` +
|
|
94
|
+
`component('${id}', { module, kind: '${expected}' }).`);
|
|
95
|
+
}
|
|
96
|
+
const props = raw.props === undefined ? undefined : parsePropDecls(raw.props, `${at}: the component "${id}"`);
|
|
97
|
+
return { id, module, kind: kind, ...(props ? { props } : {}) };
|
|
98
|
+
}
|
|
99
|
+
/** What each kind is, and where each is placed, for a refusal that says both. */
|
|
100
|
+
const KIND_WORDS = {
|
|
101
|
+
section: 'a section',
|
|
102
|
+
value: 'a value renderer',
|
|
103
|
+
input: 'an input',
|
|
104
|
+
list: 'a list presentation',
|
|
105
|
+
page: 'a free-form page',
|
|
106
|
+
};
|
|
107
|
+
const PLACED = {
|
|
108
|
+
section: 'A custom section',
|
|
109
|
+
value: 'A display rule',
|
|
110
|
+
input: 'An input',
|
|
111
|
+
list: 'customList()',
|
|
112
|
+
page: 'A free-form page (pages/*.page.tsx)',
|
|
113
|
+
};
|
|
114
|
+
function parsePropDecls(raw, at) {
|
|
115
|
+
if (!isRecord(raw))
|
|
116
|
+
throw new Error(`${at} has "props" that are not an object of prop.number(), prop.text(), prop.bool() or prop.choice().`);
|
|
117
|
+
const out = {};
|
|
118
|
+
for (const [name, entry] of Object.entries(raw)) {
|
|
119
|
+
const here = `${at}, prop "${name}"`;
|
|
120
|
+
if (!NAME.test(name))
|
|
121
|
+
throw new Error(`${here}: a prop's name is a word of letters, digits and underscores.`);
|
|
122
|
+
if (!isRecord(entry) || !COMPONENT_PROP_TYPES.includes(entry.type)) {
|
|
123
|
+
throw new Error(`${here} is not a prop declaration — write prop.number(), prop.text(), prop.bool() or prop.choice([...]).`);
|
|
124
|
+
}
|
|
125
|
+
const decl = entry;
|
|
126
|
+
if (decl.type === 'number') {
|
|
127
|
+
allowKeys(decl, ['type', 'default', 'min', 'max'], here);
|
|
128
|
+
for (const key of ['min', 'max']) {
|
|
129
|
+
if (decl[key] !== undefined && (typeof decl[key] !== 'number' || !Number.isFinite(decl[key])))
|
|
130
|
+
throw new Error(`${here} has a "${key}" that is not a number.`);
|
|
131
|
+
}
|
|
132
|
+
if (decl.min !== undefined && decl.max !== undefined && decl.min > decl.max)
|
|
133
|
+
throw new Error(`${here} has a "min" above its "max".`);
|
|
134
|
+
}
|
|
135
|
+
else if (decl.type === 'text') {
|
|
136
|
+
allowKeys(decl, ['type', 'default', 'max'], here);
|
|
137
|
+
if (decl.max !== undefined && (!Number.isInteger(decl.max) || decl.max < 1))
|
|
138
|
+
throw new Error(`${here} has a "max" that is not a positive whole number.`);
|
|
139
|
+
}
|
|
140
|
+
else if (decl.type === 'boolean') {
|
|
141
|
+
allowKeys(decl, ['type', 'default'], here);
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
allowKeys(decl, ['type', 'options', 'default'], here);
|
|
145
|
+
if (!Array.isArray(decl.options) ||
|
|
146
|
+
!decl.options.length ||
|
|
147
|
+
decl.options.some((option) => typeof option !== 'string' || !option.trim())) {
|
|
148
|
+
throw new Error(`${here} is a choice with no "options": name its values, prop.choice(['week', 'month']).`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/* A default is a value like any other: checked against its own declaration now,
|
|
152
|
+
so a component never receives what its declaration says it cannot. */
|
|
153
|
+
if (decl.default !== undefined)
|
|
154
|
+
propValue(decl, decl.default, `${here}, its default`);
|
|
155
|
+
out[name] = { ...decl };
|
|
156
|
+
}
|
|
157
|
+
return out;
|
|
158
|
+
}
|
|
159
|
+
function propValue(decl, value, at) {
|
|
160
|
+
switch (decl.type) {
|
|
161
|
+
case 'number':
|
|
162
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
163
|
+
throw new Error(`${at} is ${JSON.stringify(value)}, not a number.`);
|
|
164
|
+
if (decl.min !== undefined && value < decl.min)
|
|
165
|
+
throw new Error(`${at} is ${value}, below its min of ${decl.min}.`);
|
|
166
|
+
if (decl.max !== undefined && value > decl.max)
|
|
167
|
+
throw new Error(`${at} is ${value}, above its max of ${decl.max}.`);
|
|
168
|
+
return value;
|
|
169
|
+
case 'text':
|
|
170
|
+
if (typeof value !== 'string')
|
|
171
|
+
throw new Error(`${at} is ${JSON.stringify(value)}, not text.`);
|
|
172
|
+
if (decl.max !== undefined && value.length > decl.max)
|
|
173
|
+
throw new Error(`${at} is longer than its max of ${decl.max} characters.`);
|
|
174
|
+
return value;
|
|
175
|
+
case 'boolean':
|
|
176
|
+
if (typeof value !== 'boolean')
|
|
177
|
+
throw new Error(`${at} is ${JSON.stringify(value)}, not true or false.`);
|
|
178
|
+
return value;
|
|
179
|
+
case 'choice':
|
|
180
|
+
if (typeof value !== 'string' || !decl.options.includes(value))
|
|
181
|
+
throw new Error(`${at} is ${JSON.stringify(value)}; it is one of ${decl.options.map((o) => `"${o}"`).join(', ')}.`);
|
|
182
|
+
return value;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The props a placement hands its component: each value checked against the
|
|
187
|
+
* component's declaration and every default filled in, so the module reads
|
|
188
|
+
* exactly the shape its types promise. A prop the declaration does not name is
|
|
189
|
+
* refused, as an unknown key is everywhere else.
|
|
190
|
+
*/
|
|
191
|
+
export function componentPropValues(decl, raw, at) {
|
|
192
|
+
if (raw !== undefined && !isRecord(raw))
|
|
193
|
+
throw new Error(`${at} has "props" that are not an object.`);
|
|
194
|
+
const given = (raw ?? {});
|
|
195
|
+
const declared = decl.props ?? {};
|
|
196
|
+
for (const name of Object.keys(given)) {
|
|
197
|
+
if (!Object.hasOwn(declared, name)) {
|
|
198
|
+
const names = Object.keys(declared);
|
|
199
|
+
throw new Error(`${at} gives the prop "${name}", which the component "${decl.id}" does not declare. ${names.length ? `It declares: ${names.join(', ')}.` : 'It declares none.'}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
const out = {};
|
|
203
|
+
for (const [name, prop] of Object.entries(declared)) {
|
|
204
|
+
const value = Object.hasOwn(given, name) ? given[name] : prop.default;
|
|
205
|
+
if (value !== undefined)
|
|
206
|
+
out[name] = propValue(prop, value, `${at}, prop "${name}"`);
|
|
207
|
+
}
|
|
208
|
+
return out;
|
|
209
|
+
}
|
|
210
|
+
function readShape(raw, at, keys) {
|
|
211
|
+
if (!isRecord(raw))
|
|
212
|
+
throw new Error(`${at} is not an object like { from: 'invoice', show: ['number', 'total'] }.`);
|
|
213
|
+
allowKeys(raw, keys, at);
|
|
214
|
+
if (typeof raw.from !== 'string' || !raw.from.trim())
|
|
215
|
+
throw new Error(`${at} has no "from": the resource its rows come from.`);
|
|
216
|
+
if (!Array.isArray(raw.show) || !raw.show.length || raw.show.some((path) => typeof path !== 'string' || !PATH.test(path.trim()))) {
|
|
217
|
+
throw new Error(`${at} has no "show": the columns the component reads, label paths welcome — ['number', 'customer_id.name'].`);
|
|
218
|
+
}
|
|
219
|
+
for (const key of ['query', 'sort', 'whose', 'over']) {
|
|
220
|
+
if (raw[key] !== undefined && (typeof raw[key] !== 'string' || !raw[key].trim()))
|
|
221
|
+
throw new Error(`${at} has a "${key}" that is not a non-empty string.`);
|
|
222
|
+
}
|
|
223
|
+
if (raw.limit !== undefined && (typeof raw.limit !== 'number' || !Number.isInteger(raw.limit) || raw.limit < 1 || raw.limit > 500)) {
|
|
224
|
+
throw new Error(`${at} has a "limit" that is not a whole number from 1 to 500.`);
|
|
225
|
+
}
|
|
226
|
+
return raw;
|
|
227
|
+
}
|
|
228
|
+
function reads(raw, at, one, { key = 'rows', most = MAX_CUSTOM_READS, noun = 'reads' } = {}) {
|
|
229
|
+
if (raw === undefined)
|
|
230
|
+
return undefined;
|
|
231
|
+
if (!isRecord(raw) || !Object.keys(raw).length)
|
|
232
|
+
throw new Error(`${at} has "${key}" that are not an object of named ${noun}: { runs: { from, show } }.`);
|
|
233
|
+
const names = Object.keys(raw);
|
|
234
|
+
if (names.length > most)
|
|
235
|
+
throw new Error(`${at} declares ${names.length} ${noun}; a custom section reads at most ${most}.`);
|
|
236
|
+
return Object.fromEntries(names.map((name) => {
|
|
237
|
+
if (!NAME.test(name))
|
|
238
|
+
throw new Error(`${at}: a read's name is a word of letters, digits and underscores, like "runs"; "${name}" is not.`);
|
|
239
|
+
return [name, one(raw[name], `${at}, ${key} "${name}"`)];
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
export function parsePageReads(raw, at) {
|
|
243
|
+
return reads(raw, at, (entry, here) => {
|
|
244
|
+
const r = readShape(entry, here, PAGE_READ_KEYS);
|
|
245
|
+
return {
|
|
246
|
+
from: r.from.trim(),
|
|
247
|
+
...(r.whose === undefined ? {} : { path: r.whose.trim() }),
|
|
248
|
+
...(r.query === undefined ? {} : { filter: r.query.trim() }),
|
|
249
|
+
columns: r.show.map((path) => path.trim()),
|
|
250
|
+
...(r.sort === undefined ? {} : { sort: r.sort.trim() }),
|
|
251
|
+
...(r.limit === undefined ? {} : { limit: r.limit }),
|
|
252
|
+
};
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export function parseDashReads(raw, at) {
|
|
256
|
+
return reads(raw, at, (entry, here) => {
|
|
257
|
+
const r = readShape(entry, here, DASH_READ_KEYS);
|
|
258
|
+
return {
|
|
259
|
+
table: r.from.trim(),
|
|
260
|
+
...(r.query === undefined ? {} : { query: r.query.trim() }),
|
|
261
|
+
show: r.show.map((path) => path.trim()),
|
|
262
|
+
...(r.sort === undefined ? {} : { sort: r.sort.trim() }),
|
|
263
|
+
...(r.limit === undefined ? {} : { limit: r.limit }),
|
|
264
|
+
...(r.over === undefined ? {} : { over: r.over.trim() }),
|
|
265
|
+
};
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
function totalShape(raw, at, keys) {
|
|
269
|
+
if (!isRecord(raw))
|
|
270
|
+
throw new Error(`${at} is not an object like { from: 'invoice', measure: 'sum total' }.`);
|
|
271
|
+
allowKeys(raw, keys, at);
|
|
272
|
+
if (typeof raw.from !== 'string' || !raw.from.trim())
|
|
273
|
+
throw new Error(`${at} has no "from": the resource it measures.`);
|
|
274
|
+
if (typeof raw.measure !== 'string' || !TOTAL_MEASURE.test(raw.measure.trim().replace(/\s+/g, ' '))) {
|
|
275
|
+
throw new Error(`${at} has no "measure": "count", or ${TOTAL_FUNCTIONS.slice(1).join(', ')} and a column — 'sum amount'.`);
|
|
276
|
+
}
|
|
277
|
+
for (const key of ['by', 'query', 'whose', 'over']) {
|
|
278
|
+
if (raw[key] !== undefined && (typeof raw[key] !== 'string' || !raw[key].trim()))
|
|
279
|
+
throw new Error(`${at} has a "${key}" that is not a non-empty string.`);
|
|
280
|
+
}
|
|
281
|
+
if (raw.limit !== undefined) {
|
|
282
|
+
if (raw.by === undefined)
|
|
283
|
+
throw new Error(`${at} has a "limit" and no "by": a figure with no groups has no groups to cut.`);
|
|
284
|
+
if (typeof raw.limit !== 'number' || !Number.isInteger(raw.limit) || raw.limit < 1 || raw.limit > MAX_TOTAL_GROUPS)
|
|
285
|
+
throw new Error(`${at} has a "limit" that is not a whole number from 1 to ${MAX_TOTAL_GROUPS}.`);
|
|
286
|
+
}
|
|
287
|
+
return { ...raw, measure: raw.measure.trim().replace(/\s+/g, ' ') };
|
|
288
|
+
}
|
|
289
|
+
const totalReads = { key: 'figures', most: MAX_CUSTOM_FIGURES, noun: 'figures' };
|
|
290
|
+
export function parsePageTotals(raw, at) {
|
|
291
|
+
return reads(raw, at, (entry, here) => {
|
|
292
|
+
const r = totalShape(entry, here, PAGE_TOTAL_KEYS);
|
|
293
|
+
const [fn, column] = r.measure.split(' ');
|
|
294
|
+
return {
|
|
295
|
+
from: r.from.trim(),
|
|
296
|
+
fn,
|
|
297
|
+
...(column === undefined ? {} : { column }),
|
|
298
|
+
...(r.by === undefined ? {} : { by: r.by.trim() }),
|
|
299
|
+
...(r.whose === undefined ? {} : { path: r.whose.trim() }),
|
|
300
|
+
...(r.query === undefined ? {} : { filter: r.query.trim() }),
|
|
301
|
+
...(r.limit === undefined ? {} : { limit: r.limit }),
|
|
302
|
+
};
|
|
303
|
+
}, totalReads);
|
|
304
|
+
}
|
|
305
|
+
export function parseDashTotals(raw, at) {
|
|
306
|
+
return reads(raw, at, (entry, here) => {
|
|
307
|
+
const r = totalShape(entry, here, DASH_TOTAL_KEYS);
|
|
308
|
+
return {
|
|
309
|
+
table: r.from.trim(),
|
|
310
|
+
measure: r.measure,
|
|
311
|
+
...(r.by === undefined ? {} : { by: r.by.trim() }),
|
|
312
|
+
...(r.query === undefined ? {} : { query: r.query.trim() }),
|
|
313
|
+
...(r.over === undefined ? {} : { over: r.over.trim() }),
|
|
314
|
+
...(r.limit === undefined ? {} : { limit: r.limit }),
|
|
315
|
+
};
|
|
316
|
+
}, totalReads);
|
|
317
|
+
}
|
|
318
|
+
/** How many groups a total with a `by` returns when it says no limit. */
|
|
319
|
+
export const groupsAsked = (limit) => limit ?? DEFAULT_TOTAL_GROUPS;
|
|
320
|
+
/** A record's own fields a page's custom section reads. */
|
|
321
|
+
export function parseRecordFields(raw, at) {
|
|
322
|
+
if (raw === undefined)
|
|
323
|
+
return undefined;
|
|
324
|
+
if (!Array.isArray(raw) || !raw.length || raw.some((path) => typeof path !== 'string' || !PATH.test(path.trim()))) {
|
|
325
|
+
throw new Error(`${at} has a "record" that is not a list of the record's fields, label paths welcome — ['status', 'customer_id.name'].`);
|
|
326
|
+
}
|
|
327
|
+
return raw.map((path) => path.trim());
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* `customList(postStream, { show: ['body', 'author_id.display_name'] })`: a
|
|
331
|
+
* list view's rows drawn by the author's component. The platform keeps the
|
|
332
|
+
* query, the tabs, the filters, the sort, the paging and the bulk actions;
|
|
333
|
+
* `show` is what the query reads beside the keys, so every row the component
|
|
334
|
+
* receives carries exactly those columns.
|
|
335
|
+
*/
|
|
336
|
+
export function parseCustomList(raw, at) {
|
|
337
|
+
allowKeys(raw, ['kind', 'component', 'show', 'props'], `${at} (a custom list)`);
|
|
338
|
+
const component = parseComponentDecl(raw.component, `${at}, "component"`, 'list');
|
|
339
|
+
const show = raw.show;
|
|
340
|
+
if (!Array.isArray(show) ||
|
|
341
|
+
!show.length ||
|
|
342
|
+
show.length > MAX_CUSTOM_LIST_SHOW ||
|
|
343
|
+
show.some((path) => typeof path !== 'string' || !PATH.test(path.trim()))) {
|
|
344
|
+
throw new Error(`${at} has no "show": the columns its component reads, one to ${MAX_CUSTOM_LIST_SHOW}, label paths welcome — ['body', 'author_id.display_name'].`);
|
|
345
|
+
}
|
|
346
|
+
const columns = show.map((path) => path.trim());
|
|
347
|
+
if (new Set(columns).size !== columns.length)
|
|
348
|
+
throw new Error(`${at} names one column twice in "show".`);
|
|
349
|
+
return { kind: 'custom', component, show: columns, props: componentPropValues(component, raw.props, at) };
|
|
350
|
+
}
|
|
351
|
+
/** The most address parameters one page keeps. */
|
|
352
|
+
const MAX_PAGE_PARAMS = 8;
|
|
353
|
+
const PARAM = /^[a-z][a-z0-9_]{0,31}$/;
|
|
354
|
+
const LOADER = /^[A-Za-z][A-Za-z0-9_]{0,63}$/;
|
|
355
|
+
const words = (raw) => Array.isArray(raw) && raw.every((name) => typeof name === 'string' && name.trim() !== '');
|
|
356
|
+
/**
|
|
357
|
+
* `definePage({ reads: ['pick_list'], commands: ['pickList'], params: ['list'], component })`:
|
|
358
|
+
* a whole page drawn by the author's component. What it reads and runs is
|
|
359
|
+
* declared, so a reader who cannot read every one of its resources is not
|
|
360
|
+
* offered it, `mistri check` holds the module to it, and authority.lock
|
|
361
|
+
* records it; its place is kept in the address by the parameters it names,
|
|
362
|
+
* so a page reached by link opens where it was. A bracketed code leads each
|
|
363
|
+
* refusal, for `mistri check` (checkProblems.ts).
|
|
364
|
+
*/
|
|
365
|
+
export function parsePage(raw, at) {
|
|
366
|
+
const component = parseComponentDecl(raw.component, `${at}, "component"`, 'page');
|
|
367
|
+
const reads = raw.reads;
|
|
368
|
+
if (!words(reads) || !reads.length) {
|
|
369
|
+
throw new Error(`[page-reads] ${at} has no "reads": the resources the page reads — reads: ['pick_list', 'order_line']. A page reads nothing it does not declare.`);
|
|
370
|
+
}
|
|
371
|
+
const commands = raw.commands === undefined ? [] : raw.commands;
|
|
372
|
+
if (!words(commands))
|
|
373
|
+
throw new Error(`[page-commands] ${at} has "commands" that are not a list of command names: commands: ['pickList'].`);
|
|
374
|
+
const params = raw.params === undefined ? [] : raw.params;
|
|
375
|
+
if (!Array.isArray(params) ||
|
|
376
|
+
params.length > MAX_PAGE_PARAMS ||
|
|
377
|
+
params.some((name) => typeof name !== 'string' || !PARAM.test(name)) ||
|
|
378
|
+
params.includes('period')) {
|
|
379
|
+
throw new Error(`[page-params] ${at} has "params" that are not up to ${MAX_PAGE_PARAMS} lowercase words, like params: ['list']; "period" is a dashboard's.`);
|
|
380
|
+
}
|
|
381
|
+
if (raw.loader !== undefined && (typeof raw.loader !== 'string' || !LOADER.test(raw.loader))) {
|
|
382
|
+
throw new Error(`[page-loader] ${at} has a "loader" that is not a loader's name, as the commands module's defineLoaders() registers it.`);
|
|
383
|
+
}
|
|
384
|
+
return {
|
|
385
|
+
component,
|
|
386
|
+
reads: [...new Set(reads.map((name) => name.trim()))],
|
|
387
|
+
commands: [...new Set(commands.map((name) => name.trim()))],
|
|
388
|
+
params: [...new Set(params)],
|
|
389
|
+
...(raw.loader === undefined ? {} : { loader: raw.loader }),
|
|
390
|
+
props: componentPropValues(component, raw.props, at),
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* `inputs: { color: colorPicker }`: a component standing in a form's field —
|
|
395
|
+
* a resource's column in its edit and New forms, or a command's input in an
|
|
396
|
+
* action's or a signed-in form's command form. It draws the control and
|
|
397
|
+
* hands back a value; what the value must be is still the form's rules and
|
|
398
|
+
* the server's to judge.
|
|
399
|
+
*/
|
|
400
|
+
export function parseInputs(raw, at, options = {}) {
|
|
401
|
+
if (raw === undefined)
|
|
402
|
+
return undefined;
|
|
403
|
+
if (!isRecord(raw) || !Object.keys(raw).length)
|
|
404
|
+
throw new Error(`${at} has "inputs" that are not an object of field → input component: { color: colorPicker }.`);
|
|
405
|
+
/* A command's input inside a group is named by its path, `trade.vin`: in a repeating group, every row's. */
|
|
406
|
+
const named = options.paths ? /^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/ : /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
407
|
+
return Object.fromEntries(Object.entries(raw).map(([name, decl]) => {
|
|
408
|
+
if (!named.test(name))
|
|
409
|
+
throw new Error(`${at}, "inputs": "${name}" is not a field's name${options.paths ? ' or a path into a group (trade.vin)' : ''}.`);
|
|
410
|
+
return [name, parseComponentDecl(decl, `${at}, inputs "${name}"`, 'input')];
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
/** A command's input by its name or its path through groups (`trade.vin`), or undefined; a group itself is not one, nor are lines (their grid is the platform's). */
|
|
414
|
+
export function commandInputAt(fields, path) {
|
|
415
|
+
const [head, ...rest] = path.split('.');
|
|
416
|
+
const field = fields.find((candidate) => candidate.name === head);
|
|
417
|
+
if (!field)
|
|
418
|
+
return undefined;
|
|
419
|
+
if (!rest.length)
|
|
420
|
+
return field.type === 'group' || field.type === 'lines' ? undefined : field;
|
|
421
|
+
return field.type === 'group' && field.fields ? commandInputAt(field.fields, rest.join('.')) : undefined;
|
|
422
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { PageDef, PageSection, SectionWidth } from './pageModel.js';
|
|
2
|
+
/** What a page's `document` takes. `label` names it (the verb on its record, its heading on paper); `description` is
|
|
3
|
+
the sender's lines under the letterhead's name. */
|
|
4
|
+
export declare const DOCUMENT_KEYS: readonly ['label', 'number', 'size', 'description'];
|
|
5
|
+
/** Sheet sizes: ISO A4, or US Letter. */
|
|
6
|
+
declare const DOCUMENT_SIZES: readonly ['a4', 'letter'];
|
|
7
|
+
export type DocumentSize = (typeof DOCUMENT_SIZES)[number];
|
|
8
|
+
export interface PageDocument {
|
|
9
|
+
/** "Invoice", "Packing slip", "Payslip": the verb on the record, and the sheet's heading. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** A field path of the base whose value is the document's number. Absent: the record's own name. */
|
|
12
|
+
number?: string;
|
|
13
|
+
/** Absent: the paper of the App's locale — Letter in North America and the Philippines, A4 elsewhere. */
|
|
14
|
+
size?: DocumentSize;
|
|
15
|
+
/** The sender's lines under the letterhead's name: an address, a registration. Newlines are kept. */
|
|
16
|
+
description?: string;
|
|
17
|
+
}
|
|
18
|
+
/** A page's document, as one page body states it. */
|
|
19
|
+
export declare function parseDocument(raw: unknown, at: string): PageDocument;
|
|
20
|
+
/**
|
|
21
|
+
* What a document's sections may be, refused section by section: paper has no
|
|
22
|
+
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
23
|
+
* table whose header repeats on each sheet — never a gallery, a card or a
|
|
24
|
+
* page of rows. Its lists read every line, up to DOCUMENT_LINES, unless the
|
|
25
|
+
* author says fewer.
|
|
26
|
+
*/
|
|
27
|
+
export declare function documentSections(sections: readonly PageSection[], at: string): PageSection[];
|
|
28
|
+
/** The sheet a document is printed on: its own `size`, else the paper the App's (or tenant's) locale buys. */
|
|
29
|
+
export declare function paperSize(document: Pick<PageDocument, 'size'>, locale: string | undefined): DocumentSize;
|
|
30
|
+
/** Whether a page is a document rather than a screen. */
|
|
31
|
+
export declare const isDocument: (page: {
|
|
32
|
+
document?: unknown;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
/**
|
|
35
|
+
* A document's key is the last segment of its record's address, where a record
|
|
36
|
+
* page's tab is said: `/orders/12/invoice`. A tab of the same word on a page
|
|
37
|
+
* over the same table would be two things at one address, and a record's page
|
|
38
|
+
* never opens through a document.
|
|
39
|
+
*/
|
|
40
|
+
export declare function documentProblems(pages: readonly PageDef[], pageOf: Readonly<Record<string, string | undefined>>, tabWord: (token: string) => string, where: string): string[];
|
|
41
|
+
/** The share of a 12-column sheet a section's width takes, as the page's grid says it. */
|
|
42
|
+
export declare const SHEET_SPAN: Readonly<Record<SectionWidth, number>>;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Documents: a record put on paper — an invoice, a packing slip, a payslip, a
|
|
3
|
+
* quote.
|
|
4
|
+
*
|
|
5
|
+
* A document is an App page that says `document: { label, number, size,
|
|
6
|
+
* description }`. Its sections are the page sections a reader already knows
|
|
7
|
+
* (fields, related lists, notes), so its reads are a record page's: planned
|
|
8
|
+
* by the same route, asked through the same reads, under the same grants,
|
|
9
|
+
* row scope and tenant as the record's own page. Nothing is read for paper
|
|
10
|
+
* that the record's page could not read, and nothing new is served to make
|
|
11
|
+
* it: the browser's print engine is the renderer, and "Save as PDF" is the
|
|
12
|
+
* browser's.
|
|
13
|
+
*
|
|
14
|
+
* It is addressed under the record it is of, its key the last segment —
|
|
15
|
+
* `/atelier/orders/12/invoice` — the place a record's tab is said, so the
|
|
16
|
+
* address grammar (appAddress.ts) reads it unchanged. A document is never the
|
|
17
|
+
* page a record opens through, never a route of its own, and never in a menu:
|
|
18
|
+
* it is reached from its record, as a verb.
|
|
19
|
+
*
|
|
20
|
+
* Pure, and shared: the parser and the check here, the client's sheet and the
|
|
21
|
+
* server's address book read the same rules.
|
|
22
|
+
*/
|
|
23
|
+
import { allowKeys, isRecord } from './model.js';
|
|
24
|
+
/** What a page's `document` takes. `label` names it (the verb on its record, its heading on paper); `description` is
|
|
25
|
+
the sender's lines under the letterhead's name. */
|
|
26
|
+
export const DOCUMENT_KEYS = ['label', 'number', 'size', 'description'];
|
|
27
|
+
/** Sheet sizes: ISO A4, or US Letter. */
|
|
28
|
+
const DOCUMENT_SIZES = ['a4', 'letter'];
|
|
29
|
+
/** What paper draws: the record's own fields, the rows that point at it, and the author's words. */
|
|
30
|
+
const DOCUMENT_SECTION_KINDS = ['fields', 'list', 'note'];
|
|
31
|
+
/** Every line is on paper, up to the most a related list reads at once; a page that would be longer says so. */
|
|
32
|
+
const DOCUMENT_LINES = 500;
|
|
33
|
+
/** A page's document, as one page body states it. */
|
|
34
|
+
export function parseDocument(raw, at) {
|
|
35
|
+
const where = `${at}, "document"`;
|
|
36
|
+
if (!isRecord(raw))
|
|
37
|
+
throw new Error(`${where} is an object: { label: 'Invoice', number: 'invoice_no' }.`);
|
|
38
|
+
allowKeys(raw, DOCUMENT_KEYS, where);
|
|
39
|
+
if (typeof raw.label !== 'string' || !raw.label.trim())
|
|
40
|
+
throw new Error(`${where} has no "label": a document is named by what it is, "Invoice" or "Packing slip".`);
|
|
41
|
+
if (raw.number !== undefined &&
|
|
42
|
+
(typeof raw.number !== 'string' || !/^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(raw.number)))
|
|
43
|
+
throw new Error(`${where}: "number" is a field of the record, "invoice_no" or "pay_run_id.reference".`);
|
|
44
|
+
if (raw.size !== undefined && !DOCUMENT_SIZES.includes(raw.size))
|
|
45
|
+
throw new Error(`${where}: "size" is ${DOCUMENT_SIZES.map((size) => `"${size}"`).join(' or ')}.`);
|
|
46
|
+
if (raw.description !== undefined && (typeof raw.description !== 'string' || !raw.description.trim()))
|
|
47
|
+
throw new Error(`${where}: "description" is text, the sender's lines under the name.`);
|
|
48
|
+
return {
|
|
49
|
+
label: raw.label.trim(),
|
|
50
|
+
...(raw.number === undefined ? {} : { number: raw.number }),
|
|
51
|
+
...(raw.size === undefined ? {} : { size: raw.size }),
|
|
52
|
+
...(raw.description === undefined ? {} : { description: raw.description.trim() }),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* What a document's sections may be, refused section by section: paper has no
|
|
57
|
+
* aside, no tabs and nothing to operate, and a list on it is every line — a
|
|
58
|
+
* table whose header repeats on each sheet — never a gallery, a card or a
|
|
59
|
+
* page of rows. Its lists read every line, up to DOCUMENT_LINES, unless the
|
|
60
|
+
* author says fewer.
|
|
61
|
+
*/
|
|
62
|
+
export function documentSections(sections, at) {
|
|
63
|
+
return sections.map((section, i) => {
|
|
64
|
+
const where = `${at}, section ${i + 1}`;
|
|
65
|
+
if (!DOCUMENT_SECTION_KINDS.includes(section.kind))
|
|
66
|
+
throw new Error(`${where} is a "${section.kind}" section; a document draws fields, related lists and notes on paper.`);
|
|
67
|
+
if (section.kind === 'fields' && (section.presentation === 'card' || section.presentation === 'header'))
|
|
68
|
+
throw new Error(`${where} is a "${section.presentation}"; on paper fields are a summary, properties, facts, a table or a headline.`);
|
|
69
|
+
if (section.region === 'aside')
|
|
70
|
+
throw new Error(`${where} is in the aside; a document is one sheet wide, so place sections side by side with "width".`);
|
|
71
|
+
if (section.tab !== undefined)
|
|
72
|
+
throw new Error(`${where} has a "tab"; paper has no tabs, so every section of a document is drawn.`);
|
|
73
|
+
if (section.kind === 'fields' && section.actions?.length)
|
|
74
|
+
throw new Error(`${where} has "actions"; paper has nothing to press.`);
|
|
75
|
+
if (section.kind !== 'list')
|
|
76
|
+
return section;
|
|
77
|
+
if (section.presentation !== undefined || section.create || section.rowActions)
|
|
78
|
+
throw new Error(`${where} is a list of the record's lines on paper: no presentation, create or row actions.`);
|
|
79
|
+
return section.limit === undefined ? { ...section, limit: DOCUMENT_LINES } : section;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/* Where Letter is the paper in the drawer: ISO 216 everywhere else. */
|
|
83
|
+
const LETTER_REGIONS = new Set(['US', 'CA', 'MX', 'PH', 'PR', 'CL', 'CO', 'VE', 'GT', 'CR', 'PA', 'DO', 'SV', 'NI', 'HN', 'BZ']);
|
|
84
|
+
/** The sheet a document is printed on: its own `size`, else the paper the App's (or tenant's) locale buys. */
|
|
85
|
+
export function paperSize(document, locale) {
|
|
86
|
+
if (document.size)
|
|
87
|
+
return document.size;
|
|
88
|
+
let region;
|
|
89
|
+
try {
|
|
90
|
+
region = locale ? new Intl.Locale(locale).maximize().region : undefined;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
region = undefined;
|
|
94
|
+
}
|
|
95
|
+
return region && LETTER_REGIONS.has(region) ? 'letter' : 'a4';
|
|
96
|
+
}
|
|
97
|
+
/** Whether a page is a document rather than a screen. */
|
|
98
|
+
export const isDocument = (page) => page.document !== undefined;
|
|
99
|
+
/**
|
|
100
|
+
* A document's key is the last segment of its record's address, where a record
|
|
101
|
+
* page's tab is said: `/orders/12/invoice`. A tab of the same word on a page
|
|
102
|
+
* over the same table would be two things at one address, and a record's page
|
|
103
|
+
* never opens through a document.
|
|
104
|
+
*/
|
|
105
|
+
export function documentProblems(pages, pageOf, tabWord, where) {
|
|
106
|
+
const problems = [];
|
|
107
|
+
const documents = pages.filter(isDocument);
|
|
108
|
+
for (const document of documents) {
|
|
109
|
+
for (const page of pages) {
|
|
110
|
+
if (isDocument(page) || page.base !== document.base)
|
|
111
|
+
continue;
|
|
112
|
+
const words = new Set();
|
|
113
|
+
for (const section of page.sections) {
|
|
114
|
+
if (section.tab)
|
|
115
|
+
words.add(tabWord(`tab:${section.tab}`));
|
|
116
|
+
if (section.kind === 'list' && section.title)
|
|
117
|
+
words.add(tabWord(`tab:${section.title}`));
|
|
118
|
+
}
|
|
119
|
+
if (words.has(document.id))
|
|
120
|
+
problems.push(`${where}: pages "${document.id}" is a document at /<record>/${document.id}, which the page "${page.id}" already answers to as a tab. Give the document another key.`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
for (const [resource, id] of Object.entries(pageOf)) {
|
|
124
|
+
const named = id === undefined ? undefined : documents.find((page) => page.id === id);
|
|
125
|
+
if (named)
|
|
126
|
+
problems.push(`${where}: resources "${resource}", "page" names "${named.id}", which is a document: a record opens on a page, and its documents are verbs on it.`);
|
|
127
|
+
}
|
|
128
|
+
return problems;
|
|
129
|
+
}
|
|
130
|
+
/** The share of a 12-column sheet a section's width takes, as the page's grid says it. */
|
|
131
|
+
export const SHEET_SPAN = { full: 12, half: 6, third: 4, 'two-thirds': 8 };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which views a dashboard embeds, and which of those only a dashboard opens.
|
|
3
|
+
* The client asks this to lay out its rooms on first paint; it is apart from
|
|
4
|
+
* appPayload.ts because that module builds the payload from the parsed App,
|
|
5
|
+
* and importing it took the manifest parser into the first script. It reads
|
|
6
|
+
* the views by their shape, so the shared client asks it without the App's
|
|
7
|
+
* model.
|
|
8
|
+
*/
|
|
9
|
+
import { type ServedNavNode } from './servedApp.js';
|
|
10
|
+
/** The list views a dashboard section embeds, by key. */
|
|
11
|
+
export declare function embedTargets(views: Readonly<Record<string, object>>): Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* The views only a dashboard opens: embedded by one, and neither in nav
|
|
14
|
+
* nor among `homes`. Each has a room, where the embed's "open →" goes, and
|
|
15
|
+
* no menu lists it. The server passes every view a home rule names; the
|
|
16
|
+
* client, which knows only its own, the home it was served.
|
|
17
|
+
*/
|
|
18
|
+
export declare function embeddedOnlyViews(app: {
|
|
19
|
+
views: Readonly<Record<string, object>>;
|
|
20
|
+
nav: readonly ServedNavNode[];
|
|
21
|
+
}, homes: Iterable<string>): Set<string>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which views a dashboard embeds, and which of those only a dashboard opens.
|
|
3
|
+
* The client asks this to lay out its rooms on first paint; it is apart from
|
|
4
|
+
* appPayload.ts because that module builds the payload from the parsed App,
|
|
5
|
+
* and importing it took the manifest parser into the first script. It reads
|
|
6
|
+
* the views by their shape, so the shared client asks it without the App's
|
|
7
|
+
* model.
|
|
8
|
+
*/
|
|
9
|
+
import { navViewKeys } from './servedApp.js';
|
|
10
|
+
const embeds = (view) => Object.hasOwn(view, 'sections');
|
|
11
|
+
/** The list views a dashboard section embeds, by key. */
|
|
12
|
+
export function embedTargets(views) {
|
|
13
|
+
return new Set(Object.values(views).flatMap((view) => embeds(view) ? [...view.sections, ...(view.aside ?? [])].flatMap((section) => (section.view ? [section.view] : [])) : []));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The views only a dashboard opens: embedded by one, and neither in nav
|
|
17
|
+
* nor among `homes`. Each has a room, where the embed's "open →" goes, and
|
|
18
|
+
* no menu lists it. The server passes every view a home rule names; the
|
|
19
|
+
* client, which knows only its own, the home it was served.
|
|
20
|
+
*/
|
|
21
|
+
export function embeddedOnlyViews(app, homes) {
|
|
22
|
+
const listed = new Set([...navViewKeys(app.nav), ...homes]);
|
|
23
|
+
return new Set([...embedTargets(app.views)].filter((key) => !listed.has(key)));
|
|
24
|
+
}
|