@cosmicdrift/kumiko-framework 0.387.0 → 0.389.0
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/AGENTS.md +9 -1
- package/agents/examples/anonymous-access.md +1 -1
- package/agents/examples/apex-landing.md +204 -0
- package/agents/examples/api-worker-split.md +64 -0
- package/agents/examples/app-config.md +14 -0
- package/agents/examples/auth-mfa.md +115 -0
- package/agents/examples/env-composition.md +28 -1
- package/agents/examples/golden-path.md +13 -1
- package/agents/examples/legal-pages.md +1 -1
- package/agents/examples/lifecycle-hooks.md +55 -2
- package/agents/examples/list-table-options.md +466 -0
- package/agents/examples/pdf-audit-export.md +4 -2
- package/agents/examples/prod-boot-options.md +16 -0
- package/agents/examples/rate-limiting.md +48 -0
- package/agents/examples/record-detail-layout.md +692 -0
- package/agents/examples/seed-migration.md +212 -0
- package/agents/examples/state-machine.md +3 -2
- package/agents/examples/tenant-isolation.md +73 -1
- package/agents/examples/wizard-form.md +941 -0
- package/agents/examples/writeform-section.md +548 -0
- package/agents/examples.md +1 -0
- package/agents/features.md +19 -2
- package/agents/widgets.md +2 -0
- package/dist/api/api-constants.d.ts +1 -0
- package/dist/api/api-constants.js +2 -0
- package/dist/api/auth-routes-shared.d.ts +2 -0
- package/dist/api/auth-routes-shared.js +5 -0
- package/dist/api/client-error-route.js +10 -5
- package/dist/api/entity-read-access.d.ts +2 -1
- package/dist/api/entity-read-access.js +14 -0
- package/dist/api/export/export-cells-reference.d.ts +9 -0
- package/dist/api/export/export-cells-reference.js +21 -0
- package/dist/api/export/export-cells.d.ts +11 -0
- package/dist/api/export/export-cells.js +136 -0
- package/dist/api/export/export-ciphertext-guard.d.ts +2 -0
- package/dist/api/export/export-ciphertext-guard.js +27 -0
- package/dist/api/export/export-columns.d.ts +29 -0
- package/dist/api/export/export-columns.js +85 -0
- package/dist/api/export/export-errors.d.ts +4 -0
- package/dist/api/export/export-errors.js +14 -0
- package/dist/api/export/export-route.d.ts +4 -0
- package/dist/api/export/export-route.js +74 -0
- package/dist/api/export/export-rows.d.ts +13 -0
- package/dist/api/export/export-rows.js +62 -0
- package/dist/api/export/export-screen.d.ts +12 -0
- package/dist/api/export/export-screen.js +47 -0
- package/dist/api/export/export-xlsx-writer.d.ts +4 -0
- package/dist/api/export/export-xlsx-writer.js +21 -0
- package/dist/api/extra-route.d.ts +4 -0
- package/dist/api/index.d.ts +3 -1
- package/dist/api/index.js +3 -1
- package/dist/api/pii-leak-guard.d.ts +3 -0
- package/dist/api/pii-leak-guard.js +3 -2
- package/dist/api/request-context.d.ts +1 -1
- package/dist/api/request-context.js +1 -1
- package/dist/api/routes.d.ts +16 -0
- package/dist/api/routes.js +2 -2
- package/dist/api/server-boot-checks.d.ts +10 -0
- package/dist/api/server-boot-checks.js +157 -0
- package/dist/api/server-event-dispatcher.d.ts +26 -0
- package/dist/api/server-event-dispatcher.js +208 -0
- package/dist/api/server-extra-routes.d.ts +11 -0
- package/dist/api/server-extra-routes.js +206 -0
- package/dist/api/server-middleware.d.ts +20 -0
- package/dist/api/server-middleware.js +211 -0
- package/dist/api/server-routes.d.ts +19 -0
- package/dist/api/server-routes.js +299 -0
- package/dist/api/server-websocket-routes.d.ts +4 -0
- package/dist/api/server-websocket-routes.js +108 -0
- package/dist/api/server-wiring.d.ts +32 -0
- package/dist/api/server-wiring.js +238 -0
- package/dist/api/server.d.ts +10 -15
- package/dist/api/server.js +48 -1251
- package/dist/api/session-cookies.js +4 -4
- package/dist/api/sse-route.d.ts +2 -1
- package/dist/api/sse-route.js +27 -13
- package/dist/config/index.d.ts +3 -1
- package/dist/crypto/owner-transition-rekey.d.ts +5 -1
- package/dist/crypto/owner-transition-rekey.js +1 -1
- package/dist/crypto/pg-kms-adapter.d.ts +1 -0
- package/dist/crypto/pg-kms-adapter.js +12 -18
- package/dist/crypto/pii-field-encryption.d.ts +5 -1
- package/dist/crypto/pii-field-encryption.js +3 -1
- package/dist/db/aggregate-sql.d.ts +23 -0
- package/dist/db/aggregate-sql.js +165 -0
- package/dist/db/closed-connection.d.ts +9 -0
- package/dist/db/closed-connection.js +88 -0
- package/dist/db/connection.d.ts +4 -5
- package/dist/db/connection.js +29 -20
- package/dist/db/dialect.js +1 -1
- package/dist/db/distinct-on.d.ts +1 -1
- package/dist/db/driver-row-coercion.d.ts +2 -0
- package/dist/db/driver-row-coercion.js +186 -0
- package/dist/db/driver-value-preparation.d.ts +16 -0
- package/dist/db/driver-value-preparation.js +101 -0
- package/dist/db/entity-field-encryption.d.ts +1 -0
- package/dist/db/entity-field-encryption.js +1 -1
- package/dist/db/entity-table-meta.js +103 -110
- package/dist/db/event-store-executor-context.d.ts +2 -1
- package/dist/db/event-store-executor-read-aggregate-currencies.d.ts +17 -0
- package/dist/db/event-store-executor-read-aggregate-currencies.js +40 -0
- package/dist/db/event-store-executor-read-aggregate.d.ts +8 -0
- package/dist/db/event-store-executor-read-aggregate.js +143 -0
- package/dist/db/event-store-executor-read-filter.d.ts +31 -0
- package/dist/db/event-store-executor-read-filter.js +206 -0
- package/dist/db/event-store-executor-read-paging.d.ts +14 -0
- package/dist/db/event-store-executor-read-paging.js +99 -0
- package/dist/db/event-store-executor-read-rows.d.ts +6 -0
- package/dist/db/event-store-executor-read-rows.js +32 -0
- package/dist/db/event-store-executor-read-search.d.ts +28 -0
- package/dist/db/event-store-executor-read-search.js +221 -0
- package/dist/db/event-store-executor-read-sort.d.ts +41 -0
- package/dist/db/event-store-executor-read-sort.js +130 -0
- package/dist/db/event-store-executor-read-where.d.ts +24 -0
- package/dist/db/event-store-executor-read-where.js +81 -0
- package/dist/db/event-store-executor-read.d.ts +2 -9
- package/dist/db/event-store-executor-read.js +48 -701
- package/dist/db/event-store-executor-write-atomic.d.ts +4 -0
- package/dist/db/event-store-executor-write-atomic.js +41 -0
- package/dist/db/event-store-executor-write-steps.d.ts +17 -0
- package/dist/db/event-store-executor-write-steps.js +95 -0
- package/dist/db/event-store-executor-write.js +405 -509
- package/dist/db/event-store-executor.js +2 -1
- package/dist/db/executor-managed-tables.js +1 -1
- package/dist/db/index.d.ts +7 -3
- package/dist/db/index.js +6 -2
- package/dist/db/list-aggregate-labels.d.ts +14 -0
- package/dist/db/list-aggregate-labels.js +26 -0
- package/dist/db/migrate-generator.js +71 -86
- package/dist/db/migrate-runner.js +7 -4
- package/dist/db/pg-error.js +26 -21
- package/dist/db/queries/backfill-pii.js +3 -6
- package/dist/db/queries/database-now.js +2 -1
- package/dist/db/queries/shadow-swap.js +2 -3
- package/dist/db/query.d.ts +16 -15
- package/dist/db/query.js +76 -804
- package/dist/db/reference-data.js +19 -2
- package/dist/db/statement-timeout.js +2 -1
- package/dist/db/table-builder.js +113 -166
- package/dist/db/table-info.d.ts +10 -0
- package/dist/db/table-info.js +45 -0
- package/dist/db/temporal-value-guards.d.ts +6 -0
- package/dist/db/temporal-value-guards.js +15 -0
- package/dist/db/tenant-db-runner.d.ts +1 -0
- package/dist/db/tenant-db-runner.js +3 -0
- package/dist/db/tenant-db-upsert.d.ts +5 -0
- package/dist/db/tenant-db-upsert.js +91 -0
- package/dist/db/tenant-db.js +50 -10
- package/dist/db/where-clause.d.ts +6 -0
- package/dist/db/where-clause.js +236 -0
- package/dist/derivatives/delete-stored-file.js +2 -1
- package/dist/engine/boot-validator/boot-check.js +1 -1
- package/dist/engine/boot-validator/bundled-lists-table.d.ts +2 -0
- package/dist/engine/boot-validator/bundled-lists-table.js +36 -0
- package/dist/engine/boot-validator/detail-screens.js +2 -2
- package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
- package/dist/engine/boot-validator/entity-handler.js +17 -0
- package/dist/engine/boot-validator/entity-list-aggregate-options.d.ts +3 -0
- package/dist/engine/boot-validator/entity-list-aggregate-options.js +23 -0
- package/dist/engine/boot-validator/form-derivations.js +35 -1
- package/dist/engine/boot-validator/i18n-keys.js +5 -3
- package/dist/engine/boot-validator/index.js +2 -0
- package/dist/engine/boot-validator/list-bulk-actions.d.ts +3 -0
- package/dist/engine/boot-validator/list-bulk-actions.js +49 -0
- package/dist/engine/boot-validator/list-column-layout.d.ts +8 -0
- package/dist/engine/boot-validator/list-column-layout.js +41 -0
- package/dist/engine/boot-validator/list-table-aggregate-options.d.ts +24 -0
- package/dist/engine/boot-validator/list-table-aggregate-options.js +145 -0
- package/dist/engine/boot-validator/list-table-aggregate-query.d.ts +10 -0
- package/dist/engine/boot-validator/list-table-aggregate-query.js +31 -0
- package/dist/engine/boot-validator/list-table-export-options.d.ts +1 -0
- package/dist/engine/boot-validator/list-table-export-options.js +27 -0
- package/dist/engine/boot-validator/list-table-options.d.ts +3 -0
- package/dist/engine/boot-validator/list-table-options.js +77 -0
- package/dist/engine/boot-validator/list-table-reject-unknown-keys.d.ts +1 -0
- package/dist/engine/boot-validator/list-table-reject-unknown-keys.js +7 -0
- package/dist/engine/boot-validator/pii-retention.js +233 -155
- package/dist/engine/boot-validator/projection-list-screens.d.ts +1 -1
- package/dist/engine/boot-validator/projection-list-screens.js +3 -13
- package/dist/engine/boot-validator/related-list-table-rules.d.ts +4 -0
- package/dist/engine/boot-validator/related-list-table-rules.js +42 -0
- package/dist/engine/boot-validator/screens-actions.d.ts +1 -0
- package/dist/engine/boot-validator/screens-actions.js +8 -1
- package/dist/engine/boot-validator/screens-dashboard.js +2 -5
- package/dist/engine/boot-validator/screens-forms.js +2 -6
- package/dist/engine/boot-validator/screens-kind-config-edit.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-config-edit.js +88 -0
- package/dist/engine/boot-validator/screens-kind-entity-edit.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-entity-edit.js +55 -0
- package/dist/engine/boot-validator/screens-kind-entity-list.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-entity-list.js +235 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail.js +235 -0
- package/dist/engine/boot-validator/screens-kind-projection-list.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-projection-list.js +56 -0
- package/dist/engine/boot-validator/screens-kind-secret-mint.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-secret-mint.js +28 -0
- package/dist/engine/boot-validator/screens-kind-shared.d.ts +37 -0
- package/dist/engine/boot-validator/screens-kind-shared.js +142 -0
- package/dist/engine/boot-validator/screens-lists.d.ts +2 -1
- package/dist/engine/boot-validator/screens-lists.js +24 -11
- package/dist/engine/boot-validator/screens.d.ts +0 -2
- package/dist/engine/boot-validator/screens.js +99 -860
- package/dist/engine/build-app-schema.d.ts +2 -1
- package/dist/engine/build-app-schema.js +65 -97
- package/dist/engine/build-config-feature-schema.js +6 -1
- package/dist/engine/define-feature.js +13 -2
- package/dist/engine/define-handler.js +1 -0
- package/dist/engine/entity-handlers.d.ts +13 -0
- package/dist/engine/entity-handlers.js +10 -21
- package/dist/engine/entity-list-runtime-options.d.ts +8 -0
- package/dist/engine/entity-list-runtime-options.js +18 -0
- package/dist/engine/feature-ast/extractors/handlers.js +1 -0
- package/dist/engine/feature-ast/extractors/index.d.ts +1 -1
- package/dist/engine/feature-ast/extractors/index.js +1 -1
- package/dist/engine/feature-ast/extractors/round1.d.ts +2 -1
- package/dist/engine/feature-ast/extractors/round1.js +6 -0
- package/dist/engine/feature-ast/extractors/round2.js +25 -6
- package/dist/engine/feature-ast/index.d.ts +1 -1
- package/dist/engine/feature-ast/parse.js +3 -1
- package/dist/engine/feature-ast/patch.d.ts +2 -0
- package/dist/engine/feature-ast/patch.js +5 -182
- package/dist/engine/feature-ast/pattern-change-schema.d.ts +10 -245
- package/dist/engine/feature-ast/pattern-change-schema.js +10 -163
- package/dist/engine/feature-ast/pattern-id-matchers.d.ts +7 -0
- package/dist/engine/feature-ast/pattern-id-matchers.js +211 -0
- package/dist/engine/feature-ast/pattern-id-schema.d.ts +251 -0
- package/dist/engine/feature-ast/pattern-id-schema.js +166 -0
- package/dist/engine/feature-ast/patterns.d.ts +14 -1
- package/dist/engine/feature-ast/patterns.js +44 -51
- package/dist/engine/feature-ast/render.js +52 -87
- package/dist/engine/feature-builder-state.d.ts +1 -0
- package/dist/engine/feature-builder-state.js +1 -0
- package/dist/engine/feature-entity-handlers.js +3 -0
- package/dist/engine/feature-manifest.d.ts +1 -0
- package/dist/engine/feature-manifest.js +1 -0
- package/dist/engine/field-access.d.ts +1 -0
- package/dist/engine/field-access.js +12 -0
- package/dist/engine/form-derivations.js +18 -7
- package/dist/engine/handler-field-references.js +1 -1
- package/dist/engine/index.d.ts +2 -2
- package/dist/engine/index.js +1 -1
- package/dist/engine/pattern-library/library.js +2 -1
- package/dist/engine/pattern-library/static-schemas.d.ts +1 -0
- package/dist/engine/pattern-library/static-schemas.js +9 -0
- package/dist/engine/project-app-schema-for-roles.d.ts +2 -0
- package/dist/engine/project-app-schema-for-roles.js +6 -4
- package/dist/engine/registry-ingest.js +1 -1
- package/dist/engine/schema-builder.js +228 -212
- package/dist/engine/screen-filter-ops.js +2 -0
- package/dist/engine/screen-helpers.js +1 -1
- package/dist/engine/screen-kind.d.ts +7 -0
- package/dist/engine/screen-kind.js +1 -0
- package/dist/engine/strip-disabled-features-from-app-schema.js +58 -17
- package/dist/engine/types/feature.d.ts +1 -0
- package/dist/engine/types/index.d.ts +4 -3
- package/dist/engine/types/screen.d.ts +1 -1
- package/dist/engine/types/screen.js +1 -1
- package/dist/engine/validate-projection-allowlist.js +2 -1
- package/dist/entrypoint/index.d.ts +6 -1
- package/dist/entrypoint/index.js +10 -1
- package/dist/errors/docs-url.d.ts +1 -1
- package/dist/errors/docs-url.js +22 -2
- package/dist/es-ops/context.js +1 -1
- package/dist/event-store/admin-api.js +1 -1
- package/dist/event-store/event-store.d.ts +1 -0
- package/dist/event-store/event-store.js +17 -8
- package/dist/event-store/provenance-append.js +1 -1
- package/dist/files/bind-pending-file-refs.js +3 -3
- package/dist/files/create-file-ref-from-bytes.js +7 -1
- package/dist/files/create-file-ref.d.ts +3 -0
- package/dist/files/create-file-ref.js +11 -2
- package/dist/files/file-handle.js +2 -3
- package/dist/files/file-routes.d.ts +2 -0
- package/dist/files/file-routes.js +40 -10
- package/dist/files/provider-resolver.d.ts +1 -0
- package/dist/files/provider-resolver.js +1 -1
- package/dist/files/record-write-check.d.ts +6 -0
- package/dist/files/record-write-check.js +13 -0
- package/dist/files/resolve-content-type.js +43 -0
- package/dist/files/upload-ledger.d.ts +2 -2
- package/dist/files/upload-ledger.js +11 -4
- package/dist/i18n/required-surface-keys.js +189 -208
- package/dist/internal/stack-support.d.ts +2 -1
- package/dist/internal/stack-support.js +1 -1
- package/dist/internal/testing.js +1 -1
- package/dist/jobs/job-runner-context.d.ts +32 -0
- package/dist/jobs/job-runner-context.js +305 -0
- package/dist/jobs/job-runner-execution.d.ts +7 -0
- package/dist/jobs/job-runner-execution.js +160 -0
- package/dist/jobs/job-runner-gates.d.ts +19 -0
- package/dist/jobs/job-runner-gates.js +198 -0
- package/dist/jobs/job-runner-helpers.d.ts +17 -3
- package/dist/jobs/job-runner-helpers.js +61 -2
- package/dist/jobs/job-runner-scope.d.ts +44 -0
- package/dist/jobs/job-runner-scope.js +102 -0
- package/dist/jobs/job-runner-types.d.ts +12 -0
- package/dist/jobs/job-runner.d.ts +0 -1
- package/dist/jobs/job-runner.js +50 -657
- package/dist/observability/escape-hatch-report.d.ts +3 -0
- package/dist/observability/escape-hatch-report.js +21 -3
- package/dist/pipeline/after-rollback-sink.d.ts +6 -0
- package/dist/pipeline/after-rollback-sink.js +32 -0
- package/dist/pipeline/cascade-handler.js +165 -138
- package/dist/pipeline/dispatch-batch.js +8 -1
- package/dist/pipeline/dispatch-query.js +10 -3
- package/dist/pipeline/dispatch-shared.d.ts +13 -3
- package/dist/pipeline/dispatch-shared.js +62 -710
- package/dist/pipeline/dispatch-write.js +296 -189
- package/dist/pipeline/event-dispatcher-admin.js +2 -1
- package/dist/pipeline/event-dispatcher-delivery.js +6 -6
- package/dist/pipeline/event-dispatcher.d.ts +1 -0
- package/dist/pipeline/event-dispatcher.js +6 -9
- package/dist/pipeline/handler-context-auth.d.ts +9 -0
- package/dist/pipeline/handler-context-auth.js +54 -0
- package/dist/pipeline/handler-context-config.d.ts +14 -0
- package/dist/pipeline/handler-context-config.js +113 -0
- package/dist/pipeline/handler-context-db.d.ts +24 -0
- package/dist/pipeline/handler-context-db.js +149 -0
- package/dist/pipeline/handler-context-dispatch.d.ts +23 -0
- package/dist/pipeline/handler-context-dispatch.js +101 -0
- package/dist/pipeline/handler-context-events.d.ts +41 -0
- package/dist/pipeline/handler-context-events.js +239 -0
- package/dist/pipeline/handler-context-notify.d.ts +12 -0
- package/dist/pipeline/handler-context-notify.js +55 -0
- package/dist/pipeline/handler-context-observability.d.ts +7 -0
- package/dist/pipeline/handler-context-observability.js +21 -0
- package/dist/pipeline/handler-context-scope.d.ts +48 -0
- package/dist/pipeline/handler-context-scope.js +88 -0
- package/dist/pipeline/notify-scope.js +12 -1
- package/dist/pipeline/pre-handler-gates.js +20 -4
- package/dist/pipeline/pre-transaction-reservations.d.ts +1 -0
- package/dist/pipeline/pre-transaction-reservations.js +9 -3
- package/dist/pipeline/projection-rebuild.js +2 -1
- package/dist/pipeline/system-hooks.d.ts +3 -1
- package/dist/pipeline/system-hooks.js +55 -6
- package/dist/pipeline/write-result-masking.js +13 -10
- package/dist/schema-cli/apply-command.d.ts +2 -0
- package/dist/schema-cli/apply-command.js +97 -0
- package/dist/schema-cli/baseline-command.d.ts +2 -0
- package/dist/schema-cli/baseline-command.js +33 -0
- package/dist/schema-cli/generate-command.d.ts +2 -0
- package/dist/schema-cli/generate-command.js +90 -0
- package/dist/schema-cli/shared.d.ts +39 -0
- package/dist/schema-cli/shared.js +95 -0
- package/dist/schema-cli/status-command.d.ts +2 -0
- package/dist/schema-cli/status-command.js +73 -0
- package/dist/schema-cli/validate-boot-input.d.ts +5 -0
- package/dist/schema-cli/validate-boot-input.js +130 -0
- package/dist/schema-cli/validate-command.d.ts +2 -0
- package/dist/schema-cli/validate-command.js +130 -0
- package/dist/schema-cli.d.ts +2 -18
- package/dist/schema-cli.js +47 -604
- package/dist/search/meilisearch-adapter.js +2 -1
- package/dist/search/reindex-entity.js +15 -5
- package/dist/ui-types/index.d.ts +2 -2
- package/dist/ui-types/index.js +1 -1
- package/dist/upgrade-changelog.d.ts +2 -0
- package/dist/upgrade-changelog.js +14 -0
- package/dist/upgrade-cli.d.ts +3 -12
- package/dist/upgrade-cli.js +171 -197
- package/dist/upgrade-marker-parse.d.ts +32 -0
- package/dist/upgrade-marker-parse.js +73 -0
- package/package.json +9 -6
- package/src/changes.json +555 -0
- package/src/scripts/codemod/codemod-support.ts +1 -1
- package/src/scripts/codemod/db-factory.ts +1 -1
- package/src/scripts/codemod/feature-layout.ts +10 -2
- package/src/scripts/codemod/object-form.ts +41 -4
- package/src/scripts/codemod/package-merge.ts +58 -8
- package/src/scripts/codemod/pii-personal-migration.ts +175 -145
- package/src/scripts/codemod/testing-injection.ts +122 -42
- package/src/scripts/codemod/testing-move.ts +29 -7
- package/dist/engine/provider-plugin-context.d.ts +0 -3
- package/dist/engine/provider-plugin-context.js +0 -28
|
@@ -1,23 +1,62 @@
|
|
|
1
|
-
// Screen validation entry point. The
|
|
2
|
-
// siblings
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { rowMetaFieldNames } from "../../db/table-builder.js";
|
|
7
|
-
import { isEncryptedAtRest } from "../config-helpers.js";
|
|
1
|
+
// Screen validation entry point. The per-kind validators live in the
|
|
2
|
+
// screens-kind-*.ts siblings and the shared sub-validators in screens-dashboard/
|
|
3
|
+
// forms/lists/actions; dependencies only point one way (screens.ts ->
|
|
4
|
+
// screens-kind-*.ts -> screens-kind-shared.ts -> dashboard/forms/lists -> actions),
|
|
5
|
+
// so there is no same-folder require cycle.
|
|
8
6
|
import { qualifyEntityName } from "../qualified-name.js";
|
|
9
|
-
import {
|
|
10
|
-
import { isExtensionEditSection, isFieldsEditSection, isWriteFormEditSection, normalizeEditField, normalizeListColumn, sectionFieldSpecs, } from "../screen-helpers.js";
|
|
11
|
-
import { LIST_ROW_META_COLUMN_NAMES } from "./entity-list-screens.js";
|
|
12
|
-
import { isRowClickAction, rejectRedirectOnListRowAction, resolveRowActionNavigateTarget, validateActionFieldRefs, validateActionHasIcon, validateAtMostOneRowClick, validateClientActionName, validateDrawerTargetAction, validateNavigateActionTab, validatePrimaryActionTarget, validateRecordActionRedirect, validateRedirectTarget, validateRowActionNavigateParams, validateScreenVisibleWhen, } from "./screens-actions.js";
|
|
7
|
+
import { validateActionHasIcon, validateScreenVisibleWhen } from "./screens-actions.js";
|
|
13
8
|
import { validateDashboardActions, validateDashboardRecordBinding, validateDashboardScreen, } from "./screens-dashboard.js";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
9
|
+
import { validateInlineFormScreen } from "./screens-forms.js";
|
|
10
|
+
import { validateConfigEditScreen } from "./screens-kind-config-edit.js";
|
|
11
|
+
import { validateEntityEditScreen } from "./screens-kind-entity-edit.js";
|
|
12
|
+
import { validateEntityListScreen } from "./screens-kind-entity-list.js";
|
|
13
|
+
import { validateProjectionDetailScreen } from "./screens-kind-projection-detail.js";
|
|
14
|
+
import { validateProjectionListScreen } from "./screens-kind-projection-list.js";
|
|
15
|
+
import { validateSecretMintScreen } from "./screens-kind-secret-mint.js";
|
|
16
|
+
import { listActionContext } from "./screens-kind-shared.js";
|
|
17
|
+
import { validateExplicitListScreenExists, validateListActionTargets, validateScreenHasNavArea, } from "./screens-lists.js";
|
|
17
18
|
export { readsNavigateParamsAsFormPrefill, resolveScreenTargetQn, rowFieldExtractorKeys, validateActionFieldRefs, validateActionHasIcon, validateDrawerPrefillKeys, validateScreenShortIdCollisions, } from "./screens-actions.js";
|
|
18
19
|
export { validateDashboardCustomPanel, validateDashboardScreenPanel } from "./screens-dashboard.js";
|
|
19
20
|
export { validateColumnRendererForm } from "./screens-lists.js";
|
|
20
|
-
|
|
21
|
+
function validateCustomScreen(ctx, screenId, screen) {
|
|
22
|
+
if (!screen.renderer.react && !screen.renderer.native) {
|
|
23
|
+
throw new Error(`[Feature ${ctx.feature.name}] Screen "${screenId}" has type="custom" but the renderer ` +
|
|
24
|
+
`declares neither a react nor a native component — at least one platform must be set.`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function validateDashboardKindScreen(ctx, screenId, screen) {
|
|
28
|
+
validateDashboardScreen(ctx.feature.name, screenId, screen, ctx.featureMap);
|
|
29
|
+
validateDashboardRecordBinding(ctx.feature.name, screenId, screen);
|
|
30
|
+
validateDashboardActions(ctx.feature.name, screenId, screen, ctx.allWriteHandlerQns, ctx);
|
|
31
|
+
}
|
|
32
|
+
function validateActionFormScreen(ctx, screenId, screen) {
|
|
33
|
+
validateInlineFormScreen(ctx.feature, screenId, screen, "actionForm", ctx.allWriteHandlerQns, ctx, ctx.featureMap);
|
|
34
|
+
}
|
|
35
|
+
const SCREEN_KIND_VALIDATORS = {
|
|
36
|
+
custom: validateCustomScreen,
|
|
37
|
+
projectionList: validateProjectionListScreen,
|
|
38
|
+
projectionDetail: validateProjectionDetailScreen,
|
|
39
|
+
dashboard: validateDashboardKindScreen,
|
|
40
|
+
configEdit: validateConfigEditScreen,
|
|
41
|
+
actionForm: validateActionFormScreen,
|
|
42
|
+
secretMint: validateSecretMintScreen,
|
|
43
|
+
// secretsEdit is generator-only (buildConfigFeatureSchema) — never authored
|
|
44
|
+
// via r.screen, so feature.screens never actually carries one.
|
|
45
|
+
secretsEdit: () => { },
|
|
46
|
+
entityList: validateEntityListScreen,
|
|
47
|
+
entityEdit: validateEntityEditScreen,
|
|
48
|
+
};
|
|
49
|
+
function validateScreenOfKind(ctx, screenId, kind, screen) {
|
|
50
|
+
SCREEN_KIND_VALIDATORS[kind](ctx, screenId, screen);
|
|
51
|
+
}
|
|
52
|
+
// Only reachable by casting past ScreenDefinition; without this the table
|
|
53
|
+
// lookup would surface as a TypeError instead of a boot error.
|
|
54
|
+
function rejectUnknownScreenKind(featureName, screenId, screen) {
|
|
55
|
+
if (!Object.hasOwn(SCREEN_KIND_VALIDATORS, screen.type)) {
|
|
56
|
+
throw new Error(`[Feature ${featureName}] Screen "${screenId}" has unknown type "${String(screen.type)}".`);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
function buildScreenValidationContext(feature, featureMap, allWriteHandlerQns, allScreenQns, configKeyDefsByQn, screensByShortId, detailForScreens) {
|
|
21
60
|
// navigate targets (rowAction/toolbarAction) may point cross-feature: the
|
|
22
61
|
// runtime router (create-app) resolves a bare screenId app-wide across ALL
|
|
23
62
|
// features (a declarative list in the entity's owning feature navigates to
|
|
@@ -26,859 +65,59 @@ export function validateScreens(feature, featureMap, allWriteHandlerQns, allScre
|
|
|
26
65
|
// fully qualified cross-feature QN (resolveScreenTargetQn); short IDs
|
|
27
66
|
// stay same-feature as before.
|
|
28
67
|
const navTargetShortIds = screenShortIdsFrom(allScreenQns);
|
|
29
|
-
|
|
68
|
+
return {
|
|
69
|
+
feature,
|
|
70
|
+
featureMap,
|
|
71
|
+
allWriteHandlerQns,
|
|
72
|
+
configKeyDefsByQn,
|
|
30
73
|
allScreenQns,
|
|
31
74
|
navTargetShortIds,
|
|
32
75
|
screensByShortId,
|
|
33
76
|
detailForScreens,
|
|
34
77
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Output of buildAppSchema, which overwrites it — an authored value would be a silent no-op.
|
|
52
|
-
if ((screen.type === "entityEdit" ||
|
|
53
|
-
screen.type === "actionForm" ||
|
|
54
|
-
screen.type === "secretMint") &&
|
|
55
|
-
screen.urlPrefillFields !== undefined) {
|
|
56
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (${screen.type}) sets urlPrefillFields — ` +
|
|
57
|
-
`it is derived from navigate params by buildAppSchema; declare params on the navigating action instead.`);
|
|
58
|
-
}
|
|
59
|
-
if (screen.type !== "actionForm" &&
|
|
60
|
-
screen.type !== "secretMint" &&
|
|
61
|
-
"submitPrefilled" in screen &&
|
|
62
|
-
screen.submitPrefilled !== undefined) {
|
|
63
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (${screen.type}) sets submitPrefilled — ` +
|
|
64
|
-
`only actionForm and secretMint screens support it. Remove it.`);
|
|
65
|
-
}
|
|
66
|
-
validateScreenHasNavArea(feature, screenId, screen, featureMap);
|
|
67
|
-
validateScreenVisibleWhen(feature, screenId, screen, allScreenQns, featureMap);
|
|
68
|
-
if (screen.type === "custom") {
|
|
69
|
-
if (!screen.renderer.react && !screen.renderer.native) {
|
|
70
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" has type="custom" but the renderer ` +
|
|
71
|
-
`declares neither a react nor a native component — at least one platform must be set.`);
|
|
72
|
-
}
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (screen.type === "projectionList") {
|
|
76
|
-
// Query-driven, no entity, so only query + columns are checked (the
|
|
77
|
-
// column fields cannot be checked against an entity; they resolve
|
|
78
|
-
// against the projection rows at render time).
|
|
79
|
-
if (!screen.query || typeof screen.query !== "string") {
|
|
80
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionList) has empty or non-string query. Set query to a registered query name.`);
|
|
81
|
-
}
|
|
82
|
-
if (screen.columns.length === 0) {
|
|
83
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionList) has an empty columns list — ` +
|
|
84
|
-
`declare at least one column.`);
|
|
85
|
-
}
|
|
86
|
-
for (const col of screen.columns) {
|
|
87
|
-
const normalizedCol = normalizeListColumn(col);
|
|
88
|
-
validateColumnRendererForm(feature.name, screenId, normalizedCol);
|
|
89
|
-
rejectInertColumnSortable(feature.name, screenId, "projectionList", normalizedCol);
|
|
90
|
-
if (normalizedCol.refEntity !== undefined) {
|
|
91
|
-
assertRefTargetRegistered(`[Feature ${feature.name}] Screen "${screenId}" (projectionList)`, `column "${normalizedCol.field}" (refEntity)`, normalizedCol.refEntity, feature.name, featureMap);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Screen filter — field existence can't be checked without
|
|
95
|
-
// an entity (columns aren't a complete field inventory of the
|
|
96
|
-
// underlying query), so only pin the structure: "in" requires an
|
|
97
|
-
// array. Field validity is documented in the PR body.
|
|
98
|
-
if (screen.filter !== undefined &&
|
|
99
|
-
screen.filter.op === "in" &&
|
|
100
|
-
!Array.isArray(screen.filter.value)) {
|
|
101
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionList) filter.op "in" requires ` +
|
|
102
|
-
`filter.value to be a readonly array. Pass an array as filter.value.`);
|
|
103
|
-
}
|
|
104
|
-
if (screen.facets !== undefined) {
|
|
105
|
-
validateListFacets(`[Feature ${feature.name}] Screen "${screenId}" (projectionList)`, screen.facets, screen.columns, feature.name, featureMap);
|
|
106
|
-
}
|
|
107
|
-
if (screen.rowActions !== undefined) {
|
|
108
|
-
for (const action of screen.rowActions) {
|
|
109
|
-
rejectRedirectOnListRowAction(feature.name, screenId, "projectionList", action);
|
|
110
|
-
if (action.kind === "navigate") {
|
|
111
|
-
const target = resolveRowActionNavigateTarget(feature.name, screenId, "projectionList", "rowAction", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
112
|
-
validateRowActionNavigateParams(feature.name, screenId, "projectionList", undefined, action, target);
|
|
113
|
-
}
|
|
114
|
-
else if (action.kind === "drawer") {
|
|
115
|
-
validateDrawerTargetAction(feature.name, screenId, "projectionList", "rowAction", action, feature.screens);
|
|
116
|
-
}
|
|
117
|
-
else if (action.kind === "clientAction") {
|
|
118
|
-
validateClientActionName(feature.name, screenId, "projectionList", "rowAction", action);
|
|
119
|
-
}
|
|
120
|
-
else if (!allWriteHandlerQns.has(action.handler)) {
|
|
121
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionList) rowAction "${action.id}" ` +
|
|
122
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
123
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
validateAtMostOneRowClick(feature.name, screenId, "projectionList", screen.rowActions);
|
|
127
|
-
}
|
|
128
|
-
// Plain navigate toolbarActions (no tab) have no boot check yet.
|
|
129
|
-
if (screen.toolbarActions !== undefined) {
|
|
130
|
-
for (const action of screen.toolbarActions) {
|
|
131
|
-
if (action.kind === "drawer") {
|
|
132
|
-
validateDrawerTargetAction(feature.name, screenId, "projectionList", "toolbarAction", action, feature.screens);
|
|
133
|
-
}
|
|
134
|
-
else if (action.kind === "writeHandler" && !allWriteHandlerQns.has(action.handler)) {
|
|
135
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionList) toolbarAction "${action.id}" ` +
|
|
136
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
137
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
138
|
-
}
|
|
139
|
-
if (action.kind === "navigate" && action.tab !== undefined) {
|
|
140
|
-
resolveRowActionNavigateTarget(feature.name, screenId, "projectionList", "toolbarAction", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
if (screen.type === "projectionDetail") {
|
|
147
|
-
// Query-driven like projectionList, but a single row plus layout instead
|
|
148
|
-
// of columns. No entity check is possible: fields resolve against the
|
|
149
|
-
// query response at render time, not against an entity.
|
|
150
|
-
if (!screen.query || typeof screen.query !== "string") {
|
|
151
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) has empty or non-string query. Set query to a registered query name.`);
|
|
152
|
-
}
|
|
153
|
-
if (screen.singleton === true && screen.idParam !== undefined) {
|
|
154
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) sets both singleton: true ` +
|
|
155
|
-
`and idParam — singleton means the server picks the row from the caller's context, so there ` +
|
|
156
|
-
`is no row id to send under idParam. Remove idParam.`);
|
|
157
|
-
}
|
|
158
|
-
// singleton has no row id in the path, but the auto-generated "Edit"
|
|
159
|
-
// action (defaultEditAction in kumiko-screen.tsx) navigates
|
|
160
|
-
// to the detailFor entity's entityEdit screen using that path id —
|
|
161
|
-
// under singleton it would silently open that screen in CREATE mode
|
|
162
|
-
// instead of editing the singleton row. Reject rather than let that
|
|
163
|
-
// win silently, same as the idParam check above.
|
|
164
|
-
if (screen.singleton === true && screen.detailFor !== undefined) {
|
|
165
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) sets both singleton: true ` +
|
|
166
|
-
`and detailFor — the auto-generated "Edit" action navigates using the path's row id, which a ` +
|
|
167
|
-
`singleton screen never has. Remove detailFor, or declare an explicit "edit" action instead.`);
|
|
168
|
-
}
|
|
169
|
-
if (screen.recordTitleField !== undefined && screen.header !== undefined) {
|
|
170
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) sets both header and ` +
|
|
171
|
-
`recordTitleField — header.title already names the record, so drop recordTitleField.`);
|
|
172
|
-
}
|
|
173
|
-
if (screen.layout.sections.length === 0) {
|
|
174
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) has an empty sections list — ` +
|
|
175
|
-
`declare at least one section.`);
|
|
176
|
-
}
|
|
177
|
-
if (screen.layout.mode === "tabs") {
|
|
178
|
-
validateTabSections(feature.name, screenId, "projectionDetail", screen.layout.sections);
|
|
179
|
-
for (const section of screen.layout.sections) {
|
|
180
|
-
if (isFieldsEditSection(section) &&
|
|
181
|
-
"groups" in section &&
|
|
182
|
-
section.actions !== undefined) {
|
|
183
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.id}" ` +
|
|
184
|
-
`declares both groups and actions in tabs mode — actions has no single group's Card to sit ` +
|
|
185
|
-
`in, and an extra title-less Card around the group cards would nest a Card inside a Card. ` +
|
|
186
|
-
`Move the actions onto one group's title, or drop groups for a flat fields grid.`);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
if (screen.metrics !== undefined) {
|
|
191
|
-
for (const metric of screen.metrics) {
|
|
192
|
-
const field = metric.field;
|
|
193
|
-
if (typeof metric.label !== "string" || metric.label.length === 0) {
|
|
194
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) metric "${field}" has ` +
|
|
195
|
-
`no "label" — every metric needs an i18n label key, ` +
|
|
196
|
-
`there is no fallback to the raw column name.`);
|
|
197
|
-
}
|
|
198
|
-
const navigate = metric.navigate;
|
|
199
|
-
if (navigate !== undefined) {
|
|
200
|
-
if (navigate.screen === undefined && navigate.entity === undefined) {
|
|
201
|
-
if (navigate.tab !== undefined &&
|
|
202
|
-
!screen.layout.sections.some((section) => section.id === navigate.tab)) {
|
|
203
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) metric "${field}" ` +
|
|
204
|
-
`navigates to tab "${navigate.tab}", which is not a section id on this screen. Navigate to an existing section id or remove navigate.tab.`);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
// Also runs without `tab`: a typo'd screen/entity or an entity
|
|
209
|
-
// target without entityId would otherwise render a clickable
|
|
210
|
-
// metric that silently does nothing.
|
|
211
|
-
resolveRowActionNavigateTarget(feature.name, screenId, "projectionDetail", "metric", {
|
|
212
|
-
kind: "navigate",
|
|
213
|
-
id: field,
|
|
214
|
-
label: field,
|
|
215
|
-
...(navigate.screen !== undefined ? { screen: navigate.screen } : {}),
|
|
216
|
-
...(navigate.entity !== undefined ? { entity: navigate.entity } : {}),
|
|
217
|
-
...(navigate.entityId !== undefined ? { entityId: navigate.entityId } : {}),
|
|
218
|
-
...(navigate.tab !== undefined ? { tab: navigate.tab } : {}),
|
|
219
|
-
}, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
for (const [statusValue, tone] of Object.entries(screen.header?.statusTones ?? {})) {
|
|
225
|
-
if (!isSelectOptionTone(tone)) {
|
|
226
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) header.statusTones["${statusValue}"] ` +
|
|
227
|
-
`is "${String(tone)}" — expected one of ${SELECT_OPTION_TONES.join(", ")}.`);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
if (Array.isArray(screen.header?.subtitle)) {
|
|
231
|
-
if (screen.header.subtitleHref !== undefined) {
|
|
232
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) sets header.subtitleHref ` +
|
|
233
|
-
`together with a multi-part header.subtitle — subtitleHref only works with the string form. Use a single-field subtitle or remove subtitleHref.`);
|
|
234
|
-
}
|
|
235
|
-
const seenPartFields = new Set();
|
|
236
|
-
for (const part of screen.header.subtitle) {
|
|
237
|
-
const partField = typeof part === "string" ? part : part.field;
|
|
238
|
-
if (seenPartFields.has(partField)) {
|
|
239
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) header.subtitle ` +
|
|
240
|
-
`lists field "${partField}" twice. List each field once.`);
|
|
241
|
-
}
|
|
242
|
-
seenPartFields.add(partField);
|
|
243
|
-
const navigate = typeof part === "string" ? undefined : part.navigate;
|
|
244
|
-
if (navigate === undefined)
|
|
245
|
-
continue;
|
|
246
|
-
if (navigate.screen === undefined && navigate.entity === undefined) {
|
|
247
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) header.subtitle part ` +
|
|
248
|
-
`"${partField}" navigates with neither "screen" nor "entity" — a tab-only navigate has no link target.`);
|
|
249
|
-
}
|
|
250
|
-
resolveRowActionNavigateTarget(feature.name, screenId, "projectionDetail", "subtitle part", {
|
|
251
|
-
kind: "navigate",
|
|
252
|
-
id: partField,
|
|
253
|
-
label: partField,
|
|
254
|
-
...(navigate.screen !== undefined ? { screen: navigate.screen } : {}),
|
|
255
|
-
...(navigate.entity !== undefined ? { entity: navigate.entity } : {}),
|
|
256
|
-
...(navigate.entityId !== undefined ? { entityId: navigate.entityId } : {}),
|
|
257
|
-
...(navigate.tab !== undefined ? { tab: navigate.tab } : {}),
|
|
258
|
-
}, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
for (const section of screen.layout.sections) {
|
|
262
|
-
const sectionLabel = section.title ?? section.id ?? "(untitled)";
|
|
263
|
-
if (section.actions !== undefined) {
|
|
264
|
-
for (const action of section.actions) {
|
|
265
|
-
validateActionHasIcon(feature.name, screenId, "projectionDetail", `section "${sectionLabel}" action`, action);
|
|
266
|
-
validateRecordActionRedirect(feature, screenId, "projectionDetail", action, navigateLookups);
|
|
267
|
-
validateNavigateActionTab(feature.name, screenId, "projectionDetail", `section "${sectionLabel}" action`, action, navigateLookups);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
if (section.kind === "relatedList" && section.emptyState?.action !== undefined) {
|
|
271
|
-
validateActionHasIcon(feature.name, screenId, "projectionDetail", `section "${sectionLabel}" emptyState action`, section.emptyState.action);
|
|
272
|
-
validateListActionTargets({
|
|
273
|
-
featureName: feature.name,
|
|
274
|
-
screenId,
|
|
275
|
-
screenType: "projectionDetail",
|
|
276
|
-
screenEntity: undefined,
|
|
277
|
-
where: `Screen "${screenId}" (projectionDetail) section "${sectionLabel}"`,
|
|
278
|
-
screens: feature.screens,
|
|
279
|
-
allWriteHandlerQns,
|
|
280
|
-
...navigateLookups,
|
|
281
|
-
}, "emptyState action", section.emptyState.action);
|
|
282
|
-
}
|
|
283
|
-
if (isExtensionEditSection(section)) {
|
|
284
|
-
// projectionDetail is read-only (no composed form submit) — an
|
|
285
|
-
// extension that persists through the host's Save button has
|
|
286
|
-
// nothing to save against. Extensions that persist themselves
|
|
287
|
-
// (e.g. notes-history NotesSection, via their own dispatcher
|
|
288
|
-
// writes) are fine.
|
|
289
|
-
if (section.contributesToFormSubmit === true) {
|
|
290
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) extension section ` +
|
|
291
|
-
`"${section.title}" sets contributesToFormSubmit: true, but projectionDetail has no ` +
|
|
292
|
-
`form submit to contribute to (read-only screen). Omit contributesToFormSubmit and ` +
|
|
293
|
-
`persist through the extension's own dispatcher writes instead.`);
|
|
294
|
-
}
|
|
295
|
-
if (section.component?.react === undefined && section.component?.native === undefined) {
|
|
296
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) extension section ` +
|
|
297
|
-
`"${section.title}" has no component — declare a react/native component marker.`);
|
|
298
|
-
}
|
|
299
|
-
// The host-derived entity name on projectionDetail is an internal
|
|
300
|
-
// placeholder (no real entity backs this screen) — a self-
|
|
301
|
-
// persisting extension needs the real domain entity name declared
|
|
302
|
-
// explicitly, or it silently reads/writes against the wrong type.
|
|
303
|
-
if (section.entityName === undefined || section.entityName.trim().length === 0) {
|
|
304
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) extension section ` +
|
|
305
|
-
`"${section.title}" has no entityName — projectionDetail has no real entity, so the ` +
|
|
306
|
-
`extension must declare entityName explicitly (the domain entity it persists against).`);
|
|
307
|
-
}
|
|
308
|
-
continue;
|
|
309
|
-
}
|
|
310
|
-
if (section.kind === "relatedList") {
|
|
311
|
-
if (screen.layout.mode === "wizard") {
|
|
312
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
313
|
-
`is kind "relatedList" in a wizard layout — a read-only list is not supported in a ` +
|
|
314
|
-
`stepped form. Remove mode: "wizard" or drop the relatedList section.`);
|
|
315
|
-
}
|
|
316
|
-
validateRelatedListSection({
|
|
317
|
-
featureName: feature.name,
|
|
318
|
-
featureMap,
|
|
319
|
-
screenId,
|
|
320
|
-
screenType: "projectionDetail",
|
|
321
|
-
where: `Screen "${screenId}" (projectionDetail) section "${section.title}" (relatedList)`,
|
|
322
|
-
section,
|
|
323
|
-
screens: feature.screens,
|
|
324
|
-
allWriteHandlerQns,
|
|
325
|
-
allScreenQns,
|
|
326
|
-
navTargetShortIds,
|
|
327
|
-
screensByShortId,
|
|
328
|
-
detailForScreens,
|
|
329
|
-
});
|
|
330
|
-
continue;
|
|
331
|
-
}
|
|
332
|
-
if (isWriteFormEditSection(section)) {
|
|
333
|
-
if (Object.keys(section.fieldDefs).length === 0) {
|
|
334
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
335
|
-
`(writeForm) has an empty fieldDefs map — declare at least one field type.`);
|
|
336
|
-
}
|
|
337
|
-
if (section.fields.length === 0) {
|
|
338
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
339
|
-
`(writeForm) has zero fields — drop the section or add fields to it.`);
|
|
340
|
-
}
|
|
341
|
-
// A ref to a fieldDef the form never renders would never resolve.
|
|
342
|
-
const writeFormFieldNames = new Set(section.fields.map((f) => normalizeEditField(f).field));
|
|
343
|
-
for (const [defName, fdef] of Object.entries(section.fieldDefs)) {
|
|
344
|
-
validateFormSelectOptions(feature.name, screenId, `projectionDetail section "${section.title}" writeForm`, defName, fdef, writeFormFieldNames);
|
|
345
|
-
rejectWriteOnlyFormField(feature.name, screenId, `projectionDetail section "${section.title}" writeForm`, defName, fdef);
|
|
346
|
-
}
|
|
347
|
-
for (const f of section.fields) {
|
|
348
|
-
const fieldName = normalizeEditField(f).field;
|
|
349
|
-
if (section.fieldDefs[fieldName] === undefined) {
|
|
350
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
351
|
-
`(writeForm) field "${fieldName}" has no entry in fieldDefs — every rendered field needs ` +
|
|
352
|
-
`a type declared there. Add the field to fieldDefs.`);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
if (screen.layout.mode === "wizard") {
|
|
356
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
357
|
-
`is kind "writeForm" in a wizard layout — a self-persisting form is not supported in a ` +
|
|
358
|
-
`stepped form. Remove mode: "wizard" or drop the writeForm section.`);
|
|
359
|
-
}
|
|
360
|
-
if (!allWriteHandlerQns.has(section.handler)) {
|
|
361
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
|
|
362
|
-
`(writeForm) handler "${section.handler}" is not a registered write-handler. Check the QN ` +
|
|
363
|
-
`spelling (expected "<feature>:write:<short>") and that the handler is declared via ` +
|
|
364
|
-
`r.writeHandler(...).`);
|
|
365
|
-
}
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
validateFieldsXorGroups(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail)`, section);
|
|
369
|
-
for (const fieldSpec of sectionFieldSpecs(section)) {
|
|
370
|
-
const normalizedField = normalizeEditField(fieldSpec);
|
|
371
|
-
if (normalizedField.refEntity !== undefined) {
|
|
372
|
-
assertRefTargetRegistered(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail)`, `field "${normalizedField.field}" (refEntity)`, normalizedField.refEntity, feature.name, featureMap);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
// Header actions reuse RowAction (the displayed record stands in for
|
|
377
|
-
// the row), so the same navigate/writeHandler existence checks as
|
|
378
|
-
// entityList/projectionList apply. `rowClick` is rejected outright —
|
|
379
|
-
// a detail screen has no row to click.
|
|
380
|
-
validatePrimaryActionTarget(feature.name, screenId, screen);
|
|
381
|
-
if (screen.actions !== undefined) {
|
|
382
|
-
for (const action of screen.actions) {
|
|
383
|
-
validateActionHasIcon(feature.name, screenId, "projectionDetail", "action", action);
|
|
384
|
-
validateRecordActionRedirect(feature, screenId, "projectionDetail", action, navigateLookups);
|
|
385
|
-
if (isRowClickAction(action)) {
|
|
386
|
-
throw new Error(`[Feature ${feature.name}] Screen "${qualifyEntityName(feature.name, "screen", screenId)}" ` +
|
|
387
|
-
`(projectionDetail) action "${action.id}" sets rowClick: true — there is no row to ` +
|
|
388
|
-
`click on a detail screen. Remove rowClick.`);
|
|
389
|
-
}
|
|
390
|
-
if (action.kind === "navigate") {
|
|
391
|
-
const target = resolveRowActionNavigateTarget(feature.name, screenId, "projectionDetail", "action", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
392
|
-
validateRowActionNavigateParams(feature.name, screenId, "projectionDetail", screen.detailFor, action, target);
|
|
393
|
-
}
|
|
394
|
-
else if (action.kind === "drawer") {
|
|
395
|
-
validateDrawerTargetAction(feature.name, screenId, "projectionDetail", "action", action, feature.screens);
|
|
396
|
-
}
|
|
397
|
-
else if (action.kind === "clientAction") {
|
|
398
|
-
validateClientActionName(feature.name, screenId, "projectionDetail", "action", action);
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
if (!allWriteHandlerQns.has(action.handler)) {
|
|
402
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (projectionDetail) action "${action.id}" ` +
|
|
403
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
404
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
continue;
|
|
410
|
-
}
|
|
411
|
-
if (screen.type === "dashboard") {
|
|
412
|
-
validateDashboardScreen(feature.name, screenId, screen, featureMap);
|
|
413
|
-
validateDashboardRecordBinding(feature.name, screenId, screen);
|
|
414
|
-
validateDashboardActions(feature.name, screenId, screen, allWriteHandlerQns, {
|
|
415
|
-
allScreenQns,
|
|
416
|
-
navTargetShortIds,
|
|
417
|
-
screensByShortId,
|
|
418
|
-
detailForScreens,
|
|
419
|
-
});
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
if (screen.type === "configEdit") {
|
|
423
|
-
// Validate configEdit layout and fields like actionForm, then verify that
|
|
424
|
-
// every qualified config key is registered and its scope matches the key.
|
|
425
|
-
const fieldNames = new Set(Object.keys(screen.fields));
|
|
426
|
-
if (fieldNames.size === 0) {
|
|
427
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) has empty fields map — ` +
|
|
428
|
-
`declare at least one field.`);
|
|
429
|
-
}
|
|
430
|
-
for (const [fname, fdef] of Object.entries(screen.fields)) {
|
|
431
|
-
// @cast-boundary schema-walk — feature-config inspection
|
|
432
|
-
const ftype = fdef.type;
|
|
433
|
-
if (typeof ftype !== "string" || ftype.length === 0) {
|
|
434
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) field "${fname}" has no ` +
|
|
435
|
-
`\`type\` set. Each field must declare a type (e.g. "text", "number", "select").`);
|
|
436
|
-
}
|
|
437
|
-
validateFormSelectOptions(feature.name, screenId, "configEdit", fname, fdef, fieldNames);
|
|
438
|
-
}
|
|
439
|
-
if (screen.layout.sections.length === 0) {
|
|
440
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) has an empty sections list — ` +
|
|
441
|
-
`declare at least one section.`);
|
|
442
|
-
}
|
|
443
|
-
for (const section of screen.layout.sections) {
|
|
444
|
-
if (isExtensionEditSection(section)) {
|
|
445
|
-
if (section.component?.react === undefined && section.component?.native === undefined) {
|
|
446
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) extension section ` +
|
|
447
|
-
`"${section.title}" has no component — declare a react/native component marker.`);
|
|
448
|
-
}
|
|
449
|
-
continue;
|
|
450
|
-
}
|
|
451
|
-
if (section.kind === "relatedList") {
|
|
452
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) relatedList section ` +
|
|
453
|
-
`"${section.title}" is not supported — relatedList is a projectionDetail-only ` +
|
|
454
|
-
`primitive (fw#2166). Move the section to a projectionDetail screen or remove it.`);
|
|
455
|
-
}
|
|
456
|
-
if (isWriteFormEditSection(section)) {
|
|
457
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) writeForm section ` +
|
|
458
|
-
`"${section.title}" is not supported — writeForm is a projectionDetail-only primitive. Move the section to a projectionDetail screen or remove it.`);
|
|
459
|
-
}
|
|
460
|
-
validateFieldsXorGroups(`[Feature ${feature.name}] Screen "${screenId}" (configEdit)`, section);
|
|
461
|
-
for (const fieldSpec of sectionFieldSpecs(section)) {
|
|
462
|
-
const normalized = normalizeEditField(fieldSpec);
|
|
463
|
-
if (!fieldNames.has(normalized.field)) {
|
|
464
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) layout references unknown ` +
|
|
465
|
-
`field "${normalized.field}". Known fields: ${[...fieldNames].sort().join(", ")}`);
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
validateWizardLayout(feature.name, screenId, "configEdit", screen.layout, featureMap);
|
|
470
|
-
for (const fname of Object.keys(screen.secretKeys ?? {})) {
|
|
471
|
-
if (!fieldNames.has(fname)) {
|
|
472
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) secretKeys names unknown field "${fname}".`);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
// configKeys: every fieldName must have a mapping entry, and every
|
|
476
|
-
// qualified key must exist in the registry.
|
|
477
|
-
for (const fname of fieldNames) {
|
|
478
|
-
const secretQn = screen.secretKeys?.[fname];
|
|
479
|
-
if (secretQn !== undefined) {
|
|
480
|
-
validateConfigEditSecretField(feature.name, screen, fname, secretQn, featureMap);
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
const qualified = screen.configKeys[fname];
|
|
484
|
-
if (qualified === undefined) {
|
|
485
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) field "${fname}" has ` +
|
|
486
|
-
`no entry in the configKeys map. Every declared field needs a mapping to a ` +
|
|
487
|
-
`qualified config key (\`<feature>:config:<short>\`). Add one to configKeys.`);
|
|
488
|
-
}
|
|
489
|
-
const configKeyDef = configKeyDefsByQn.get(qualified);
|
|
490
|
-
if (configKeyDef === undefined) {
|
|
491
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) field "${fname}" → ` +
|
|
492
|
-
`Config key "${qualified}" is not declared in any feature registry. Typo? ` +
|
|
493
|
-
`Expected format: "<feature>:config:<short>". Known keys: ${[...configKeyDefsByQn.keys()].sort().join(", ") || "(none)"}`);
|
|
494
|
-
}
|
|
495
|
-
if (isWriteOnlyField(screen.fields[fname]) && !isEncryptedAtRest(configKeyDef)) {
|
|
496
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (configEdit) field "${fname}" declares writeOnly ` +
|
|
497
|
-
`but config key "${qualified}" is not encrypted at rest — writeOnly on a configEdit field ` +
|
|
498
|
-
`only hides a stored secret (declare the key with encrypted: true or backing: "secrets").`);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
continue;
|
|
502
|
-
}
|
|
503
|
-
if (screen.type === "actionForm") {
|
|
504
|
-
validateInlineFormScreen(feature, screenId, screen, "actionForm", allWriteHandlerQns, navigateLookups, featureMap);
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
if (screen.type === "secretMint") {
|
|
508
|
-
validateInlineFormScreen(feature, screenId, screen, "secretMint", allWriteHandlerQns, navigateLookups, featureMap);
|
|
509
|
-
if (screen.reveal.fields.length === 0) {
|
|
510
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (secretMint) has an empty reveal.fields ` +
|
|
511
|
-
`list — declare at least one field to reveal.`);
|
|
512
|
-
}
|
|
513
|
-
const revealFieldNames = new Set();
|
|
514
|
-
for (const revealField of screen.reveal.fields) {
|
|
515
|
-
if (typeof revealField.field !== "string" || revealField.field.trim() === "") {
|
|
516
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (secretMint) has a reveal.fields entry ` +
|
|
517
|
-
`with an empty or non-string "field". Set field to a non-empty string.`);
|
|
518
|
-
}
|
|
519
|
-
if (revealFieldNames.has(revealField.field)) {
|
|
520
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (secretMint) reveal.fields has a ` +
|
|
521
|
-
`duplicate field "${revealField.field}" — each revealed field must be unique.`);
|
|
522
|
-
}
|
|
523
|
-
revealFieldNames.add(revealField.field);
|
|
524
|
-
if (typeof revealField.label !== "string" || revealField.label.trim() === "") {
|
|
525
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (secretMint) reveal.fields entry ` +
|
|
526
|
-
`"${revealField.field}" has an empty or non-string "label". Set label to a non-empty string.`);
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
validateSecretMintConfirm(feature, screenId, screen, allWriteHandlerQns);
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
// secretsEdit is generator-only (buildConfigFeatureSchema) — never
|
|
533
|
-
// authored via r.screen, so feature.screens never actually carries one.
|
|
534
|
-
// Kept here only so this loop's type narrowing stays exhaustive.
|
|
535
|
-
if (screen.type === "secretsEdit")
|
|
536
|
-
continue;
|
|
537
|
-
// entityList / entityEdit: entity-refs are feature-local.
|
|
538
|
-
const entityDef = feature.entities?.[screen.entity];
|
|
539
|
-
if (!entityDef) {
|
|
540
|
-
const known = Object.keys(feature.entities ?? {})
|
|
541
|
-
.sort()
|
|
542
|
-
.join(", ") || "(none)";
|
|
543
|
-
const crossFeature = findEntityFeature(screen.entity, featureMap);
|
|
544
|
-
const hint = crossFeature
|
|
545
|
-
? ` Entity "${screen.entity}" is owned by feature "${crossFeature}" — cross-feature screen ownership is not supported.`
|
|
546
|
-
: "";
|
|
547
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" references entity "${screen.entity}" ` +
|
|
548
|
-
`which is not declared in this feature (known: ${known}).${hint}`);
|
|
549
|
-
}
|
|
550
|
-
const fieldNames = new Set(Object.keys(entityDef.fields));
|
|
551
|
-
// List columns may also name a read-time derived field (not a stored
|
|
552
|
-
// column). Allowed for display; deliberately NOT added to `fieldNames`, so
|
|
553
|
-
// defaultSort/filter on a derived field still fails — server-side sort over
|
|
554
|
-
// a non-column is a silent no-op (see DerivedFieldDef).
|
|
555
|
-
const columnFieldNames = entityDef.derivedFields !== undefined
|
|
556
|
-
? new Set([...fieldNames, ...Object.keys(entityDef.derivedFields)])
|
|
557
|
-
: fieldNames;
|
|
558
|
-
const rowMeta = rowMetaFieldNames(entityDef.softDelete ?? false);
|
|
559
|
-
if (screen.type === "entityList") {
|
|
560
|
-
// Empty column list would render as a blank table — almost always the
|
|
561
|
-
// sign of an in-progress screen the author forgot to fill in. Fail
|
|
562
|
-
// loud: ui-core's computeListViewModel can't do anything useful with
|
|
563
|
-
// zero columns either.
|
|
564
|
-
if (screen.columns.length === 0) {
|
|
565
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) has an empty columns list — ` +
|
|
566
|
-
`declare at least one column.`);
|
|
567
|
-
}
|
|
568
|
-
for (const col of screen.columns) {
|
|
569
|
-
const normalized = normalizeListColumn(col);
|
|
570
|
-
// A row-meta column (id/tenantId/version/insertedAt/modifiedAt/...) is a
|
|
571
|
-
// real DB column without being a declared entity field — e.g. a
|
|
572
|
-
// SystemAdmin cross-tenant list exposing tenantId. Accept it like a
|
|
573
|
-
// regular field name — but only the columns computeListViewModel can
|
|
574
|
-
// actually render (LIST_ROW_META_COLUMN_NAMES), not the wider
|
|
575
|
-
// softDelete-aware rowMeta set used below for payload/visible refs.
|
|
576
|
-
//
|
|
577
|
-
// A virtual presentational column (drawn by a columnRenderer component
|
|
578
|
-
// from the row, e.g. tag chips) needs BOTH a label AND a renderer —
|
|
579
|
-
// renderer is what actually makes it "virtual" (label alone still
|
|
580
|
-
// needs list.ts's virtual-branch to have something to draw; without
|
|
581
|
-
// a renderer the column would render nothing). A column with neither
|
|
582
|
-
// matching a real field/row-meta column NOR a renderer is a typo worth
|
|
583
|
-
// failing the boot.
|
|
584
|
-
if (!columnFieldNames.has(normalized.field) &&
|
|
585
|
-
!LIST_ROW_META_COLUMN_NAMES.has(normalized.field) &&
|
|
586
|
-
!(normalized.label !== undefined && normalized.renderer !== undefined)) {
|
|
587
|
-
throw new Error(buildUnknownFieldMessage(feature.name, screenId, normalized.field, screen.entity, columnFieldNames));
|
|
588
|
-
}
|
|
589
|
-
validateColumnRendererForm(feature.name, screenId, normalized);
|
|
590
|
-
rejectInertColumnSortable(feature.name, screenId, "entityList", normalized);
|
|
591
|
-
if (normalized.refEntity !== undefined) {
|
|
592
|
-
assertRefTargetRegistered(`[Feature ${feature.name}] Screen "${screenId}" (entityList)`, `column "${normalized.field}" (refEntity)`, normalized.refEntity, feature.name, featureMap);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
// Validate pagination, sorting, and search at boot so authoring errors
|
|
596
|
-
// fail before runtime debugging of empty or incorrectly sorted lists.
|
|
597
|
-
if (screen.pageSize !== undefined && screen.pageSize <= 0) {
|
|
598
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) has pageSize=${screen.pageSize} — ` +
|
|
599
|
-
`must be a positive integer.`);
|
|
600
|
-
}
|
|
601
|
-
if (screen.defaultSort !== undefined) {
|
|
602
|
-
const sortField = screen.defaultSort.field;
|
|
603
|
-
if (!fieldNames.has(sortField)) {
|
|
604
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) defaultSort references unknown ` +
|
|
605
|
-
`field "${sortField}". Known fields: ${[...fieldNames].sort().join(", ")}`);
|
|
606
|
-
}
|
|
607
|
-
// `sortable: true` is required so the UI never sorts on a column that has
|
|
608
|
-
// no server-side DB index or that the schema deliberately keeps unsortable
|
|
609
|
-
// (audit fields, computed values). `sortable` currently
|
|
610
|
-
// exists only on TextFieldDef; the `in` narrowing also permits other
|
|
611
|
-
// field types without an explicit flag, which is acceptable because
|
|
612
|
-
// Number/Date fields are naturally sortable. Authors can mark them
|
|
613
|
-
// sortable when their field type supports it.
|
|
614
|
-
const fieldDef = entityDef.fields[sortField];
|
|
615
|
-
const isSortable = fieldDef !== undefined && "sortable" in fieldDef && fieldDef.sortable === true;
|
|
616
|
-
if (!isSortable) {
|
|
617
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) defaultSort.field "${sortField}" ` +
|
|
618
|
-
`is not sortable. Set sortable: true on the field definition or pick another field.`);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
if (screen.createScreen !== undefined &&
|
|
622
|
-
!Object.hasOwn(feature.screens, screen.createScreen)) {
|
|
623
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) createScreen ` +
|
|
624
|
-
`"${screen.createScreen}" does not resolve to a registered screen in this feature. ` +
|
|
625
|
-
`Known screens in this feature: ${Object.keys(feature.screens).sort().join(", ") || "(none)"}.`);
|
|
626
|
-
}
|
|
627
|
-
// Screen filters are checked in three layers:
|
|
628
|
-
// 1) The field exists on the entity; a typo would otherwise produce an
|
|
629
|
-
// empty list instead of a clear boot failure.
|
|
630
|
-
// 2) The field has `filterable: true`, preventing accidental filtering
|
|
631
|
-
// of audit, computed, or encrypted fields.
|
|
632
|
-
// 3) The operation matches the field type, so lt/gt on text fields
|
|
633
|
-
// fails at boot instead of causing surprising runtime behavior.
|
|
634
|
-
// Additionally, "in" requires a readonly array.
|
|
635
|
-
if (screen.filter !== undefined) {
|
|
636
|
-
const filterField = screen.filter.field;
|
|
637
|
-
if (!fieldNames.has(filterField)) {
|
|
638
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) filter references unknown ` +
|
|
639
|
-
`field "${filterField}". Known fields: ${[...fieldNames].sort().join(", ")}`);
|
|
640
|
-
}
|
|
641
|
-
if (!isListFilterAllowed(entityDef, filterField, screen.filter)) {
|
|
642
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) filter references field ` +
|
|
643
|
-
`"${filterField}" which is encrypted, personal or secret, so the list handler rejects ` +
|
|
644
|
-
`this filter at runtime. Only op "eq" works on a personal field with find: "exact" or ` +
|
|
645
|
-
`"fuzzy"; otherwise drop the filter or filter on another field.`);
|
|
646
|
-
}
|
|
647
|
-
const fieldDef = entityDef.fields[filterField];
|
|
648
|
-
if (fieldDef !== undefined && !isFieldFilterable(fieldDef)) {
|
|
649
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) filter references field ` +
|
|
650
|
-
`"${filterField}" which is not filterable. Set filterable: true on the field ` +
|
|
651
|
-
`definition or pick another field.`);
|
|
652
|
-
}
|
|
653
|
-
if (fieldDef !== undefined) {
|
|
654
|
-
const allowedOps = getAllowedFilterOps(fieldDef);
|
|
655
|
-
if (!allowedOps.includes(screen.filter.op)) {
|
|
656
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) filter.op ` +
|
|
657
|
-
`"${screen.filter.op}" is not allowed on field "${filterField}" ` +
|
|
658
|
-
`(type "${fieldDef.type}"). Allowed ops: ${allowedOps.join(", ") || "(none)"}.`);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
if (screen.filter.op === "in" && !Array.isArray(screen.filter.value)) {
|
|
662
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) filter.op "in" requires ` +
|
|
663
|
-
`filter.value to be a readonly array. Pass an array as filter.value.`);
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
// Pin rowActions at boot: a navigate target must exist in the same feature
|
|
667
|
-
// and a writeHandler QN must be registered. Typos would otherwise only
|
|
668
|
-
// surface on the first click as "Screen not found" or a 404.
|
|
669
|
-
if (screen.rowActions !== undefined) {
|
|
670
|
-
for (const action of screen.rowActions) {
|
|
671
|
-
rejectRedirectOnListRowAction(feature.name, screenId, "entityList", action);
|
|
672
|
-
if (action.kind === "navigate") {
|
|
673
|
-
const target = resolveRowActionNavigateTarget(feature.name, screenId, "entityList", "rowAction", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
674
|
-
// The renderer's default-entityId fallback (row["id"]) only fires
|
|
675
|
-
// for a same-feature entityEdit target — it can't safely guess
|
|
676
|
-
// the id for a screen owned by a different feature. Cross-feature
|
|
677
|
-
// + entityEdit therefore MUST set an explicit entityId, or the
|
|
678
|
-
// edit screen silently opens with no entity context at runtime.
|
|
679
|
-
// Entity-targets are exempt: the renderer always
|
|
680
|
-
// supplies an id for them (explicit entityId, else row["id"]),
|
|
681
|
-
// regardless of which feature the resolved detailFor screen
|
|
682
|
-
// belongs to.
|
|
683
|
-
if (action.screen !== undefined &&
|
|
684
|
-
target !== undefined &&
|
|
685
|
-
target.featureName !== feature.name &&
|
|
686
|
-
target.screen.type === "entityEdit" &&
|
|
687
|
-
action.entityId === undefined) {
|
|
688
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) rowAction "${action.id}" ` +
|
|
689
|
-
`navigates cross-feature to entityEdit screen "${action.screen}" (feature ` +
|
|
690
|
-
`"${target.featureName}") without an explicit entityId field — the renderer's ` +
|
|
691
|
-
`same-feature row["id"] fallback does not apply across features. Set entityId to ` +
|
|
692
|
-
`the row field that names the target entity's id.`);
|
|
693
|
-
}
|
|
694
|
-
// params only have a reader in actionForm and entityEdit-CREATE;
|
|
695
|
-
// on projectionDetail/dashboard/configEdit/entityEdit-update they
|
|
696
|
-
// are silently ignored at runtime. `custom` is deliberately
|
|
697
|
-
// exempt: it renders an app-registered component the framework
|
|
698
|
-
// has no visibility into — the author may read nav.searchParams
|
|
699
|
-
// directly (real example: publicstatus's MonitorDetailScreen
|
|
700
|
-
// does exactly that), so flagging it would be a false positive
|
|
701
|
-
// on working code, not a caught bug.
|
|
702
|
-
//
|
|
703
|
-
// Whether an entityEdit target lands in create or update mode is
|
|
704
|
-
// decided by the same rule the renderer's runNavigate() uses: an
|
|
705
|
-
// explicit entityId always forces update mode, and (absent an
|
|
706
|
-
// explicit entityId) a same-entity target gets row["id"] auto-
|
|
707
|
-
// injected — only a cross-entity target with no explicit
|
|
708
|
-
// entityId reaches create.
|
|
709
|
-
validateRowActionNavigateParams(feature.name, screenId, "entityList", screen.entity, action, target);
|
|
710
|
-
}
|
|
711
|
-
else if (action.kind === "drawer") {
|
|
712
|
-
validateDrawerTargetAction(feature.name, screenId, "entityList", "rowAction", action, feature.screens);
|
|
713
|
-
}
|
|
714
|
-
else if (action.kind === "clientAction") {
|
|
715
|
-
validateClientActionName(feature.name, screenId, "entityList", "rowAction", action);
|
|
716
|
-
}
|
|
717
|
-
else {
|
|
718
|
-
if (!allWriteHandlerQns.has(action.handler)) {
|
|
719
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) rowAction "${action.id}" ` +
|
|
720
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
721
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
validateActionFieldRefs(feature.name, screenId, "rowAction", action.id, action, fieldNames, rowMeta);
|
|
725
|
-
}
|
|
726
|
-
validateAtMostOneRowClick(feature.name, screenId, "entityList", screen.rowActions);
|
|
727
|
-
}
|
|
728
|
-
// toolbarActions, analogous to rowActions: misspelled navigate targets and
|
|
729
|
-
// unregistered writeHandler QNs fail at boot instead of on the first click.
|
|
730
|
-
if (screen.toolbarActions !== undefined) {
|
|
731
|
-
for (const action of screen.toolbarActions) {
|
|
732
|
-
if (action.kind === "navigate") {
|
|
733
|
-
const candidateQn = qualifyEntityName(feature.name, "screen", action.screen);
|
|
734
|
-
if (!allScreenQns.has(candidateQn) && !navTargetShortIds.has(action.screen)) {
|
|
735
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) toolbarAction "${action.id}" ` +
|
|
736
|
-
`navigate-target "${action.screen}" does not resolve to a registered screen in any feature. Use "<feature>:screen:<id>" of an existing screen.`);
|
|
737
|
-
}
|
|
738
|
-
if (action.tab !== undefined) {
|
|
739
|
-
resolveRowActionNavigateTarget(feature.name, screenId, "entityList", "toolbarAction", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
else if (action.kind === "drawer") {
|
|
743
|
-
validateDrawerTargetAction(feature.name, screenId, "entityList", "toolbarAction", action, feature.screens);
|
|
744
|
-
}
|
|
745
|
-
else {
|
|
746
|
-
if (!allWriteHandlerQns.has(action.handler)) {
|
|
747
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityList) toolbarAction "${action.id}" ` +
|
|
748
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
749
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
validateActionFieldRefs(feature.name, screenId, "toolbarAction", action.id, action, fieldNames, rowMeta);
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
if (screen.expandableRow !== undefined) {
|
|
756
|
-
const expandableRow = screen.expandableRow;
|
|
757
|
-
validateRelatedListSection({
|
|
758
|
-
featureName: feature.name,
|
|
759
|
-
featureMap,
|
|
760
|
-
screenId,
|
|
761
|
-
screenType: "entityList expandableRow",
|
|
762
|
-
where: `Screen "${screenId}" (entityList) expandableRow "${expandableRow.title}"`,
|
|
763
|
-
section: expandableRow,
|
|
764
|
-
screens: feature.screens,
|
|
765
|
-
allWriteHandlerQns,
|
|
766
|
-
allScreenQns,
|
|
767
|
-
navTargetShortIds,
|
|
768
|
-
screensByShortId,
|
|
769
|
-
detailForScreens,
|
|
770
|
-
});
|
|
771
|
-
// Toolbar actions of the expansion evaluate against the host row.
|
|
772
|
-
for (const action of expandableRow.toolbarActions ?? []) {
|
|
773
|
-
validateActionFieldRefs(feature.name, screenId, "toolbarAction", action.id, action, fieldNames, rowMeta);
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
}
|
|
777
|
-
else {
|
|
778
|
-
// Same rationale as the columns check: an entityEdit layout with zero
|
|
779
|
-
// sections (or sections without any fields) renders as nothing — reject
|
|
780
|
-
// at boot so the author sees it before the blank form surprises them.
|
|
781
|
-
if (screen.layout.sections.length === 0) {
|
|
782
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) has an empty sections list — ` +
|
|
783
|
-
`declare at least one section.`);
|
|
784
|
-
}
|
|
785
|
-
for (const section of screen.layout.sections) {
|
|
786
|
-
if (section.actions !== undefined) {
|
|
787
|
-
const sectionLabel = section.title ?? section.id ?? "(untitled)";
|
|
788
|
-
for (const action of section.actions) {
|
|
789
|
-
validateActionHasIcon(feature.name, screenId, "entityEdit", `section "${sectionLabel}" action`, action);
|
|
790
|
-
validateRecordActionRedirect(feature, screenId, "entityEdit", action, navigateLookups);
|
|
791
|
-
validateNavigateActionTab(feature.name, screenId, "entityEdit", `section "${sectionLabel}" action`, action, navigateLookups);
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
if (isExtensionEditSection(section)) {
|
|
795
|
-
if (section.component?.react === undefined && section.component?.native === undefined) {
|
|
796
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) extension section ` +
|
|
797
|
-
`"${section.title}" has no component — declare a react/native component marker.`);
|
|
798
|
-
}
|
|
799
|
-
continue;
|
|
800
|
-
}
|
|
801
|
-
if (section.kind === "relatedList") {
|
|
802
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) relatedList section ` +
|
|
803
|
-
`"${section.title}" is not supported — relatedList is a projectionDetail-only ` +
|
|
804
|
-
`primitive (fw#2166). Move the section to a projectionDetail screen or remove it.`);
|
|
805
|
-
}
|
|
806
|
-
if (isWriteFormEditSection(section)) {
|
|
807
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) writeForm section ` +
|
|
808
|
-
`"${section.title}" is not supported — writeForm is a projectionDetail-only primitive. Move the section to a projectionDetail screen or remove it.`);
|
|
809
|
-
}
|
|
810
|
-
validateFieldsXorGroups(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit)`, section);
|
|
811
|
-
for (const fieldSpec of sectionFieldSpecs(section)) {
|
|
812
|
-
const normalized = normalizeEditField(fieldSpec);
|
|
813
|
-
if (!fieldNames.has(normalized.field)) {
|
|
814
|
-
throw new Error(buildUnknownFieldMessage(feature.name, screenId, normalized.field, screen.entity, fieldNames));
|
|
815
|
-
}
|
|
816
|
-
validateNoWidgetRequiredField(feature.name, screenId, entityDef, normalized);
|
|
817
|
-
validateEditFieldExtras(feature.name, screenId, entityDef, normalized);
|
|
818
|
-
const fieldWhere = `[Feature ${feature.name}] Screen "${screenId}" (entityEdit) field "${normalized.field}"`;
|
|
819
|
-
validateFieldFormRefs(fieldWhere, normalized, fieldNames);
|
|
820
|
-
validateFillActionTarget(fieldWhere, normalized, entityDef.fields[normalized.field]);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
validateWizardLayout(feature.name, screenId, "entityEdit", screen.layout, featureMap);
|
|
824
|
-
// Header actions reuse RowAction — same shape and same checks as
|
|
825
|
-
// projectionDetail's `actions` above (the loaded record stands in
|
|
826
|
-
// for the row). `rowClick` is rejected outright — entityEdit has no
|
|
827
|
-
// row to click either.
|
|
828
|
-
if (screen.actions !== undefined) {
|
|
829
|
-
for (const action of screen.actions) {
|
|
830
|
-
validateRecordActionRedirect(feature, screenId, "entityEdit", action, navigateLookups);
|
|
831
|
-
if (isRowClickAction(action)) {
|
|
832
|
-
throw new Error(`[Feature ${feature.name}] Screen "${qualifyEntityName(feature.name, "screen", screenId)}" ` +
|
|
833
|
-
`(entityEdit) action "${action.id}" sets rowClick: true — there is no row to click ` +
|
|
834
|
-
`on an edit screen. Remove rowClick.`);
|
|
835
|
-
}
|
|
836
|
-
if (action.kind === "navigate") {
|
|
837
|
-
const target = resolveRowActionNavigateTarget(feature.name, screenId, "entityEdit", "action", action, allScreenQns, navTargetShortIds, screensByShortId, detailForScreens);
|
|
838
|
-
validateRowActionNavigateParams(feature.name, screenId, "entityEdit", screen.entity, action, target);
|
|
839
|
-
}
|
|
840
|
-
else if (action.kind === "drawer") {
|
|
841
|
-
validateDrawerTargetAction(feature.name, screenId, "entityEdit", "action", action, feature.screens);
|
|
842
|
-
}
|
|
843
|
-
else if (action.kind === "clientAction") {
|
|
844
|
-
validateClientActionName(feature.name, screenId, "entityEdit", "action", action);
|
|
845
|
-
}
|
|
846
|
-
else {
|
|
847
|
-
if (!allWriteHandlerQns.has(action.handler)) {
|
|
848
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) action "${action.id}" ` +
|
|
849
|
-
`handler "${action.handler}" is not a registered write-handler. Check the QN spelling ` +
|
|
850
|
-
`(expected "<feature>:write:<short>") and that the handler is declared via r.writeHandler(...).`);
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
if (screen.recordTitleField !== undefined && !fieldNames.has(screen.recordTitleField)) {
|
|
856
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) recordTitleField ` +
|
|
857
|
-
`"${screen.recordTitleField}" is not a field of entity "${screen.entity}" ` +
|
|
858
|
-
`(known: ${[...fieldNames].sort().join(", ")}).`);
|
|
859
|
-
}
|
|
860
|
-
if (typeof screen.readOnly === "object" && !fieldNames.has(screen.readOnly.field)) {
|
|
861
|
-
throw new Error(`[Feature ${feature.name}] Screen "${screenId}" (entityEdit) readOnly condition field ` +
|
|
862
|
-
`"${screen.readOnly.field}" is not a field of entity "${screen.entity}" ` +
|
|
863
|
-
`(known: ${[...fieldNames].sort().join(", ")}).`);
|
|
864
|
-
}
|
|
865
|
-
if (screen.redirect !== undefined) {
|
|
866
|
-
validateRedirectTarget(feature, screenId, "entityEdit", screen.redirect, navigateLookups);
|
|
867
|
-
}
|
|
868
|
-
}
|
|
78
|
+
}
|
|
79
|
+
function validateListEmptyStateAction(ctx, screenId, screen) {
|
|
80
|
+
if ((screen.type === "entityList" || screen.type === "projectionList") &&
|
|
81
|
+
screen.emptyState?.action !== undefined) {
|
|
82
|
+
validateActionHasIcon(ctx.feature.name, screenId, screen.type, "emptyState action", screen.emptyState.action);
|
|
83
|
+
validateListActionTargets(listActionContext(ctx, screenId, screen.type, undefined, `Screen "${screenId}" (${screen.type})`), "emptyState action", screen.emptyState.action);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Output of buildAppSchema, which overwrites it — an authored value would be a silent no-op.
|
|
87
|
+
function rejectAuthoredUrlPrefillFields(featureName, screenId, screen) {
|
|
88
|
+
if ((screen.type === "entityEdit" ||
|
|
89
|
+
screen.type === "actionForm" ||
|
|
90
|
+
screen.type === "secretMint") &&
|
|
91
|
+
screen.urlPrefillFields !== undefined) {
|
|
92
|
+
throw new Error(`[Feature ${featureName}] Screen "${screenId}" (${screen.type}) sets urlPrefillFields — ` +
|
|
93
|
+
`it is derived from navigate params by buildAppSchema; declare params on the navigating action instead.`);
|
|
869
94
|
}
|
|
870
95
|
}
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
96
|
+
function rejectSubmitPrefilledOutsideForms(featureName, screenId, screen) {
|
|
97
|
+
if (screen.type !== "actionForm" &&
|
|
98
|
+
screen.type !== "secretMint" &&
|
|
99
|
+
"submitPrefilled" in screen &&
|
|
100
|
+
screen.submitPrefilled !== undefined) {
|
|
101
|
+
throw new Error(`[Feature ${featureName}] Screen "${screenId}" (${screen.type}) sets submitPrefilled — ` +
|
|
102
|
+
`only actionForm and secretMint screens support it. Remove it.`);
|
|
875
103
|
}
|
|
876
|
-
return undefined;
|
|
877
104
|
}
|
|
878
|
-
|
|
879
|
-
const
|
|
880
|
-
|
|
881
|
-
|
|
105
|
+
function validateScreenPrelude(ctx, screenId, screen) {
|
|
106
|
+
const featureName = ctx.feature.name;
|
|
107
|
+
validateExplicitListScreenExists(featureName, screenId, screen, ctx.screensByShortId);
|
|
108
|
+
validateListEmptyStateAction(ctx, screenId, screen);
|
|
109
|
+
rejectAuthoredUrlPrefillFields(featureName, screenId, screen);
|
|
110
|
+
rejectSubmitPrefilledOutsideForms(featureName, screenId, screen);
|
|
111
|
+
validateScreenHasNavArea(ctx.feature, screenId, screen, ctx.featureMap);
|
|
112
|
+
validateScreenVisibleWhen(ctx.feature, screenId, screen, ctx.allScreenQns, ctx.featureMap);
|
|
113
|
+
}
|
|
114
|
+
export function validateScreens(feature, featureMap, allWriteHandlerQns, allScreenQns, configKeyDefsByQn, screensByShortId, detailForScreens) {
|
|
115
|
+
const ctx = buildScreenValidationContext(feature, featureMap, allWriteHandlerQns, allScreenQns, configKeyDefsByQn, screensByShortId, detailForScreens);
|
|
116
|
+
for (const [screenId, screen] of Object.entries(feature.screens)) {
|
|
117
|
+
validateScreenPrelude(ctx, screenId, screen);
|
|
118
|
+
rejectUnknownScreenKind(feature.name, screenId, screen);
|
|
119
|
+
validateScreenOfKind(ctx, screenId, screen.type, screen);
|
|
120
|
+
}
|
|
882
121
|
}
|
|
883
122
|
export function collectScreenQns(features) {
|
|
884
123
|
const set = new Set();
|
|
@@ -890,7 +129,7 @@ export function collectScreenQns(features) {
|
|
|
890
129
|
return set;
|
|
891
130
|
}
|
|
892
131
|
// Extract bare screen IDs (without the `<feature>:screen:` prefix) from
|
|
893
|
-
// qualified QNs for app-wide navigate-target resolution (see
|
|
132
|
+
// qualified QNs for app-wide navigate-target resolution (see buildScreenValidationContext).
|
|
894
133
|
// This mirrors the runtime router, which matches bare IDs across features.
|
|
895
134
|
export function screenShortIdsFrom(allScreenQns) {
|
|
896
135
|
const marker = ":screen:";
|