@marktiderman/genesis-core 2.16.1 → 2.17.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 (124) hide show
  1. package/README.md +3 -2
  2. package/dist/{aggregate-Y5IJ5aPn.d.ts → aggregate-v_r-nZbH.d.ts} +1 -1
  3. package/dist/{chunk-M5IX7C6U.js → chunk-24X4HWL5.js} +4 -4
  4. package/dist/{chunk-M5IX7C6U.js.map → chunk-24X4HWL5.js.map} +1 -1
  5. package/dist/chunk-2ORQLYVW.js +115 -0
  6. package/dist/chunk-2ORQLYVW.js.map +1 -0
  7. package/dist/{chunk-XPBS5YE4.js → chunk-4POVYF6P.js} +4 -4
  8. package/dist/{chunk-XPBS5YE4.js.map → chunk-4POVYF6P.js.map} +1 -1
  9. package/dist/{chunk-IYGVJFCV.js → chunk-5KLIFJYG.js} +3 -3
  10. package/dist/{chunk-IYGVJFCV.js.map → chunk-5KLIFJYG.js.map} +1 -1
  11. package/dist/{chunk-ALLWIK62.js → chunk-6B4CN2TC.js} +8 -6
  12. package/dist/chunk-6B4CN2TC.js.map +1 -0
  13. package/dist/chunk-6JOWGO2X.js +266 -0
  14. package/dist/chunk-6JOWGO2X.js.map +1 -0
  15. package/dist/{chunk-E3K2A3PK.js → chunk-6SHGMEA6.js} +3 -3
  16. package/dist/{chunk-E3K2A3PK.js.map → chunk-6SHGMEA6.js.map} +1 -1
  17. package/dist/chunk-6VNM6KAX.js +59 -0
  18. package/dist/chunk-6VNM6KAX.js.map +1 -0
  19. package/dist/{chunk-SOO54YYY.js → chunk-AQX5HQD6.js} +3 -3
  20. package/dist/{chunk-SOO54YYY.js.map → chunk-AQX5HQD6.js.map} +1 -1
  21. package/dist/chunk-BNKP2H7J.js +11 -0
  22. package/dist/chunk-BNKP2H7J.js.map +1 -0
  23. package/dist/{chunk-FXPODKCK.js → chunk-FBMKI22S.js} +6 -6
  24. package/dist/{chunk-FXPODKCK.js.map → chunk-FBMKI22S.js.map} +1 -1
  25. package/dist/{chunk-POUI7GAI.js → chunk-JF7FXSQB.js} +5 -5
  26. package/dist/{chunk-POUI7GAI.js.map → chunk-JF7FXSQB.js.map} +1 -1
  27. package/dist/chunk-JNWTHDGF.js +892 -0
  28. package/dist/chunk-JNWTHDGF.js.map +1 -0
  29. package/dist/chunk-K33LWVUF.js +31 -0
  30. package/dist/chunk-K33LWVUF.js.map +1 -0
  31. package/dist/chunk-KRRESUXT.js +192 -0
  32. package/dist/chunk-KRRESUXT.js.map +1 -0
  33. package/dist/{chunk-LB6FMQQM.js → chunk-KV2HW4G4.js} +3 -11
  34. package/dist/chunk-KV2HW4G4.js.map +1 -0
  35. package/dist/{chunk-42NVJJTT.js → chunk-MMMC37AP.js} +3 -3
  36. package/dist/{chunk-42NVJJTT.js.map → chunk-MMMC37AP.js.map} +1 -1
  37. package/dist/chunk-MZVFOTAE.js +96 -0
  38. package/dist/chunk-MZVFOTAE.js.map +1 -0
  39. package/dist/{chunk-R3YXYVWF.js → chunk-OIZNABG4.js} +5 -4
  40. package/dist/chunk-OIZNABG4.js.map +1 -0
  41. package/dist/{chunk-QGWQ6LK3.js → chunk-QJOKZZKY.js} +9 -6
  42. package/dist/chunk-QJOKZZKY.js.map +1 -0
  43. package/dist/chunk-TWLPC4S3.js +53 -0
  44. package/dist/chunk-TWLPC4S3.js.map +1 -0
  45. package/dist/{chunk-7EFTWOMA.js → chunk-UNEZF3ZP.js} +73 -15
  46. package/dist/chunk-UNEZF3ZP.js.map +1 -0
  47. package/dist/chunk-WNOCPV4A.js +220 -0
  48. package/dist/chunk-WNOCPV4A.js.map +1 -0
  49. package/dist/{chunk-ZYOJWU62.js → chunk-XIBQ5BTZ.js} +12 -53
  50. package/dist/chunk-XIBQ5BTZ.js.map +1 -0
  51. package/dist/chunk-YMFJLBIZ.js +159 -0
  52. package/dist/chunk-YMFJLBIZ.js.map +1 -0
  53. package/dist/{chunk-UDSTWXXZ.js → chunk-ZKLB2HB5.js} +3 -3
  54. package/dist/{chunk-UDSTWXXZ.js.map → chunk-ZKLB2HB5.js.map} +1 -1
  55. package/dist/csv.d.ts +12 -3
  56. package/dist/csv.js +4 -4
  57. package/dist/csv.js.map +1 -1
  58. package/dist/form-types.d.ts +1 -1
  59. package/dist/headless/index.d.ts +1 -1
  60. package/dist/hooks/index.d.ts +16 -6
  61. package/dist/hooks/index.js +27 -15
  62. package/dist/hooks/mutation-mode.d.ts +1 -1
  63. package/dist/hooks/mutation-mode.js +3 -3
  64. package/dist/hooks/related-keys.d.ts +1 -1
  65. package/dist/hooks/use-aggregate.d.ts +2 -2
  66. package/dist/hooks/use-aggregate.js +3 -3
  67. package/dist/hooks/use-board-columns.d.ts +79 -0
  68. package/dist/hooks/use-board-columns.js +4 -0
  69. package/dist/hooks/use-board-columns.js.map +1 -0
  70. package/dist/hooks/use-capabilities.d.ts +1 -1
  71. package/dist/hooks/use-capabilities.js +2 -2
  72. package/dist/hooks/use-infinite-resource.d.ts +1 -1
  73. package/dist/hooks/use-infinite-resource.js +3 -3
  74. package/dist/hooks/use-link-options.d.ts +1 -1
  75. package/dist/hooks/use-link-options.js +5 -5
  76. package/dist/hooks/use-list-state.d.ts +103 -0
  77. package/dist/hooks/use-list-state.js +21 -0
  78. package/dist/hooks/use-list-state.js.map +1 -0
  79. package/dist/hooks/use-live.d.ts +1 -1
  80. package/dist/hooks/use-live.js +2 -2
  81. package/dist/hooks/use-one.d.ts +7 -1
  82. package/dist/hooks/use-one.js +3 -3
  83. package/dist/hooks/use-persisted-ui-state.js +2 -2
  84. package/dist/hooks/use-relation-label.d.ts +1 -1
  85. package/dist/hooks/use-relation-label.js +2 -2
  86. package/dist/hooks/use-resource-form.d.ts +1 -1
  87. package/dist/hooks/use-resource-form.js +7 -7
  88. package/dist/hooks/use-resource.d.ts +7 -1
  89. package/dist/hooks/use-resource.js +5 -5
  90. package/dist/hooks/use-segment-counts.d.ts +23 -0
  91. package/dist/hooks/use-segment-counts.js +19 -0
  92. package/dist/hooks/use-segment-counts.js.map +1 -0
  93. package/dist/hooks/use-view-board.d.ts +120 -0
  94. package/dist/hooks/use-view-board.js +29 -0
  95. package/dist/hooks/use-view-board.js.map +1 -0
  96. package/dist/hooks/use-view-calendar-range.d.ts +91 -0
  97. package/dist/hooks/use-view-calendar-range.js +22 -0
  98. package/dist/hooks/use-view-calendar-range.js.map +1 -0
  99. package/dist/hooks/use-write.d.ts +1 -1
  100. package/dist/index.d.ts +41 -11
  101. package/dist/index.js +119 -26
  102. package/dist/index.js.map +1 -1
  103. package/dist/provider/index.d.ts +61 -8
  104. package/dist/provider/index.js +2 -2
  105. package/dist/resource-view/index.d.ts +162 -757
  106. package/dist/resource-view/index.js +31 -686
  107. package/dist/resource-view/index.js.map +1 -1
  108. package/dist/saved-views-C45lRm7i.d.ts +155 -0
  109. package/dist/schema/index.d.ts +3 -3
  110. package/dist/schema/index.js +2 -1
  111. package/dist/testing/index.d.ts +2 -2
  112. package/dist/types-BAhcze_-.d.ts +1063 -0
  113. package/dist/{types-BriIV4e_.d.ts → types-CiQY6hUy.d.ts} +11 -1
  114. package/dist/{viewer-scope-Dx0N9AYk.d.ts → viewer-oOk0ZZk9.d.ts} +36 -34
  115. package/dist/{workspaces-CxpiFu2-.d.ts → workspaces-DeaFix5Z.d.ts} +1 -1
  116. package/dist/workspaces.d.ts +2 -2
  117. package/dist/{write-outcome-CkQXgtJq.d.ts → write-outcome-DuwfsnyO.d.ts} +1 -1
  118. package/package.json +11 -1
  119. package/dist/chunk-7EFTWOMA.js.map +0 -1
  120. package/dist/chunk-ALLWIK62.js.map +0 -1
  121. package/dist/chunk-LB6FMQQM.js.map +0 -1
  122. package/dist/chunk-QGWQ6LK3.js.map +0 -1
  123. package/dist/chunk-R3YXYVWF.js.map +0 -1
  124. package/dist/chunk-ZYOJWU62.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/resource-view/errors.ts","../src/resource-view/scope.ts","../src/resource-view/link.ts","../src/resource-view/types.ts","../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IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA,EAAS,WAAA;AAAA,IACT,KAAA,EAAO,CAAC,IAAA,KAAiB,MAAA,CAAO,IAAI,IAAI,CAAA;AAAA,IACxC,MAAA,EAAQ,CAAC,IAAA,KAAkB,MAAA,CAAO,GAAA,CAAI,IAAI,CAAA,IAAK,QAAA,CAAS,IAAI,CAAA,GAAI,WAAA,CAAY,IAAI,CAAA,GAAI,MAAA;AAAA,IACpF,KAAA;AAAA,IACA,OAAA;AAAA,IACA,UAAA;AAAA,IACA,OAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA,GAAA;AAAA,IACA,SAAS,MAAM,eAAA;AAAA,IACf,SAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAS,MAAM,eAAA;AAAA,IACf,UAAU,MAAM,gBAAA;AAAA,IAChB,cAAA;AAAA,IACA,YAAA,EAAc,CAAC,MAAA,EAA6D,IAAA,KAAkB,kBAAkB,eAAA,EAAiB,MAAA,EAAQ,QAAQ,IAAI,CAAA;AAAA,IACrJ,OAAO,MAAM,SAAA;AAAA,IACb,OAAA;AAAA,IACA,UAAA;AAAA,IACA,QAAA;AAAA,IACA,cAAc,MAAM;AAAA,GACrB,CAAA;AACH","file":"chunk-JNWTHDGF.js","sourcesContent":["// The error defineView and its helpers throw for a view that doesn't fit its contract.\n\n/** A view that names a field, preset or section its contract doesn't have. */\nexport class ViewDefinitionError extends Error {\n readonly problems: readonly string[];\n constructor(resource: string, problems: readonly string[]) {\n super(`defineView(${resource}): ${problems.join(\"; \")}`);\n this.name = \"ViewDefinitionError\";\n this.problems = problems;\n }\n}\n","// scopeValues: a view's scope keys, read from ViewerScope's `scope`, as a screen's `filter`.\n\nimport type { ResourceScope } from \"../hooks/viewer-scope\";\nimport { ViewDefinitionError } from \"./errors\";\nimport type { ResourceView } from \"./types\";\n\ntype ScopeValue = string | number | boolean | null;\n\nconst camel = (key: string) => key.replace(/_([a-z0-9])/g, (_, c: string) => c.toUpperCase());\n\n/**\n * The view's declared scope keys with their values from the viewer's scope, ready to pass as a\n * screen's `filter`: `scope: [\"league_id\"]` reads `scope.league_id`, then `scope.leagueId`.\n *\n * ```tsx\n * <ResourceView view={brandsView} filter={scopeValues(brandsView, useViewerScope().scope)} />\n * ```\n *\n * In development a declared key with no single value (missing, `undefined`, or a list) throws\n * {@link ViewDefinitionError}, so a screen mounted outside its scope fails loudly. In production\n * it is left out; row-level security still decides what the viewer reads.\n */\nexport function scopeValues(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract\n view: Pick<ResourceView<any, any>, \"resource\" | \"definition\">,\n scope: ResourceScope | null | undefined,\n): Readonly<Record<string, ScopeValue>> {\n const out: Record<string, ScopeValue> = {};\n const missing: string[] = [];\n for (const key of (view.definition.scope ?? []) as readonly string[]) {\n const value = scope && Object.hasOwn(scope, key) ? scope[key] : scope?.[camel(key)];\n if (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") out[key] = value;\n else missing.push(key);\n }\n if (missing.length && process.env.NODE_ENV !== \"production\") {\n throw new ViewDefinitionError(\n view.resource,\n missing.map((key) => `scope \"${key}\" has no single value in ViewerScope's scope`),\n );\n }\n return Object.freeze(out);\n}\n\n/**\n * The view's scope keys as a list filter, the way `ResourceView` applies them itself: like\n * {@link scopeValues}, but a list (`{ orgId: [\"o1\", \"o2\"] }`, a roll-up across organizations)\n * filters to any of its values, and a key the scope doesn't set is left out instead of throwing.\n * A single value also starts new rows; a list doesn't, so a new row in a roll-up asks which one.\n */\nexport function scopeFilter(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract\n view: Pick<ResourceView<any, any>, \"definition\">,\n scope: ResourceScope | null | undefined,\n): Readonly<Record<string, ScopeValue | readonly (string | number)[]>> {\n const out: Record<string, ScopeValue | readonly (string | number)[]> = {};\n if (!scope) return out;\n for (const key of (view.definition.scope ?? []) as readonly string[]) {\n const value = Object.hasOwn(scope, key) ? scope[key] : scope[camel(key)];\n if (value === null || typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") out[key] = value;\n else if (Array.isArray(value) && value.every((v) => typeof v === \"string\" || typeof v === \"number\")) out[key] = value as readonly (string | number)[];\n }\n return Object.freeze(out);\n}\n","// A link's picker (docs/RESOURCE-VIEW.md, \"Links in forms\"): which linked rows it lists. Pure, no\n// React: web's RelationField and native's link picker both send what `filters` returns through\n// the provider, so row-level security still decides what the viewer can pick.\n\nimport type { FilterParam } from \"../provider/types\";\nimport type { FieldReference } from \"../schema/types\";\nimport type { ResourceScope } from \"../hooks/viewer-scope\";\nimport { isDevelopment, reportError } from \"../errors\";\nimport { ViewDefinitionError } from \"./errors\";\nimport { scopeFilter } from \"./scope\";\nimport type { LinkFilter, LinkedView, ResolvedLink, ViewLink } from \"./types\";\n\n// A field name only goes into a request's `sort`, so nothing else rides along in it.\nconst IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * A screen's or a picker's filter as provider filters: a single value is `eq`, `null` is\n * `is_null` and a list is `in`.\n */\nexport function filterParams(filter: LinkFilter | null | undefined): FilterParam[] {\n return Object.entries(filter ?? {}).map(([field, value]): FilterParam =>\n value === null\n ? { field, operator: \"is_null\" }\n : Array.isArray(value)\n ? { field, operator: \"in\", value: [...(value as readonly (string | number)[])] }\n : { field, operator: \"eq\", value: value as string | number | boolean },\n );\n}\n\n/** Problems with a `link` as written, for defineView to report with the rest. */\nexport function linkProblems(name: string, link: unknown, reference: FieldReference | undefined): string[] {\n if (link === undefined) return [];\n const where = `fields.${name}.link`;\n if (!reference) return [`${where} is set, but \"${name}\" isn't a link`];\n if (!link || typeof link !== \"object\" || Array.isArray(link)) return [`${where} isn't an object`];\n const l = link as ViewLink;\n const problems: string[] = [];\n if (l.view !== undefined && typeof l.view !== \"function\") problems.push(...linkedViewProblems(where, l.view, reference, l.preset));\n else if (l.view === undefined && l.preset !== undefined) problems.push(`${where}.preset needs a view`);\n if (l.preset !== undefined && typeof l.preset !== \"string\") problems.push(`${where}.preset isn't a preset name`);\n if (l.filter !== undefined && typeof l.filter !== \"function\" && (!l.filter || typeof l.filter !== \"object\" || Array.isArray(l.filter))) {\n problems.push(`${where}.filter isn't a filter or a function`);\n }\n if (\n l.searchFields !== undefined &&\n (!Array.isArray(l.searchFields) || l.searchFields.some((f) => typeof f !== \"string\" || !IDENTIFIER.test(f)))\n ) {\n problems.push(`${where}.searchFields isn't a list of field names`);\n }\n if (l.orderBy === \"view\") {\n if (l.view === undefined) problems.push(`${where}.orderBy \"view\" needs a view`);\n } else if (l.orderBy !== undefined) {\n const o = l.orderBy as { field?: unknown; direction?: unknown } | null;\n if (!o || typeof o !== \"object\" || typeof o.field !== \"string\" || !IDENTIFIER.test(o.field)) {\n problems.push(`${where}.orderBy isn't \"view\" or { field, direction }`);\n } else if (o.direction !== undefined && o.direction !== \"asc\" && o.direction !== \"desc\") {\n problems.push(`${where}.orderBy.direction is \"asc\" or \"desc\", not ${String(o.direction)}`);\n }\n }\n return problems;\n}\n\nfunction linkedViewProblems(where: string, view: unknown, reference: FieldReference, preset: string | undefined): string[] {\n const v = view as LinkedView | null;\n if (!v || typeof v !== \"object\" || typeof v.resource !== \"string\") return [`${where}.view isn't a view`];\n // A view of another resource would list rows the link can't hold.\n if (v.resource !== reference.resource) return [`${where}.view is a view of \"${v.resource}\", but the link points at \"${reference.resource}\"`];\n if (preset !== undefined && !Object.hasOwn(v.definition.presets ?? {}, preset)) {\n return [`${where}.preset \"${preset}\" isn't one of ${v.resource}'s presets`];\n }\n return [];\n}\n\n/**\n * The resolved picker for a link: `owner` is the view's resource (for errors), `labelField` the\n * view field's own. A `view` given as a function is read, and checked, on the first `filters`.\n */\nexport function resolveLink(\n owner: string,\n name: string,\n reference: FieldReference,\n link: ViewLink | undefined,\n labelField: string | undefined,\n): ResolvedLink {\n let linked: LinkedView | undefined;\n let read = false;\n const linkedView = (): LinkedView | undefined => {\n if (read) return linked;\n read = true;\n linked = typeof link?.view === \"function\" ? link.view() : link?.view;\n if (linked && typeof link?.view === \"function\") {\n const problems = linkedViewProblems(`fields.${name}.link`, linked, reference, link.preset);\n if (problems.length) {\n const error = new ViewDefinitionError(owner, problems);\n // Read while a form renders: in development the mistake fails loudly; in production the\n // form still opens, its picker listing the linked resource under row-level security only.\n if (isDevelopment()) throw error;\n reportError(error, { source: \"core:resource-view-link\", tags: { resource: owner } });\n linked = undefined;\n }\n }\n return linked;\n };\n // No `link.view`: Genesis keeps no registry of views or tenant columns by resource, so nothing\n // here can add the linked resource's scope. The data provider's row-level security narrows the\n // list, and the server must refuse a cross-tenant link (docs/RESOURCE-VIEW.md, \"Links in forms\").\n return Object.freeze({\n resource: reference.resource,\n field: reference.field,\n // Read when asked: a view given as a function may not exist yet while this one is defined.\n get labelField() {\n return labelField ?? linkedView()?.labelField;\n },\n ...(link?.searchFields ? { searchFields: Object.freeze([...link.searchFields]) } : {}),\n // Read when asked, like the naming field: `\"view\"` reads a view given as a function.\n get orderBy() {\n const order = link?.orderBy === \"view\" ? linkedView()?.definition.orderBy : link?.orderBy;\n if (!order || typeof order.field !== \"string\" || !IDENTIFIER.test(order.field)) return undefined;\n const nulls = (order as { nulls?: unknown }).nulls;\n return Object.freeze({\n field: order.field,\n direction: order.direction === \"desc\" ? (\"desc\" as const) : (\"asc\" as const),\n ...(nulls === \"first\" || nulls === \"last\" ? { nulls } : {}),\n });\n },\n filters(scope?: ResourceScope | null, values: Readonly<Record<string, unknown>> = {}): FilterParam[] {\n const view = linkedView();\n const preset = view ? view.definition.presets?.[link?.preset ?? \"default\"]?.filter : undefined;\n const own = typeof link?.filter === \"function\" ? link.filter(values) : link?.filter;\n // The linked view's own list rules first, then the link's: a later field wins.\n return filterParams({ ...(view ? scopeFilter(view, scope) : {}), ...(preset as LinkFilter | undefined), ...own });\n },\n });\n}\n","// What a resource means to people (docs/RESOURCE-VIEW.md, \"View\"). Types only: no React, no\n// DOM, so web, native and the extension all import the same view.\n\nimport type { GalleryItem } from \"../gallery\";\nimport type { ChipTone } from \"../resource/status\";\nimport type { DataRow, FieldSchema, ResourceContract, RowAction, RowOf } from \"../schema/types\";\nimport type { Viewer } from \"../viewer\";\nimport type { FilterParam } from \"../provider/types\";\nimport type { ResourceScope } from \"../hooks/viewer-scope\";\n\nexport type { RowOf, Viewer };\n\n/** A chip's colour: the one Genesis tone set (`ChipTone`, genesis-core/resource). */\nexport type ViewTone = ChipTone;\n\n/**\n * How a value is shown. A hint: each platform registers one renderer per hint, so the shared view\n * never imports a platform. Derived from the field when the view doesn't say.\n */\nexport type DisplayHint =\n | \"text\"\n | \"longText\"\n | \"number\"\n | \"currency\"\n | \"percent\"\n | \"boolean\"\n | \"badge\"\n | \"date\"\n | \"datetime\"\n | \"relation\"\n | \"url\"\n | \"email\"\n | \"image\"\n | \"json\";\n\n/** The field names a contract declares; `string` when the contract isn't a literal. */\nexport type FieldNameOf<C extends ResourceContract> = C[\"fields\"][number][\"name\"];\n\n/** What a view says about one field. Every key is optional; the contract fills the rest. */\nexport interface ViewField<Row extends DataRow = DataRow> {\n /** The field's label. Default: the contract's label, then the name in title case. */\n label?: string;\n display?: DisplayHint;\n /** A badge's tone per value, e.g. `{ active: \"success\", archived: \"muted\" }`. */\n tones?: Readonly<Record<string, ViewTone>>;\n /**\n * The words for a value, e.g. `{ draft: \"In progress\" }`: badges, form choices, group titles.\n * A value without one shows in title case. Keys must be the field's enum values, if it has any.\n */\n labels?: Readonly<Record<string, string>>;\n /**\n * For a link (`relation`): the linked row's field that names it, e.g. `\"full_name\"`. Default:\n * the linked resource's `labelField` (`provider.describe`), else a `name`/`title`-like field.\n */\n labelField?: string;\n /**\n * For a link: the words when the linked row is hidden from this viewer or gone, e.g.\n * `\"Someone you can't see\"`. Default: the catalogue's `common.hiddenLink`. Never the raw id.\n */\n missingLabel?: string;\n /**\n * For a link: edit it in the view's forms with a picker, and how the picker lists the rows it\n * can point at. Setting it (`{}` is enough) opts the link in; without it (or the view's\n * `editLinks`) a link stays read-only. `view` narrows it to the linked view's rules (its scope\n * and default filter); `filter` adds more.\n */\n link?: ViewLink;\n /** Longest text a form accepts. Feeds the derived validation. */\n max?: number;\n /**\n * In a form: the browser's autofill token (`email`, `tel`, `given-name`, `one-time-code`,\n * `off`, ...). Unset, the input carries no `autocomplete` attribute and gets no token from its\n * type, so the browser applies its own heuristics (it may still offer to fill it). Set a token\n * where the form is about the viewer, and `off` on a form about someone else (an admin editing\n * a member) to ask the browser not to fill in the person at the keyboard.\n */\n autoComplete?: string;\n /** In a form: which on-screen keyboard a phone shows. Unset, it follows the field's type. */\n inputMode?: \"none\" | \"text\" | \"decimal\" | \"numeric\" | \"tel\" | \"search\" | \"email\" | \"url\";\n /** In a form: the label on the keyboard's Return key (`next`, `done`, `go`, `search`, `send`). */\n enterKeyHint?: \"enter\" | \"done\" | \"go\" | \"next\" | \"previous\" | \"search\" | \"send\";\n /** Shown read-only even where the server would accept a write. Never widens. */\n readOnly?: boolean;\n /**\n * Show the cell only when the row (and the viewer) say so: for values a server function masks\n * by policy (`(row) => row.author_visible`). The masking itself is the server's. It hides\n * table cells and the peek only: not workspace settings, an edit form's prefilled values, a\n * view's `summary` or header, or sorting and searching on the column.\n */\n when?: (row: Row, viewer: Viewer) => boolean;\n /** In a form: show the field only while this holds for the form's values. A hidden field isn't saved. */\n visible?: (values: Readonly<Record<string, unknown>>) => boolean;\n /**\n * A timestamp's clock: the viewer's (default), the scope's (the zone of whatever the screen is\n * scoped to: ViewerScope's `scopeTimeZone`, or NativeResourceView's prop), or a fixed IANA zone.\n * Closed: any other word (the removed `\"practice\"`) is a type error, and `defineView` refuses a\n * zone the runtime doesn't know.\n */\n timeZone?: ViewTimeZone;\n /**\n * How much the field matters in a row (ADR 0017): `title` (the row's name, strongest; one per\n * view, default the `labelField`), `secondary` or `muted`. Meaning, not markup: each platform\n * and brand decides how it looks.\n */\n emphasis?: ViewEmphasis;\n /** `false` keeps the column's header from sorting the list (a value the server can't order by). */\n sortable?: boolean;\n /** Hide the column below this screen width on the web: `sm`, `md`, `lg` or `xl`. */\n hideBelow?: ViewBreakpoint;\n /** The column's starting width: a number of pixels, or a CSS length (`\"12rem\"`). */\n width?: number | string;\n}\n\n/** How much a field matters in a row (`ViewField.emphasis`). @stability Beta */\nexport type ViewEmphasis = \"title\" | \"secondary\" | \"muted\";\n\n/** A screen width a column hides below (`ViewField.hideBelow`). @stability Beta */\nexport type ViewBreakpoint = \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n/**\n * A field a person can narrow the list by (ADR 0017, `defineView`'s `filters`). The platform\n * draws it from what the contract and the view know: a field with choices (an enum, a yes/no)\n * gets multi-select chips in its words and tones, a date or number a range, a text field\n * \"contains\". Every value is sent to the server, never applied to loaded rows.\n *\n * @stability Beta\n */\nexport interface ViewFilter<Name extends string = string> {\n field: Name;\n /** The filter's label. Default the field's. */\n label?: string;\n /** Default from the field: `choice` for an enum or yes/no, `range` for a date or number, else `text`. */\n kind?: ViewFilterKind;\n /** For `choice`: narrow the values offered (and, for a field without fixed values, name them). */\n options?: readonly string[];\n /** The value the filter starts at: values for a choice, `{ gte, lte }` for a range, words for text. */\n default?: ViewFilterValue;\n}\n\n/** How a declared filter narrows the list. @stability Beta */\nexport type ViewFilterKind = \"choice\" | \"range\" | \"text\";\n\n/**\n * A declared filter's value: the chosen values (`choice`), a range (`{ gte, lte }`, either end\n * open) or words (`text`, matched as \"contains\").\n *\n * @stability Beta\n */\nexport type ViewFilterValue = readonly string[] | { readonly gte?: string; readonly lte?: string } | string;\n\n/**\n * Which rows a segment holds: equality per field, `null` for \"is empty\", a list for \"any of\", and\n * `{ gte, lte }` for a range. Sent to the server with the list request.\n *\n * @stability Beta\n */\nexport type SegmentWhere<Name extends string = string> = Readonly<\n Partial<Record<Name, string | number | boolean | null | readonly (string | number)[] | { readonly gte?: string | number; readonly lte?: string | number }>>\n>;\n\n/**\n * A named tab over a list (\"Open\", \"Mine\", \"All\") with its own filter and an optional count\n * (ADR 0017). Not a preset (a screen's fixed columns and filter) and not a saved view (a person's\n * own).\n *\n * @stability Beta\n */\nexport interface ViewSegment<Name extends string = string> {\n /** Lowercase letters, digits, `-` and `_`: it goes in the URL (`?seg=open`). */\n id: string;\n label: string;\n /** Its rows, or a function of the viewer for one relative to them (`(v) => ({ owner_id: v.id })`). No `where`: every row. */\n where?: SegmentWhere<Name> | ((viewer: Viewer) => SegmentWhere<Name>);\n /**\n * Arguments for a function-backed source (`source.args`'s `take`), sent as equality filters the\n * function takes and the query leaves out: `{ inbox_view: \"mine\" }`. Not fields, so not checked\n * against the contract.\n */\n args?: Readonly<Record<string, string | number | boolean | null>>;\n /** Show a count beside the label: one count request through the provider. */\n count?: boolean;\n /** A column preset the segment shows (`columns`). Default the screen's. */\n columns?: string;\n}\n\n/** A group or footer total (`defineView`'s `totals`). @stability Beta */\nexport type ViewTotal = \"sum\" | \"avg\" | \"min\" | \"max\" | \"count\";\n\n/**\n * A view's CSV export (ADR 0017 §8). The default columns are the column preset's, minus sensitive\n * fields and computed columns; values are written in words (a badge's label) unless `raw`.\n *\n * @stability Beta\n */\nexport interface ViewExport<Name extends string = string> {\n /** The fields exported, in order. Default the shown preset's field columns. */\n columns?: readonly Name[];\n /** The file's name, without `.csv`. Default the view's plural noun. */\n filename?: string;\n /** Stop after this many rows (the file says it was cut short). Default 10 000. */\n maxRows?: number;\n /** Write stored values (codes) instead of their words. Default false. */\n raw?: boolean;\n}\n\n/**\n * What a bulk action runs on: the selected rows, or (only for a `run` that says `matching`) every\n * row the list's filters, segment and search match, sent as those filters and never as ids.\n *\n * @stability Beta\n */\nexport type BulkTarget<Row extends DataRow = DataRow> =\n | { readonly kind: \"rows\"; readonly rows: readonly Row[] }\n | { readonly kind: \"matching\"; readonly filters: readonly FilterParam[]; readonly search?: { readonly query: string; readonly fields: readonly string[] }; readonly total: number };\n\n/**\n * A view action that also runs on many rows at once (ADR 0017 §3, `ViewAction.bulk`). Without\n * `run`, it runs the row action once per selected row through the provider, checking `can` per\n * row and reporting the rows it skipped and why.\n *\n * @stability Beta\n */\nexport interface ViewBulkAction<Row extends DataRow = DataRow> {\n /** The bulk bar's words. Default the action's label. */\n label?: string;\n /** A confirmation, with `{count}`: \"Archive {count} tasks?\". Default the action's own `confirm`. */\n confirm?: string;\n /** Runs it on many rows at once (one server call). Default: the row action per row. */\n run?: (target: BulkTarget<Row>, viewer: Viewer) => void | Promise<void>;\n /**\n * `run` accepts every matching row as filters (`target.kind === \"matching\"`), so \"select all\n * matching\" can reach it. Such a run gets no rows, so no per-row `can` check has happened: it\n * must enforce access itself (a server function under the caller's row-level security, checking\n * each row it touches), and treat the filters and search as untrusted input from the browser.\n */\n matching?: boolean;\n}\n\n/**\n * A picker's filter: equality per field. `null` is \"is empty\", a list is \"any of\". Sent to the\n * server with the list request, never applied to loaded rows.\n */\nexport type LinkFilter = Readonly<Record<string, string | number | boolean | null | readonly (string | number)[]>>;\n\n/** The parts of the linked resource's view a picker reads. */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract and row\nexport type LinkedView = Pick<ResourceView<any, any>, \"resource\" | \"definition\" | \"labelField\">;\n\n/**\n * How a link's picker lists the linked rows (`fields.owner_id.link`). The list always goes through\n * the provider, so row-level security decides what the viewer can pick; these only narrow it.\n */\nexport interface ViewLink {\n /**\n * The linked resource's view. Its `scope` keys (read from the viewer's scope, as its own lists\n * do), its `default` preset's filter (or `preset`'s) and its `labelField` apply to the picker.\n * A function for two views that link each other (`() => usersView`).\n */\n view?: LinkedView | (() => LinkedView);\n /** One of the linked view's presets whose filter the picker uses. Default: its `default` preset. */\n preset?: string;\n /**\n * More filters: fixed, or from the form's values, for a picker that follows another field\n * (`(values) => ({ project_id: values.project_id })`, the tasks of the chosen project).\n */\n filter?: LinkFilter | ((values: Readonly<Record<string, unknown>>) => LinkFilter);\n /** The linked fields a search matches. Default: the naming field (`labelField`). */\n searchFields?: readonly string[];\n /**\n * The order the picker lists rows in. Default: by the naming field, then the key. `\"view\"`\n * uses the linked view's own `orderBy` (a `position` its list is sorted by) and needs `view`;\n * a linked view without one keeps the default. `{ field, direction }` names a linked field.\n */\n orderBy?: \"view\" | LinkOrder;\n}\n\n/** A picker's order: a field of the linked resource, ascending unless it says so. */\nexport interface LinkOrder {\n field: string;\n direction?: \"asc\" | \"desc\";\n /** Where rows with no value go. Unset, the store decides. */\n nulls?: \"first\" | \"last\";\n}\n\n/** A link's picker, resolved: what to list, what names a row, and the filters to send. */\nexport interface ResolvedLink {\n /** The linked resource. */\n resource: string;\n /** The linked field the link stores (its key, usually `id`). */\n field: string;\n /** The linked field that names a row: the view field's, else the linked view's. Undefined: the provider's `describe`. */\n readonly labelField: string | undefined;\n /** The linked fields a search matches. Unset: the naming field. */\n searchFields?: readonly string[];\n /**\n * The order the picker lists rows in (`link.orderBy`, or the linked view's `orderBy` for\n * `\"view\"`), then the key. Undefined: by the naming field, then the key.\n */\n readonly orderBy?: { readonly field: string; readonly direction: \"asc\" | \"desc\"; readonly nulls?: \"first\" | \"last\" | undefined } | undefined;\n /**\n * The filters a picker sends: the linked view's scope keys from `scope` (as its own lists apply\n * them), its preset's filter, then the link's own `filter` for these form values.\n */\n filters(scope?: ResourceScope | null, values?: Readonly<Record<string, unknown>>): FilterParam[];\n}\n\n/**\n * An IANA zone name as written: `\"UTC\"`, `\"GMT\"` or `Area/Location` (`\"Europe/Berlin\"`). The\n * type keeps a bare word out; `defineView` checks the runtime knows the zone.\n */\nexport type TimeZoneName = \"UTC\" | \"GMT\" | `${string}/${string}`;\n\n/** A view field's clock: the viewer's, the scope's, or a fixed zone. */\nexport type ViewTimeZone = \"viewer\" | \"scope\" | TimeZoneName;\n\n/** A column computed from the row, never stored or sent. */\nexport interface ComputedColumn<Row extends DataRow = DataRow> {\n /** The column's key; must not clash with a field name. */\n key: string;\n label: string;\n value: (row: Row) => unknown;\n display?: DisplayHint;\n}\n\n/** One entry in a column list: a field by name, or a computed column. */\nexport type ViewColumn<Name extends string, Row extends DataRow> = Name | ComputedColumn<Row>;\n\n/** A form laid out in order: fields, and fields under a heading. */\nexport type ViewFormItem<Name extends string> = Name | { section: string; title?: string; fields: readonly Name[] };\n\n/**\n * A named tab of the list: which columns, and which rows (`{ status: \"open\" }` is an equality\n * filter, sent to the server, never applied to loaded rows).\n */\nexport interface ViewPreset<Name extends string> {\n label?: string;\n columns?: string;\n filter?: Readonly<Partial<Record<Name, string | number | boolean | null>>>;\n}\n\n/** `true` when allowed, or the reason it isn't, in one sentence for the disabled control. */\nexport type Allowed = true | string;\n\n/**\n * Row rules the server can't cheaply express (\"the default brand can't be deleted\"). They only\n * narrow: the effective right is the server's AND these. An invariant goes in the database too.\n *\n * Each gets the viewer (`useViewer()`: id, scope, roles). Outside a ViewerScope it is\n * `{ id: null, scope: {} }`, so a guard that needs it refuses with its reason. Pure and\n * synchronous; never a security check (row-level security is the boundary).\n */\nexport interface ViewGuards<Row extends DataRow> {\n create?: (viewer: Viewer) => Allowed;\n update?: (row: Row, viewer: Viewer) => Allowed;\n delete?: (row: Row, viewer: Viewer) => Allowed;\n}\n\n/**\n * A named operation on one row, shaped like core's {@link RowAction} (which a provider reports),\n * plus a guard. The guard only narrows: the server still decides whether the action runs.\n *\n * ```ts\n * actions: [{ name: \"archive\", label: \"Archive\", confirm: \"Archive this brand?\", can: (r) => (r.is_default ? \"The default brand stays.\" : true) }]\n * ```\n */\nexport interface ViewAction<Row extends DataRow = DataRow> extends RowAction {\n /** Drawn as destructive (red, the menu's destructive style). */\n destructive?: boolean;\n can?: (row: Row, viewer: Viewer) => Allowed;\n /** Also offer it on many selected rows (ADR 0017): `true`, or how it runs on them. */\n bulk?: boolean | ViewBulkAction<Row>;\n}\n\n/** An action as a renderer lists it: the words only. Ask `view.canAction` whether a row allows it. */\nexport type ResolvedViewAction = RowAction & {\n readonly destructive?: boolean;\n /** Set when the action runs on many rows: its bar label, confirmation and whether it takes every matching row. */\n readonly bulk?: { readonly label: string; readonly confirm?: string; readonly matching: boolean; readonly batch: boolean };\n};\n\n/** A row in one line, for pickers, notifications and page bars. */\nexport interface RowSummary {\n title: string;\n subtitle?: string;\n chips?: readonly { label: string; tone?: ViewTone }[];\n /**\n * A picture beside the row: `src` is shown only when `isSafeUrl` accepts it; otherwise the\n * initials of `name`. `alt` defaults to empty (decorative). Resolve it with `rowPicture`.\n */\n image?: RowImage;\n}\n\n/** A row's picture, as a view's `summary` gives it. */\nexport interface RowImage {\n src?: string;\n /** Whose picture: the initials come from it when there is no safe `src`. */\n name?: string;\n /** Alternative text. Default empty: the picture is decorative (the row's title names it). */\n alt?: string;\n}\n\n/** A row's picture, ready to draw: an image (with initials for when it fails to load), or initials. */\nexport type RowPicture =\n | { readonly kind: \"image\"; readonly src: string; readonly alt: string; readonly fallback: string }\n | { readonly kind: \"initials\"; readonly text: string };\n\n/**\n * The words a view shows. Each one is a step in a chain, and each step overrides the one before:\n * words derived from the resource's name, then the contract's (`noun`, `nounPlural`, `label`, which\n * `genesis introspect` reads from the table comment's `@genesis {...}`), then these, then the\n * screen's own props. Templates take `{noun}`, `{nouns}`, `{count}` and `{total}`.\n */\nexport interface ViewCopy {\n /** One row, in a sentence: \"brand\". Default: the contract's `noun`, then the table name's singular. */\n noun?: string;\n /**\n * Several: \"brands\". Default: the contract's `nounPlural`, then the plural of a `noun` the view or\n * contract gives (\"entry\" → \"entries\"); with only a noun derived from the name, the contract's\n * label when it reads as a plural (\"People\"), else the table name.\n */\n nounPlural?: string;\n /** The page title. Default: the contract's label, then the plural noun in title case. */\n title?: string;\n subtitle?: string;\n empty?: { title?: string; body?: string };\n /** The create button. Default \"New\". */\n create?: string;\n /**\n * The form's words. Titles: default \"New {noun}\" and \"Edit {noun}\" (the UI catalogue's `form`).\n * Submit buttons: default \"Create\" and \"Save\". Descriptions (read out with the title): default\n * the UI catalogue's `form.createDescription` and `form.editDescription`.\n */\n form?: {\n createTitle?: string;\n editTitle?: string;\n createSubmit?: string;\n editSubmit?: string;\n createDescription?: string;\n editDescription?: string;\n };\n /**\n * The count beside the title. Default \"{count} {noun}\" for one, \"{count} {nouns}\" for more, and\n * \"{count} of {total}\" when filtered (the UI catalogue's `page.count*`).\n */\n count?: { one?: string; other?: string; filtered?: string };\n}\n\n/** How a calendar lays out its window: a month grid, 1–4 weeks, a day-by-day agenda, or a row per lane. */\nexport type ViewCalendarLayout = \"month\" | \"weeks\" | \"agenda\" | \"lanes\";\n\n/** What a calendar's `durationField` counts. */\nexport type ViewCalendarDurationUnit = \"minutes\" | \"hours\" | \"days\";\n\n/**\n * How the view's rows show as a calendar: ResourceView's `mode=\"calendar\"` on the web,\n * NativeResourceView's later. Plain values only, so every platform reads the same block; a screen\n * overrides the layout, weeks and anchor, and adds functions (dot colours, `onSelect`).\n */\nexport interface ViewCalendar<Name extends string = string> {\n /** The date or timestamp field that places each row. */\n field: Name;\n /** Where a row ends: its last day for a date field, its end instant for a timestamp. */\n endField?: Name;\n /**\n * A number field holding how long a row runs, for a row with no end column: its end is the\n * start plus this many `durationUnit`s. A row whose `endField` has a value keeps that end.\n */\n durationField?: Name;\n /** What `durationField` counts. Default `minutes`. */\n durationUnit?: ViewCalendarDurationUnit;\n /**\n * The longest a row with a `durationField` runs, in `durationUnit`s. The calendar reads rows that\n * started up to this long before its window too, so one that runs into the window from before\n * it (a session at 23:00 for two hours) is drawn. Without it, such a row is drawn only on the\n * days it starts in the window, and a calendar with no `endField` warns once. Past the read's\n * limit, the latest starts are kept.\n */\n maxDuration?: number;\n /** A yes/no field: the row is all day, its timestamp shown without a time. */\n allDayField?: Name;\n /** The field whose value (or list of values) names a row's lanes: a dot each, a lane each. */\n laneBy?: Name;\n /** Default `month`. */\n layout?: ViewCalendarLayout;\n /**\n * The layout on a phone (below 768px), until the person picks one from the layout switch:\n * `\"agenda\"` turns a month grid too narrow to read into a day-by-day list. Unset, a phone shows\n * `layout`, as before.\n */\n phoneLayout?: ViewCalendarLayout;\n /** For `weeks`, `agenda` and `lanes`: 1 to 4. Default 2. */\n weeks?: 1 | 2 | 3 | 4;\n /** 0 Sunday or 1 Monday (default). */\n weekStartsOn?: 0 | 1;\n}\n\n/**\n * How the view's rows show as a board: a column per value of one field, a card per row.\n * ResourceView's `mode=\"board\"` draws it, and moving a card between columns writes the field\n * through the provider. Plain values only, so every platform reads the same block.\n */\nexport interface ViewBoard<Name extends string = string> {\n /** The field whose value is a card's column: a field with choices (an enum) or a yes/no one. */\n field: Name;\n /**\n * The columns, in order, as values of `field`. Default: its choices in the contract's order,\n * then a \"No value\" column when it can be empty. Listing them shows only those.\n */\n columns?: readonly string[];\n /** The fields a card shows under its title, in order. Default none: the title alone. */\n cardFields?: readonly Name[];\n /**\n * The most cards a column should hold, by value (`{ doing: 3 }`): a work-in-progress limit.\n * A column over its limit says so; nothing stops a move into it.\n */\n limits?: Readonly<Record<string, number>>;\n}\n\n/**\n * How the view's rows show as a gallery: ResourceView's `mode=\"grid\"` draws a photo per row in\n * justified rows (the layout `GalleryGrid` uses, from `@marktiderman/genesis-core/gallery`) in\n * place of cards. Plain field names only, so every platform reads the same block.\n */\nexport interface ViewGallery<Name extends string = string> {\n /** The field holding the image's URL. */\n image: Name;\n /** The image's width and height in pixels, when the rows store them: rows pack by their ratio, 4:3 without. */\n width?: Name;\n height?: Name;\n /** A short line under the photo in the viewer. Default none. */\n caption?: Name;\n /** The photo's text alternative. Default the row's label (the view's `labelField`). */\n alt?: Name;\n /** The target row height, px on the web and points on a phone. Default 180, as `GalleryGrid`. */\n rowHeight?: number;\n}\n\n/**\n * How the view's rows show as an inbox (ADR 0017, the `inbox` view type): a three-pane layout of\n * segments, a list of rows like messages, and the open record. Field names only, except `unread`,\n * which may be a function of the row; every platform reads the same block.\n *\n * @stability Beta\n */\nexport interface ViewInbox<Name extends string = string, Row extends DataRow = DataRow> {\n /** The row's title line: a field, or a function of the row (a direct message's other person). Default the view's `labelField`. */\n title?: Name | ((row: Row) => string | null | undefined);\n /** One line under the title (the latest message, a description): a field, or a function of the row. */\n preview?: Name | ((row: Row) => string | null | undefined);\n /** A date or timestamp field: the row's short relative time. */\n time?: Name;\n /** Who it's from, in words: a line under the preview, and the avatar's initials. A field, or a function of the row. */\n from?: Name | ((row: Row) => string | null | undefined);\n /** An image field: the avatar beside the row. */\n avatar?: Name;\n /** A yes/no field, or a function of the row: bold, with a dot, while it's unread. */\n unread?: Name | ((row: Row) => boolean);\n /** A field drawn as a badge at the row's end, in its `fields.<name>.tones`. */\n badge?: Name;\n /** What fills the left rail: the view's segments (and saved views). Default `\"segments\"` when the view has segments. */\n rail?: \"segments\" | \"none\";\n /** The view action the `e` key runs on the open row (\"done\", \"close\"). Default an action named `done` or `close`. */\n doneAction?: string;\n /**\n * The view action run when an unread row is opened, to mark it read. Default an action named\n * `markRead`, if the view declares one. Genesis never writes on its own.\n */\n markRead?: string;\n}\n\n/** One row as an inbox draws it (`ResourceView.inboxRow`). @stability Beta */\nexport interface InboxRow {\n readonly id: string;\n readonly title: string;\n readonly preview?: string;\n /** The time field's value, as stored (an ISO date or timestamp). */\n readonly time?: string;\n readonly from?: string;\n readonly avatar?: string;\n readonly unread: boolean;\n readonly badge?: { readonly label: string; readonly tone?: ViewTone };\n}\n\n/**\n * How a record opens from a view (a record page, ADR 0021): a **side peek** (a panel at the edge,\n * the list still beside it), a **center peek** (a dialog over the list) or a full **page** (the\n * record's own route).\n *\n * @stability Beta\n */\nexport type RecordOpen = \"side-peek\" | \"center-peek\" | \"page\";\n\n/** The open modes, in the order a picker lists them. @stability Beta */\nexport const RECORD_OPEN_MODES: readonly RecordOpen[] = Object.freeze([\"side-peek\", \"center-peek\", \"page\"]);\n\n/** What `defineView` accepts. */\nexport interface ViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {\n copy?: ViewCopy;\n fields?: { readonly [K in FieldNameOf<C>]?: ViewField<Row> };\n /**\n * Column lists by preset name. `default` is the full list; others (`compact`) are what a screen\n * picks. Without `default`: every field that isn't sensitive, generated-only or the key.\n */\n columns?: { readonly default?: readonly ViewColumn<FieldNameOf<C>, Row>[] } & {\n readonly [preset: string]: readonly ViewColumn<FieldNameOf<C>, Row>[] | undefined;\n };\n /** Tabs: columns plus filters. */\n presets?: Readonly<Record<string, ViewPreset<FieldNameOf<C>>>>;\n /** The record form. Default: every writable field, in contract order. */\n form?: readonly ViewFormItem<FieldNameOf<C>>[];\n /**\n * Edit every link in this view's forms with a picker. Default false: a link is read-only (and\n * never sent) unless its `fields.<link>.link` is set (`{}` is enough). The default flips in 3.0.\n */\n editLinks?: boolean;\n can?: ViewGuards<Row>;\n /** Named operations on one row, in the order a menu shows them. Names are unique. */\n actions?: readonly ViewAction<Row>[];\n summary?: (row: Row) => RowSummary;\n /** The scope keys this view needs above it (`[\"org_id\"]`). They stay out of forms. */\n scope?: readonly FieldNameOf<C>[];\n /** How the rows show as a calendar (`mode=\"calendar\"`). */\n calendar?: ViewCalendar<FieldNameOf<C>>;\n /** How the rows show as a board (`mode=\"board\"`). */\n board?: ViewBoard<FieldNameOf<C>>;\n /** How the rows show as a gallery of photos (`mode=\"grid\"`), in place of cards. */\n gallery?: ViewGallery<FieldNameOf<C>>;\n /** How the rows show as an inbox (`type=\"inbox\"`): a list like messages beside the open record. */\n inbox?: ViewInbox<FieldNameOf<C>, Row>;\n /** Group rows under headers by this field. */\n groupBy?: FieldNameOf<C>;\n /**\n * How a record opens from every view type of this view (ADR 0021): `side-peek` (default),\n * `center-peek` or `page`. A screen's own `open` (or ResourcePage's older `detail`) wins.\n */\n open?: RecordOpen;\n /**\n * The record view a peek renders: a function, because the record view is defined from this\n * view, with its return type named so TypeScript needn't infer one from the other:\n * `recordView: (): AnyRecordView => brandRecordView`. Without one, a peek shows the view's\n * columns as today.\n */\n recordView?: () => import(\"./record-view\").AnyRecordView;\n /**\n * Default order; `manual: true` turns on drag to reorder, writing this field. `nulls` says where\n * rows with no value go (unset, the store decides: Postgres puts them first on a descending sort).\n */\n orderBy?: { field: FieldNameOf<C>; direction?: \"asc\" | \"desc\"; nulls?: \"first\" | \"last\"; manual?: boolean };\n /** Bumped when stored preferences (saved views, column order) change shape. */\n version?: number;\n /**\n * The fields a person can narrow the list by (ADR 0017 §1): drawn as a filter bar on the web,\n * sent to the server, and kept in the URL (`f.<field>`) once the app gives the list a URL adapter.\n */\n filters?: readonly ViewFilter<FieldNameOf<C>>[];\n /** Named tabs over the list, each with its own filter and an optional count (ADR 0017 §1). */\n segments?: readonly ViewSegment<FieldNameOf<C>>[];\n /**\n * The view types a person may switch between (ADR 0017): `table`, `list`, `grid`, `board`,\n * `calendar`, `gallery` or a registered type's id. Default: table, list and grid, plus each\n * type the view has a block for (gallery, board, calendar). A switcher shows when there are two\n * or more; each person's choice is kept in the app's saved-view store.\n */\n types?: readonly string[];\n /** Per field, a total shown in each group's header and the list's footer (`sum`, `avg`, `min`, `max`, `count`). */\n totals?: Readonly<Partial<Record<FieldNameOf<C>, ViewTotal>>>;\n /**\n * A row's tone (an overdue task, a paused client), drawn from tokens: a leading bar and a\n * tinted row on the web. Return nothing for a plain row.\n */\n rowTone?: (row: Row) => ViewTone | null | undefined;\n /** Offer \"Export CSV\" on the list (`true`, or which columns, the file's name and the cap). */\n export?: boolean | ViewExport<FieldNameOf<C>>;\n /**\n * A refused row or bulk action: `disable` (default) shows it with the guard's reason, `hide`\n * leaves it out (for an action only some people ever have).\n */\n refusals?: \"disable\" | \"hide\";\n}\n\n/** A declared filter as a renderer draws it: everything resolved. @stability Beta */\nexport interface ResolvedFilter {\n readonly field: string;\n readonly label: string;\n readonly kind: ViewFilterKind;\n /** For `choice`: each value with its words and tone, in the contract's order. */\n readonly options: readonly { readonly value: string; readonly label: string; readonly tone?: ViewTone }[];\n /** For `range`: whether the values are dates (`date`), timestamps (`datetime`) or numbers. */\n readonly input?: \"date\" | \"datetime\" | \"number\";\n /**\n * For a `date` input over a timestamp column (one shown as a date): a day is the viewer's day, so\n * a range runs from that day's start in their zone to the next day's start.\n */\n readonly instants?: boolean;\n readonly default?: ViewFilterValue;\n}\n\n/** A segment as a renderer draws it. @stability Beta */\nexport interface ResolvedSegment {\n readonly id: string;\n readonly label: string;\n readonly count: boolean;\n readonly columns?: string;\n}\n\n/** A column as a renderer draws it: everything resolved. */\nexport interface ResolvedColumn<Row extends DataRow = DataRow> {\n key: string;\n label: string;\n display: DisplayHint;\n /** The field behind it; absent for a computed column. */\n field?: FieldSchema;\n value: (row: Row) => unknown;\n tones?: Readonly<Record<string, ViewTone>>;\n /** The words for a value (`ViewField.labels`); `valueText` reads them. */\n labels?: Readonly<Record<string, string>>;\n /** For a link: the linked row's field that names it (`ViewField.labelField`). */\n labelField?: string;\n /** For a link: the words when its row is hidden or gone (`ViewField.missingLabel`). */\n missingLabel?: string;\n /** Whether to show the cell. Without a viewer it answers for no one (fail closed). */\n when?: (row: Row, viewer?: Viewer) => boolean;\n timeZone?: ViewField[\"timeZone\"];\n /** `ViewField.emphasis`; the label field's column is `title` unless the view says otherwise. */\n emphasis?: ViewEmphasis;\n /** `false` when the header mustn't sort (`ViewField.sortable`, or a computed column). */\n sortable?: boolean;\n hideBelow?: ViewBreakpoint;\n width?: number | string;\n}\n\n/** A form field as a renderer draws it. */\nexport interface ResolvedFormField {\n field: FieldSchema;\n label: string;\n display: DisplayHint;\n required: boolean;\n readOnly: boolean;\n max?: number;\n /** The input's autofill token (`ViewField.autoComplete`). */\n autoComplete?: string;\n /** The keyboard a phone shows (`ViewField.inputMode`). */\n inputMode?: ViewField[\"inputMode\"];\n /** The Return key's label (`ViewField.enterKeyHint`). */\n enterKeyHint?: ViewField[\"enterKeyHint\"];\n /** For a link: the linked row's field that names it (`ViewField.labelField`). */\n labelField?: string;\n /** For a link: the words when its row is hidden or gone (`ViewField.missingLabel`). */\n missingLabel?: string;\n /** An enum field's choices, in the contract's order, with the view's words. */\n options?: readonly { value: string; label: string }[];\n /** For a link the view opted in (`fields.<link>.link`, `editLinks`): how its picker lists the linked rows. */\n link?: ResolvedLink;\n /** The heading it sits under, or null for none. */\n section: string | null;\n sectionTitle: string | null;\n visible?: (values: Readonly<Record<string, unknown>>) => boolean;\n}\n\n/** What `defineView` returns: frozen, with everything the renderers need resolved. */\nexport interface ResourceView<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> {\n readonly contract: C;\n readonly definition: Readonly<ViewDefinition<C, Row>>;\n /** The resource name the provider addresses. */\n readonly resource: string;\n readonly noun: string;\n readonly nounPlural: string;\n readonly title: string;\n /** The field that names a row, for links, pickers and the peek's title. */\n readonly labelField: string | undefined;\n /** The column presets this view has, `default` first. */\n readonly presets: readonly string[];\n field(name: string): FieldSchema | undefined;\n label(name: string): string;\n display(name: string): DisplayHint;\n /** A value in words: the field's `labels`, else title case. For badges, choices and group titles. */\n valueLabel(name: string, value: unknown): string;\n columns(preset?: string): readonly ResolvedColumn<Row>[];\n /**\n * One field as a column, resolved as a preset lists it (a board card's fields, say). Undefined\n * for a name that isn't a field or one the viewer can't read (`permissions.read: false`).\n */\n column(name: string): ResolvedColumn<Row> | undefined;\n form(mode: \"create\" | \"edit\"): readonly ResolvedFormField[];\n /** Fields a writer may send: the form's, never generated, read-only, key or scope fields. */\n writable(mode: \"create\" | \"edit\"): readonly string[];\n /**\n * Whether the view's guard allows it for this viewer: `true`, or the guard's reason. Without a\n * viewer, guards get `NO_VIEWER` (no one), so one that needs the viewer refuses.\n */\n can(action: \"create\", viewer?: Viewer): Allowed;\n can(action: \"update\" | \"delete\", row: Row, viewer?: Viewer): Allowed;\n /** The view's actions, in order, frozen. */\n actions(): readonly ResolvedViewAction[];\n /**\n * Whether this row allows the named action: `true`, or the guard's reason. Only narrows what the\n * server allows. Throws {@link ViewDefinitionError} for a name the view doesn't define.\n */\n canAction(name: string, row: Row, viewer?: Viewer): Allowed;\n summary(row: Row): RowSummary;\n /**\n * The row as a gallery photo, by the view's `gallery` block and any `override` a screen passes\n * (ResourceView's `gallery`): undefined without a gallery block. Its `id` is the row's key, its\n * `alt` the row's label unless the block names a field; a row without an image has an empty `src`,\n * which GalleryGrid and NativeGalleryGrid draw as a placeholder tile; leave those out of a Lightbox.\n */\n galleryItem(row: Row, override?: Partial<ViewGallery>): GalleryItem | undefined;\n /** The declared filters, resolved (ADR 0017). Empty without `filters`. @stability Beta */\n filters(): readonly ResolvedFilter[];\n /** The declared segments, resolved. Empty without `segments`. @stability Beta */\n segments(): readonly ResolvedSegment[];\n /**\n * A segment's rows as provider filters, for this viewer. Throws {@link ViewDefinitionError} for\n * an id the view doesn't define. @stability Beta\n */\n segmentFilters(id: string, viewer?: Viewer): FilterParam[];\n /**\n * Declared filters' values as provider filters. Only declared filters count, and a value a\n * filter doesn't accept (a choice it doesn't offer, a malformed range) is dropped: the URL is\n * an allow-list, never a way to send any field. Days and times on a timestamp column are read\n * on `zone`'s clock (the viewer's; default the device's): a day runs from its start to the next\n * day's start, and a time with no offset is that zone's. @stability Beta\n */\n filterParams(values: Readonly<Record<string, ViewFilterValue | undefined>> | null | undefined, zone?: string): FilterParam[];\n /** The view types a person may switch between, in order (`types`, or the derived default). @stability Beta */\n types(): readonly string[];\n /** The row's tone (`rowTone`), or undefined. @stability Beta */\n rowTone(row: Row): ViewTone | undefined;\n /**\n * What \"Export CSV\" writes for a column preset, or undefined when the view has no `export`.\n * @stability Beta\n */\n exportPlan(preset?: string): { readonly columns: readonly ResolvedColumn<Row>[]; readonly filename: string; readonly maxRows: number; readonly raw: boolean } | undefined;\n /**\n * The row as an inbox draws it, by the view's `inbox` block (its title from `labelField` when\n * the block says none). Works without a block too: the summary's title. @stability Beta\n */\n inboxRow(row: Row): InboxRow;\n /** The inbox's `done` and `markRead` actions, when the view declares them. @stability Beta */\n inboxActions(): { readonly done?: string; readonly markRead?: string };\n}\n","// defineView: a contract plus what it means to people, checked once and frozen (the same rule as\n// genesis-sites' defineSection). Everything a renderer needs is resolved here, so web, native and\n// the extension draw the same labels, columns and form.\n\nimport { NO_VIEWER, type Viewer } from \"../viewer\";\nimport { encodeRecordKey, keyFields } from \"../schema/keys\";\nimport type { GalleryItem } from \"../gallery\";\nimport { fieldControl, type DataRow, type FieldSchema, type ResourceContract } from \"../schema/types\";\nimport { titleCase } from \"../utils\";\nimport { isTimeZone } from \"../dates\";\nimport { ViewDefinitionError } from \"./errors\";\nimport { linkProblems, resolveLink } from \"./link\";\nimport { filterProblems, filterValueParams, resolveFilters, segmentProblems, whereParams } from \"./list-state\";\nimport type { FilterParam } from \"../provider/types\";\nimport type {\n Allowed,\n ComputedColumn,\n DisplayHint,\n ResolvedColumn,\n ResolvedFormField,\n ResolvedViewAction,\n ResourceView,\n RowOf,\n RowSummary,\n ViewBoard,\n ViewCalendar,\n ViewDefinition,\n ViewField,\n ViewFilter,\n ViewGallery,\n ViewInbox,\n RecordOpen,\n} from \"./types\";\nimport { RECORD_OPEN_MODES } from \"./types\";\n\n// Facts a contract may carry from `@genesis` comments. Read loosely so a contract emitted before\n// they existed still works.\ntype FieldFacts = FieldSchema & { readonly readOnly?: boolean; readonly sensitive?: boolean };\ntype ContractFacts = ResourceContract & {\n readonly label?: string;\n readonly labelField?: string;\n readonly noun?: string;\n readonly nounPlural?: string;\n};\n\n// In a file of its own so scope.ts and link.ts can throw it without importing this one.\nexport { ViewDefinitionError } from \"./errors\";\n\n/** The display a field gets when the view doesn't name one. */\nexport function deriveDisplay(field: FieldSchema): DisplayHint {\n if (field.references) return \"relation\";\n switch (fieldControl(field)) {\n case \"url\":\n return \"url\";\n case \"email\":\n return \"email\";\n case \"image\":\n return \"image\";\n case \"textarea\":\n return \"longText\";\n case \"date\":\n return \"date\";\n }\n if (field.enumValues?.length) return \"badge\";\n switch (field.type) {\n case \"boolean\":\n return \"boolean\";\n case \"number\":\n return \"number\";\n case \"json\":\n return \"json\";\n case \"relation\":\n return \"relation\";\n case \"datetime\":\n return /^date$/i.test(field.dbType ?? \"\") ? \"date\" : \"datetime\";\n }\n return \"text\";\n}\n\n// Plurals whose singular the rules below would get wrong.\nconst SAME_OR_IRREGULAR: Readonly<Record<string, string>> = {\n series: \"series\",\n species: \"species\",\n movies: \"movie\",\n cookies: \"cookie\",\n ties: \"tie\",\n pies: \"pie\",\n people: \"person\",\n};\n\n/** A table name's singular, for the default noun. A wrong guess is fixed with `@genesis {\"noun\"}`. */\nexport function singular(word: string): string {\n const last = word.split(\" \").pop()!;\n const head = word.slice(0, word.length - last.length);\n const lower = last.toLowerCase();\n const one = (s: string) => head + s;\n if (SAME_OR_IRREGULAR[lower]) return one(SAME_OR_IRREGULAR[lower]!);\n if (/[^aeiou]ies$/.test(lower)) return one(`${last.slice(0, -3)}y`);\n // statuses, addresses, boxes, matches, wishes, quizzes\n if (/(?:s|x|z|ch|sh)es$/.test(lower)) return one(last.slice(0, -2));\n if (/(?:ss|us|is)$/.test(lower) || !lower.endsWith(\"s\")) return word;\n return one(last.slice(0, -1));\n}\n\n// Singulars whose plural the rules below would get wrong: the irregulars above, inverted.\nconst PLURAL_OF: Readonly<Record<string, string>> = Object.fromEntries(\n Object.entries(SAME_OR_IRREGULAR).map(([many, one]) => [one, many]),\n);\n\n/** A noun's plural, the inverse of `singular`: entry → entries, box → boxes, person → people. */\nexport function plural(word: string): string {\n const last = word.split(\" \").pop()!;\n const head = word.slice(0, word.length - last.length);\n const lower = last.toLowerCase();\n const many = (s: string) => head + s;\n if (PLURAL_OF[lower]) return many(PLURAL_OF[lower]!);\n if (/[^aeiou]y$/.test(lower)) return many(`${last.slice(0, -1)}ies`);\n if (/(?:s|x|z|ch|sh)$/.test(lower)) return many(`${last}es`);\n return many(`${last}s`);\n}\n\n// The view's own operations (`view.can`): an action can't take their names.\nconst RESERVED_ACTIONS: ReadonlySet<string> = new Set([\"create\", \"update\", \"delete\"]);\n\nconst own = <V>(record: Readonly<Record<string, V>> | undefined, key: string): V | undefined =>\n record && Object.hasOwn(record, key) ? record[key] : undefined;\n\n/** A value in words: its entry in `labels`, else the value in title case (`draft` → \"Draft\"). */\nexport function valueText(labels: Readonly<Record<string, string>> | undefined, value: unknown): string {\n const key = String(value);\n return own(labels, key) ?? titleCase(key);\n}\n\nconst KIND: Readonly<Record<string, string>> = { datetime: \"date or timestamp\", boolean: \"yes/no\", number: \"number\" };\nconst EMPHASES: readonly string[] = [\"title\", \"secondary\", \"muted\"];\nconst BREAKPOINTS: readonly string[] = [\"sm\", \"md\", \"lg\", \"xl\"];\nconst TOTALS: readonly string[] = [\"sum\", \"avg\", \"min\", \"max\", \"count\"];\nconst LAYOUTS: readonly string[] = [\"month\", \"weeks\", \"agenda\", \"lanes\"];\n\n/** A calendar block's keys: anything else in one is a mistake `defineView` names. */\nconst CALENDAR_KEYS: readonly string[] = [\n \"field\", \"endField\", \"durationField\", \"durationUnit\", \"maxDuration\", \"allDayField\", \"laneBy\", \"layout\", \"phoneLayout\", \"weeks\", \"weekStartsOn\",\n];\n\n/**\n * What's wrong with a calendar block for these fields, one sentence each (empty when it's fine).\n * `defineView` checks the view's own block with it; a renderer checks a screen's overrides merged\n * over that block with it too, so neither can name a field that isn't there or isn't a date.\n *\n * @stability Beta\n */\nexport function calendarProblems(fields: readonly Pick<FieldSchema, \"name\" | \"type\" | \"array\">[], calendar: Partial<ViewCalendar>): string[] {\n const problems: string[] = [];\n const byName = new Map(fields.map((f) => [f.name, f]));\n const typed = (name: string | undefined, where: string, type: string) => {\n if (name === undefined) return;\n const f = byName.get(name);\n if (!f) problems.push(`${where} names \"${name}\", which isn't a field`);\n else if (f.type !== type || f.array) problems.push(`${where} \"${name}\" isn't a ${KIND[type]} field`);\n };\n typed(calendar.field, \"calendar.field\", \"datetime\");\n typed(calendar.endField, \"calendar.endField\", \"datetime\");\n typed(calendar.durationField, \"calendar.durationField\", \"number\");\n typed(calendar.allDayField, \"calendar.allDayField\", \"boolean\");\n if (calendar.durationUnit !== undefined && ![\"minutes\", \"hours\", \"days\"].includes(calendar.durationUnit)) {\n problems.push(`calendar.durationUnit \"${String(calendar.durationUnit)}\" isn't minutes, hours or days`);\n }\n if (calendar.durationUnit !== undefined && calendar.durationField === undefined) problems.push(\"calendar.durationUnit needs a durationField\");\n if (calendar.maxDuration !== undefined) {\n if (typeof calendar.maxDuration !== \"number\" || !Number.isFinite(calendar.maxDuration) || calendar.maxDuration <= 0) {\n problems.push(`calendar.maxDuration is a number above 0, not ${JSON.stringify(calendar.maxDuration)}`);\n } else if (calendar.durationField === undefined) problems.push(\"calendar.maxDuration needs a durationField\");\n }\n if (calendar.laneBy !== undefined && !byName.has(calendar.laneBy)) problems.push(`calendar.laneBy names \"${calendar.laneBy}\", which isn't a field`);\n for (const key of [\"layout\", \"phoneLayout\"] as const) {\n const value = calendar[key];\n if (value !== undefined && !LAYOUTS.includes(value)) problems.push(`calendar.${key} \"${String(value)}\" isn't month, weeks, agenda or lanes`);\n }\n if (calendar.weeks !== undefined && ![1, 2, 3, 4].includes(calendar.weeks)) problems.push(`calendar.weeks is 1 to 4, not ${String(calendar.weeks)}`);\n if (calendar.weekStartsOn !== undefined && calendar.weekStartsOn !== 0 && calendar.weekStartsOn !== 1) {\n problems.push(`calendar.weekStartsOn is 0 (Sunday) or 1 (Monday), not ${String(calendar.weekStartsOn)}`);\n }\n return problems;\n}\n\n/** A board block's keys: anything else in one is a mistake `defineView` names. */\nconst BOARD_KEYS: readonly string[] = [\"field\", \"columns\", \"cardFields\", \"limits\"];\n\n/**\n * The values a board's field can hold, in the contract's order: an enum's choices, or `true`\n * and `false` for a yes/no field. Undefined when the field has no fixed set of values.\n *\n * @stability Beta\n */\nexport function boardChoices(field: Pick<FieldSchema, \"type\" | \"array\" | \"enumValues\"> | undefined): readonly string[] | undefined {\n if (!field || field.array) return undefined;\n if (field.enumValues?.length) return field.enumValues;\n if (field.type === \"boolean\") return [\"true\", \"false\"];\n return undefined;\n}\n\n/** An inbox block's keys: anything else in one is a mistake `defineView` names. */\nconst INBOX_KEYS: readonly string[] = [\"title\", \"preview\", \"time\", \"from\", \"avatar\", \"unread\", \"badge\", \"rail\", \"doneAction\", \"markRead\"];\n\n/**\n * What's wrong with an inbox block for these fields, one sentence each (empty when it's fine).\n *\n * @stability Beta\n */\nexport function inboxProblems(fields: readonly Pick<FieldSchema, \"name\" | \"type\" | \"array\">[], inbox: Partial<ViewInbox>, actions: readonly string[] = []): string[] {\n const problems: string[] = [];\n const byName = new Map(fields.map((f) => [f.name, f]));\n const named = (key: \"title\" | \"preview\" | \"time\" | \"from\" | \"avatar\" | \"badge\", type?: \"string\" | \"datetime\") => {\n const name = inbox[key];\n if (name === undefined) return;\n if (typeof name === \"function\" && (key === \"title\" || key === \"preview\" || key === \"from\")) return;\n const field = typeof name === \"string\" ? byName.get(name) : undefined;\n if (!field) problems.push(`inbox.${key} names \"${String(name)}\", which isn't a field`);\n else if (type && (field.type !== type || field.array)) problems.push(`inbox.${key} \"${name}\" isn't a ${type === \"datetime\" ? \"date or timestamp\" : \"text\"} field`);\n };\n named(\"title\");\n named(\"preview\");\n named(\"time\", \"datetime\");\n named(\"from\");\n named(\"avatar\", \"string\");\n named(\"badge\");\n if (inbox.unread !== undefined && typeof inbox.unread !== \"function\") {\n const field = typeof inbox.unread === \"string\" ? byName.get(inbox.unread) : undefined;\n if (!field) problems.push(`inbox.unread names \"${String(inbox.unread)}\", which isn't a field (or pass a function of the row)`);\n else if (field.type !== \"boolean\") problems.push(`inbox.unread \"${inbox.unread}\" isn't a yes/no field`);\n }\n if (inbox.rail !== undefined && inbox.rail !== \"segments\" && inbox.rail !== \"none\") problems.push(`inbox.rail is \"segments\" or \"none\", not ${JSON.stringify(inbox.rail)}`);\n for (const key of [\"doneAction\", \"markRead\"] as const) {\n const name = inbox[key];\n if (name !== undefined && (typeof name !== \"string\" || !actions.includes(name))) problems.push(`inbox.${key} names \"${String(name)}\", which isn't one of the view's actions`);\n }\n return problems;\n}\n\n/** A gallery block's keys: anything else in one is a mistake `defineView` names. */\nconst GALLERY_KEYS: readonly string[] = [\"image\", \"width\", \"height\", \"caption\", \"alt\", \"rowHeight\"];\n\n/**\n * What's wrong with a gallery block for these fields, one sentence each (empty when it's fine).\n *\n * @stability Beta\n */\nexport function galleryProblems(fields: readonly Pick<FieldSchema, \"name\" | \"type\" | \"array\">[], gallery: Partial<ViewGallery>): string[] {\n const problems: string[] = [];\n const byName = new Map(fields.map((f) => [f.name, f]));\n const named = (key: \"image\" | \"width\" | \"height\" | \"caption\" | \"alt\", type?: \"string\" | \"number\") => {\n const name = gallery[key];\n if (name === undefined) return;\n const field = byName.get(name);\n if (!field) problems.push(`gallery.${key} names \"${name}\", which isn't a field`);\n else if (type && (field.type !== type || field.array)) problems.push(`gallery.${key} \"${name}\" is a ${field.array ? \"list\" : field.type}, not a ${type === \"string\" ? \"text\" : \"number\"} field`);\n };\n named(\"image\", \"string\");\n named(\"width\", \"number\");\n named(\"height\", \"number\");\n named(\"caption\");\n named(\"alt\");\n if ((gallery.width === undefined) !== (gallery.height === undefined)) problems.push(\"gallery.width and gallery.height go together: a ratio needs both\");\n const { rowHeight } = gallery;\n if (rowHeight !== undefined && !(typeof rowHeight === \"number\" && Number.isFinite(rowHeight) && rowHeight > 0)) problems.push(`gallery.rowHeight is a height above 0, not ${String(rowHeight)}`);\n return problems;\n}\n\n/**\n * What's wrong with a board block for these fields, one sentence each (empty when it's fine).\n *\n * @stability Beta\n */\nexport function boardProblems(\n fields: readonly Pick<FieldSchema, \"name\" | \"type\" | \"array\" | \"enumValues\">[],\n board: Partial<ViewBoard>,\n): string[] {\n const problems: string[] = [];\n const byName = new Map(fields.map((f) => [f.name, f]));\n const field = board.field === undefined ? undefined : byName.get(board.field);\n if (board.field !== undefined && !field) problems.push(`board.field names \"${board.field}\", which isn't a field`);\n const choices = boardChoices(field);\n if (field && !choices) problems.push(`board.field \"${board.field}\" has no fixed values: use an enum or a yes/no field`);\n if (board.columns !== undefined) {\n if (!Array.isArray(board.columns) || board.columns.length === 0) problems.push(\"board.columns isn't a list of values\");\n else {\n const seen = new Set<string>();\n for (const value of board.columns) {\n if (choices && !choices.includes(value)) problems.push(`board.columns lists \"${String(value)}\", which isn't a value of ${board.field}`);\n if (seen.has(value)) problems.push(`board.columns lists \"${String(value)}\" twice`);\n seen.add(value);\n }\n }\n }\n for (const name of board.cardFields ?? []) {\n if (!byName.has(name)) problems.push(`board.cardFields names \"${name}\", which isn't a field`);\n }\n for (const [value, limit] of Object.entries(board.limits ?? {})) {\n const columns = board.columns ?? choices;\n if (columns && !columns.includes(value)) problems.push(`board.limits has \"${value}\", which isn't one of the board's columns`);\n if (!Number.isInteger(limit) || limit < 1) problems.push(`board.limits.${value} is a whole number of cards, 1 or more, not ${String(limit)}`);\n }\n return problems;\n}\n\n/**\n * Describe what a resource means to people. The result is frozen and platform-neutral:\n *\n * ```ts\n * export const brandsView = defineView(contracts[\"public.brands\"], {\n * fields: { status: { display: \"badge\", tones: { active: \"success\" } } },\n * columns: { default: [\"name\", \"status\", \"created_at\"], compact: [\"name\"] },\n * can: {\n * delete: (row) => (row.is_default ? \"The default brand stays.\" : true),\n * update: (row, viewer) => (row.owner_id === viewer.id ? true : \"Only its owner edits a brand.\"),\n * },\n * actions: [{ name: \"archive\", label: \"Archive\", can: (row) => (row.is_default ? \"The default brand stays.\" : true) }],\n * });\n * ```\n *\n * Throws {@link ViewDefinitionError} when it names something the contract doesn't have, so a\n * renamed column fails at start-up, not as a blank cell.\n */\nexport function defineView<C extends ResourceContract, Row extends DataRow = RowOf<C>>(\n contract: C,\n definition: ViewDefinition<C, Row> = {},\n): ResourceView<C, Row> {\n const facts = contract as ContractFacts;\n const fields = contract.fields as readonly FieldFacts[];\n const byName = new Map(fields.map((f) => [f.name, f]));\n const keys = new Set(keyFields(contract));\n const scope = new Set<string>(definition.scope ?? []);\n // Copied and frozen, so changing the objects passed in can't change the view afterwards.\n const viewFields = Object.freeze(\n Object.fromEntries(\n Object.entries(definition.fields ?? {}).map(([k, v]) => {\n const f = { ...(v as ViewField) };\n // Maps only: anything else is left as given for the checks below to name.\n const map = (m: unknown) => Boolean(m) && typeof m === \"object\" && !Array.isArray(m);\n if (map(f.tones)) f.tones = Object.freeze({ ...f.tones });\n if (map(f.labels)) f.labels = Object.freeze({ ...f.labels });\n return [k, Object.freeze(f)];\n }),\n ),\n ) as Readonly<Record<string, NonNullable<ViewDefinition<C, Row>[\"fields\"]>[never]>>;\n const columnLists = Object.freeze(\n Object.fromEntries(\n Object.entries(definition.columns ?? {}).map(([k, list]) => [\n k,\n Object.freeze((list ?? []).map((c) => (typeof c === \"string\" ? c : Object.freeze({ ...c })))),\n ]),\n ),\n ) as Readonly<Record<string, readonly (string | ComputedColumn<Row>)[] | undefined>>;\n const formItems = Object.freeze(\n (definition.form ?? []).map((item) => (typeof item === \"string\" ? item : Object.freeze({ ...item, fields: Object.freeze([...item.fields]) }))),\n );\n const presets = Object.freeze(\n Object.fromEntries(\n Object.entries(definition.presets ?? {}).map(([k, p]) => [k, Object.freeze({ ...p, ...(p.filter ? { filter: Object.freeze({ ...p.filter }) } : {}) })]),\n ),\n ) as NonNullable<ViewDefinition<C, Row>[\"presets\"]>;\n const actionList = Object.freeze(\n // Names are trimmed, so \" archive\" and \"archive\" are one name.\n (Array.isArray(definition.actions) ? definition.actions : []).map((a) =>\n a && typeof a === \"object\" ? Object.freeze({ ...a, ...(typeof a.name === \"string\" ? { name: a.name.trim() } : {}) }) : a,\n ),\n );\n\n // ── Check every name once ────────────────────────────────────────────\n const problems: string[] = [];\n const known = (name: string, where: string) => {\n if (!byName.has(name)) problems.push(`${where} names \"${name}\", which isn't a field`);\n };\n for (const name of Object.keys(viewFields)) known(name, \"fields\");\n for (const [name, v] of Object.entries(viewFields)) {\n if (v?.labels === undefined) continue;\n if (!v.labels || typeof v.labels !== \"object\" || Array.isArray(v.labels)) {\n problems.push(`fields.${name}.labels isn't a map of values to words`);\n continue;\n }\n const values = byName.get(name)?.enumValues;\n for (const [value, words] of Object.entries(v.labels)) {\n if (typeof words !== \"string\" || !words.trim()) problems.push(`fields.${name}.labels.${value} isn't text`);\n if (values?.length && !values.includes(value)) problems.push(`fields.${name}.labels names \"${value}\", which isn't one of its values`);\n }\n }\n // A clock is \"viewer\", \"scope\" or a zone this runtime knows. Never a quiet fallback: a field\n // drawn on the wrong clock shows the wrong times with nothing to say so.\n for (const [name, v] of Object.entries(viewFields)) {\n const zone: unknown = v?.timeZone;\n if (zone === undefined || zone === \"viewer\" || zone === \"scope\") continue;\n if (zone === \"practice\") {\n problems.push(\n `fields.${name}.timeZone \"practice\" was renamed \"scope\" in genesis-core 2; run \\`genesis codemod genesis-core-2-scope-names\\``,\n );\n } else if (!isTimeZone(zone)) {\n problems.push(`fields.${name}.timeZone \"${String(zone)}\" isn't \"viewer\", \"scope\" or a time zone this runtime knows`);\n }\n }\n for (const [name, v] of Object.entries(viewFields)) {\n if (v?.missingLabel === undefined) continue;\n if (typeof v.missingLabel !== \"string\" || !v.missingLabel.trim()) problems.push(`fields.${name}.missingLabel isn't text`);\n else if (!byName.get(name)?.references) problems.push(`fields.${name}.missingLabel is set, but \"${name}\" isn't a link`);\n }\n for (const [name, v] of Object.entries(viewFields)) problems.push(...linkProblems(name, v?.link, byName.get(name)?.references));\n // Column hints and emphasis (ADR 0017).\n const titled: string[] = [];\n for (const [name, v] of Object.entries(viewFields)) {\n if (!v) continue;\n if (v.emphasis !== undefined && !EMPHASES.includes(v.emphasis)) problems.push(`fields.${name}.emphasis is title, secondary or muted, not ${JSON.stringify(v.emphasis)}`);\n if (v.emphasis === \"title\") titled.push(name);\n if (v.sortable !== undefined && typeof v.sortable !== \"boolean\") problems.push(`fields.${name}.sortable isn't true or false`);\n if (v.hideBelow !== undefined && !BREAKPOINTS.includes(v.hideBelow)) problems.push(`fields.${name}.hideBelow is sm, md, lg or xl, not ${JSON.stringify(v.hideBelow)}`);\n if (v.width !== undefined && !(typeof v.width === \"number\" ? Number.isFinite(v.width) && v.width > 0 : typeof v.width === \"string\" && v.width.trim() !== \"\")) {\n problems.push(`fields.${name}.width is a number of pixels or a CSS length, not ${JSON.stringify(v.width)}`);\n }\n }\n if (titled.length > 1) problems.push(`fields: only one field is the row's title (emphasis \"title\"); ${titled.map((n) => `\"${n}\"`).join(\" and \")} both are`);\n if (definition.editLinks !== undefined && typeof definition.editLinks !== \"boolean\") problems.push(\"editLinks isn't true or false\");\n for (const [name, v] of Object.entries(viewFields)) {\n if (v?.labelField === undefined) continue;\n if (typeof v.labelField !== \"string\" || !/^[A-Za-z_][A-Za-z0-9_]*$/.test(v.labelField)) {\n problems.push(`fields.${name}.labelField isn't a field name`);\n } else if (!byName.get(name)?.references) {\n problems.push(`fields.${name}.labelField is set, but \"${name}\" isn't a link`);\n }\n }\n for (const [preset, list] of Object.entries(columnLists)) {\n const seen = new Set<string>();\n for (const column of list ?? []) {\n const key = typeof column === \"string\" ? column : column.key;\n if (typeof column === \"string\") known(column, `columns.${preset}`);\n else if (byName.has(column.key)) problems.push(`columns.${preset}: computed \"${column.key}\" clashes with a field`);\n if (seen.has(key)) problems.push(`columns.${preset} lists \"${key}\" twice`);\n seen.add(key);\n }\n }\n const formSeen = new Set<string>();\n for (const item of formItems) {\n for (const name of typeof item === \"string\" ? [item] : item.fields) {\n known(name, \"form\");\n if (formSeen.has(name)) problems.push(`form lists \"${name}\" twice`);\n formSeen.add(name);\n }\n }\n for (const name of scope) known(name, \"scope\");\n if (definition.groupBy) known(definition.groupBy, \"groupBy\");\n const rawOpen = (definition as { open?: unknown }).open;\n if (rawOpen !== undefined && !RECORD_OPEN_MODES.includes(rawOpen as RecordOpen)) {\n problems.push(`open is ${RECORD_OPEN_MODES.map((m) => `\"${m}\"`).join(\", \")}, not ${JSON.stringify(rawOpen)}`);\n }\n const rawRecordView = (definition as { recordView?: unknown }).recordView;\n if (rawRecordView !== undefined && typeof rawRecordView !== \"function\") problems.push(\"recordView is a function that returns the record view (`() => brandRecordView`)\");\n // A copy, frozen like the other blocks: changing the object passed in can't change the view.\n // Checked as written first: a plain object with a field, and only keys a calendar has.\n const rawCalendar = definition.calendar as unknown;\n let calendar: Readonly<ViewCalendar> | undefined;\n if (rawCalendar !== undefined) {\n if (!rawCalendar || typeof rawCalendar !== \"object\" || Array.isArray(rawCalendar)) {\n problems.push(\"calendar isn't an object\");\n } else {\n for (const key of Object.keys(rawCalendar)) if (!CALENDAR_KEYS.includes(key)) problems.push(`calendar.${key} isn't a calendar setting`);\n if ((rawCalendar as { field?: unknown }).field === undefined) problems.push(\"calendar.field is required\");\n calendar = Object.freeze({ ...(rawCalendar as ViewCalendar) });\n problems.push(...calendarProblems(fields, calendar));\n }\n }\n const rawBoard = definition.board as unknown;\n let board: Readonly<ViewBoard> | undefined;\n if (rawBoard !== undefined) {\n if (!rawBoard || typeof rawBoard !== \"object\" || Array.isArray(rawBoard)) {\n problems.push(\"board isn't an object\");\n } else {\n for (const key of Object.keys(rawBoard)) if (!BOARD_KEYS.includes(key)) problems.push(`board.${key} isn't a board setting`);\n if ((rawBoard as { field?: unknown }).field === undefined) problems.push(\"board.field is required\");\n const given = rawBoard as ViewBoard;\n board = Object.freeze({\n ...given,\n ...(given.columns ? { columns: Object.freeze([...given.columns]) } : {}),\n ...(given.cardFields ? { cardFields: Object.freeze([...given.cardFields]) } : {}),\n ...(given.limits ? { limits: Object.freeze({ ...given.limits }) } : {}),\n });\n problems.push(...boardProblems(fields, board));\n }\n }\n const rawGallery = definition.gallery as unknown;\n let gallery: Readonly<ViewGallery> | undefined;\n if (rawGallery !== undefined) {\n if (!rawGallery || typeof rawGallery !== \"object\" || Array.isArray(rawGallery)) {\n problems.push(\"gallery isn't an object\");\n } else {\n for (const key of Object.keys(rawGallery)) if (!GALLERY_KEYS.includes(key)) problems.push(`gallery.${key} isn't a gallery setting`);\n if ((rawGallery as { image?: unknown }).image === undefined) problems.push(\"gallery.image is required\");\n gallery = Object.freeze({ ...(rawGallery as ViewGallery) });\n problems.push(...galleryProblems(fields, gallery));\n }\n }\n const rawInbox = (definition as { inbox?: unknown }).inbox;\n let inbox: Readonly<ViewInbox> | undefined;\n if (rawInbox !== undefined) {\n if (!rawInbox || typeof rawInbox !== \"object\" || Array.isArray(rawInbox)) {\n problems.push(\"inbox isn't an object\");\n } else {\n for (const key of Object.keys(rawInbox)) if (!INBOX_KEYS.includes(key)) problems.push(`inbox.${key} isn't an inbox setting`);\n inbox = Object.freeze({ ...(rawInbox as ViewInbox) });\n const actionNames = (Array.isArray(definition.actions) ? definition.actions : []).map((a) => (a && typeof a.name === \"string\" ? a.name.trim() : \"\"));\n problems.push(...inboxProblems(fields, inbox, actionNames));\n }\n }\n if (definition.orderBy) {\n known(definition.orderBy.field, \"orderBy\");\n const { nulls } = definition.orderBy as { nulls?: unknown };\n if (nulls !== undefined && nulls !== \"first\" && nulls !== \"last\") problems.push(`orderBy.nulls is \"first\" or \"last\", not ${String(nulls)}`);\n }\n for (const [name, preset] of Object.entries(presets)) {\n if (preset.columns && preset.columns !== \"default\" && !own(columnLists, preset.columns)) {\n problems.push(`presets.${name} uses columns \"${preset.columns}\", which isn't defined`);\n }\n for (const field of Object.keys(preset.filter ?? {})) known(field, `presets.${name}.filter`);\n }\n if (facts.labelField) known(facts.labelField, \"the contract's labelField\");\n const actionSeen = new Set<string>();\n if (definition.actions !== undefined && !Array.isArray(definition.actions)) problems.push(\"actions isn't a list\");\n actionList.forEach((action, i) => {\n const where = `actions[${i}]`;\n if (!action || typeof action !== \"object\") {\n problems.push(`${where} isn't an action`);\n return;\n }\n if (typeof action.name !== \"string\" || !action.name.trim()) problems.push(`${where} has no name`);\n else if (RESERVED_ACTIONS.has(action.name)) problems.push(`${where} is named \"${action.name}\", which is reserved for the view's own ${action.name}`);\n else if (actionSeen.has(action.name)) problems.push(`actions lists \"${action.name}\" twice`);\n else actionSeen.add(action.name);\n if (typeof action.label !== \"string\" || !action.label.trim()) problems.push(`${where} has no label`);\n if (action.confirm !== undefined && typeof action.confirm !== \"string\") problems.push(`${where}.confirm isn't text`);\n if (action.description !== undefined && typeof action.description !== \"string\") {\n problems.push(`${where}.description isn't text`);\n }\n if (action.can !== undefined && typeof action.can !== \"function\") problems.push(`${where}.can isn't a function`);\n if (action.destructive !== undefined && typeof action.destructive !== \"boolean\") problems.push(`${where}.destructive isn't true or false`);\n const bulk = (action as { bulk?: unknown }).bulk;\n if (bulk !== undefined && typeof bulk !== \"boolean\") {\n if (!bulk || typeof bulk !== \"object\" || Array.isArray(bulk)) problems.push(`${where}.bulk is true or { label, confirm, run, matching }`);\n else {\n const b = bulk as { label?: unknown; confirm?: unknown; run?: unknown; matching?: unknown };\n if (b.label !== undefined && (typeof b.label !== \"string\" || !b.label.trim())) problems.push(`${where}.bulk.label isn't text`);\n if (b.confirm !== undefined && typeof b.confirm !== \"string\") problems.push(`${where}.bulk.confirm isn't text`);\n if (b.run !== undefined && typeof b.run !== \"function\") problems.push(`${where}.bulk.run isn't a function`);\n if (b.matching !== undefined && typeof b.matching !== \"boolean\") problems.push(`${where}.bulk.matching isn't true or false`);\n if (b.matching === true && typeof b.run !== \"function\") problems.push(`${where}.bulk.matching needs a run that takes the list's filters`);\n }\n }\n });\n // Filters, segments, types, totals, tone, export (ADR 0017).\n problems.push(...filterProblems(byName, definition.filters));\n problems.push(...segmentProblems(byName, definition.segments, (name) => name === \"default\" || Boolean(own(columnLists, name))));\n const rawTypes = (definition as { types?: unknown }).types;\n if (rawTypes !== undefined) {\n if (!Array.isArray(rawTypes) || rawTypes.length === 0) problems.push(\"types is a list of view types (table, list, grid, board, calendar, gallery or a registered one)\");\n else {\n const seen = new Set<string>();\n for (const t of rawTypes as unknown[]) {\n if (typeof t !== \"string\" || !/^[a-z][a-z0-9-]{0,39}$/.test(t)) problems.push(`types lists ${JSON.stringify(t)}, which isn't a view type's id`);\n else if (seen.has(t)) problems.push(`types lists \"${t}\" twice`);\n else seen.add(t);\n if (t === \"board\" && !definition.board) problems.push('types lists \"board\", which needs a board block');\n if (t === \"calendar\" && !definition.calendar) problems.push('types lists \"calendar\", which needs a calendar block');\n if (t === \"gallery\" && !definition.gallery) problems.push('types lists \"gallery\", which needs a gallery block');\n if (t === \"inbox\" && !definition.inbox) problems.push('types lists \"inbox\", which needs an inbox block');\n }\n }\n }\n const rawTotals = (definition as { totals?: unknown }).totals;\n if (rawTotals !== undefined) {\n if (!rawTotals || typeof rawTotals !== \"object\" || Array.isArray(rawTotals)) problems.push(\"totals is a map of fields to sum, avg, min, max or count\");\n else\n for (const [name, fn] of Object.entries(rawTotals)) {\n const field = byName.get(name);\n if (!field) problems.push(`totals names \"${name}\", which isn't a field`);\n else if (!TOTALS.includes(fn as string)) problems.push(`totals.${name} is sum, avg, min, max or count, not ${JSON.stringify(fn)}`);\n else if (fn !== \"count\" && field.type !== \"number\") problems.push(`totals.${name} is ${String(fn)}, but \"${name}\" isn't a number`);\n }\n }\n if (definition.rowTone !== undefined && typeof definition.rowTone !== \"function\") problems.push(\"rowTone is a function of the row that returns a tone\");\n const rawExport = (definition as { export?: unknown }).export;\n if (rawExport !== undefined && typeof rawExport !== \"boolean\") {\n if (!rawExport || typeof rawExport !== \"object\" || Array.isArray(rawExport)) problems.push(\"export is true or { columns, filename, maxRows, raw }\");\n else {\n const e = rawExport as { columns?: unknown; filename?: unknown; maxRows?: unknown; raw?: unknown };\n if (e.columns !== undefined) {\n if (!Array.isArray(e.columns) || e.columns.length === 0) problems.push(\"export.columns is a list of fields\");\n else for (const c of e.columns as unknown[]) if (typeof c !== \"string\" || !byName.has(c)) problems.push(`export.columns names ${JSON.stringify(c)}, which isn't a field`);\n }\n if (e.filename !== undefined && (typeof e.filename !== \"string\" || !/^[\\w .-]{1,100}$/.test(e.filename))) problems.push(\"export.filename is a plain file name (letters, digits, spaces, . - _)\");\n if (e.maxRows !== undefined && !(Number.isInteger(e.maxRows) && (e.maxRows as number) > 0)) problems.push(\"export.maxRows is a whole number above 0\");\n if (e.raw !== undefined && typeof e.raw !== \"boolean\") problems.push(\"export.raw isn't true or false\");\n }\n }\n const rawRefusals = (definition as { refusals?: unknown }).refusals;\n if (rawRefusals !== undefined && rawRefusals !== \"disable\" && rawRefusals !== \"hide\") problems.push(`refusals is \"disable\" or \"hide\", not ${JSON.stringify(rawRefusals)}`);\n if (problems.length) throw new ViewDefinitionError(contract.name, problems);\n\n // ── Words ────────────────────────────────────────────────────────────\n const copy = definition.copy ?? {};\n const base = contract.name.split(\".\").pop() ?? contract.name;\n const noun = copy.noun ?? facts.noun ?? singular(base.replace(/_/g, \" \"));\n // Several: the view's, the contract's, the noun's plural; with only a derived noun, the\n // contract's label when it reads as a plural (\"People\"), else the table name.\n const labelWords = facts.label?.toLowerCase();\n const nounPlural =\n copy.nounPlural ??\n facts.nounPlural ??\n (copy.noun || facts.noun ? plural(noun) : labelWords && singular(labelWords) !== labelWords ? labelWords : base.replace(/_/g, \" \"));\n const title = copy.title ?? facts.label ?? titleCase(nounPlural);\n const labelField = facts.labelField ?? fields.find((f) => /^(name|title|label|full_name|display_name)$/.test(f.name))?.name;\n\n const label = (name: string): string => own(viewFields, name)?.label ?? byName.get(name)?.label ?? titleCase(name);\n const display = (name: string): DisplayHint => {\n const field = byName.get(name);\n return own(viewFields, name)?.display ?? (field ? deriveDisplay(field) : \"text\");\n };\n const valueLabel = (name: string, value: unknown): string => valueText(own(viewFields, name)?.labels, value);\n // A field the provider says this user can't read is left out everywhere, even when listed.\n const readable = (name: string) => byName.get(name)?.permissions?.read !== false;\n // A link is edited in a form (a picker over the linked rows, never a typed id) only when the view\n // opts in: `fields.<link>.link` (`{}` is enough) or `editLinks: true`. Otherwise it stays\n // read-only, as before 2.x links had pickers; a screen fills a required one (its `filter`,\n // `defaults`). The default flips in 3.0.\n const editLinks = definition.editLinks === true;\n const linkEditable = (f: FieldFacts) => Boolean(f.references) && (editLinks || own(viewFields, f.name)?.link !== undefined);\n // Read-only: what the server fills (generated, `@genesis readonly`), what this user can't change,\n // what the view says, and a link the view hasn't opted in. Scope (tenant) links stay out of\n // forms altogether (below).\n const readOnly = (field: FieldFacts) =>\n Boolean(\n field.generated ||\n field.readOnly ||\n (field.references && !linkEditable(field)) ||\n field.permissions?.update === false ||\n own(viewFields, field.name)?.readOnly,\n );\n // Left out of defaults (a view still lists them on purpose): the key, scope (tenant) columns,\n // sensitive values, and links, whose words cost a lookup.\n const quiet = (f: FieldFacts) => keys.has(f.name) || scope.has(f.name) || Boolean(f.sensitive) || Boolean(f.references);\n // An opted-in link a new row can't do without (no default, never empty) is in a derived form\n // anyway: without it, the form could never save. Other links are in a form when the view lists them.\n const neededLink = (f: FieldFacts) => linkEditable(f) && !f.nullable && !f.optional && !f.hasDefault && !scope.has(f.name);\n\n // ── Columns ──────────────────────────────────────────────────────────\n const defaultColumns: readonly (string | ComputedColumn<Row>)[] =\n own(columnLists, \"default\") ?? fields.filter((f) => !quiet(f)).map((f) => f.name);\n const presetNames = Object.freeze([\"default\", ...Object.keys(columnLists).filter((p) => p !== \"default\")]);\n // The row's title is the field the view names (`emphasis: \"title\"`), else the label field.\n const titleField = Object.entries(viewFields).find(([, v]) => v?.emphasis === \"title\")?.[0] ?? labelField;\n const emphasisOf = (name: string) => own(viewFields, name)?.emphasis ?? (name === titleField ? (\"title\" as const) : undefined);\n // One field as a column: its words, hint, tones and guards. Cached, so every list and card shares it.\n const fieldColumns = new Map<string, ResolvedColumn<Row>>();\n const fieldColumn = (column: string): ResolvedColumn<Row> => {\n const cached = fieldColumns.get(column);\n if (cached) return cached;\n const v = own(viewFields, column);\n const resolved: ResolvedColumn<Row> = Object.freeze({\n key: column,\n label: label(column),\n display: display(column),\n field: byName.get(column)!,\n value: (row: Row) => row[column],\n ...(v?.tones ? { tones: v.tones } : {}),\n ...(v?.labels ? { labels: v.labels } : {}),\n ...(v?.labelField ? { labelField: v.labelField } : {}),\n ...(v?.missingLabel ? { missingLabel: v.missingLabel } : {}),\n ...(v?.when ? { when: (row: Row, viewer: Viewer = NO_VIEWER) => v.when!(row, viewer) } : {}),\n ...(v?.timeZone ? { timeZone: v.timeZone } : {}),\n ...(emphasisOf(column) ? { emphasis: emphasisOf(column)! } : {}),\n ...(v?.sortable === false ? { sortable: false } : {}),\n ...(v?.hideBelow ? { hideBelow: v.hideBelow } : {}),\n ...(v?.width !== undefined ? { width: v.width } : {}),\n });\n fieldColumns.set(column, resolved);\n return resolved;\n };\n const resolvedColumns = new Map<string, readonly ResolvedColumn<Row>[]>();\n const columns = (preset = \"default\"): readonly ResolvedColumn<Row>[] => {\n const cached = resolvedColumns.get(preset);\n if (cached) return cached;\n const list = preset === \"default\" ? defaultColumns : own(columnLists, preset);\n if (!list) throw new ViewDefinitionError(contract.name, [`no column preset \"${preset}\"`]);\n const out = Object.freeze(\n list.filter((column) => typeof column !== \"string\" || readable(column)).map((column): ResolvedColumn<Row> => {\n if (typeof column !== \"string\") {\n // A computed column has no database column to sort by.\n return Object.freeze({ key: column.key, label: column.label, display: column.display ?? \"text\", value: column.value, sortable: false });\n }\n return fieldColumn(column);\n }),\n );\n resolvedColumns.set(preset, out);\n return out;\n };\n\n // ── Form ─────────────────────────────────────────────────────────────\n // One picker per link, made once: what it lists, what names a row, the filters it sends.\n const links = new Map(\n fields\n .filter((f) => linkEditable(f))\n .map((f) => [f.name, resolveLink(contract.name, f.name, f.references!, own(viewFields, f.name)?.link, own(viewFields, f.name)?.labelField)]),\n );\n type Placed = { name: string; section: string | null; sectionTitle: string | null };\n const placed: readonly Placed[] = definition.form\n ? formItems.flatMap((item): Placed[] =>\n typeof item === \"string\"\n ? [{ name: item, section: null, sectionTitle: null }]\n : item.fields.map((name) => ({ name, section: item.section, sectionTitle: item.title ?? titleCase(item.section) })),\n )\n : fields\n // JSON needs an editor of its own, so it is never in a derived form.\n // A key the person types (a code, a slug) stays; one the server fills doesn't.\n .filter(\n (f) =>\n !readOnly(f) &&\n (!quiet(f) || (keys.has(f.name) && !f.hasDefault && !f.sensitive) || (neededLink(f) && !f.sensitive)) &&\n f.type !== \"json\" &&\n !f.array,\n )\n .map((f): Placed => ({ name: f.name, section: null, sectionTitle: null }));\n // A key the server fills (a default) is never sent on create; no key is sent on edit.\n const serverKey = (f: FieldFacts, mode: \"create\" | \"edit\") => keys.has(f.name) && (mode === \"edit\" || Boolean(f.hasDefault));\n const resolvedForms = new Map<string, readonly ResolvedFormField[]>();\n const form = (mode: \"create\" | \"edit\"): readonly ResolvedFormField[] => {\n const cached = resolvedForms.get(mode);\n if (cached) return cached;\n const out = Object.freeze(placed\n .filter(({ name }) => !scope.has(name) && readable(name) && !serverKey(byName.get(name)!, mode))\n .map(({ name, section, sectionTitle }) => {\n const field = byName.get(name)!;\n const v = own(viewFields, name);\n const locked = readOnly(field);\n return Object.freeze({\n field,\n label: label(name),\n display: display(name),\n required: !locked && !field.nullable && !field.optional && (mode === \"edit\" || !field.hasDefault),\n readOnly: locked,\n section,\n sectionTitle,\n ...(v?.max !== undefined ? { max: v.max } : {}),\n ...(v?.autoComplete ? { autoComplete: v.autoComplete } : {}),\n ...(v?.inputMode ? { inputMode: v.inputMode } : {}),\n ...(v?.enterKeyHint ? { enterKeyHint: v.enterKeyHint } : {}),\n ...(v?.labelField ? { labelField: v.labelField } : {}),\n ...(v?.missingLabel ? { missingLabel: v.missingLabel } : {}),\n ...(field.enumValues?.length\n ? { options: Object.freeze(field.enumValues.map((value) => Object.freeze({ value, label: valueLabel(name, value) }))) }\n : {}),\n ...(links.has(name) ? { link: links.get(name)! } : {}),\n ...(v?.visible ? { visible: v.visible } : {}),\n });\n }));\n resolvedForms.set(mode, out);\n return out;\n };\n const writable = (mode: \"create\" | \"edit\") => Object.freeze(form(mode).filter((f) => !f.readOnly).map((f) => f.field.name));\n\n // ── Guards and summary ───────────────────────────────────────────────\n const guards = definition.can ?? {};\n // `can(\"create\", viewer)` and `can(\"update\", row, viewer)`; no viewer means no one (fail closed).\n function can(action: \"create\" | \"update\" | \"delete\", rowOrViewer?: Row | Viewer, maybeViewer?: Viewer): Allowed {\n // Plain JavaScript can pass a row to create: that row would be read as the viewer.\n if (action === \"create\" && maybeViewer !== undefined) throw new TypeError(`[genesis-core] ${contract.name}: can(\"create\", viewer) takes no row`);\n if (action === \"create\") return guards.create?.((rowOrViewer as Viewer | undefined) ?? NO_VIEWER) ?? true;\n const guard = guards[action];\n const row = rowOrViewer as Row | undefined;\n return guard && row ? guard(row, maybeViewer ?? NO_VIEWER) : true;\n }\n const actionGuards = new Map(actionList.map((a) => [a.name, a.can]));\n const resolvedActions: readonly ResolvedViewAction[] = Object.freeze(\n actionList.map((a) =>\n Object.freeze({\n name: a.name,\n label: a.label,\n ...(a.confirm !== undefined ? { confirm: a.confirm } : {}),\n ...(a.description !== undefined ? { description: a.description } : {}),\n ...(a.destructive ? { destructive: true } : {}),\n ...(a.bulk\n ? {\n bulk: Object.freeze({\n label: (typeof a.bulk === \"object\" ? a.bulk.label : undefined) ?? a.label,\n ...(((typeof a.bulk === \"object\" ? a.bulk.confirm : undefined) ?? a.confirm) !== undefined\n ? { confirm: ((typeof a.bulk === \"object\" ? a.bulk.confirm : undefined) ?? a.confirm)! }\n : {}),\n matching: typeof a.bulk === \"object\" && a.bulk.matching === true,\n batch: typeof a.bulk === \"object\" && typeof a.bulk.run === \"function\",\n }),\n }\n : {}),\n }),\n ),\n );\n function canAction(name: string, row: Row, viewer: Viewer = NO_VIEWER): Allowed {\n if (!actionGuards.has(name)) throw new ViewDefinitionError(contract.name, [`no action \"${name}\"`]);\n const guard = actionGuards.get(name);\n if (!guard) return true;\n const result: unknown = guard(row, viewer);\n // Only `true` allows; a reason is shown as given; anything else (false, \"\", undefined) refuses.\n if (result === true) return true;\n return typeof result === \"string\" && result.trim() ? result : \"This isn't allowed.\";\n }\n const summary = (row: Row): RowSummary => {\n if (definition.summary) return definition.summary(row);\n const value = labelField ? row[labelField] : undefined;\n return { title: value === null || value === undefined || value === \"\" ? titleCase(noun) : String(value) };\n };\n\n const galleryItem = (row: Row, override?: Partial<ViewGallery>): GalleryItem | undefined => {\n const block = { ...gallery, ...override };\n if (!block.image) return undefined;\n // A row without an image is still a photo: an empty `src`, which the grids draw as a placeholder.\n const image = row[block.image];\n const src = typeof image === \"string\" ? image : \"\";\n const number = (name: string | undefined) => {\n const value = name ? Number(row[name]) : NaN;\n return Number.isFinite(value) && value > 0 ? value : undefined;\n };\n const text = (name: string | undefined) => {\n const value = name ? row[name] : undefined;\n return value === null || value === undefined || value === \"\" ? undefined : String(value);\n };\n const width = number(block.width);\n const height = number(block.height);\n const caption = text(block.caption);\n const alt = text(block.alt) ?? summary(row).title;\n return {\n id: String(encodeRecordKey(contract, row as DataRow)),\n src,\n alt,\n ...(width !== undefined && height !== undefined ? { width, height } : {}),\n ...(caption !== undefined ? { caption } : {}),\n };\n };\n\n // ── Filters, segments, types, tone, export (ADR 0017) ─────────────────\n const resolvedFilters = resolveFilters(byName, definition.filters as readonly ViewFilter[] | undefined, label, (name) => own(viewFields, name) as ViewField | undefined, valueLabel);\n const segmentList = Object.freeze((definition.segments ?? []).map((s) => Object.freeze({ ...s })));\n const resolvedSegments = Object.freeze(\n segmentList.map((s) => Object.freeze({ id: s.id, label: s.label, count: s.count === true, ...(s.columns ? { columns: s.columns } : {}) })),\n );\n const segmentFilters = (id: string, viewer: Viewer = NO_VIEWER): FilterParam[] => {\n const segment = segmentList.find((s) => s.id === id);\n if (!segment) throw new ViewDefinitionError(contract.name, [`no segment \"${id}\"`]);\n const where = typeof segment.where === \"function\" ? segment.where(viewer) : segment.where;\n return [...whereParams(where as Parameters<typeof whereParams>[0]), ...whereParams(segment.args)];\n };\n const viewTypes: readonly string[] = Object.freeze(\n definition.types\n ? [...definition.types]\n : [\"table\", \"list\", \"grid\", ...(gallery ? [\"gallery\"] : []), ...(board ? [\"board\"] : []), ...(calendar ? [\"calendar\"] : []), ...(inbox ? [\"inbox\"] : [])],\n );\n const rowTone = (row: Row) => definition.rowTone?.(row) ?? undefined;\n const exportPlan = (preset = \"default\") => {\n if (!definition.export) return undefined;\n const given = typeof definition.export === \"object\" ? definition.export : {};\n const fromPreset = columns(own(columnLists, preset) || preset === \"default\" ? preset : \"default\").filter((c) => c.field && !(c.field as FieldFacts).sensitive);\n const chosen = given.columns ? given.columns.map((name) => fieldColumn(name)).filter((c) => readable(c.key)) : fromPreset;\n return Object.freeze({\n columns: Object.freeze(chosen),\n filename: given.filename ?? (nounPlural.replace(/[^\\w .-]/g, \"\") || \"export\"),\n maxRows: given.maxRows ?? 10_000,\n raw: given.raw === true,\n });\n };\n\n const actionNames = new Set(actionList.map((a) => a.name));\n const inboxActionNames = Object.freeze({\n ...((inbox?.doneAction ?? [\"done\", \"close\"].find((n) => actionNames.has(n))) ? { done: inbox?.doneAction ?? [\"done\", \"close\"].find((n) => actionNames.has(n))! } : {}),\n ...((inbox?.markRead ?? (actionNames.has(\"markRead\") ? \"markRead\" : undefined)) ? { markRead: inbox?.markRead ?? \"markRead\" } : {}),\n });\n const words = (value: unknown) => (value === null || value === undefined || value === \"\" ? undefined : String(value));\n const inboxText = (pick: string | ((row: Row) => string | null | undefined) | undefined, row: Row) =>\n pick === undefined ? undefined : typeof pick === \"function\" ? words(pick(row)) : words(row[pick]);\n const inboxRow = (row: Row) => {\n const block = (inbox ?? {}) as ViewInbox<string, Row>;\n const title = inboxText(block.title, row) ?? summary(row).title;\n const preview = inboxText(block.preview, row);\n const from = inboxText(block.from, row);\n const unread =\n typeof block.unread === \"function\" ? block.unread(row as never) === true : typeof block.unread === \"string\" ? row[block.unread] === true : false;\n const badgeValue = block.badge ? row[block.badge] : undefined;\n const badgeTones = block.badge ? own(viewFields, block.badge)?.tones : undefined;\n const badgeTone = badgeValue !== undefined && badgeValue !== null && badgeTones ? own(badgeTones, String(badgeValue)) : undefined;\n const time = block.time ? row[block.time] : undefined;\n return Object.freeze({\n id: String(encodeRecordKey(contract, row as DataRow)),\n title,\n unread,\n ...(preview ? { preview } : {}),\n ...(time instanceof Date ? { time: time.toISOString() } : words(time) ? { time: words(time)! } : {}),\n ...(from ? { from } : {}),\n ...(block.avatar && words(row[block.avatar]) ? { avatar: words(row[block.avatar])! } : {}),\n ...(words(badgeValue) ? { badge: Object.freeze({ label: valueLabel(block.badge!, badgeValue), ...(badgeTone ? { tone: badgeTone } : {}) }) } : {}),\n });\n };\n\n return Object.freeze({\n contract,\n definition: Object.freeze({\n ...definition,\n fields: viewFields,\n columns: columnLists,\n presets,\n ...(definition.form ? { form: formItems } : {}),\n ...(definition.scope ? { scope: Object.freeze([...definition.scope]) } : {}),\n ...(definition.actions ? { actions: actionList } : {}),\n ...(calendar ? { calendar } : {}),\n ...(board ? { board } : {}),\n ...(gallery ? { gallery } : {}),\n ...(inbox ? { inbox } : {}),\n ...(definition.filters ? { filters: Object.freeze(definition.filters.map((f) => Object.freeze({ ...f }))) } : {}),\n ...(definition.segments ? { segments: segmentList } : {}),\n ...(definition.types ? { types: viewTypes } : {}),\n ...(definition.totals ? { totals: Object.freeze({ ...definition.totals }) } : {}),\n }) as Readonly<ViewDefinition<C, Row>>,\n resource: contract.name,\n noun,\n nounPlural,\n title,\n labelField,\n presets: presetNames,\n field: (name: string) => byName.get(name),\n column: (name: string) => (byName.has(name) && readable(name) ? fieldColumn(name) : undefined),\n label,\n display,\n valueLabel,\n columns,\n form,\n writable,\n can: can as ResourceView<C, Row>[\"can\"],\n actions: () => resolvedActions,\n canAction,\n summary,\n galleryItem,\n filters: () => resolvedFilters,\n segments: () => resolvedSegments,\n segmentFilters,\n filterParams: (values: Parameters<ResourceView<C, Row>[\"filterParams\"]>[0], zone?: string) => filterValueParams(resolvedFilters, byName, values, zone),\n types: () => viewTypes,\n rowTone,\n exportPlan,\n inboxRow,\n inboxActions: () => inboxActionNames,\n });\n}\n"]}
