@cosmicdrift/kumiko-framework 0.387.0 → 0.388.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.
Files changed (240) hide show
  1. package/AGENTS.md +6 -1
  2. package/agents/examples/anonymous-access.md +1 -1
  3. package/agents/examples/apex-landing.md +204 -0
  4. package/agents/examples/api-worker-split.md +64 -0
  5. package/agents/examples/app-config.md +14 -0
  6. package/agents/examples/auth-mfa.md +115 -0
  7. package/agents/examples/env-composition.md +28 -1
  8. package/agents/examples/legal-pages.md +1 -1
  9. package/agents/examples/prod-boot-options.md +16 -0
  10. package/agents/examples/rate-limiting.md +48 -0
  11. package/agents/examples/record-detail-layout.md +692 -0
  12. package/agents/examples/seed-migration.md +212 -0
  13. package/agents/examples/wizard-form.md +941 -0
  14. package/agents/examples/writeform-section.md +548 -0
  15. package/agents/features.md +19 -2
  16. package/agents/widgets.md +1 -0
  17. package/dist/api/client-error-route.js +8 -2
  18. package/dist/api/index.d.ts +3 -1
  19. package/dist/api/index.js +3 -1
  20. package/dist/api/request-context.d.ts +1 -1
  21. package/dist/api/request-context.js +1 -1
  22. package/dist/api/server-boot-checks.d.ts +10 -0
  23. package/dist/api/server-boot-checks.js +157 -0
  24. package/dist/api/server-event-dispatcher.d.ts +26 -0
  25. package/dist/api/server-event-dispatcher.js +208 -0
  26. package/dist/api/server-extra-routes.d.ts +11 -0
  27. package/dist/api/server-extra-routes.js +203 -0
  28. package/dist/api/server-middleware.d.ts +20 -0
  29. package/dist/api/server-middleware.js +211 -0
  30. package/dist/api/server-routes.d.ts +19 -0
  31. package/dist/api/server-routes.js +293 -0
  32. package/dist/api/server-websocket-routes.d.ts +4 -0
  33. package/dist/api/server-websocket-routes.js +108 -0
  34. package/dist/api/server-wiring.d.ts +32 -0
  35. package/dist/api/server-wiring.js +236 -0
  36. package/dist/api/server.d.ts +10 -15
  37. package/dist/api/server.js +48 -1251
  38. package/dist/api/session-cookies.js +4 -4
  39. package/dist/api/sse-route.js +16 -12
  40. package/dist/crypto/owner-transition-rekey.d.ts +5 -1
  41. package/dist/crypto/owner-transition-rekey.js +1 -1
  42. package/dist/crypto/pii-field-encryption.d.ts +5 -1
  43. package/dist/crypto/pii-field-encryption.js +3 -1
  44. package/dist/db/aggregate-sql.d.ts +21 -0
  45. package/dist/db/aggregate-sql.js +155 -0
  46. package/dist/db/closed-connection.d.ts +9 -0
  47. package/dist/db/closed-connection.js +95 -0
  48. package/dist/db/dialect.js +1 -1
  49. package/dist/db/distinct-on.d.ts +1 -1
  50. package/dist/db/driver-row-coercion.d.ts +2 -0
  51. package/dist/db/driver-row-coercion.js +186 -0
  52. package/dist/db/driver-value-preparation.d.ts +16 -0
  53. package/dist/db/driver-value-preparation.js +99 -0
  54. package/dist/db/entity-field-encryption.d.ts +1 -0
  55. package/dist/db/entity-field-encryption.js +1 -1
  56. package/dist/db/entity-table-meta.js +103 -110
  57. package/dist/db/event-store-executor-context.d.ts +2 -1
  58. package/dist/db/event-store-executor-read-aggregate.d.ts +8 -0
  59. package/dist/db/event-store-executor-read-aggregate.js +112 -0
  60. package/dist/db/event-store-executor-read-filter.d.ts +31 -0
  61. package/dist/db/event-store-executor-read-filter.js +203 -0
  62. package/dist/db/event-store-executor-read-paging.d.ts +14 -0
  63. package/dist/db/event-store-executor-read-paging.js +99 -0
  64. package/dist/db/event-store-executor-read-rows.d.ts +6 -0
  65. package/dist/db/event-store-executor-read-rows.js +32 -0
  66. package/dist/db/event-store-executor-read-search.d.ts +28 -0
  67. package/dist/db/event-store-executor-read-search.js +221 -0
  68. package/dist/db/event-store-executor-read-sort.d.ts +41 -0
  69. package/dist/db/event-store-executor-read-sort.js +130 -0
  70. package/dist/db/event-store-executor-read-where.d.ts +24 -0
  71. package/dist/db/event-store-executor-read-where.js +81 -0
  72. package/dist/db/event-store-executor-read.d.ts +2 -9
  73. package/dist/db/event-store-executor-read.js +48 -701
  74. package/dist/db/event-store-executor-write-steps.d.ts +20 -0
  75. package/dist/db/event-store-executor-write-steps.js +100 -0
  76. package/dist/db/event-store-executor-write.js +395 -499
  77. package/dist/db/index.d.ts +6 -2
  78. package/dist/db/index.js +5 -1
  79. package/dist/db/list-aggregate-labels.d.ts +14 -0
  80. package/dist/db/list-aggregate-labels.js +26 -0
  81. package/dist/db/migrate-generator.js +71 -86
  82. package/dist/db/migrate-runner.js +4 -1
  83. package/dist/db/query.d.ts +2 -15
  84. package/dist/db/query.js +8 -761
  85. package/dist/db/reference-data.js +6 -1
  86. package/dist/db/table-builder.js +113 -166
  87. package/dist/db/table-info.d.ts +10 -0
  88. package/dist/db/table-info.js +45 -0
  89. package/dist/db/temporal-value-guards.d.ts +6 -0
  90. package/dist/db/temporal-value-guards.js +15 -0
  91. package/dist/db/tenant-db-runner.d.ts +1 -0
  92. package/dist/db/tenant-db-runner.js +3 -0
  93. package/dist/db/tenant-db.js +39 -9
  94. package/dist/db/where-clause.d.ts +6 -0
  95. package/dist/db/where-clause.js +236 -0
  96. package/dist/derivatives/delete-stored-file.js +2 -1
  97. package/dist/engine/boot-validator/boot-check.js +1 -1
  98. package/dist/engine/boot-validator/detail-screens.js +2 -2
  99. package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
  100. package/dist/engine/boot-validator/entity-handler.js +17 -0
  101. package/dist/engine/boot-validator/form-derivations.js +35 -1
  102. package/dist/engine/boot-validator/i18n-keys.js +5 -3
  103. package/dist/engine/boot-validator/index.js +2 -0
  104. package/dist/engine/boot-validator/pii-retention.js +233 -155
  105. package/dist/engine/boot-validator/screens-actions.d.ts +1 -0
  106. package/dist/engine/boot-validator/screens-actions.js +8 -1
  107. package/dist/engine/boot-validator/screens-dashboard.js +2 -5
  108. package/dist/engine/boot-validator/screens-forms.js +2 -6
  109. package/dist/engine/boot-validator/screens-kind-config-edit.d.ts +3 -0
  110. package/dist/engine/boot-validator/screens-kind-config-edit.js +88 -0
  111. package/dist/engine/boot-validator/screens-kind-entity-edit.d.ts +3 -0
  112. package/dist/engine/boot-validator/screens-kind-entity-edit.js +55 -0
  113. package/dist/engine/boot-validator/screens-kind-entity-list.d.ts +3 -0
  114. package/dist/engine/boot-validator/screens-kind-entity-list.js +228 -0
  115. package/dist/engine/boot-validator/screens-kind-projection-detail.d.ts +3 -0
  116. package/dist/engine/boot-validator/screens-kind-projection-detail.js +235 -0
  117. package/dist/engine/boot-validator/screens-kind-projection-list.d.ts +3 -0
  118. package/dist/engine/boot-validator/screens-kind-projection-list.js +52 -0
  119. package/dist/engine/boot-validator/screens-kind-secret-mint.d.ts +3 -0
  120. package/dist/engine/boot-validator/screens-kind-secret-mint.js +28 -0
  121. package/dist/engine/boot-validator/screens-kind-shared.d.ts +37 -0
  122. package/dist/engine/boot-validator/screens-kind-shared.js +142 -0
  123. package/dist/engine/boot-validator/screens-lists.d.ts +2 -1
  124. package/dist/engine/boot-validator/screens-lists.js +12 -9
  125. package/dist/engine/boot-validator/screens.d.ts +0 -2
  126. package/dist/engine/boot-validator/screens.js +99 -860
  127. package/dist/engine/build-app-schema.js +56 -96
  128. package/dist/engine/define-feature.js +9 -2
  129. package/dist/engine/define-handler.js +1 -0
  130. package/dist/engine/entity-handlers.d.ts +13 -0
  131. package/dist/engine/entity-handlers.js +10 -21
  132. package/dist/engine/entity-list-runtime-options.d.ts +8 -0
  133. package/dist/engine/entity-list-runtime-options.js +18 -0
  134. package/dist/engine/feature-ast/extractors/handlers.js +1 -0
  135. package/dist/engine/feature-ast/extractors/round2.js +25 -6
  136. package/dist/engine/feature-ast/patch.js +4 -182
  137. package/dist/engine/feature-ast/pattern-change-schema.d.ts +3 -0
  138. package/dist/engine/feature-ast/pattern-change-schema.js +1 -0
  139. package/dist/engine/feature-ast/pattern-id-matchers.d.ts +7 -0
  140. package/dist/engine/feature-ast/pattern-id-matchers.js +210 -0
  141. package/dist/engine/feature-ast/patterns.d.ts +9 -0
  142. package/dist/engine/feature-ast/patterns.js +43 -51
  143. package/dist/engine/feature-ast/render.js +48 -87
  144. package/dist/engine/feature-entity-handlers.js +3 -0
  145. package/dist/engine/form-derivations.js +18 -7
  146. package/dist/engine/handler-field-references.js +1 -1
  147. package/dist/engine/project-app-schema-for-roles.d.ts +2 -0
  148. package/dist/engine/project-app-schema-for-roles.js +6 -4
  149. package/dist/engine/registry-ingest.js +1 -1
  150. package/dist/engine/schema-builder.js +228 -212
  151. package/dist/engine/screen-helpers.js +1 -1
  152. package/dist/engine/screen-kind.d.ts +7 -0
  153. package/dist/engine/screen-kind.js +1 -0
  154. package/dist/engine/strip-disabled-features-from-app-schema.js +51 -14
  155. package/dist/engine/validate-projection-allowlist.js +2 -1
  156. package/dist/entrypoint/index.d.ts +4 -1
  157. package/dist/entrypoint/index.js +7 -1
  158. package/dist/errors/docs-url.d.ts +1 -1
  159. package/dist/errors/docs-url.js +22 -2
  160. package/dist/es-ops/context.js +1 -1
  161. package/dist/event-store/admin-api.js +1 -1
  162. package/dist/event-store/event-store.js +10 -4
  163. package/dist/files/bind-pending-file-refs.js +3 -3
  164. package/dist/files/create-file-ref-from-bytes.js +4 -1
  165. package/dist/files/file-handle.js +2 -3
  166. package/dist/files/file-routes.js +11 -8
  167. package/dist/files/resolve-content-type.js +43 -0
  168. package/dist/files/upload-ledger.js +7 -0
  169. package/dist/i18n/required-surface-keys.js +182 -206
  170. package/dist/internal/stack-support.d.ts +2 -1
  171. package/dist/internal/stack-support.js +1 -1
  172. package/dist/jobs/job-runner-context.d.ts +32 -0
  173. package/dist/jobs/job-runner-context.js +305 -0
  174. package/dist/jobs/job-runner-execution.d.ts +7 -0
  175. package/dist/jobs/job-runner-execution.js +160 -0
  176. package/dist/jobs/job-runner-gates.d.ts +19 -0
  177. package/dist/jobs/job-runner-gates.js +198 -0
  178. package/dist/jobs/job-runner-helpers.d.ts +17 -3
  179. package/dist/jobs/job-runner-helpers.js +61 -2
  180. package/dist/jobs/job-runner-scope.d.ts +44 -0
  181. package/dist/jobs/job-runner-scope.js +102 -0
  182. package/dist/jobs/job-runner-types.d.ts +12 -0
  183. package/dist/jobs/job-runner.d.ts +0 -1
  184. package/dist/jobs/job-runner.js +47 -657
  185. package/dist/observability/escape-hatch-report.d.ts +3 -0
  186. package/dist/observability/escape-hatch-report.js +12 -1
  187. package/dist/pipeline/cascade-handler.js +165 -138
  188. package/dist/pipeline/dispatch-query.js +10 -3
  189. package/dist/pipeline/dispatch-shared.d.ts +13 -3
  190. package/dist/pipeline/dispatch-shared.js +58 -710
  191. package/dist/pipeline/dispatch-write.js +296 -189
  192. package/dist/pipeline/event-dispatcher-admin.js +2 -1
  193. package/dist/pipeline/event-dispatcher-delivery.js +3 -5
  194. package/dist/pipeline/handler-context-auth.d.ts +9 -0
  195. package/dist/pipeline/handler-context-auth.js +54 -0
  196. package/dist/pipeline/handler-context-config.d.ts +14 -0
  197. package/dist/pipeline/handler-context-config.js +113 -0
  198. package/dist/pipeline/handler-context-db.d.ts +24 -0
  199. package/dist/pipeline/handler-context-db.js +149 -0
  200. package/dist/pipeline/handler-context-dispatch.d.ts +21 -0
  201. package/dist/pipeline/handler-context-dispatch.js +89 -0
  202. package/dist/pipeline/handler-context-events.d.ts +43 -0
  203. package/dist/pipeline/handler-context-events.js +237 -0
  204. package/dist/pipeline/handler-context-notify.d.ts +12 -0
  205. package/dist/pipeline/handler-context-notify.js +55 -0
  206. package/dist/pipeline/handler-context-observability.d.ts +7 -0
  207. package/dist/pipeline/handler-context-observability.js +21 -0
  208. package/dist/pipeline/handler-context-scope.d.ts +48 -0
  209. package/dist/pipeline/handler-context-scope.js +88 -0
  210. package/dist/pipeline/notify-scope.js +12 -1
  211. package/dist/pipeline/pre-handler-gates.js +20 -4
  212. package/dist/pipeline/pre-transaction-reservations.d.ts +1 -0
  213. package/dist/pipeline/pre-transaction-reservations.js +9 -3
  214. package/dist/pipeline/projection-rebuild.js +2 -1
  215. package/dist/schema-cli/apply-command.d.ts +2 -0
  216. package/dist/schema-cli/apply-command.js +97 -0
  217. package/dist/schema-cli/baseline-command.d.ts +2 -0
  218. package/dist/schema-cli/baseline-command.js +33 -0
  219. package/dist/schema-cli/generate-command.d.ts +2 -0
  220. package/dist/schema-cli/generate-command.js +90 -0
  221. package/dist/schema-cli/shared.d.ts +39 -0
  222. package/dist/schema-cli/shared.js +95 -0
  223. package/dist/schema-cli/status-command.d.ts +2 -0
  224. package/dist/schema-cli/status-command.js +73 -0
  225. package/dist/schema-cli/validate-boot-input.d.ts +5 -0
  226. package/dist/schema-cli/validate-boot-input.js +130 -0
  227. package/dist/schema-cli/validate-command.d.ts +2 -0
  228. package/dist/schema-cli/validate-command.js +130 -0
  229. package/dist/schema-cli.d.ts +2 -18
  230. package/dist/schema-cli.js +47 -604
  231. package/dist/search/meilisearch-adapter.js +2 -1
  232. package/dist/upgrade-cli.js +149 -121
  233. package/package.json +4 -4
  234. package/src/changes.json +310 -0
  235. package/src/scripts/codemod/feature-layout.ts +10 -2
  236. package/src/scripts/codemod/object-form.ts +41 -4
  237. package/src/scripts/codemod/package-merge.ts +58 -8
  238. package/src/scripts/codemod/pii-personal-migration.ts +175 -145
  239. package/src/scripts/codemod/testing-injection.ts +122 -42
  240. package/src/scripts/codemod/testing-move.ts +29 -7
