@cosmicdrift/kumiko-framework 0.409.0 → 0.411.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 (41) hide show
  1. package/AGENTS.md +4 -2
  2. package/agents/api/framework-engine.md +4 -0
  3. package/agents/api/framework-ui-types.md +10 -0
  4. package/agents/api/renderer-web.md +113 -10
  5. package/agents/api/types.md +22 -0
  6. package/agents/api.md +1 -1
  7. package/agents/boot-rules.md +5 -0
  8. package/agents/examples/anonymous-access.md +23 -1
  9. package/agents/examples/contact.md +11 -5
  10. package/agents/examples/realtime-sse.md +37 -2
  11. package/agents/examples/record-detail-layout.md +35 -2
  12. package/agents/examples/wizard-form.md +96 -5
  13. package/agents/features-index.md +1 -1
  14. package/agents/features.md +9 -2
  15. package/agents/widgets.md +6 -0
  16. package/dist/db/queries/session-advisory-lock.js +3 -0
  17. package/dist/engine/access.js +5 -1
  18. package/dist/engine/boot-validator/access-declarations.js +19 -0
  19. package/dist/engine/boot-validator/boot-rules.d.ts +25 -0
  20. package/dist/engine/boot-validator/handler-declaration-rules.d.ts +5 -0
  21. package/dist/engine/boot-validator/handler-declaration-rules.js +5 -0
  22. package/dist/engine/boot-validator/list-table-options.js +1 -0
  23. package/dist/engine/boot-validator/nav.js +4 -2
  24. package/dist/engine/boot-validator/screens-forms-layout-rules.d.ts +15 -0
  25. package/dist/engine/boot-validator/screens-forms-layout-rules.js +15 -0
  26. package/dist/engine/boot-validator/screens-forms.d.ts +1 -1
  27. package/dist/engine/boot-validator/screens-forms.js +60 -3
  28. package/dist/engine/boot-validator/screens-kind-projection-detail-rules.d.ts +5 -0
  29. package/dist/engine/boot-validator/screens-kind-projection-detail-rules.js +5 -0
  30. package/dist/engine/boot-validator/screens-kind-projection-detail.js +19 -0
  31. package/dist/engine/boot-validator/screens-lists.js +2 -2
  32. package/dist/engine/project-app-schema-for-roles.js +11 -10
  33. package/dist/engine/screen-helpers.d.ts +1 -0
  34. package/dist/engine/screen-helpers.js +1 -1
  35. package/dist/pipeline/context-services.d.ts +1 -0
  36. package/dist/pipeline/context-services.js +1 -0
  37. package/dist/pipeline/handler-context-scope.js +5 -1
  38. package/dist/pipeline/user-live-signals.d.ts +5 -0
  39. package/dist/pipeline/user-live-signals.js +20 -0
  40. package/package.json +3 -3
  41. package/src/changes.json +54 -0
@@ -17,6 +17,7 @@ header, a metrics band, and a tabbed layout instead of one long stacked form.
17
17
  rendered from the columns of the screen's own query row
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
+ - a header action with `showOnTabs: ["payments"]`, shown only while that tab is active
20
21
  - boot-validator catching two common author mistakes: a `metrics` entry
21
22
  with an empty `label`, and a `tabs` layout with fewer than two
22
23
  sections
@@ -571,6 +572,24 @@ test.describe("record-detail-layout — tall tab panel scrolls", () => {
571
572
  await expect(end).toBeInViewport();
572
573
  });
573
574
  });
