@cosmicdrift/kumiko-framework 0.413.1 → 0.415.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 +5 -2
- package/agents/api/framework-db.md +14 -3
- package/agents/api/framework-engine.md +69 -13
- package/agents/api/framework-errors.md +1 -1
- package/agents/api/framework-event-store.md +14 -0
- package/agents/api/framework-ui-types.md +158 -21
- package/agents/api/renderer-web.md +112 -11
- package/agents/api/testing-helpers.md +3 -2
- package/agents/api/testing-stack.md +3 -0
- package/agents/api/types.md +248 -24
- package/agents/api.md +7 -7
- package/agents/boot-rules.md +66 -10
- package/agents/examples/api-docs.md +2 -6
- package/agents/examples/auth-mfa.md +57 -10
- package/agents/examples/chat-channels.md +2 -0
- package/agents/examples/crypto-shredding-hr.md +63 -1
- package/agents/examples/currencies-global.md +1 -0
- package/agents/examples/env-composition.md +7 -11
- package/agents/examples/managed-pages.md +90 -1
- package/agents/examples/pwa-shell.md +210 -0
- package/agents/examples/rate-limiting.md +3 -3
- package/agents/examples/record-detail-layout.md +1643 -67
- package/agents/examples/workflow-engine.md +16 -12
- package/agents/examples.md +1 -0
- package/agents/features-index.md +4 -2
- package/agents/features.md +22 -7
- package/agents/widgets.md +26 -1
- package/dist/api/api-constants.d.ts +1 -0
- package/dist/api/api-constants.js +4 -0
- package/dist/api/auth-middleware.js +4 -3
- package/dist/api/auth-routes-shared.js +2 -1
- package/dist/api/entity-read-access.d.ts +1 -0
- package/dist/api/entity-read-access.js +18 -0
- package/dist/api/export/export-route.d.ts +6 -1
- package/dist/api/export/export-route.js +27 -1
- package/dist/api/export/export-rows.js +19 -3
- package/dist/api/request-context-internals.d.ts +2 -0
- package/dist/api/request-context-scopes.js +9 -2
- package/dist/api/request-context.js +1 -1
- package/dist/api/routes.d.ts +2 -0
- package/dist/api/routes.js +9 -1
- package/dist/api/server-event-dispatcher.js +3 -0
- package/dist/api/server-extra-routes.js +2 -1
- package/dist/api/server-feature-http-routes.d.ts +9 -0
- package/dist/api/server-feature-http-routes.js +109 -0
- package/dist/api/server-middleware.js +2 -19
- package/dist/api/server-pat-rate-limit-guard.d.ts +3 -0
- package/dist/api/server-pat-rate-limit-guard.js +19 -0
- package/dist/api/server-rate-limit-wiring.d.ts +10 -0
- package/dist/api/server-rate-limit-wiring.js +37 -0
- package/dist/api/server-routes.d.ts +4 -12
- package/dist/api/server-routes.js +12 -171
- package/dist/api/server-schema-route.d.ts +3 -0
- package/dist/api/server-schema-route.js +58 -0
- package/dist/api/server-wiring.js +2 -37
- package/dist/api/server.js +3 -1
- package/dist/compliance/override-schema.js +5 -5
- package/dist/compliance/sub-processors.js +10 -1
- package/dist/crypto/index.d.ts +1 -1
- package/dist/crypto/index.js +1 -1
- package/dist/crypto/pii-field-encryption.d.ts +2 -0
- package/dist/crypto/pii-field-encryption.js +16 -1
- package/dist/db/apply-entity-event.js +4 -0
- package/dist/db/bun-sql-connection-codes.d.ts +1 -0
- package/dist/db/bun-sql-connection-codes.js +7 -0
- package/dist/db/collect-table-metas.js +4 -1
- package/dist/db/config-seed.js +1 -1
- package/dist/db/derived-field-sql.js +15 -13
- package/dist/db/derived-related-sql.d.ts +2 -2
- package/dist/db/derived-related-sql.js +4 -2
- package/dist/db/dialect.d.ts +3 -0
- package/dist/db/dialect.js +1 -3
- package/dist/db/driver-row-coercion.js +2 -2
- package/dist/db/driver-value-preparation.js +1 -1
- package/dist/db/eagerload.js +15 -12
- package/dist/db/entity-table-meta.d.ts +2 -0
- package/dist/db/entity-table-meta.js +7 -0
- package/dist/db/event-store-executor-context.js +13 -8
- package/dist/db/event-store-executor-read-aggregate-currencies.js +2 -2
- package/dist/db/event-store-executor-read-aggregate.js +2 -2
- package/dist/db/event-store-executor-read-filter.d.ts +4 -0
- package/dist/db/event-store-executor-read-filter.js +28 -11
- package/dist/db/event-store-executor-read-search.d.ts +1 -0
- package/dist/db/event-store-executor-read-search.js +6 -6
- package/dist/db/event-store-executor-read-sort.js +3 -3
- package/dist/db/event-store-executor-read-where.js +14 -5
- package/dist/db/event-store-executor-read.js +7 -7
- package/dist/db/event-store-executor-write.js +50 -95
- package/dist/db/executor-managed-tables.js +4 -1
- package/dist/db/index.d.ts +4 -2
- package/dist/db/index.js +4 -2
- package/dist/db/known-table-names.d.ts +1 -0
- package/dist/db/known-table-names.js +7 -5
- package/dist/db/list-aggregate-labels.d.ts +1 -0
- package/dist/db/list-aggregate-labels.js +9 -1
- package/dist/db/migrate-generator.js +23 -4
- package/dist/db/migrate-rls-diff.d.ts +1 -0
- package/dist/db/migrate-rls-diff.js +15 -1
- package/dist/db/migrate-runner.js +2 -2
- package/dist/db/money.d.ts +1 -1
- package/dist/db/money.js +1 -4
- package/dist/db/parent-ref-clause.d.ts +6 -2
- package/dist/db/parent-ref-clause.js +105 -24
- package/dist/db/parent-ref-global-hosts.d.ts +23 -0
- package/dist/db/parent-ref-global-hosts.js +85 -0
- package/dist/db/production-schema-command-hint.d.ts +1 -0
- package/dist/db/production-schema-command-hint.js +3 -0
- package/dist/db/queries/backfill-pii.js +55 -29
- package/dist/db/queries/ddl.js +13 -2
- package/dist/db/queries/event-store-open-streams.d.ts +15 -0
- package/dist/db/queries/event-store-open-streams.js +33 -0
- package/dist/db/queries/event-store-payload-scrub.d.ts +5 -0
- package/dist/db/queries/event-store-payload-scrub.js +11 -0
- package/dist/db/queries/event-store.js +0 -1
- package/dist/db/queries/raw-sql.js +0 -1
- package/dist/db/queries/rebuild-rls-guard.d.ts +2 -1
- package/dist/db/queries/rebuild-rls-guard.js +24 -11
- package/dist/db/queries/rls-boot-catalog.d.ts +1 -0
- package/dist/db/queries/rls-boot-catalog.js +13 -9
- package/dist/db/queries/rls-shape.d.ts +3 -1
- package/dist/db/queries/rls-shape.js +31 -6
- package/dist/db/queries/session-advisory-lock.js +2 -1
- package/dist/db/queries/test-stack.js +7 -7
- package/dist/db/query.js +16 -11
- package/dist/db/rebuild-marker.js +11 -2
- package/dist/db/render-rls-ddl.d.ts +2 -0
- package/dist/db/render-rls-ddl.js +16 -11
- package/dist/db/replay-migration-sql.js +1 -1
- package/dist/db/row-level-security-boot-check.js +18 -5
- package/dist/db/row-level-security-connection.js +25 -12
- package/dist/db/row-level-security-scope.d.ts +2 -1
- package/dist/db/row-level-security-scope.js +9 -5
- package/dist/db/sql-identifier.d.ts +1 -0
- package/dist/db/sql-identifier.js +3 -0
- package/dist/db/system-tenant-read-db.d.ts +5 -0
- package/dist/db/system-tenant-read-db.js +28 -0
- package/dist/db/table-builder.d.ts +3 -1
- package/dist/db/table-builder.js +18 -8
- package/dist/db/table-info.d.ts +1 -2
- package/dist/db/table-introspection.d.ts +3 -0
- package/dist/db/table-introspection.js +6 -0
- package/dist/db/table-push.d.ts +1 -0
- package/dist/db/table-push.js +7 -1
- package/dist/db/tenant-db-runner.d.ts +3 -0
- package/dist/db/tenant-db-runner.js +19 -1
- package/dist/db/transaction-serialization.d.ts +1 -0
- package/dist/db/transaction-serialization.js +20 -3
- package/dist/db/where-clause.js +11 -2
- package/dist/db/write-ownership-failures.d.ts +25 -0
- package/dist/db/write-ownership-failures.js +82 -0
- package/dist/engine/boot-validator/boot-check.js +7 -1
- package/dist/engine/boot-validator/boot-phases-app.js +5 -5
- package/dist/engine/boot-validator/boot-phases.js +3 -2
- package/dist/engine/boot-validator/boot-rules.d.ts +305 -28
- package/dist/engine/boot-validator/boot-rules.js +4 -0
- package/dist/engine/boot-validator/bundled-lists-table.js +2 -2
- package/dist/engine/boot-validator/card-meta-overflow-rules.d.ts +2 -2
- package/dist/engine/boot-validator/card-meta-overflow-rules.js +2 -2
- package/dist/engine/boot-validator/card-meta-overflow.js +8 -5
- package/dist/engine/boot-validator/config-deps.d.ts +0 -1
- package/dist/engine/boot-validator/config-deps.js +0 -28
- package/dist/engine/boot-validator/config-key-rules.d.ts +0 -15
- package/dist/engine/boot-validator/config-key-rules.js +0 -15
- package/dist/engine/boot-validator/dashboard-screen-target.d.ts +22 -0
- package/dist/engine/boot-validator/dashboard-screen-target.js +20 -0
- package/dist/engine/boot-validator/dashboard-stat-navigate.d.ts +1 -0
- package/dist/engine/boot-validator/dashboard-stat-navigate.js +25 -17
- package/dist/engine/boot-validator/definition-webhook-events-rules.d.ts +5 -0
- package/dist/engine/boot-validator/definition-webhook-events-rules.js +5 -0
- package/dist/engine/boot-validator/derived-sql-fields.js +1 -2
- package/dist/engine/boot-validator/entity-declaration-rules.d.ts +5 -0
- package/dist/engine/boot-validator/entity-declaration-rules.js +5 -0
- package/dist/engine/boot-validator/entity-list-screens.d.ts +1 -0
- package/dist/engine/boot-validator/entity-list-screens.js +35 -13
- package/dist/engine/boot-validator/entity-structure-rules.d.ts +5 -0
- package/dist/engine/boot-validator/entity-structure-rules.js +5 -0
- package/dist/engine/boot-validator/list-column-layout.js +10 -6
- package/dist/engine/boot-validator/list-row-guidance-rules.d.ts +67 -0
- package/dist/engine/boot-validator/list-row-guidance-rules.js +67 -0
- package/dist/engine/boot-validator/list-row-guidance.d.ts +20 -0
- package/dist/engine/boot-validator/list-row-guidance.js +143 -0
- package/dist/engine/boot-validator/list-sort-summary-rules.d.ts +42 -0
- package/dist/engine/boot-validator/list-sort-summary-rules.js +42 -0
- package/dist/engine/boot-validator/list-sort-summary.d.ts +5 -0
- package/dist/engine/boot-validator/list-sort-summary.js +160 -0
- package/dist/engine/boot-validator/list-table-options.js +15 -1
- package/dist/engine/boot-validator/list-table-rules.d.ts +10 -5
- package/dist/engine/boot-validator/list-table-rules.js +10 -5
- package/dist/engine/boot-validator/list-toolbar-options.d.ts +10 -0
- package/dist/engine/boot-validator/list-toolbar-options.js +30 -0
- package/dist/engine/boot-validator/named-filter-rules.d.ts +42 -2
- package/dist/engine/boot-validator/named-filter-rules.js +42 -2
- package/dist/engine/boot-validator/ownership.js +10 -1
- package/dist/engine/boot-validator/parent-ref.js +87 -50
- package/dist/engine/boot-validator/projection-list-screens.d.ts +1 -0
- package/dist/engine/boot-validator/projection-list-screens.js +32 -1
- package/dist/engine/boot-validator/query-output-columns.js +62 -9
- package/dist/engine/boot-validator/query-output-guidance.d.ts +7 -0
- package/dist/engine/boot-validator/query-output-guidance.js +40 -0
- package/dist/engine/boot-validator/query-refs.js +34 -1
- package/dist/engine/boot-validator/row-decoration.d.ts +11 -0
- package/dist/engine/boot-validator/row-decoration.js +16 -0
- package/dist/engine/boot-validator/screens-actions.js +1 -1
- package/dist/engine/boot-validator/screens-dashboard-links.d.ts +10 -0
- package/dist/engine/boot-validator/screens-dashboard-links.js +36 -0
- package/dist/engine/boot-validator/screens-dashboard-narrow.d.ts +4 -0
- package/dist/engine/boot-validator/screens-dashboard-narrow.js +211 -0
- package/dist/engine/boot-validator/screens-dashboard-rules.d.ts +84 -4
- package/dist/engine/boot-validator/screens-dashboard-rules.js +84 -4
- package/dist/engine/boot-validator/screens-dashboard.js +29 -7
- package/dist/engine/boot-validator/screens-kind-entity-list.js +32 -27
- package/dist/engine/boot-validator/screens-kind-projection-detail-guidance.d.ts +3 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail-guidance.js +46 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.d.ts +20 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail-rules.js +20 -0
- package/dist/engine/boot-validator/screens-kind-projection-detail.js +2 -0
- package/dist/engine/boot-validator/screens-kind-projection-list.js +4 -0
- package/dist/engine/boot-validator/screens-kind-rules.d.ts +25 -0
- package/dist/engine/boot-validator/screens-kind-rules.js +25 -0
- package/dist/engine/boot-validator/screens-lists.d.ts +8 -2
- package/dist/engine/boot-validator/screens-lists.js +19 -3
- package/dist/engine/boot-validator/screens.js +1 -1
- package/dist/engine/boot-validator/sort-nulls.d.ts +2 -0
- package/dist/engine/boot-validator/sort-nulls.js +15 -0
- package/dist/engine/boot-validator/zod-shape.d.ts +2 -1
- package/dist/engine/boot-validator/zod-shape.js +19 -1
- package/dist/engine/build-app-schema.js +4 -0
- package/dist/engine/config-helpers.d.ts +1 -2
- package/dist/engine/config-helpers.js +6 -7
- package/dist/engine/define-feature.js +1 -0
- package/dist/engine/define-handler.d.ts +1 -0
- package/dist/engine/define-handler.js +4 -2
- package/dist/engine/definition-violations.js +2 -2
- package/dist/engine/entity-handlers.js +3 -8
- package/dist/engine/entity-list-runtime-options.js +9 -8
- package/dist/engine/factories.d.ts +2 -0
- package/dist/engine/feature-config-events-jobs.js +1 -0
- package/dist/engine/feature-entity-handlers.js +5 -2
- package/dist/engine/field-access.d.ts +1 -1
- package/dist/engine/field-access.js +7 -10
- package/dist/engine/find-entity.js +3 -3
- package/dist/engine/form-derivations.js +3 -3
- package/dist/engine/index.d.ts +3 -3
- package/dist/engine/index.js +2 -2
- package/dist/engine/named-filter-roles.d.ts +3 -0
- package/dist/engine/named-filter-roles.js +15 -0
- package/dist/engine/pipeline.js +0 -1
- package/dist/engine/project-app-schema-for-roles.js +17 -2
- package/dist/engine/qualified-name.js +0 -1
- package/dist/engine/registry-facade.js +1 -2
- package/dist/engine/registry-state.d.ts +1 -1
- package/dist/engine/registry-state.js +5 -2
- package/dist/engine/registry-validate.js +2 -1
- package/dist/engine/resolve-named-list-filters.js +5 -2
- package/dist/engine/schema-builder.js +9 -11
- package/dist/engine/screen-helpers.d.ts +12 -0
- package/dist/engine/screen-helpers.js +17 -1
- package/dist/engine/soft-delete-cleanup.js +3 -5
- package/dist/engine/state-machine.js +0 -1
- package/dist/engine/steps/_database-clock.d.ts +2 -0
- package/dist/engine/steps/_database-clock.js +6 -0
- package/dist/engine/steps/compute.js +1 -1
- package/dist/engine/steps/retry.js +5 -1
- package/dist/engine/steps/return.js +0 -1
- package/dist/engine/steps/wait-for-event.js +2 -1
- package/dist/engine/steps/wait.js +2 -1
- package/dist/engine/system-user.d.ts +2 -2
- package/dist/engine/system-user.js +2 -2
- package/dist/engine/types/handlers.d.ts +1 -1
- package/dist/engine/types/handlers.js +1 -1
- package/dist/engine/types/screen.d.ts +1 -1
- package/dist/engine/types/screen.js +1 -1
- package/dist/engine/webhook-contracts.d.ts +2 -3
- package/dist/engine/webhook-contracts.js +2 -25
- package/dist/engine/webhook-events.js +48 -29
- package/dist/engine/webhook-payload-strictness.d.ts +7 -0
- package/dist/engine/webhook-payload-strictness.js +53 -0
- package/dist/env/_zod-introspect.d.ts +1 -0
- package/dist/env/dry-run.d.ts +1 -1
- package/dist/env/dry-run.js +1 -1
- package/dist/env/field-meta.d.ts +4 -0
- package/dist/env/field-meta.js +67 -0
- package/dist/env/field-rules.d.ts +9 -0
- package/dist/env/field-rules.js +46 -0
- package/dist/env/index.d.ts +3 -3
- package/dist/env/index.js +16 -71
- package/dist/env/internals.d.ts +3 -0
- package/dist/env/internals.js +1 -2
- package/dist/env/required-env.d.ts +3 -1
- package/dist/env/required-env.js +5 -2
- package/dist/errors/reasons.d.ts +1 -0
- package/dist/errors/reasons.js +4 -0
- package/dist/errors/serialize.js +2 -2
- package/dist/errors/write-error-info.js +0 -2
- package/dist/es-ops/operations-schema.js +18 -7
- package/dist/event-store/admin-api.js +3 -3
- package/dist/event-store/event-store.js +0 -3
- package/dist/event-store/index.d.ts +1 -0
- package/dist/event-store/index.js +1 -0
- package/dist/event-store/transfer.js +1 -1
- package/dist/files/assert-file-refs-belong-to-tenant.d.ts +2 -1
- package/dist/files/assert-file-refs-belong-to-tenant.js +15 -13
- package/dist/files/bind-pending-file-refs.d.ts +3 -1
- package/dist/files/bind-pending-file-refs.js +54 -27
- package/dist/files/copy-pending-file-refs-to-tenant.js +7 -3
- package/dist/files/create-file-ref.d.ts +4 -1
- package/dist/files/create-file-ref.js +14 -3
- package/dist/files/default-file-guard.js +4 -1
- package/dist/files/file-claim.d.ts +6 -0
- package/dist/files/file-claim.js +17 -0
- package/dist/files/file-field-slots.d.ts +2 -0
- package/dist/files/file-field-slots.js +28 -0
- package/dist/files/file-ref-entity.d.ts +3 -0
- package/dist/files/file-ref-entity.js +2 -0
- package/dist/files/file-ref-table.d.ts +3 -0
- package/dist/files/file-routes.d.ts +4 -1
- package/dist/files/file-routes.js +80 -16
- package/dist/files/in-memory-provider.d.ts +1 -1
- package/dist/files/in-memory-provider.js +2 -1
- package/dist/files/index.d.ts +1 -1
- package/dist/files/index.js +1 -1
- package/dist/files/invalid-file-ref-error.d.ts +2 -0
- package/dist/files/invalid-file-ref-error.js +15 -0
- package/dist/files/local-provider.js +9 -2
- package/dist/files/provider-resolver.js +1 -1
- package/dist/files/rebind-file-ref.d.ts +3 -2
- package/dist/files/rebind-file-ref.js +24 -18
- package/dist/files/resolve-file-handles.d.ts +13 -0
- package/dist/files/resolve-file-handles.js +57 -0
- package/dist/files/storage-tracking.d.ts +1 -1
- package/dist/files/storage-tracking.js +5 -2
- package/dist/files/sweep-stale-pending-file-refs.js +10 -4
- package/dist/files/types.d.ts +4 -0
- package/dist/files/types.js +10 -0
- package/dist/files/upload-field-resolution.d.ts +1 -0
- package/dist/files/upload-field-resolution.js +16 -2
- package/dist/files/upload-ledger.js +1 -1
- package/dist/i18n/required-surface-guidance-keys.d.ts +3 -0
- package/dist/i18n/required-surface-guidance-keys.js +9 -0
- package/dist/i18n/required-surface-keys.js +21 -5
- package/dist/internal/boot-rule-table-expectations.d.ts +2 -0
- package/dist/internal/boot-rule-table-expectations.js +29 -0
- package/dist/internal/row-level-security.d.ts +1 -0
- package/dist/internal/row-level-security.js +1 -0
- package/dist/internal/testing.d.ts +1 -0
- package/dist/internal/testing.js +1 -0
- package/dist/jobs/index.d.ts +1 -0
- package/dist/jobs/index.js +1 -0
- package/dist/jobs/job-load-events.d.ts +10 -0
- package/dist/jobs/job-load-events.js +12 -0
- package/dist/jobs/job-runner-context.js +6 -158
- package/dist/jobs/job-runner-dispatch.d.ts +7 -0
- package/dist/jobs/job-runner-dispatch.js +57 -0
- package/dist/jobs/job-runner-event-triggers.js +18 -9
- package/dist/jobs/job-runner-execution.js +5 -2
- package/dist/jobs/job-runner-facets.d.ts +48 -0
- package/dist/jobs/job-runner-facets.js +156 -0
- package/dist/jobs/job-runner-gates.js +19 -11
- package/dist/jobs/job-runner-helpers.d.ts +5 -1
- package/dist/jobs/job-runner-helpers.js +18 -3
- package/dist/jobs/job-runner-scope.d.ts +1 -0
- package/dist/jobs/job-runner-scope.js +2 -0
- package/dist/jobs/job-runner-tenant-cap-lock.d.ts +2 -0
- package/dist/jobs/job-runner-tenant-cap-lock.js +30 -0
- package/dist/jobs/job-runner-types.d.ts +1 -0
- package/dist/jobs/job-runner.js +39 -70
- package/dist/jobs/obliterate-job-queues.d.ts +6 -0
- package/dist/jobs/obliterate-job-queues.js +23 -0
- package/dist/lifecycle/lifecycle.js +1 -1
- package/dist/migrations/event-header-scrub.d.ts +11 -0
- package/dist/migrations/event-header-scrub.js +33 -0
- package/dist/migrations/event-payload-scrub.d.ts +1 -1
- package/dist/migrations/event-payload-scrub.js +36 -4
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.js +2 -0
- package/dist/migrations/kumiko-drift.d.ts +5 -2
- package/dist/migrations/kumiko-drift.js +51 -14
- package/dist/migrations/pending-rebuilds.js +4 -5
- package/dist/observability/sensitive-filter.js +0 -12
- package/dist/pipeline/aggregate-type-removal.js +17 -4
- package/dist/pipeline/context-services.d.ts +2 -0
- package/dist/pipeline/context-services.js +5 -2
- package/dist/pipeline/dispatch-batch.js +4 -3
- package/dist/pipeline/dispatch-context-helpers.d.ts +11 -0
- package/dist/pipeline/dispatch-context-helpers.js +58 -0
- package/dist/pipeline/dispatch-nested-write.d.ts +7 -0
- package/dist/pipeline/dispatch-nested-write.js +119 -0
- package/dist/pipeline/dispatch-query.js +10 -3
- package/dist/pipeline/dispatch-scope.js +4 -3
- package/dist/pipeline/dispatch-shared.d.ts +2 -6
- package/dist/pipeline/dispatch-shared.js +6 -38
- package/dist/pipeline/dispatch-write.d.ts +0 -1
- package/dist/pipeline/dispatch-write.js +3 -302
- package/dist/pipeline/dispatcher-utils.js +6 -0
- package/dist/pipeline/effective-system-scope.d.ts +3 -0
- package/dist/pipeline/effective-system-scope.js +22 -0
- package/dist/pipeline/event-dispatcher-delivery.d.ts +1 -0
- package/dist/pipeline/event-dispatcher-delivery.js +20 -9
- package/dist/pipeline/event-dispatcher.d.ts +6 -1
- package/dist/pipeline/event-dispatcher.js +6 -7
- package/dist/pipeline/handler-context-auth.d.ts +3 -2
- package/dist/pipeline/handler-context-auth.js +3 -4
- package/dist/pipeline/handler-context-db.js +11 -4
- package/dist/pipeline/handler-context-dispatch.js +2 -2
- package/dist/pipeline/handler-context-events.d.ts +8 -3
- package/dist/pipeline/handler-context-events.js +20 -65
- package/dist/pipeline/handler-context-member-resolution.js +16 -8
- package/dist/pipeline/handler-context-notify.d.ts +1 -0
- package/dist/pipeline/handler-context-notify.js +2 -0
- package/dist/pipeline/handler-context-phase-denials.js +3 -2
- package/dist/pipeline/handler-context-projection.d.ts +3 -0
- package/dist/pipeline/handler-context-projection.js +39 -0
- package/dist/pipeline/handler-context-scope.d.ts +1 -1
- package/dist/pipeline/handler-context-scope.js +14 -2
- package/dist/pipeline/index.d.ts +1 -1
- package/dist/pipeline/index.js +1 -1
- package/dist/pipeline/irreversible-operation-gate.js +36 -10
- package/dist/pipeline/lifecycle-pipeline.d.ts +1 -0
- package/dist/pipeline/lifecycle-pipeline.js +7 -4
- package/dist/pipeline/member-reader.js +4 -2
- package/dist/pipeline/msp-rebuild.js +1 -1
- package/dist/pipeline/nested-write-parent-guard.d.ts +5 -0
- package/dist/pipeline/nested-write-parent-guard.js +81 -0
- package/dist/pipeline/projection-rebuild.d.ts +2 -0
- package/dist/pipeline/projection-rebuild.js +16 -7
- package/dist/pipeline/projection-state.js +4 -6
- package/dist/pipeline/system-hooks.js +36 -6
- package/dist/pipeline/write-result-masking.js +31 -3
- package/dist/pipeline/write-transition-guard.d.ts +7 -0
- package/dist/pipeline/write-transition-guard.js +95 -0
- package/dist/schema-cli/shared.d.ts +2 -0
- package/dist/schema-cli/shared.js +4 -2
- package/dist/schema-cli/validate-command.js +43 -28
- package/dist/search/meilisearch-adapter-internals.d.ts +2 -0
- package/dist/search/meilisearch-adapter-internals.js +5 -0
- package/dist/search/meilisearch-adapter.d.ts +1 -0
- package/dist/search/meilisearch-adapter.js +17 -11
- package/dist/search/reindex-entity.d.ts +2 -0
- package/dist/search/reindex-entity.js +32 -4
- package/dist/search/reindex-tenants-search.js +20 -4
- package/dist/time/tz-context.js +1 -1
- package/dist/ui-types/card-column-roles.d.ts +6 -0
- package/dist/ui-types/card-column-roles.js +21 -3
- package/dist/ui-types/index.d.ts +3 -3
- package/dist/ui-types/index.js +2 -2
- package/dist/utils/ids.js +0 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/return-path-limit.d.ts +1 -0
- package/dist/utils/return-path-limit.js +1 -0
- package/package.json +5 -3
- package/presets/biome-app.json +39 -21
- package/presets/biome-plugins/admin-api.grit +10 -0
- package/presets/biome-plugins/error-reasons.grit +53 -0
- package/presets/biome-plugins/es-literal-writes-tests.grit +18 -0
- package/presets/biome-plugins/es-literal-writes.grit +22 -0
- package/presets/biome-plugins/i18n-locale-terminology-de.grit +15 -0
- package/presets/biome-plugins/i18n-locale-terminology-romance.grit +10 -0
- package/presets/biome-plugins/no-create-test-dispatcher.grit +5 -0
- package/presets/biome-plugins/no-css-properties-type.grit +7 -0
- package/presets/biome-plugins/no-date-api.grit +11 -0
- package/presets/biome-plugins/no-direct-fetch.grit +16 -0
- package/presets/biome-plugins/no-direct-fs.grit +16 -0
- package/presets/biome-plugins/no-external-font-cdn-css.grit +9 -0
- package/presets/biome-plugins/no-external-font-cdn.grit +12 -0
- package/presets/biome-plugins/no-raw-hooks.grit +10 -0
- package/presets/biome-plugins/no-same-folder-barrel-import.grit +11 -0
- package/presets/biome-plugins/no-screen-container-classes.grit +7 -0
- package/presets/biome-plugins/no-skipped-or-retried-tests.grit +34 -0
- package/presets/biome-plugins/no-temporal-polyfill-require.grit +10 -0
- package/presets/biome-plugins/raw-html-in-web.grit +40 -0
- package/presets/biome-plugins/raw-ui-in-app.grit +142 -0
- package/presets/biome-plugins/restricted-event-store-symbols.grit +18 -0
- package/presets/biome-plugins/test-title.grit +20 -0
- package/presets/biome-plugins/unsafe-json-parse.grit +12 -0
- package/presets/biome-rules.json +467 -0
- package/src/changes.json +366 -0
- package/dist/engine/minor-units.d.ts +0 -2
- package/dist/engine/minor-units.js +0 -8
|
@@ -18,6 +18,39 @@ header, a metrics band, and a tabbed layout instead of one long stacked form.
|
|
|
18
18
|
- `layout.mode: "tabs"` with two `relatedList` tabs (order items, payments)
|
|
19
19
|
and one `fields` tab (master data) — each `relatedList` runs its own query
|
|
20
20
|
- a header action with `showOnTabs: ["payments"]`, shown only while that tab is active
|
|
21
|
+
- guidance for a non-expert reader: a `projectionList` with `rowToneField` (row tint),
|
|
22
|
+
a `hint` column (sentence, detail, tone, "Why?" reason) and a row action shown
|
|
23
|
+
only when `visible` holds; on the detail screen `breadcrumb`, `summary`, `banner`
|
|
24
|
+
and `steps`, each filled from a query field and dropped when the value is empty
|
|
25
|
+
- `focus: true` on the detail screen: the app header actions leave the shell header and the
|
|
26
|
+
sidebar shows the focus rail; below 768 px a top bar replaces the header with the record
|
|
27
|
+
title, a back arrow to the list screen and the page-header overflow menu
|
|
28
|
+
- on phones the `orders` list draws cards in the order lead sentence (the hint column, with
|
|
29
|
+
detail and "Why?"), title, up to three values, then the row action; a hint column is never
|
|
30
|
+
the title and a `hideOnNarrow` one stays out of the card
|
|
31
|
+
- a work queue on that list: named filters as one select with hit counts (`namedFilterFacet`),
|
|
32
|
+
a per-filter `sort` and `emptyState` with a reset button, a badge column, per-row button
|
|
33
|
+
actions (a write "Send reminder" or a link "Open order", shown by `visible`) and a summary row footer
|
|
34
|
+
- a `today` dashboard on the 12-column grid: a `lead` briefing (two thirds), count tiles that
|
|
35
|
+
use the list's own query and link into the filtered list, a headerless "Now" list, two third
|
|
36
|
+
width lists and a money group. List and dashboard answer from `src/order-board.ts`, which the
|
|
37
|
+
e2e mock dispatcher shares
|
|
38
|
+
- on the detail screen: a second step action as a link button, metric tiles with `tone`,
|
|
39
|
+
`toneField` and `navigate: { tab }`, and tab counts via `countField`; the breadcrumb stays
|
|
40
|
+
unlinked because the recipe has no entity with a `detailFor` screen to link to
|
|
41
|
+
- phone variants: `hideOnNarrow` on dashboard panels and the progress chain, a list panel's
|
|
42
|
+
`narrow` (`cards` with a `limit`, or a one-line `line` link), `narrowBlocks` on the briefing,
|
|
43
|
+
`hint.plainSentence`, `showOnNarrowOnly` list columns, stat-group `columns`, and on the detail
|
|
44
|
+
`summary.narrowField` and `steps.narrowLimit`; the reason of a hint stays behind its toggle unless `reasonOpenField` opens it (with `reasonTitleField` as bold lead-in; steps use `whyOpen`/`whyTitle`)
|
|
45
|
+
- round 5 (board gaps): a titled `stat-group` strip with a panel `icon` and per-stat `narrowLabel`,
|
|
46
|
+
`narrowOrder` on a panel, `showTotal: { text, narrowText }`, `footerLink.moreText` and
|
|
47
|
+
`narrowMoreText`, `narrow: { layout: "line", field }`, `rowLink` on a list panel (arrow, or
|
|
48
|
+
`icon: "chevron"` for a date list), `hint.narrowDetailField` on cards, summary row items placed
|
|
49
|
+
under their `column`, and on the detail `header.narrowSubtitle`, a banner action `narrowLabel`,
|
|
50
|
+
`RecordStep.narrowDetail` and a `hideOnNarrow` metric. Phone cards leave out the reason toggle
|
|
51
|
+
- round 6 (board gaps): `rowLink.screenField` / `paramsField` (target screen from a query field),
|
|
52
|
+
list panel `icon`, `narrow.moreText`, `narrow.field` as any query output field,
|
|
53
|
+
`footerLink.narrowOnly`, `narrow.titleField` on cards and `rowToneMarker: "dot"`
|
|
21
54
|
- boot-validator catching two common author mistakes: a `metrics` entry
|
|
22
55
|
with an empty `label`, and a `tabs` layout with fewer than two
|
|
23
56
|
sections
|
|
@@ -35,6 +68,71 @@ bun test
|
|
|
35
68
|
|
|
36
69
|
## Source files
|
|
37
70
|
|
|
71
|
+
### e2e/board-screenshots.spec.ts
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
// Manual visual evidence for the board blocks (dashboard, work queue, case file), desktop and
|
|
75
|
+
// phone via the screenshot projects in playwright.config.ts (PADDING_PARITY_SCREENSHOTS=1).
|
|
76
|
+
// Captures only; the behaviour is asserted in work-queue.spec.ts.
|
|
77
|
+
|
|
78
|
+
import { expect, boundaryGuardedTest as test } from "@cosmicdrift/kumiko-testing/e2e";
|
|
79
|
+
import type { Page } from "@playwright/test";
|
|
80
|
+
|
|
81
|
+
const PHONE_FULL_HEIGHT = 2600;
|
|
82
|
+
const FILTER_FACET = "facet-__namedFilter";
|
|
83
|
+
|
|
84
|
+
// Phones keep the facets behind a "Filters" button.
|
|
85
|
+
async function openFilterSelect(page: Page): Promise<void> {
|
|
86
|
+
const facet = page.getByTestId(FILTER_FACET);
|
|
87
|
+
if (!(await facet.isVisible())) await page.getByRole("button", { name: "Filters" }).click();
|
|
88
|
+
await facet.click();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
test("board: today dashboard", async ({ page }, testInfo) => {
|
|
92
|
+
await page.goto("/today");
|
|
93
|
+
await expect(page.getByText("Inbox")).toBeVisible();
|
|
94
|
+
await expect(page.getByText("Send payment reminder").first()).toBeVisible();
|
|
95
|
+
await page.screenshot({ path: testInfo.outputPath("today.png"), fullPage: true });
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test("board: orders list in its states", async ({ page }, testInfo) => {
|
|
99
|
+
await page.goto("/orders");
|
|
100
|
+
await expect(page.getByText("SO-10483")).toBeVisible();
|
|
101
|
+
await page.screenshot({ path: testInfo.outputPath("orders.png"), fullPage: true });
|
|
102
|
+
|
|
103
|
+
await openFilterSelect(page);
|
|
104
|
+
await page.screenshot({ path: testInfo.outputPath("orders-select-open.png"), fullPage: true });
|
|
105
|
+
await page.getByTestId(`${FILTER_FACET}-action-needed`).click();
|
|
106
|
+
await expect(page.getByText("SO-10483")).toHaveCount(0);
|
|
107
|
+
await page.screenshot({ path: testInfo.outputPath("orders-filtered.png"), fullPage: true });
|
|
108
|
+
|
|
109
|
+
// The reason sits behind its toggle in the table; the phone cards leave it out.
|
|
110
|
+
const reasonToggle = page.locator("[data-hint-reason-toggle]").first();
|
|
111
|
+
if (await reasonToggle.isVisible()) {
|
|
112
|
+
await reasonToggle.click();
|
|
113
|
+
await expect(page.locator("[data-hint-reason]").first()).toBeVisible();
|
|
114
|
+
}
|
|
115
|
+
await page.screenshot({ path: testInfo.outputPath("orders-reason-open.png"), fullPage: true });
|
|
116
|
+
|
|
117
|
+
await openFilterSelect(page);
|
|
118
|
+
await page.getByTestId(`${FILTER_FACET}-reminder-due`).click();
|
|
119
|
+
await expect(page.getByTestId("render-list-empty-reset-filter")).toBeVisible();
|
|
120
|
+
await page.screenshot({ path: testInfo.outputPath("orders-empty.png"), fullPage: true });
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
test("board: order detail with a step reason open", async ({ page }, testInfo) => {
|
|
124
|
+
await page.goto("/order-detail/o1?guidance=1");
|
|
125
|
+
await expect(page.getByTestId("render-edit-form")).toBeVisible();
|
|
126
|
+
await page.getByRole("button", { name: /why/i }).first().click();
|
|
127
|
+
// The shell scrolls inside <main>, so fullPage alone would cut a phone capture at the viewport.
|
|
128
|
+
const viewport = page.viewportSize();
|
|
129
|
+
if (viewport !== null && viewport.width < 768) {
|
|
130
|
+
await page.setViewportSize({ width: viewport.width, height: PHONE_FULL_HEIGHT });
|
|
131
|
+
}
|
|
132
|
+
await page.screenshot({ path: testInfo.outputPath("order-detail.png"), fullPage: true });
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
38
136
|
### e2e/build-server.ts
|
|
39
137
|
|
|
40
138
|
```ts
|
|
@@ -236,13 +334,33 @@ function OrderInternalNote(): ReactNode {
|
|
|
236
334
|
);
|
|
237
335
|
}
|
|
238
336
|
|
|
337
|
+
function OrderInboxIcon(): ReactNode {
|
|
338
|
+
return (
|
|
339
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
340
|
+
<path d="M2 9h3l1 2h4l1-2h3v4H2z" stroke="currentColor" strokeWidth="1.5" />
|
|
341
|
+
</svg>
|
|
342
|
+
);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function DeadlinesIcon(): ReactNode {
|
|
346
|
+
return (
|
|
347
|
+
<svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16" fill="none">
|
|
348
|
+
<rect x="2" y="3" width="12" height="11" rx="1.5" stroke="currentColor" strokeWidth="1.5" />
|
|
349
|
+
<path d="M2 7h12M5 1.5v3M11 1.5v3" stroke="currentColor" strokeWidth="1.5" />
|
|
350
|
+
</svg>
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
|
|
239
354
|
function Shell({
|
|
240
355
|
schema,
|
|
356
|
+
children,
|
|
241
357
|
}: {
|
|
242
358
|
readonly children: ReactNode;
|
|
243
359
|
readonly schema: AppSchema;
|
|
244
360
|
}): ReactNode {
|
|
245
361
|
const feature = schema.features[0];
|
|
362
|
+
// Only the root path pins the record; other paths (/today, /orders) render the routed screen.
|
|
363
|
+
const isPinnedRecord = window.location.pathname === "/";
|
|
246
364
|
// KumikoScreen sits directly under DefaultAppShell's <main> — same as the
|
|
247
365
|
// real RoutedScreen (create-app.tsx) — so RenderEdit's `fillHeight` chain
|
|
248
366
|
// (h-full all the way down) resolves against `main`'s own, genuinely
|
|
@@ -254,11 +372,13 @@ function Shell({
|
|
|
254
372
|
schema={schema}
|
|
255
373
|
user={{ id: "u1", roles: ["Admin"] }}
|
|
256
374
|
>
|
|
257
|
-
{
|
|
258
|
-
|
|
375
|
+
<ExtensionSectionsProvider value={{ OrderInboxIcon, DeadlinesIcon, OrderInternalNote }}>
|
|
376
|
+
{isPinnedRecord && feature !== undefined ? (
|
|
259
377
|
<KumikoScreen schema={feature} qn={ORDER_DETAIL_SCREEN_QN} entityId="order-1" />
|
|
260
|
-
|
|
261
|
-
|
|
378
|
+
) : (
|
|
379
|
+
children
|
|
380
|
+
)}
|
|
381
|
+
</ExtensionSectionsProvider>
|
|
262
382
|
</DefaultAppShell>
|
|
263
383
|
);
|
|
264
384
|
}
|
|
@@ -319,20 +439,48 @@ import type {
|
|
|
319
439
|
WriteOpts,
|
|
320
440
|
WriteResult,
|
|
321
441
|
} from "@cosmicdrift/kumiko-renderer/headless";
|
|
322
|
-
|
|
442
|
+
import {
|
|
443
|
+
answerBriefing,
|
|
444
|
+
answerCustomers,
|
|
445
|
+
answerDeadlines,
|
|
446
|
+
answerMoney,
|
|
447
|
+
answerNowList,
|
|
448
|
+
answerOrderDetail,
|
|
449
|
+
answerOrderList,
|
|
450
|
+
answerOrderSummary,
|
|
451
|
+
orderListSchema,
|
|
452
|
+
orderSummarySchema,
|
|
453
|
+
} from "../../src/order-board";
|
|
454
|
+
|
|
455
|
+
const QUERY_ORDER_LIST = "order-desk:query:order:list";
|
|
456
|
+
const QUERY_ORDER_SUMMARY = "order-desk:query:order:summary";
|
|
457
|
+
const QUERY_ORDER_NOW = "order-desk:query:order:now";
|
|
458
|
+
const QUERY_ORDER_BRIEFING = "order-desk:query:order:briefing";
|
|
459
|
+
const QUERY_ORDER_DEADLINES = "order-desk:query:order:deadlines";
|
|
460
|
+
const QUERY_ORDER_CUSTOMERS = "order-desk:query:order:customers";
|
|
461
|
+
const QUERY_ORDER_MONEY = "order-desk:query:order:money";
|
|
323
462
|
const QUERY_ORDER_DETAIL = "order-desk:query:order:detail";
|
|
324
463
|
const QUERY_ORDER_ITEMS = "order-desk:query:order:items";
|
|
325
464
|
const QUERY_ORDER_PAYMENTS = "order-desk:query:order:payments";
|
|
326
465
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
466
|
+
// The guidance blocks (breadcrumb, summary, banner, progress, steps) stack tall above the tabs;
|
|
467
|
+
// the height specs measure the tab panel and run without them, `?guidance=1` turns them on.
|
|
468
|
+
function orderDetailForUrl(id: string): Record<string, unknown> {
|
|
469
|
+
const {
|
|
470
|
+
path,
|
|
471
|
+
summaryLine,
|
|
472
|
+
summaryShort,
|
|
473
|
+
summaryTone,
|
|
474
|
+
notice,
|
|
475
|
+
steps,
|
|
476
|
+
progress,
|
|
477
|
+
...withoutGuidance
|
|
478
|
+
} = answerOrderDetail(id);
|
|
479
|
+
const withGuidance = new URLSearchParams(window.location.search).has("guidance");
|
|
480
|
+
return withGuidance
|
|
481
|
+
? { ...withoutGuidance, path, summaryLine, summaryShort, summaryTone, notice, steps, progress }
|
|
482
|
+
: withoutGuidance;
|
|
483
|
+
}
|
|
336
484
|
|
|
337
485
|
function itemsCountFromUrl(): number {
|
|
338
486
|
const raw = new URLSearchParams(window.location.search).get("items");
|
|
@@ -367,7 +515,30 @@ export function createMockDispatcher(): Dispatcher {
|
|
|
367
515
|
if (type === QUERY_ORDER_DETAIL) {
|
|
368
516
|
const data = (payload ?? {}) as Record<string, unknown>; // @cast-boundary mock-dispatcher wire payload
|
|
369
517
|
const id = (data["id"] as string | undefined) ?? "order-1";
|
|
370
|
-
return { isSuccess: true, data:
|
|
518
|
+
return { isSuccess: true, data: orderDetailForUrl(id) as unknown as TData };
|
|
519
|
+
}
|
|
520
|
+
if (type === QUERY_ORDER_LIST) {
|
|
521
|
+
const answer = answerOrderList(orderListSchema.parse(payload ?? {}));
|
|
522
|
+
return { isSuccess: true, data: answer as unknown as TData };
|
|
523
|
+
}
|
|
524
|
+
if (type === QUERY_ORDER_SUMMARY) {
|
|
525
|
+
const answer = answerOrderSummary(orderSummarySchema.parse(payload ?? {}));
|
|
526
|
+
return { isSuccess: true, data: answer as unknown as TData };
|
|
527
|
+
}
|
|
528
|
+
if (type === QUERY_ORDER_NOW) {
|
|
529
|
+
return { isSuccess: true, data: answerNowList() as unknown as TData };
|
|
530
|
+
}
|
|
531
|
+
if (type === QUERY_ORDER_BRIEFING) {
|
|
532
|
+
return { isSuccess: true, data: answerBriefing() as unknown as TData };
|
|
533
|
+
}
|
|
534
|
+
if (type === QUERY_ORDER_DEADLINES) {
|
|
535
|
+
return { isSuccess: true, data: answerDeadlines() as unknown as TData };
|
|
536
|
+
}
|
|
537
|
+
if (type === QUERY_ORDER_CUSTOMERS) {
|
|
538
|
+
return { isSuccess: true, data: answerCustomers() as unknown as TData };
|
|
539
|
+
}
|
|
540
|
+
if (type === QUERY_ORDER_MONEY) {
|
|
541
|
+
return { isSuccess: true, data: answerMoney() as unknown as TData };
|
|
371
542
|
}
|
|
372
543
|
if (type === QUERY_ORDER_ITEMS) {
|
|
373
544
|
return { isSuccess: true, data: { rows: buildItemRows(itemsCountFromUrl()) } as TData };
|
|
@@ -574,20 +745,20 @@ test.describe("record-detail-layout — tall tab panel scrolls", () => {
|
|
|
574
745
|
});
|
|
575
746
|
|
|
576
747
|
test.describe("record-detail-layout — header action per tab", () => {
|
|
577
|
-
const recordPayment = "
|
|
748
|
+
const recordPayment = "Record payment";
|
|
578
749
|
|
|
579
750
|
test("record-payment shows on the payments tab only", async ({ page }) => {
|
|
580
751
|
await page.goto("/?tab=payments");
|
|
581
752
|
await expect(page.getByTestId("kumiko-screen-projection-detail-tabs")).toBeVisible();
|
|
582
753
|
// The third header action lands in the overflow menu.
|
|
583
754
|
await page.getByRole("button", { name: "More actions" }).last().click();
|
|
584
|
-
await expect(page.
|
|
755
|
+
await expect(page.getByRole("menuitem", { name: recordPayment })).toBeVisible();
|
|
585
756
|
|
|
586
757
|
await page.goto("/?tab=items");
|
|
587
758
|
await expect(page.getByTestId("render-list-table")).toBeVisible();
|
|
588
759
|
// Only two actions remain, so no overflow menu is rendered.
|
|
589
760
|
await expect(page.getByRole("button", { name: "More actions" })).toHaveCount(0);
|
|
590
|
-
await expect(page.
|
|
761
|
+
await expect(page.getByRole("menuitem", { name: recordPayment })).toHaveCount(0);
|
|
591
762
|
});
|
|
592
763
|
});
|
|
593
764
|
```
|
|
@@ -701,7 +872,7 @@ export default defineConfig({
|
|
|
701
872
|
projects: [
|
|
702
873
|
{
|
|
703
874
|
name: "chromium",
|
|
704
|
-
testIgnore: /(phone-viewport|padding-parity-screenshots)\.spec\.ts$/,
|
|
875
|
+
testIgnore: /(phone-viewport|padding-parity-screenshots|board-screenshots)\.spec\.ts$/,
|
|
705
876
|
use: { ...devices["Desktop Chrome"], viewport: { width: 1440, height: 900 } },
|
|
706
877
|
},
|
|
707
878
|
// Desktop copy of padding-parity-screenshots.spec.ts, distinct from the
|
|
@@ -712,7 +883,7 @@ export default defineConfig({
|
|
|
712
883
|
? [
|
|
713
884
|
{
|
|
714
885
|
name: "chromium-desktop-screenshots",
|
|
715
|
-
testMatch: /padding-parity-screenshots\.spec\.ts$/,
|
|
886
|
+
testMatch: /(padding-parity-screenshots|board-screenshots)\.spec\.ts$/,
|
|
716
887
|
use: { ...devices["Desktop Chrome"], viewport: { width: 1440, height: 900 } },
|
|
717
888
|
},
|
|
718
889
|
]
|
|
@@ -725,7 +896,7 @@ export default defineConfig({
|
|
|
725
896
|
{
|
|
726
897
|
name: "chromium-phone",
|
|
727
898
|
testMatch: WITH_PARITY_SCREENSHOTS
|
|
728
|
-
? /(phone-viewport|padding-parity-screenshots)\.spec\.ts$/
|
|
899
|
+
? /(phone-viewport|padding-parity-screenshots|board-screenshots)\.spec\.ts$/
|
|
729
900
|
: /phone-viewport\.spec\.ts$/,
|
|
730
901
|
use: { ...devices["Desktop Chrome"], viewport: { width: 390, height: 844 } },
|
|
731
902
|
},
|
|
@@ -743,6 +914,86 @@ export default defineConfig({
|
|
|
743
914
|
});
|
|
744
915
|
```
|
|
745
916
|
|
|
917
|
+
### e2e/work-queue.spec.ts
|
|
918
|
+
|
|
919
|
+
```ts
|
|
920
|
+
// The orders work queue: named filters in one select with hit counts, a filter-owned sort,
|
|
921
|
+
// a filter-owned empty state with a reset button, and the summary row footer.
|
|
922
|
+
|
|
923
|
+
import { expect, boundaryGuardedTest as test } from "@cosmicdrift/kumiko-testing/e2e";
|
|
924
|
+
|
|
925
|
+
const FILTER_FACET = "facet-__namedFilter";
|
|
926
|
+
// The open reason box renders as its own table row under the data row; count data rows only.
|
|
927
|
+
const DATA_ROWS = "tbody tr:not([data-reason-row])";
|
|
928
|
+
|
|
929
|
+
test("picking a named filter narrows the list and sorts it by the filter's own order", async ({
|
|
930
|
+
page,
|
|
931
|
+
}) => {
|
|
932
|
+
await page.goto("/orders");
|
|
933
|
+
await expect(page.getByText("SO-10483")).toBeVisible();
|
|
934
|
+
|
|
935
|
+
await page.getByTestId(FILTER_FACET).click();
|
|
936
|
+
await expect(page.getByTestId(`${FILTER_FACET}-action-needed`)).toContainText("5");
|
|
937
|
+
await page.getByTestId(`${FILTER_FACET}-action-needed`).click();
|
|
938
|
+
|
|
939
|
+
await expect(page.getByText("SO-10483")).toHaveCount(0);
|
|
940
|
+
const rowTexts = await page.locator(DATA_ROWS).allInnerTexts();
|
|
941
|
+
const orderNumbers = rowTexts.map((text) => /SO-\d+/.exec(text)?.[0]);
|
|
942
|
+
expect(orderNumbers).toEqual(["SO-10482", "SO-10488", "SO-10484", "SO-10485", "SO-10486"]);
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
test("a filter without hits shows its own empty state, and its reset button brings the list back", async ({
|
|
946
|
+
page,
|
|
947
|
+
}) => {
|
|
948
|
+
await page.goto("/orders");
|
|
949
|
+
await page.getByTestId(FILTER_FACET).click();
|
|
950
|
+
await page.getByTestId(`${FILTER_FACET}-reminder-due`).click();
|
|
951
|
+
|
|
952
|
+
await expect(page.getByTestId("render-list-empty-reset-filter")).toBeVisible();
|
|
953
|
+
await expect(page.getByText("SO-10482")).toHaveCount(0);
|
|
954
|
+
|
|
955
|
+
await page.getByTestId("render-list-empty-reset-filter").click();
|
|
956
|
+
await expect(page.getByText("SO-10482")).toBeVisible();
|
|
957
|
+
await expect(page.getByTestId("render-list-empty-reset-filter")).toHaveCount(0);
|
|
958
|
+
});
|
|
959
|
+
|
|
960
|
+
test("the summary row is the only footer and carries the open amount", async ({ page }) => {
|
|
961
|
+
await page.goto("/orders");
|
|
962
|
+
await expect(page.getByTestId("list-summary")).toContainText("2,497.00");
|
|
963
|
+
await expect(page.getByTestId("list-totals")).toHaveCount(0);
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
test("the sort select reorders the list by the chosen option", async ({ page }) => {
|
|
967
|
+
await page.goto("/orders");
|
|
968
|
+
const select = page.getByTestId("render-list-table-sort-options");
|
|
969
|
+
await expect(page.getByTestId("render-list-table-sort-options-label")).toContainText("Sorted by");
|
|
970
|
+
await select.selectOption({ label: "Customer A-Z" });
|
|
971
|
+
await expect(page.getByTestId("render-list-table-sort-options-label")).toContainText(
|
|
972
|
+
"Customer A-Z",
|
|
973
|
+
);
|
|
974
|
+
const rowTexts = await page.locator(DATA_ROWS).allInnerTexts();
|
|
975
|
+
const customers = rowTexts.map(
|
|
976
|
+
(text) => /Aiko|Emma|Jonas|Kenji|Lars|Maria|Priya|Tom/.exec(text)?.[0],
|
|
977
|
+
);
|
|
978
|
+
expect(customers).toEqual([...customers].sort());
|
|
979
|
+
});
|
|
980
|
+
|
|
981
|
+
test("the summary row follows the filter", async ({ page }) => {
|
|
982
|
+
await page.goto("/orders");
|
|
983
|
+
await expect(page.getByTestId("list-summary")).toContainText(/^8€/);
|
|
984
|
+
await page.getByTestId(FILTER_FACET).click();
|
|
985
|
+
await page.getByTestId(`${FILTER_FACET}-action-needed`).click();
|
|
986
|
+
await expect(page.getByTestId("list-summary")).toContainText(/^5€/);
|
|
987
|
+
});
|
|
988
|
+
|
|
989
|
+
test("a stat tile on the dashboard links into the filtered list", async ({ page }) => {
|
|
990
|
+
await page.goto("/today");
|
|
991
|
+
await page.getByText("Need action").click();
|
|
992
|
+
await expect(page).toHaveURL(/orders/);
|
|
993
|
+
await expect(page.getByText("SO-10483")).toHaveCount(0);
|
|
994
|
+
});
|
|
995
|
+
```
|
|
996
|
+
|
|
746
997
|
### src/__tests__/feature.test.ts
|
|
747
998
|
|
|
748
999
|
```ts
|
|
@@ -765,6 +1016,15 @@ import {
|
|
|
765
1016
|
import { withBootValidatorFixture } from "@cosmicdrift/kumiko-testing/helpers";
|
|
766
1017
|
import { z } from "zod";
|
|
767
1018
|
import { createOrderDeskFeature } from "../feature";
|
|
1019
|
+
import {
|
|
1020
|
+
answerBriefing,
|
|
1021
|
+
answerNextReminder,
|
|
1022
|
+
answerOrderDetail,
|
|
1023
|
+
answerOrderList,
|
|
1024
|
+
answerOrderSummary,
|
|
1025
|
+
orderListSchema,
|
|
1026
|
+
orderSummarySchema,
|
|
1027
|
+
} from "../order-board";
|
|
768
1028
|
|
|
769
1029
|
function validateBoot(features: Parameters<typeof validateBootRaw>[0]): void {
|
|
770
1030
|
validateBootRaw(withBootValidatorFixture(features));
|
|
@@ -788,6 +1048,8 @@ describe("record-detail-layout showcase — registration", () => {
|
|
|
788
1048
|
if (screen?.type !== "projectionDetail") throw new Error("expected projectionDetail");
|
|
789
1049
|
expect(screen.header).toEqual({
|
|
790
1050
|
title: "customerName",
|
|
1051
|
+
shortTitle: "shortTitle",
|
|
1052
|
+
narrowSubtitle: "narrowSubtitle",
|
|
791
1053
|
subtitle: [
|
|
792
1054
|
"orderNumber",
|
|
793
1055
|
{ field: "placedAt", format: { format: "date", dateStyle: "medium" } },
|
|
@@ -825,12 +1087,225 @@ describe("record-detail-layout showcase — registration", () => {
|
|
|
825
1087
|
expect(screen.inlineActions).toEqual(["download-invoice"]);
|
|
826
1088
|
});
|
|
827
1089
|
|
|
828
|
-
test("relatedList columns
|
|
1090
|
+
test("relatedList columns carry their own header label, there is no entity to resolve it from", () => {
|
|
829
1091
|
const screen = registry.getScreen("order-desk:screen:order-detail");
|
|
830
1092
|
if (screen?.type !== "projectionDetail") throw new Error("expected projectionDetail");
|
|
831
1093
|
const itemsSection = screen.layout.sections[0];
|
|
832
1094
|
if (itemsSection?.kind !== "relatedList") throw new Error("expected relatedList");
|
|
833
|
-
expect(normalizeListColumn(itemsSection.columns[0]!)).toEqual({
|
|
1095
|
+
expect(normalizeListColumn(itemsSection.columns[0]!)).toEqual({
|
|
1096
|
+
field: "sku",
|
|
1097
|
+
label: "order-desk.col.sku",
|
|
1098
|
+
});
|
|
1099
|
+
});
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
describe("record-detail-layout showcase — guidance", () => {
|
|
1103
|
+
test("the orders list carries rowToneField and a hint column", () => {
|
|
1104
|
+
const screen = registry.getScreen("order-desk:screen:orders");
|
|
1105
|
+
if (screen?.type !== "projectionList") throw new Error("expected projectionList");
|
|
1106
|
+
expect(screen.rowToneField).toBe("tone");
|
|
1107
|
+
const hint = screen.columns.map((c) => normalizeListColumn(c)).find((c) => c.hint);
|
|
1108
|
+
expect(hint?.hint?.detailField).toBe("nextStepDue");
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
test("the detail screen declares breadcrumb, summary, banner and steps from query fields", () => {
|
|
1112
|
+
const screen = registry.getScreen("order-desk:screen:order-detail");
|
|
1113
|
+
if (screen?.type !== "projectionDetail") throw new Error("expected projectionDetail");
|
|
1114
|
+
expect(screen.breadcrumb).toEqual({ field: "path" });
|
|
1115
|
+
expect(screen.summary).toEqual({
|
|
1116
|
+
field: "summaryLine",
|
|
1117
|
+
narrowField: "summaryShort",
|
|
1118
|
+
toneField: "summaryTone",
|
|
1119
|
+
});
|
|
1120
|
+
expect(screen.banner?.field).toBe("notice");
|
|
1121
|
+
expect(screen.steps?.field).toBe("steps");
|
|
1122
|
+
expect(screen.progress?.field).toBe("progress");
|
|
1123
|
+
});
|
|
1124
|
+
});
|
|
1125
|
+
|
|
1126
|
+
describe("record-detail-layout showcase — work queue", () => {
|
|
1127
|
+
test("the orders list offers named filters as a counted select, with sort and empty state", () => {
|
|
1128
|
+
const screen = registry.getScreen("order-desk:screen:orders");
|
|
1129
|
+
if (screen?.type !== "projectionList") throw new Error("expected projectionList");
|
|
1130
|
+
expect(screen.namedFilters?.map((filter) => filter.id)).toEqual([
|
|
1131
|
+
"action-needed",
|
|
1132
|
+
"reminder-due",
|
|
1133
|
+
"ending-soon",
|
|
1134
|
+
]);
|
|
1135
|
+
expect(screen.namedFilterFacet).toEqual({
|
|
1136
|
+
display: "select",
|
|
1137
|
+
showCounts: true,
|
|
1138
|
+
label: "order-desk.orders.todo",
|
|
1139
|
+
narrowPlacement: "behind-filter",
|
|
1140
|
+
});
|
|
1141
|
+
const buttons = (screen.rowActions ?? []).filter((action) => action.display === "button");
|
|
1142
|
+
expect(buttons.map((action) => [action.id, action.visible])).toEqual([
|
|
1143
|
+
["remind", { field: "canRemind", eq: true }],
|
|
1144
|
+
["open-order", { field: "canRemind", eq: false }],
|
|
1145
|
+
]);
|
|
1146
|
+
expect(screen.namedFilters?.[0]?.sort).toEqual({ field: "urgency", dir: "desc" });
|
|
1147
|
+
expect(screen.namedFilters?.[0]?.emptyState?.title).toBe("order-desk.orders.all-done");
|
|
1148
|
+
expect(screen.table?.totals).toBeUndefined();
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
test("the list query filters, sorts, counts and aggregates like the screen asks", () => {
|
|
1152
|
+
const ask = (payload: object) => answerOrderList(orderListSchema.parse(payload));
|
|
1153
|
+
const open = ask({ namedFilter: "action-needed", sort: "urgency", sortDirection: "desc" });
|
|
1154
|
+
if (!("rows" in open)) throw new Error("expected rows");
|
|
1155
|
+
expect(open.rows.map((row) => row.id)).toEqual(["o1", "o7", "o3", "o4", "o5"]);
|
|
1156
|
+
|
|
1157
|
+
const counted = ask({ namedFilter: "action-needed", limit: 1, totalCount: true });
|
|
1158
|
+
if (!("rows" in counted)) throw new Error("expected rows");
|
|
1159
|
+
expect(counted.rows).toHaveLength(1);
|
|
1160
|
+
expect(counted.total).toBe(5);
|
|
1161
|
+
|
|
1162
|
+
const none = ask({ namedFilter: "reminder-due", totalCount: true });
|
|
1163
|
+
if (!("rows" in none)) throw new Error("expected rows");
|
|
1164
|
+
expect(none.rows).toHaveLength(0);
|
|
1165
|
+
|
|
1166
|
+
const totals = ask({
|
|
1167
|
+
aggregate: { measures: [{ field: "openAmount", kind: "sum" }] },
|
|
1168
|
+
});
|
|
1169
|
+
if (!("groups" in totals)) throw new Error("expected groups");
|
|
1170
|
+
expect(totals.groups[0]?.measures).toEqual([2497]);
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
test("the today dashboard counts through the list query and links into the filtered list", () => {
|
|
1174
|
+
const screen = registry.getScreen("order-desk:screen:today");
|
|
1175
|
+
if (screen?.type !== "dashboard") throw new Error("expected dashboard");
|
|
1176
|
+
expect(screen.panels.map((panel) => panel.kind)).toEqual([
|
|
1177
|
+
"text",
|
|
1178
|
+
"stat-group",
|
|
1179
|
+
"list",
|
|
1180
|
+
"list",
|
|
1181
|
+
"list",
|
|
1182
|
+
"stat-group",
|
|
1183
|
+
]);
|
|
1184
|
+
const counts = screen.panels.find((panel) => panel.id === "queue-counts");
|
|
1185
|
+
if (counts?.kind !== "stat-group") throw new Error("expected stat-group");
|
|
1186
|
+
expect(counts.stats.map((stat) => stat.navigate?.namedFilter)).toEqual([
|
|
1187
|
+
"action-needed",
|
|
1188
|
+
"reminder-due",
|
|
1189
|
+
"ending-soon",
|
|
1190
|
+
]);
|
|
1191
|
+
});
|
|
1192
|
+
});
|
|
1193
|
+
|
|
1194
|
+
describe("record-detail-layout showcase — board gaps", () => {
|
|
1195
|
+
test("the orders list declares sort options, a summary query and a self-sizing hint column", () => {
|
|
1196
|
+
const screen = registry.getScreen("order-desk:screen:orders");
|
|
1197
|
+
if (screen?.type !== "projectionList") throw new Error("expected projectionList");
|
|
1198
|
+
expect(screen.sortOptions?.map((option) => [option.field, option.dir])).toEqual([
|
|
1199
|
+
["urgency", "desc"],
|
|
1200
|
+
["customerName", "asc"],
|
|
1201
|
+
]);
|
|
1202
|
+
expect(screen.table?.summaryRow?.query).toBe("order-desk:query:order:summary");
|
|
1203
|
+
const hint = screen.columns.map((c) => normalizeListColumn(c)).find((c) => c.hint);
|
|
1204
|
+
expect([hint?.width, hint?.minWidth]).toEqual([320, 240]);
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
test("the summary query follows the named filter", () => {
|
|
1208
|
+
const all = answerOrderSummary(orderSummarySchema.parse({}));
|
|
1209
|
+
const open = answerOrderSummary(orderSummarySchema.parse({ namedFilter: "action-needed" }));
|
|
1210
|
+
expect(all.items[0]?.value).toBe(8);
|
|
1211
|
+
expect(open.items[0]?.value).toBe(5);
|
|
1212
|
+
expect(all.items.map((item) => item.label)).toEqual(["Orders", "Open", "Overdue"]);
|
|
1213
|
+
});
|
|
1214
|
+
|
|
1215
|
+
test("the today board links its list and stat group and the detail places progress beside the steps", () => {
|
|
1216
|
+
const today = registry.getScreen("order-desk:screen:today");
|
|
1217
|
+
if (today?.type !== "dashboard") throw new Error("expected dashboard");
|
|
1218
|
+
const now = today.panels.find((panel) => panel.id === "now");
|
|
1219
|
+
if (now?.kind !== "list") throw new Error("expected the now list");
|
|
1220
|
+
expect(now.footerLink?.namedFilter).toBe("action-needed");
|
|
1221
|
+
const counts = today.panels.find((panel) => panel.id === "queue-counts");
|
|
1222
|
+
if (counts?.kind !== "stat-group") throw new Error("expected stat-group");
|
|
1223
|
+
expect([counts.layout, counts.link?.screen]).toEqual(["strip", "orders"]);
|
|
1224
|
+
|
|
1225
|
+
const detail = registry.getScreen("order-desk:screen:order-detail");
|
|
1226
|
+
if (detail?.type !== "projectionDetail") throw new Error("expected projectionDetail");
|
|
1227
|
+
expect(detail.progress?.placement).toBe("beside-steps");
|
|
1228
|
+
expect(detail.metricsPlacement).toEqual({ narrow: "after-guidance" });
|
|
1229
|
+
expect(detail.metrics?.map((metric) => metric.subField)).toContain("totalNote");
|
|
1230
|
+
});
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
describe("record-detail-layout showcase — phone variants", () => {
|
|
1234
|
+
test("the today board limits, collapses and hides panels under sm", () => {
|
|
1235
|
+
const today = registry.getScreen("order-desk:screen:today");
|
|
1236
|
+
if (today?.type !== "dashboard") throw new Error("expected dashboard");
|
|
1237
|
+
const panel = (id: string) => today.panels.find((candidate) => candidate.id === id);
|
|
1238
|
+
const now = panel("now");
|
|
1239
|
+
const deadlines = panel("deadlines");
|
|
1240
|
+
if (now?.kind !== "list" || deadlines?.kind !== "list") throw new Error("expected lists");
|
|
1241
|
+
expect(now.narrow).toEqual({ layout: "cards", limit: 3 });
|
|
1242
|
+
expect(deadlines.narrow?.field).toBe("title");
|
|
1243
|
+
expect(deadlines.narrow?.moreText).toBe("order-desk.today.deadlines-more-narrow");
|
|
1244
|
+
expect(deadlines.icon).toEqual({ react: { __component: "DeadlinesIcon" } });
|
|
1245
|
+
expect(deadlines.footerLink?.narrowOnly).toBe(true);
|
|
1246
|
+
expect(deadlines.rowLink).toEqual({
|
|
1247
|
+
screenField: "screen",
|
|
1248
|
+
paramsField: "params",
|
|
1249
|
+
icon: "chevron",
|
|
1250
|
+
});
|
|
1251
|
+
expect(panel("customers")?.kind === "list" && panel("customers")).toBeTruthy();
|
|
1252
|
+
expect(panel("customers")?.hideOnNarrow).toBe(true);
|
|
1253
|
+
expect(panel("money")?.hideOnNarrow).toBe(true);
|
|
1254
|
+
});
|
|
1255
|
+
|
|
1256
|
+
test("the detail shortens summary and steps and drops the chain under sm", () => {
|
|
1257
|
+
const detail = registry.getScreen("order-desk:screen:order-detail");
|
|
1258
|
+
if (detail?.type !== "projectionDetail") throw new Error("expected projectionDetail");
|
|
1259
|
+
expect(detail.steps?.narrowLimit).toBe(3);
|
|
1260
|
+
expect(detail.progress?.hideOnNarrow).toBe(true);
|
|
1261
|
+
expect(answerOrderDetail("o1").steps.length).toBeGreaterThan(3);
|
|
1262
|
+
});
|
|
1263
|
+
|
|
1264
|
+
test("the board uses the round-5 phone and row options", () => {
|
|
1265
|
+
const today = registry.getScreen("order-desk:screen:today");
|
|
1266
|
+
if (today?.type !== "dashboard") throw new Error("expected dashboard");
|
|
1267
|
+
const customers = today.panels.find((candidate) => candidate.id === "customers");
|
|
1268
|
+
if (customers?.kind !== "list") throw new Error("expected the customers list");
|
|
1269
|
+
expect(customers.rowLink).toEqual({ screen: "order-detail", paramField: "params" });
|
|
1270
|
+
expect(customers.rowToneMarker).toBe("dot");
|
|
1271
|
+
expect(today.panels.find((candidate) => candidate.id === "briefing")?.narrowOrder).toBe(1);
|
|
1272
|
+
expect(answerOrderSummary(orderSummarySchema.parse({})).items.map((i) => i.column)).toEqual([
|
|
1273
|
+
"orderNumber",
|
|
1274
|
+
"openAmount",
|
|
1275
|
+
"urgencyLabel",
|
|
1276
|
+
]);
|
|
1277
|
+
});
|
|
1278
|
+
|
|
1279
|
+
test("the briefing answers a shorter variant for phones", () => {
|
|
1280
|
+
expect(answerBriefing().narrowBlocks.length).toBeGreaterThan(0);
|
|
1281
|
+
});
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
describe("record-detail-layout showcase — board gaps round 8", () => {
|
|
1285
|
+
test("two narrow-only value columns stand side by side on the phone card", () => {
|
|
1286
|
+
const screen = registry.getScreen("order-desk:screen:orders");
|
|
1287
|
+
if (screen?.type !== "projectionList") throw new Error("expected projectionList");
|
|
1288
|
+
const inline = screen.columns
|
|
1289
|
+
.map((column) => normalizeListColumn(column))
|
|
1290
|
+
.filter((column) => column.narrowInline === true);
|
|
1291
|
+
expect(inline.map((column) => [column.field, column.showOnNarrowOnly])).toEqual([
|
|
1292
|
+
["narrowOpen", true],
|
|
1293
|
+
["narrowStatus", true],
|
|
1294
|
+
]);
|
|
1295
|
+
const first = answerOrderList(orderListSchema.parse({}));
|
|
1296
|
+
expect("rows" in first && first.rows[0]?.narrowOpen).toBe("€ 312.00 open");
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
test("the reminder-due empty state takes its description params from a registered query", () => {
|
|
1300
|
+
const screen = registry.getScreen("order-desk:screen:orders");
|
|
1301
|
+
if (screen?.type !== "projectionList") throw new Error("expected projectionList");
|
|
1302
|
+
const reminder = screen.namedFilters?.find((filter) => filter.id === "reminder-due");
|
|
1303
|
+
expect(reminder?.emptyState).toEqual({
|
|
1304
|
+
title: "order-desk.orders.all-done",
|
|
1305
|
+
description: "order-desk.orders.next-reminder",
|
|
1306
|
+
paramsQuery: "order-desk:query:order:next-reminder",
|
|
1307
|
+
});
|
|
1308
|
+
expect(answerNextReminder()).toEqual({ customer: "Aiko Tanaka", due: "by Friday" });
|
|
834
1309
|
});
|
|
835
1310
|
});
|
|
836
1311
|
|
|
@@ -869,6 +1344,24 @@ describe("record-detail-layout showcase — boot-validator catches author mistak
|
|
|
869
1344
|
expect(() => validateBoot([broken])).toThrow(/metric "totalAmount" has no "label"/);
|
|
870
1345
|
});
|
|
871
1346
|
|
|
1347
|
+
test("a hint column naming an empty detail field fails boot", () => {
|
|
1348
|
+
const broken = defineFeature("broken-order-desk-hint", (r) => {
|
|
1349
|
+
r.queryHandler({
|
|
1350
|
+
name: "order:list",
|
|
1351
|
+
schema: z.object({}),
|
|
1352
|
+
handler: async () => ({ rows: [] }),
|
|
1353
|
+
access: { openToAll: { reason: "test handler callable by any signed-in test user" } },
|
|
1354
|
+
});
|
|
1355
|
+
r.screen({
|
|
1356
|
+
id: "orders",
|
|
1357
|
+
type: "projectionList",
|
|
1358
|
+
query: "broken-order-desk-hint:query:order:list",
|
|
1359
|
+
columns: [{ field: "nextStep", hint: { detailField: "" } }],
|
|
1360
|
+
});
|
|
1361
|
+
});
|
|
1362
|
+
expect(() => validateBoot([broken])).toThrow(/list\/guidance-field-empty/);
|
|
1363
|
+
});
|
|
1364
|
+
|
|
872
1365
|
test("tabs with only one section fails boot", () => {
|
|
873
1366
|
const broken = defineFeature("broken-order-desk-tabs", (r) => {
|
|
874
1367
|
r.queryHandler({
|
|
@@ -892,59 +1385,180 @@ describe("record-detail-layout showcase — boot-validator catches author mistak
|
|
|
892
1385
|
});
|
|
893
1386
|
```
|
|
894
1387
|
|
|
1388
|
+
### src/__tests__/next-reminder.integration.test.ts
|
|
1389
|
+
|
|
1390
|
+
```ts
|
|
1391
|
+
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
1392
|
+
import { createTestUser, testTenantId } from "@cosmicdrift/kumiko-framework/seeding";
|
|
1393
|
+
import { setupTestStack, type TestStack } from "@cosmicdrift/kumiko-testing/stack";
|
|
1394
|
+
import { createOrderDeskFeature } from "../feature";
|
|
1395
|
+
|
|
1396
|
+
let stack: TestStack;
|
|
1397
|
+
const support = createTestUser({ roles: ["Support"], tenantId: testTenantId(1) });
|
|
1398
|
+
|
|
1399
|
+
beforeAll(async () => {
|
|
1400
|
+
stack = await setupTestStack({ features: [createOrderDeskFeature()], systemHooks: [] });
|
|
1401
|
+
});
|
|
1402
|
+
|
|
1403
|
+
afterAll(async () => {
|
|
1404
|
+
await stack.cleanup();
|
|
1405
|
+
});
|
|
1406
|
+
|
|
1407
|
+
describe("emptyState.paramsQuery over HTTP", () => {
|
|
1408
|
+
test("the query the reminder-due empty state names answers the params of its description", async () => {
|
|
1409
|
+
const params = await stack.http.queryOk<{ customer: string; due: string }>(
|
|
1410
|
+
"order-desk:query:order:next-reminder",
|
|
1411
|
+
{},
|
|
1412
|
+
support,
|
|
1413
|
+
);
|
|
1414
|
+
expect(params).toEqual({ customer: "Aiko Tanaka", due: "by Friday" });
|
|
1415
|
+
});
|
|
1416
|
+
|
|
1417
|
+
test("a caller without the list's roles cannot read the params", async () => {
|
|
1418
|
+
const outsider = createTestUser({ roles: ["User"], tenantId: testTenantId(1) });
|
|
1419
|
+
const denied = await stack.http.queryErr("order-desk:query:order:next-reminder", {}, outsider);
|
|
1420
|
+
expect(denied.code).toBe("access_denied");
|
|
1421
|
+
});
|
|
1422
|
+
});
|
|
1423
|
+
```
|
|
1424
|
+
|
|
895
1425
|
### src/feature.ts
|
|
896
1426
|
|
|
897
1427
|
```ts
|
|
898
|
-
// Record Detail Layout Showcase — a
|
|
899
|
-
// "Akte" (case file) layout:
|
|
1428
|
+
// Record Detail Layout Showcase — a work queue, a briefing dashboard and a
|
|
1429
|
+
// projectionDetail screen with the "Akte" (case file) layout:
|
|
900
1430
|
// 1. `header` renders the query row's customer/order/status columns above
|
|
901
1431
|
// the layout — the identity a support agent scans first.
|
|
902
|
-
// 2. `metrics` renders a labeled band of key numbers from the same row
|
|
903
|
-
//
|
|
904
|
-
//
|
|
905
|
-
// 3. `layout.mode: "tabs"` splits the record into four tabs: two
|
|
906
|
-
//
|
|
907
|
-
//
|
|
908
|
-
//
|
|
909
|
-
// parity check — every tab kind must sit in the same Card padding, no
|
|
910
|
-
// section carries extra chrome of its own).
|
|
1432
|
+
// 2. `metrics` renders a labeled band of key numbers from the same row; each metric
|
|
1433
|
+
// carries its own i18n `label`, there is no fallback to the raw column name. Tiles take a
|
|
1434
|
+
// fixed `tone` or a per-record `toneField` and can jump to a tab with `navigate`.
|
|
1435
|
+
// 3. `layout.mode: "tabs"` splits the record into four tabs: two `relatedList`
|
|
1436
|
+
// sections (own query, own pagination, mounts only when active, badge via `countField`),
|
|
1437
|
+
// one `fields` section (master data) and one `extension` section (plugin-mounted component;
|
|
1438
|
+
// every tab kind sits in the same Card padding, no extra chrome).
|
|
911
1439
|
// 4. The payments tab's emptyState picks its text from the order record through `variants`.
|
|
912
1440
|
// 5. A screen-level `actions` entry (fw#3234) renders next to the header,
|
|
913
1441
|
// not inside any tab's Card. `inlineActions` keeps download-invoice a visible
|
|
914
1442
|
// button next to it where the page header would otherwise fold it into the menu.
|
|
915
|
-
//
|
|
916
1443
|
// 6. `showOnTabs` limits the record-payment action to the payments tab.
|
|
1444
|
+
// 7. Guidance: the `orders` projectionList tints rows via `rowToneField`, shows a
|
|
1445
|
+
// "to do" hint column (sentence, detail, tone, a "Why?" reason), a badge column and
|
|
1446
|
+
// per-row button actions (send a reminder, or open the record). Named filters sit in one select with hit counts,
|
|
1447
|
+
// each with its own sort and empty state; the summary row totals the rows. The detail screen adds
|
|
1448
|
+
// `breadcrumb`, `summary`, `banner` and `steps`, each reading a query field; empty values drop out.
|
|
1449
|
+
// 8. The `today` dashboard composes a lead briefing, count tiles that link into the filtered
|
|
1450
|
+
// list, a headerless "Now" list and two narrow lists on a 12-column grid.
|
|
1451
|
+
// 9. Phone variants: `hideOnNarrow` drops panels, a list panel's `narrow` turns it into limited cards or a
|
|
1452
|
+
// one-line link, `narrowBlocks` shortens the briefing, `showOnNarrowOnly` adds card-only meta, and the
|
|
1453
|
+
// detail shows `summary.narrowField`, `steps.narrowLimit` and no `progress` chain under sm.
|
|
1454
|
+
// 10. `focus: true` gives the detail a focused shell; phones get a top bar with the
|
|
1455
|
+
// record title, a back arrow to the list and the page-header overflow menu.
|
|
1456
|
+
//
|
|
1457
|
+
// 11. Phone card values: two `showOnNarrowOnly` columns with `narrowInline` stand side by side on one line.
|
|
1458
|
+
// The named-filter select sits behind the filter icon on phones (`narrowPlacement: "behind-filter"`),
|
|
1459
|
+
// and the "reminder due" empty state fills its description from a query (`emptyState.paramsQuery`).
|
|
917
1460
|
//
|
|
918
|
-
// projectionDetail
|
|
919
|
-
//
|
|
920
|
-
// query's row, not an entity field.
|
|
1461
|
+
// projectionDetail binds to an explicit query, not an entity: every field name below
|
|
1462
|
+
// (header, metrics, fields) is a column of that query's row.
|
|
921
1463
|
|
|
922
1464
|
import { defineFeature, type FeatureDefinition } from "@cosmicdrift/kumiko-framework/engine";
|
|
923
1465
|
import { z } from "zod";
|
|
1466
|
+
import {
|
|
1467
|
+
answerBriefing,
|
|
1468
|
+
answerCustomers,
|
|
1469
|
+
answerDeadlines,
|
|
1470
|
+
answerMoney,
|
|
1471
|
+
answerNextReminder,
|
|
1472
|
+
answerNowList,
|
|
1473
|
+
answerOrderDetail,
|
|
1474
|
+
answerOrderList,
|
|
1475
|
+
answerOrderSummary,
|
|
1476
|
+
orderListSchema,
|
|
1477
|
+
orderSummarySchema,
|
|
1478
|
+
} from "./order-board.ts";
|
|
924
1479
|
|
|
925
1480
|
const rowIdSchema = z.object({ id: z.string() });
|
|
1481
|
+
const noPayloadSchema = z.object({});
|
|
1482
|
+
const accessRoles = { roles: ["Support", "Admin"] } as const;
|
|
1483
|
+
|
|
1484
|
+
export const ORDER_LIST_QUERY = "order-desk:query:order:list";
|
|
926
1485
|
|
|
927
1486
|
export function createOrderDeskFeature(): FeatureDefinition {
|
|
928
1487
|
return defineFeature("order-desk", (r) => {
|
|
929
1488
|
r.systemScope();
|
|
930
1489
|
|
|
1490
|
+
r.queryHandler({
|
|
1491
|
+
name: "order:list",
|
|
1492
|
+
schema: orderListSchema,
|
|
1493
|
+
handler: async (query) => answerOrderList(query.payload),
|
|
1494
|
+
access: accessRoles,
|
|
1495
|
+
});
|
|
1496
|
+
|
|
1497
|
+
r.queryHandler({
|
|
1498
|
+
name: "order:summary",
|
|
1499
|
+
schema: orderSummarySchema,
|
|
1500
|
+
handler: async (query) => answerOrderSummary(query.payload),
|
|
1501
|
+
access: accessRoles,
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1504
|
+
r.queryHandler({
|
|
1505
|
+
name: "order:now",
|
|
1506
|
+
schema: noPayloadSchema,
|
|
1507
|
+
handler: async () => answerNowList(),
|
|
1508
|
+
access: accessRoles,
|
|
1509
|
+
});
|
|
1510
|
+
|
|
1511
|
+
r.queryHandler({
|
|
1512
|
+
name: "order:next-reminder",
|
|
1513
|
+
schema: noPayloadSchema,
|
|
1514
|
+
handler: async () => answerNextReminder(),
|
|
1515
|
+
access: accessRoles,
|
|
1516
|
+
});
|
|
1517
|
+
|
|
1518
|
+
r.queryHandler({
|
|
1519
|
+
name: "order:briefing",
|
|
1520
|
+
schema: noPayloadSchema,
|
|
1521
|
+
handler: async () => answerBriefing(),
|
|
1522
|
+
access: accessRoles,
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
r.queryHandler({
|
|
1526
|
+
name: "order:deadlines",
|
|
1527
|
+
schema: noPayloadSchema,
|
|
1528
|
+
handler: async () => answerDeadlines(),
|
|
1529
|
+
outputSchema: z.object({
|
|
1530
|
+
rows: z.array(
|
|
1531
|
+
z.object({
|
|
1532
|
+
id: z.string(),
|
|
1533
|
+
due: z.string(),
|
|
1534
|
+
title: z.string(),
|
|
1535
|
+
screen: z.string(),
|
|
1536
|
+
params: z.object({ entityId: z.string() }),
|
|
1537
|
+
}),
|
|
1538
|
+
),
|
|
1539
|
+
}),
|
|
1540
|
+
access: accessRoles,
|
|
1541
|
+
});
|
|
1542
|
+
|
|
1543
|
+
r.queryHandler({
|
|
1544
|
+
name: "order:customers",
|
|
1545
|
+
schema: noPayloadSchema,
|
|
1546
|
+
handler: async () => answerCustomers(),
|
|
1547
|
+
access: accessRoles,
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1550
|
+
r.queryHandler({
|
|
1551
|
+
name: "order:money",
|
|
1552
|
+
schema: noPayloadSchema,
|
|
1553
|
+
handler: async () => answerMoney(),
|
|
1554
|
+
access: accessRoles,
|
|
1555
|
+
});
|
|
1556
|
+
|
|
931
1557
|
r.queryHandler({
|
|
932
1558
|
name: "order:detail",
|
|
933
1559
|
schema: rowIdSchema,
|
|
934
|
-
handler: async (query) => (
|
|
935
|
-
|
|
936
|
-
customerName: "Aiko Tanaka",
|
|
937
|
-
orderNumber: "SO-10482",
|
|
938
|
-
status: "processing",
|
|
939
|
-
totalAmount: "€ 1,248.00",
|
|
940
|
-
outstandingAmount: "€ 312.00",
|
|
941
|
-
itemCount: "3",
|
|
942
|
-
placedAt: "2026-08-21",
|
|
943
|
-
shippingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
944
|
-
billingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
945
|
-
salesRep: "Jonas Weber",
|
|
946
|
-
}),
|
|
947
|
-
access: { roles: ["Support", "Admin"] },
|
|
1560
|
+
handler: async (query) => answerOrderDetail(query.payload.id),
|
|
1561
|
+
access: accessRoles,
|
|
948
1562
|
});
|
|
949
1563
|
|
|
950
1564
|
r.queryHandler({
|
|
@@ -957,7 +1571,7 @@ export function createOrderDeskFeature(): FeatureDefinition {
|
|
|
957
1571
|
{ sku: "PAD-01", description: "Desk mat", quantity: 1, unitPrice: 22 },
|
|
958
1572
|
],
|
|
959
1573
|
}),
|
|
960
|
-
access:
|
|
1574
|
+
access: accessRoles,
|
|
961
1575
|
});
|
|
962
1576
|
|
|
963
1577
|
r.queryHandler({
|
|
@@ -969,27 +1583,445 @@ export function createOrderDeskFeature(): FeatureDefinition {
|
|
|
969
1583
|
{ paidAt: "2026-08-25", amount: 312, method: "invoice", status: "pending" },
|
|
970
1584
|
],
|
|
971
1585
|
}),
|
|
972
|
-
access:
|
|
1586
|
+
access: accessRoles,
|
|
1587
|
+
});
|
|
1588
|
+
|
|
1589
|
+
r.writeHandler({
|
|
1590
|
+
name: "order:remind",
|
|
1591
|
+
schema: rowIdSchema,
|
|
1592
|
+
handler: async (event) => ({ isSuccess: true as const, data: { id: event.payload.id } }),
|
|
1593
|
+
access: accessRoles,
|
|
1594
|
+
});
|
|
1595
|
+
|
|
1596
|
+
r.translations({
|
|
1597
|
+
keys: {
|
|
1598
|
+
"screen:orders.title": { en: "Orders" },
|
|
1599
|
+
"screen:order-detail.title": { en: "Order" },
|
|
1600
|
+
"screen:today.title": { en: "Today" },
|
|
1601
|
+
"order-desk.orders.todo": { en: "To do" },
|
|
1602
|
+
"order-desk.orders.nothing-open": { en: "Nothing to do" },
|
|
1603
|
+
"order-desk.orders.all-done": { en: "All done" },
|
|
1604
|
+
"order-desk.orders.all-done-hint": { en: "No order needs you right now." },
|
|
1605
|
+
"order-desk.orders.next-reminder": { en: "Next reminder: {customer}, due {due}." },
|
|
1606
|
+
"order-desk.filter.action-needed": { en: "Needs action" },
|
|
1607
|
+
"order-desk.filter.reminder-due": { en: "Reminder due" },
|
|
1608
|
+
"order-desk.filter.ending-soon": { en: "Ending soon" },
|
|
1609
|
+
"order-desk.col.order": { en: "Order" },
|
|
1610
|
+
"order-desk.col.customer": { en: "Customer" },
|
|
1611
|
+
"order-desk.col.urgency": { en: "Urgency" },
|
|
1612
|
+
"order-desk.col.todo": { en: "To do" },
|
|
1613
|
+
"order-desk.col.open-amount": { en: "Open" },
|
|
1614
|
+
"order-desk.col.sku": { en: "SKU" },
|
|
1615
|
+
"order-desk.col.description": { en: "Description" },
|
|
1616
|
+
"order-desk.col.quantity": { en: "Quantity" },
|
|
1617
|
+
"order-desk.col.unit-price": { en: "Unit price" },
|
|
1618
|
+
"order-desk.col.paid-at": { en: "Paid on" },
|
|
1619
|
+
"order-desk.col.amount": { en: "Amount" },
|
|
1620
|
+
"order-desk.col.method": { en: "Method" },
|
|
1621
|
+
"order-desk.col.status": { en: "Status" },
|
|
1622
|
+
"order-desk.sort.urgency": { en: "Urgency" },
|
|
1623
|
+
"order-desk.sort.customer": { en: "Customer A-Z" },
|
|
1624
|
+
"order-desk.today.now": { en: "Now" },
|
|
1625
|
+
"order-desk.today.now-all": { en: "All orders needing action" },
|
|
1626
|
+
"order-desk.today.inbox": { en: "Inbox" },
|
|
1627
|
+
"order-desk.today.inbox-sub": { en: "Orders waiting for you" },
|
|
1628
|
+
"order-desk.today.inbox-link": { en: "All orders" },
|
|
1629
|
+
"order-desk.today.deadlines": { en: "Deadlines" },
|
|
1630
|
+
"order-desk.today.deadlines-all": { en: "All deadlines" },
|
|
1631
|
+
"order-desk.col.narrow-open": { en: "Open amount" },
|
|
1632
|
+
"order-desk.col.narrow-status": { en: "Status" },
|
|
1633
|
+
"order-desk.today.customers": { en: "Customers" },
|
|
1634
|
+
"order-desk.today.money": { en: "Money" },
|
|
1635
|
+
"order-desk.today.money-sub": { en: "Across all open orders" },
|
|
1636
|
+
"order-desk.today.stat.action-needed": { en: "Need action" },
|
|
1637
|
+
"order-desk.today.stat.reminder-due": { en: "Reminders due" },
|
|
1638
|
+
"order-desk.today.stat.ending-soon": { en: "Ending soon" },
|
|
1639
|
+
"order-desk.today.now-total": { en: "The {shown} most urgent of {total} orders" },
|
|
1640
|
+
"order-desk.today.now-total-narrow": { en: "{shown} of {total}" },
|
|
1641
|
+
"order-desk.today.deadlines-more": { en: "{count} more deadlines" },
|
|
1642
|
+
"order-desk.today.deadlines-more-narrow": { en: "{count} more" },
|
|
1643
|
+
"order-desk.action.record-short": { en: "Record" },
|
|
1644
|
+
"order-desk.today.stat.open": { en: "Open" },
|
|
1645
|
+
"order-desk.today.stat.overdue": { en: "Overdue" },
|
|
1646
|
+
"order-desk.today.stat.collected": { en: "Collected" },
|
|
1647
|
+
"order-desk.action.open": { en: "Open" },
|
|
1648
|
+
"order-desk.action.remind": { en: "Send reminder" },
|
|
1649
|
+
"order-desk.action.open-order": { en: "Open order" },
|
|
1650
|
+
"order-desk.action.prepare": { en: "Let the assistant prepare" },
|
|
1651
|
+
"order-desk.action.recordPayment": { en: "Record payment" },
|
|
1652
|
+
"order-desk.action.refreshOrder": { en: "Refresh" },
|
|
1653
|
+
"order-desk.action.downloadInvoice": { en: "Download invoice" },
|
|
1654
|
+
"order-desk.steps.title": { en: "Next steps" },
|
|
1655
|
+
"order-desk.steps.empty": { en: "Nothing left to do" },
|
|
1656
|
+
"order-desk.metric.totalAmount": { en: "Total" },
|
|
1657
|
+
"order-desk.metric.outstandingAmount": { en: "Outstanding" },
|
|
1658
|
+
"order-desk.metric.itemCount": { en: "Items" },
|
|
1659
|
+
"order-desk.metric.placedAt": { en: "Placed" },
|
|
1660
|
+
"order-desk.tab.items": { en: "Items" },
|
|
1661
|
+
"order-desk.tab.payments": { en: "Payments" },
|
|
1662
|
+
"order-desk.tab.details": { en: "Details" },
|
|
1663
|
+
"order-desk.tab.internalNote": { en: "Internal note" },
|
|
1664
|
+
"order-desk.payments.empty": { en: "No payments yet" },
|
|
1665
|
+
"order-desk.payments.empty-pending": { en: "A payment is pending" },
|
|
1666
|
+
},
|
|
1667
|
+
});
|
|
1668
|
+
|
|
1669
|
+
r.screen({
|
|
1670
|
+
id: "orders",
|
|
1671
|
+
type: "projectionList",
|
|
1672
|
+
query: ORDER_LIST_QUERY,
|
|
1673
|
+
rowToneField: "tone",
|
|
1674
|
+
columns: [
|
|
1675
|
+
{ field: "orderNumber", label: "order-desk.col.order" },
|
|
1676
|
+
{ field: "customerName", label: "order-desk.col.customer", hideOnNarrow: true },
|
|
1677
|
+
{
|
|
1678
|
+
field: "urgencyLabel",
|
|
1679
|
+
label: "order-desk.col.urgency",
|
|
1680
|
+
display: "badge",
|
|
1681
|
+
badgeToneField: "urgencyTone",
|
|
1682
|
+
},
|
|
1683
|
+
{
|
|
1684
|
+
field: "nextStep",
|
|
1685
|
+
label: "order-desk.col.todo",
|
|
1686
|
+
hint: {
|
|
1687
|
+
detailField: "nextStepDue",
|
|
1688
|
+
narrowDetailField: "nextStepShort",
|
|
1689
|
+
reasonField: "nextStepReason",
|
|
1690
|
+
reasonTitleField: "nextStepReasonTitle",
|
|
1691
|
+
reasonOpenField: "nextStepReasonOpen",
|
|
1692
|
+
emptyLabel: "order-desk.orders.nothing-open",
|
|
1693
|
+
},
|
|
1694
|
+
width: 320,
|
|
1695
|
+
minWidth: 240,
|
|
1696
|
+
},
|
|
1697
|
+
{ field: "openAmount", label: "order-desk.col.open-amount", hideOnNarrow: true },
|
|
1698
|
+
{
|
|
1699
|
+
field: "narrowOpen",
|
|
1700
|
+
label: "order-desk.col.narrow-open",
|
|
1701
|
+
showOnNarrowOnly: true,
|
|
1702
|
+
narrowInline: true,
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
field: "narrowStatus",
|
|
1706
|
+
label: "order-desk.col.narrow-status",
|
|
1707
|
+
showOnNarrowOnly: true,
|
|
1708
|
+
narrowInline: true,
|
|
1709
|
+
},
|
|
1710
|
+
],
|
|
1711
|
+
defaultSort: { field: "urgency", dir: "desc" },
|
|
1712
|
+
sortOptions: [
|
|
1713
|
+
{ field: "urgency", dir: "desc", label: "order-desk.sort.urgency" },
|
|
1714
|
+
{ field: "customerName", dir: "asc", label: "order-desk.sort.customer" },
|
|
1715
|
+
],
|
|
1716
|
+
namedFilters: [
|
|
1717
|
+
{
|
|
1718
|
+
id: "action-needed",
|
|
1719
|
+
label: "order-desk.filter.action-needed",
|
|
1720
|
+
sort: { field: "urgency", dir: "desc" },
|
|
1721
|
+
emptyState: {
|
|
1722
|
+
title: "order-desk.orders.all-done",
|
|
1723
|
+
description: "order-desk.orders.all-done-hint",
|
|
1724
|
+
},
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
id: "reminder-due",
|
|
1728
|
+
label: "order-desk.filter.reminder-due",
|
|
1729
|
+
emptyState: {
|
|
1730
|
+
title: "order-desk.orders.all-done",
|
|
1731
|
+
description: "order-desk.orders.next-reminder",
|
|
1732
|
+
paramsQuery: "order-desk:query:order:next-reminder",
|
|
1733
|
+
},
|
|
1734
|
+
},
|
|
1735
|
+
{ id: "ending-soon", label: "order-desk.filter.ending-soon" },
|
|
1736
|
+
],
|
|
1737
|
+
namedFilterFacet: {
|
|
1738
|
+
display: "select",
|
|
1739
|
+
showCounts: true,
|
|
1740
|
+
label: "order-desk.orders.todo",
|
|
1741
|
+
narrowPlacement: "behind-filter",
|
|
1742
|
+
},
|
|
1743
|
+
narrowFacets: "pills",
|
|
1744
|
+
table: {
|
|
1745
|
+
frame: "card",
|
|
1746
|
+
summaryRow: { query: "order-desk:query:order:summary" },
|
|
1747
|
+
},
|
|
1748
|
+
rowActions: [
|
|
1749
|
+
{
|
|
1750
|
+
kind: "navigate",
|
|
1751
|
+
id: "open",
|
|
1752
|
+
label: "order-desk.action.open",
|
|
1753
|
+
screen: "order-detail",
|
|
1754
|
+
rowClick: true,
|
|
1755
|
+
},
|
|
1756
|
+
{
|
|
1757
|
+
id: "remind",
|
|
1758
|
+
label: "order-desk.action.remind",
|
|
1759
|
+
handler: "order-desk:write:order:remind",
|
|
1760
|
+
display: "button",
|
|
1761
|
+
visible: { field: "canRemind", eq: true },
|
|
1762
|
+
},
|
|
1763
|
+
{
|
|
1764
|
+
kind: "navigate",
|
|
1765
|
+
id: "open-order",
|
|
1766
|
+
label: "order-desk.action.open-order",
|
|
1767
|
+
screen: "order-detail",
|
|
1768
|
+
display: "button",
|
|
1769
|
+
visible: { field: "canRemind", eq: false },
|
|
1770
|
+
},
|
|
1771
|
+
],
|
|
1772
|
+
access: accessRoles,
|
|
1773
|
+
});
|
|
1774
|
+
|
|
1775
|
+
r.screen({
|
|
1776
|
+
id: "today",
|
|
1777
|
+
type: "dashboard",
|
|
1778
|
+
panels: [
|
|
1779
|
+
{
|
|
1780
|
+
kind: "text",
|
|
1781
|
+
id: "briefing",
|
|
1782
|
+
span: "two-thirds",
|
|
1783
|
+
narrowOrder: 1,
|
|
1784
|
+
query: "order-desk:query:order:briefing",
|
|
1785
|
+
},
|
|
1786
|
+
{
|
|
1787
|
+
kind: "stat-group",
|
|
1788
|
+
id: "queue-counts",
|
|
1789
|
+
label: "order-desk.today.inbox",
|
|
1790
|
+
subtitle: "order-desk.today.inbox-sub",
|
|
1791
|
+
span: "full",
|
|
1792
|
+
layout: "strip",
|
|
1793
|
+
icon: { react: { __component: "OrderInboxIcon" } },
|
|
1794
|
+
link: { label: "order-desk.today.inbox-link", screen: "orders" },
|
|
1795
|
+
stats: [
|
|
1796
|
+
{
|
|
1797
|
+
kind: "stat",
|
|
1798
|
+
id: "action-needed",
|
|
1799
|
+
label: "order-desk.today.stat.action-needed",
|
|
1800
|
+
query: ORDER_LIST_QUERY,
|
|
1801
|
+
valueField: "total",
|
|
1802
|
+
params: { namedFilter: "action-needed", limit: 1, totalCount: true },
|
|
1803
|
+
tone: "negative",
|
|
1804
|
+
navigate: { screen: "orders", namedFilter: "action-needed" },
|
|
1805
|
+
},
|
|
1806
|
+
{
|
|
1807
|
+
kind: "stat",
|
|
1808
|
+
id: "reminder-due",
|
|
1809
|
+
label: "order-desk.today.stat.reminder-due",
|
|
1810
|
+
query: ORDER_LIST_QUERY,
|
|
1811
|
+
valueField: "total",
|
|
1812
|
+
params: { namedFilter: "reminder-due", limit: 1, totalCount: true },
|
|
1813
|
+
tone: "warn",
|
|
1814
|
+
navigate: { screen: "orders", namedFilter: "reminder-due" },
|
|
1815
|
+
},
|
|
1816
|
+
{
|
|
1817
|
+
kind: "stat",
|
|
1818
|
+
id: "ending-soon",
|
|
1819
|
+
label: "order-desk.today.stat.ending-soon",
|
|
1820
|
+
query: ORDER_LIST_QUERY,
|
|
1821
|
+
valueField: "total",
|
|
1822
|
+
params: { namedFilter: "ending-soon", limit: 1, totalCount: true },
|
|
1823
|
+
navigate: { screen: "orders", namedFilter: "ending-soon" },
|
|
1824
|
+
},
|
|
1825
|
+
],
|
|
1826
|
+
},
|
|
1827
|
+
{
|
|
1828
|
+
kind: "list",
|
|
1829
|
+
id: "now",
|
|
1830
|
+
label: "order-desk.today.now",
|
|
1831
|
+
span: "two-thirds",
|
|
1832
|
+
showHeader: false,
|
|
1833
|
+
showTotal: {
|
|
1834
|
+
text: "order-desk.today.now-total",
|
|
1835
|
+
narrowText: "order-desk.today.now-total-narrow",
|
|
1836
|
+
},
|
|
1837
|
+
narrow: { layout: "cards", limit: 3 },
|
|
1838
|
+
footerLink: {
|
|
1839
|
+
label: "order-desk.today.now-all",
|
|
1840
|
+
screen: "orders",
|
|
1841
|
+
namedFilter: "action-needed",
|
|
1842
|
+
},
|
|
1843
|
+
query: "order-desk:query:order:now",
|
|
1844
|
+
rowToneField: "tone",
|
|
1845
|
+
columns: [
|
|
1846
|
+
{ field: "urgencyLabel", display: "badge", badgeToneField: "urgencyTone" },
|
|
1847
|
+
{
|
|
1848
|
+
field: "nextStep",
|
|
1849
|
+
hint: {
|
|
1850
|
+
detailField: "nextStepDue",
|
|
1851
|
+
narrowDetailField: "nextStepShort",
|
|
1852
|
+
reasonField: "nextStepReason",
|
|
1853
|
+
reasonTitleField: "nextStepReasonTitle",
|
|
1854
|
+
reasonOpenField: "nextStepReasonOpen",
|
|
1855
|
+
plainSentence: true,
|
|
1856
|
+
},
|
|
1857
|
+
},
|
|
1858
|
+
{
|
|
1859
|
+
field: "actionLabel",
|
|
1860
|
+
display: "button",
|
|
1861
|
+
linkScreenField: "actionScreen",
|
|
1862
|
+
linkParamsField: "actionParams",
|
|
1863
|
+
},
|
|
1864
|
+
],
|
|
1865
|
+
},
|
|
1866
|
+
{
|
|
1867
|
+
kind: "list",
|
|
1868
|
+
id: "deadlines",
|
|
1869
|
+
label: "order-desk.today.deadlines",
|
|
1870
|
+
span: "third",
|
|
1871
|
+
showHeader: false,
|
|
1872
|
+
icon: { react: { __component: "DeadlinesIcon" } },
|
|
1873
|
+
narrow: {
|
|
1874
|
+
layout: "line",
|
|
1875
|
+
field: "title",
|
|
1876
|
+
moreText: "order-desk.today.deadlines-more-narrow",
|
|
1877
|
+
},
|
|
1878
|
+
rowLink: { screenField: "screen", paramsField: "params", icon: "chevron" },
|
|
1879
|
+
footerLink: {
|
|
1880
|
+
narrowOnly: true,
|
|
1881
|
+
label: "order-desk.today.deadlines-all",
|
|
1882
|
+
moreText: "order-desk.today.deadlines-more",
|
|
1883
|
+
narrowMoreText: "order-desk.today.deadlines-more-narrow",
|
|
1884
|
+
screen: "orders",
|
|
1885
|
+
},
|
|
1886
|
+
query: "order-desk:query:order:deadlines",
|
|
1887
|
+
columns: [{ field: "due", display: "datetime" }, { field: "title" }],
|
|
1888
|
+
},
|
|
1889
|
+
{
|
|
1890
|
+
kind: "list",
|
|
1891
|
+
id: "customers",
|
|
1892
|
+
label: "order-desk.today.customers",
|
|
1893
|
+
span: "third",
|
|
1894
|
+
showHeader: false,
|
|
1895
|
+
hideOnNarrow: true,
|
|
1896
|
+
rowLink: { screen: "order-detail", paramField: "params" },
|
|
1897
|
+
query: "order-desk:query:order:customers",
|
|
1898
|
+
rowToneField: "tone",
|
|
1899
|
+
rowToneMarker: "dot",
|
|
1900
|
+
columns: [
|
|
1901
|
+
{ field: "customerName" },
|
|
1902
|
+
{ field: "openCount", display: "badge", badgeToneField: "openTone" },
|
|
1903
|
+
],
|
|
1904
|
+
},
|
|
1905
|
+
{
|
|
1906
|
+
kind: "stat-group",
|
|
1907
|
+
id: "money",
|
|
1908
|
+
label: "order-desk.today.money",
|
|
1909
|
+
subtitle: "order-desk.today.money-sub",
|
|
1910
|
+
span: "two-thirds",
|
|
1911
|
+
layout: "cards",
|
|
1912
|
+
columns: 3,
|
|
1913
|
+
hideOnNarrow: true,
|
|
1914
|
+
stats: [
|
|
1915
|
+
{
|
|
1916
|
+
kind: "stat",
|
|
1917
|
+
id: "open",
|
|
1918
|
+
label: "order-desk.today.stat.open",
|
|
1919
|
+
query: "order-desk:query:order:money",
|
|
1920
|
+
valueField: "open",
|
|
1921
|
+
},
|
|
1922
|
+
{
|
|
1923
|
+
kind: "stat",
|
|
1924
|
+
id: "overdue",
|
|
1925
|
+
label: "order-desk.today.stat.overdue",
|
|
1926
|
+
query: "order-desk:query:order:money",
|
|
1927
|
+
valueField: "overdue",
|
|
1928
|
+
tone: "negative",
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
kind: "stat",
|
|
1932
|
+
id: "collected",
|
|
1933
|
+
label: "order-desk.today.stat.collected",
|
|
1934
|
+
query: "order-desk:query:order:money",
|
|
1935
|
+
valueField: "collected",
|
|
1936
|
+
tone: "positive",
|
|
1937
|
+
},
|
|
1938
|
+
],
|
|
1939
|
+
},
|
|
1940
|
+
],
|
|
1941
|
+
access: accessRoles,
|
|
973
1942
|
});
|
|
974
1943
|
|
|
975
1944
|
r.screen({
|
|
976
1945
|
id: "order-detail",
|
|
977
1946
|
type: "projectionDetail",
|
|
978
1947
|
query: "order-desk:query:order:detail",
|
|
1948
|
+
focus: true,
|
|
1949
|
+
listScreenId: "orders",
|
|
979
1950
|
header: {
|
|
980
1951
|
title: "customerName",
|
|
1952
|
+
shortTitle: "shortTitle",
|
|
981
1953
|
// Parts are joined by a separator; `format` formats the raw field value.
|
|
1954
|
+
narrowSubtitle: "narrowSubtitle",
|
|
982
1955
|
subtitle: [
|
|
983
1956
|
"orderNumber",
|
|
984
1957
|
{ field: "placedAt", format: { format: "date", dateStyle: "medium" } },
|
|
985
1958
|
],
|
|
986
1959
|
status: "status",
|
|
987
1960
|
},
|
|
1961
|
+
breadcrumb: { field: "path" },
|
|
1962
|
+
summary: { field: "summaryLine", narrowField: "summaryShort", toneField: "summaryTone" },
|
|
1963
|
+
banner: {
|
|
1964
|
+
field: "notice",
|
|
1965
|
+
actions: [
|
|
1966
|
+
{
|
|
1967
|
+
kind: "navigate",
|
|
1968
|
+
id: "banner-open",
|
|
1969
|
+
label: "order-desk.action.recordPayment",
|
|
1970
|
+
screen: "order-detail",
|
|
1971
|
+
icon: "plus",
|
|
1972
|
+
hideIcon: true,
|
|
1973
|
+
narrowLabel: "order-desk.action.record-short",
|
|
1974
|
+
},
|
|
1975
|
+
],
|
|
1976
|
+
},
|
|
1977
|
+
progress: { field: "progress", placement: "beside-steps", hideOnNarrow: true },
|
|
1978
|
+
steps: {
|
|
1979
|
+
field: "steps",
|
|
1980
|
+
narrowLimit: 3,
|
|
1981
|
+
title: "order-desk.steps.title",
|
|
1982
|
+
emptyLabel: "order-desk.steps.empty",
|
|
1983
|
+
actions: [
|
|
1984
|
+
{
|
|
1985
|
+
kind: "navigate",
|
|
1986
|
+
id: "step-open",
|
|
1987
|
+
label: "order-desk.action.refreshOrder",
|
|
1988
|
+
screen: "order-detail",
|
|
1989
|
+
icon: "refresh",
|
|
1990
|
+
},
|
|
1991
|
+
{
|
|
1992
|
+
kind: "navigate",
|
|
1993
|
+
id: "prepare",
|
|
1994
|
+
label: "order-desk.action.prepare",
|
|
1995
|
+
screen: "order-detail",
|
|
1996
|
+
display: "link",
|
|
1997
|
+
icon: "sparkles",
|
|
1998
|
+
visible: { field: "canPrepare", eq: true },
|
|
1999
|
+
},
|
|
2000
|
+
],
|
|
2001
|
+
},
|
|
2002
|
+
metricsStyle: "tiles",
|
|
2003
|
+
metricsPlacement: { narrow: "after-guidance" },
|
|
988
2004
|
metrics: [
|
|
989
|
-
{
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
2005
|
+
{
|
|
2006
|
+
field: "totalAmount",
|
|
2007
|
+
label: "order-desk.metric.totalAmount",
|
|
2008
|
+
subField: "totalNote",
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
field: "outstandingAmount",
|
|
2012
|
+
label: "order-desk.metric.outstandingAmount",
|
|
2013
|
+
labelField: "outstandingLabel",
|
|
2014
|
+
subField: "outstandingNote",
|
|
2015
|
+
tone: "warn",
|
|
2016
|
+
toneField: "outstandingTone",
|
|
2017
|
+
navigate: { tab: "payments" },
|
|
2018
|
+
},
|
|
2019
|
+
{
|
|
2020
|
+
field: "itemCount",
|
|
2021
|
+
label: "order-desk.metric.itemCount",
|
|
2022
|
+
navigate: { tab: "items" },
|
|
2023
|
+
},
|
|
2024
|
+
{ field: "placedAt", label: "order-desk.metric.placedAt", hideOnNarrow: true },
|
|
993
2025
|
],
|
|
994
2026
|
layout: {
|
|
995
2027
|
mode: "tabs",
|
|
@@ -998,24 +2030,34 @@ export function createOrderDeskFeature(): FeatureDefinition {
|
|
|
998
2030
|
id: "items",
|
|
999
2031
|
kind: "relatedList",
|
|
1000
2032
|
title: "order-desk.tab.items",
|
|
2033
|
+
countField: "itemsCount",
|
|
1001
2034
|
query: "order-desk:query:order:items",
|
|
1002
2035
|
columns: [
|
|
1003
|
-
"sku",
|
|
1004
|
-
"description",
|
|
1005
|
-
"quantity",
|
|
1006
|
-
{
|
|
2036
|
+
{ field: "sku", label: "order-desk.col.sku" },
|
|
2037
|
+
{ field: "description", label: "order-desk.col.description" },
|
|
2038
|
+
{ field: "quantity", label: "order-desk.col.quantity" },
|
|
2039
|
+
{
|
|
2040
|
+
field: "unitPrice",
|
|
2041
|
+
label: "order-desk.col.unit-price",
|
|
2042
|
+
renderer: { format: "currency", symbol: "€" },
|
|
2043
|
+
},
|
|
1007
2044
|
],
|
|
1008
2045
|
},
|
|
1009
2046
|
{
|
|
1010
2047
|
id: "payments",
|
|
1011
2048
|
kind: "relatedList",
|
|
1012
2049
|
title: "order-desk.tab.payments",
|
|
2050
|
+
countField: "paymentsCount",
|
|
1013
2051
|
query: "order-desk:query:order:payments",
|
|
1014
2052
|
columns: [
|
|
1015
|
-
"paidAt",
|
|
1016
|
-
{
|
|
1017
|
-
|
|
1018
|
-
|
|
2053
|
+
{ field: "paidAt", label: "order-desk.col.paid-at" },
|
|
2054
|
+
{
|
|
2055
|
+
field: "amount",
|
|
2056
|
+
label: "order-desk.col.amount",
|
|
2057
|
+
renderer: { format: "currency", symbol: "€" },
|
|
2058
|
+
},
|
|
2059
|
+
{ field: "method", label: "order-desk.col.method" },
|
|
2060
|
+
{ field: "status", label: "order-desk.col.status" },
|
|
1019
2061
|
],
|
|
1020
2062
|
emptyState: {
|
|
1021
2063
|
title: "order-desk.payments.empty",
|
|
@@ -1067,8 +2109,542 @@ export function createOrderDeskFeature(): FeatureDefinition {
|
|
|
1067
2109
|
},
|
|
1068
2110
|
],
|
|
1069
2111
|
inlineActions: ["download-invoice"],
|
|
1070
|
-
access:
|
|
2112
|
+
access: accessRoles,
|
|
1071
2113
|
});
|
|
1072
2114
|
});
|
|
1073
2115
|
}
|
|
1074
2116
|
```
|
|
2117
|
+
|
|
2118
|
+
### src/order-board.ts
|
|
2119
|
+
|
|
2120
|
+
```ts
|
|
2121
|
+
// In-memory order data shared by the real query handlers (feature.ts) and the e2e
|
|
2122
|
+
// mock dispatcher, so the browser fixture answers exactly what the server would.
|
|
2123
|
+
|
|
2124
|
+
import { z } from "zod";
|
|
2125
|
+
|
|
2126
|
+
export const ORDER_DETAIL_SCREEN_QN = "order-desk:screen:order-detail";
|
|
2127
|
+
|
|
2128
|
+
export const NAMED_FILTER_IDS = ["action-needed", "reminder-due", "ending-soon"] as const;
|
|
2129
|
+
export type OrderNamedFilterId = (typeof NAMED_FILTER_IDS)[number];
|
|
2130
|
+
|
|
2131
|
+
const AGGREGATE_MEASURE_KINDS = ["sum", "avg", "count", "min", "max"] as const;
|
|
2132
|
+
|
|
2133
|
+
export const orderListSchema = z.object({
|
|
2134
|
+
namedFilter: z.enum(NAMED_FILTER_IDS).optional(),
|
|
2135
|
+
search: z.string().optional(),
|
|
2136
|
+
sort: z.string().optional(),
|
|
2137
|
+
sortDirection: z.enum(["asc", "desc"]).optional(),
|
|
2138
|
+
limit: z.number().int().positive().max(200).optional(),
|
|
2139
|
+
offset: z.number().int().nonnegative().optional(),
|
|
2140
|
+
totalCount: z.boolean().optional(),
|
|
2141
|
+
aggregate: z
|
|
2142
|
+
.object({
|
|
2143
|
+
groupBy: z.string().optional(),
|
|
2144
|
+
measures: z
|
|
2145
|
+
.array(z.object({ field: z.string(), kind: z.enum(AGGREGATE_MEASURE_KINDS) }))
|
|
2146
|
+
.default([]),
|
|
2147
|
+
})
|
|
2148
|
+
.optional(),
|
|
2149
|
+
});
|
|
2150
|
+
|
|
2151
|
+
export type OrderListPayload = z.infer<typeof orderListSchema>;
|
|
2152
|
+
|
|
2153
|
+
// The list sends its narrowing (named filter, search) to the summary query as well; limit and paging never reach it.
|
|
2154
|
+
export const orderSummarySchema = z.object({
|
|
2155
|
+
namedFilter: z.enum(NAMED_FILTER_IDS).optional(),
|
|
2156
|
+
search: z.string().optional(),
|
|
2157
|
+
});
|
|
2158
|
+
|
|
2159
|
+
export type OrderSummaryPayload = z.infer<typeof orderSummarySchema>;
|
|
2160
|
+
|
|
2161
|
+
type RowTone = "ok" | "warn" | "bad" | "critical" | "neutral";
|
|
2162
|
+
type UrgencyTone = "negative" | "warn" | "neutral" | "positive";
|
|
2163
|
+
|
|
2164
|
+
export type OrderRow = {
|
|
2165
|
+
readonly id: string;
|
|
2166
|
+
readonly orderNumber: string;
|
|
2167
|
+
readonly customerName: string;
|
|
2168
|
+
readonly tone: RowTone;
|
|
2169
|
+
readonly urgency: number;
|
|
2170
|
+
readonly urgencyLabel: string;
|
|
2171
|
+
readonly urgencyTone: UrgencyTone;
|
|
2172
|
+
readonly nextStep: string;
|
|
2173
|
+
readonly nextStepDue: string;
|
|
2174
|
+
readonly nextStepReason: string;
|
|
2175
|
+
readonly nextStepReasonTitle?: string;
|
|
2176
|
+
readonly nextStepReasonOpen?: boolean;
|
|
2177
|
+
readonly openAmount: number;
|
|
2178
|
+
readonly status: "processing" | "shipped" | "closing" | "delivered";
|
|
2179
|
+
readonly actionLabel: string;
|
|
2180
|
+
readonly canRemind: boolean;
|
|
2181
|
+
};
|
|
2182
|
+
|
|
2183
|
+
const ORDER_ROWS: readonly OrderRow[] = [
|
|
2184
|
+
{
|
|
2185
|
+
id: "o1",
|
|
2186
|
+
orderNumber: "SO-10482",
|
|
2187
|
+
customerName: "Aiko Tanaka",
|
|
2188
|
+
tone: "bad",
|
|
2189
|
+
urgency: 92,
|
|
2190
|
+
urgencyLabel: "Critical",
|
|
2191
|
+
urgencyTone: "negative",
|
|
2192
|
+
nextStep: "Send payment reminder",
|
|
2193
|
+
nextStepDue: "by Friday",
|
|
2194
|
+
nextStepReason: "312 EUR is 14 days overdue.\nTwo earlier mails stayed unanswered.",
|
|
2195
|
+
nextStepReasonTitle: "Rule 10 · Payment overdue.",
|
|
2196
|
+
nextStepReasonOpen: true,
|
|
2197
|
+
openAmount: 312,
|
|
2198
|
+
status: "processing",
|
|
2199
|
+
actionLabel: "Send reminder",
|
|
2200
|
+
canRemind: true,
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
id: "o2",
|
|
2204
|
+
orderNumber: "SO-10483",
|
|
2205
|
+
customerName: "Jonas Weber",
|
|
2206
|
+
tone: "ok",
|
|
2207
|
+
urgency: 0,
|
|
2208
|
+
urgencyLabel: "",
|
|
2209
|
+
urgencyTone: "neutral",
|
|
2210
|
+
nextStep: "",
|
|
2211
|
+
nextStepDue: "",
|
|
2212
|
+
nextStepReason: "",
|
|
2213
|
+
openAmount: 0,
|
|
2214
|
+
status: "delivered",
|
|
2215
|
+
actionLabel: "",
|
|
2216
|
+
canRemind: false,
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
id: "o3",
|
|
2220
|
+
orderNumber: "SO-10484",
|
|
2221
|
+
customerName: "Maria Lopez",
|
|
2222
|
+
tone: "warn",
|
|
2223
|
+
urgency: 74,
|
|
2224
|
+
urgencyLabel: "Overdue",
|
|
2225
|
+
urgencyTone: "negative",
|
|
2226
|
+
nextStep: "Confirm the delivery slot",
|
|
2227
|
+
nextStepDue: "Tuesday",
|
|
2228
|
+
nextStepReason: "The carrier asked twice for a date.",
|
|
2229
|
+
openAmount: 180,
|
|
2230
|
+
status: "shipped",
|
|
2231
|
+
actionLabel: "Open order",
|
|
2232
|
+
canRemind: false,
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
id: "o4",
|
|
2236
|
+
orderNumber: "SO-10485",
|
|
2237
|
+
customerName: "Tom Becker",
|
|
2238
|
+
tone: "warn",
|
|
2239
|
+
urgency: 61,
|
|
2240
|
+
urgencyLabel: "Urgent",
|
|
2241
|
+
urgencyTone: "warn",
|
|
2242
|
+
nextStep: "Call about the backorder",
|
|
2243
|
+
nextStepDue: "tomorrow",
|
|
2244
|
+
nextStepReason: "Two of five items are backordered.\nThe customer expects a full delivery.",
|
|
2245
|
+
openAmount: 540,
|
|
2246
|
+
status: "processing",
|
|
2247
|
+
actionLabel: "Open order",
|
|
2248
|
+
canRemind: false,
|
|
2249
|
+
},
|
|
2250
|
+
{
|
|
2251
|
+
id: "o5",
|
|
2252
|
+
orderNumber: "SO-10486",
|
|
2253
|
+
customerName: "Priya Nair",
|
|
2254
|
+
tone: "neutral",
|
|
2255
|
+
urgency: 35,
|
|
2256
|
+
urgencyLabel: "Due",
|
|
2257
|
+
urgencyTone: "neutral",
|
|
2258
|
+
nextStep: "Review the credit limit",
|
|
2259
|
+
nextStepDue: "next week",
|
|
2260
|
+
nextStepReason: "The open balance grew past the agreed limit.",
|
|
2261
|
+
openAmount: 1190,
|
|
2262
|
+
status: "closing",
|
|
2263
|
+
actionLabel: "Open order",
|
|
2264
|
+
canRemind: false,
|
|
2265
|
+
},
|
|
2266
|
+
{
|
|
2267
|
+
id: "o6",
|
|
2268
|
+
orderNumber: "SO-10487",
|
|
2269
|
+
customerName: "Lars Hansen",
|
|
2270
|
+
tone: "ok",
|
|
2271
|
+
urgency: 0,
|
|
2272
|
+
urgencyLabel: "",
|
|
2273
|
+
urgencyTone: "neutral",
|
|
2274
|
+
nextStep: "",
|
|
2275
|
+
nextStepDue: "",
|
|
2276
|
+
nextStepReason: "",
|
|
2277
|
+
openAmount: 0,
|
|
2278
|
+
status: "delivered",
|
|
2279
|
+
actionLabel: "",
|
|
2280
|
+
canRemind: false,
|
|
2281
|
+
},
|
|
2282
|
+
{
|
|
2283
|
+
id: "o7",
|
|
2284
|
+
orderNumber: "SO-10488",
|
|
2285
|
+
customerName: "Emma Rossi",
|
|
2286
|
+
tone: "bad",
|
|
2287
|
+
urgency: 80,
|
|
2288
|
+
urgencyLabel: "Overdue",
|
|
2289
|
+
urgencyTone: "negative",
|
|
2290
|
+
nextStep: "Send payment reminder",
|
|
2291
|
+
nextStepDue: "Thursday",
|
|
2292
|
+
nextStepReason: "180 EUR is 9 days overdue.",
|
|
2293
|
+
openAmount: 180,
|
|
2294
|
+
status: "processing",
|
|
2295
|
+
actionLabel: "Send reminder",
|
|
2296
|
+
canRemind: true,
|
|
2297
|
+
},
|
|
2298
|
+
{
|
|
2299
|
+
id: "o8",
|
|
2300
|
+
orderNumber: "SO-10489",
|
|
2301
|
+
customerName: "Kenji Mori",
|
|
2302
|
+
tone: "ok",
|
|
2303
|
+
urgency: 0,
|
|
2304
|
+
urgencyLabel: "",
|
|
2305
|
+
urgencyTone: "neutral",
|
|
2306
|
+
nextStep: "",
|
|
2307
|
+
nextStepDue: "",
|
|
2308
|
+
nextStepReason: "",
|
|
2309
|
+
openAmount: 95,
|
|
2310
|
+
status: "closing",
|
|
2311
|
+
actionLabel: "",
|
|
2312
|
+
canRemind: false,
|
|
2313
|
+
},
|
|
2314
|
+
];
|
|
2315
|
+
|
|
2316
|
+
const NAMED_FILTER_PREDICATES: Readonly<Record<OrderNamedFilterId, (row: OrderRow) => boolean>> = {
|
|
2317
|
+
"action-needed": (row) => row.nextStep !== "",
|
|
2318
|
+
"reminder-due": (row) => row.canRemind && row.nextStepDue === "today",
|
|
2319
|
+
"ending-soon": (row) => row.status === "closing",
|
|
2320
|
+
};
|
|
2321
|
+
|
|
2322
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
2323
|
+
|
|
2324
|
+
function matchesSearch(row: OrderRow, search: string | undefined): boolean {
|
|
2325
|
+
if (search === undefined || search === "") return true;
|
|
2326
|
+
const needle = search.toLowerCase();
|
|
2327
|
+
return (
|
|
2328
|
+
row.orderNumber.toLowerCase().includes(needle) ||
|
|
2329
|
+
row.customerName.toLowerCase().includes(needle)
|
|
2330
|
+
);
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
function fieldValue(row: OrderRow, field: string): unknown {
|
|
2334
|
+
return Object.entries(row).find(([key]) => key === field)?.[1];
|
|
2335
|
+
}
|
|
2336
|
+
|
|
2337
|
+
function compareRows(
|
|
2338
|
+
field: string,
|
|
2339
|
+
direction: "asc" | "desc",
|
|
2340
|
+
): (a: OrderRow, b: OrderRow) => number {
|
|
2341
|
+
const sign = direction === "asc" ? 1 : -1;
|
|
2342
|
+
return (a, b) => {
|
|
2343
|
+
const left = fieldValue(a, field);
|
|
2344
|
+
const right = fieldValue(b, field);
|
|
2345
|
+
if (typeof left === "number" && typeof right === "number") return sign * (left - right);
|
|
2346
|
+
return sign * String(left).localeCompare(String(right));
|
|
2347
|
+
};
|
|
2348
|
+
}
|
|
2349
|
+
|
|
2350
|
+
function filteredRows(payload: OrderListPayload): readonly OrderRow[] {
|
|
2351
|
+
const predicate =
|
|
2352
|
+
payload.namedFilter === undefined ? undefined : NAMED_FILTER_PREDICATES[payload.namedFilter];
|
|
2353
|
+
return ORDER_ROWS.filter(
|
|
2354
|
+
(row) => (predicate === undefined || predicate(row)) && matchesSearch(row, payload.search),
|
|
2355
|
+
);
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
function numericValues(rows: readonly OrderRow[], field: string): number[] {
|
|
2359
|
+
return rows.flatMap((row) => {
|
|
2360
|
+
const value = fieldValue(row, field);
|
|
2361
|
+
return typeof value === "number" ? [value] : [];
|
|
2362
|
+
});
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
function measureOf(
|
|
2366
|
+
kind: (typeof AGGREGATE_MEASURE_KINDS)[number],
|
|
2367
|
+
rows: readonly OrderRow[],
|
|
2368
|
+
field: string,
|
|
2369
|
+
): number | null {
|
|
2370
|
+
if (kind === "count") return rows.length;
|
|
2371
|
+
const values = numericValues(rows, field);
|
|
2372
|
+
if (values.length === 0) return null;
|
|
2373
|
+
const sum = values.reduce((total, value) => total + value, 0);
|
|
2374
|
+
if (kind === "sum") return sum;
|
|
2375
|
+
if (kind === "avg") return sum / values.length;
|
|
2376
|
+
return kind === "min" ? Math.min(...values) : Math.max(...values);
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
export type OrderListAnswer =
|
|
2380
|
+
| {
|
|
2381
|
+
readonly groups: readonly {
|
|
2382
|
+
readonly key: null;
|
|
2383
|
+
readonly count: number;
|
|
2384
|
+
readonly measures: readonly (number | null)[];
|
|
2385
|
+
}[];
|
|
2386
|
+
}
|
|
2387
|
+
| {
|
|
2388
|
+
readonly rows: readonly (OrderRow & {
|
|
2389
|
+
readonly narrowOpen: string;
|
|
2390
|
+
readonly narrowStatus: string;
|
|
2391
|
+
readonly actionScreen?: string;
|
|
2392
|
+
readonly actionParams?: { readonly entityId: string };
|
|
2393
|
+
})[];
|
|
2394
|
+
readonly nextCursor: null;
|
|
2395
|
+
readonly total?: number;
|
|
2396
|
+
};
|
|
2397
|
+
|
|
2398
|
+
export function answerOrderList(payload: OrderListPayload): OrderListAnswer {
|
|
2399
|
+
const matching = filteredRows(payload);
|
|
2400
|
+
if (payload.aggregate !== undefined) {
|
|
2401
|
+
return {
|
|
2402
|
+
groups: [
|
|
2403
|
+
{
|
|
2404
|
+
key: null,
|
|
2405
|
+
count: matching.length,
|
|
2406
|
+
measures: payload.aggregate.measures.map((m) => measureOf(m.kind, matching, m.field)),
|
|
2407
|
+
},
|
|
2408
|
+
],
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
const ordered =
|
|
2412
|
+
payload.sort === undefined
|
|
2413
|
+
? matching
|
|
2414
|
+
: [...matching].sort(compareRows(payload.sort, payload.sortDirection ?? "asc"));
|
|
2415
|
+
const offset = payload.offset ?? 0;
|
|
2416
|
+
const rows = ordered.slice(offset, offset + (payload.limit ?? DEFAULT_PAGE_SIZE)).map((row) => ({
|
|
2417
|
+
...row,
|
|
2418
|
+
narrowOpen: `${euro(row.openAmount)} open`,
|
|
2419
|
+
narrowStatus: row.status,
|
|
2420
|
+
nextStepShort: row.nextStepDue === "" ? "" : `${row.nextStepDue} · ${euro(row.openAmount)}`,
|
|
2421
|
+
...(row.nextStep !== "" && {
|
|
2422
|
+
actionScreen: ORDER_DETAIL_SCREEN_QN,
|
|
2423
|
+
actionParams: { entityId: row.id },
|
|
2424
|
+
}),
|
|
2425
|
+
}));
|
|
2426
|
+
return {
|
|
2427
|
+
rows,
|
|
2428
|
+
nextCursor: null,
|
|
2429
|
+
...(payload.totalCount === true && { total: matching.length }),
|
|
2430
|
+
};
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
export function answerOrderSummary(payload: OrderSummaryPayload) {
|
|
2434
|
+
const matching = filteredRows(payload);
|
|
2435
|
+
const overdue = matching.filter((row) => row.urgencyTone === "negative");
|
|
2436
|
+
return {
|
|
2437
|
+
items: [
|
|
2438
|
+
{ label: "Orders", value: matching.length, column: "orderNumber" },
|
|
2439
|
+
{
|
|
2440
|
+
label: "Open",
|
|
2441
|
+
value: euro(matching.reduce((total, row) => total + row.openAmount, 0)),
|
|
2442
|
+
column: "openAmount",
|
|
2443
|
+
},
|
|
2444
|
+
{
|
|
2445
|
+
label: "Overdue",
|
|
2446
|
+
value: euro(overdue.reduce((total, row) => total + row.openAmount, 0)),
|
|
2447
|
+
tone: "bad",
|
|
2448
|
+
column: "urgencyLabel",
|
|
2449
|
+
},
|
|
2450
|
+
],
|
|
2451
|
+
};
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
function actionNeededRows(limit: number): readonly OrderRow[] {
|
|
2455
|
+
return ORDER_ROWS.filter(NAMED_FILTER_PREDICATES["action-needed"])
|
|
2456
|
+
.sort(compareRows("urgency", "desc"))
|
|
2457
|
+
.slice(0, limit);
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
const NOW_LIST_LIMIT = 4;
|
|
2461
|
+
|
|
2462
|
+
export function answerNowList() {
|
|
2463
|
+
return {
|
|
2464
|
+
rows: actionNeededRows(NOW_LIST_LIMIT).map((row) => ({
|
|
2465
|
+
...row,
|
|
2466
|
+
nextStepShort: `${row.nextStepDue} · ${euro(row.openAmount)}`,
|
|
2467
|
+
actionScreen: ORDER_DETAIL_SCREEN_QN,
|
|
2468
|
+
actionParams: { entityId: row.id },
|
|
2469
|
+
})),
|
|
2470
|
+
total: actionNeededRows(ORDER_ROWS.length).length,
|
|
2471
|
+
};
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
// The params of the "reminder due" empty state; null while no order is waiting for a reminder.
|
|
2475
|
+
export function answerNextReminder(): { readonly customer: string; readonly due: string } | null {
|
|
2476
|
+
const next = ORDER_ROWS.find((row) => row.canRemind);
|
|
2477
|
+
return next === undefined ? null : { customer: next.customerName, due: next.nextStepDue };
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
export function answerBriefing() {
|
|
2481
|
+
const open = actionNeededRows(ORDER_ROWS.length);
|
|
2482
|
+
const [first] = open;
|
|
2483
|
+
return {
|
|
2484
|
+
blocks: [
|
|
2485
|
+
{
|
|
2486
|
+
kind: "paragraph",
|
|
2487
|
+
emphasis: "lead",
|
|
2488
|
+
text: `${open.length} orders need you today.${
|
|
2489
|
+
first === undefined
|
|
2490
|
+
? ""
|
|
2491
|
+
: ` Most pressing is ${first.orderNumber} from ${first.customerName}.`
|
|
2492
|
+
}`,
|
|
2493
|
+
},
|
|
2494
|
+
{
|
|
2495
|
+
kind: "hint",
|
|
2496
|
+
text: "Sorted by urgency. Open an order and let the assistant prepare the step.",
|
|
2497
|
+
},
|
|
2498
|
+
],
|
|
2499
|
+
narrowBlocks: [
|
|
2500
|
+
{ kind: "paragraph", emphasis: "lead", text: `${open.length} orders need you today.` },
|
|
2501
|
+
{ kind: "hint", text: "Tuesday, 3 November · as of 06:00" },
|
|
2502
|
+
],
|
|
2503
|
+
};
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
const DEADLINES = [
|
|
2507
|
+
{ id: "d1", due: "2026-11-06T09:00:00Z", title: "Reminder SO-10482", orderId: "o1" },
|
|
2508
|
+
{ id: "d2", due: "2026-11-05T14:00:00Z", title: "Call Tom Becker", orderId: "o4" },
|
|
2509
|
+
{ id: "d3", due: "2026-11-10T10:30:00Z", title: "Credit review SO-10486", orderId: "o5" },
|
|
2510
|
+
{ id: "d4", due: "2026-11-12T08:00:00Z", title: "Delivery slot SO-10484", orderId: "o3" },
|
|
2511
|
+
] as const;
|
|
2512
|
+
|
|
2513
|
+
export function answerDeadlines() {
|
|
2514
|
+
return {
|
|
2515
|
+
rows: [...DEADLINES]
|
|
2516
|
+
.sort((a, b) => a.due.localeCompare(b.due))
|
|
2517
|
+
.map((deadline) => ({
|
|
2518
|
+
id: deadline.id,
|
|
2519
|
+
due: deadline.due,
|
|
2520
|
+
title: deadline.title,
|
|
2521
|
+
screen: ORDER_DETAIL_SCREEN_QN,
|
|
2522
|
+
params: { entityId: deadline.orderId },
|
|
2523
|
+
})),
|
|
2524
|
+
};
|
|
2525
|
+
}
|
|
2526
|
+
|
|
2527
|
+
const CUSTOMERS = [
|
|
2528
|
+
{
|
|
2529
|
+
id: "c1",
|
|
2530
|
+
customerName: "Aiko Tanaka",
|
|
2531
|
+
openCount: 3,
|
|
2532
|
+
openTone: "negative",
|
|
2533
|
+
tone: "bad",
|
|
2534
|
+
orderId: "o1",
|
|
2535
|
+
},
|
|
2536
|
+
{
|
|
2537
|
+
id: "c2",
|
|
2538
|
+
customerName: "Priya Nair",
|
|
2539
|
+
openCount: 2,
|
|
2540
|
+
openTone: "warn",
|
|
2541
|
+
tone: "warn",
|
|
2542
|
+
orderId: "o5",
|
|
2543
|
+
},
|
|
2544
|
+
{
|
|
2545
|
+
id: "c3",
|
|
2546
|
+
customerName: "Tom Becker",
|
|
2547
|
+
openCount: 1,
|
|
2548
|
+
openTone: "neutral",
|
|
2549
|
+
tone: "neutral",
|
|
2550
|
+
orderId: "o4",
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
id: "c4",
|
|
2554
|
+
customerName: "Jonas Weber",
|
|
2555
|
+
openCount: 0,
|
|
2556
|
+
openTone: "positive",
|
|
2557
|
+
tone: "ok",
|
|
2558
|
+
orderId: "o2",
|
|
2559
|
+
},
|
|
2560
|
+
] as const;
|
|
2561
|
+
|
|
2562
|
+
export function answerCustomers() {
|
|
2563
|
+
return {
|
|
2564
|
+
rows: CUSTOMERS.map((customer) => ({
|
|
2565
|
+
id: customer.id,
|
|
2566
|
+
customerName: customer.customerName,
|
|
2567
|
+
openCount: customer.openCount,
|
|
2568
|
+
openTone: customer.openTone,
|
|
2569
|
+
tone: customer.tone,
|
|
2570
|
+
screen: ORDER_DETAIL_SCREEN_QN,
|
|
2571
|
+
params: { entityId: customer.orderId },
|
|
2572
|
+
})),
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
|
|
2576
|
+
function euro(amount: number): string {
|
|
2577
|
+
return `€ ${amount.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
2578
|
+
}
|
|
2579
|
+
|
|
2580
|
+
export function answerMoney() {
|
|
2581
|
+
const open = ORDER_ROWS.reduce((total, row) => total + row.openAmount, 0);
|
|
2582
|
+
const overdue = ORDER_ROWS.filter((row) => row.urgencyTone === "negative").reduce(
|
|
2583
|
+
(total, row) => total + row.openAmount,
|
|
2584
|
+
0,
|
|
2585
|
+
);
|
|
2586
|
+
return {
|
|
2587
|
+
open: euro(open),
|
|
2588
|
+
overdue: euro(overdue),
|
|
2589
|
+
collected: euro(1860),
|
|
2590
|
+
openOrders: String(ORDER_ROWS.filter((row) => row.openAmount > 0).length),
|
|
2591
|
+
};
|
|
2592
|
+
}
|
|
2593
|
+
|
|
2594
|
+
export function answerOrderDetail(id: string) {
|
|
2595
|
+
return {
|
|
2596
|
+
id,
|
|
2597
|
+
customerName: "Aiko Tanaka",
|
|
2598
|
+
orderNumber: "SO-10482",
|
|
2599
|
+
shortTitle: "SO-10482",
|
|
2600
|
+
status: "processing",
|
|
2601
|
+
totalAmount: "€ 1,248.00",
|
|
2602
|
+
totalNote: "2 payments",
|
|
2603
|
+
outstandingAmount: "€ 312.00",
|
|
2604
|
+
outstandingNote: "14 days overdue",
|
|
2605
|
+
outstandingLabel: "Outstanding since 01.12.",
|
|
2606
|
+
outstandingTone: "bad",
|
|
2607
|
+
itemCount: "3",
|
|
2608
|
+
itemsCount: 3,
|
|
2609
|
+
paymentsCount: 2,
|
|
2610
|
+
placedAt: "2026-08-21",
|
|
2611
|
+
shippingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
2612
|
+
billingAddress: "Karl-Marx-Straße 12, 12043 Berlin",
|
|
2613
|
+
salesRep: "Jonas Weber",
|
|
2614
|
+
path: [{ label: "Orders" }, { label: "Aiko Tanaka" }, { label: "SO-10482" }],
|
|
2615
|
+
summaryLine: "Waiting for the second payment",
|
|
2616
|
+
summaryShort: "Second payment open.",
|
|
2617
|
+
summaryTone: "warn",
|
|
2618
|
+
narrowSubtitle: "SO-10482 · placed 21 Aug",
|
|
2619
|
+
notice: { title: "Payment overdue", text: "312 EUR is 14 days overdue", tone: "bad" },
|
|
2620
|
+
steps: [
|
|
2621
|
+
{
|
|
2622
|
+
id: "remind",
|
|
2623
|
+
title: "Send payment reminder",
|
|
2624
|
+
detail: "by Friday",
|
|
2625
|
+
narrowDetail: "Fri",
|
|
2626
|
+
tone: "warn",
|
|
2627
|
+
whyOpen: true,
|
|
2628
|
+
whyTitle: "Rule 10 · Payment overdue.",
|
|
2629
|
+
why: "The invoice is 14 days overdue.\nTwo earlier mails stayed unanswered.\nThe credit limit is 1,500 EUR.",
|
|
2630
|
+
canPrepare: true,
|
|
2631
|
+
},
|
|
2632
|
+
{ id: "escalate", title: "Escalate to accounting", canPrepare: false },
|
|
2633
|
+
{ id: "credit", title: "Review the credit limit", canPrepare: false },
|
|
2634
|
+
{ id: "handover", title: "Plan the handover", canPrepare: false },
|
|
2635
|
+
{ id: "close", title: "Close the order", canPrepare: false },
|
|
2636
|
+
],
|
|
2637
|
+
progress: [
|
|
2638
|
+
{
|
|
2639
|
+
title: "Order to cash",
|
|
2640
|
+
currentIndex: 1,
|
|
2641
|
+
steps: [
|
|
2642
|
+
{ id: "placed", label: "Placed", done: true, detail: "21 Aug" },
|
|
2643
|
+
{ id: "paid", label: "Paid", done: false, detail: "312 EUR open" },
|
|
2644
|
+
{ id: "shipped", label: "Shipped", done: false },
|
|
2645
|
+
],
|
|
2646
|
+
},
|
|
2647
|
+
],
|
|
2648
|
+
};
|
|
2649
|
+
}
|
|
2650
|
+
```
|