@@ -0,0 +1,55 @@
1
+ import { isExtensionEditSection, normalizeEditField, sectionFieldSpecs, } from "../screen-helpers.js";
2
+ import { validateRedirectTarget } from "./screens-actions.js";
3
+ import { validateEditFieldExtras, validateFieldFormRefs, validateFieldsXorGroups, validateFillActionTarget, validateNoWidgetRequiredField, validateWizardLayout, } from "./screens-forms.js";
4
+ import { assertExtensionSectionHasComponent, buildUnknownFieldMessage, rejectEmptySections, rejectProjectionDetailOnlySection, resolveScreenEntity, validateRecordHeaderAction, validateRecordSectionActions, } from "./screens-kind-shared.js";
5
+ function validateEntityEditField(featureName, screenId, entityName, entityDef, fieldNames, fieldSpec) {
6
+ const normalized = normalizeEditField(fieldSpec);
7
+ if (!fieldNames.has(normalized.field)) {
8
+ throw new Error(buildUnknownFieldMessage(featureName, screenId, normalized.field, entityName, fieldNames));
9
+ }
10
+ validateNoWidgetRequiredField(featureName, screenId, entityDef, normalized);
11
+ validateEditFieldExtras(featureName, screenId, entityDef, normalized);
12
+ const fieldWhere = `[Feature ${featureName}] Screen "${screenId}" (entityEdit) field "${normalized.field}"`;
13
+ validateFieldFormRefs(fieldWhere, normalized, fieldNames);
14
+ validateFillActionTarget(fieldWhere, normalized, entityDef.fields[normalized.field]);
15
+ }
16
+ function validateEntityEditSection(ctx, screenId, screen, entityDef, fieldNames, section) {
17
+ const featureName = ctx.feature.name;
18
+ validateRecordSectionActions(ctx, screenId, "entityEdit", section);
19
+ if (isExtensionEditSection(section)) {
20
+ assertExtensionSectionHasComponent(featureName, screenId, "entityEdit", section);
21
+ }
22
+ else {
23
+ rejectProjectionDetailOnlySection(featureName, screenId, "entityEdit", section);
24
+ validateFieldsXorGroups(`[Feature ${featureName}] Screen "${screenId}" (entityEdit)`, section);
25
+ for (const fieldSpec of sectionFieldSpecs(section)) {
26
+ validateEntityEditField(featureName, screenId, screen.entity, entityDef, fieldNames, fieldSpec);
27
+ }
28
+ }
29
+ }
30
+ export function validateEntityEditScreen(ctx, screenId, screen) {
31
+ const featureName = ctx.feature.name;
32
+ const entityDef = resolveScreenEntity(ctx, screenId, screen.entity);
33
+ const fieldNames = new Set(Object.keys(entityDef.fields));
34
+ rejectEmptySections(featureName, screenId, "entityEdit", screen.layout.sections.length);
35
+ for (const section of screen.layout.sections) {
36
+ validateEntityEditSection(ctx, screenId, screen, entityDef, fieldNames, section);
37
+ }
38
+ validateWizardLayout(featureName, screenId, "entityEdit", screen.layout, ctx.featureMap);
39
+ for (const action of screen.actions ?? []) {
40
+ validateRecordHeaderAction(ctx, screenId, "entityEdit", screen.entity, action);
41
+ }
42
+ if (screen.recordTitleField !== undefined && !fieldNames.has(screen.recordTitleField)) {
43
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityEdit) recordTitleField ` +
44
+ `"${screen.recordTitleField}" is not a field of entity "${screen.entity}" ` +
45
+ `(known: ${[...fieldNames].sort().join(", ")}).`);
46
+ }
47
+ if (typeof screen.readOnly === "object" && !fieldNames.has(screen.readOnly.field)) {
48
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityEdit) readOnly condition field ` +
49
+ `"${screen.readOnly.field}" is not a field of entity "${screen.entity}" ` +
50
+ `(known: ${[...fieldNames].sort().join(", ")}).`);
51
+ }
52
+ if (screen.redirect !== undefined) {
53
+ validateRedirectTarget(ctx.feature, screenId, "entityEdit", screen.redirect, ctx);
54
+ }
55
+ }
@@ -0,0 +1,3 @@
1
+ import type { EntityListScreenDefinition } from "../types/screen.ts";
2
+ import { type ScreenValidationContext } from "./screens-kind-shared.ts";
3
+ export declare function validateEntityListScreen(ctx: ScreenValidationContext, screenId: string, screen: EntityListScreenDefinition): void;
@@ -0,0 +1,228 @@
1
+ import { isListFilterAllowed } from "../../db/entity-field-encryption.js";
2
+ import { rowMetaFieldNames } from "../../db/table-builder.js";
3
+ import { qualifyEntityName } from "../qualified-name.js";
4
+ import { getAllowedFilterOps, isFieldFilterable } from "../screen-filter-ops.js";
5
+ import { normalizeListColumn } from "../screen-helpers.js";
6
+ import { LIST_ROW_META_COLUMN_NAMES } from "./entity-list-screens.js";
7
+ import { assertWriteHandlerRegistered, rejectRedirectOnListRowAction, resolveRowActionNavigateTarget, validateActionFieldRefs, validateAtMostOneRowClick, validateDrawerTargetAction, validateRowActionNavigateParams, } from "./screens-actions.js";
8
+ import { buildUnknownFieldMessage, listActionContext, rejectEmptyColumns, rejectNonArrayInFilter, resolveScreenEntity, validateListColumnRendering, } from "./screens-kind-shared.js";
9
+ import { validateRelatedListSection, validateRowActionTarget } from "./screens-lists.js";
10
+ function resolveEntityListFields(ctx, screenId, entityName) {
11
+ const entityDef = resolveScreenEntity(ctx, screenId, entityName);
12
+ const fieldNames = new Set(Object.keys(entityDef.fields));
13
+ // List columns may also name a read-time derived field (not a stored
14
+ // column). Allowed for display; deliberately NOT added to `fieldNames`, so
15
+ // defaultSort/filter on a derived field still fails — server-side sort over
16
+ // a non-column is a silent no-op (see DerivedFieldDef).
17
+ const columnFieldNames = entityDef.derivedFields !== undefined
18
+ ? new Set([...fieldNames, ...Object.keys(entityDef.derivedFields)])
19
+ : fieldNames;
20
+ const rowMeta = rowMetaFieldNames(entityDef.softDelete ?? false);
21
+ return { entityDef, fieldNames, columnFieldNames, rowMeta };
22
+ }
23
+ function validateEntityListColumns(ctx, screenId, screen, fields) {
24
+ const featureName = ctx.feature.name;
25
+ rejectEmptyColumns(featureName, screenId, "entityList", screen.columns.length);
26
+ for (const col of screen.columns) {
27
+ const normalized = normalizeListColumn(col);
28
+ // A row-meta column (id/tenantId/version/insertedAt/modifiedAt/...) is a
29
+ // real DB column without being a declared entity field — e.g. a
30
+ // SystemAdmin cross-tenant list exposing tenantId. Accept it like a
31
+ // regular field name — but only the columns computeListViewModel can
32
+ // actually render (LIST_ROW_META_COLUMN_NAMES), not the wider
33
+ // softDelete-aware rowMeta set used for payload/visible refs.
34
+ //
35
+ // A virtual presentational column (drawn by a columnRenderer component
36
+ // from the row, e.g. tag chips) needs BOTH a label AND a renderer —
37
+ // renderer is what actually makes it "virtual" (label alone still
38
+ // needs list.ts's virtual-branch to have something to draw). A column
39
+ // with neither matching a real field/row-meta column NOR a renderer is
40
+ // a typo worth failing the boot.
41
+ if (!fields.columnFieldNames.has(normalized.field) &&
42
+ !LIST_ROW_META_COLUMN_NAMES.has(normalized.field) &&
43
+ !(normalized.label !== undefined && normalized.renderer !== undefined)) {
44
+ throw new Error(buildUnknownFieldMessage(featureName, screenId, normalized.field, screen.entity, fields.columnFieldNames));
45
+ }
46
+ validateListColumnRendering(ctx, screenId, "entityList", normalized);
47
+ }
48
+ }
49
+ function validateEntityListDefaultSort(featureName, screenId, defaultSort, fields) {
50
+ const sortField = defaultSort.field;
51
+ if (!fields.fieldNames.has(sortField)) {
52
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) defaultSort references unknown ` +
53
+ `field "${sortField}". Known fields: ${[...fields.fieldNames].sort().join(", ")}`);
54
+ }
55
+ // `sortable: true` is required so the UI never sorts on a column that has
56
+ // no server-side DB index or that the schema deliberately keeps unsortable
57
+ // (audit fields, computed values). `sortable` currently
58
+ // exists only on TextFieldDef; the `in` narrowing also permits other
59
+ // field types without an explicit flag, which is acceptable because
60
+ // Number/Date fields are naturally sortable. Authors can mark them
61
+ // sortable when their field type supports it.
62
+ const fieldDef = fields.entityDef.fields[sortField];
63
+ const isSortable = fieldDef !== undefined && "sortable" in fieldDef && fieldDef.sortable === true;
64
+ if (!isSortable) {
65
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) defaultSort.field "${sortField}" ` +
66
+ `is not sortable. Set sortable: true on the field definition or pick another field.`);
67
+ }
68
+ }
69
+ // Screen filters are checked in three layers:
70
+ // 1) The field exists on the entity; a typo would otherwise produce an
71
+ // empty list instead of a clear boot failure.
72
+ // 2) The field has `filterable: true`, preventing accidental filtering
73
+ // of audit, computed, or encrypted fields.
74
+ // 3) The operation matches the field type, so lt/gt on text fields
75
+ // fails at boot instead of causing surprising runtime behavior.
76
+ // Additionally, "in" requires a readonly array.
77
+ function validateEntityListFilter(featureName, screenId, filter, fields) {
78
+ const filterField = filter.field;
79
+ if (!fields.fieldNames.has(filterField)) {
80
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) filter references unknown ` +
81
+ `field "${filterField}". Known fields: ${[...fields.fieldNames].sort().join(", ")}`);
82
+ }
83
+ if (!isListFilterAllowed(fields.entityDef, filterField, filter)) {
84
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) filter references field ` +
85
+ `"${filterField}" which is encrypted, personal or secret, so the list handler rejects ` +
86
+ `this filter at runtime. Only op "eq" works on a personal field with find: "exact" or ` +
87
+ `"fuzzy"; otherwise drop the filter or filter on another field.`);
88
+ }
89
+ const fieldDef = fields.entityDef.fields[filterField];
90
+ if (fieldDef !== undefined && !isFieldFilterable(fieldDef)) {
91
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) filter references field ` +
92
+ `"${filterField}" which is not filterable. Set filterable: true on the field ` +
93
+ `definition or pick another field.`);
94
+ }
95
+ if (fieldDef !== undefined) {
96
+ const allowedOps = getAllowedFilterOps(fieldDef);
97
+ if (!allowedOps.includes(filter.op)) {
98
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) filter.op ` +
99
+ `"${filter.op}" is not allowed on field "${filterField}" ` +
100
+ `(type "${fieldDef.type}"). Allowed ops: ${allowedOps.join(", ") || "(none)"}.`);
101
+ }
102
+ }
103
+ rejectNonArrayInFilter(featureName, screenId, "entityList", filter);
104
+ }
105
+ // The renderer's default-entityId fallback (row["id"]) only fires for a
106
+ // same-feature entityEdit target — it can't safely guess the id for a screen
107
+ // owned by a different feature. Cross-feature + entityEdit therefore MUST set
108
+ // an explicit entityId, or the edit screen silently opens with no entity
109
+ // context at runtime. Entity-targets are exempt: the renderer always supplies
110
+ // an id for them (explicit entityId, else row["id"]), regardless of which
111
+ // feature the resolved detailFor screen belongs to.
112
+ function rejectCrossFeatureEditTargetWithoutEntityId(featureName, screenId, action, target) {
113
+ if (action.screen !== undefined &&
114
+ target !== undefined &&
115
+ target.featureName !== featureName &&
116
+ target.screen.type === "entityEdit" &&
117
+ action.entityId === undefined) {
118
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) rowAction "${action.id}" ` +
119
+ `navigates cross-feature to entityEdit screen "${action.screen}" (feature ` +
120
+ `"${target.featureName}") without an explicit entityId field — the renderer's ` +
121
+ `same-feature row["id"] fallback does not apply across features. Set entityId to ` +
122
+ `the row field that names the target entity's id.`);
123
+ }
124
+ }
125
+ // Pin rowActions at boot: a navigate target must exist and a writeHandler QN
126
+ // must be registered. Typos would otherwise only surface on the first click as
127
+ // "Screen not found" or a 404.
128
+ function validateEntityListRowAction(ctx, screenId, screen, fields, action) {
129
+ const featureName = ctx.feature.name;
130
+ rejectRedirectOnListRowAction(featureName, screenId, "entityList", action);
131
+ if (action.kind === "navigate") {
132
+ const target = resolveRowActionNavigateTarget(featureName, screenId, "entityList", "rowAction", action, ctx.allScreenQns, ctx.navTargetShortIds, ctx.screensByShortId, ctx.detailForScreens);
133
+ rejectCrossFeatureEditTargetWithoutEntityId(featureName, screenId, action, target);
134
+ // params only have a reader in actionForm and entityEdit-CREATE; on
135
+ // projectionDetail/dashboard/configEdit/entityEdit-update they are
136
+ // silently ignored at runtime. `custom` is deliberately exempt: it renders
137
+ // an app-registered component the framework has no visibility into, so
138
+ // flagging it would be a false positive on working code.
139
+ //
140
+ // Whether an entityEdit target lands in create or update mode is decided
141
+ // by the same rule the renderer's runNavigate() uses: an explicit
142
+ // entityId always forces update mode, and (absent an explicit entityId) a
143
+ // same-entity target gets row["id"] auto-injected — only a cross-entity
144
+ // target with no explicit entityId reaches create.
145
+ validateRowActionNavigateParams(featureName, screenId, "entityList", screen.entity, action, target);
146
+ }
147
+ else {
148
+ validateRowActionTarget(listActionContext(ctx, screenId, "entityList", screen.entity, `Screen "${screenId}" (entityList)`), "rowAction", "rowAction", action);
149
+ }
150
+ validateActionFieldRefs(featureName, screenId, "rowAction", action.id, action, fields.fieldNames, fields.rowMeta);
151
+ }
152
+ // toolbarActions, analogous to rowActions: misspelled navigate targets and
153
+ // unregistered writeHandler QNs fail at boot instead of on the first click.
154
+ function validateEntityListToolbarAction(ctx, screenId, fields, action) {
155
+ const featureName = ctx.feature.name;
156
+ if (action.kind === "navigate") {
157
+ const candidateQn = qualifyEntityName(featureName, "screen", action.screen);
158
+ if (!ctx.allScreenQns.has(candidateQn) && !ctx.navTargetShortIds.has(action.screen)) {
159
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) toolbarAction "${action.id}" ` +
160
+ `navigate-target "${action.screen}" does not resolve to a registered screen in any feature. Use "<feature>:screen:<id>" of an existing screen.`);
161
+ }
162
+ if (action.tab !== undefined) {
163
+ resolveRowActionNavigateTarget(featureName, screenId, "entityList", "toolbarAction", action, ctx.allScreenQns, ctx.navTargetShortIds, ctx.screensByShortId, ctx.detailForScreens);
164
+ }
165
+ }
166
+ else if (action.kind === "drawer") {
167
+ validateDrawerTargetAction(featureName, screenId, "entityList", "toolbarAction", action, ctx.feature.screens);
168
+ }
169
+ else {
170
+ assertWriteHandlerRegistered(featureName, `Screen "${screenId}" (entityList) toolbarAction "${action.id}"`, action.handler, ctx.allWriteHandlerQns);
171
+ }
172
+ validateActionFieldRefs(featureName, screenId, "toolbarAction", action.id, action, fields.fieldNames, fields.rowMeta);
173
+ }
174
+ function validateEntityListExpandableRow(ctx, screenId, expandableRow, fields) {
175
+ validateRelatedListSection({
176
+ featureName: ctx.feature.name,
177
+ featureMap: ctx.featureMap,
178
+ screenId,
179
+ screenType: "entityList expandableRow",
180
+ where: `Screen "${screenId}" (entityList) expandableRow "${expandableRow.title}"`,
181
+ section: expandableRow,
182
+ screens: ctx.feature.screens,
183
+ allWriteHandlerQns: ctx.allWriteHandlerQns,
184
+ allScreenQns: ctx.allScreenQns,
185
+ navTargetShortIds: ctx.navTargetShortIds,
186
+ screensByShortId: ctx.screensByShortId,
187
+ detailForScreens: ctx.detailForScreens,
188
+ });
189
+ // Toolbar actions of the expansion evaluate against the host row.
190
+ for (const action of expandableRow.toolbarActions ?? []) {
191
+ validateActionFieldRefs(ctx.feature.name, screenId, "toolbarAction", action.id, action, fields.fieldNames, fields.rowMeta);
192
+ }
193
+ }
194
+ export function validateEntityListScreen(ctx, screenId, screen) {
195
+ const featureName = ctx.feature.name;
196
+ const fields = resolveEntityListFields(ctx, screenId, screen.entity);
197
+ validateEntityListColumns(ctx, screenId, screen, fields);
198
+ // Validate pagination, sorting, and search at boot so authoring errors
199
+ // fail before runtime debugging of empty or incorrectly sorted lists.
200
+ if (screen.pageSize !== undefined && screen.pageSize <= 0) {
201
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) has pageSize=${screen.pageSize} — ` +
202
+ `must be a positive integer.`);
203
+ }
204
+ if (screen.defaultSort !== undefined) {
205
+ validateEntityListDefaultSort(featureName, screenId, screen.defaultSort, fields);
206
+ }
207
+ if (screen.createScreen !== undefined &&
208
+ !Object.hasOwn(ctx.feature.screens, screen.createScreen)) {
209
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (entityList) createScreen ` +
210
+ `"${screen.createScreen}" does not resolve to a registered screen in this feature. ` +
211
+ `Known screens in this feature: ${Object.keys(ctx.feature.screens).sort().join(", ") || "(none)"}.`);
212
+ }
213
+ if (screen.filter !== undefined) {
214
+ validateEntityListFilter(featureName, screenId, screen.filter, fields);
215
+ }
216
+ if (screen.rowActions !== undefined) {
217
+ for (const action of screen.rowActions) {
218
+ validateEntityListRowAction(ctx, screenId, screen, fields, action);
219
+ }
220
+ validateAtMostOneRowClick(featureName, screenId, "entityList", screen.rowActions);
221
+ }
222
+ for (const action of screen.toolbarActions ?? []) {
223
+ validateEntityListToolbarAction(ctx, screenId, fields, action);
224
+ }
225
+ if (screen.expandableRow !== undefined) {
226
+ validateEntityListExpandableRow(ctx, screenId, screen.expandableRow, fields);
227
+ }
228
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProjectionDetailScreenDefinition } from "../types/screen.ts";
2
+ import { type ScreenValidationContext } from "./screens-kind-shared.ts";
3
+ export declare function validateProjectionDetailScreen(ctx: ScreenValidationContext, screenId: string, screen: ProjectionDetailScreenDefinition): void;
@@ -0,0 +1,235 @@
1
+ import { SELECT_OPTION_TONES } from "@cosmicdrift/kumiko-types/fields";
2
+ import { isExtensionEditSection, isFieldsEditSection, isWriteFormEditSection, normalizeEditField, sectionFieldSpecs, } from "../screen-helpers.js";
3
+ import { assertWriteHandlerRegistered, resolveRowActionNavigateTarget, validateActionHasIcon, validatePrimaryActionTarget, } from "./screens-actions.js";
4
+ import { rejectWriteOnlyFormField, validateFieldsXorGroups, validateFormSelectOptions, validateTabSections, } from "./screens-forms.js";
5
+ import { assertExtensionSectionHasComponent, editSectionLabel, listActionContext, navigateActionFromLink, rejectEmptySections, rejectMissingQuery, validateRecordHeaderAction, validateRecordSectionActions, } from "./screens-kind-shared.js";
6
+ import { assertRefTargetRegistered, validateListActionTargets, validateRelatedListSection, } from "./screens-lists.js";
7
+ import { isSelectOptionTone } from "./select-option-tone.js";
8
+ function validateProjectionDetailFlags(featureName, screenId, screen) {
9
+ if (screen.singleton === true && screen.idParam !== undefined) {
10
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) sets both singleton: true ` +
11
+ `and idParam — singleton means the server picks the row from the caller's context, so there ` +
12
+ `is no row id to send under idParam. Remove idParam.`);
13
+ }
14
+ // singleton has no row id in the path, but the auto-generated "Edit"
15
+ // action (defaultEditAction in kumiko-screen.tsx) navigates
16
+ // to the detailFor entity's entityEdit screen using that path id —
17
+ // under singleton it would silently open that screen in CREATE mode
18
+ // instead of editing the singleton row. Reject rather than let that
19
+ // win silently, same as the idParam check above.
20
+ if (screen.singleton === true && screen.detailFor !== undefined) {
21
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) sets both singleton: true ` +
22
+ `and detailFor — the auto-generated "Edit" action navigates using the path's row id, which a ` +
23
+ `singleton screen never has. Remove detailFor, or declare an explicit "edit" action instead.`);
24
+ }
25
+ if (screen.recordTitleField !== undefined && screen.header !== undefined) {
26
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) sets both header and ` +
27
+ `recordTitleField — header.title already names the record, so drop recordTitleField.`);
28
+ }
29
+ }
30
+ function validateProjectionDetailTabs(featureName, screenId, screen) {
31
+ if (screen.layout.mode === "tabs") {
32
+ validateTabSections(featureName, screenId, "projectionDetail", screen.layout.sections);
33
+ for (const section of screen.layout.sections) {
34
+ if (isFieldsEditSection(section) && "groups" in section && section.actions !== undefined) {
35
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) section "${section.id}" ` +
36
+ `declares both groups and actions in tabs mode — actions has no single group's Card to sit ` +
37
+ `in, and an extra title-less Card around the group cards would nest a Card inside a Card. ` +
38
+ `Move the actions onto one group's title, or drop groups for a flat fields grid.`);
39
+ }
40
+ }
41
+ }
42
+ }
43
+ function validateProjectionDetailMetricNavigate(ctx, screenId, screen, field, navigate) {
44
+ const featureName = ctx.feature.name;
45
+ if (navigate.screen === undefined && navigate.entity === undefined) {
46
+ if (navigate.tab !== undefined &&
47
+ !screen.layout.sections.some((section) => section.id === navigate.tab)) {
48
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) metric "${field}" ` +
49
+ `navigates to tab "${navigate.tab}", which is not a section id on this screen. Navigate to an existing section id or remove navigate.tab.`);
50
+ }
51
+ }
52
+ else {
53
+ // Also runs without `tab`: a typo'd screen/entity or an entity
54
+ // target without entityId would otherwise render a clickable
55
+ // metric that silently does nothing.
56
+ resolveRowActionNavigateTarget(featureName, screenId, "projectionDetail", "metric", navigateActionFromLink(field, navigate), ctx.allScreenQns, ctx.navTargetShortIds, ctx.screensByShortId, ctx.detailForScreens);
57
+ }
58
+ }
59
+ function validateProjectionDetailMetric(ctx, screenId, screen, metric) {
60
+ if (typeof metric.label !== "string" || metric.label.length === 0) {
61
+ throw new Error(`[Feature ${ctx.feature.name}] Screen "${screenId}" (projectionDetail) metric "${metric.field}" has ` +
62
+ `no "label" — every metric needs an i18n label key, ` +
63
+ `there is no fallback to the raw column name.`);
64
+ }
65
+ if (metric.navigate !== undefined) {
66
+ validateProjectionDetailMetricNavigate(ctx, screenId, screen, metric.field, metric.navigate);
67
+ }
68
+ }
69
+ function validateProjectionDetailStatusTones(featureName, screenId, screen) {
70
+ for (const [statusValue, tone] of Object.entries(screen.header?.statusTones ?? {})) {
71
+ if (!isSelectOptionTone(tone)) {
72
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) header.statusTones["${statusValue}"] ` +
73
+ `is "${String(tone)}" — expected one of ${SELECT_OPTION_TONES.join(", ")}.`);
74
+ }
75
+ }
76
+ }
77
+ function validateProjectionDetailSubtitleParts(ctx, screenId, subtitleHref, parts) {
78
+ const featureName = ctx.feature.name;
79
+ if (subtitleHref !== undefined) {
80
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) sets header.subtitleHref ` +
81
+ `together with a multi-part header.subtitle — subtitleHref only works with the string form. Use a single-field subtitle or remove subtitleHref.`);
82
+ }
83
+ const seenPartFields = new Set();
84
+ for (const part of parts) {
85
+ const partField = typeof part === "string" ? part : part.field;
86
+ if (seenPartFields.has(partField)) {
87
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) header.subtitle ` +
88
+ `lists field "${partField}" twice. List each field once.`);
89
+ }
90
+ seenPartFields.add(partField);
91
+ const navigate = typeof part === "string" ? undefined : part.navigate;
92
+ if (navigate === undefined)
93
+ continue;
94
+ if (navigate.screen === undefined && navigate.entity === undefined) {
95
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) header.subtitle part ` +
96
+ `"${partField}" navigates with neither "screen" nor "entity" — a tab-only navigate has no link target.`);
97
+ }
98
+ resolveRowActionNavigateTarget(featureName, screenId, "projectionDetail", "subtitle part", navigateActionFromLink(partField, navigate), ctx.allScreenQns, ctx.navTargetShortIds, ctx.screensByShortId, ctx.detailForScreens);
99
+ }
100
+ }
101
+ function validateProjectionDetailSubtitle(ctx, screenId, screen) {
102
+ const header = screen.header;
103
+ if (header !== undefined && Array.isArray(header.subtitle)) {
104
+ validateProjectionDetailSubtitleParts(ctx, screenId, header.subtitleHref, header.subtitle);
105
+ }
106
+ }
107
+ function validateProjectionDetailExtensionSection(featureName, screenId, section) {
108
+ // projectionDetail is read-only (no composed form submit) — an
109
+ // extension that persists through the host's Save button has
110
+ // nothing to save against. Extensions that persist themselves
111
+ // (e.g. notes-history NotesSection, via their own dispatcher
112
+ // writes) are fine.
113
+ if (section.contributesToFormSubmit === true) {
114
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) extension section ` +
115
+ `"${section.title}" sets contributesToFormSubmit: true, but projectionDetail has no ` +
116
+ `form submit to contribute to (read-only screen). Omit contributesToFormSubmit and ` +
117
+ `persist through the extension's own dispatcher writes instead.`);
118
+ }
119
+ assertExtensionSectionHasComponent(featureName, screenId, "projectionDetail", section);
120
+ // The host-derived entity name on projectionDetail is an internal
121
+ // placeholder (no real entity backs this screen) — a self-
122
+ // persisting extension needs the real domain entity name declared
123
+ // explicitly, or it silently reads/writes against the wrong type.
124
+ if (section.entityName === undefined || section.entityName.trim().length === 0) {
125
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) extension section ` +
126
+ `"${section.title}" has no entityName — projectionDetail has no real entity, so the ` +
127
+ `extension must declare entityName explicitly (the domain entity it persists against).`);
128
+ }
129
+ }
130
+ function validateProjectionDetailRelatedList(ctx, screenId, screen, section) {
131
+ if (screen.layout.mode === "wizard") {
132
+ throw new Error(`[Feature ${ctx.feature.name}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
133
+ `is kind "relatedList" in a wizard layout — a read-only list is not supported in a ` +
134
+ `stepped form. Remove mode: "wizard" or drop the relatedList section.`);
135
+ }
136
+ validateRelatedListSection({
137
+ featureName: ctx.feature.name,
138
+ featureMap: ctx.featureMap,
139
+ screenId,
140
+ screenType: "projectionDetail",
141
+ where: `Screen "${screenId}" (projectionDetail) section "${section.title}" (relatedList)`,
142
+ section,
143
+ screens: ctx.feature.screens,
144
+ allWriteHandlerQns: ctx.allWriteHandlerQns,
145
+ allScreenQns: ctx.allScreenQns,
146
+ navTargetShortIds: ctx.navTargetShortIds,
147
+ screensByShortId: ctx.screensByShortId,
148
+ detailForScreens: ctx.detailForScreens,
149
+ });
150
+ }
151
+ function validateProjectionDetailWriteForm(ctx, screenId, screen, section) {
152
+ const featureName = ctx.feature.name;
153
+ if (Object.keys(section.fieldDefs).length === 0) {
154
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
155
+ `(writeForm) has an empty fieldDefs map — declare at least one field type.`);
156
+ }
157
+ if (section.fields.length === 0) {
158
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
159
+ `(writeForm) has zero fields — drop the section or add fields to it.`);
160
+ }
161
+ // A ref to a fieldDef the form never renders would never resolve.
162
+ const writeFormFieldNames = new Set(section.fields.map((f) => normalizeEditField(f).field));
163
+ for (const [defName, fdef] of Object.entries(section.fieldDefs)) {
164
+ validateFormSelectOptions(featureName, screenId, `projectionDetail section "${section.title}" writeForm`, defName, fdef, writeFormFieldNames);
165
+ rejectWriteOnlyFormField(featureName, screenId, `projectionDetail section "${section.title}" writeForm`, defName, fdef);
166
+ }
167
+ for (const f of section.fields) {
168
+ const fieldName = normalizeEditField(f).field;
169
+ if (section.fieldDefs[fieldName] === undefined) {
170
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
171
+ `(writeForm) field "${fieldName}" has no entry in fieldDefs — every rendered field needs ` +
172
+ `a type declared there. Add the field to fieldDefs.`);
173
+ }
174
+ }
175
+ if (screen.layout.mode === "wizard") {
176
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail) section "${section.title}" ` +
177
+ `is kind "writeForm" in a wizard layout — a self-persisting form is not supported in a ` +
178
+ `stepped form. Remove mode: "wizard" or drop the writeForm section.`);
179
+ }
180
+ assertWriteHandlerRegistered(featureName, `Screen "${screenId}" (projectionDetail) section "${section.title}" (writeForm)`, section.handler, ctx.allWriteHandlerQns);
181
+ }
182
+ function validateProjectionDetailFieldsSection(ctx, screenId, section) {
183
+ const featureName = ctx.feature.name;
184
+ validateFieldsXorGroups(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail)`, section);
185
+ for (const fieldSpec of sectionFieldSpecs(section)) {
186
+ const normalizedField = normalizeEditField(fieldSpec);
187
+ if (normalizedField.refEntity !== undefined) {
188
+ assertRefTargetRegistered(`[Feature ${featureName}] Screen "${screenId}" (projectionDetail)`, `field "${normalizedField.field}" (refEntity)`, normalizedField.refEntity, featureName, ctx.featureMap);
189
+ }
190
+ }
191
+ }
192
+ function validateProjectionDetailSection(ctx, screenId, screen, section) {
193
+ const featureName = ctx.feature.name;
194
+ validateRecordSectionActions(ctx, screenId, "projectionDetail", section);
195
+ if (section.kind === "relatedList" && section.emptyState?.action !== undefined) {
196
+ const sectionLabel = editSectionLabel(section);
197
+ validateActionHasIcon(featureName, screenId, "projectionDetail", `section "${sectionLabel}" emptyState action`, section.emptyState.action);
198
+ validateListActionTargets(listActionContext(ctx, screenId, "projectionDetail", undefined, `Screen "${screenId}" (projectionDetail) section "${sectionLabel}"`), "emptyState action", section.emptyState.action);
199
+ }
200
+ if (isExtensionEditSection(section)) {
201
+ validateProjectionDetailExtensionSection(featureName, screenId, section);
202
+ }
203
+ else if (section.kind === "relatedList") {
204
+ validateProjectionDetailRelatedList(ctx, screenId, screen, section);
205
+ }
206
+ else if (isWriteFormEditSection(section)) {
207
+ validateProjectionDetailWriteForm(ctx, screenId, screen, section);
208
+ }
209
+ else {
210
+ validateProjectionDetailFieldsSection(ctx, screenId, section);
211
+ }
212
+ }
213
+ // Query-driven like projectionList, but a single row plus layout instead of
214
+ // columns. No entity check is possible: fields resolve against the query
215
+ // response at render time, not against an entity.
216
+ export function validateProjectionDetailScreen(ctx, screenId, screen) {
217
+ const featureName = ctx.feature.name;
218
+ rejectMissingQuery(featureName, screenId, "projectionDetail", screen.query);
219
+ validateProjectionDetailFlags(featureName, screenId, screen);
220
+ rejectEmptySections(featureName, screenId, "projectionDetail", screen.layout.sections.length);
221
+ validateProjectionDetailTabs(featureName, screenId, screen);
222
+ for (const metric of screen.metrics ?? []) {
223
+ validateProjectionDetailMetric(ctx, screenId, screen, metric);
224
+ }
225
+ validateProjectionDetailStatusTones(featureName, screenId, screen);
226
+ validateProjectionDetailSubtitle(ctx, screenId, screen);
227
+ for (const section of screen.layout.sections) {
228
+ validateProjectionDetailSection(ctx, screenId, screen, section);
229
+ }
230
+ validatePrimaryActionTarget(featureName, screenId, screen);
231
+ for (const action of screen.actions ?? []) {
232
+ validateActionHasIcon(featureName, screenId, "projectionDetail", "action", action);
233
+ validateRecordHeaderAction(ctx, screenId, "projectionDetail", screen.detailFor, action);
234
+ }
235
+ }
@@ -0,0 +1,3 @@
1
+ import type { ProjectionListScreenDefinition } from "../types/screen.ts";
2
+ import { type ScreenValidationContext } from "./screens-kind-shared.ts";
3
+ export declare function validateProjectionListScreen(ctx: ScreenValidationContext, screenId: string, screen: ProjectionListScreenDefinition): void;
@@ -0,0 +1,52 @@
1
+ import { normalizeListColumn } from "../screen-helpers.js";
2
+ import { assertWriteHandlerRegistered, resolveRowActionNavigateTarget, validateAtMostOneRowClick, validateDrawerTargetAction, } from "./screens-actions.js";
3
+ import { listActionContext, rejectEmptyColumns, rejectMissingQuery, rejectNonArrayInFilter, validateListColumnRendering, } from "./screens-kind-shared.js";
4
+ import { validateListActionTargets, validateListFacets } from "./screens-lists.js";
5
+ function validateProjectionListRowActions(ctx, screenId, rowActions) {
6
+ const listContext = listActionContext(ctx, screenId, "projectionList", undefined, `Screen "${screenId}" (projectionList)`);
7
+ for (const action of rowActions) {
8
+ validateListActionTargets(listContext, "rowAction", action);
9
+ }
10
+ validateAtMostOneRowClick(ctx.feature.name, screenId, "projectionList", rowActions);
11
+ }
12
+ // Plain navigate toolbarActions (no tab) have no boot check yet.
13
+ function validateProjectionListToolbarActions(ctx, screenId, toolbarActions) {
14
+ const featureName = ctx.feature.name;
15
+ for (const action of toolbarActions) {
16
+ if (action.kind === "drawer") {
17
+ validateDrawerTargetAction(featureName, screenId, "projectionList", "toolbarAction", action, ctx.feature.screens);
18
+ }
19
+ else if (action.kind === "writeHandler") {
20
+ assertWriteHandlerRegistered(featureName, `Screen "${screenId}" (projectionList) toolbarAction "${action.id}"`, action.handler, ctx.allWriteHandlerQns);
21
+ }
22
+ if (action.kind === "navigate" && action.tab !== undefined) {
23
+ resolveRowActionNavigateTarget(featureName, screenId, "projectionList", "toolbarAction", action, ctx.allScreenQns, ctx.navTargetShortIds, ctx.screensByShortId, ctx.detailForScreens);
24
+ }
25
+ }
26
+ }
27
+ // Query-driven, no entity, so only query + columns are checked (the column
28
+ // fields cannot be checked against an entity; they resolve against the
29
+ // projection rows at render time).
30
+ export function validateProjectionListScreen(ctx, screenId, screen) {
31
+ const featureName = ctx.feature.name;
32
+ rejectMissingQuery(featureName, screenId, "projectionList", screen.query);
33
+ rejectEmptyColumns(featureName, screenId, "projectionList", screen.columns.length);
34
+ for (const col of screen.columns) {
35
+ validateListColumnRendering(ctx, screenId, "projectionList", normalizeListColumn(col));
36
+ }
37
+ // Screen filter: field existence can't be checked without an entity (columns
38
+ // aren't a complete field inventory of the underlying query), so only the
39
+ // structure is pinned: "in" requires an array.
40
+ if (screen.filter !== undefined) {
41
+ rejectNonArrayInFilter(featureName, screenId, "projectionList", screen.filter);
42
+ }
43
+ if (screen.facets !== undefined) {
44
+ validateListFacets(`[Feature ${featureName}] Screen "${screenId}" (projectionList)`, screen.facets, screen.columns, featureName, ctx.featureMap);
45
+ }
46
+ if (screen.rowActions !== undefined) {
47
+ validateProjectionListRowActions(ctx, screenId, screen.rowActions);
48
+ }
49
+ if (screen.toolbarActions !== undefined) {
50
+ validateProjectionListToolbarActions(ctx, screenId, screen.toolbarActions);
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ import type { SecretMintScreenDefinition } from "../types/screen.ts";
2
+ import type { ScreenValidationContext } from "./screens-kind-shared.ts";
3
+ export declare function validateSecretMintScreen(ctx: ScreenValidationContext, screenId: string, screen: SecretMintScreenDefinition): void;
@@ -0,0 +1,28 @@
1
+ import { validateInlineFormScreen, validateSecretMintConfirm } from "./screens-forms.js";
2
+ function validateSecretMintRevealFields(featureName, screenId, screen) {
3
+ if (screen.reveal.fields.length === 0) {
4
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (secretMint) has an empty reveal.fields ` +
5
+ `list — declare at least one field to reveal.`);
6
+ }
7
+ const revealFieldNames = new Set();
8
+ for (const revealField of screen.reveal.fields) {
9
+ if (typeof revealField.field !== "string" || revealField.field.trim() === "") {
10
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (secretMint) has a reveal.fields entry ` +
11
+ `with an empty or non-string "field". Set field to a non-empty string.`);
12
+ }
13
+ if (revealFieldNames.has(revealField.field)) {
14
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (secretMint) reveal.fields has a ` +
15
+ `duplicate field "${revealField.field}" — each revealed field must be unique.`);
16
+ }
17
+ revealFieldNames.add(revealField.field);
18
+ if (typeof revealField.label !== "string" || revealField.label.trim() === "") {
19
+ throw new Error(`[Feature ${featureName}] Screen "${screenId}" (secretMint) reveal.fields entry ` +
20
+ `"${revealField.field}" has an empty or non-string "label". Set label to a non-empty string.`);
21
+ }
22
+ }
23
+ }
24
+ export function validateSecretMintScreen(ctx, screenId, screen) {
25
+ validateInlineFormScreen(ctx.feature, screenId, screen, "secretMint", ctx.allWriteHandlerQns, ctx, ctx.featureMap);
26
+ validateSecretMintRevealFields(ctx.feature.name, screenId, screen);
27
+ validateSecretMintConfirm(ctx.feature, screenId, screen, ctx.allWriteHandlerQns);
28
+ }