575
+
576
+ test.describe("record-detail-layout — header action per tab", () => {
577
+ const recordPayment = "order-desk.action.recordPayment";
578
+
579
+ test("record-payment shows on the payments tab only", async ({ page }) => {
580
+ await page.goto("/?tab=payments");
581
+ await expect(page.getByTestId("kumiko-screen-projection-detail-tabs")).toBeVisible();
582
+ // The third header action lands in the overflow menu.
583
+ await page.getByRole("button", { name: "More actions" }).last().click();
584
+ await expect(page.getByText(recordPayment)).toBeVisible();
585
+
586
+ await page.goto("/?tab=items");
587
+ await expect(page.getByTestId("render-list-table")).toBeVisible();
588
+ // Only two actions remain, so no overflow menu is rendered.
589
+ await expect(page.getByRole("button", { name: "More actions" })).toHaveCount(0);
590
+ await expect(page.getByText(recordPayment)).toHaveCount(0);
591
+ });
592
+ });
574
593
  ```
575
594
 
576
595
  ### e2e/padding-parity-screenshots.spec.ts
@@ -795,10 +814,14 @@ describe("record-detail-layout showcase — registration", () => {
795
814
  ]);
796
815
  });
797
816
 
798
- test("screen-level actions carry refresh-order and keep download-invoice inline", () => {
817
+ test("screen-level actions carry refresh-order, inline download-invoice and the payments-only record-payment", () => {
799
818
  const screen = registry.getScreen("order-desk:screen:order-detail");
800
819
  if (screen?.type !== "projectionDetail") throw new Error("expected projectionDetail");
801
- expect(screen.actions?.map((a) => a.id)).toEqual(["refresh-order", "download-invoice"]);
820
+ expect(screen.actions?.map((a) => a.id)).toEqual([
821
+ "refresh-order",
822
+ "download-invoice",
823
+ "record-payment",
824
+ ]);
802
825
  expect(screen.inlineActions).toEqual(["download-invoice"]);
803
826
  });
804
827
 
@@ -890,6 +913,8 @@ describe("record-detail-layout showcase — boot-validator catches author mistak
890
913
  // not inside any tab's Card. `inlineActions` keeps download-invoice a visible
891
914
  // button next to it where the page header would otherwise fold it into the menu.
892
915
  //
916
+ // 6. `showOnTabs` limits the record-payment action to the payments tab.
917
+ //
893
918
  // projectionDetail has no entity — it binds to an explicit query instead, so
894
919
  // every field name below (header, metrics, fields) is a column of that
895
920
  // query's row, not an entity field.
@@ -1032,6 +1057,14 @@ export function createOrderDeskFeature(): FeatureDefinition {
1032
1057
  screen: "order-detail",
1033
1058
  icon: "download",
1034
1059
  },
1060
+ {
1061
+ kind: "navigate",
1062
+ id: "record-payment",
1063
+ label: "order-desk.action.recordPayment",
1064
+ screen: "order-detail",
1065
+ icon: "plus",
1066
+ showOnTabs: ["payments"],
1067
+ },
1035
1068
  ],
1036
1069
  inlineActions: ["download-invoice"],
1037
1070
  access: { roles: ["Support", "Admin"] },
@@ -32,6 +32,15 @@ the user left off.
32
32
  mounted alongside this one (both enforced at boot). The actual
33
33
  save/resume/discard wiring happens automatically inside `RenderEdit` —
34
34
  this recipe never calls a form-draft handler from its own code.
35
+ - **Step rail texts** — a section's `subtitle` is the line under its step in
36
+ the rail (opt-in, `description` is never used there); `summaryField`
37
+ replaces it with the entered value once the step is done. `wizard.aside`
38
+ adds the "up next" card, and `finishDescription` the finish card on the
39
+ last step. Extension steps take the same three texts; on an `actionForm`
40
+ `summaryField` and `submitDisabledWhen` may name a field of its `fields`.
41
+ - **Footer options** — `wizard.saveAndCloseOnCreate` offers "Save and close" (also on the last step)
42
+ while creating; `wizard.submitDisabledWhen` disables Finish while a field
43
+ condition holds. It is UI-only: enforce the rule in a validation hook too.
35
44
 
36
45
  ## Feature composition
37
46
 
@@ -881,12 +890,15 @@ test.describe("wizard-form — step navigation, validation, draft resume", () =>
881
890
  const rail = page.getByTestId("render-edit-wizard-steps");
882
891
  const step0 = page.getByTestId("render-edit-wizard-steps-step-0");
883
892
  const step1 = page.getByTestId("render-edit-wizard-steps-step-1");
893
+ const step2 = page.getByTestId("render-edit-wizard-steps-step-2");
884
894
 
885
895
  await expect(rail).toBeVisible();
886
896
  await expect(page.getByTestId("render-edit-wizard-progress")).toHaveCount(0);
887
897
  await expect(step0).toHaveAttribute("aria-current", "step");
888
- await expect(step0).toHaveCSS("height", "36px");
889
- await expect(step1).toHaveCSS("height", "36px");
898
+ // Rows with a subtitle grow past 36px; the subtitle-less Review row pins the exact box.
899
+ await expect(step2).toHaveCSS("height", "36px");
900
+ expect((await step0.boundingBox())?.height).toBeGreaterThanOrEqual(36);
901
+ expect((await step1.boundingBox())?.height).toBeGreaterThanOrEqual(36);
890
902
 
891
903
  await page.getByTestId("field-title").locator("input").fill("Vintage desk lamp");
892
904
  await selectCombobox(page, "category", "furniture");
@@ -894,7 +906,75 @@ test.describe("wizard-form — step navigation, validation, draft resume", () =>
894
906
 
895
907
  await expect(step1).toHaveAttribute("aria-current", "step");
896
908
  await expect(step0).not.toHaveAttribute("aria-current", "step");
897
- await expect(step1).toHaveCSS("height", "36px");
909
+ await expect(step2).toHaveCSS("height", "36px");
910
+ });
911
+
912
+ test("the rail shows the other steps' subtitles and, once a step is done, its summaryField value", async ({
913
+ page,
914
+ }) => {
915
+ await gotoWizard(page);
916
+ await expect(page.getByTestId("render-edit-wizard-steps-subtitle-0")).toHaveCount(0);
917
+ await expect(page.getByTestId("render-edit-wizard-steps-subtitle-1")).toHaveText(
918
+ "Price and condition",
919
+ );
920
+
921
+ await page.getByTestId("field-title").locator("input").fill("Vintage desk lamp");
922
+ await selectCombobox(page, "category", "furniture");
923
+ await page.getByTestId("render-edit-wizard-next").click();
924
+
925
+ await expect(page.getByTestId("render-edit-wizard-steps-subtitle-0")).toHaveText(
926
+ "Vintage desk lamp",
927
+ );
928
+ await expect(page.getByTestId("render-edit-wizard-steps-subtitle-1")).toHaveCount(0);
929
+ });
930
+
931
+ test("the up-next card names the next step and, on the last step, the finish action", async ({
932
+ page,
933
+ }) => {
934
+ await gotoWizard(page);
935
+ const upNext = page.getByTestId("render-edit-wizard-steps-up-next");
936
+ await expect(upNext).toContainText("Pricing");
937
+ await expect(upNext).toContainText("Price and condition");
938
+
939
+ await page.getByTestId("field-title").locator("input").fill("Vintage desk lamp");
940
+ await selectCombobox(page, "category", "furniture");
941
+ await page.getByTestId("render-edit-wizard-next").click();
942
+ await expect(upNext).toContainText("Review");
943
+ await page.getByTestId("field-price").locator("input").fill("42");
944
+ await page.getByTestId("render-edit-wizard-next").click();
945
+
946
+ await expect(upNext).toContainText("Publishes the listing.");
947
+ });
948
+
949
+ test("Save and close is offered while creating and creates the listing", async ({ page }) => {
950
+ await gotoWizard(page);
951
+ await page.getByTestId("field-title").locator("input").fill("Quick save lamp");
952
+ await selectCombobox(page, "category", "furniture");
953
+
954
+ await page.getByTestId("render-edit-wizard-save-close").click();
955
+
956
+ await expect
957
+ .poll(async () => (await createdListings(page)).map((listing) => listing["title"]))
958
+ .toEqual(["Quick save lamp"]);
959
+ });
960
+
961
+ test("submitDisabledWhen disables Finish while the category is vehicles", async ({ page }) => {
962
+ await gotoWizard(page);
963
+ await page.getByTestId("field-title").locator("input").fill("Old bicycle");
964
+ await selectCombobox(page, "category", "vehicles");
965
+ await page.getByTestId("render-edit-wizard-next").click();
966
+ await page.getByTestId("field-price").locator("input").fill("150");
967
+ await page.getByTestId("render-edit-wizard-next").click();
968
+
969
+ await expect(page.getByTestId("render-edit-submit")).toBeDisabled();
970
+
971
+ await page.getByTestId("render-edit-wizard-back").click();
972
+ await page.getByTestId("render-edit-wizard-back").click();
973
+ await selectCombobox(page, "category", "furniture");
974
+ await page.getByTestId("render-edit-wizard-next").click();
975
+ await page.getByTestId("render-edit-wizard-next").click();
976
+
977
+ await expect(page.getByTestId("render-edit-submit")).toBeEnabled();
898
978
  });
899
979
 
900
980
  test("an empty required field blocks Next and shows a field error", async ({ page }) => {
@@ -1256,9 +1336,20 @@ export const listingsFeature = defineFeature("listings", (r) => {
1256
1336
  layout: {
1257
1337
  mode: "wizard",
1258
1338
  draft: true,
1339
+ wizard: {
1340
+ aside: { upNext: true, finishDescription: "Publishes the listing." },
1341
+ saveAndCloseOnCreate: true,
1342
+ // UI-only: the write handler would still accept a vehicle listing.
1343
+ submitDisabledWhen: { field: "category", eq: "vehicles" },
1344
+ },
1259
1345
  sections: [
1260
- { title: "Basics", fields: ["title", "category"] },
1261
- { title: "Pricing", fields: ["price", "condition"] },
1346
+ {
1347
+ title: "Basics",
1348
+ subtitle: "Title and category",
1349
+ summaryField: "title",
1350
+ fields: ["title", "category"],
1351
+ },
1352
+ { title: "Pricing", subtitle: "Price and condition", fields: ["price", "condition"] },
1262
1353
  {
1263
1354
  kind: "extension",
1264
1355
  title: "Review",
@@ -49,7 +49,7 @@ One entry per feature a package ships: purpose, import of its factory, required
49
49
  - `config`: Stores per-tenant (and optionally per-user) configuration values with a multi-layer cascade: user-row → tenant-row → system-row → app-override (deploy-time `AppConfigOverrides`) → computed → feature default.
50
50
  `import { createConfigFeature } from "@cosmicdrift/kumiko-bundled-features/config"`
51
51
  - `contact`: Contact inbox: an anonymous browser client (GET /contact/client.js) submits questions, contact requests, bug reports and wishes behind a honeypot, a minimum submit time and a single-use proof-of-work challenge; signed-in users file reports from the admin.
52
- `import { createContactFeature } from "@cosmicdrift/kumiko-bundled-features/contact"`; requires `config`, `delivery`, `user-data-rights`, `files`, `notes-history`, `channel-telegram`
52
+ `import { createContactFeature } from "@cosmicdrift/kumiko-bundled-features/contact"`; requires `config`, `delivery`, `user-data-rights`, `files`, `notes-history`
53
53
  - `crypto-shredding`: Operator-level crypto-shredding trigger.
54
54
  `import { createCryptoShreddingFeature } from "@cosmicdrift/kumiko-bundled-features/crypto-shredding"`
55
55
  - `custom-fields`: Tenant- and system-scoped custom field definitions with generic value storage on any host entity.
@@ -200,14 +200,15 @@ Contact inbox: an anonymous browser client (GET /contact/client.js) submits ques
200
200
 
201
201
  Category: communication
202
202
 
203
- Requires: `config`, `delivery`, `user-data-rights`, `files`, `notes-history`, `channel-telegram`
203
+ Requires: `config`, `delivery`, `user-data-rights`, `files`, `notes-history`
204
+
205
+ Optional requires: `channel-telegram`
204
206
 
205
207
  Config keys:
206
208
 
207
209
  | Key | Type | Scope | Default |
208
210
  | --- | --- | --- | --- |
209
211
  | `reply-to` | text | system | `` |
210
- | `telegram-chat` | text | system | `` |
211
212
 
212
213
  ## crypto-shredding
213
214
 
@@ -557,6 +558,12 @@ Category: identity
557
558
 
558
559
  Requires: `user`, `tenant`, `auth-foundation`
559
560
 
561
+ ## presence
562
+
563
+ Who else is on this record right now: a browser sends a heartbeat every 15 seconds for one row of an allow-listed entity and gets the other viewers and editors back, with a live signal to them on a change. State is ephemeral (Redis hash per tenant, entity and row, in-memory without Redis), keyed by the session tenant, expires after ttlSeconds without a heartbeat and holds user ids only; display names are looked up per response. A caller sees presence only for rows visible to them. Mount with createPresenceFeature({ entities: ["task"] }).
564
+
565
+ Category: communication
566
+
560
567
  ## rate-limiting
561
568
 
562
569
  Adds an ops-side `rate-limiting:query:status` query handler for inspecting current bucket state; the actual request throttling is wired automatically by the dispatcher when any handler declares a `rateLimit` option (e.g. `{ per: 'user', limit: 3, windowSeconds: 60 }`) or when you pass `context.rateLimit` to `buildServer`. Loading this feature is optional if you only need L3 per-handler rate limits and have no need for ops introspection.
package/agents/widgets.md CHANGED
@@ -23,6 +23,7 @@ Value exports of `@cosmicdrift/kumiko-renderer/web`.
23
23
  | `ClampedText` | Clamps content to `lines`; the toggle shows only while the content actually overflows. |
24
24
  | `CollapsibleSection` | Collapsible section using native <details> with React-controlled state; otherwise the open attribute resets to its initial value on every parent re-render. |
25
25
  | `ComparisonTable` | Transposed comparison table: row = metric, column = variant, with the best column optionally highlighted for each metric. |
26
+ | `Composer` | Chat input: a label-less textarea with a text send button inside the field frame, bottom right. |
26
27
  | `DateField` | Date field = Field + Input(kind:"date"), ISO yyyy-mm-dd. |
27
28
  | `DefaultAppShell` | |
28
29
  | `DetailList` | Read-only key-value list for detail views (dimmed label on the left, value on the right). |
@@ -69,6 +70,8 @@ Value exports of `@cosmicdrift/kumiko-renderer/web`.
69
70
  | `PlainContentEditor` | |
70
71
  | `PlanCard` | |
71
72
  | `PlanGrid` | |
73
+ | `PresenceAvatars` | Small round avatars of the people on a row, with "+n" for the rest; for list rows. |
74
+ | `PresenceNotice` | One quiet line above a record: who else is on it and for how long. |
72
75
  | `PrimitivesProvider` | |
73
76
  | `ProfileMenu` | |
74
77
  | `ProgressBar` | Progress bar, `value` 0..1 (clamped). |
@@ -86,6 +89,7 @@ Value exports of `@cosmicdrift/kumiko-renderer/web`.
86
89
  | `ResultTable` | Static, prop-driven result table for calculated rows (tranches, scenarios). |
87
90
  | `ScreenWidthProvider` | |
88
91
  | `SectionCard` | Section with a title and optional action slot (range switcher, filter) — replaces repeated `<section className={CARD}>…<h2>` blocks in custom screens. |
92
+ | `SectionNavLayout` | Content column plus an "On this page" navigation in a right column (from xl), for custom screens. |
89
93
  | `SelectField` | Select field = Field + Input(kind:"select"). |
90
94
  | `SenderFrame` | Sand frame with one white sheet inside, for content that mimics a letter or mail. |
91
95
  | `SenderSheet` | The white sheet alone, for a frame that holds several sheets (PDF pages, thumbnails). |
@@ -134,6 +138,8 @@ Value exports of `@cosmicdrift/kumiko-renderer/web`.
134
138
  | `useLiveEvents` | Hook for a useQuery-like consumer. |
135
139
  | `useLocale` | Provides the current LocaleResolver and automatically subscribes to locale changes — the calling component re-renders when the language changes. |
136
140
  | `useNav` | |
141
+ | `usePresence` | Announces the user on one record: a heartbeat right away and every 15 s, a leave when the record closes. |
142
+ | `usePresenceList` | Who else is on each of the given rows, for badges in a list. |
137
143
  | `usePrimitives` | |
138
144
  | `useQuery` | |
139
145
  | `useResolvers` | |
@@ -8,6 +8,8 @@ export async function withSessionAdvisoryLock(db, key, fn) {
8
8
  }
9
9
  const conn = await client.reserve();
10
10
  try {
11
+ // Waiting for a peer must not hit the pool's statement_timeout (57014 would crash the waiter's boot).
12
+ await conn.unsafe("SET statement_timeout = 0");
11
13
  await conn.unsafe(`SELECT pg_advisory_lock($1)`, [key]);
12
14
  try {
13
15
  return await fn();
@@ -15,6 +17,7 @@ export async function withSessionAdvisoryLock(db, key, fn) {
15
17
  finally {
16
18
  // A dropped session already released its lock; failing here would mask fn's outcome.
17
19
  await conn.unsafe(`SELECT pg_advisory_unlock($1)`, [key]).catch(() => undefined);
20
+ await conn.unsafe("RESET statement_timeout").catch(() => undefined);
18
21
  }
19
22
  }
20
23
  finally {
@@ -1,4 +1,4 @@
1
- import { isOpenToAllGranted } from "@cosmicdrift/kumiko-types/handlers";
1
+ import { isAnySignedInGranted, isOpenToAllGranted } from "@cosmicdrift/kumiko-types/handlers";
2
2
  import { ANONYMOUS_ROLE } from "./system-user.js";
3
3
  // Default-deny: a handler without an explicit AccessRule is unreachable. To
4
4
  // grant access a handler must either list allowed roles or opt into
@@ -11,6 +11,8 @@ import { ANONYMOUS_ROLE } from "./system-user.js";
11
11
  // list `anonymous` in `roles` (e.g. `roles: ["anonymous", "customer"]`).
12
12
  // Without this guard, enabling `anonymousAccess` on the server would silently
13
13
  // turn every existing `openToAll: true` handler into a public endpoint.
14
+ // `anySignedIn` widens such a public rule to every signed-in caller instead of
15
+ // the listed roles only.
14
16
  export function hasAccess(user, access) {
15
17
  if (!access)
16
18
  return false;
@@ -21,5 +23,7 @@ export function hasAccess(user, access) {
21
23
  }
22
24
  if (access.roles.length === 0)
23
25
  return false;
26
+ if (isAnySignedInGranted(access) && !user.roles.includes(ANONYMOUS_ROLE))
27
+ return true;
24
28
  return access.roles.some((role) => user.roles.includes(role));
25
29
  }
@@ -178,6 +178,22 @@ function validateAnonymousPersonalData(feature, handlerName, handler) {
178
178
  "vouch for it; protection comes from the handler's required rateLimit (per ip).",
179
179
  });
180
180
  }
181
+ // Read via `unknown`: access can come from untyped sources (pattern JSON, Designer).
182
+ function validateAnySignedIn(feature, kind, handlerName, access) {
183
+ // skip: openToAll has no anySignedIn, or nothing declared
184
+ if (!("roles" in access) || !("anySignedIn" in access))
185
+ return;
186
+ const declared = access.anySignedIn;
187
+ // skip: a public rule that admits every signed-in caller as well
188
+ if (declared === true && accessAllowsAnonymous(access))
189
+ return;
190
+ const problem = declared === true
191
+ ? `its roles do not include "${ANONYMOUS_ROLE}"; for every signed-in user without anonymous callers use { openToAll: { reason } }`
192
+ : `the only supported value is true, got ${JSON.stringify(declared)}`;
193
+ throw bootRuleError(HANDLER_DECLARATION_RULES.anySignedInInvalid, {
194
+ message: `[Feature ${feature.name}] ${kind} handler "${handlerName}" declares access.anySignedIn but ${problem}.`,
195
+ });
196
+ }
181
197
  // The rateLimit is the only protection of a public-intake handler, so the
182
198
  // generic anonymous opt-out (rateLimit: { disabled: true }) must not apply.
183
199
  function validatePublicIntakeRateLimit(feature, kind, handlerName, handler) {
@@ -197,6 +213,7 @@ function validatePublicIntakeRateLimit(feature, kind, handlerName, handler) {
197
213
  export function validateAccessDeclarations(feature) {
198
214
  for (const [handlerName, handler] of Object.entries(feature.writeHandlers)) {
199
215
  validateOpenToAllReason(feature, "write", handlerName, handler.access);
216
+ validateAnySignedIn(feature, "write", handlerName, handler.access);
200
217
  validateEscapeHatchReason(feature, "write", handlerName, handler.escapeHatch);
201
218
  validatePersonalDataValue(feature, "write", handlerName, handler.access);
202
219
  validateOpenToAllPersonalData(feature, handlerName, handler);
@@ -205,6 +222,7 @@ export function validateAccessDeclarations(feature) {
205
222
  }
206
223
  for (const [handlerName, handler] of Object.entries(feature.queryHandlers)) {
207
224
  validateOpenToAllReason(feature, "query", handlerName, handler.access);
225
+ validateAnySignedIn(feature, "query", handlerName, handler.access);
208
226
  validateEscapeHatchReason(feature, "query", handlerName, handler.escapeHatch);
209
227
  validatePersonalDataSupportedForKind(feature, "query", handlerName, handler.access);
210
228
  validatePersonalDataValue(feature, "query", handlerName, handler.access);
@@ -212,6 +230,7 @@ export function validateAccessDeclarations(feature) {
212
230
  }
213
231
  for (const [handlerName, handler] of Object.entries(feature.streamHandlers)) {
214
232
  validateOpenToAllReason(feature, "stream", handlerName, handler.access);
233
+ validateAnySignedIn(feature, "stream", handlerName, handler.access);
215
234
  validateEscapeHatchReason(feature, "stream", handlerName, handler.escapeHatch);
216
235
  validatePersonalDataSupportedForKind(feature, "stream", handlerName, handler.access);
217
236
  }
@@ -957,6 +957,21 @@ export declare const FRAMEWORK_BOOT_RULE_TABLES: readonly [{
957
957
  readonly summary: "Every wizard section has a non-empty title.";
958
958
  readonly fix: "Give each wizard section a title.";
959
959
  };
960
+ readonly wizardOptionWithoutWizard: {
961
+ readonly id: "form/wizard-option-without-wizard";
962
+ readonly summary: "layout.wizard.saveAndCloseOnCreate, submitDisabledWhen, aside.finishDescription and section summaryField are set only on a wizard layout.";
963
+ readonly fix: 'Remove the option or set mode: "wizard".';
964
+ };
965
+ readonly wizardSummaryFieldUnknown: {
966
+ readonly id: "form/wizard-summary-field-unknown";
967
+ readonly summary: "A wizard section summaryField names a field of that section.";
968
+ readonly fix: "Use a field name declared in the section.";
969
+ };
970
+ readonly wizardSubmitConditionFieldUnknown: {
971
+ readonly id: "form/wizard-submit-condition-field-unknown";
972
+ readonly summary: "layout.wizard.submitDisabledWhen names a field of the layout.";
973
+ readonly fix: "Use a field name declared in one of the sections.";
974
+ };
960
975
  readonly sectionFieldsAndGroups: {
961
976
  readonly id: "form/section-fields-and-groups";
962
977
  readonly summary: "A section declares fields or groups, not both.";
@@ -1270,6 +1285,11 @@ export declare const FRAMEWORK_BOOT_RULE_TABLES: readonly [{
1270
1285
  readonly summary: "A metric navigate.tab names a section id of the screen.";
1271
1286
  readonly fix: "Navigate to an existing section id or remove navigate.tab.";
1272
1287
  };
1288
+ readonly actionShowOnTabsInvalid: {
1289
+ readonly id: "projection-detail/action-show-on-tabs-invalid";
1290
+ readonly summary: 'A header action showOnTabs is non-empty, names section ids of the screen and needs layout.mode "tabs".';
1291
+ readonly fix: "List existing section ids or remove showOnTabs.";
1292
+ };
1273
1293
  readonly metricLabelMissing: {
1274
1294
  readonly id: "projection-detail/metric-label-missing";
1275
1295
  readonly summary: "Every metric has an i18n label key.";
@@ -2748,6 +2768,11 @@ export declare const FRAMEWORK_BOOT_RULE_TABLES: readonly [{
2748
2768
  readonly summary: 'A handler with access.personalData "public-intake" allows the anonymous role.';
2749
2769
  readonly fix: "Add the anonymous role to access.roles or remove personalData.";
2750
2770
  };
2771
+ readonly anySignedInInvalid: {
2772
+ readonly id: "handler/any-signed-in-invalid";
2773
+ readonly summary: "access.anySignedIn is true when set and appears only next to the anonymous role, on endpoints that are public anyway.";
2774
+ readonly fix: 'Add "anonymous" to access.roles, or use { openToAll: { reason } } for every signed-in user without anonymous callers.';
2775
+ };
2751
2776
  readonly publicIntakeRateLimitDisabled: {
2752
2777
  readonly id: "handler/public-intake-rate-limit-disabled";
2753
2778
  readonly summary: 'A handler with access.personalData "public-intake" keeps its rateLimit enabled, because it is the only protection for anonymous personal-data writes.';
@@ -34,6 +34,11 @@ export declare const HANDLER_DECLARATION_RULES: {
34
34
  readonly summary: 'A handler with access.personalData "public-intake" allows the anonymous role.';
35
35
  readonly fix: "Add the anonymous role to access.roles or remove personalData.";
36
36
  };
37
+ readonly anySignedInInvalid: {
38
+ readonly id: "handler/any-signed-in-invalid";
39
+ readonly summary: "access.anySignedIn is true when set and appears only next to the anonymous role, on endpoints that are public anyway.";
40
+ readonly fix: 'Add "anonymous" to access.roles, or use { openToAll: { reason } } for every signed-in user without anonymous callers.';
41
+ };
37
42
  readonly publicIntakeRateLimitDisabled: {
38
43
  readonly id: "handler/public-intake-rate-limit-disabled";
39
44
  readonly summary: 'A handler with access.personalData "public-intake" keeps its rateLimit enabled, because it is the only protection for anonymous personal-data writes.';
@@ -34,6 +34,11 @@ export const HANDLER_DECLARATION_RULES = {
34
34
  summary: 'A handler with access.personalData "public-intake" allows the anonymous role.',
35
35
  fix: "Add the anonymous role to access.roles or remove personalData.",
36
36
  },
37
+ anySignedInInvalid: {
38
+ id: "handler/any-signed-in-invalid",
39
+ summary: "access.anySignedIn is true when set and appears only next to the anonymous role, on endpoints that are public anyway.",
40
+ fix: 'Add "anonymous" to access.roles, or use { openToAll: { reason } } for every signed-in user without anonymous callers.',
41
+ },
37
42
  publicIntakeRateLimitDisabled: {
38
43
  id: "handler/public-intake-rate-limit-disabled",
39
44
  summary: 'A handler with access.personalData "public-intake" keeps its rateLimit enabled, because it is the only protection for anonymous personal-data writes.',
@@ -14,6 +14,7 @@ const BOOLEAN_OPTION_KEYS = [
14
14
  "pinning",
15
15
  "resizing",
16
16
  "keyboardNavigation",
17
+ "compactHeader",
17
18
  ];
18
19
  function validateDensity(where, density) {
19
20
  if (!isPlainObject(density)) {
@@ -1,7 +1,7 @@
1
1
  // Nav validation + collectKnownRoles (role synthesis for ownership
2
2
  // validation in index.ts — thematically adjacent to ownership.ts, kept
3
3
  // here since this is a structural move, not a semantic reorg).
4
- import { isOpenToAllGranted } from "@cosmicdrift/kumiko-types/handlers";
4
+ import { isAnySignedInGranted, isOpenToAllGranted } from "@cosmicdrift/kumiko-types/handlers";
5
5
  import { createFallbackLogger } from "../../logging/utils.js";
6
6
  import { qualifyEntityName } from "../qualified-name.js";
7
7
  import { bootRuleError } from "./boot-rule.js";
@@ -118,12 +118,14 @@ export function validateNavCycles(allNavQns) {
118
118
  visit(qualified, []);
119
119
  }
120
120
  }
121
- // undefined or granted openToAll means visible to everyone (no role-set to compare); malformed/denied openToAll returns `[]`, same as an explicit `roles: []`.
121
+ // undefined, granted openToAll or anySignedIn means visible to everyone (no role-set to compare); malformed/denied openToAll returns `[]`, same as an explicit `roles: []`.
122
122
  function navViewerRoles(access) {
123
123
  if (access === undefined)
124
124
  return undefined;
125
125
  if ("openToAll" in access)
126
126
  return isOpenToAllGranted(access) ? undefined : [];
127
+ if (isAnySignedInGranted(access))
128
+ return undefined;
127
129
  return access.roles;
128
130
  }
129
131
  // Warn (never throw — this is a real UX bug, not a broken ref)
@@ -49,6 +49,21 @@ export declare const FORM_LAYOUT_RULES: {
49
49
  readonly summary: "Every wizard section has a non-empty title.";
50
50
  readonly fix: "Give each wizard section a title.";
51
51
  };
52
+ readonly wizardOptionWithoutWizard: {
53
+ readonly id: "form/wizard-option-without-wizard";
54
+ readonly summary: "layout.wizard.saveAndCloseOnCreate, submitDisabledWhen, aside.finishDescription and section summaryField are set only on a wizard layout.";
55
+ readonly fix: 'Remove the option or set mode: "wizard".';
56
+ };
57
+ readonly wizardSummaryFieldUnknown: {
58
+ readonly id: "form/wizard-summary-field-unknown";
59
+ readonly summary: "A wizard section summaryField names a field of that section.";
60
+ readonly fix: "Use a field name declared in the section.";
61
+ };
62
+ readonly wizardSubmitConditionFieldUnknown: {
63
+ readonly id: "form/wizard-submit-condition-field-unknown";
64
+ readonly summary: "layout.wizard.submitDisabledWhen names a field of the layout.";
65
+ readonly fix: "Use a field name declared in one of the sections.";
66
+ };
52
67
  readonly sectionFieldsAndGroups: {
53
68
  readonly id: "form/section-fields-and-groups";
54
69
  readonly summary: "A section declares fields or groups, not both.";
@@ -49,6 +49,21 @@ export const FORM_LAYOUT_RULES = {
49
49
  summary: "Every wizard section has a non-empty title.",
50
50
  fix: "Give each wizard section a title.",
51
51
  },
52
+ wizardOptionWithoutWizard: {
53
+ id: "form/wizard-option-without-wizard",
54
+ summary: "layout.wizard.saveAndCloseOnCreate, submitDisabledWhen, aside.finishDescription and section summaryField are set only on a wizard layout.",
55
+ fix: 'Remove the option or set mode: "wizard".',
56
+ },
57
+ wizardSummaryFieldUnknown: {
58
+ id: "form/wizard-summary-field-unknown",
59
+ summary: "A wizard section summaryField names a field of that section.",
60
+ fix: "Use a field name declared in the section.",
61
+ },
62
+ wizardSubmitConditionFieldUnknown: {
63
+ id: "form/wizard-submit-condition-field-unknown",
64
+ summary: "layout.wizard.submitDisabledWhen names a field of the layout.",
65
+ fix: "Use a field name declared in one of the sections.",
66
+ },
52
67
  sectionFieldsAndGroups: {
53
68
  id: "form/section-fields-and-groups",
54
69
  summary: "A section declares fields or groups, not both.",
@@ -13,7 +13,7 @@ export declare function validateTabSections(featureName: string, screenId: strin
13
13
  readonly id?: string;
14
14
  readonly title?: string;
15
15
  }[]): void;
16
- export declare function validateWizardLayout(featureName: string, screenId: string, screenType: "entityEdit" | "actionForm" | "configEdit" | "secretMint", layout: EditLayout, featureMap: ReadonlyMap<string, FeatureDefinition>): void;
16
+ export declare function validateWizardLayout(featureName: string, screenId: string, screenType: "entityEdit" | "actionForm" | "configEdit" | "secretMint", layout: EditLayout, featureMap: ReadonlyMap<string, FeatureDefinition>, inlineFieldNames?: ReadonlySet<string>): void;
17
17
  export declare function isWriteOnlyField(fdef: FieldDefinition | undefined): boolean;
18
18
  export declare function validateConfigEditSecretField(featureName: string, screen: ConfigEditScreenDefinition, fieldName: string, secretQn: string, featureMap: ReadonlyMap<string, FeatureDefinition>): void;
19
19
  export declare function rejectWriteOnlyFormField(featureName: string, screenId: string, context: string, fieldName: string, fdef: FieldDefinition): void;
@@ -1,6 +1,6 @@
1
1
  import { NO_WIDGET_FIELD_TYPES, optionsQueryFieldRefs } from "@cosmicdrift/kumiko-types/fields";
2
2
  import { isKebabSegment } from "../qualified-name.js";
3
- import { isExtensionEditSection, isWriteFormEditSection, normalizeEditField, sectionFieldSpecs, } from "../screen-helpers.js";
3
+ import { isExtensionEditSection, isFieldsEditSection, isWriteFormEditSection, normalizeEditField, sectionFieldSpecs, } from "../screen-helpers.js";
4
4
  import { bootRuleError } from "./boot-rule.js";
5
5
  import { validateFormDerivations, validateFormDerivationsEnforced } from "./form-derivations.js";
6
6
  import { assertWriteHandlerRegistered, isSensitiveOrPasswordField, validateIdlessSuccessLink, validateRedirectTarget, validateScreenNavTarget, } from "./screens-actions.js";
@@ -189,10 +189,66 @@ export function validateTabSections(featureName, screenId, screenType, sections)
189
189
  tabIds.add(section.id);
190
190
  });
191
191
  }
192
+ // An actionForm's own `fields` count too: extension steps (a wizard with no fields section) keep their values there.
193
+ function wizardFieldNames(layout, inlineFieldNames) {
194
+ const names = new Set(inlineFieldNames);
195
+ for (const section of layout.sections) {
196
+ if (!isFieldsEditSection(section))
197
+ continue;
198
+ for (const spec of sectionFieldSpecs(section))
199
+ names.add(normalizeEditField(spec).field);
200
+ }
201
+ return names;
202
+ }
203
+ function usesWizardOption(layout) {
204
+ const wizard = layout.wizard;
205
+ return (wizard?.saveAndCloseOnCreate !== undefined ||
206
+ wizard?.submitDisabledWhen !== undefined ||
207
+ wizard?.aside?.finishDescription !== undefined ||
208
+ layout.sections.some((section) => (isFieldsEditSection(section) || section.kind === "extension") &&
209
+ section.summaryField !== undefined));
210
+ }
211
+ function validateWizardOptions(featureName, screenId, screenType, layout, inlineFieldNames) {
212
+ const where = `[Feature ${featureName}] Screen "${screenId}" (${screenType})`;
213
+ const wizard = layout.wizard;
214
+ if (layout.mode !== "wizard") {
215
+ if (usesWizardOption(layout)) {
216
+ throw bootRuleError(FORM_LAYOUT_RULES.wizardOptionWithoutWizard, {
217
+ message: `${where} sets a wizard-only layout option but mode is not "wizard". Remove it or set mode: "wizard".`,
218
+ });
219
+ }
220
+ // skip: the remaining checks only apply to wizards
221
+ return;
222
+ }
223
+ const allFieldNames = wizardFieldNames(layout, inlineFieldNames);
224
+ for (const section of layout.sections) {
225
+ if (section.kind === "extension" &&
226
+ section.summaryField !== undefined &&
227
+ !allFieldNames.has(section.summaryField)) {
228
+ throw bootRuleError(FORM_LAYOUT_RULES.wizardSummaryFieldUnknown, {
229
+ message: `${where} extension section "${section.title}" sets summaryField "${section.summaryField}", which is not a field of the screen. Use a field name declared in the screen's fields or a fields section.`,
230
+ });
231
+ }
232
+ if (!isFieldsEditSection(section))
233
+ continue;
234
+ const sectionFieldNames = sectionFieldSpecs(section).map((spec) => normalizeEditField(spec).field);
235
+ if (section.summaryField !== undefined && !sectionFieldNames.includes(section.summaryField)) {
236
+ throw bootRuleError(FORM_LAYOUT_RULES.wizardSummaryFieldUnknown, {
237
+ message: `${where} section "${section.title ?? ""}" sets summaryField "${section.summaryField}", which is not a field of that section. Use a field name declared in the section.`,
238
+ });
239
+ }
240
+ }
241
+ const condition = wizard?.submitDisabledWhen;
242
+ if (typeof condition === "object" && !allFieldNames.has(condition.field)) {
243
+ throw bootRuleError(FORM_LAYOUT_RULES.wizardSubmitConditionFieldUnknown, {
244
+ message: `${where} layout.wizard.submitDisabledWhen names field "${condition.field}", which no section declares. Use a field name declared in one of the sections.`,
245
+ });
246
+ }
247
+ }
192
248
  // Wizard layouts (mode: "wizard") need >= 2 titled sections — a single or
