@marktiderman/genesis-core 2.17.0 → 2.18.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 (80) hide show
  1. package/dist/{aggregate-v_r-nZbH.d.ts → aggregate-CUirs7ka.d.ts} +1 -1
  2. package/dist/{chunk-UNEZF3ZP.js → chunk-5PCGMSDX.js} +209 -28
  3. package/dist/chunk-5PCGMSDX.js.map +1 -0
  4. package/dist/{chunk-JNWTHDGF.js → chunk-AOIVTOHX.js} +3 -3
  5. package/dist/{chunk-JNWTHDGF.js.map → chunk-AOIVTOHX.js.map} +1 -1
  6. package/dist/{chunk-FBMKI22S.js → chunk-ATVK3VYS.js} +3 -3
  7. package/dist/{chunk-FBMKI22S.js.map → chunk-ATVK3VYS.js.map} +1 -1
  8. package/dist/{chunk-NOPS5EIH.js → chunk-CJ5V6JES.js} +5 -114
  9. package/dist/chunk-CJ5V6JES.js.map +1 -0
  10. package/dist/{chunk-TWLPC4S3.js → chunk-DJRT4DUF.js} +3 -3
  11. package/dist/{chunk-TWLPC4S3.js.map → chunk-DJRT4DUF.js.map} +1 -1
  12. package/dist/{chunk-WNOCPV4A.js → chunk-DTVYCATJ.js} +3 -3
  13. package/dist/{chunk-WNOCPV4A.js.map → chunk-DTVYCATJ.js.map} +1 -1
  14. package/dist/chunk-LYNIHY3F.js +115 -0
  15. package/dist/chunk-LYNIHY3F.js.map +1 -0
  16. package/dist/{chunk-6B4CN2TC.js → chunk-OCMYW2YE.js} +3 -3
  17. package/dist/{chunk-6B4CN2TC.js.map → chunk-OCMYW2YE.js.map} +1 -1
  18. package/dist/{chunk-AQX5HQD6.js → chunk-OTUTSAZD.js} +3 -3
  19. package/dist/{chunk-AQX5HQD6.js.map → chunk-OTUTSAZD.js.map} +1 -1
  20. package/dist/{chunk-KRRESUXT.js → chunk-PH25HOAL.js} +6 -6
  21. package/dist/{chunk-KRRESUXT.js.map → chunk-PH25HOAL.js.map} +1 -1
  22. package/dist/{chunk-XIBQ5BTZ.js → chunk-RZVLUUMY.js} +4 -4
  23. package/dist/{chunk-XIBQ5BTZ.js.map → chunk-RZVLUUMY.js.map} +1 -1
  24. package/dist/{chunk-2ORQLYVW.js → chunk-SMEG63MO.js} +4 -4
  25. package/dist/{chunk-2ORQLYVW.js.map → chunk-SMEG63MO.js.map} +1 -1
  26. package/dist/{chunk-YMFJLBIZ.js → chunk-UKJCF2CM.js} +3 -3
  27. package/dist/{chunk-YMFJLBIZ.js.map → chunk-UKJCF2CM.js.map} +1 -1
  28. package/dist/{chunk-K33LWVUF.js → chunk-UKWM32CG.js} +3 -3
  29. package/dist/{chunk-K33LWVUF.js.map → chunk-UKWM32CG.js.map} +1 -1
  30. package/dist/csv.d.ts +1 -1
  31. package/dist/errors.js +2 -1
  32. package/dist/form-types.d.ts +1 -1
  33. package/dist/headless/index.d.ts +1 -1
  34. package/dist/hooks/index.d.ts +4 -4
  35. package/dist/hooks/index.js +13 -12
  36. package/dist/hooks/mutation-mode.d.ts +1 -1
  37. package/dist/hooks/mutation-mode.js +3 -2
  38. package/dist/hooks/related-keys.d.ts +1 -1
  39. package/dist/hooks/use-aggregate.d.ts +2 -2
  40. package/dist/hooks/use-board-columns.d.ts +1 -1
  41. package/dist/hooks/use-capabilities.d.ts +1 -1
  42. package/dist/hooks/use-infinite-resource.d.ts +1 -1
  43. package/dist/hooks/use-link-options.d.ts +1 -1
  44. package/dist/hooks/use-list-state.d.ts +3 -3
  45. package/dist/hooks/use-list-state.js +5 -4
  46. package/dist/hooks/use-live.d.ts +1 -1
  47. package/dist/hooks/use-one.d.ts +1 -1
  48. package/dist/hooks/use-relation-label.d.ts +1 -1
  49. package/dist/hooks/use-resource-form.d.ts +1 -1
  50. package/dist/hooks/use-resource-form.js +4 -3
  51. package/dist/hooks/use-resource.d.ts +1 -1
  52. package/dist/hooks/use-resource.js +4 -3
  53. package/dist/hooks/use-segment-counts.d.ts +2 -2
  54. package/dist/hooks/use-segment-counts.js +5 -4
  55. package/dist/hooks/use-view-board.d.ts +2 -2
  56. package/dist/hooks/use-view-board.js +8 -7
  57. package/dist/hooks/use-view-calendar-range.d.ts +2 -2
  58. package/dist/hooks/use-view-calendar-range.js +6 -5
  59. package/dist/hooks/use-write.d.ts +1 -1
  60. package/dist/index.d.ts +8 -8
  61. package/dist/index.js +15 -14
  62. package/dist/index.js.map +1 -1
  63. package/dist/provider/index.d.ts +7 -378
  64. package/dist/provider/index.js +3 -2
  65. package/dist/{write-outcome-DuwfsnyO.d.ts → read-outcome-Cq0h2oAG.d.ts} +31 -2
  66. package/dist/resource-view/index.d.ts +4 -4
  67. package/dist/resource-view/index.js +5 -4
  68. package/dist/resource-view/index.js.map +1 -1
  69. package/dist/{saved-views-C45lRm7i.d.ts → saved-views-Bcox3blZ.d.ts} +2 -2
  70. package/dist/schema/index.d.ts +3 -4
  71. package/dist/supabase-provider-D5ditkHi.d.ts +465 -0
  72. package/dist/testing/index.d.ts +87 -3
  73. package/dist/testing/index.js +88 -1
  74. package/dist/testing/index.js.map +1 -1
  75. package/dist/{types-CiQY6hUy.d.ts → types-BnOCVJzm.d.ts} +1 -1
  76. package/dist/{types-BAhcze_-.d.ts → types-CBtBvGw0.d.ts} +1 -1
  77. package/package.json +1 -1
  78. package/dist/chunk-NOPS5EIH.js.map +0 -1
  79. package/dist/chunk-UNEZF3ZP.js.map +0 -1
  80. package/dist/read-outcome-BnboMYOV.d.ts +0 -30
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/resource-view/picture.ts","../../src/resource-view/group.ts","../../src/resource-view/tree.ts","../../src/resource-view/record-view.ts","../../src/resource-view/widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAMA,IAAI,SAAA;AAIJ,IAAM,MAAA,GAAS,SAAA;AACf,SAAS,UAAU,IAAA,EAAwB;AACzC,EAAA,IAAI,cAAc,MAAA,EAAW;AAC3B,IAAA,SAAA,GAAY,OAAO,IAAA,KAAS,WAAA,IAAe,OAAO,KAAK,S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AE,IAAA,GAAO,CAAA,CAAA,EAAI,OAAO,IAAA;AACxG,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAA,GAAQ,IAAI,CAAA;AACjC","file":"index.js","sourcesContent":["// rowPicture: what to draw for a row's picture (docs/RESOURCE-VIEW.md, \"summary\"). Pure, so web,\n// native and the extension draw the same image or initials, behind the same URL check.\n\nimport { isSafeUrl } from \"../urls\";\nimport type { RowPicture, RowSummary } from \"./types\";\n\nlet segmenter: Intl.Segmenter | null | undefined;\n\n// The first letter of a word, as a whole character: \"é\" keeps its accent, \"李\" is a letter, and\n// punctuation, digits and emoji never count.\nconst LETTER = /^\\p{L}/u;\nfunction lettersOf(word: string): string[] {\n if (segmenter === undefined) {\n segmenter = typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\" ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" }) : null;\n }\n const parts = segmenter ? Array.from(segmenter.segment(word), (s) => s.segment) : Array.from(word);\n return parts.filter((part) => LETTER.test(part));\n}\nfunction firstLetter(word: string): string {\n return lettersOf(word)[0] ?? \"\";\n}\n\n/**\n * First and last initial of a name, from letters only: \"Ada Lovelace\" → \"AL\", \"Ana-María López\"\n * → \"AL\", \"李 小龙\" → \"李小\", \"Cher\" → \"C\". Empty when the name has no letters (\" \", \"🎉🎉\").\n *\n * `distinct: true` gives a one-word name its first two letters (\"Probe\" → \"Pr\", \"Polish\" → \"Po\"),\n * so people who share an initial still differ in a list. Names of two words or more are unchanged.\n */\nexport function initialsOf(name: string | undefined, options: { distinct?: boolean | undefined } = {}): string {\n const words = (name ?? \"\").trim().split(/\\s+/);\n const letters = words.map(firstLetter).filter(Boolean);\n if (letters.length === 0) return \"\";\n const upper = (l: string) => (l.toUpperCase().length === l.length ? l.toUpperCase() : l);\n if (letters.length === 1 && options.distinct) {\n const word = words.find((w) => firstLetter(w))!;\n const second = lettersOf(word)[1];\n // One character each: \"ß\" stays \"ß\" rather than becoming \"SS\".\n return upper(letters[0]!) + (second ? (second.toLowerCase().length === second.length ? second.toLowerCase() : second) : \"\");\n }\n const pair = letters.length === 1 ? [letters[0]!] : [letters[0]!, letters[letters.length - 1]!];\n // One character each: \"ß\" stays \"ß\" rather than becoming \"SS\".\n return pair.map(upper).join(\"\");\n}\n\n/** An image source: `isSafeUrl`, and only http(s) or a root-relative path (never mailto, tel or `#x`). */\nfunction isImageSrc(src: unknown): src is string {\n if (!isSafeUrl(src)) return false;\n const value = src.trim();\n return value.startsWith(\"/\") || /^https?:/i.test(value);\n}\n\n/**\n * What to draw for a summary's picture:\n *\n * ```ts\n * rowPicture({ title: \"Ada\", image: { src: \"https://…/ada.png\", name: \"Ada Lovelace\" } });\n * // { kind: \"image\", src: \"https://…/ada.png\", alt: \"\", fallback: \"AL\" }\n * rowPicture({ title: \"Ada\", image: { src: \"javascript:x\", name: \"Ada Lovelace\" } });\n * // { kind: \"initials\", text: \"AL\" }\n * ```\n *\n * `null` when the summary has no `image`, or neither a safe `src` nor a `name` with letters.\n */\nexport function rowPicture(summary: RowSummary): RowPicture | null {\n const image = summary.image;\n if (!image) return null;\n const initials = initialsOf(image.name);\n if (isImageSrc(image.src)) return { kind: \"image\", src: image.src.trim(), alt: image.alt ?? \"\", fallback: initials };\n return initials ? { kind: \"initials\", text: initials } : null;\n}\n","// groupRows: a view's rows under headers by its `groupBy` field (or another), with no React, so a\n// custom view on the web, a phone screen and a server export group the same way.\n\nimport type { DataRow, ResourceContract } from \"../schema/types\";\nimport type { ResourceView } from \"./types\";\n\n/**\n * One group of rows: the value they share, its words and the rows, in the order they came.\n *\n * @stability Beta\n */\nexport interface RowGroup<Row extends DataRow = DataRow> {\n /** Stable, for list keys: the value as text, or `\"\"` for rows with no value. */\n readonly key: string;\n /** The value the rows share (`null` for the group with none). */\n readonly value: unknown;\n /** The value in words (`view.valueLabel`), or `emptyLabel` for the group with none. */\n readonly label: string;\n readonly rows: readonly Row[];\n}\n\n/** @stability Beta */\nexport interface GroupRowsOptions {\n /** The field to group by. Default the view's `groupBy`. */\n field?: string;\n /** The words for rows with no value. Default \"No {field label}\". */\n emptyLabel?: string;\n}\n\nconst isEmpty = (value: unknown) => value === null || value === undefined || value === \"\";\n\n/**\n * A view's rows in groups, in the order each group first appears (the server's sort, so loading\n * more never reorders what's on screen). Without a field (no `groupBy` and none given), one group\n * holding every row, with an empty label.\n *\n * ```ts\n * for (const group of groupRows(tasksView, rows)) console.log(group.label, group.rows.length);\n * ```\n *\n * @stability Beta\n */\nexport function groupRows<Row extends DataRow>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract; Row is what matters here\n view: ResourceView<ResourceContract<any>, Row>,\n rows: readonly Row[],\n options: GroupRowsOptions = {},\n): RowGroup<Row>[] {\n const field = options.field ?? (view.definition.groupBy as string | undefined);\n if (!field) return rows.length ? [Object.freeze({ key: \"\", value: null, label: \"\", rows: Object.freeze([...rows]) })] : [];\n const groups = new Map<string, { key: string; value: unknown; label: string; rows: Row[] }>();\n for (const row of rows) {\n const value = row[field];\n const key = isEmpty(value) ? \"\" : String(value);\n let group = groups.get(key);\n if (!group) {\n const label = isEmpty(value) ? (options.emptyLabel ?? `No ${view.label(field).toLowerCase()}`) : view.valueLabel(field, value);\n group = { key, value: isEmpty(value) ? null : value, label, rows: [] };\n groups.set(key, group);\n }\n group.rows.push(row);\n }\n return [...groups.values()].map((g) => Object.freeze({ ...g, rows: Object.freeze(g.rows) }));\n}\n\n/**\n * The view's `totals` over some rows (a group's, or every loaded row for a footer): per field, its\n * sum, average, lowest, highest or count, `null` when no row has a number. Fields the view names\n * no total for are left out.\n *\n * ```ts\n * groupTotals(tasksView, group.rows); // { estimate_hours: 12.5 }\n * ```\n *\n * @stability Beta\n */\nexport function groupTotals<Row extends DataRow>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract; Row is what matters here\n view: ResourceView<ResourceContract<any>, Row>,\n rows: readonly Row[],\n): Readonly<Record<string, number | null>> {\n const out: Record<string, number | null> = {};\n for (const [field, fn] of Object.entries((view.definition.totals ?? {}) as Readonly<Record<string, string>>)) {\n if (fn === \"count\") {\n out[field] = rows.filter((r) => !isEmpty(r[field])).length;\n continue;\n }\n const numbers = rows.map((r) => (isEmpty(r[field]) ? NaN : Number(r[field]))).filter((n) => Number.isFinite(n));\n if (!numbers.length) {\n out[field] = null;\n continue;\n }\n const sum = numbers.reduce((a, b) => a + b, 0);\n out[field] = fn === \"sum\" ? sum : fn === \"avg\" ? sum / numbers.length : fn === \"min\" ? Math.min(...numbers) : Math.max(...numbers);\n }\n return Object.freeze(out);\n}\n","// Tree mode: nested records drawn from a flat list. Each row names its parent; the tree is built\n// from the data, never from nested input, so caching and writes stay the flat list's. No React:\n// genesis-ui's `useResourceView` holds the state and draws it, and a native list can reuse it.\n// docs/RESOURCE-VIEW.md, \"Tree mode\".\n\n/**\n * A screen's `tree` (`<ResourceView tree={{ getParentId }} />`): rows nest under the row\n * `getParentId` names. Client-side data only: every row is loaded, and children are never\n * fetched on expand.\n */\nexport interface ResourceTree<T> {\n /** The parent row's key (the same text as the row key), or `null` / `undefined` / `\"\"` for a root. */\n getParentId: (row: T) => string | null | undefined;\n /**\n * Which rows start open (uncontrolled): `true` every parent, a number the parents shallower\n * than that depth (`1` opens the roots), `false` none. Default `false`.\n */\n defaultExpanded?: boolean | number;\n /** The open rows by key, controlled. Leave unset and the screen keeps its own. */\n expanded?: ReadonlySet<string>;\n /** Called with the next open set whenever a row opens or closes. */\n onExpandedChange?: (expanded: Set<string>) => void;\n /** Selecting a row selects its descendants too, and clearing it clears them. Default `false`. */\n cascadeSelect?: boolean;\n}\n\n/** How to read the tree out of flat rows. */\nexport interface TreeOptions<T> {\n /** A row's own id. */\n getId: (row: T) => string;\n /** The parent's id; `null`, `undefined` or `\"\"` for a root. A parent that isn't loaded makes a root too. */\n getParentId: (row: T) => string | null | undefined;\n /**\n * Which nodes are open: their ids, or `\"all\"`. A closed node's descendants aren't returned.\n * While `match` is set, every ancestor of a match is open regardless, so each match shows.\n */\n expanded: ReadonlySet<string> | \"all\";\n /**\n * The filter, when one is active: rows that match it, and their ancestors (so a match keeps its\n * context), are kept; everything else is left out. Undefined: no filter, every row is kept.\n */\n match?: (row: T) => boolean;\n /**\n * The sort, applied within each set of siblings (stable: ties keep the rows' order). Without it,\n * siblings keep the rows' order, so a list sorted beforehand is sorted within siblings too.\n */\n compare?: (a: T, b: T) => number;\n}\n\n/** One visible row of the tree, in display order. */\nexport interface TreeNode<T> {\n row: T;\n id: string;\n /** The parent's id as drawn: `null` for a root (a missing parent, or a broken cycle, counts as none). */\n parentId: string | null;\n /** 0 for a root. */\n depth: number;\n /** Whether it has children among the kept rows (so a toggle makes sense). */\n hasChildren: boolean;\n /** Whether it is open. Always false without children. */\n expanded: boolean;\n /** False for an ancestor kept only as a match's context; true otherwise, and always true without a filter. */\n matched: boolean;\n /** 1-based position among its kept siblings, and how many there are (`aria-posinset`, `aria-setsize`). */\n position: number;\n siblings: number;\n}\n\n/** What {@link treeRows} returns. */\nexport interface TreeResult<T> {\n /** The rows to draw, in order: each parent before its children, siblings in input order. */\n visible: TreeNode<T>[];\n /** Every kept row's node by id, collapsed ones included. */\n nodes: ReadonlyMap<string, TreeNode<T>>;\n /** Every descendant of a node among the kept rows, depth-first, collapsed or not. */\n descendants: (id: string) => string[];\n /** The ids of every kept node that has children: \"expand all\". */\n parents: () => string[];\n}\n\nconst rootish = (parent: string | null | undefined): parent is null | undefined | \"\" => parent == null || parent === \"\";\n\n/**\n * Build the tree from flat rows. Siblings are sorted by `compare`, else keep the rows' order, so\n * either way the sort applies within each set of siblings. A row whose parent isn't among `rows` is a root,\n * and so is a row whose parent would close a cycle (each cycle loses one link). Duplicate ids keep\n * the first row.\n */\nexport function treeRows<T>(rows: readonly T[], options: TreeOptions<T>): TreeResult<T> {\n const { getId, getParentId, expanded, match, compare } = options;\n const byId = new Map<string, T>();\n const order: string[] = [];\n for (const row of rows) {\n const id = getId(row);\n if (byId.has(id)) continue;\n byId.set(id, row);\n order.push(id);\n }\n\n // The parent each row hangs from: absent, unloaded or cyclic parents make a root.\n const parentOf = new Map<string, string | null>();\n const resolving = new Set<string>();\n const resolve = (id: string): string | null => {\n if (parentOf.has(id)) return parentOf.get(id)!;\n const raw = getParentId(byId.get(id)!);\n let parent: string | null = rootish(raw) || raw === id || !byId.has(raw) ? null : raw;\n if (parent !== null) {\n resolving.add(id);\n // Walk up: meeting a row still being resolved means a cycle; break it here.\n if (resolving.has(parent)) parent = null;\n else resolve(parent);\n resolving.delete(id);\n }\n parentOf.set(id, parent);\n return parent;\n };\n for (const id of order) resolve(id);\n // A cycle's other members may have resolved through the broken one before it broke: recheck\n // that every chain ends at a root.\n for (const id of order) {\n const seen = new Set<string>([id]);\n let at = parentOf.get(id) ?? null;\n while (at !== null && !seen.has(at)) {\n seen.add(at);\n at = parentOf.get(at) ?? null;\n }\n if (at !== null) parentOf.set(id, null);\n }\n\n // What the filter keeps: matches, and every ancestor of one.\n let kept: Set<string> | null = null;\n const matched = new Set<string>();\n if (match) {\n kept = new Set();\n for (const id of order) {\n if (!match(byId.get(id)!)) continue;\n matched.add(id);\n for (let at: string | null = id; at !== null && !kept.has(at); at = parentOf.get(at) ?? null) kept.add(at);\n }\n }\n\n const children = new Map<string | null, string[]>();\n for (const id of order) {\n if (kept && !kept.has(id)) continue;\n const parent = parentOf.get(id) ?? null;\n const list = children.get(parent);\n if (list) list.push(id);\n else children.set(parent, [id]);\n }\n // Sort within siblings only: a child never leaves its parent. Array sort is stable.\n if (compare) for (const list of children.values()) list.sort((a, b) => compare(byId.get(a)!, byId.get(b)!));\n\n const isOpen = (id: string) => (match ? true : expanded === \"all\" || expanded.has(id));\n const nodes = new Map<string, TreeNode<T>>();\n const visible: TreeNode<T>[] = [];\n const visit = (parent: string | null, depth: number, shown: boolean) => {\n const ids = children.get(parent) ?? [];\n ids.forEach((id, index) => {\n const hasChildren = (children.get(id)?.length ?? 0) > 0;\n const open = hasChildren && isOpen(id);\n const node: TreeNode<T> = {\n row: byId.get(id)!,\n id,\n parentId: parent,\n depth,\n hasChildren,\n expanded: open,\n matched: match ? matched.has(id) : true,\n position: index + 1,\n siblings: ids.length,\n };\n nodes.set(id, node);\n if (shown) visible.push(node);\n visit(id, depth + 1, shown && open);\n });\n };\n visit(null, 0, true);\n\n const descendants = (id: string): string[] => {\n const out: string[] = [];\n const walk = (at: string) => {\n for (const child of children.get(at) ?? []) {\n out.push(child);\n walk(child);\n }\n };\n walk(id);\n return out;\n };\n const parents = () => [...nodes.values()].filter((n) => n.hasChildren).map((n) => n.id);\n return { visible, nodes, descendants, parents };\n}\n\n/**\n * The open ids a tree starts with: `true` opens every parent, a number opens parents shallower\n * than that depth (`1` opens the roots), `false` or nothing opens none.\n */\nexport function initialExpanded<T>(rows: readonly T[], options: Omit<TreeOptions<T>, \"expanded\" | \"match\">, open: boolean | number | undefined): Set<string> {\n if (!open) return new Set();\n const tree = treeRows(rows, { ...options, expanded: \"all\" });\n const depth = open === true ? Infinity : open;\n return new Set(tree.parents().filter((id) => tree.nodes.get(id)!.depth < depth));\n}\n\n/** The open set with `id` opened or closed: a new set, or the same one when nothing changes. */\nexport function setExpanded(expanded: ReadonlySet<string>, id: string, open: boolean): ReadonlySet<string> {\n if (expanded.has(id) === open) return expanded;\n const next = new Set(expanded);\n if (open) next.add(id);\n else next.delete(id);\n return next;\n}\n\n/**\n * The selection after toggling `id` with cascade: the node and every descendant take the node's\n * new state. Without cascade, use a plain toggle; selection never cascades by default.\n */\nexport function cascadeSelection(selected: ReadonlySet<string>, id: string, descendants: readonly string[]): Set<string> {\n const next = new Set(selected);\n const on = !selected.has(id);\n for (const at of [id, ...descendants]) {\n if (on) next.add(at);\n else next.delete(at);\n }\n return next;\n}\n","// defineRecordView: one record's screen from a view (docs/RESOURCE-VIEW.md, \"RecordView\").\n// A header (the row's summary and the view's actions), sections (a child list, a few settings, or\n// a slot the screen fills) and readiness checks. Checked once and frozen like defineView, with no\n// React, so web and native draw the same screen from it.\n\nimport { encodeRecordKey } from \"../schema/keys\";\nimport type { Identifier } from \"../provider/types\";\nimport { readinessOf, type Readiness } from \"../resource\";\nimport type { DataRow, FieldSchema, ResourceContract } from \"../schema/types\";\nimport { ViewDefinitionError } from \"./errors\";\nimport type { Viewer } from \"../viewer\";\nimport type { Allowed, FieldNameOf, ResolvedFormField, ResourceView, RowOf, ViewTone } from \"./types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- a child list can be any resource\ntype AnyView = ResourceView<ResourceContract<any>, any>;\n\n/** Equality filters for a child list, sent to the server: `{ brand_id: brand.id }`. `null` is \"is empty\". */\nexport type RecordViewFilter = Readonly<Record<string, string | number | boolean | null>>;\n\ninterface SectionBase {\n /** Unique in the record view; the screen's route segment or slot key. */\n id: string;\n label: string;\n}\n\n/** A child list: another view, filtered by this record. */\nexport interface RecordViewListSection<Row extends DataRow = DataRow> extends SectionBase {\n list: { view: AnyView; filter: (row: Row) => RecordViewFilter };\n settings?: never;\n}\n\n/** A few of this record's own fields, edited in place. Each must be in `view.writable(\"edit\")`. */\nexport interface RecordViewSettingsSection<Name extends string = string> extends SectionBase {\n settings: readonly Name[];\n list?: never;\n}\n\n/** A section the screen fills itself, through a slot keyed by `id`. */\nexport interface RecordViewSlotSection extends SectionBase {\n list?: never;\n settings?: never;\n}\n\nexport type RecordViewSection<Row extends DataRow = DataRow, Name extends string = string> =\n | RecordViewListSection<Row>\n | RecordViewSettingsSection<Name>\n | RecordViewSlotSection;\n\n/** One readiness check: \"Has a logo\", ok or not, and why not. */\nexport interface RecordViewReadinessItem {\n /** A stable key for the check; default its position and title. */\n id?: string;\n title: string;\n ok: boolean;\n reason?: string;\n /** Genesis chip tones only. Default `success` when ok, `warning` when not. */\n tone?: ViewTone;\n}\n\n/**\n * A record page template (ADR 0021): `standard` (a header with the summary and actions, then the\n * sections) or `document` (a cover, an icon, a large title, the properties, then the body, like\n * a page in a notes app).\n *\n * @stability Beta\n */\nexport type RecordPageTemplate = \"standard\" | \"document\";\n\n/**\n * Where a `document` template finds its parts, by field name. Each is optional; a part whose\n * field is empty on a row isn't drawn.\n *\n * @stability Beta\n */\nexport interface RecordViewDocument<Name extends string = string> {\n /** A text field holding the cover image's URL. */\n cover?: Name;\n /** A text field holding the icon: an emoji or a short text, or an image's URL. */\n icon?: Name;\n /** The fields listed under the title, as label and value, in order. */\n properties?: readonly Name[];\n /** The long text below the properties. */\n body?: Name;\n}\n\n/** What `defineRecordView` accepts. */\nexport interface RecordViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {\n /** The view actions the header offers, by name, in order. Default: every view action. */\n header?: { actions?: readonly string[] };\n /** The sections. A `document` template may have none (the document is the page). */\n sections: readonly RecordViewSection<Row, FieldNameOf<C>>[];\n readiness?: (row: Row) => readonly RecordViewReadinessItem[];\n /** The record page template. Default `standard`, the page as before. */\n template?: RecordPageTemplate;\n /** With `template: \"document\"`: the fields its cover, icon, properties and body show. */\n document?: RecordViewDocument<FieldNameOf<C>>;\n}\n\n/** A section as a renderer draws it. */\nexport type ResolvedRecordViewSection =\n | { readonly id: string; readonly label: string; readonly kind: \"list\"; readonly view: AnyView }\n | { readonly id: string; readonly label: string; readonly kind: \"settings\"; readonly settings: readonly string[] }\n | { readonly id: string; readonly label: string; readonly kind: \"slot\" };\n\n/** A header action with whether this row allows it. */\nexport interface RecordViewHeaderAction {\n readonly name: string;\n readonly label: string;\n readonly confirm?: string;\n readonly description?: string;\n readonly destructive?: boolean;\n /** `true`, or the view guard's reason. Only narrows what the server allows. */\n readonly allowed: Allowed;\n}\n\n/** The header for one row: the view's summary plus the header's actions. */\nexport interface RecordViewHeader {\n readonly title: string;\n readonly subtitle?: string;\n readonly chips: readonly { label: string; tone?: ViewTone }[];\n readonly actions: readonly RecordViewHeaderAction[];\n}\n\n/** What a screen and its provider add to the header: they only narrow the view's guards. */\nexport interface RecordViewHeaderOptions<Row extends DataRow = DataRow> {\n /** The screen's own rule: `false` hides the action, a sentence refuses it with that reason. */\n can?: (action: string, row: Row) => Allowed | boolean;\n /** Whether anything can run actions here (the screen's `onAction`, or the provider's `runAction`). `false` hides them all. */\n runnable?: boolean;\n /** The action names the provider reports serving (`ResourceSchema.actions`), when it reports them. Others are hidden. */\n served?: readonly string[];\n /** Who is looking (`useViewer()`), for the view's action guards. Without it they get no one. */\n viewer?: Viewer;\n}\n\n/** A readiness check with its tone resolved. */\nexport interface ResolvedReadinessItem {\n /** Stable, for list keys: the check's `id`, or its position and title. */\n readonly key: string;\n readonly title: string;\n readonly ok: boolean;\n readonly reason?: string;\n readonly tone: ViewTone;\n}\n\n/**\n * Any record view, whatever its contract: the type a view's `recordView` returns. Name it on that\n * function (`recordView: (): AnyRecordView => brandRecordView`), since the record view is defined\n * from the view and TypeScript can't infer one from the other.\n *\n * @stability Beta\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract and row, by design\nexport type AnyRecordView = RecordView<ResourceContract<any>, any>;\n\n/** What `defineRecordView` returns: frozen, with pure helpers for the renderers. */\nexport interface RecordView<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> {\n readonly view: ResourceView<C, Row>;\n readonly sections: readonly ResolvedRecordViewSection[];\n /** The header's action names, in order. */\n readonly headerActions: readonly string[];\n readonly hasReadiness: boolean;\n /** The record page template: `standard` unless the definition says `document`. */\n readonly template: RecordPageTemplate;\n /** The document template's fields (frozen); empty for `standard`. */\n readonly document: Readonly<RecordViewDocument>;\n section(id: string): ResolvedRecordViewSection | undefined;\n /** The record's address for the provider: its key fields (`keyFields`), composite keys encoded. */\n recordId(row: Row): Identifier;\n /**\n * Why settings can't be saved for this row and viewer: the view's `can(\"update\", row, viewer)`\n * reason, or `null` when they can. Renderers then show the settings read-only with the reason.\n * Without a viewer the guard gets no one, so one that needs the viewer locks them.\n */\n settingsLocked(row: Row, viewer?: Viewer): string | null;\n headerFor(row: Row, options?: RecordViewHeaderOptions<Row>): RecordViewHeader;\n /**\n * Settings fields as the view's form resolves them (`view.form(\"edit\")`), in the order listed:\n * one section's, or every settings section's without an id.\n */\n settingsFields(sectionId?: string): readonly ResolvedFormField[];\n /** Only the section's listed keys that `values` has: what a save sends. */\n settingsPatch(sectionId: string, values: Readonly<Record<string, unknown>>): Record<string, unknown>;\n /**\n * A list section's filter for this row. In development, a filter with no key, or a value that\n * isn't a string, number, boolean or null, throws: it would show every child row.\n */\n listFilter(sectionId: string, row: Row): RecordViewFilter;\n /** The readiness checks for this row, tones resolved; empty without `readiness`. */\n readinessFor(row: Row): readonly ResolvedReadinessItem[];\n /**\n * The checks in one chip's terms (genesis-core/resource's `readinessOf`): an unmet `danger`\n * check is a problem, any other unmet check one to look at. `null` without `readiness`. Draw\n * it with `readinessChip`.\n */\n readinessSummary(row: Row): Readiness | null;\n}\n\nconst WORKSPACE = Symbol.for(\"genesis.resource-workspace\");\n/** The reason shown when a guard refuses without one. */\nconst REFUSED = \"This isn't allowed.\";\nconst TONES: ReadonlySet<string> = new Set<ViewTone>([\"success\", \"warning\", \"danger\", \"info\", \"muted\"]);\nconst SECTION_KEYS: ReadonlySet<string> = new Set([\"id\", \"label\", \"list\", \"settings\"]);\nconst DOCUMENT_KEYS: ReadonlySet<string> = new Set([\"cover\", \"icon\", \"properties\", \"body\"]);\nconst dev = () => process.env.NODE_ENV !== \"production\";\n\n/** Why a field can't be a setting edited in place, or null when it can. */\nfunction unsettable(field: FieldSchema | undefined): string | null {\n if (!field) return null;\n const facts = field as FieldSchema & { sensitive?: boolean };\n if (field.type === \"json\") return \"is JSON\";\n if (field.array) return \"is a list\";\n if (field.references || field.type === \"relation\") return \"is a link\";\n if (facts.sensitive) return \"is sensitive\";\n return null;\n}\n\n/**\n * Whether two values are the same as a settings form holds them: 2 and \"2\", and null, undefined\n * and \"\", are the same. A settings section compares an edit with the row through it, so an edit\n * back to the stored value isn't a change (web and native RecordView).\n */\nexport function sameFormValue(a: unknown, b: unknown): boolean {\n const text = (v: unknown) => (v === null || v === undefined ? \"\" : Array.isArray(v) ? v.join(\",\") : String(v));\n return text(a) === text(b);\n}\n\n/** Whether a value is a record view (`defineRecordView`'s result). */\nexport function isRecordView(value: unknown): value is RecordView {\n return typeof value === \"object\" && value !== null && (value as Record<symbol, unknown>)[WORKSPACE] === true;\n}\n\nfunction isView(value: unknown): value is AnyView {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as AnyView).columns === \"function\" &&\n typeof (value as AnyView).resource === \"string\"\n );\n}\n\n/**\n * One record's screen from its view:\n *\n * ```ts\n * export const brandRecordView = defineRecordView(brandsView, {\n * header: { actions: [\"archive\"] },\n * sections: [\n * { id: \"products\", label: \"Products\", list: { view: productsView, filter: (b) => ({ brand_id: b.id }) } },\n * { id: \"settings\", label: \"Settings\", settings: [\"name\", \"website\"] },\n * { id: \"activity\", label: \"Activity\" }, // the screen fills it\n * ],\n * readiness: (b) => [{ title: \"Has a website\", ok: !!b.website, reason: \"Add the website.\" }],\n * });\n * ```\n *\n * Throws {@link ViewDefinitionError} for a settings field the view can't write, a header action\n * the view doesn't define, a repeated section id, or a section that holds another record view.\n */\nexport function defineRecordView<C extends ResourceContract, Row extends DataRow = RowOf<C>>(\n view: ResourceView<C, Row>,\n definition: RecordViewDefinition<C, Row>,\n): RecordView<C, Row> {\n const where = `${view.resource} record view`;\n const problems: string[] = [];\n const writable = new Set(view.writable(\"edit\"));\n const actionNames = new Set(view.actions().map((a) => a.name));\n\n // ── Sections ─────────────────────────────────────────────────────────\n const input = Array.isArray(definition?.sections) ? definition.sections : [];\n const template: RecordPageTemplate = definition?.template ?? \"standard\";\n if (template !== \"standard\" && template !== \"document\") problems.push(`template is \"standard\" or \"document\", not ${JSON.stringify(template)}`);\n if (!Array.isArray(definition?.sections)) problems.push(\"sections isn't a list\");\n else if (input.length === 0 && template !== \"document\") problems.push(\"sections is empty\");\n const ids = new Set<string>();\n const settingsSeen = new Set<string>();\n const sections: ResolvedRecordViewSection[] = [];\n const filters = new Map<string, (row: Row) => RecordViewFilter>();\n input.forEach((raw, i) => {\n const at = `sections[${i}]`;\n if (!raw || typeof raw !== \"object\") {\n problems.push(`${at} isn't a section`);\n return;\n }\n const s = raw as RecordViewSection<Row> & Record<string, unknown>;\n const name = typeof s.id === \"string\" && s.id.trim() ? s.id : undefined;\n if (!name) problems.push(`${at} has no id`);\n else if (ids.has(name)) problems.push(`sections lists \"${name}\" twice`);\n else ids.add(name);\n const label = `sections.${name ?? i}`;\n if (typeof s.label !== \"string\" || !s.label.trim()) problems.push(`${label} has no label`);\n if (isRecordView(s) || \"sections\" in s || \"workspace\" in s) {\n problems.push(`${label} holds a record view; sections don't nest`);\n return;\n }\n const unknown = Object.keys(s).filter((k) => !SECTION_KEYS.has(k));\n if (unknown.length) problems.push(`${label} has ${unknown.map((k) => `\"${k}\"`).join(\", \")}, which isn't a section key (id, label, list, settings)`);\n const hasList = s.list !== undefined;\n const hasSettings = s.settings !== undefined;\n if (hasList && hasSettings) {\n problems.push(`${label} has both list and settings; a section has one`);\n return;\n }\n if (hasList) {\n const list = s.list as { view?: unknown; filter?: unknown };\n if (isRecordView(list?.view)) problems.push(`${label}.list.view is a record view; sections don't nest`);\n else if (!isView(list?.view)) problems.push(`${label}.list.view isn't a view`);\n if (typeof list?.filter !== \"function\") problems.push(`${label}.list.filter isn't a function`);\n if (name && isView(list?.view) && !isRecordView(list.view) && typeof list.filter === \"function\") {\n filters.set(name, list.filter as (row: Row) => RecordViewFilter);\n sections.push(Object.freeze({ id: name, label: s.label, kind: \"list\", view: list.view }));\n }\n return;\n }\n if (hasSettings) {\n if (!Array.isArray(s.settings)) {\n problems.push(`${label}.settings isn't a list`);\n return;\n }\n if (s.settings.length === 0) problems.push(`${label}.settings lists no fields`);\n for (const field of s.settings as readonly string[]) {\n const why = unsettable(view.field(field));\n if (why) problems.push(`${label}.settings names \"${field}\", which ${why}; it needs an editor of its own`);\n else if (!writable.has(field)) problems.push(`${label}.settings names \"${field}\", which the view can't write on edit`);\n if (settingsSeen.has(field)) problems.push(`settings lists \"${field}\" twice`);\n settingsSeen.add(field);\n }\n if (name) sections.push(Object.freeze({ id: name, label: s.label, kind: \"settings\", settings: Object.freeze((s.settings as readonly string[]).map(String)) }));\n return;\n }\n if (name) sections.push(Object.freeze({ id: name, label: s.label, kind: \"slot\" }));\n });\n\n // ── Header and readiness ─────────────────────────────────────────────\n const requested = definition?.header?.actions;\n if (requested !== undefined && !Array.isArray(requested)) problems.push(\"header.actions isn't a list\");\n const headerActions = Object.freeze(\n Array.isArray(requested) ? [...requested] : view.actions().map((a) => a.name),\n );\n const headerSeen = new Set<string>();\n for (const name of headerActions) {\n if (!actionNames.has(name)) problems.push(`header.actions names \"${name}\", which isn't a view action`);\n if (headerSeen.has(name)) problems.push(`header.actions lists \"${name}\" twice`);\n headerSeen.add(name);\n }\n if (definition?.readiness !== undefined && typeof definition.readiness !== \"function\") {\n problems.push(\"readiness isn't a function\");\n }\n // ── The document template ────────────────────────────────────────────\n const doc = definition?.document;\n if (doc !== undefined) {\n if (!doc || typeof doc !== \"object\" || Array.isArray(doc)) problems.push(\"document isn't an object\");\n else {\n if (template !== \"document\") problems.push(`document is set, but template isn't \"document\"`);\n for (const key of Object.keys(doc)) if (!DOCUMENT_KEYS.has(key)) problems.push(`document.${key} isn't a document setting (cover, icon, properties, body)`);\n for (const key of [\"cover\", \"icon\", \"body\"] as const) {\n const name = doc[key];\n if (name === undefined) continue;\n const field = view.field(String(name));\n if (!field) problems.push(`document.${key} names \"${String(name)}\", which isn't a field`);\n else if (field.type !== \"string\" || field.array) problems.push(`document.${key} \"${String(name)}\" is a ${field.array ? \"list\" : field.type}, not a text field`);\n }\n if (doc.properties !== undefined) {\n if (!Array.isArray(doc.properties)) problems.push(\"document.properties isn't a list\");\n else for (const name of doc.properties) if (!view.field(String(name))) problems.push(`document.properties names \"${String(name)}\", which isn't a field`);\n }\n }\n }\n if (problems.length) throw new ViewDefinitionError(where, problems);\n const document: Readonly<RecordViewDocument> = Object.freeze(\n doc ? { ...doc, ...(doc.properties ? { properties: Object.freeze([...doc.properties].map(String)) } : {}) } : {},\n );\n\n const frozenSections = Object.freeze(sections);\n const byId = new Map(frozenSections.map((s) => [s.id, s]));\n const actionByName = new Map(view.actions().map((a) => [a.name, a]));\n const readiness = definition.readiness;\n\n const settingsOf = (sectionId: string): readonly string[] => {\n const s = byId.get(sectionId);\n if (!s || s.kind !== \"settings\") throw new ViewDefinitionError(where, [`no settings section \"${sectionId}\"`]);\n return s.settings;\n };\n const resolvedSettings = new Map<string, readonly ResolvedFormField[]>();\n const settingsFields = (sectionId?: string): readonly ResolvedFormField[] => {\n const key = sectionId ?? \"\";\n const cached = resolvedSettings.get(key);\n if (cached) return cached;\n const names =\n sectionId === undefined\n ? frozenSections.flatMap((s) => (s.kind === \"settings\" ? s.settings : []))\n : settingsOf(sectionId);\n const form = new Map(view.form(\"edit\").map((f) => [f.field.name, f]));\n const out = Object.freeze(names.map((n) => form.get(n)).filter((f): f is ResolvedFormField => f !== undefined));\n resolvedSettings.set(key, out);\n return out;\n };\n\n const headerFor = (row: Row, options: RecordViewHeaderOptions<Row> = {}): RecordViewHeader => {\n const summary = view.summary(row);\n const served = options.served ? new Set(options.served) : null;\n const actions: RecordViewHeaderAction[] = [];\n if (options.runnable !== false) {\n for (const name of headerActions) {\n if (served && !served.has(name)) continue;\n const own = options.can?.(name, row);\n if (own === false) continue;\n // Guards only narrow: the screen's refusal wins, then the view's.\n const allowed: Allowed = typeof own === \"string\" ? own || REFUSED : view.canAction(name, row, options.viewer);\n actions.push(Object.freeze({ ...actionByName.get(name)!, allowed }));\n }\n }\n return Object.freeze({\n title: summary.title,\n ...(summary.subtitle !== undefined ? { subtitle: summary.subtitle } : {}),\n chips: Object.freeze([...(summary.chips ?? [])]),\n actions: Object.freeze(actions),\n });\n };\n\n const readinessFor = (row: Row): readonly ResolvedReadinessItem[] => {\n if (!readiness) return Object.freeze([]);\n return Object.freeze(\n readiness(row).map((item, i) => {\n let tone = item.tone ?? (item.ok ? \"success\" : \"warning\");\n if (!TONES.has(tone)) {\n if (dev()) console.warn(`[genesis-core] ${where}: readiness \"${item.title}\" has tone \"${String(tone)}\", which isn't a chip tone; showing it muted.`);\n tone = \"muted\";\n }\n return Object.freeze({\n key: item.id ?? `${i}:${item.title}`,\n title: item.title,\n ok: Boolean(item.ok),\n ...(item.reason !== undefined ? { reason: item.reason } : {}),\n tone,\n });\n }),\n );\n };\n\n const readinessSummary = (row: Row): Readiness | null =>\n readiness\n ? readinessOf(\n readinessFor(row)\n .filter((r) => !r.ok)\n .map((r) => ({ level: r.tone === \"danger\" ? (\"error\" as const) : (\"warning\" as const) })),\n )\n : null;\n\n return Object.freeze({\n [WORKSPACE]: true,\n view,\n sections: frozenSections,\n headerActions,\n hasReadiness: Boolean(readiness),\n template,\n document,\n section: (id: string) => byId.get(id),\n recordId: (row: Row) => encodeRecordKey(view.contract, row),\n settingsLocked: (row: Row, viewer?: Viewer) => {\n const allowed = view.can(\"update\", row, viewer);\n return allowed === true ? null : typeof allowed === \"string\" && allowed.trim() ? allowed : REFUSED;\n },\n headerFor,\n settingsFields,\n settingsPatch: (sectionId: string, values: Readonly<Record<string, unknown>>) => {\n const patch: Record<string, unknown> = {};\n for (const name of settingsOf(sectionId)) if (Object.hasOwn(values, name)) patch[name] = values[name];\n return patch;\n },\n listFilter: (sectionId: string, row: Row) => {\n const filter = filters.get(sectionId);\n if (!filter) throw new ViewDefinitionError(where, [`no list section \"${sectionId}\"`]);\n const out = filter(row);\n if (dev()) {\n const entries = out && typeof out === \"object\" ? Object.entries(out) : [];\n const bad = entries.filter(([, v]) => !(v === null || typeof v === \"string\" || typeof v === \"number\" || typeof v === \"boolean\"));\n if (entries.length === 0 || bad.length) {\n throw new ViewDefinitionError(where, [\n entries.length === 0\n ? `sections.${sectionId}.list.filter gave no keys, which would list every row`\n : `sections.${sectionId}.list.filter gives ${bad.map(([k]) => `\"${k}\"`).join(\", \")} no single value`,\n ]);\n }\n }\n return Object.freeze({ ...out });\n },\n readinessFor,\n readinessSummary,\n }) as RecordView<C, Row>;\n}\n\n// The names before record views were called record views (\"workspace\" now means where the viewer\n// is working: docs/adr/0004-workspaces.md). Kept for one minor release.\n\n/** @deprecated Renamed `defineRecordView`. Removed in the next major. @stability Deprecated */\nexport const defineWorkspace = defineRecordView;\n/** @deprecated Renamed `isRecordView`. Removed in the next major. @stability Deprecated */\nexport const isWorkspace = isRecordView;\n/** @deprecated Renamed `RecordView`. Removed in the next major. @stability Deprecated */\nexport type ResourceWorkspace<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> = RecordView<C, Row>;\n/** @deprecated Renamed `RecordViewDefinition`. */\nexport type WorkspaceDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> = RecordViewDefinition<C, Row>;\n/** @deprecated Renamed `RecordViewSection`. */\nexport type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = string> = RecordViewSection<Row, Name>;\n/** @deprecated Renamed `RecordViewHeaderAction`. */\nexport type WorkspaceHeaderAction = RecordViewHeaderAction;\n","// defineWidget: a small tile on a dashboard or a record page's sidebar, fed by a view (ADR 0023).\n//\n// A widget is data, with no React: which view it reads (and so which resource, scope, preset\n// and permissions), what it needs from it (a total, or a few rows), its label and how its value\n// reads. genesis-ui's `<Widget>` draws it; a phone draws the same definition. The pure helpers\n// here (`resolveWidgetRequest`, `resolveStreak`, `resolveChartSeries`, `toWidgetText`) are what\n// both platforms compute, so they can't drift.\n\nimport { addDays, dayIn, deviceTimeZone, isDay, startOfWeek, type Day } from \"../dates\";\nimport type { ResourceScope } from \"../hooks/viewer-scope\";\nimport type { AggregateMetric, AggregateParams, FilterParam, SortParam } from \"../provider/types\";\nimport { toAggregateValues } from \"../provider/aggregate\";\nimport type { DataRow, ResourceContract } from \"../schema/types\";\nimport { ViewDefinitionError } from \"./errors\";\nimport { filterParams } from \"./link\";\nimport { scopeFilter } from \"./scope\";\nimport type { Allowed, ResourceView, Viewer } from \"./types\";\n\n/** The built-in kinds of widget. */\nexport type WidgetKind = \"number\" | \"progress\" | \"streak\" | \"list\" | \"chart\";\n\n/** How a widget's number reads: plain, short (`1.2k`), a percent of 1, a currency, or your own words. */\nexport type WidgetFormat =\n | \"number\"\n | \"compact\"\n | \"percent\"\n | { currency: string; maximumFractionDigits?: number }\n | ((value: number) => string);\n\ntype Scalar = string | number | boolean | null;\n/** Values a widget narrows its view by, as a screen's `filter`: `{ status: \"open\" }`, `{ owner_id: [a, b] }`. */\nexport type WidgetFilter = Readonly<Record<string, Scalar | readonly (string | number)[]>>;\n\n/** What every kind of widget says. */\nexport interface WidgetBase<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> {\n /** Stable, unique on its dashboard: a key, a test id, a saved layout's entry. */\n id: string;\n /** What the tile is called (\"Open deals\"). */\n label: string;\n /** The view it reads: its resource, scope keys, presets, fields and who may read them. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract's view\n view: ResourceView<C, Row & any>;\n /** One of the view's presets: its filter narrows the rows, as a tab would. */\n preset?: string;\n /** More values to narrow by, over the scope and the preset. */\n filter?: WidgetFilter;\n /** A short line under the value (\"this quarter\"). */\n description?: string;\n /** Where the tile goes when pressed: the full view, usually. */\n href?: string;\n /**\n * Whether this viewer sees the tile: `true`, or the reason not. Only narrows; the view's own\n * field permissions (a field the viewer can't read) hide it too, and row security decides\n * which rows any total covers.\n */\n can?: (viewer: Viewer | undefined) => Allowed;\n /** Keep the tile current with changes made elsewhere (`DataProvider.subscribe`). Default true. */\n live?: boolean;\n}\n\n/** A number: a count, or the sum, average, lowest or highest of a field. */\nexport interface NumberWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"number\";\n /** What to total. Default `{ fn: \"count\" }`. */\n metric?: AggregateMetric;\n format?: WidgetFormat;\n}\n\n/** Progress toward a goal: a total over a fixed number, or over another total (done of all). */\nexport interface ProgressWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"progress\";\n /** What counts as done. Default `{ fn: \"count\" }` over the widget's rows. */\n metric?: AggregateMetric;\n /**\n * The goal: a number, or a total over the view's scope and `goalFilter` (not the preset or\n * `filter`): `{ fn: \"count\" }` with the preset \"done\" makes \"done of all\".\n */\n goal: number | AggregateMetric;\n /** Narrows the goal's rows when it is a total. */\n goalFilter?: WidgetFilter;\n format?: WidgetFormat;\n}\n\n/** A streak: how many days (or weeks) in a row, up to today, have at least one row. */\nexport interface StreakWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"streak\";\n /** The date (or timestamp) field a row counts on. */\n dateField: string;\n /** Default `day`. Weeks start on Monday. */\n unit?: \"day\" | \"week\";\n /** The zone days are counted in. Default the device's. */\n timeZone?: string;\n /** The most recent rows read to count it. Default 400. */\n limit?: number;\n}\n\n/** A short list: the first few rows, as the view names them. */\nexport interface ListWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"list\";\n /** Rows shown. Default 5, at most 50. */\n limit?: number;\n /** Their order. Default the view's `orderBy`. */\n sort?: SortParam;\n}\n\n/** A chart: one bar (or point) per value of a field, with a count or a total each. */\nexport interface ChartWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"chart\";\n /** The field whose values are the bars. */\n groupBy: string;\n /** Each bar's height. Default `{ fn: \"count\" }`. */\n metric?: AggregateMetric;\n /** Default `bar`. */\n chart?: \"bar\" | \"line\";\n /** The most rows read to draw it. Default 1000. */\n limit?: number;\n format?: WidgetFormat;\n}\n\n/** What `defineWidget` accepts. */\nexport type WidgetDefinition<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> =\n | NumberWidget<C, Row>\n | ProgressWidget<C, Row>\n | StreakWidget<C, Row>\n | ListWidget<C, Row>\n | ChartWidget<C, Row>;\n\n/** A checked, frozen widget. */\nexport type DefinedWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> = Readonly<WidgetDefinition<C, Row>> & {\n readonly __widget: true;\n};\n\nconst ID = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;\n\nfunction metricProblems(where: string, metric: AggregateMetric | undefined, view: WidgetBase[\"view\"]): string[] {\n if (!metric || metric.fn === \"count\") return [];\n if (![\"sum\", \"avg\", \"min\", \"max\"].includes(metric.fn)) return [`${where}.fn: one of count, sum, avg, min, max`];\n if (!view.field(metric.field)) return [`${where}.field: \"${metric.field}\" isn't a field of ${view.resource}`];\n return [];\n}\n\n/** Every problem with a widget; empty when it is sound. */\nexport function widgetProblems(input: WidgetDefinition): string[] {\n const w = input as Partial<WidgetDefinition> & Record<string, unknown>;\n if (!w || typeof w !== \"object\") return [\"expected a widget\"];\n const problems: string[] = [];\n if (typeof w.id !== \"string\" || !ID.test(w.id)) problems.push(\"id: a letter, then letters, digits, - or _\");\n if (typeof w.label !== \"string\" || !w.label.trim()) problems.push(\"label: expected a non-empty string\");\n const view = w.view;\n if (!view || typeof view !== \"object\" || typeof view.field !== \"function\") return [...problems, \"view: a view from defineView\"];\n if (w.preset !== undefined && !view.definition.presets?.[w.preset]) problems.push(`preset: ${view.resource} has no preset \"${w.preset}\"`);\n for (const field of Object.keys(w.filter ?? {})) if (!view.field(field)) problems.push(`filter.${field}: not a field of ${view.resource}`);\n const currency = (w as { format?: { currency?: unknown } }).format?.currency;\n if (currency !== undefined) {\n try {\n new Intl.NumberFormat(\"en\", { style: \"currency\", currency: String(currency) });\n } catch {\n problems.push(\"format.currency: an ISO 4217 code (USD, EUR)\");\n }\n }\n switch (w.kind) {\n case \"number\":\n problems.push(...metricProblems(\"metric\", w.metric, view));\n break;\n case \"progress\":\n problems.push(...metricProblems(\"metric\", w.metric, view));\n if (typeof w.goal === \"number\") {\n if (!(w.goal > 0)) problems.push(\"goal: a number above 0, or a total\");\n } else if (!w.goal || typeof w.goal !== \"object\") problems.push(\"goal: a number above 0, or a total\");\n else problems.push(...metricProblems(\"goal\", w.goal, view));\n for (const field of Object.keys(w.goalFilter ?? {})) if (!view.field(field)) problems.push(`goalFilter.${field}: not a field of ${view.resource}`);\n break;\n case \"streak\":\n if (typeof w.dateField !== \"string\" || !view.field(w.dateField)) problems.push(`dateField: not a field of ${view.resource}`);\n if (w.unit !== undefined && w.unit !== \"day\" && w.unit !== \"week\") problems.push(\"unit: day or week\");\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 1000)) problems.push(\"limit: a whole number from 1 to 1000\");\n break;\n case \"list\":\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 50)) problems.push(\"limit: a whole number from 1 to 50\");\n if (w.sort && !view.field(w.sort.field)) problems.push(`sort.field: not a field of ${view.resource}`);\n break;\n case \"chart\":\n if (typeof w.groupBy !== \"string\" || !view.field(w.groupBy)) problems.push(`groupBy: not a field of ${view.resource}`);\n problems.push(...metricProblems(\"metric\", w.metric, view));\n if (w.chart !== undefined && w.chart !== \"bar\" && w.chart !== \"line\") problems.push(\"chart: bar or line\");\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 1000)) problems.push(\"limit: a whole number from 1 to 1000\");\n break;\n default:\n problems.push(\"kind: one of number, progress, streak, list, chart\");\n }\n return problems;\n}\n\n/**\n * Define a widget: a tile fed by a view. Checks it against the view (its fields, presets) and\n * returns it frozen. Throws {@link ViewDefinitionError} with every problem.\n *\n * ```ts\n * const openDeals = defineWidget({ id: \"open-deals\", kind: \"number\", label: \"Open deals\", view: dealsView, preset: \"open\" });\n * const pipeline = defineWidget({\n * id: \"pipeline\", kind: \"number\", label: \"Pipeline\", view: dealsView, preset: \"open\",\n * metric: { fn: \"sum\", field: \"amount\" }, format: { currency: \"USD\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineWidget<C extends ResourceContract, Row extends DataRow>(input: WidgetDefinition<C, Row>): DefinedWidget<C, Row> {\n const problems = widgetProblems(input as unknown as WidgetDefinition);\n if (problems.length) throw new ViewDefinitionError(`widget ${String((input as { id?: unknown })?.id)}`, problems);\n // Shallow: the view inside is already frozen, and functions (format, can) stay as given.\n return Object.freeze({ ...input, __widget: true as const }) as DefinedWidget<C, Row>;\n}\n\n/** Whether a value is a widget from `defineWidget`. */\nexport function isWidget(value: unknown): value is DefinedWidget {\n return !!value && typeof value === \"object\" && (value as { __widget?: unknown }).__widget === true;\n}\n\n/** The fields a widget reads: hidden from a viewer who can't read any of them. */\nfunction fieldsRead(w: WidgetDefinition): string[] {\n switch (w.kind) {\n case \"number\":\n return w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : [];\n case \"progress\":\n return [\n ...(w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : []),\n ...(typeof w.goal === \"object\" && w.goal.fn !== \"count\" ? [w.goal.field] : []),\n ];\n case \"streak\":\n return [w.dateField];\n case \"chart\":\n return [w.groupBy, ...(w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : [])];\n case \"list\":\n return [];\n }\n}\n\n/**\n * Whether this viewer sees the widget: `true`, or the reason not. A field it totals that the\n * viewer can't read (`permissions.read: false` in the contract) hides it, then the widget's own\n * `can`. Only narrows: row security still decides the rows behind any total.\n *\n * @stability Beta\n */\nexport function resolveWidgetAccess(widget: WidgetDefinition, viewer?: Viewer): Allowed {\n for (const field of fieldsRead(widget)) {\n if (widget.view.field(field)?.permissions?.read === false) return `You can't see ${widget.view.label(field).toLowerCase()}.`;\n }\n return widget.can ? widget.can(viewer) : true;\n}\n\n/** What a widget asks its provider for, from its view, scope, preset and filter. */\nexport interface WidgetRequest {\n resource: string;\n /** The preset's filter, the scope, then the widget's own filter. */\n filters: FilterParam[];\n /** Totals to ask `aggregate` for (number, progress). */\n aggregate?: AggregateParams;\n /** The goal's totals, over the scope and `goalFilter` only (progress with a total goal). */\n goal?: AggregateParams;\n /** Rows to read (streak, list, chart): how many and in what order. */\n rows?: { perPage: number; sort?: SortParam };\n}\n\n/**\n * What a widget needs from its provider, for a viewer working in `scope` (ViewerScope's): the\n * filters its view would list with, and either the totals or the rows. `<Widget>` and a phone\n * build their reads from this.\n *\n * @stability Beta\n */\nexport function resolveWidgetRequest(widget: WidgetDefinition, scope?: ResourceScope | null): WidgetRequest {\n const { view } = widget;\n const preset = widget.preset ? view.definition.presets?.[widget.preset] : undefined;\n if (widget.preset && !preset) throw new ViewDefinitionError(view.resource, [`no preset \"${widget.preset}\"`]);\n const scoped = filterParams(scopeFilter(view, scope) as WidgetFilter);\n const filters = [...filterParams(preset?.filter as WidgetFilter | undefined), ...scoped, ...filterParams(widget.filter)];\n const orderBy = view.definition.orderBy;\n const viewSort: SortParam | undefined = orderBy\n ? { field: orderBy.field as string, order: orderBy.direction ?? \"asc\", ...(orderBy.nulls ? { nulls: orderBy.nulls } : {}) }\n : undefined;\n switch (widget.kind) {\n case \"number\":\n return { resource: view.resource, filters, aggregate: { metrics: { value: widget.metric ?? { fn: \"count\" } }, filters } };\n case \"progress\": {\n const request: WidgetRequest = { resource: view.resource, filters, aggregate: { metrics: { value: widget.metric ?? { fn: \"count\" } }, filters } };\n if (typeof widget.goal === \"object\") {\n const goalFilters = [...scoped, ...filterParams(widget.goalFilter)];\n request.goal = { metrics: { goal: widget.goal }, filters: goalFilters };\n }\n return request;\n }\n case \"streak\":\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 400, sort: { field: widget.dateField, order: \"desc\", nulls: \"last\" } } };\n case \"list\": {\n const sort = widget.sort ?? viewSort;\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 5, ...(sort ? { sort } : {}) } };\n }\n case \"chart\":\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 1000 } };\n }\n}\n\n/** The day a row's date or timestamp falls on, in `zone`. */\nfunction dayOfValue(value: unknown, zone: string): Day | undefined {\n if (typeof value === \"string\" && isDay(value)) return value;\n if (typeof value !== \"string\" && !(value instanceof Date) && typeof value !== \"number\") return undefined;\n const at = value instanceof Date ? value : new Date(value);\n return Number.isNaN(at.getTime()) ? undefined : dayIn(zone, at);\n}\n\n/** A streak's length and whether today (this week) is already in it. */\nexport interface Streak {\n /** Days (or weeks) in a row, ending today or, while today is still open, yesterday. */\n current: number;\n /** Whether today (this week) has a row. */\n today: boolean;\n unit: \"day\" | \"week\";\n}\n\n/**\n * How many days (or weeks) in a row have at least one of `values` (dates or timestamps), ending\n * today, or yesterday while today has none yet, so a streak isn't broken before the day is over.\n *\n * @stability Beta\n */\nexport function resolveStreak(\n values: readonly unknown[],\n options: { unit?: \"day\" | \"week\"; timeZone?: string; today?: Day } = {},\n): Streak {\n const unit = options.unit ?? \"day\";\n const zone = options.timeZone ?? deviceTimeZone();\n const step = unit === \"day\" ? 1 : 7;\n const bucket = (day: Day) => (unit === \"day\" ? day : startOfWeek(day, 1));\n const seen = new Set<Day>();\n for (const value of values) {\n const day = dayOfValue(value, zone);\n if (day) seen.add(bucket(day));\n }\n const now = bucket(options.today ?? dayIn(zone));\n const today = seen.has(now);\n let at = today ? now : addDays(now, -step);\n let current = 0;\n while (seen.has(at)) {\n current++;\n at = addDays(at, -step);\n }\n return { current, today, unit };\n}\n\n/** One bar (or point) of a chart widget. */\nexport interface ChartPoint {\n /** The field's value, as text (`\"(none)\"` for an empty one). */\n key: string;\n /** The value in words (`ResourceView.valueLabel`). */\n label: string;\n value: number;\n}\n\n/**\n * A chart widget's bars from its rows: one per value of `groupBy`, in the field's choice order\n * when it has choices (else by value), each the metric over the rows with that value.\n *\n * @stability Beta\n */\nexport function resolveChartSeries(widget: ChartWidget, rows: readonly Record<string, unknown>[]): ChartPoint[] {\n const groups = new Map<string, Record<string, unknown>[]>();\n for (const row of rows) {\n const raw = row[widget.groupBy];\n const key = raw === null || raw === undefined || raw === \"\" ? \"(none)\" : String(raw);\n const list = groups.get(key) ?? [];\n list.push(row);\n groups.set(key, list);\n }\n const choices = (widget.view.field(widget.groupBy)?.enumValues ?? []) as readonly string[];\n const keys = [\n ...choices.filter((c) => groups.has(c)),\n ...[...groups.keys()].filter((k) => !choices.includes(k)).sort((a, b) => a.localeCompare(b, undefined, { numeric: true })),\n ];\n const metric = widget.metric ?? { fn: \"count\" as const };\n return keys.map((key) => {\n const list = groups.get(key)!;\n // The same rule as a number widget's total: rows with no number in the field are skipped, not\n // read as 0; a group where none has one draws as 0.\n const value = toAggregateValues(list, { value: metric })[\"value\"] ?? 0;\n return { key, label: key === \"(none)\" ? \"None\" : widget.view.valueLabel(widget.groupBy, key), value };\n });\n}\n\n/**\n * A widget's number in words: `null` reads \"—\", a percent is of 1 (0.42 is 42%).\n *\n * @stability Beta\n */\nexport function toWidgetText(value: number | null | undefined, format: WidgetFormat = \"number\", locale?: string): string {\n if (value === null || value === undefined || !Number.isFinite(value)) return \"—\";\n if (typeof format === \"function\") return format(value);\n if (typeof format === \"object\") {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: format.currency,\n ...(format.maximumFractionDigits !== undefined ? { maximumFractionDigits: format.maximumFractionDigits } : {}),\n }).format(value);\n }\n switch (format) {\n case \"compact\":\n return new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }).format(value);\n case \"percent\":\n return new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(value);\n default:\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }).format(value);\n }\n}\n\n/**\n * Progress as a fraction from 0 to 1 (more than 1 when the goal is passed), or null without a\n * goal to measure against.\n *\n * @stability Beta\n */\nexport function resolveProgress(value: number | null | undefined, goal: number | null | undefined): number | null {\n if (value === null || value === undefined || goal === null || goal === undefined || !(goal > 0)) return null;\n return Math.max(0, value / goal);\n}\n"]}
1
+ {"version":3,"sources":["../../src/resource-view/picture.ts","../../src/resource-view/group.ts","../../src/resource-view/tree.ts","../../src/resource-view/record-view.ts","../../src/resource-view/widget.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,IAAI,SAAA;AAIJ,IAAM,MAAA,GAAS,SAAA;AACf,SAAS,UAAU,IAAA,EAAwB;AACzC,EAAA,IAAI,cAA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IAAQ,KAAA,KAAU,MAAA,IAAa,IAAA,KAAS,IAAA,IAAQ,IAAA,KAAS,MAAA,IAAa,EAAE,IAAA,GAAO,CAAA,CAAA,EAAI,OAAO,IAAA;AACxG,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,KAAA,GAAQ,IAAI,CAAA;AACjC","file":"index.js","sourcesContent":["// rowPicture: what to draw for a row's picture (docs/RESOURCE-VIEW.md, \"summary\"). Pure, so web,\n// native and the extension draw the same image or initials, behind the same URL check.\n\nimport { isSafeUrl } from \"../urls\";\nimport type { RowPicture, RowSummary } from \"./types\";\n\nlet segmenter: Intl.Segmenter | null | undefined;\n\n// The first letter of a word, as a whole character: \"é\" keeps its accent, \"李\" is a letter, and\n// punctuation, digits and emoji never count.\nconst LETTER = /^\\p{L}/u;\nfunction lettersOf(word: string): string[] {\n if (segmenter === undefined) {\n segmenter = typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\" ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" }) : null;\n }\n const parts = segmenter ? Array.from(segmenter.segment(word), (s) => s.segment) : Array.from(word);\n return parts.filter((part) => LETTER.test(part));\n}\nfunction firstLetter(word: string): string {\n return lettersOf(word)[0] ?? \"\";\n}\n\n/**\n * First and last initial of a name, from letters only: \"Ada Lovelace\" → \"AL\", \"Ana-María López\"\n * → \"AL\", \"李 小龙\" → \"李小\", \"Cher\" → \"C\". Empty when the name has no letters (\" \", \"🎉🎉\").\n *\n * `distinct: true` gives a one-word name its first two letters (\"Probe\" → \"Pr\", \"Polish\" → \"Po\"),\n * so people who share an initial still differ in a list. Names of two words or more are unchanged.\n */\nexport function initialsOf(name: string | undefined, options: { distinct?: boolean | undefined } = {}): string {\n const words = (name ?? \"\").trim().split(/\\s+/);\n const letters = words.map(firstLetter).filter(Boolean);\n if (letters.length === 0) return \"\";\n const upper = (l: string) => (l.toUpperCase().length === l.length ? l.toUpperCase() : l);\n if (letters.length === 1 && options.distinct) {\n const word = words.find((w) => firstLetter(w))!;\n const second = lettersOf(word)[1];\n // One character each: \"ß\" stays \"ß\" rather than becoming \"SS\".\n return upper(letters[0]!) + (second ? (second.toLowerCase().length === second.length ? second.toLowerCase() : second) : \"\");\n }\n const pair = letters.length === 1 ? [letters[0]!] : [letters[0]!, letters[letters.length - 1]!];\n // One character each: \"ß\" stays \"ß\" rather than becoming \"SS\".\n return pair.map(upper).join(\"\");\n}\n\n/** An image source: `isSafeUrl`, and only http(s) or a root-relative path (never mailto, tel or `#x`). */\nfunction isImageSrc(src: unknown): src is string {\n if (!isSafeUrl(src)) return false;\n const value = src.trim();\n return value.startsWith(\"/\") || /^https?:/i.test(value);\n}\n\n/**\n * What to draw for a summary's picture:\n *\n * ```ts\n * rowPicture({ title: \"Ada\", image: { src: \"https://…/ada.png\", name: \"Ada Lovelace\" } });\n * // { kind: \"image\", src: \"https://…/ada.png\", alt: \"\", fallback: \"AL\" }\n * rowPicture({ title: \"Ada\", image: { src: \"javascript:x\", name: \"Ada Lovelace\" } });\n * // { kind: \"initials\", text: \"AL\" }\n * ```\n *\n * `null` when the summary has no `image`, or neither a safe `src` nor a `name` with letters.\n */\nexport function rowPicture(summary: RowSummary): RowPicture | null {\n const image = summary.image;\n if (!image) return null;\n const initials = initialsOf(image.name);\n if (isImageSrc(image.src)) return { kind: \"image\", src: image.src.trim(), alt: image.alt ?? \"\", fallback: initials };\n return initials ? { kind: \"initials\", text: initials } : null;\n}\n","// groupRows: a view's rows under headers by its `groupBy` field (or another), with no React, so a\n// custom view on the web, a phone screen and a server export group the same way.\n\nimport type { DataRow, ResourceContract } from \"../schema/types\";\nimport type { ResourceView } from \"./types\";\n\n/**\n * One group of rows: the value they share, its words and the rows, in the order they came.\n *\n * @stability Beta\n */\nexport interface RowGroup<Row extends DataRow = DataRow> {\n /** Stable, for list keys: the value as text, or `\"\"` for rows with no value. */\n readonly key: string;\n /** The value the rows share (`null` for the group with none). */\n readonly value: unknown;\n /** The value in words (`view.valueLabel`), or `emptyLabel` for the group with none. */\n readonly label: string;\n readonly rows: readonly Row[];\n}\n\n/** @stability Beta */\nexport interface GroupRowsOptions {\n /** The field to group by. Default the view's `groupBy`. */\n field?: string;\n /** The words for rows with no value. Default \"No {field label}\". */\n emptyLabel?: string;\n}\n\nconst isEmpty = (value: unknown) => value === null || value === undefined || value === \"\";\n\n/**\n * A view's rows in groups, in the order each group first appears (the server's sort, so loading\n * more never reorders what's on screen). Without a field (no `groupBy` and none given), one group\n * holding every row, with an empty label.\n *\n * ```ts\n * for (const group of groupRows(tasksView, rows)) console.log(group.label, group.rows.length);\n * ```\n *\n * @stability Beta\n */\nexport function groupRows<Row extends DataRow>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract; Row is what matters here\n view: ResourceView<ResourceContract<any>, Row>,\n rows: readonly Row[],\n options: GroupRowsOptions = {},\n): RowGroup<Row>[] {\n const field = options.field ?? (view.definition.groupBy as string | undefined);\n if (!field) return rows.length ? [Object.freeze({ key: \"\", value: null, label: \"\", rows: Object.freeze([...rows]) })] : [];\n const groups = new Map<string, { key: string; value: unknown; label: string; rows: Row[] }>();\n for (const row of rows) {\n const value = row[field];\n const key = isEmpty(value) ? \"\" : String(value);\n let group = groups.get(key);\n if (!group) {\n const label = isEmpty(value) ? (options.emptyLabel ?? `No ${view.label(field).toLowerCase()}`) : view.valueLabel(field, value);\n group = { key, value: isEmpty(value) ? null : value, label, rows: [] };\n groups.set(key, group);\n }\n group.rows.push(row);\n }\n return [...groups.values()].map((g) => Object.freeze({ ...g, rows: Object.freeze(g.rows) }));\n}\n\n/**\n * The view's `totals` over some rows (a group's, or every loaded row for a footer): per field, its\n * sum, average, lowest, highest or count, `null` when no row has a number. Fields the view names\n * no total for are left out.\n *\n * ```ts\n * groupTotals(tasksView, group.rows); // { estimate_hours: 12.5 }\n * ```\n *\n * @stability Beta\n */\nexport function groupTotals<Row extends DataRow>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract; Row is what matters here\n view: ResourceView<ResourceContract<any>, Row>,\n rows: readonly Row[],\n): Readonly<Record<string, number | null>> {\n const out: Record<string, number | null> = {};\n for (const [field, fn] of Object.entries((view.definition.totals ?? {}) as Readonly<Record<string, string>>)) {\n if (fn === \"count\") {\n out[field] = rows.filter((r) => !isEmpty(r[field])).length;\n continue;\n }\n const numbers = rows.map((r) => (isEmpty(r[field]) ? NaN : Number(r[field]))).filter((n) => Number.isFinite(n));\n if (!numbers.length) {\n out[field] = null;\n continue;\n }\n const sum = numbers.reduce((a, b) => a + b, 0);\n out[field] = fn === \"sum\" ? sum : fn === \"avg\" ? sum / numbers.length : fn === \"min\" ? Math.min(...numbers) : Math.max(...numbers);\n }\n return Object.freeze(out);\n}\n","// Tree mode: nested records drawn from a flat list. Each row names its parent; the tree is built\n// from the data, never from nested input, so caching and writes stay the flat list's. No React:\n// genesis-ui's `useResourceView` holds the state and draws it, and a native list can reuse it.\n// docs/RESOURCE-VIEW.md, \"Tree mode\".\n\n/**\n * A screen's `tree` (`<ResourceView tree={{ getParentId }} />`): rows nest under the row\n * `getParentId` names. Client-side data only: every row is loaded, and children are never\n * fetched on expand.\n */\nexport interface ResourceTree<T> {\n /** The parent row's key (the same text as the row key), or `null` / `undefined` / `\"\"` for a root. */\n getParentId: (row: T) => string | null | undefined;\n /**\n * Which rows start open (uncontrolled): `true` every parent, a number the parents shallower\n * than that depth (`1` opens the roots), `false` none. Default `false`.\n */\n defaultExpanded?: boolean | number;\n /** The open rows by key, controlled. Leave unset and the screen keeps its own. */\n expanded?: ReadonlySet<string>;\n /** Called with the next open set whenever a row opens or closes. */\n onExpandedChange?: (expanded: Set<string>) => void;\n /** Selecting a row selects its descendants too, and clearing it clears them. Default `false`. */\n cascadeSelect?: boolean;\n}\n\n/** How to read the tree out of flat rows. */\nexport interface TreeOptions<T> {\n /** A row's own id. */\n getId: (row: T) => string;\n /** The parent's id; `null`, `undefined` or `\"\"` for a root. A parent that isn't loaded makes a root too. */\n getParentId: (row: T) => string | null | undefined;\n /**\n * Which nodes are open: their ids, or `\"all\"`. A closed node's descendants aren't returned.\n * While `match` is set, every ancestor of a match is open regardless, so each match shows.\n */\n expanded: ReadonlySet<string> | \"all\";\n /**\n * The filter, when one is active: rows that match it, and their ancestors (so a match keeps its\n * context), are kept; everything else is left out. Undefined: no filter, every row is kept.\n */\n match?: (row: T) => boolean;\n /**\n * The sort, applied within each set of siblings (stable: ties keep the rows' order). Without it,\n * siblings keep the rows' order, so a list sorted beforehand is sorted within siblings too.\n */\n compare?: (a: T, b: T) => number;\n}\n\n/** One visible row of the tree, in display order. */\nexport interface TreeNode<T> {\n row: T;\n id: string;\n /** The parent's id as drawn: `null` for a root (a missing parent, or a broken cycle, counts as none). */\n parentId: string | null;\n /** 0 for a root. */\n depth: number;\n /** Whether it has children among the kept rows (so a toggle makes sense). */\n hasChildren: boolean;\n /** Whether it is open. Always false without children. */\n expanded: boolean;\n /** False for an ancestor kept only as a match's context; true otherwise, and always true without a filter. */\n matched: boolean;\n /** 1-based position among its kept siblings, and how many there are (`aria-posinset`, `aria-setsize`). */\n position: number;\n siblings: number;\n}\n\n/** What {@link treeRows} returns. */\nexport interface TreeResult<T> {\n /** The rows to draw, in order: each parent before its children, siblings in input order. */\n visible: TreeNode<T>[];\n /** Every kept row's node by id, collapsed ones included. */\n nodes: ReadonlyMap<string, TreeNode<T>>;\n /** Every descendant of a node among the kept rows, depth-first, collapsed or not. */\n descendants: (id: string) => string[];\n /** The ids of every kept node that has children: \"expand all\". */\n parents: () => string[];\n}\n\nconst rootish = (parent: string | null | undefined): parent is null | undefined | \"\" => parent == null || parent === \"\";\n\n/**\n * Build the tree from flat rows. Siblings are sorted by `compare`, else keep the rows' order, so\n * either way the sort applies within each set of siblings. A row whose parent isn't among `rows` is a root,\n * and so is a row whose parent would close a cycle (each cycle loses one link). Duplicate ids keep\n * the first row.\n */\nexport function treeRows<T>(rows: readonly T[], options: TreeOptions<T>): TreeResult<T> {\n const { getId, getParentId, expanded, match, compare } = options;\n const byId = new Map<string, T>();\n const order: string[] = [];\n for (const row of rows) {\n const id = getId(row);\n if (byId.has(id)) continue;\n byId.set(id, row);\n order.push(id);\n }\n\n // The parent each row hangs from: absent, unloaded or cyclic parents make a root.\n const parentOf = new Map<string, string | null>();\n const resolving = new Set<string>();\n const resolve = (id: string): string | null => {\n if (parentOf.has(id)) return parentOf.get(id)!;\n const raw = getParentId(byId.get(id)!);\n let parent: string | null = rootish(raw) || raw === id || !byId.has(raw) ? null : raw;\n if (parent !== null) {\n resolving.add(id);\n // Walk up: meeting a row still being resolved means a cycle; break it here.\n if (resolving.has(parent)) parent = null;\n else resolve(parent);\n resolving.delete(id);\n }\n parentOf.set(id, parent);\n return parent;\n };\n for (const id of order) resolve(id);\n // A cycle's other members may have resolved through the broken one before it broke: recheck\n // that every chain ends at a root.\n for (const id of order) {\n const seen = new Set<string>([id]);\n let at = parentOf.get(id) ?? null;\n while (at !== null && !seen.has(at)) {\n seen.add(at);\n at = parentOf.get(at) ?? null;\n }\n if (at !== null) parentOf.set(id, null);\n }\n\n // What the filter keeps: matches, and every ancestor of one.\n let kept: Set<string> | null = null;\n const matched = new Set<string>();\n if (match) {\n kept = new Set();\n for (const id of order) {\n if (!match(byId.get(id)!)) continue;\n matched.add(id);\n for (let at: string | null = id; at !== null && !kept.has(at); at = parentOf.get(at) ?? null) kept.add(at);\n }\n }\n\n const children = new Map<string | null, string[]>();\n for (const id of order) {\n if (kept && !kept.has(id)) continue;\n const parent = parentOf.get(id) ?? null;\n const list = children.get(parent);\n if (list) list.push(id);\n else children.set(parent, [id]);\n }\n // Sort within siblings only: a child never leaves its parent. Array sort is stable.\n if (compare) for (const list of children.values()) list.sort((a, b) => compare(byId.get(a)!, byId.get(b)!));\n\n const isOpen = (id: string) => (match ? true : expanded === \"all\" || expanded.has(id));\n const nodes = new Map<string, TreeNode<T>>();\n const visible: TreeNode<T>[] = [];\n const visit = (parent: string | null, depth: number, shown: boolean) => {\n const ids = children.get(parent) ?? [];\n ids.forEach((id, index) => {\n const hasChildren = (children.get(id)?.length ?? 0) > 0;\n const open = hasChildren && isOpen(id);\n const node: TreeNode<T> = {\n row: byId.get(id)!,\n id,\n parentId: parent,\n depth,\n hasChildren,\n expanded: open,\n matched: match ? matched.has(id) : true,\n position: index + 1,\n siblings: ids.length,\n };\n nodes.set(id, node);\n if (shown) visible.push(node);\n visit(id, depth + 1, shown && open);\n });\n };\n visit(null, 0, true);\n\n const descendants = (id: string): string[] => {\n const out: string[] = [];\n const walk = (at: string) => {\n for (const child of children.get(at) ?? []) {\n out.push(child);\n walk(child);\n }\n };\n walk(id);\n return out;\n };\n const parents = () => [...nodes.values()].filter((n) => n.hasChildren).map((n) => n.id);\n return { visible, nodes, descendants, parents };\n}\n\n/**\n * The open ids a tree starts with: `true` opens every parent, a number opens parents shallower\n * than that depth (`1` opens the roots), `false` or nothing opens none.\n */\nexport function initialExpanded<T>(rows: readonly T[], options: Omit<TreeOptions<T>, \"expanded\" | \"match\">, open: boolean | number | undefined): Set<string> {\n if (!open) return new Set();\n const tree = treeRows(rows, { ...options, expanded: \"all\" });\n const depth = open === true ? Infinity : open;\n return new Set(tree.parents().filter((id) => tree.nodes.get(id)!.depth < depth));\n}\n\n/** The open set with `id` opened or closed: a new set, or the same one when nothing changes. */\nexport function setExpanded(expanded: ReadonlySet<string>, id: string, open: boolean): ReadonlySet<string> {\n if (expanded.has(id) === open) return expanded;\n const next = new Set(expanded);\n if (open) next.add(id);\n else next.delete(id);\n return next;\n}\n\n/**\n * The selection after toggling `id` with cascade: the node and every descendant take the node's\n * new state. Without cascade, use a plain toggle; selection never cascades by default.\n */\nexport function cascadeSelection(selected: ReadonlySet<string>, id: string, descendants: readonly string[]): Set<string> {\n const next = new Set(selected);\n const on = !selected.has(id);\n for (const at of [id, ...descendants]) {\n if (on) next.add(at);\n else next.delete(at);\n }\n return next;\n}\n","// defineRecordView: one record's screen from a view (docs/RESOURCE-VIEW.md, \"RecordView\").\n// A header (the row's summary and the view's actions), sections (a child list, a few settings, or\n// a slot the screen fills) and readiness checks. Checked once and frozen like defineView, with no\n// React, so web and native draw the same screen from it.\n\nimport { encodeRecordKey } from \"../schema/keys\";\nimport type { Identifier } from \"../provider/types\";\nimport { readinessOf, type Readiness } from \"../resource\";\nimport type { DataRow, FieldSchema, ResourceContract } from \"../schema/types\";\nimport { ViewDefinitionError } from \"./errors\";\nimport type { Viewer } from \"../viewer\";\nimport type { Allowed, FieldNameOf, ResolvedFormField, ResourceView, RowOf, ViewTone } from \"./types\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- a child list can be any resource\ntype AnyView = ResourceView<ResourceContract<any>, any>;\n\n/** Equality filters for a child list, sent to the server: `{ brand_id: brand.id }`. `null` is \"is empty\". */\nexport type RecordViewFilter = Readonly<Record<string, string | number | boolean | null>>;\n\ninterface SectionBase {\n /** Unique in the record view; the screen's route segment or slot key. */\n id: string;\n label: string;\n}\n\n/** A child list: another view, filtered by this record. */\nexport interface RecordViewListSection<Row extends DataRow = DataRow> extends SectionBase {\n list: { view: AnyView; filter: (row: Row) => RecordViewFilter };\n settings?: never;\n}\n\n/** A few of this record's own fields, edited in place. Each must be in `view.writable(\"edit\")`. */\nexport interface RecordViewSettingsSection<Name extends string = string> extends SectionBase {\n settings: readonly Name[];\n list?: never;\n}\n\n/** A section the screen fills itself, through a slot keyed by `id`. */\nexport interface RecordViewSlotSection extends SectionBase {\n list?: never;\n settings?: never;\n}\n\nexport type RecordViewSection<Row extends DataRow = DataRow, Name extends string = string> =\n | RecordViewListSection<Row>\n | RecordViewSettingsSection<Name>\n | RecordViewSlotSection;\n\n/** One readiness check: \"Has a logo\", ok or not, and why not. */\nexport interface RecordViewReadinessItem {\n /** A stable key for the check; default its position and title. */\n id?: string;\n title: string;\n ok: boolean;\n reason?: string;\n /** Genesis chip tones only. Default `success` when ok, `warning` when not. */\n tone?: ViewTone;\n}\n\n/**\n * A record page template (ADR 0021): `standard` (a header with the summary and actions, then the\n * sections) or `document` (a cover, an icon, a large title, the properties, then the body, like\n * a page in a notes app).\n *\n * @stability Beta\n */\nexport type RecordPageTemplate = \"standard\" | \"document\";\n\n/**\n * Where a `document` template finds its parts, by field name. Each is optional; a part whose\n * field is empty on a row isn't drawn.\n *\n * @stability Beta\n */\nexport interface RecordViewDocument<Name extends string = string> {\n /** A text field holding the cover image's URL. */\n cover?: Name;\n /** A text field holding the icon: an emoji or a short text, or an image's URL. */\n icon?: Name;\n /** The fields listed under the title, as label and value, in order. */\n properties?: readonly Name[];\n /** The long text below the properties. */\n body?: Name;\n}\n\n/** What `defineRecordView` accepts. */\nexport interface RecordViewDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> {\n /** The view actions the header offers, by name, in order. Default: every view action. */\n header?: { actions?: readonly string[] };\n /** The sections. A `document` template may have none (the document is the page). */\n sections: readonly RecordViewSection<Row, FieldNameOf<C>>[];\n readiness?: (row: Row) => readonly RecordViewReadinessItem[];\n /** The record page template. Default `standard`, the page as before. */\n template?: RecordPageTemplate;\n /** With `template: \"document\"`: the fields its cover, icon, properties and body show. */\n document?: RecordViewDocument<FieldNameOf<C>>;\n}\n\n/** A section as a renderer draws it. */\nexport type ResolvedRecordViewSection =\n | { readonly id: string; readonly label: string; readonly kind: \"list\"; readonly view: AnyView }\n | { readonly id: string; readonly label: string; readonly kind: \"settings\"; readonly settings: readonly string[] }\n | { readonly id: string; readonly label: string; readonly kind: \"slot\" };\n\n/** A header action with whether this row allows it. */\nexport interface RecordViewHeaderAction {\n readonly name: string;\n readonly label: string;\n readonly confirm?: string;\n readonly description?: string;\n readonly destructive?: boolean;\n /** `true`, or the view guard's reason. Only narrows what the server allows. */\n readonly allowed: Allowed;\n}\n\n/** The header for one row: the view's summary plus the header's actions. */\nexport interface RecordViewHeader {\n readonly title: string;\n readonly subtitle?: string;\n readonly chips: readonly { label: string; tone?: ViewTone }[];\n readonly actions: readonly RecordViewHeaderAction[];\n}\n\n/** What a screen and its provider add to the header: they only narrow the view's guards. */\nexport interface RecordViewHeaderOptions<Row extends DataRow = DataRow> {\n /** The screen's own rule: `false` hides the action, a sentence refuses it with that reason. */\n can?: (action: string, row: Row) => Allowed | boolean;\n /** Whether anything can run actions here (the screen's `onAction`, or the provider's `runAction`). `false` hides them all. */\n runnable?: boolean;\n /** The action names the provider reports serving (`ResourceSchema.actions`), when it reports them. Others are hidden. */\n served?: readonly string[];\n /** Who is looking (`useViewer()`), for the view's action guards. Without it they get no one. */\n viewer?: Viewer;\n}\n\n/** A readiness check with its tone resolved. */\nexport interface ResolvedReadinessItem {\n /** Stable, for list keys: the check's `id`, or its position and title. */\n readonly key: string;\n readonly title: string;\n readonly ok: boolean;\n readonly reason?: string;\n readonly tone: ViewTone;\n}\n\n/**\n * Any record view, whatever its contract: the type a view's `recordView` returns. Name it on that\n * function (`recordView: (): AnyRecordView => brandRecordView`), since the record view is defined\n * from the view and TypeScript can't infer one from the other.\n *\n * @stability Beta\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract and row, by design\nexport type AnyRecordView = RecordView<ResourceContract<any>, any>;\n\n/** What `defineRecordView` returns: frozen, with pure helpers for the renderers. */\nexport interface RecordView<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> {\n readonly view: ResourceView<C, Row>;\n readonly sections: readonly ResolvedRecordViewSection[];\n /** The header's action names, in order. */\n readonly headerActions: readonly string[];\n readonly hasReadiness: boolean;\n /** The record page template: `standard` unless the definition says `document`. */\n readonly template: RecordPageTemplate;\n /** The document template's fields (frozen); empty for `standard`. */\n readonly document: Readonly<RecordViewDocument>;\n section(id: string): ResolvedRecordViewSection | undefined;\n /** The record's address for the provider: its key fields (`keyFields`), composite keys encoded. */\n recordId(row: Row): Identifier;\n /**\n * Why settings can't be saved for this row and viewer: the view's `can(\"update\", row, viewer)`\n * reason, or `null` when they can. Renderers then show the settings read-only with the reason.\n * Without a viewer the guard gets no one, so one that needs the viewer locks them.\n */\n settingsLocked(row: Row, viewer?: Viewer): string | null;\n headerFor(row: Row, options?: RecordViewHeaderOptions<Row>): RecordViewHeader;\n /**\n * Settings fields as the view's form resolves them (`view.form(\"edit\")`), in the order listed:\n * one section's, or every settings section's without an id.\n */\n settingsFields(sectionId?: string): readonly ResolvedFormField[];\n /** Only the section's listed keys that `values` has: what a save sends. */\n settingsPatch(sectionId: string, values: Readonly<Record<string, unknown>>): Record<string, unknown>;\n /**\n * A list section's filter for this row. In development, a filter with no key, or a value that\n * isn't a string, number, boolean or null, throws: it would show every child row.\n */\n listFilter(sectionId: string, row: Row): RecordViewFilter;\n /** The readiness checks for this row, tones resolved; empty without `readiness`. */\n readinessFor(row: Row): readonly ResolvedReadinessItem[];\n /**\n * The checks in one chip's terms (genesis-core/resource's `readinessOf`): an unmet `danger`\n * check is a problem, any other unmet check one to look at. `null` without `readiness`. Draw\n * it with `readinessChip`.\n */\n readinessSummary(row: Row): Readiness | null;\n}\n\nconst WORKSPACE = Symbol.for(\"genesis.resource-workspace\");\n/** The reason shown when a guard refuses without one. */\nconst REFUSED = \"This isn't allowed.\";\nconst TONES: ReadonlySet<string> = new Set<ViewTone>([\"success\", \"warning\", \"danger\", \"info\", \"muted\"]);\nconst SECTION_KEYS: ReadonlySet<string> = new Set([\"id\", \"label\", \"list\", \"settings\"]);\nconst DOCUMENT_KEYS: ReadonlySet<string> = new Set([\"cover\", \"icon\", \"properties\", \"body\"]);\nconst dev = () => process.env.NODE_ENV !== \"production\";\n\n/** Why a field can't be a setting edited in place, or null when it can. */\nfunction unsettable(field: FieldSchema | undefined): string | null {\n if (!field) return null;\n const facts = field as FieldSchema & { sensitive?: boolean };\n if (field.type === \"json\") return \"is JSON\";\n if (field.array) return \"is a list\";\n if (field.references || field.type === \"relation\") return \"is a link\";\n if (facts.sensitive) return \"is sensitive\";\n return null;\n}\n\n/**\n * Whether two values are the same as a settings form holds them: 2 and \"2\", and null, undefined\n * and \"\", are the same. A settings section compares an edit with the row through it, so an edit\n * back to the stored value isn't a change (web and native RecordView).\n */\nexport function sameFormValue(a: unknown, b: unknown): boolean {\n const text = (v: unknown) => (v === null || v === undefined ? \"\" : Array.isArray(v) ? v.join(\",\") : String(v));\n return text(a) === text(b);\n}\n\n/** Whether a value is a record view (`defineRecordView`'s result). */\nexport function isRecordView(value: unknown): value is RecordView {\n return typeof value === \"object\" && value !== null && (value as Record<symbol, unknown>)[WORKSPACE] === true;\n}\n\nfunction isView(value: unknown): value is AnyView {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as AnyView).columns === \"function\" &&\n typeof (value as AnyView).resource === \"string\"\n );\n}\n\n/**\n * One record's screen from its view:\n *\n * ```ts\n * export const brandRecordView = defineRecordView(brandsView, {\n * header: { actions: [\"archive\"] },\n * sections: [\n * { id: \"products\", label: \"Products\", list: { view: productsView, filter: (b) => ({ brand_id: b.id }) } },\n * { id: \"settings\", label: \"Settings\", settings: [\"name\", \"website\"] },\n * { id: \"activity\", label: \"Activity\" }, // the screen fills it\n * ],\n * readiness: (b) => [{ title: \"Has a website\", ok: !!b.website, reason: \"Add the website.\" }],\n * });\n * ```\n *\n * Throws {@link ViewDefinitionError} for a settings field the view can't write, a header action\n * the view doesn't define, a repeated section id, or a section that holds another record view.\n */\nexport function defineRecordView<C extends ResourceContract, Row extends DataRow = RowOf<C>>(\n view: ResourceView<C, Row>,\n definition: RecordViewDefinition<C, Row>,\n): RecordView<C, Row> {\n const where = `${view.resource} record view`;\n const problems: string[] = [];\n const writable = new Set(view.writable(\"edit\"));\n const actionNames = new Set(view.actions().map((a) => a.name));\n\n // ── Sections ─────────────────────────────────────────────────────────\n const input = Array.isArray(definition?.sections) ? definition.sections : [];\n const template: RecordPageTemplate = definition?.template ?? \"standard\";\n if (template !== \"standard\" && template !== \"document\") problems.push(`template is \"standard\" or \"document\", not ${JSON.stringify(template)}`);\n if (!Array.isArray(definition?.sections)) problems.push(\"sections isn't a list\");\n else if (input.length === 0 && template !== \"document\") problems.push(\"sections is empty\");\n const ids = new Set<string>();\n const settingsSeen = new Set<string>();\n const sections: ResolvedRecordViewSection[] = [];\n const filters = new Map<string, (row: Row) => RecordViewFilter>();\n input.forEach((raw, i) => {\n const at = `sections[${i}]`;\n if (!raw || typeof raw !== \"object\") {\n problems.push(`${at} isn't a section`);\n return;\n }\n const s = raw as RecordViewSection<Row> & Record<string, unknown>;\n const name = typeof s.id === \"string\" && s.id.trim() ? s.id : undefined;\n if (!name) problems.push(`${at} has no id`);\n else if (ids.has(name)) problems.push(`sections lists \"${name}\" twice`);\n else ids.add(name);\n const label = `sections.${name ?? i}`;\n if (typeof s.label !== \"string\" || !s.label.trim()) problems.push(`${label} has no label`);\n if (isRecordView(s) || \"sections\" in s || \"workspace\" in s) {\n problems.push(`${label} holds a record view; sections don't nest`);\n return;\n }\n const unknown = Object.keys(s).filter((k) => !SECTION_KEYS.has(k));\n if (unknown.length) problems.push(`${label} has ${unknown.map((k) => `\"${k}\"`).join(\", \")}, which isn't a section key (id, label, list, settings)`);\n const hasList = s.list !== undefined;\n const hasSettings = s.settings !== undefined;\n if (hasList && hasSettings) {\n problems.push(`${label} has both list and settings; a section has one`);\n return;\n }\n if (hasList) {\n const list = s.list as { view?: unknown; filter?: unknown };\n if (isRecordView(list?.view)) problems.push(`${label}.list.view is a record view; sections don't nest`);\n else if (!isView(list?.view)) problems.push(`${label}.list.view isn't a view`);\n if (typeof list?.filter !== \"function\") problems.push(`${label}.list.filter isn't a function`);\n if (name && isView(list?.view) && !isRecordView(list.view) && typeof list.filter === \"function\") {\n filters.set(name, list.filter as (row: Row) => RecordViewFilter);\n sections.push(Object.freeze({ id: name, label: s.label, kind: \"list\", view: list.view }));\n }\n return;\n }\n if (hasSettings) {\n if (!Array.isArray(s.settings)) {\n problems.push(`${label}.settings isn't a list`);\n return;\n }\n if (s.settings.length === 0) problems.push(`${label}.settings lists no fields`);\n for (const field of s.settings as readonly string[]) {\n const why = unsettable(view.field(field));\n if (why) problems.push(`${label}.settings names \"${field}\", which ${why}; it needs an editor of its own`);\n else if (!writable.has(field)) problems.push(`${label}.settings names \"${field}\", which the view can't write on edit`);\n if (settingsSeen.has(field)) problems.push(`settings lists \"${field}\" twice`);\n settingsSeen.add(field);\n }\n if (name) sections.push(Object.freeze({ id: name, label: s.label, kind: \"settings\", settings: Object.freeze((s.settings as readonly string[]).map(String)) }));\n return;\n }\n if (name) sections.push(Object.freeze({ id: name, label: s.label, kind: \"slot\" }));\n });\n\n // ── Header and readiness ─────────────────────────────────────────────\n const requested = definition?.header?.actions;\n if (requested !== undefined && !Array.isArray(requested)) problems.push(\"header.actions isn't a list\");\n const headerActions = Object.freeze(\n Array.isArray(requested) ? [...requested] : view.actions().map((a) => a.name),\n );\n const headerSeen = new Set<string>();\n for (const name of headerActions) {\n if (!actionNames.has(name)) problems.push(`header.actions names \"${name}\", which isn't a view action`);\n if (headerSeen.has(name)) problems.push(`header.actions lists \"${name}\" twice`);\n headerSeen.add(name);\n }\n if (definition?.readiness !== undefined && typeof definition.readiness !== \"function\") {\n problems.push(\"readiness isn't a function\");\n }\n // ── The document template ────────────────────────────────────────────\n const doc = definition?.document;\n if (doc !== undefined) {\n if (!doc || typeof doc !== \"object\" || Array.isArray(doc)) problems.push(\"document isn't an object\");\n else {\n if (template !== \"document\") problems.push(`document is set, but template isn't \"document\"`);\n for (const key of Object.keys(doc)) if (!DOCUMENT_KEYS.has(key)) problems.push(`document.${key} isn't a document setting (cover, icon, properties, body)`);\n for (const key of [\"cover\", \"icon\", \"body\"] as const) {\n const name = doc[key];\n if (name === undefined) continue;\n const field = view.field(String(name));\n if (!field) problems.push(`document.${key} names \"${String(name)}\", which isn't a field`);\n else if (field.type !== \"string\" || field.array) problems.push(`document.${key} \"${String(name)}\" is a ${field.array ? \"list\" : field.type}, not a text field`);\n }\n if (doc.properties !== undefined) {\n if (!Array.isArray(doc.properties)) problems.push(\"document.properties isn't a list\");\n else for (const name of doc.properties) if (!view.field(String(name))) problems.push(`document.properties names \"${String(name)}\", which isn't a field`);\n }\n }\n }\n if (problems.length) throw new ViewDefinitionError(where, problems);\n const document: Readonly<RecordViewDocument> = Object.freeze(\n doc ? { ...doc, ...(doc.properties ? { properties: Object.freeze([...doc.properties].map(String)) } : {}) } : {},\n );\n\n const frozenSections = Object.freeze(sections);\n const byId = new Map(frozenSections.map((s) => [s.id, s]));\n const actionByName = new Map(view.actions().map((a) => [a.name, a]));\n const readiness = definition.readiness;\n\n const settingsOf = (sectionId: string): readonly string[] => {\n const s = byId.get(sectionId);\n if (!s || s.kind !== \"settings\") throw new ViewDefinitionError(where, [`no settings section \"${sectionId}\"`]);\n return s.settings;\n };\n const resolvedSettings = new Map<string, readonly ResolvedFormField[]>();\n const settingsFields = (sectionId?: string): readonly ResolvedFormField[] => {\n const key = sectionId ?? \"\";\n const cached = resolvedSettings.get(key);\n if (cached) return cached;\n const names =\n sectionId === undefined\n ? frozenSections.flatMap((s) => (s.kind === \"settings\" ? s.settings : []))\n : settingsOf(sectionId);\n const form = new Map(view.form(\"edit\").map((f) => [f.field.name, f]));\n const out = Object.freeze(names.map((n) => form.get(n)).filter((f): f is ResolvedFormField => f !== undefined));\n resolvedSettings.set(key, out);\n return out;\n };\n\n const headerFor = (row: Row, options: RecordViewHeaderOptions<Row> = {}): RecordViewHeader => {\n const summary = view.summary(row);\n const served = options.served ? new Set(options.served) : null;\n const actions: RecordViewHeaderAction[] = [];\n if (options.runnable !== false) {\n for (const name of headerActions) {\n if (served && !served.has(name)) continue;\n const own = options.can?.(name, row);\n if (own === false) continue;\n // Guards only narrow: the screen's refusal wins, then the view's.\n const allowed: Allowed = typeof own === \"string\" ? own || REFUSED : view.canAction(name, row, options.viewer);\n actions.push(Object.freeze({ ...actionByName.get(name)!, allowed }));\n }\n }\n return Object.freeze({\n title: summary.title,\n ...(summary.subtitle !== undefined ? { subtitle: summary.subtitle } : {}),\n chips: Object.freeze([...(summary.chips ?? [])]),\n actions: Object.freeze(actions),\n });\n };\n\n const readinessFor = (row: Row): readonly ResolvedReadinessItem[] => {\n if (!readiness) return Object.freeze([]);\n return Object.freeze(\n readiness(row).map((item, i) => {\n let tone = item.tone ?? (item.ok ? \"success\" : \"warning\");\n if (!TONES.has(tone)) {\n if (dev()) console.warn(`[genesis-core] ${where}: readiness \"${item.title}\" has tone \"${String(tone)}\", which isn't a chip tone; showing it muted.`);\n tone = \"muted\";\n }\n return Object.freeze({\n key: item.id ?? `${i}:${item.title}`,\n title: item.title,\n ok: Boolean(item.ok),\n ...(item.reason !== undefined ? { reason: item.reason } : {}),\n tone,\n });\n }),\n );\n };\n\n const readinessSummary = (row: Row): Readiness | null =>\n readiness\n ? readinessOf(\n readinessFor(row)\n .filter((r) => !r.ok)\n .map((r) => ({ level: r.tone === \"danger\" ? (\"error\" as const) : (\"warning\" as const) })),\n )\n : null;\n\n return Object.freeze({\n [WORKSPACE]: true,\n view,\n sections: frozenSections,\n headerActions,\n hasReadiness: Boolean(readiness),\n template,\n document,\n section: (id: string) => byId.get(id),\n recordId: (row: Row) => encodeRecordKey(view.contract, row),\n settingsLocked: (row: Row, viewer?: Viewer) => {\n const allowed = view.can(\"update\", row, viewer);\n return allowed === true ? null : typeof allowed === \"string\" && allowed.trim() ? allowed : REFUSED;\n },\n headerFor,\n settingsFields,\n settingsPatch: (sectionId: string, values: Readonly<Record<string, unknown>>) => {\n const patch: Record<string, unknown> = {};\n for (const name of settingsOf(sectionId)) if (Object.hasOwn(values, name)) patch[name] = values[name];\n return patch;\n },\n listFilter: (sectionId: string, row: Row) => {\n const filter = filters.get(sectionId);\n if (!filter) throw new ViewDefinitionError(where, [`no list section \"${sectionId}\"`]);\n const out = filter(row);\n if (dev()) {\n const entries = out && typeof out === \"object\" ? Object.entries(out) : [];\n const bad = entries.filter(([, v]) => !(v === null || typeof v === \"string\" || typeof v === \"number\" || typeof v === \"boolean\"));\n if (entries.length === 0 || bad.length) {\n throw new ViewDefinitionError(where, [\n entries.length === 0\n ? `sections.${sectionId}.list.filter gave no keys, which would list every row`\n : `sections.${sectionId}.list.filter gives ${bad.map(([k]) => `\"${k}\"`).join(\", \")} no single value`,\n ]);\n }\n }\n return Object.freeze({ ...out });\n },\n readinessFor,\n readinessSummary,\n }) as RecordView<C, Row>;\n}\n\n// The names before record views were called record views (\"workspace\" now means where the viewer\n// is working: docs/adr/0004-workspaces.md). Kept for one minor release.\n\n/** @deprecated Renamed `defineRecordView`. Removed in the next major. @stability Deprecated */\nexport const defineWorkspace = defineRecordView;\n/** @deprecated Renamed `isRecordView`. Removed in the next major. @stability Deprecated */\nexport const isWorkspace = isRecordView;\n/** @deprecated Renamed `RecordView`. Removed in the next major. @stability Deprecated */\nexport type ResourceWorkspace<C extends ResourceContract = ResourceContract, Row extends DataRow = RowOf<C>> = RecordView<C, Row>;\n/** @deprecated Renamed `RecordViewDefinition`. */\nexport type WorkspaceDefinition<C extends ResourceContract, Row extends DataRow = RowOf<C>> = RecordViewDefinition<C, Row>;\n/** @deprecated Renamed `RecordViewSection`. */\nexport type WorkspaceSection<Row extends DataRow = DataRow, Name extends string = string> = RecordViewSection<Row, Name>;\n/** @deprecated Renamed `RecordViewHeaderAction`. */\nexport type WorkspaceHeaderAction = RecordViewHeaderAction;\n","// defineWidget: a small tile on a dashboard or a record page's sidebar, fed by a view (ADR 0023).\n//\n// A widget is data, with no React: which view it reads (and so which resource, scope, preset\n// and permissions), what it needs from it (a total, or a few rows), its label and how its value\n// reads. genesis-ui's `<Widget>` draws it; a phone draws the same definition. The pure helpers\n// here (`resolveWidgetRequest`, `resolveStreak`, `resolveChartSeries`, `toWidgetText`) are what\n// both platforms compute, so they can't drift.\n\nimport { addDays, dayIn, deviceTimeZone, isDay, startOfWeek, type Day } from \"../dates\";\nimport type { ResourceScope } from \"../hooks/viewer-scope\";\nimport type { AggregateMetric, AggregateParams, FilterParam, SortParam } from \"../provider/types\";\nimport { toAggregateValues } from \"../provider/aggregate\";\nimport type { DataRow, ResourceContract } from \"../schema/types\";\nimport { ViewDefinitionError } from \"./errors\";\nimport { filterParams } from \"./link\";\nimport { scopeFilter } from \"./scope\";\nimport type { Allowed, ResourceView, Viewer } from \"./types\";\n\n/** The built-in kinds of widget. */\nexport type WidgetKind = \"number\" | \"progress\" | \"streak\" | \"list\" | \"chart\";\n\n/** How a widget's number reads: plain, short (`1.2k`), a percent of 1, a currency, or your own words. */\nexport type WidgetFormat =\n | \"number\"\n | \"compact\"\n | \"percent\"\n | { currency: string; maximumFractionDigits?: number }\n | ((value: number) => string);\n\ntype Scalar = string | number | boolean | null;\n/** Values a widget narrows its view by, as a screen's `filter`: `{ status: \"open\" }`, `{ owner_id: [a, b] }`. */\nexport type WidgetFilter = Readonly<Record<string, Scalar | readonly (string | number)[]>>;\n\n/** What every kind of widget says. */\nexport interface WidgetBase<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> {\n /** Stable, unique on its dashboard: a key, a test id, a saved layout's entry. */\n id: string;\n /** What the tile is called (\"Open deals\"). */\n label: string;\n /** The view it reads: its resource, scope keys, presets, fields and who may read them. */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- any contract's view\n view: ResourceView<C, Row & any>;\n /** One of the view's presets: its filter narrows the rows, as a tab would. */\n preset?: string;\n /** More values to narrow by, over the scope and the preset. */\n filter?: WidgetFilter;\n /** A short line under the value (\"this quarter\"). */\n description?: string;\n /** Where the tile goes when pressed: the full view, usually. */\n href?: string;\n /**\n * Whether this viewer sees the tile: `true`, or the reason not. Only narrows; the view's own\n * field permissions (a field the viewer can't read) hide it too, and row security decides\n * which rows any total covers.\n */\n can?: (viewer: Viewer | undefined) => Allowed;\n /** Keep the tile current with changes made elsewhere (`DataProvider.subscribe`). Default true. */\n live?: boolean;\n}\n\n/** A number: a count, or the sum, average, lowest or highest of a field. */\nexport interface NumberWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"number\";\n /** What to total. Default `{ fn: \"count\" }`. */\n metric?: AggregateMetric;\n format?: WidgetFormat;\n}\n\n/** Progress toward a goal: a total over a fixed number, or over another total (done of all). */\nexport interface ProgressWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"progress\";\n /** What counts as done. Default `{ fn: \"count\" }` over the widget's rows. */\n metric?: AggregateMetric;\n /**\n * The goal: a number, or a total over the view's scope and `goalFilter` (not the preset or\n * `filter`): `{ fn: \"count\" }` with the preset \"done\" makes \"done of all\".\n */\n goal: number | AggregateMetric;\n /** Narrows the goal's rows when it is a total. */\n goalFilter?: WidgetFilter;\n format?: WidgetFormat;\n}\n\n/** A streak: how many days (or weeks) in a row, up to today, have at least one row. */\nexport interface StreakWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"streak\";\n /** The date (or timestamp) field a row counts on. */\n dateField: string;\n /** Default `day`. Weeks start on Monday. */\n unit?: \"day\" | \"week\";\n /** The zone days are counted in. Default the device's. */\n timeZone?: string;\n /** The most recent rows read to count it. Default 400. */\n limit?: number;\n}\n\n/** A short list: the first few rows, as the view names them. */\nexport interface ListWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"list\";\n /** Rows shown. Default 5, at most 50. */\n limit?: number;\n /** Their order. Default the view's `orderBy`. */\n sort?: SortParam;\n}\n\n/** A chart: one bar (or point) per value of a field, with a count or a total each. */\nexport interface ChartWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> extends WidgetBase<C, Row> {\n kind: \"chart\";\n /** The field whose values are the bars. */\n groupBy: string;\n /** Each bar's height. Default `{ fn: \"count\" }`. */\n metric?: AggregateMetric;\n /** Default `bar`. */\n chart?: \"bar\" | \"line\";\n /** The most rows read to draw it. Default 1000. */\n limit?: number;\n format?: WidgetFormat;\n}\n\n/** What `defineWidget` accepts. */\nexport type WidgetDefinition<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> =\n | NumberWidget<C, Row>\n | ProgressWidget<C, Row>\n | StreakWidget<C, Row>\n | ListWidget<C, Row>\n | ChartWidget<C, Row>;\n\n/** A checked, frozen widget. */\nexport type DefinedWidget<C extends ResourceContract = ResourceContract, Row extends DataRow = DataRow> = Readonly<WidgetDefinition<C, Row>> & {\n readonly __widget: true;\n};\n\nconst ID = /^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/;\n\nfunction metricProblems(where: string, metric: AggregateMetric | undefined, view: WidgetBase[\"view\"]): string[] {\n if (!metric || metric.fn === \"count\") return [];\n if (![\"sum\", \"avg\", \"min\", \"max\"].includes(metric.fn)) return [`${where}.fn: one of count, sum, avg, min, max`];\n if (!view.field(metric.field)) return [`${where}.field: \"${metric.field}\" isn't a field of ${view.resource}`];\n return [];\n}\n\n/** Every problem with a widget; empty when it is sound. */\nexport function widgetProblems(input: WidgetDefinition): string[] {\n const w = input as Partial<WidgetDefinition> & Record<string, unknown>;\n if (!w || typeof w !== \"object\") return [\"expected a widget\"];\n const problems: string[] = [];\n if (typeof w.id !== \"string\" || !ID.test(w.id)) problems.push(\"id: a letter, then letters, digits, - or _\");\n if (typeof w.label !== \"string\" || !w.label.trim()) problems.push(\"label: expected a non-empty string\");\n const view = w.view;\n if (!view || typeof view !== \"object\" || typeof view.field !== \"function\") return [...problems, \"view: a view from defineView\"];\n if (w.preset !== undefined && !view.definition.presets?.[w.preset]) problems.push(`preset: ${view.resource} has no preset \"${w.preset}\"`);\n for (const field of Object.keys(w.filter ?? {})) if (!view.field(field)) problems.push(`filter.${field}: not a field of ${view.resource}`);\n const currency = (w as { format?: { currency?: unknown } }).format?.currency;\n if (currency !== undefined) {\n try {\n new Intl.NumberFormat(\"en\", { style: \"currency\", currency: String(currency) });\n } catch {\n problems.push(\"format.currency: an ISO 4217 code (USD, EUR)\");\n }\n }\n switch (w.kind) {\n case \"number\":\n problems.push(...metricProblems(\"metric\", w.metric, view));\n break;\n case \"progress\":\n problems.push(...metricProblems(\"metric\", w.metric, view));\n if (typeof w.goal === \"number\") {\n if (!(w.goal > 0)) problems.push(\"goal: a number above 0, or a total\");\n } else if (!w.goal || typeof w.goal !== \"object\") problems.push(\"goal: a number above 0, or a total\");\n else problems.push(...metricProblems(\"goal\", w.goal, view));\n for (const field of Object.keys(w.goalFilter ?? {})) if (!view.field(field)) problems.push(`goalFilter.${field}: not a field of ${view.resource}`);\n break;\n case \"streak\":\n if (typeof w.dateField !== \"string\" || !view.field(w.dateField)) problems.push(`dateField: not a field of ${view.resource}`);\n if (w.unit !== undefined && w.unit !== \"day\" && w.unit !== \"week\") problems.push(\"unit: day or week\");\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 1000)) problems.push(\"limit: a whole number from 1 to 1000\");\n break;\n case \"list\":\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 50)) problems.push(\"limit: a whole number from 1 to 50\");\n if (w.sort && !view.field(w.sort.field)) problems.push(`sort.field: not a field of ${view.resource}`);\n break;\n case \"chart\":\n if (typeof w.groupBy !== \"string\" || !view.field(w.groupBy)) problems.push(`groupBy: not a field of ${view.resource}`);\n problems.push(...metricProblems(\"metric\", w.metric, view));\n if (w.chart !== undefined && w.chart !== \"bar\" && w.chart !== \"line\") problems.push(\"chart: bar or line\");\n if (w.limit !== undefined && !(Number.isInteger(w.limit) && w.limit > 0 && w.limit <= 1000)) problems.push(\"limit: a whole number from 1 to 1000\");\n break;\n default:\n problems.push(\"kind: one of number, progress, streak, list, chart\");\n }\n return problems;\n}\n\n/**\n * Define a widget: a tile fed by a view. Checks it against the view (its fields, presets) and\n * returns it frozen. Throws {@link ViewDefinitionError} with every problem.\n *\n * ```ts\n * const openDeals = defineWidget({ id: \"open-deals\", kind: \"number\", label: \"Open deals\", view: dealsView, preset: \"open\" });\n * const pipeline = defineWidget({\n * id: \"pipeline\", kind: \"number\", label: \"Pipeline\", view: dealsView, preset: \"open\",\n * metric: { fn: \"sum\", field: \"amount\" }, format: { currency: \"USD\" },\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineWidget<C extends ResourceContract, Row extends DataRow>(input: WidgetDefinition<C, Row>): DefinedWidget<C, Row> {\n const problems = widgetProblems(input as unknown as WidgetDefinition);\n if (problems.length) throw new ViewDefinitionError(`widget ${String((input as { id?: unknown })?.id)}`, problems);\n // Shallow: the view inside is already frozen, and functions (format, can) stay as given.\n return Object.freeze({ ...input, __widget: true as const }) as DefinedWidget<C, Row>;\n}\n\n/** Whether a value is a widget from `defineWidget`. */\nexport function isWidget(value: unknown): value is DefinedWidget {\n return !!value && typeof value === \"object\" && (value as { __widget?: unknown }).__widget === true;\n}\n\n/** The fields a widget reads: hidden from a viewer who can't read any of them. */\nfunction fieldsRead(w: WidgetDefinition): string[] {\n switch (w.kind) {\n case \"number\":\n return w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : [];\n case \"progress\":\n return [\n ...(w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : []),\n ...(typeof w.goal === \"object\" && w.goal.fn !== \"count\" ? [w.goal.field] : []),\n ];\n case \"streak\":\n return [w.dateField];\n case \"chart\":\n return [w.groupBy, ...(w.metric && w.metric.fn !== \"count\" ? [w.metric.field] : [])];\n case \"list\":\n return [];\n }\n}\n\n/**\n * Whether this viewer sees the widget: `true`, or the reason not. A field it totals that the\n * viewer can't read (`permissions.read: false` in the contract) hides it, then the widget's own\n * `can`. Only narrows: row security still decides the rows behind any total.\n *\n * @stability Beta\n */\nexport function resolveWidgetAccess(widget: WidgetDefinition, viewer?: Viewer): Allowed {\n for (const field of fieldsRead(widget)) {\n if (widget.view.field(field)?.permissions?.read === false) return `You can't see ${widget.view.label(field).toLowerCase()}.`;\n }\n return widget.can ? widget.can(viewer) : true;\n}\n\n/** What a widget asks its provider for, from its view, scope, preset and filter. */\nexport interface WidgetRequest {\n resource: string;\n /** The preset's filter, the scope, then the widget's own filter. */\n filters: FilterParam[];\n /** Totals to ask `aggregate` for (number, progress). */\n aggregate?: AggregateParams;\n /** The goal's totals, over the scope and `goalFilter` only (progress with a total goal). */\n goal?: AggregateParams;\n /** Rows to read (streak, list, chart): how many and in what order. */\n rows?: { perPage: number; sort?: SortParam };\n}\n\n/**\n * What a widget needs from its provider, for a viewer working in `scope` (ViewerScope's): the\n * filters its view would list with, and either the totals or the rows. `<Widget>` and a phone\n * build their reads from this.\n *\n * @stability Beta\n */\nexport function resolveWidgetRequest(widget: WidgetDefinition, scope?: ResourceScope | null): WidgetRequest {\n const { view } = widget;\n const preset = widget.preset ? view.definition.presets?.[widget.preset] : undefined;\n if (widget.preset && !preset) throw new ViewDefinitionError(view.resource, [`no preset \"${widget.preset}\"`]);\n const scoped = filterParams(scopeFilter(view, scope) as WidgetFilter);\n const filters = [...filterParams(preset?.filter as WidgetFilter | undefined), ...scoped, ...filterParams(widget.filter)];\n const orderBy = view.definition.orderBy;\n const viewSort: SortParam | undefined = orderBy\n ? { field: orderBy.field as string, order: orderBy.direction ?? \"asc\", ...(orderBy.nulls ? { nulls: orderBy.nulls } : {}) }\n : undefined;\n switch (widget.kind) {\n case \"number\":\n return { resource: view.resource, filters, aggregate: { metrics: { value: widget.metric ?? { fn: \"count\" } }, filters } };\n case \"progress\": {\n const request: WidgetRequest = { resource: view.resource, filters, aggregate: { metrics: { value: widget.metric ?? { fn: \"count\" } }, filters } };\n if (typeof widget.goal === \"object\") {\n const goalFilters = [...scoped, ...filterParams(widget.goalFilter)];\n request.goal = { metrics: { goal: widget.goal }, filters: goalFilters };\n }\n return request;\n }\n case \"streak\":\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 400, sort: { field: widget.dateField, order: \"desc\", nulls: \"last\" } } };\n case \"list\": {\n const sort = widget.sort ?? viewSort;\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 5, ...(sort ? { sort } : {}) } };\n }\n case \"chart\":\n return { resource: view.resource, filters, rows: { perPage: widget.limit ?? 1000 } };\n }\n}\n\n/** The day a row's date or timestamp falls on, in `zone`. */\nfunction dayOfValue(value: unknown, zone: string): Day | undefined {\n if (typeof value === \"string\" && isDay(value)) return value;\n if (typeof value !== \"string\" && !(value instanceof Date) && typeof value !== \"number\") return undefined;\n const at = value instanceof Date ? value : new Date(value);\n return Number.isNaN(at.getTime()) ? undefined : dayIn(zone, at);\n}\n\n/** A streak's length and whether today (this week) is already in it. */\nexport interface Streak {\n /** Days (or weeks) in a row, ending today or, while today is still open, yesterday. */\n current: number;\n /** Whether today (this week) has a row. */\n today: boolean;\n unit: \"day\" | \"week\";\n}\n\n/**\n * How many days (or weeks) in a row have at least one of `values` (dates or timestamps), ending\n * today, or yesterday while today has none yet, so a streak isn't broken before the day is over.\n *\n * @stability Beta\n */\nexport function resolveStreak(\n values: readonly unknown[],\n options: { unit?: \"day\" | \"week\"; timeZone?: string; today?: Day } = {},\n): Streak {\n const unit = options.unit ?? \"day\";\n const zone = options.timeZone ?? deviceTimeZone();\n const step = unit === \"day\" ? 1 : 7;\n const bucket = (day: Day) => (unit === \"day\" ? day : startOfWeek(day, 1));\n const seen = new Set<Day>();\n for (const value of values) {\n const day = dayOfValue(value, zone);\n if (day) seen.add(bucket(day));\n }\n const now = bucket(options.today ?? dayIn(zone));\n const today = seen.has(now);\n let at = today ? now : addDays(now, -step);\n let current = 0;\n while (seen.has(at)) {\n current++;\n at = addDays(at, -step);\n }\n return { current, today, unit };\n}\n\n/** One bar (or point) of a chart widget. */\nexport interface ChartPoint {\n /** The field's value, as text (`\"(none)\"` for an empty one). */\n key: string;\n /** The value in words (`ResourceView.valueLabel`). */\n label: string;\n value: number;\n}\n\n/**\n * A chart widget's bars from its rows: one per value of `groupBy`, in the field's choice order\n * when it has choices (else by value), each the metric over the rows with that value.\n *\n * @stability Beta\n */\nexport function resolveChartSeries(widget: ChartWidget, rows: readonly Record<string, unknown>[]): ChartPoint[] {\n const groups = new Map<string, Record<string, unknown>[]>();\n for (const row of rows) {\n const raw = row[widget.groupBy];\n const key = raw === null || raw === undefined || raw === \"\" ? \"(none)\" : String(raw);\n const list = groups.get(key) ?? [];\n list.push(row);\n groups.set(key, list);\n }\n const choices = (widget.view.field(widget.groupBy)?.enumValues ?? []) as readonly string[];\n const keys = [\n ...choices.filter((c) => groups.has(c)),\n ...[...groups.keys()].filter((k) => !choices.includes(k)).sort((a, b) => a.localeCompare(b, undefined, { numeric: true })),\n ];\n const metric = widget.metric ?? { fn: \"count\" as const };\n return keys.map((key) => {\n const list = groups.get(key)!;\n // The same rule as a number widget's total: rows with no number in the field are skipped, not\n // read as 0; a group where none has one draws as 0.\n const value = toAggregateValues(list, { value: metric })[\"value\"] ?? 0;\n return { key, label: key === \"(none)\" ? \"None\" : widget.view.valueLabel(widget.groupBy, key), value };\n });\n}\n\n/**\n * A widget's number in words: `null` reads \"—\", a percent is of 1 (0.42 is 42%).\n *\n * @stability Beta\n */\nexport function toWidgetText(value: number | null | undefined, format: WidgetFormat = \"number\", locale?: string): string {\n if (value === null || value === undefined || !Number.isFinite(value)) return \"—\";\n if (typeof format === \"function\") return format(value);\n if (typeof format === \"object\") {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: format.currency,\n ...(format.maximumFractionDigits !== undefined ? { maximumFractionDigits: format.maximumFractionDigits } : {}),\n }).format(value);\n }\n switch (format) {\n case \"compact\":\n return new Intl.NumberFormat(locale, { notation: \"compact\", maximumFractionDigits: 1 }).format(value);\n case \"percent\":\n return new Intl.NumberFormat(locale, { style: \"percent\", maximumFractionDigits: 0 }).format(value);\n default:\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 2 }).format(value);\n }\n}\n\n/**\n * Progress as a fraction from 0 to 1 (more than 1 when the goal is passed), or null without a\n * goal to measure against.\n *\n * @stability Beta\n */\nexport function resolveProgress(value: number | null | undefined, goal: number | null | undefined): number | null {\n if (value === null || value === undefined || goal === null || goal === undefined || !(goal > 0)) return null;\n return Math.max(0, value / goal);\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { S as StorageAdapter } from './types-DKcxHXxq.js';
2
- import { b as ViewFilterValue, c as ViewFilterKind, d as ResolvedFilter, S as SegmentWhere } from './types-BAhcze_-.js';
3
- import { a as FilterParam } from './types-CiQY6hUy.js';
2
+ import { b as ViewFilterValue, c as ViewFilterKind, d as ResolvedFilter, S as SegmentWhere } from './types-CBtBvGw0.js';
3
+ import { a as FilterParam } from './types-BnOCVJzm.js';
4
4
 
5
5
  /** A segment's `where` as provider filters. A range keeps only the ends it has. */
6
6
  declare function whereParams(where: SegmentWhere | null | undefined): FilterParam[];
@@ -1,8 +1,7 @@
1
- import { R as ResourceContract, c as Identifier, e as DataRow } from '../types-CiQY6hUy.js';
2
- export { j as AuditEntry, C as ControlHint, v as FieldPermissions, f as FieldReference, F as FieldSchema, x as FilterOperator, P as ProviderCapabilities, O as RecordComment, Q as ResourceAccess, T as ResourceRelation, U as ResourceSchema, V as ResourceSummary, m as RowAction, l as RowOf, _ as StorageType, a1 as VersionField, a2 as WidgetHint, a3 as defineResource, a4 as fieldControl } from '../types-CiQY6hUy.js';
3
- export { D as DataWriteError, a as DataWriteErrorOptions, N as NO_ROWS_MATCHED, W as WriteOutcome, i as isDataWriteError } from '../write-outcome-DuwfsnyO.js';
1
+ import { R as ResourceContract, c as Identifier, e as DataRow } from '../types-BnOCVJzm.js';
2
+ export { j as AuditEntry, q as ControlHint, v as FieldPermissions, f as FieldReference, F as FieldSchema, x as FilterOperator, P as ProviderCapabilities, O as RecordComment, Q as ResourceAccess, T as ResourceRelation, U as ResourceSchema, V as ResourceSummary, m as RowAction, l as RowOf, _ as StorageType, a1 as VersionField, a2 as WidgetHint, a3 as defineResource, a4 as fieldControl } from '../types-BnOCVJzm.js';
3
+ export { D as DataReadError, a as DataReadErrorOptions, b as DataWriteError, c as DataWriteErrorOptions, N as NO_ROWS_MATCHED, R as ReadOutcome, W as WriteOutcome, i as isDataReadError, d as isDataWriteError, r as readFailureMessage } from '../read-outcome-Cq0h2oAG.js';
4
4
  export { W as WriteConflict, a as WriteConflictOptions, b as WriteState, w as writeConflict } from '../write-state-DVC4Yq9T.js';
5
- export { D as DataReadError, a as DataReadErrorOptions, R as ReadOutcome, i as isDataReadError, r as readFailureMessage } from '../read-outcome-BnboMYOV.js';
6
5
 
7
6
  /** The key of a contract as a list, whichever form `key` was declared in. */
8
7
  declare function keyFields(contract: Pick<ResourceContract, "key">): readonly string[];