@@ -0,0 +1,31 @@
1
+ import { useViewer } from './chunk-XIBQ5BTZ.js';
2
+ import { resourceKeys } from './chunk-2IGAUXYH.js';
3
+ import { useDataProvider } from './chunk-OIZNABG4.js';
4
+ import { resolveAggregate } from './chunk-J54XXKQD.js';
5
+ import { useQueries } from '@tanstack/react-query';
6
+
7
+ function useSegmentCounts(view, baseFilters, options = {}) {
8
+ const provider = useDataProvider();
9
+ const viewer = useViewer();
10
+ const segments = view.segments();
11
+ const counted = useQueries({
12
+ queries: segments.map((s) => {
13
+ const params = { metrics: { n: { fn: "count" } }, filters: [...baseFilters, ...view.segmentFilters(s.id, viewer)], count: "estimated" };
14
+ return {
15
+ queryKey: resourceKeys(view.resource).aggregate(params),
16
+ queryFn: () => resolveAggregate(provider, view.resource, params),
17
+ enabled: !!s.count && options.enabled !== false
18
+ };
19
+ })
20
+ });
21
+ const out = {};
22
+ segments.forEach((s, i) => {
23
+ const n = counted[i]?.data?.values["n"];
24
+ out[s.id] = typeof n === "number" ? n : void 0;
25
+ });
26
+ return out;
27
+ }
28
+
29
+ export { useSegmentCounts };
30
+ //# sourceMappingURL=chunk-K33LWVUF.js.map
31
+ //# sourceMappingURL=chunk-K33LWVUF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/use-segment-counts.ts"],"names":[],"mappings":";;;;;;AAkBO,SAAS,gBAAA,CAEd,IAAA,EACA,WAAA,EACA,OAAA,GAAiC,EAAC,EACY;AAC9C,EAAA,MAAM,WAAW,eAAA,EAAgB;AACjC,EAAA,MAAM,SAAS,SAAA,EAAU;AACzB,EAAA,MAAM,QAAA,GAAW,KAAK,QAAA,EAAS;AAC/B,EAAA,MAAM,UAAU,UAAA,CAAW;AAAA,IACzB,OAAA,EAAS,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM;AAC3B,MAAA,MAAM,MAAA,GAAS,EAAE,OAAA,EAAS,EAAE,GAAG,EAAE,EAAA,EAAI,OAAA,EAAiB,EAAE,EAAG,OAAA,EAAS,CAAC,GAAG,WAAA,EAAa,GAAG,IAAA,CAAK,cAAA,CAAe,CAAA,CAAE,IAAI,MAAM,CAAC,CAAA,EAAG,KAAA,EAAO,WAAA,EAAqB;AACxJ,MAAA,OAAO;AAAA,QACL,UAAU,YAAA,CAAa,IAAA,CAAK,QAAQ,CAAA,CAAE,UAAU,MAAM,CAAA;AAAA,QACtD,SAAS,MAAM,gBAAA,CAAiB,QAAA,EAAU,IAAA,CAAK,UAAU,MAAM,CAAA;AAAA,QAC/D,SAAS,CAAC,CAAC,CAAA,CAAE,KAAA,IAAS,QAAQ,OAAA,KAAY;AAAA,OAC5C;AAAA,IACF,CAAC;AAAA,GACF,CAAA;AACD,EAAA,MAAM,MAA0C,EAAC;AACjD,EAAA,QAAA,CAAS,OAAA,CAAQ,CAAC,CAAA,EAAG,CAAA,KAAM;AACzB,IAAA,MAAM,IAAI,OAAA,CAAQ,CAAC,CAAA,EAAG,IAAA,EAAM,OAAO,GAAG,CAAA;AACtC,IAAA,GAAA,CAAI,EAAE,EAAE,CAAA,GAAI,OAAO,CAAA,KAAM,WAAW,CAAA,GAAI,MAAA;AAAA,EAC1C,CAAC,CAAA;AACD,EAAA,OAAO,GAAA;AACT","file":"chunk-K33LWVUF.js","sourcesContent":["import { useQueries } from \"@tanstack/react-query\";\nimport { useDataProvider } from \"../provider/context\";\nimport { resolveAggregate } from \"../provider/aggregate\";\nimport type { FilterParam } from \"../provider/types\";\nimport { resourceKeys } from \"../query-keys\";\nimport type { ResourceContract } from \"../schema/types\";\nimport type { ResourceView } from \"../resource-view/types\";\nimport { useViewer } from \"./viewer-scope\";\n\n/**\n * Each segment's row count for a view's list (ADR 0017), for the segments that ask for one\n * (`count: true`): the list's other filters (scope, the screen's, the declared filters) plus the\n * segment's own, counted through the provider (estimated). A segment without a count, or one not\n * counted yet, maps to undefined. The web's segment strip, the inbox rail and the phone's segment\n * chips all read it.\n *\n * @stability Beta\n */\nexport function useSegmentCounts(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract and row\n view: ResourceView<ResourceContract<any>, any>,\n baseFilters: readonly FilterParam[],\n options: { enabled?: boolean } = {},\n): Readonly<Record<string, number | undefined>> {\n const provider = useDataProvider();\n const viewer = useViewer();\n const segments = view.segments();\n const counted = useQueries({\n queries: segments.map((s) => {\n const params = { metrics: { n: { fn: \"count\" as const } }, filters: [...baseFilters, ...view.segmentFilters(s.id, viewer)], count: \"estimated\" as const };\n return {\n queryKey: resourceKeys(view.resource).aggregate(params),\n queryFn: () => resolveAggregate(provider, view.resource, params),\n enabled: !!s.count && options.enabled !== false,\n };\n }),\n });\n const out: Record<string, number | undefined> = {};\n segments.forEach((s, i) => {\n const n = counted[i]?.data?.values[\"n\"];\n out[s.id] = typeof n === \"number\" ? n : undefined;\n });\n return out;\n}\n"]}