193
249
  // untitled step would leave the progress indicator blank, so both fail at
194
250
  // boot rather than as a broken step UI.
195
- export function validateWizardLayout(featureName, screenId, screenType, layout, featureMap) {
251
+ export function validateWizardLayout(featureName, screenId, screenType, layout, featureMap, inlineFieldNames) {
196
252
  // entityEdit renders tabs like wizard steps: every section stays mounted,
197
253
  // submit validates across all of them, and a field error jumps to the tab
198
254
  // holding it. The other three have no such jump — actionForm and
@@ -227,6 +283,7 @@ export function validateWizardLayout(featureName, screenId, screenType, layout,
227
283
  });
228
284
  }
229
285
  }
286
+ validateWizardOptions(featureName, screenId, screenType, layout, inlineFieldNames);
230
287
  // skip: mode omitted/"single" — no wizard constraints apply.
231
288
  if (layout.mode !== "wizard")
232
289
  return;
@@ -584,7 +641,7 @@ export function validateInlineFormScreen(feature, screenId, screen, kind, allWri
584
641
  const allowEmptyMintForm = kind === "secretMint";
585
642
  const fieldNames = validateFormFieldsMap(feature.name, screenId, kind, screen.fields, allowEmptyMintForm);
586
643
  validateFormLayoutSections(feature.name, screenId, kind, screen.layout, fieldNames, screen.fields, allowEmptyMintForm && fieldNames.size === 0);
587
- validateWizardLayout(feature.name, screenId, kind, screen.layout, featureMap);
644
+ validateWizardLayout(feature.name, screenId, kind, screen.layout, featureMap, fieldNames);
588
645
  if (screen.type === "actionForm") {
589
646
  validateFormDerivations(feature.name, screenId, screen);
590
647
  validateFormDerivationsEnforced(feature.name, screenId, screen, featureMap);
@@ -24,6 +24,11 @@ export declare const PROJECTION_DETAIL_RULES: {
24
24
  readonly summary: "A metric navigate.tab names a section id of the screen.";
25
25
  readonly fix: "Navigate to an existing section id or remove navigate.tab.";
26
26
  };
27
+ readonly actionShowOnTabsInvalid: {
28
+ readonly id: "projection-detail/action-show-on-tabs-invalid";
29
+ readonly summary: 'A header action showOnTabs is non-empty, names section ids of the screen and needs layout.mode "tabs".';
30
+ readonly fix: "List existing section ids or remove showOnTabs.";
31
+ };
27
32
  readonly metricLabelMissing: {
28
33
  readonly id: "projection-detail/metric-label-missing";
29
34
  readonly summary: "Every metric has an i18n label key.";