@ai-matrx/records-ui 0.116.59 → 0.116.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -1
- package/dist/{SaveToTable-2TQKEYJA.js → SaveToTable-VPLDWCSU.js} +4 -4
- package/dist/{chunk-AJVN4BMI.js → chunk-2YK72GHL.js} +305 -248
- package/dist/chunk-2YK72GHL.js.map +1 -0
- package/dist/{chunk-NGOPU3AJ.js → chunk-4KWCNW7V.js} +5 -4
- package/dist/{chunk-NGOPU3AJ.js.map → chunk-4KWCNW7V.js.map} +1 -1
- package/dist/{chunk-MBUW42SM.js → chunk-NBL26U5K.js} +2 -2
- package/dist/{chunk-4ZS4WEEE.js → chunk-TEYXG4XD.js} +73 -4
- package/dist/chunk-TEYXG4XD.js.map +1 -0
- package/dist/{chunk-HAWACXPU.js → chunk-W6FX3XVF.js} +2 -2
- package/dist/{chunk-Y6U5OFJX.js → chunk-WXYI4DKC.js} +3 -3
- package/dist/data-source.cjs +2 -1
- package/dist/data-source.cjs.map +1 -1
- package/dist/data-source.js +2 -1
- package/dist/data-source.js.map +1 -1
- package/dist/helpers.cjs +7 -7
- package/dist/helpers.cjs.map +1 -1
- package/dist/helpers.js +8 -8
- package/dist/helpers.js.map +1 -1
- package/dist/index.cjs +734 -617
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -16
- package/dist/index.d.ts +17 -16
- package/dist/index.js +56 -64
- package/dist/index.js.map +1 -1
- package/dist/pickers.cjs +106 -96
- package/dist/pickers.cjs.map +1 -1
- package/dist/pickers.js +4 -4
- package/dist/skeleton.js +3 -3
- package/package.json +6 -6
- package/dist/chunk-4ZS4WEEE.js.map +0 -1
- package/dist/chunk-AJVN4BMI.js.map +0 -1
- /package/dist/{SaveToTable-2TQKEYJA.js.map → SaveToTable-VPLDWCSU.js.map} +0 -0
- /package/dist/{chunk-MBUW42SM.js.map → chunk-NBL26U5K.js.map} +0 -0
- /package/dist/{chunk-HAWACXPU.js.map → chunk-W6FX3XVF.js.map} +0 -0
- /package/dist/{chunk-Y6U5OFJX.js.map → chunk-WXYI4DKC.js.map} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
EMBEDDED_PLAIN_FOOTER_CLASS,
|
|
4
4
|
EMBEDDED_TABLE_CLASS
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-W6FX3XVF.js";
|
|
6
6
|
|
|
7
7
|
// src/skeletonLayout.ts
|
|
8
8
|
var RECORDS_SKELETON_LAYOUTS = [
|
|
@@ -302,4 +302,4 @@ export {
|
|
|
302
302
|
RecordsSkeleton,
|
|
303
303
|
TablePageSkeleton
|
|
304
304
|
};
|
|
305
|
-
//# sourceMappingURL=chunk-
|
|
305
|
+
//# sourceMappingURL=chunk-NBL26U5K.js.map
|
|
@@ -4,6 +4,68 @@ import {
|
|
|
4
4
|
isSystemFieldKind
|
|
5
5
|
} from "./chunk-WCQSJPLS.js";
|
|
6
6
|
|
|
7
|
+
// src/personZone.ts
|
|
8
|
+
import { setColorRuleTimeZone, setDisplayTimeZone } from "@ai-matrx/design-system/data-table/table-style";
|
|
9
|
+
import { globalSlot } from "@ai-matrx/kit/global-slot";
|
|
10
|
+
var state = globalSlot("ai-matrx.records-ui.person-time-zone", () => ({
|
|
11
|
+
zone: null,
|
|
12
|
+
listeners: /* @__PURE__ */ new Set()
|
|
13
|
+
}));
|
|
14
|
+
function valid(z) {
|
|
15
|
+
if (typeof z !== "string" || !z.trim()) return false;
|
|
16
|
+
try {
|
|
17
|
+
new Intl.DateTimeFormat("en-US", { timeZone: z });
|
|
18
|
+
return true;
|
|
19
|
+
} catch {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function setPersonTimeZone(next) {
|
|
24
|
+
const clean = valid(next) ? next : null;
|
|
25
|
+
if (clean === state.zone) return;
|
|
26
|
+
state.zone = clean;
|
|
27
|
+
setColorRuleTimeZone(clean);
|
|
28
|
+
setDisplayTimeZone(clean);
|
|
29
|
+
state.listeners.forEach((l) => l());
|
|
30
|
+
}
|
|
31
|
+
function getPersonTimeZone() {
|
|
32
|
+
return state.zone;
|
|
33
|
+
}
|
|
34
|
+
function subscribePersonTimeZone(listener) {
|
|
35
|
+
state.listeners.add(listener);
|
|
36
|
+
return () => {
|
|
37
|
+
state.listeners.delete(listener);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function personWallNow(at = /* @__PURE__ */ new Date()) {
|
|
41
|
+
const zone = state.zone;
|
|
42
|
+
if (!zone) return at;
|
|
43
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
44
|
+
timeZone: zone,
|
|
45
|
+
year: "numeric",
|
|
46
|
+
month: "2-digit",
|
|
47
|
+
day: "2-digit",
|
|
48
|
+
hour: "2-digit",
|
|
49
|
+
minute: "2-digit",
|
|
50
|
+
second: "2-digit",
|
|
51
|
+
hourCycle: "h23"
|
|
52
|
+
}).formatToParts(at);
|
|
53
|
+
const n = (t) => Number(parts.find((p) => p.type === t)?.value ?? 0);
|
|
54
|
+
return new Date(n("year"), n("month") - 1, n("day"), n("hour"), n("minute"), n("second"));
|
|
55
|
+
}
|
|
56
|
+
function instantFromPersonWall(wall) {
|
|
57
|
+
const zone = state.zone;
|
|
58
|
+
if (!zone) return wall;
|
|
59
|
+
const target = Date.UTC(wall.getFullYear(), wall.getMonth(), wall.getDate(), wall.getHours(), wall.getMinutes(), wall.getSeconds(), wall.getMilliseconds());
|
|
60
|
+
let guess = target;
|
|
61
|
+
for (let i = 0; i < 3; i += 1) {
|
|
62
|
+
const seen = personWallNow(new Date(guess));
|
|
63
|
+
const shown = Date.UTC(seen.getFullYear(), seen.getMonth(), seen.getDate(), seen.getHours(), seen.getMinutes(), seen.getSeconds(), wall.getMilliseconds());
|
|
64
|
+
guess -= shown - target;
|
|
65
|
+
}
|
|
66
|
+
return new Date(guess);
|
|
67
|
+
}
|
|
68
|
+
|
|
7
69
|
// src/docs.ts
|
|
8
70
|
function fieldToken(fieldId) {
|
|
9
71
|
return `{{field:${fieldId}}}`;
|
|
@@ -174,6 +236,7 @@ function fieldTypeLabel(field) {
|
|
|
174
236
|
|
|
175
237
|
// src/dates.ts
|
|
176
238
|
import { formatFieldValue } from "@ai-matrx/design-system/field-formats";
|
|
239
|
+
import { momentZoneOptions } from "@ai-matrx/design-system/field-formats";
|
|
177
240
|
var BARE_CALENDAR_DATE = /^(\d{4})-(\d{2})-(\d{2})(?:[T ]00:00(?::00(?:\.0+)?)?)?$/;
|
|
178
241
|
function systemStampOf(field) {
|
|
179
242
|
if (field.type !== "formula") return null;
|
|
@@ -189,7 +252,7 @@ function carriesTimeOfDay(field, value) {
|
|
|
189
252
|
function timeOfDayWords(value) {
|
|
190
253
|
if (!hasTimePart(value)) return null;
|
|
191
254
|
const at = value instanceof Date ? value : new Date(value);
|
|
192
|
-
return Number.isNaN(at.getTime()) ? null : at.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
|
|
255
|
+
return Number.isNaN(at.getTime()) ? null : at.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit", ...momentZoneOptions(at) });
|
|
193
256
|
}
|
|
194
257
|
function hasTimePart(value) {
|
|
195
258
|
if (value instanceof Date || typeof value === "number") return true;
|
|
@@ -230,8 +293,9 @@ function calendarDayOf(value) {
|
|
|
230
293
|
} else if (typeof value !== "number" && !(value instanceof Date)) {
|
|
231
294
|
return null;
|
|
232
295
|
}
|
|
233
|
-
const
|
|
234
|
-
if (Number.isNaN(
|
|
296
|
+
const instant = value instanceof Date ? value : new Date(value);
|
|
297
|
+
if (Number.isNaN(instant.getTime())) return null;
|
|
298
|
+
const at = personWallNow(instant);
|
|
235
299
|
return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;
|
|
236
300
|
}
|
|
237
301
|
function calendarDayLabel(day) {
|
|
@@ -257,6 +321,11 @@ function daysBetween(from, to) {
|
|
|
257
321
|
}
|
|
258
322
|
|
|
259
323
|
export {
|
|
324
|
+
setPersonTimeZone,
|
|
325
|
+
getPersonTimeZone,
|
|
326
|
+
subscribePersonTimeZone,
|
|
327
|
+
personWallNow,
|
|
328
|
+
instantFromPersonWall,
|
|
260
329
|
displayFormatOf,
|
|
261
330
|
choiceLooksOf,
|
|
262
331
|
choiceWord,
|
|
@@ -287,4 +356,4 @@ export {
|
|
|
287
356
|
addDays,
|
|
288
357
|
daysBetween
|
|
289
358
|
};
|
|
290
|
-
//# sourceMappingURL=chunk-
|
|
359
|
+
//# sourceMappingURL=chunk-TEYXG4XD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/personZone.ts","../src/docs.ts","../src/choiceLooks.ts","../src/parity.ts","../src/dates.ts"],"sourcesContent":["// The person's time zone, as the app saved it (userPreferences.display.timeZone).\n//\n// The host app tells this package once (`setPersonTimeZone(\"America/Los_Angeles\")`); every \"today\" and\n// \"now\" a screen draws (the calendar's today marker and now-line, a timeline's today, a date picker's\n// today) is read in that zone instead of the device's. With nothing set the device zone applies, as before.\n// Nothing here stores a zone: the host's saved preference is the one place, this is its mirror.\n\nimport { setColorRuleTimeZone, setDisplayTimeZone } from \"@ai-matrx/design-system/data-table/table-style\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\n// No React here: `@ai-matrx/records-ui/helpers` serves this file alone (the host sets the zone at\n// boot), and the root entry carries its own copy — so the zone lives in ONE realm-wide slot that\n// both copies read, never a module `let` that would split in two. The hook is `./personTime`.\nconst state = globalSlot(\"ai-matrx.records-ui.person-time-zone\", () => ({\n zone: null as string | null,\n listeners: new Set<() => void>(),\n}));\n\nfunction valid(z: unknown): z is string {\n if (typeof z !== \"string\" || !z.trim()) return false;\n try {\n new Intl.DateTimeFormat(\"en-US\", { timeZone: z });\n return true;\n } catch {\n return false;\n }\n}\n\n/** The host app's saved zone (IANA). `null` / junk clears it: the device zone applies. */\nexport function setPersonTimeZone(next: string | null | undefined): void {\n const clean = valid(next) ? next : null;\n if (clean === state.zone) return;\n state.zone = clean;\n // \"Today\" in a color rule is the person's day, not the device's (lane NOTION-SMALL-2).\n setColorRuleTimeZone(clean);\n // And every moment a screen prints (grid cell, panel, card, export) reads in it too: ONE zone, one slot.\n setDisplayTimeZone(clean);\n state.listeners.forEach((l) => l());\n}\n\nexport function getPersonTimeZone(): string | null {\n return state.zone;\n}\n\n/** Calls `listener` whenever the zone changes; returns the unsubscribe. */\nexport function subscribePersonTimeZone(listener: () => void): () => void {\n state.listeners.add(listener);\n return () => {\n state.listeners.delete(listener);\n };\n}\n\n/**\n * `at` as a Date whose LOCAL fields (getFullYear, getHours, ...) read the wall clock in the person's zone.\n * For day / hour math only: never compare it with a stored instant.\n */\nexport function personWallNow(at: Date = new Date()): Date {\n const zone = state.zone;\n if (!zone) return at;\n const parts = new Intl.DateTimeFormat(\"en-US\", {\n timeZone: zone,\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n hourCycle: \"h23\",\n }).formatToParts(at);\n const n = (t: string) => Number(parts.find((p) => p.type === t)?.value ?? 0);\n return new Date(n(\"year\"), n(\"month\") - 1, n(\"day\"), n(\"hour\"), n(\"minute\"), n(\"second\"));\n}\n\n/**\n * The inverse of `personWallNow`: the INSTANT at which the person's wall clock reads the local fields\n * of `wall` (getFullYear, getHours, ...). A calendar drop at \"9:30 on Nov 3\" writes this, so the card\n * reads 9:30 on Nov 3 again in the person's zone. With no zone set it is `wall` itself (device zone).\n */\nexport function instantFromPersonWall(wall: Date): Date {\n const zone = state.zone;\n if (!zone) return wall;\n const target = Date.UTC(wall.getFullYear(), wall.getMonth(), wall.getDate(), wall.getHours(), wall.getMinutes(), wall.getSeconds(), wall.getMilliseconds());\n let guess = target;\n for (let i = 0; i < 3; i += 1) {\n const seen = personWallNow(new Date(guess));\n const shown = Date.UTC(seen.getFullYear(), seen.getMonth(), seen.getDate(), seen.getHours(), seen.getMinutes(), seen.getSeconds(), wall.getMilliseconds());\n guess -= shown - target;\n }\n return new Date(guess);\n}\n","// src/docs.ts — @ai-matrx/records-ui · SCR-20, SCR-21, SCR-22\n//\n// DOCUMENTS OVER RECORDS. A template is a body whose tokens point at Fields BY\n// ID; a render is written ONCE and frozen with the SHA-256 of its own text; a\n// signature seals that exact version and is immutable once made.\n//\n// Three things this package refuses to re-implement, because the store already\n// does them and doing them twice is how two answers appear:\n// · which tokens a body contains — `custom.doc_tokens`;\n// · which of them this Table cannot answer, and why — `custom.doc_unresolved_tokens`;\n// · whether a signature still holds — `custom.doc_signature_intact`.\n//\n// The token syntax is the store's own: `{{field:<the field's id>}}`. A name\n// would be a token that silently stops resolving the day somebody renames a\n// Field, which is the exact failure REC-17 exists to prevent.\n\nimport type { Field, Uuid } from \"@ai-matrx/records\";\n\n/** The one token form, written the way the store's own pattern reads it. */\nexport function fieldToken(fieldId: Uuid): string {\n return `{{field:${fieldId}}}`;\n}\n\n/** THE DECLARATIVE SPEC an agent writes. One template, whole, in one object. */\nexport interface DocTemplateSpec {\n name: string;\n /** The body, tokens and all. */\n body: string;\n}\n\n/**\n * A template written in terms of Field KEYS — which is how an agent thinks and\n * how a person reads — turned into the store's id-based tokens. The agent writes\n * `{{title}}`; what is stored points at the Field's id, so a rename never\n * silently empties the document.\n *\n * A key this Table does not have is LEFT EXACTLY AS IT IS, so\n * `custom.doc_unresolved_tokens` names it and the screen shows the store's own\n * reason — it is never quietly deleted from the body.\n */\nexport function bodyFromKeys(body: string, fields: Field[]): string {\n const byKey = new Map(fields.map((f) => [f.key, f.id]));\n return body.replace(/\\{\\{\\s*([a-zA-Z0-9_]+)\\s*\\}\\}/g, (whole, key: string) => {\n const id = byKey.get(key);\n return id ? fieldToken(id) : whole;\n });\n}\n\n/** The reverse, for a person reading a stored body: ids shown as the Field's label. */\nexport function bodyForReading(body: string, fields: Field[]): string {\n const byId = new Map(fields.map((f) => [f.id, f.label || f.key]));\n return body.replace(/\\{\\{\\s*field:([0-9a-fA-F-]{36})\\s*\\}\\}/g, (whole, id: string) => {\n const label = byId.get(id);\n return label ? `{{${label}}}` : whole;\n });\n}\n\n/** VAL-10: a signature is a Value on a text Field whose format is `signature`. */\nexport function isSignatureField(field: Field): boolean {\n return field.type === \"text\" && (field.format ?? \"\").toLowerCase() === \"signature\";\n}\n","// src/choiceLooks.ts — @ai-matrx/records-ui · merge tranche 6f (early)\n//\n// A CHOICE WEARS THE COLOR ITS OWNER GAVE IT.\n//\n// The older /data grid let a person paint each choice of a list (\"Completed\" green, \"Scheduled\"\n// blue), and those colors are kept on the Field itself: `display_format.options.choices`, the\n// document `custom.field_update` writes (the /data Sheet's seam writes it the same way, and a\n// column's settings here write it back). The grid used to ignore it and HASH THE WORD into a\n// color, so a column painted green on /data came up amber here, and a color a person set in the\n// settings changed nothing on screen — the silent half of a setting.\n//\n// Pure: no React, no store call. The Field the grid already holds carries everything.\n\nimport { newerKindOf } from \"@ai-matrx/records/field-kinds\";\nimport type { Field } from \"@ai-matrx/records\";\n// The values from the pure `table-style` subpath (no \"use client\", no grid): `@ai-matrx/records-ui/helpers`\n// reaches this file through `fieldTypeLabel`, and the data-table root would drag the whole grid with it.\nimport { CHOICE_CHIP_CLASS, NEUTRAL_CHIP_CLASS, STYLE_COLORS } from \"@ai-matrx/design-system/data-table/table-style\";\nimport type { ChoiceColorLookup, StyleColor } from \"@ai-matrx/design-system/data-table\";\n\n/** One choice's look, as the Field keeps it. */\nexport interface ChoiceLook {\n value: string;\n label?: string;\n color?: StyleColor;\n}\n\n/** The Field's display document, which the store keeps beside its declared keys. */\nexport function displayFormatOf(field: Field): { id: string; options: Record<string, unknown> } | null {\n const raw = (field as unknown as { display_format?: unknown }).display_format;\n if (!raw || typeof raw !== \"object\") return null;\n const id = (raw as { id?: unknown }).id;\n if (typeof id !== \"string\" || id === \"\") return null;\n const options = (raw as { options?: unknown }).options;\n return { id, options: options && typeof options === \"object\" ? (options as Record<string, unknown>) : {} };\n}\n\nfunction isStyleColor(v: unknown): v is StyleColor {\n return typeof v === \"string\" && (STYLE_COLORS as readonly string[]).includes(v);\n}\n\n/** Every choice look the Field keeps, in its own order. A color outside the palette is dropped. */\nexport function choiceLooksOf(field: Field): ChoiceLook[] {\n const display = displayFormatOf(field);\n const choices = display?.options[\"choices\"];\n if (!Array.isArray(choices)) return [];\n const out: ChoiceLook[] = [];\n for (const c of choices) {\n if (!c || typeof c !== \"object\") continue;\n const value = (c as { value?: unknown }).value;\n if (typeof value !== \"string\" || value.trim() === \"\") continue;\n const color = (c as { color?: unknown }).color;\n const label = (c as { label?: unknown }).label;\n out.push({\n value: value.trim(),\n ...(typeof label === \"string\" && label.trim() !== \"\" ? { label: label.trim() } : {}),\n ...(isStyleColor(color) ? { color } : {}),\n });\n }\n return out;\n}\n\n/**\n * ONE WORD, HOWEVER IT WAS WRITTEN. A moved list keeps its words as `completed` / `truck_4` and\n * shows them as `Completed` / `Truck 4`; a color kept against either spelling is the same choice.\n */\nexport function choiceWord(value: unknown): string {\n return String(value ?? \"\")\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n}\n\n/**\n * NOTION'S STATUS COLORS, BY GROUP: To-do gray, In progress blue, Complete green. A status choice\n * the column paints nothing for wears its group's color, so a fresh Status column reads the way\n * Notion's does with nobody picking a color. A choice with a color of its own keeps it\n * (`storedChoiceColor` asks the column first).\n */\nexport const STATUS_GROUP_COLOR = { todo: \"gray\", in_progress: \"blue\", done: \"green\" } as const satisfies Record<string, StyleColor>;\n\n/** The color a status choice's GROUP gives it, or `undefined` when the column is not a Status. */\nexport function statusGroupColor(field: Field, value: unknown): StyleColor | undefined {\n if (newerKindOf(field) !== \"status\" || value === null || value === undefined || value === \"\") return undefined;\n const word = choiceWord(value);\n if (word === \"\") return undefined;\n const groups = ((field.config ?? {}) as Record<string, unknown>)[\"status_groups\"];\n if (groups && typeof groups === \"object\") {\n // the group is kept under the choice's KEY; the cell may hold its WORDS (\"In progress\" ↔ in_progress)\n for (const [key, group] of Object.entries(groups as Record<string, unknown>)) {\n if (choiceWord(key) !== word) continue;\n return group === \"in_progress\" ? STATUS_GROUP_COLOR.in_progress : group === \"done\" ? STATUS_GROUP_COLOR.done : STATUS_GROUP_COLOR.todo;\n }\n }\n return STATUS_GROUP_COLOR.todo;\n}\n\n/** The color this Field keeps for this value, or `undefined` when it keeps none. */\nexport function storedChoiceColor(field: Field, value: unknown): StyleColor | undefined {\n if (value === null || value === undefined || value === \"\") return undefined;\n const word = choiceWord(value);\n if (word === \"\") return undefined;\n for (const look of choiceLooksOf(field)) {\n if (!look.color) continue;\n if (choiceWord(look.value) === word || (look.label && choiceWord(look.label) === word)) return look.color;\n }\n return statusGroupColor(field, value);\n}\n\n/**\n * THE COLOUR-BY LOOKUP, STORED COLORS FIRST. A value whose column keeps a color for it wears\n * that color; any other value still paints, deterministically, through `fallback` — a colour-by\n * that silently did nothing would be the screen lying about a setting a person just changed.\n */\nexport function storedChoiceColorLookup(\n fields: readonly Field[],\n fallback: ChoiceColorLookup,\n): ChoiceColorLookup {\n const byKey = new Map(fields.map((f) => [f.key, f] as const));\n return (fieldKey, value) => {\n const field = byKey.get(fieldKey);\n return (field ? storedChoiceColor(field, value) : undefined) ?? fallback(fieldKey, value);\n };\n}\n\n/**\n * THE ORDER A NEW CHOICE IS PAINTED IN (Airtable): each choice added to a list takes the next\n * palette color the list does not wear yet, so a fresh list reads as distinct chips with nobody\n * picking a color. Gray last — it reads as \"no colour\".\n */\nexport const NEW_CHOICE_PALETTE: readonly StyleColor[] = [\"blue\", \"green\", \"amber\", \"red\", \"violet\", \"teal\", \"slate\"];\n\n/** The color the next choice of a list takes, given the colors its choices already wear. */\nexport function nextChoiceColor(worn: ReadonlyArray<StyleColor | null | undefined>): StyleColor {\n const taken = new Set(worn.filter((c): c is StyleColor => Boolean(c)));\n const free = NEW_CHOICE_PALETTE.find((c) => !taken.has(c));\n return free ?? NEW_CHOICE_PALETTE[worn.length % NEW_CHOICE_PALETTE.length]!;\n}\n\n/**\n * THE ONE CHIP A CHOICE IS DRAWN AS — the grid cell, the picker's list and its chip, a form's\n * pills: the color the column keeps for the value (by any of the words given — its key, its\n * label), else the neutral chip. One answer, so no surface paints a choice its own way.\n */\nexport function choiceChipLookOf(field: Field, ...words: unknown[]): { className: string; color: StyleColor | null } {\n for (const word of words) {\n const color = storedChoiceColor(field, word);\n if (color) return { className: CHOICE_CHIP_CLASS[color], color };\n }\n return { className: NEUTRAL_CHIP_CLASS, color: null };\n}\n","// src/parity.ts — @ai-matrx/records-ui\n//\n// FLD-11, the parity floor. A Field stores a BEHAVIOR (one of five) plus\n// modifiers, unit and format; a person picked one of THIRTEEN parity types in\n// the UI. This resolves the second from the first, using the same facts the\n// store's own `custom.parity_field_types()` describes — which is generated into\n// `@ai-matrx/records` and imported here, never retyped.\n//\n// Nothing in this file decides policy. It decides which editor to draw.\n\nimport { displayFormatOf } from \"./choiceLooks\";\nimport {\n KERNEL_TABLES,\n PARITY_FIELD_TYPES,\n fieldKindFor,\n newerKindOf,\n isButtonField,\n type FieldKind,\n type KernelTargets,\n type ParityFieldType,\n} from \"@ai-matrx/records/field-kinds\";\nimport type { Field } from \"@ai-matrx/records\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\nimport { isSignatureField } from \"./docs\";\nimport { fieldTypeChoice, isSystemFieldKind, type PickableFieldType } from \"./fieldTypes\";\n\n/** The kernel ids come from the store's own kernel rows, never from a literal here. */\nconst kernelId = (name: string): string =>\n KERNEL_TABLES.find((t) => t.name === name)?.id ?? \"\";\nconst KERNEL_FILE_TABLE = kernelId(\"File\");\nconst KERNEL_PERSON_TABLE = kernelId(\"Person\");\n\nexport const PARITY_LABEL: Record<ParityFieldType, string> = {\n attachment: \"Attachment\",\n checkbox: \"Yes / no\",\n currency: \"Currency\",\n datetime: \"Date\",\n email: \"Email\",\n formula: \"Formula\",\n lookup: \"Lookup\",\n member: \"Person\",\n multi_select: \"Multi-select\",\n percent: \"Percent\",\n phone: \"Phone\",\n rollup: \"Rollup\",\n select: \"Select\",\n url: \"Link\",\n};\n\n/** The \"made of\" sentence the store itself publishes, for the field editor's help text. */\nexport const PARITY_MADE_OF: Record<string, string> = Object.fromEntries(\n PARITY_FIELD_TYPES.map((p) => [p.parity_type, p.made_of]),\n);\n\n/**\n * Plain text and plain number are behaviors with no parity type of their own.\n *\n * 🚨 THIS IS NOW AN ALIAS, AND THAT IS THE POINT (TAILS-3, 2026-09-21). The\n * classifier moved into `@ai-matrx/records` as `FieldKind` so that the editor a\n * person types into and the COERCION applied to what they typed are decided by\n * one body. They were decided by two, and the public booking page paid for it:\n * \"Vehicle Year takes a number, and it was given a string\" on every table with\n * a number field.\n */\nexport type EditorKind = FieldKind;\n\n/** The kernel ids come from the store's own kernel rows, never from a literal here. */\nconst KERNEL: KernelTargets = { file: KERNEL_FILE_TABLE, person: KERNEL_PERSON_TABLE };\n\n/**\n * Which editor one Field wants. Reads the Field's own declaration only — the\n * behavior, the modifiers, the format, the relation target and the config —\n * because those are what the store stores, and a screen that guessed from a\n * value would draw a different editor for an empty record.\n *\n * It is `fieldKindFor` with this package's kernel ids bound. Nothing here\n * decides anything the core does not.\n */\nexport function editorKindFor(field: Field): EditorKind {\n return fieldKindFor(field, KERNEL);\n}\n\n/**\n * WHICH KIND A PERSON PICKED, read back off the Field the store keeps — the ONE reader every\n * \"what does this column hold\" answer goes through (the Settings column list, the column panel).\n *\n * `editorKindFor` answers which EDITOR to draw, and for two families that is not the kind a\n * person picked: a Signature is a text Field whose format is `signature` (it draws a line of\n * text), and the store's stamps — Record number, Created time, Last changed time — are formula\n * Fields whose `config.system` names the stamp. Read through the editor classifier alone, the\n * Settings list called a Signature \"Text\" and a Record number \"Worked out from other columns\"\n * (lane 10 W1-A, guard `every-pickable-kind-reads-back-as-itself.test.tsx`).\n *\n * `undefined` when the Field is none of the kinds the menu offers.\n */\nexport function pickableTypeOf(field: Field): PickableFieldType | undefined {\n if (isSignatureField(field)) return \"signature\";\n // NOTION-PROPS-3: a button is text wearing the format `button`.\n if (isButtonField(field)) return \"button\";\n // LANE 10 P4: the nine newer kinds, each a base type wearing a format (`newerKindOf`).\n const newer = newerKindOf(field);\n if (newer) return newer;\n // A RATING OR A TIME made as a plain column wearing its look (`LOOK_KINDS`): named by that kind.\n const look = displayFormatOf(field)?.id;\n if (look === \"rating\" && field.type === \"range\") return \"rating\";\n if (look === \"time\" && field.type === \"text\") return \"time\";\n if ((look === \"color_pair\" || look === \"type_style\" || look === \"shadow\") && field.type === \"text\") return look;\n if (look === \"measure\" && field.type === \"range\") return \"measure\";\n const system = (field.config as Record<string, unknown> | undefined)?.[\"system\"];\n if (field.type === \"formula\" && typeof system === \"string\" && isSystemFieldKind(system)) return system;\n const kind = editorKindFor(field);\n return fieldTypeChoice(kind) ? (kind as PickableFieldType) : undefined;\n}\n\n/**\n * The type word a person sees in a header or a settings row — and it is the\n * SAME word the field panel offers, read from `FIELD_TYPE_CHOICES`, so a column\n * added as \"Money\" is never described anywhere else as \"Currency\".\n */\nexport function fieldTypeLabel(field: Field): string {\n const kind = pickableTypeOf(field) ?? editorKindFor(field);\n const known = fieldTypeChoice(kind)?.label;\n if (known) return field.multi && kind !== \"multi_select\" ? `${known} (many)` : known;\n const plain: Record<string, string> = {\n // `boolean` is the BEHAVIOR word; `checkbox` is the type a person picks. Both are\n // written the way a person writes them, never as a raw token.\n boolean: \"Yes / no\",\n date: \"Date\",\n json: \"Structured data\",\n relation: \"Link to a record\",\n };\n // Never a raw token on a screen: an editor kind this table has not named is\n // still written the way a person writes it.\n return plain[kind] ?? humanizeIdentifier(kind);\n}\n","/**\n * 🚨 THE ONE DATE HELPER EVERY LAYOUT READS (lane UI-FIX-18, VERIFIER-18 H2 / M1).\n *\n * MEASURED 2026-09-24 on production, browser in America/Los_Angeles: Kitchen's start date,\n * stored `2026-04-01`, read **Apr 1** in the grid, **Mar 31** on the calendar, **3/31** in\n * the gallery, and Backyard Deck's May 1 read **4/30** in the record panel. The grid was right\n * because it formats through the design system's registry (`formatFieldValue`), which reads a\n * bare `YYYY-MM-DD` as a day on a calendar. Every other surface called `new Date(\"2026-04-01\")`\n * itself — which JavaScript parses as UTC MIDNIGHT — and then printed it in the viewer's zone,\n * so everybody west of Greenwich saw the day before.\n *\n * THE CLASS, NOT THE INSTANCE. No component in this package parses or prints a date on its\n * own any more; it asks this file, and this file asks the SAME registry the grid asks. The\n * calendar's day key is the one thing the registry does not answer, and it is answered here\n * by the same rule: a bare calendar date IS its own day (read the characters), an instant\n * (`…Z`, `…+hh:mm`) is placed on the viewer's own calendar.\n *\n * The store's own stamps — Created time and Last changed time (`fx.created_time`,\n * `fx.modified_time`) — are instants, and are printed like every other date-and-time cell\n * (VERIFIER-18 M1 found `2026-09-25T00:13:34.564Z` in the grid, the gallery and the panel).\n */\nimport { formatFieldValue, type FieldFormatConfig } from \"@ai-matrx/design-system/field-formats\";\nimport type { Field } from \"@ai-matrx/records\";\nimport { momentZoneOptions } from \"@ai-matrx/design-system/field-formats\";\nimport { personWallNow } from \"./personZone\";\n\n/** A day on a calendar with no time and no zone — `2026-04-01`, or a zoneless local midnight. */\nconst BARE_CALENDAR_DATE = /^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ]00:00(?::00(?:\\.0+)?)?)?$/;\n\ntype SystemStamp = \"autonumber\" | \"created_time\" | \"modified_time\";\n\n/** The store's own stamp this Field is, when it is one (`config.system`). */\nexport function systemStampOf(field: Pick<Field, \"type\" | \"config\">): SystemStamp | null {\n if (field.type !== \"formula\") return null;\n const system = String((field.config ?? {})[\"system\"] ?? \"\");\n return system === \"autonumber\" || system === \"created_time\" || system === \"modified_time\" ? system : null;\n}\n\n/**\n * Does this value (or, with no value, this Field) carry a TIME OF DAY as well as a date?\n *\n * A DATE IS A DATE (chair ruling, 2026-09-24). The control and the text follow the STORED\n * VALUE's shape, never `config.kind` alone: a value with no time part — `1988-06-14`, a date\n * of birth on a `kind: \"datetime\"` Field — gets a date-only control and a date-only reading\n * everywhere (grid, form, panel, calendar). With no value yet, only a Field that says so\n * outright carries a time: the older `format: \"datetime\"`, or the store's own Created / Last\n * changed stamps (instants by construction).\n */\nexport function carriesTimeOfDay(field: Pick<Field, \"type\" | \"config\" | \"format\">, value?: unknown): boolean {\n if (value !== undefined && value !== null && value !== \"\") return hasTimePart(value);\n const stamp = systemStampOf(field);\n if (stamp === \"created_time\" || stamp === \"modified_time\") return true;\n return (field.format ?? \"\").toLowerCase() === \"datetime\";\n}\n\n/**\n * THE TIME OF DAY A MOMENT CARRIES, in the reader's clock (\"3:30 PM\") — the same words the grid's\n * date-and-time cell ends in — or null for a bare day. A calendar's month card and a timeline's bar\n * show it before the title (lane 10 P4, verifier V8 #7), as Google Calendar does.\n */\nexport function timeOfDayWords(value: unknown): string | null {\n if (!hasTimePart(value)) return null;\n const at = value instanceof Date ? value : new Date(value as string | number);\n return Number.isNaN(at.getTime()) ? null : at.toLocaleTimeString(undefined, { hour: \"numeric\", minute: \"2-digit\", ...momentZoneOptions(at) });\n}\n\n/** A value that names a moment in the day, not just the day. */\nexport function hasTimePart(value: unknown): boolean {\n if (value instanceof Date || typeof value === \"number\") return true;\n if (typeof value !== \"string\") return false;\n const trimmed = value.trim();\n if (BARE_CALENDAR_DATE.test(trimmed)) return false;\n return /^\\d{4}-\\d{2}-\\d{2}[T ]\\d/.test(trimmed);\n}\n\n/** Is this Field a date column at all — a dated range, or the store's own time stamp? */\nexport function isDateField(field: Pick<Field, \"type\" | \"config\">): boolean {\n const stamp = systemStampOf(field);\n if (stamp === \"created_time\" || stamp === \"modified_time\") return true;\n if (field.type !== \"range\") return false;\n const kind = String((field.config ?? {})[\"kind\"] ?? \"\");\n return kind === \"date\" || kind === \"datetime\";\n}\n\n/**\n * The format a date-ish Field draws with, or `undefined` for a Field that is not one. With a\n * value, it is that value's own shape; without, the Field's (`carriesTimeOfDay`).\n * `presentation.formatForField` answers dates through this, so the grid and every card agree.\n */\nexport function dateFormatFor(\n field: Pick<Field, \"type\" | \"config\" | \"format\">,\n value?: unknown,\n): FieldFormatConfig | undefined {\n if (!isDateField(field)) return undefined;\n return carriesTimeOfDay(field, value) ? { id: \"datetime\" } : { id: \"date\" };\n}\n\n/**\n * THE TEXT OF ONE DATE VALUE, in the viewer's language — through the design system's\n * registry, exactly as the grid prints it, in the value's own shape. `null` when the value is\n * not a date at all, so the caller can fall back to its own reading (THE FALLBACK LAW).\n */\nexport function dateText(field: Pick<Field, \"type\" | \"config\" | \"format\">, value: unknown): string | null {\n const format = dateFormatFor(field, value) ?? (isDateLike(value) ? { id: hasTimePart(value) ? \"datetime\" : \"date\" } : undefined);\n if (!format) return null;\n const result = formatFieldValue(value, format);\n return result.ok && !result.empty ? result.text : null;\n}\n\nfunction isDateLike(value: unknown): boolean {\n return typeof value === \"string\" && /^\\d{4}-\\d{2}-\\d{2}/.test(value.trim());\n}\n\nfunction pad(n: number): string {\n return n < 10 ? `0${n}` : String(n);\n}\n\n/**\n * THE CALENDAR DAY a value falls on, as `YYYY-MM-DD` — the key a calendar files a card under.\n *\n * A bare calendar date is its own day. An instant is placed on the VIEWER's calendar: a visit\n * logged at 5:13 PM Pacific on 24 September is on the 24th for the person in Pacific time,\n * even though it is already the 25th in UTC.\n */\nexport function calendarDayOf(value: unknown): string | null {\n if (typeof value === \"string\") {\n const trimmed = value.trim();\n const bare = BARE_CALENDAR_DATE.exec(trimmed);\n if (bare) return `${bare[1]}-${bare[2]}-${bare[3]}`;\n if (trimmed === \"\") return null;\n } else if (typeof value !== \"number\" && !(value instanceof Date)) {\n return null;\n }\n const instant = value instanceof Date ? value : new Date(value as string | number);\n if (Number.isNaN(instant.getTime())) return null;\n // The day is the one on the PERSON's wall clock (their saved zone), not the device's.\n const at = personWallNow(instant);\n return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;\n}\n\n/** The heading of one calendar day — `Apr 1, 2026` — built on local midnight, never UTC. */\nexport function calendarDayLabel(day: string): string {\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(day);\n if (!m) return day;\n const at = new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3]));\n return at.toLocaleDateString(undefined, { month: \"short\", day: \"numeric\", year: \"numeric\" });\n}\n\n// ---------------------------------------------------------------------------------------------\n// DAY ARITHMETIC ON THE VIEWER'S OWN CALENDAR (lane VIEWS-AND-FIELDS, sublane TL, 2026-10-02).\n// A day key is `YYYY-MM-DD`, built and read at LOCAL midnight — never `new Date(\"YYYY-MM-DD\")`,\n// which is UTC midnight and lands on the day before for everybody west of Greenwich. The timeline\n// places and moves bars with these; a move is always a whole number of days.\n\n/** The day key of a moment, on the viewer's calendar. */\nexport function dayKeyOf(at: Date): string {\n return `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())}`;\n}\n\n/** A day key as local midnight. */\nexport function dayAt(day: string): Date {\n const [y, m, d] = day.split(\"-\").map(Number);\n return new Date(y!, (m ?? 1) - 1, d ?? 1);\n}\n\n/** The day `n` days after (or before, when negative) `day`. */\nexport function addDays(day: string, n: number): string {\n const at = dayAt(day);\n at.setDate(at.getDate() + n);\n return dayKeyOf(at);\n}\n\n/** Whole days from `from` to `to` (negative when `to` is earlier). DST-safe: rounds the hour away. */\nexport function daysBetween(from: string, to: string): number {\n return Math.round((dayAt(to).getTime() - dayAt(from).getTime()) / 86_400_000);\n}\n"],"mappings":";;;;;;;AAOA,SAAS,sBAAsB,0BAA0B;AACzD,SAAS,kBAAkB;AAK3B,IAAM,QAAQ,WAAW,wCAAwC,OAAO;AAAA,EACtE,MAAM;AAAA,EACN,WAAW,oBAAI,IAAgB;AACjC,EAAE;AAEF,SAAS,MAAM,GAAyB;AACtC,MAAI,OAAO,MAAM,YAAY,CAAC,EAAE,KAAK,EAAG,QAAO;AAC/C,MAAI;AACF,QAAI,KAAK,eAAe,SAAS,EAAE,UAAU,EAAE,CAAC;AAChD,WAAO;AAAA,EACT,QAAQ;AACN,W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GO,SAAS,MAAM,KAAmB;AACvC,QAAM,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI,MAAM;AAC3C,SAAO,IAAI,KAAK,IAAK,KAAK,KAAK,GAAG,KAAK,CAAC;AAC1C;AAGO,SAAS,QAAQ,KAAa,GAAmB;AACtD,QAAM,KAAK,MAAM,GAAG;AACpB,KAAG,QAAQ,GAAG,QAAQ,IAAI,CAAC;AAC3B,SAAO,SAAS,EAAE;AACpB;AAGO,SAAS,YAAY,MAAc,IAAoB;AAC5D,SAAO,KAAK,OAAO,MAAM,EAAE,EAAE,QAAQ,IAAI,MAAM,IAAI,EAAE,QAAQ,KAAK,KAAU;AAC9E;","names":["newerKindOf","newerKindOf"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
dateFormatFor,
|
|
4
4
|
editorKindFor
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TEYXG4XD.js";
|
|
6
6
|
|
|
7
7
|
// src/presentation.ts
|
|
8
8
|
import { COLOR_ROTATION, parseTableStyle, tableStyleIsEmpty } from "@ai-matrx/design-system/data-table/table-style";
|
|
@@ -446,4 +446,4 @@ export {
|
|
|
446
446
|
EMBEDDED_TABLE_CLASS,
|
|
447
447
|
EMBEDDED_PLAIN_FOOTER_CLASS
|
|
448
448
|
};
|
|
449
|
-
//# sourceMappingURL=chunk-
|
|
449
|
+
//# sourceMappingURL=chunk-W6FX3XVF.js.map
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
useChoiceNudge,
|
|
25
25
|
useRecordsUi,
|
|
26
26
|
useTableRights
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-4KWCNW7V.js";
|
|
28
28
|
import {
|
|
29
29
|
guessColumn,
|
|
30
30
|
readTableShapes,
|
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
fieldTypeLabel,
|
|
39
39
|
hasTimePart,
|
|
40
40
|
isDateField
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-TEYXG4XD.js";
|
|
42
42
|
import {
|
|
43
43
|
fieldTypeChoice
|
|
44
44
|
} from "./chunk-WCQSJPLS.js";
|
|
@@ -5093,4 +5093,4 @@ export {
|
|
|
5093
5093
|
shapesOfSource,
|
|
5094
5094
|
SaveToTable
|
|
5095
5095
|
};
|
|
5096
|
-
//# sourceMappingURL=chunk-
|
|
5096
|
+
//# sourceMappingURL=chunk-WXYI4DKC.js.map
|
package/dist/data-source.cjs
CHANGED
|
@@ -53,6 +53,7 @@ async function hasSession(getSession) {
|
|
|
53
53
|
return true;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
var displayZone = globalSlot.globalSlot("ai-matrx.design-system.display-time-zone", () => ({ zone: null }));
|
|
56
57
|
var SOMEBODY = "somebody in this organization";
|
|
57
58
|
var THE_SYSTEM = "Matrx";
|
|
58
59
|
function actorWords(actor, resolve) {
|
|
@@ -71,7 +72,7 @@ function whenWords(at, now = /* @__PURE__ */ new Date()) {
|
|
|
71
72
|
const age = now.getTime() - then.getTime();
|
|
72
73
|
if (!Number.isFinite(age)) return "at an unknown time";
|
|
73
74
|
if (age < 30 * 864e5) return format.formatRelativeTime(then, { style: "intl", now: now.getTime() });
|
|
74
|
-
return then.toLocaleDateString();
|
|
75
|
+
return then.toLocaleDateString(void 0, displayZone.zone ? { timeZone: displayZone.zone } : void 0);
|
|
75
76
|
}
|
|
76
77
|
var OPERATION_WORDS = {
|
|
77
78
|
created: "Created",
|
package/dist/data-source.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dataSource.ts","../src/whoChanged.ts"],"names":["globalSlot","formatRelativeTime","humanizeIdentifier"],"mappings":";;;;;;;AAUO,SAAS,YAAY,MAAA,EAA+C;AACzE,EAAA,OAAO,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,EAAQ,SAAS,MAAA,EAAO,GAAI,EAAE,KAAA,EAAO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AAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,KAAA;AACvC","file":"data-source.cjs","sourcesContent":["// src/dataSource.ts — @ai-matrx/records-ui (pure; also served alone by `@ai-matrx/records-ui/helpers`)\n//\n// The two helpers every host calls before it draws anything: who is acting (`personActor`) and the\n// store's data seam over a supabase-js client (`recordsDataSource`). No React and no screen here, so\n// a service, a registry or a server module that needs only these never pulls the package's screens.\n// `RecordsMount` re-exports both, so the root entry keeps them.\n\nimport type { RecordsActor, RecordsDataSource, Uuid } from \"@ai-matrx/records\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport function personActor(userId: Uuid | null | undefined): RecordsActor {\n return userId ? { actor: \"user\", user_id: userId } : { actor: \"user\" };\n}\n\n/**\n * A supabase-js client AS this package's data seam.\n *\n * `RecordsDataSource` is deliberately a small structural subset of\n * `SupabaseClient` — the package holds no key and opens no connection, the host\n * hands it a client that already carries the person's session.\n *\n * IT IS NOT AN IDENTITY CAST, and it cost a live screen to learn why\n * (2026-09-19, /data's first load): the port's `rpc(fn, args, { schema })`\n * says the schema OUT LOUD, because every door of this store is `custom.<name>`\n * and every door of the trust layer is `iam.<name>`. supabase-js's own\n * `rpc(fn, args, options)` has no `schema` option at all — its third argument is\n * `{ head, get, count }` — so a client passed straight through silently asked\n * its default PostgREST profile and the store answered, correctly and uselessly,\n * \"Could not find the function public.table_kernel_id ... PGRST202\". The schema\n * is chosen the one way supabase-js offers: `client.schema(name).rpc(...)`.\n *\n * `schema(name).from(table)` already agrees structurally and is passed through.\n *\n * `fallbackSchema` is the profile a call that says NOTHING is sent to. No caller\n * in `@ai-matrx/records` omits the option — `callDoor` always says `custom` and\n * `trustDoor` always says `iam` — so it never fires today; it exists so that a\n * call which one day forgets lands on the store rather than silently on\n * `public`. It is a FALLBACK and not the answer: a version of this adapter that\n * sent EVERY door to one fixed schema would route the `iam` trust doors (the\n * external principal, the publish binding) into `custom` and get a PGRST202\n * naming the wrong schema.\n *\n * The cast itself stays HERE, once, where it is explained: a generated\n * `Database` type makes `schema().from().select()` enormous, and a host app that\n * passes its client straight into `config` gets `TS2589: Type instantiation is\n * excessively deep and possibly infinite` in its own build (matrx-frontend,\n * 2026-09-18, on all three campaign routes at once).\n */\n/*\n * ONE DATA SOURCE PER SUPABASE CLIENT (owner, 2026-10-02). The record store's data layer keys its\n * cache by the data source object, so a host that builds this adapter again on every mount (a\n * board tile woken or brought back by Undo) must get the SAME object back for the same client —\n * otherwise every remount is a stranger to the answers the last mount read.\n */\n// One cache per realm, never per bundle copy: this module ships in BOTH the root entry and\n// `@ai-matrx/records-ui/helpers` (`splitting: false`), and a module `let` would split it in two.\nconst dataSources = globalSlot(\"ai-matrx.records-ui.data-sources\", () => new WeakMap<object, Map<string, RecordsDataSource>>());\n\nexport function recordsDataSource(client: object, fallbackSchema = \"custom\"): RecordsDataSource {\n let bySchema = dataSources.get(client);\n if (!bySchema) {\n bySchema = new Map();\n dataSources.set(client, bySchema);\n }\n const held = bySchema.get(fallbackSchema);\n if (held) return held;\n const made = makeRecordsDataSource(client, fallbackSchema);\n bySchema.set(fallbackSchema, made);\n return made;\n}\n\nfunction makeRecordsDataSource(client: object, fallbackSchema: string): RecordsDataSource {\n const supabase = client as unknown as {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n schema: (name: string) => {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n from: (table: string) => unknown;\n };\n auth?: { getSession?: () => Promise<{ data?: { session?: unknown } | null }> };\n };\n return {\n // PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.\n opensInOneCall: true,\n async rpc(fn, args, options) {\n const schema = options?.schema ?? fallbackSchema;\n // 🚨 NO STORE DOOR LEAVES WITHOUT A PERSON (lane MONITOR-TRIAGE, 2026-10-01). `anon` holds\n // no USAGE on schema `custom`, so a door called with no session can only come back\n // \"42501 permission denied for schema custom\" (HTTP 401) — seven of them per signed-out\n // /data load (inbox, counts, home, portals…), every one a red row in ops.system_error.\n // A `custom` door with no session is answered HERE, with the store's own signed-out\n // sentence and no network call. Other schemas (`iam`, `platform`) serve guests by design\n // and are never short-circuited. A client without `auth` (a server or test seam) is\n // passed straight through.\n if (schema === \"custom\" && supabase.auth?.getSession && !(await hasSession(supabase.auth.getSession))) {\n return { data: null, error: SIGNED_OUT } as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n }\n const on = supabase.schema(schema);\n return (await on.rpc(fn, args)) as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n },\n schema(name) {\n return supabase.schema(name) as ReturnType<RecordsDataSource[\"schema\"]>;\n },\n };\n}\n\n/** The read door's own sentence for a call with nobody signed in (`custom.read_records_page`, DOOR-1). */\nconst SIGNED_OUT = {\n code: \"42501\",\n message: \"Nobody is signed in, so there is nothing to read.\",\n hint: \"Sign in, then try again.\",\n details: null,\n} as const;\n\nasync function hasSession(getSession: () => Promise<{ data?: { session?: unknown } | null }>): Promise<boolean> {\n try {\n const answer = await getSession();\n return Boolean(answer?.data?.session);\n } catch {\n // Auth could not say: let the request go and the database's answer stand.\n return true;\n }\n}\n","import { formatRelativeTime } from \"@ai-matrx/kit/format\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n// src/whoChanged.ts — @ai-matrx/records-ui · SCR-17, the cell's half\n//\n// \"WHO?\" IS A QUESTION. A SCREEN IS SUPPOSED TO ANSWER IT.\n//\n// 🚨 WHAT A CLINIC SAW (crew B2, 2026-09-21, ten real patients on the live app):\n//\n// \"Every single cell shows a small 'who?' hover badge next to its value instead\n// of a resolved author name, an agent/rule label, or even 'system' — the\n// attribution feature is visibly wired up (it renders on every cell) but never\n// resolves to anything readable.\"\n//\n// They were right that it never resolved, and the reason was that nothing ever\n// asked. The badge opened a panel; it never looked anything up. Meanwhile the\n// store had the answer the whole time: `custom.field_history` on those exact ten\n// patients answers `kind: user, name: admin` on every one of them, and has since\n// they were written.\n//\n// So the badge asks, on the gesture that already reaches it — a hover or a Tab —\n// for the ONE cell being asked about. Nothing is fetched for a page of two\n// hundred cells nobody points at.\n//\n// THE THREE WORDS, AND NEVER A UUID. VAL-8 fixes the vocabulary at `user`,\n// `agent`, `system` and there is no fourth. An agent ALWAYS names the person it\n// acted for (AGT-N-4: it carries exactly that person's authority, so a screen\n// showing the machine without the person would be hiding who is answerable). The\n// system is \"the system\" — a platform word a person can read, not a null. And a\n// person whose name the door did not carry is resolved through the app's ONE\n// organization-scoped roster (the `members` port, FIX-7B's rule: the people of\n// THIS organization and nobody else). If even that cannot name them, the sentence\n// says so in words. It never prints an id: SCR-N-5 forbids showing one to a\n// person, and \"87a6e699…\" answers nobody's question anyway.\n\nimport type { FieldHistoryEntry, HistoryActor, Uuid } from \"@ai-matrx/records\";\n\n/** What the roster can tell us about a user id. `null` when it cannot. */\nexport type ResolveName = (userId: Uuid) => string | null;\n\n/** The honest stand-in when nobody and nothing can put a name to the author. */\nexport const SOMEBODY = \"somebody in this organization\";\n\n/** The platform's own word for itself. Never \"null\", never \"system_user\". */\nexport const THE_SYSTEM = \"Matrx\";\n\n/**\n * WHO, in the words a person reads. One place, so the grid cell, the record\n * timeline and the column history cannot drift into three different answers.\n */\nexport function actorWords(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const named = actor.name?.trim() || (actor.user_id && resolve ? resolve(actor.user_id)?.trim() : null) || null;\n if (actor.kind === \"agent\") {\n // An agent without the person it acted for cannot happen at the door — the\n // store refuses that write — but a screen still says something true if it does.\n const on = actor.on_behalf_of;\n const person = on?.name?.trim() || (on?.user_id && resolve ? resolve(on.user_id)?.trim() : null) || SOMEBODY;\n const approver = actor.approved_by\n ? actor.approved_by.name?.trim() || (resolve ? resolve(actor.approved_by.user_id)?.trim() : null) || SOMEBODY\n : null;\n return `${named ?? \"an assistant\"}, for ${person}${approver ? `, approved by ${approver}` : \"\"}`;\n }\n return named ?? SOMEBODY;\n}\n\n/** How long ago, in the words a person uses out loud. */\nexport function whenWords(at: string, now: Date = new Date()): string {\n const then = new Date(at);\n const age = now.getTime() - then.getTime();\n if (!Number.isFinite(age)) return \"at an unknown time\";\n if (age < 30 * 86_400_000) return formatRelativeTime(then, { style: \"intl\", now: now.getTime() });\n return then.toLocaleDateString();\n}\n\n/**\n * THE WHOLE ANSWER, as one sentence, ending in what to do to see the rest.\n * `null` is a real state and gets its own sentence: this column has never been\n * changed on this record since the store started keeping versions, which is not\n * the same as \"we could not find out\".\n */\n/**\n * WHAT HAPPENED, IN A PERSON'S WORDS (BREAKER-2 B2-29). The store words four operations and\n * lowercases any other (`RETYPE` → \"retype\"), so the panel read \"retype · admin · part of a bigger\n * change\". Every word the store can send is worded here; an unknown one is still written the way\n * a person writes it, never as a token. A soft delete is an archive, and says so.\n */\nconst OPERATION_WORDS: Record<string, string> = {\n created: \"Created\",\n edited: \"Edited\",\n deleted: \"Archived\",\n archived: \"Archived\",\n restored: \"Restored\",\n retype: \"Column type changed\",\n delete: \"Removed\",\n soft_delete: \"Archived\",\n insert: \"Created\",\n update: \"Edited\",\n restore: \"Restored\",\n};\n\nexport function operationWords(label: string | null | undefined): string {\n const raw = (label ?? \"\").trim();\n if (raw === \"\") return \"Changed\";\n const known = OPERATION_WORDS[raw.toLowerCase()];\n if (known) return known;\n const words = humanizeIdentifier(raw).toLowerCase();\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\nexport function lastChangeSentence(\n fieldLabel: string,\n entry: FieldHistoryEntry | null,\n resolve?: ResolveName | undefined,\n): string {\n if (!entry) {\n return `Nothing is recorded against ${fieldLabel} on this record yet. Press H for the whole history of this column.`;\n }\n const verb = operationWords(entry.operation_label).toLowerCase();\n return `${fieldLabel} — ${verb} by ${actorWords(entry.actor, resolve)}, ${whenWords(entry.occurred_at)}. Press H for the whole history.`;\n}\n\n/**\n * The SHORT form the badge wears once it knows: a name a person recognizes at a\n * glance, in the width of a cell corner. Never a uuid, never an email's domain.\n */\nexport function actorBadge(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const words = actorWords(actor, resolve);\n if (words === SOMEBODY) return \"somebody\";\n const first = words.split(\",\")[0]!.trim();\n const at = first.indexOf(\"@\");\n return at > 0 ? first.slice(0, at) : first;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dataSource.ts","../src/whoChanged.ts"],"names":["globalSlot","formatRelativeTime","humanizeIdentifier"],"mappings":";;;;;;;AAUO,SAAS,YAAY,MAAA,EAA+C;AACzE,EAAA,OAAO,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,EAAQ,SAAS,MAAA,EAAO,GAAI,EAAE,KAAA,EAAO,MAAA,EAAO;AACvE;AA4CA,IAAM,cAAcA,qBAAA,CAAW,kCAAA,EAAoC,sBAAM,IAAI,SAAiD,CAAA;AAEvH,SAAS,iBAAA,CAAkB,MAAA,EAAgB,cAAA,GAAiB,QAAA,EAA6B;AAC9F,EAAA,IAAI,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,MAAM,CAAA;AACrC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,QAAA,uBAAe,GAAA,EAAI;AACnB,IAAA,WAAA,CAAY,GAAA,CAAI,QAAQ,QAAQ,CAAA;AAAA,EAClC;AACA,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,GAAA,CAAI,cAAc,CAAA;AACxC,EAAA,IAAI,MAAM,OAAO,IAAA;AACjB,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,MAAA,EAAQ,cAAc,CAAA;AACzD,EAAA,QAAA,CAAS,GAAA,CAAI,gBAAgB,IAAI,CAAA;AACjC,EAAA,OAAO,IAAA;AACT;AAEA,SAAS,qBAAA,CAAsB,QAAgB,cAAA,EAA2C;AACxF,EAAA,MAAM,QAAA,GAAW,MAAA;AAQjB,EAAA,OAAO;AAAA;AAAA,IAEL,cAAA,EAAgB,IAAA;AAAA,IAChB,MAAM,GAAA,CAAI,EAAA,EAAI,IAA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AA,OAAO,CAAA,EAAG,UAAU,CAAA,QAAA,EAAM,IAAI,OAAO,UAAA,CAAW,KAAA,CAAM,KAAA,EAAO,OAAO,CAAC,CAAA,EAAA,EAAK,SAAA,CAAU,KAAA,CAAM,WAAW,CAAC,CAAA,gCAAA,CAAA;AACxG;AAMO,SAAS,UAAA,CAAW,OAAqB,OAAA,EAA2C;AACzF,EAAA,IAAI,KAAA,CAAM,IAAA,KAAS,QAAA,EAAU,OAAO,UAAA;AACpC,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AACvC,EAAA,IAAI,KAAA,KAAU,UAAU,OAAO,UAAA;AAC/B,EAAA,MAAM,QAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,EAAG,IAAA,EAAK;AACxC,EAAA,MAAM,EAAA,GAAK,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AAC5B,EAAA,OAAO,KAAK,CAAA,GAAI,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,KAAA;AACvC","file":"data-source.cjs","sourcesContent":["// src/dataSource.ts — @ai-matrx/records-ui (pure; also served alone by `@ai-matrx/records-ui/helpers`)\n//\n// The two helpers every host calls before it draws anything: who is acting (`personActor`) and the\n// store's data seam over a supabase-js client (`recordsDataSource`). No React and no screen here, so\n// a service, a registry or a server module that needs only these never pulls the package's screens.\n// `RecordsMount` re-exports both, so the root entry keeps them.\n\nimport type { RecordsActor, RecordsDataSource, Uuid } from \"@ai-matrx/records\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport function personActor(userId: Uuid | null | undefined): RecordsActor {\n return userId ? { actor: \"user\", user_id: userId } : { actor: \"user\" };\n}\n\n/**\n * A supabase-js client AS this package's data seam.\n *\n * `RecordsDataSource` is deliberately a small structural subset of\n * `SupabaseClient` — the package holds no key and opens no connection, the host\n * hands it a client that already carries the person's session.\n *\n * IT IS NOT AN IDENTITY CAST, and it cost a live screen to learn why\n * (2026-09-19, /data's first load): the port's `rpc(fn, args, { schema })`\n * says the schema OUT LOUD, because every door of this store is `custom.<name>`\n * and every door of the trust layer is `iam.<name>`. supabase-js's own\n * `rpc(fn, args, options)` has no `schema` option at all — its third argument is\n * `{ head, get, count }` — so a client passed straight through silently asked\n * its default PostgREST profile and the store answered, correctly and uselessly,\n * \"Could not find the function public.table_kernel_id ... PGRST202\". The schema\n * is chosen the one way supabase-js offers: `client.schema(name).rpc(...)`.\n *\n * `schema(name).from(table)` already agrees structurally and is passed through.\n *\n * `fallbackSchema` is the profile a call that says NOTHING is sent to. No caller\n * in `@ai-matrx/records` omits the option — `callDoor` always says `custom` and\n * `trustDoor` always says `iam` — so it never fires today; it exists so that a\n * call which one day forgets lands on the store rather than silently on\n * `public`. It is a FALLBACK and not the answer: a version of this adapter that\n * sent EVERY door to one fixed schema would route the `iam` trust doors (the\n * external principal, the publish binding) into `custom` and get a PGRST202\n * naming the wrong schema.\n *\n * The cast itself stays HERE, once, where it is explained: a generated\n * `Database` type makes `schema().from().select()` enormous, and a host app that\n * passes its client straight into `config` gets `TS2589: Type instantiation is\n * excessively deep and possibly infinite` in its own build (matrx-frontend,\n * 2026-09-18, on all three campaign routes at once).\n */\n/*\n * ONE DATA SOURCE PER SUPABASE CLIENT (owner, 2026-10-02). The record store's data layer keys its\n * cache by the data source object, so a host that builds this adapter again on every mount (a\n * board tile woken or brought back by Undo) must get the SAME object back for the same client —\n * otherwise every remount is a stranger to the answers the last mount read.\n */\n// One cache per realm, never per bundle copy: this module ships in BOTH the root entry and\n// `@ai-matrx/records-ui/helpers` (`splitting: false`), and a module `let` would split it in two.\nconst dataSources = globalSlot(\"ai-matrx.records-ui.data-sources\", () => new WeakMap<object, Map<string, RecordsDataSource>>());\n\nexport function recordsDataSource(client: object, fallbackSchema = \"custom\"): RecordsDataSource {\n let bySchema = dataSources.get(client);\n if (!bySchema) {\n bySchema = new Map();\n dataSources.set(client, bySchema);\n }\n const held = bySchema.get(fallbackSchema);\n if (held) return held;\n const made = makeRecordsDataSource(client, fallbackSchema);\n bySchema.set(fallbackSchema, made);\n return made;\n}\n\nfunction makeRecordsDataSource(client: object, fallbackSchema: string): RecordsDataSource {\n const supabase = client as unknown as {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n schema: (name: string) => {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n from: (table: string) => unknown;\n };\n auth?: { getSession?: () => Promise<{ data?: { session?: unknown } | null }> };\n };\n return {\n // PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.\n opensInOneCall: true,\n async rpc(fn, args, options) {\n const schema = options?.schema ?? fallbackSchema;\n // 🚨 NO STORE DOOR LEAVES WITHOUT A PERSON (lane MONITOR-TRIAGE, 2026-10-01). `anon` holds\n // no USAGE on schema `custom`, so a door called with no session can only come back\n // \"42501 permission denied for schema custom\" (HTTP 401) — seven of them per signed-out\n // /data load (inbox, counts, home, portals…), every one a red row in ops.system_error.\n // A `custom` door with no session is answered HERE, with the store's own signed-out\n // sentence and no network call. Other schemas (`iam`, `platform`) serve guests by design\n // and are never short-circuited. A client without `auth` (a server or test seam) is\n // passed straight through.\n if (schema === \"custom\" && supabase.auth?.getSession && !(await hasSession(supabase.auth.getSession))) {\n return { data: null, error: SIGNED_OUT } as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n }\n const on = supabase.schema(schema);\n return (await on.rpc(fn, args)) as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n },\n schema(name) {\n return supabase.schema(name) as ReturnType<RecordsDataSource[\"schema\"]>;\n },\n };\n}\n\n/** The read door's own sentence for a call with nobody signed in (`custom.read_records_page`, DOOR-1). */\nconst SIGNED_OUT = {\n code: \"42501\",\n message: \"Nobody is signed in, so there is nothing to read.\",\n hint: \"Sign in, then try again.\",\n details: null,\n} as const;\n\nasync function hasSession(getSession: () => Promise<{ data?: { session?: unknown } | null }>): Promise<boolean> {\n try {\n const answer = await getSession();\n return Boolean(answer?.data?.session);\n } catch {\n // Auth could not say: let the request go and the database's answer stand.\n return true;\n }\n}\n","import { formatRelativeTime } from \"@ai-matrx/kit/format\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n// src/whoChanged.ts — @ai-matrx/records-ui · SCR-17, the cell's half\n//\n// \"WHO?\" IS A QUESTION. A SCREEN IS SUPPOSED TO ANSWER IT.\n//\n// 🚨 WHAT A CLINIC SAW (crew B2, 2026-09-21, ten real patients on the live app):\n//\n// \"Every single cell shows a small 'who?' hover badge next to its value instead\n// of a resolved author name, an agent/rule label, or even 'system' — the\n// attribution feature is visibly wired up (it renders on every cell) but never\n// resolves to anything readable.\"\n//\n// They were right that it never resolved, and the reason was that nothing ever\n// asked. The badge opened a panel; it never looked anything up. Meanwhile the\n// store had the answer the whole time: `custom.field_history` on those exact ten\n// patients answers `kind: user, name: admin` on every one of them, and has since\n// they were written.\n//\n// So the badge asks, on the gesture that already reaches it — a hover or a Tab —\n// for the ONE cell being asked about. Nothing is fetched for a page of two\n// hundred cells nobody points at.\n//\n// THE THREE WORDS, AND NEVER A UUID. VAL-8 fixes the vocabulary at `user`,\n// `agent`, `system` and there is no fourth. An agent ALWAYS names the person it\n// acted for (AGT-N-4: it carries exactly that person's authority, so a screen\n// showing the machine without the person would be hiding who is answerable). The\n// system is \"the system\" — a platform word a person can read, not a null. And a\n// person whose name the door did not carry is resolved through the app's ONE\n// organization-scoped roster (the `members` port, FIX-7B's rule: the people of\n// THIS organization and nobody else). If even that cannot name them, the sentence\n// says so in words. It never prints an id: SCR-N-5 forbids showing one to a\n// person, and \"87a6e699…\" answers nobody's question anyway.\n\nimport type { FieldHistoryEntry, HistoryActor, Uuid } from \"@ai-matrx/records\";\n\n// Read the same realm-wide slot set by design-system's setDisplayTimeZone. This\n// helper is also exported by the light /data-source entry, so it cannot import\n// design-system's field-format bundle merely to read the saved zone.\nconst displayZone = globalSlot<{ zone: string | null }>(\"ai-matrx.design-system.display-time-zone\", () => ({ zone: null }));\n\n/** What the roster can tell us about a user id. `null` when it cannot. */\nexport type ResolveName = (userId: Uuid) => string | null;\n\n/** The honest stand-in when nobody and nothing can put a name to the author. */\nexport const SOMEBODY = \"somebody in this organization\";\n\n/** The platform's own word for itself. Never \"null\", never \"system_user\". */\nexport const THE_SYSTEM = \"Matrx\";\n\n/**\n * WHO, in the words a person reads. One place, so the grid cell, the record\n * timeline and the column history cannot drift into three different answers.\n */\nexport function actorWords(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const named = actor.name?.trim() || (actor.user_id && resolve ? resolve(actor.user_id)?.trim() : null) || null;\n if (actor.kind === \"agent\") {\n // An agent without the person it acted for cannot happen at the door — the\n // store refuses that write — but a screen still says something true if it does.\n const on = actor.on_behalf_of;\n const person = on?.name?.trim() || (on?.user_id && resolve ? resolve(on.user_id)?.trim() : null) || SOMEBODY;\n const approver = actor.approved_by\n ? actor.approved_by.name?.trim() || (resolve ? resolve(actor.approved_by.user_id)?.trim() : null) || SOMEBODY\n : null;\n return `${named ?? \"an assistant\"}, for ${person}${approver ? `, approved by ${approver}` : \"\"}`;\n }\n return named ?? SOMEBODY;\n}\n\n/** How long ago, in the words a person uses out loud. */\nexport function whenWords(at: string, now: Date = new Date()): string {\n const then = new Date(at);\n const age = now.getTime() - then.getTime();\n if (!Number.isFinite(age)) return \"at an unknown time\";\n if (age < 30 * 86_400_000) return formatRelativeTime(then, { style: \"intl\", now: now.getTime() });\n return then.toLocaleDateString(undefined, displayZone.zone ? { timeZone: displayZone.zone } : undefined);\n}\n\n/**\n * THE WHOLE ANSWER, as one sentence, ending in what to do to see the rest.\n * `null` is a real state and gets its own sentence: this column has never been\n * changed on this record since the store started keeping versions, which is not\n * the same as \"we could not find out\".\n */\n/**\n * WHAT HAPPENED, IN A PERSON'S WORDS (BREAKER-2 B2-29). The store words four operations and\n * lowercases any other (`RETYPE` → \"retype\"), so the panel read \"retype · admin · part of a bigger\n * change\". Every word the store can send is worded here; an unknown one is still written the way\n * a person writes it, never as a token. A soft delete is an archive, and says so.\n */\nconst OPERATION_WORDS: Record<string, string> = {\n created: \"Created\",\n edited: \"Edited\",\n deleted: \"Archived\",\n archived: \"Archived\",\n restored: \"Restored\",\n retype: \"Column type changed\",\n delete: \"Removed\",\n soft_delete: \"Archived\",\n insert: \"Created\",\n update: \"Edited\",\n restore: \"Restored\",\n};\n\nexport function operationWords(label: string | null | undefined): string {\n const raw = (label ?? \"\").trim();\n if (raw === \"\") return \"Changed\";\n const known = OPERATION_WORDS[raw.toLowerCase()];\n if (known) return known;\n const words = humanizeIdentifier(raw).toLowerCase();\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\nexport function lastChangeSentence(\n fieldLabel: string,\n entry: FieldHistoryEntry | null,\n resolve?: ResolveName | undefined,\n): string {\n if (!entry) {\n return `Nothing is recorded against ${fieldLabel} on this record yet. Press H for the whole history of this column.`;\n }\n const verb = operationWords(entry.operation_label).toLowerCase();\n return `${fieldLabel} — ${verb} by ${actorWords(entry.actor, resolve)}, ${whenWords(entry.occurred_at)}. Press H for the whole history.`;\n}\n\n/**\n * The SHORT form the badge wears once it knows: a name a person recognizes at a\n * glance, in the width of a cell corner. Never a uuid, never an email's domain.\n */\nexport function actorBadge(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const words = actorWords(actor, resolve);\n if (words === SOMEBODY) return \"somebody\";\n const first = words.split(\",\")[0]!.trim();\n const at = first.indexOf(\"@\");\n return at > 0 ? first.slice(0, at) : first;\n}\n"]}
|
package/dist/data-source.js
CHANGED
|
@@ -51,6 +51,7 @@ async function hasSession(getSession) {
|
|
|
51
51
|
return true;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
+
var displayZone = globalSlot("ai-matrx.design-system.display-time-zone", () => ({ zone: null }));
|
|
54
55
|
var SOMEBODY = "somebody in this organization";
|
|
55
56
|
var THE_SYSTEM = "Matrx";
|
|
56
57
|
function actorWords(actor, resolve) {
|
|
@@ -69,7 +70,7 @@ function whenWords(at, now = /* @__PURE__ */ new Date()) {
|
|
|
69
70
|
const age = now.getTime() - then.getTime();
|
|
70
71
|
if (!Number.isFinite(age)) return "at an unknown time";
|
|
71
72
|
if (age < 30 * 864e5) return formatRelativeTime(then, { style: "intl", now: now.getTime() });
|
|
72
|
-
return then.toLocaleDateString();
|
|
73
|
+
return then.toLocaleDateString(void 0, displayZone.zone ? { timeZone: displayZone.zone } : void 0);
|
|
73
74
|
}
|
|
74
75
|
var OPERATION_WORDS = {
|
|
75
76
|
created: "Created",
|
package/dist/data-source.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/dataSource.ts","../src/whoChanged.ts"],"names":[],"mappings":";;;;;AAUO,SAAS,YAAY,MAAA,EAA+C;AACzE,EAAA,OAAO,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,EAAQ,SAAS,MAAA,EAAO,GAAI,EAAE,KAAA,EAAO,MAAA,EAAO;AACvE;AA4CA,IAAM,cAAc,UAAA,CAAW,kCAAA,EAAoC,sBAAM,IAAI,SAAiD,CAAA;AAEvH,SAAS,iBAAA,CAAkB,MAAA,EAAgB,cAAA,GAAiB,QAAA,EAA6B;AAC9F,EAAA,IAAI,QAAA,GAAW,WAAA,CAAY,GAAA,CAAI,MAAM,CAAA;AACrC,EAAA,IAAI,CAAC,QAAA,EAAU;AACb,IAAA,QAAA,uBAAe,GAAA,EAAI;AACnB,IAAA,WAAA,CAAY,GAAA,CAAI,QAAQ,QAAQ,CAAA;AAAA,EAClC;AACA,EAAA,MAAM,IAAA,GAAO,QAAA,CAAS,GAAA,CAAI,cAAc,CAAA;AACxC,EAAA,IAAI,MAAM,OAAO,IAAA;AACjB,EAAA,MAAM,IAAA,GAAO,qBAAA,CAAsB,MAAA,EAAQ,cAAc,CAAA;AACzD,EAA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,GAAO,cAAA,CAAe,KAAA,CAAM,eAAe,EAAE,WAAA,EAAY;AAC/D,EAAA,OAAO,CAAA,EAAG,UAAU,CAAA,QAAA,EAAM,IAAI,OAAO,UAAA,CAAW,KAAA,CAAM,KAAA,EAAO,OAAO,CAAC,CAAA,EAAA,EAAK,SAAA,CAAU,KAAA,CAAM,WAAW,CAAC,CAAA,gCAAA,CAAA;AACxG;AAMO,SAAS,UAAA,CAAW,OAAqB,OAAA,EAA2C;AACzF,EAAA,IAAI,KAAA,CAAM,IAAA,KAAS,QAAA,EAAU,OAAO,UAAA;AACpC,EAAA,MAAM,KAAA,GAAQ,UAAA,CAAW,KAAA,EAAO,OAAO,CAAA;AACvC,EAAA,IAAI,KAAA,KAAU,UAAU,OAAO,UAAA;AAC/B,EAAA,MAAM,QAAQ,KAAA,CAAM,KAAA,CAAM,GAAG,CAAA,CAAE,CAAC,EAAG,IAAA,EAAK;AACxC,EAAA,MAAM,EAAA,GAAK,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AAC5B,EAAA,OAAO,KAAK,CAAA,GAAI,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,KAAA;AACvC","file":"data-source.js","sourcesContent":["// src/dataSource.ts — @ai-matrx/records-ui (pure; also served alone by `@ai-matrx/records-ui/helpers`)\n//\n// The two helpers every host calls before it draws anything: who is acting (`personActor`) and the\n// store's data seam over a supabase-js client (`recordsDataSource`). No React and no screen here, so\n// a service, a registry or a server module that needs only these never pulls the package's screens.\n// `RecordsMount` re-exports both, so the root entry keeps them.\n\nimport type { RecordsActor, RecordsDataSource, Uuid } from \"@ai-matrx/records\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport function personActor(userId: Uuid | null | undefined): RecordsActor {\n return userId ? { actor: \"user\", user_id: userId } : { actor: \"user\" };\n}\n\n/**\n * A supabase-js client AS this package's data seam.\n *\n * `RecordsDataSource` is deliberately a small structural subset of\n * `SupabaseClient` — the package holds no key and opens no connection, the host\n * hands it a client that already carries the person's session.\n *\n * IT IS NOT AN IDENTITY CAST, and it cost a live screen to learn why\n * (2026-09-19, /data's first load): the port's `rpc(fn, args, { schema })`\n * says the schema OUT LOUD, because every door of this store is `custom.<name>`\n * and every door of the trust layer is `iam.<name>`. supabase-js's own\n * `rpc(fn, args, options)` has no `schema` option at all — its third argument is\n * `{ head, get, count }` — so a client passed straight through silently asked\n * its default PostgREST profile and the store answered, correctly and uselessly,\n * \"Could not find the function public.table_kernel_id ... PGRST202\". The schema\n * is chosen the one way supabase-js offers: `client.schema(name).rpc(...)`.\n *\n * `schema(name).from(table)` already agrees structurally and is passed through.\n *\n * `fallbackSchema` is the profile a call that says NOTHING is sent to. No caller\n * in `@ai-matrx/records` omits the option — `callDoor` always says `custom` and\n * `trustDoor` always says `iam` — so it never fires today; it exists so that a\n * call which one day forgets lands on the store rather than silently on\n * `public`. It is a FALLBACK and not the answer: a version of this adapter that\n * sent EVERY door to one fixed schema would route the `iam` trust doors (the\n * external principal, the publish binding) into `custom` and get a PGRST202\n * naming the wrong schema.\n *\n * The cast itself stays HERE, once, where it is explained: a generated\n * `Database` type makes `schema().from().select()` enormous, and a host app that\n * passes its client straight into `config` gets `TS2589: Type instantiation is\n * excessively deep and possibly infinite` in its own build (matrx-frontend,\n * 2026-09-18, on all three campaign routes at once).\n */\n/*\n * ONE DATA SOURCE PER SUPABASE CLIENT (owner, 2026-10-02). The record store's data layer keys its\n * cache by the data source object, so a host that builds this adapter again on every mount (a\n * board tile woken or brought back by Undo) must get the SAME object back for the same client —\n * otherwise every remount is a stranger to the answers the last mount read.\n */\n// One cache per realm, never per bundle copy: this module ships in BOTH the root entry and\n// `@ai-matrx/records-ui/helpers` (`splitting: false`), and a module `let` would split it in two.\nconst dataSources = globalSlot(\"ai-matrx.records-ui.data-sources\", () => new WeakMap<object, Map<string, RecordsDataSource>>());\n\nexport function recordsDataSource(client: object, fallbackSchema = \"custom\"): RecordsDataSource {\n let bySchema = dataSources.get(client);\n if (!bySchema) {\n bySchema = new Map();\n dataSources.set(client, bySchema);\n }\n const held = bySchema.get(fallbackSchema);\n if (held) return held;\n const made = makeRecordsDataSource(client, fallbackSchema);\n bySchema.set(fallbackSchema, made);\n return made;\n}\n\nfunction makeRecordsDataSource(client: object, fallbackSchema: string): RecordsDataSource {\n const supabase = client as unknown as {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n schema: (name: string) => {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n from: (table: string) => unknown;\n };\n auth?: { getSession?: () => Promise<{ data?: { session?: unknown } | null }> };\n };\n return {\n // PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.\n opensInOneCall: true,\n async rpc(fn, args, options) {\n const schema = options?.schema ?? fallbackSchema;\n // 🚨 NO STORE DOOR LEAVES WITHOUT A PERSON (lane MONITOR-TRIAGE, 2026-10-01). `anon` holds\n // no USAGE on schema `custom`, so a door called with no session can only come back\n // \"42501 permission denied for schema custom\" (HTTP 401) — seven of them per signed-out\n // /data load (inbox, counts, home, portals…), every one a red row in ops.system_error.\n // A `custom` door with no session is answered HERE, with the store's own signed-out\n // sentence and no network call. Other schemas (`iam`, `platform`) serve guests by design\n // and are never short-circuited. A client without `auth` (a server or test seam) is\n // passed straight through.\n if (schema === \"custom\" && supabase.auth?.getSession && !(await hasSession(supabase.auth.getSession))) {\n return { data: null, error: SIGNED_OUT } as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n }\n const on = supabase.schema(schema);\n return (await on.rpc(fn, args)) as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n },\n schema(name) {\n return supabase.schema(name) as ReturnType<RecordsDataSource[\"schema\"]>;\n },\n };\n}\n\n/** The read door's own sentence for a call with nobody signed in (`custom.read_records_page`, DOOR-1). */\nconst SIGNED_OUT = {\n code: \"42501\",\n message: \"Nobody is signed in, so there is nothing to read.\",\n hint: \"Sign in, then try again.\",\n details: null,\n} as const;\n\nasync function hasSession(getSession: () => Promise<{ data?: { session?: unknown } | null }>): Promise<boolean> {\n try {\n const answer = await getSession();\n return Boolean(answer?.data?.session);\n } catch {\n // Auth could not say: let the request go and the database's answer stand.\n return true;\n }\n}\n","import { formatRelativeTime } from \"@ai-matrx/kit/format\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n// src/whoChanged.ts — @ai-matrx/records-ui · SCR-17, the cell's half\n//\n// \"WHO?\" IS A QUESTION. A SCREEN IS SUPPOSED TO ANSWER IT.\n//\n// 🚨 WHAT A CLINIC SAW (crew B2, 2026-09-21, ten real patients on the live app):\n//\n// \"Every single cell shows a small 'who?' hover badge next to its value instead\n// of a resolved author name, an agent/rule label, or even 'system' — the\n// attribution feature is visibly wired up (it renders on every cell) but never\n// resolves to anything readable.\"\n//\n// They were right that it never resolved, and the reason was that nothing ever\n// asked. The badge opened a panel; it never looked anything up. Meanwhile the\n// store had the answer the whole time: `custom.field_history` on those exact ten\n// patients answers `kind: user, name: admin` on every one of them, and has since\n// they were written.\n//\n// So the badge asks, on the gesture that already reaches it — a hover or a Tab —\n// for the ONE cell being asked about. Nothing is fetched for a page of two\n// hundred cells nobody points at.\n//\n// THE THREE WORDS, AND NEVER A UUID. VAL-8 fixes the vocabulary at `user`,\n// `agent`, `system` and there is no fourth. An agent ALWAYS names the person it\n// acted for (AGT-N-4: it carries exactly that person's authority, so a screen\n// showing the machine without the person would be hiding who is answerable). The\n// system is \"the system\" — a platform word a person can read, not a null. And a\n// person whose name the door did not carry is resolved through the app's ONE\n// organization-scoped roster (the `members` port, FIX-7B's rule: the people of\n// THIS organization and nobody else). If even that cannot name them, the sentence\n// says so in words. It never prints an id: SCR-N-5 forbids showing one to a\n// person, and \"87a6e699…\" answers nobody's question anyway.\n\nimport type { FieldHistoryEntry, HistoryActor, Uuid } from \"@ai-matrx/records\";\n\n/** What the roster can tell us about a user id. `null` when it cannot. */\nexport type ResolveName = (userId: Uuid) => string | null;\n\n/** The honest stand-in when nobody and nothing can put a name to the author. */\nexport const SOMEBODY = \"somebody in this organization\";\n\n/** The platform's own word for itself. Never \"null\", never \"system_user\". */\nexport const THE_SYSTEM = \"Matrx\";\n\n/**\n * WHO, in the words a person reads. One place, so the grid cell, the record\n * timeline and the column history cannot drift into three different answers.\n */\nexport function actorWords(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const named = actor.name?.trim() || (actor.user_id && resolve ? resolve(actor.user_id)?.trim() : null) || null;\n if (actor.kind === \"agent\") {\n // An agent without the person it acted for cannot happen at the door — the\n // store refuses that write — but a screen still says something true if it does.\n const on = actor.on_behalf_of;\n const person = on?.name?.trim() || (on?.user_id && resolve ? resolve(on.user_id)?.trim() : null) || SOMEBODY;\n const approver = actor.approved_by\n ? actor.approved_by.name?.trim() || (resolve ? resolve(actor.approved_by.user_id)?.trim() : null) || SOMEBODY\n : null;\n return `${named ?? \"an assistant\"}, for ${person}${approver ? `, approved by ${approver}` : \"\"}`;\n }\n return named ?? SOMEBODY;\n}\n\n/** How long ago, in the words a person uses out loud. */\nexport function whenWords(at: string, now: Date = new Date()): string {\n const then = new Date(at);\n const age = now.getTime() - then.getTime();\n if (!Number.isFinite(age)) return \"at an unknown time\";\n if (age < 30 * 86_400_000) return formatRelativeTime(then, { style: \"intl\", now: now.getTime() });\n return then.toLocaleDateString();\n}\n\n/**\n * THE WHOLE ANSWER, as one sentence, ending in what to do to see the rest.\n * `null` is a real state and gets its own sentence: this column has never been\n * changed on this record since the store started keeping versions, which is not\n * the same as \"we could not find out\".\n */\n/**\n * WHAT HAPPENED, IN A PERSON'S WORDS (BREAKER-2 B2-29). The store words four operations and\n * lowercases any other (`RETYPE` → \"retype\"), so the panel read \"retype · admin · part of a bigger\n * change\". Every word the store can send is worded here; an unknown one is still written the way\n * a person writes it, never as a token. A soft delete is an archive, and says so.\n */\nconst OPERATION_WORDS: Record<string, string> = {\n created: \"Created\",\n edited: \"Edited\",\n deleted: \"Archived\",\n archived: \"Archived\",\n restored: \"Restored\",\n retype: \"Column type changed\",\n delete: \"Removed\",\n soft_delete: \"Archived\",\n insert: \"Created\",\n update: \"Edited\",\n restore: \"Restored\",\n};\n\nexport function operationWords(label: string | null | undefined): string {\n const raw = (label ?? \"\").trim();\n if (raw === \"\") return \"Changed\";\n const known = OPERATION_WORDS[raw.toLowerCase()];\n if (known) return known;\n const words = humanizeIdentifier(raw).toLowerCase();\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\nexport function lastChangeSentence(\n fieldLabel: string,\n entry: FieldHistoryEntry | null,\n resolve?: ResolveName | undefined,\n): string {\n if (!entry) {\n return `Nothing is recorded against ${fieldLabel} on this record yet. Press H for the whole history of this column.`;\n }\n const verb = operationWords(entry.operation_label).toLowerCase();\n return `${fieldLabel} — ${verb} by ${actorWords(entry.actor, resolve)}, ${whenWords(entry.occurred_at)}. Press H for the whole history.`;\n}\n\n/**\n * The SHORT form the badge wears once it knows: a name a person recognizes at a\n * glance, in the width of a cell corner. Never a uuid, never an email's domain.\n */\nexport function actorBadge(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const words = actorWords(actor, resolve);\n if (words === SOMEBODY) return \"somebody\";\n const first = words.split(\",\")[0]!.trim();\n const at = first.indexOf(\"@\");\n return at > 0 ? first.slice(0, at) : first;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/dataSource.ts","../src/whoChanged.ts"],"names":["globalSlot"],"mappings":";;;;;AAUO,SAAS,YAAY,MAAA,EAA+C;AACzE,EAAA,OAAO,MAAA,GAAS,EAAE,KAAA,EAAO,MAAA,EAAQ,SAAS,MAAA,EAAO,GAAI,EAAE,KAAA,EAAO,MAAA,EAAO;AACvE;AA4CA,IAAM,cAAc,UAAA,CAAW,kCAAA,EAAoC,sBAAM,IAAI,SAAiD,CAAA;AAEvH,SAAS,iBAAA,CAAkB,MAAA,EAAgB,cAAA,GAAiB,QAAA,EAA6B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,OAAO,KAAK,CAAA,GAAI,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,GAAI,KAAA;AACvC","file":"data-source.js","sourcesContent":["// src/dataSource.ts — @ai-matrx/records-ui (pure; also served alone by `@ai-matrx/records-ui/helpers`)\n//\n// The two helpers every host calls before it draws anything: who is acting (`personActor`) and the\n// store's data seam over a supabase-js client (`recordsDataSource`). No React and no screen here, so\n// a service, a registry or a server module that needs only these never pulls the package's screens.\n// `RecordsMount` re-exports both, so the root entry keeps them.\n\nimport type { RecordsActor, RecordsDataSource, Uuid } from \"@ai-matrx/records\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\n\nexport function personActor(userId: Uuid | null | undefined): RecordsActor {\n return userId ? { actor: \"user\", user_id: userId } : { actor: \"user\" };\n}\n\n/**\n * A supabase-js client AS this package's data seam.\n *\n * `RecordsDataSource` is deliberately a small structural subset of\n * `SupabaseClient` — the package holds no key and opens no connection, the host\n * hands it a client that already carries the person's session.\n *\n * IT IS NOT AN IDENTITY CAST, and it cost a live screen to learn why\n * (2026-09-19, /data's first load): the port's `rpc(fn, args, { schema })`\n * says the schema OUT LOUD, because every door of this store is `custom.<name>`\n * and every door of the trust layer is `iam.<name>`. supabase-js's own\n * `rpc(fn, args, options)` has no `schema` option at all — its third argument is\n * `{ head, get, count }` — so a client passed straight through silently asked\n * its default PostgREST profile and the store answered, correctly and uselessly,\n * \"Could not find the function public.table_kernel_id ... PGRST202\". The schema\n * is chosen the one way supabase-js offers: `client.schema(name).rpc(...)`.\n *\n * `schema(name).from(table)` already agrees structurally and is passed through.\n *\n * `fallbackSchema` is the profile a call that says NOTHING is sent to. No caller\n * in `@ai-matrx/records` omits the option — `callDoor` always says `custom` and\n * `trustDoor` always says `iam` — so it never fires today; it exists so that a\n * call which one day forgets lands on the store rather than silently on\n * `public`. It is a FALLBACK and not the answer: a version of this adapter that\n * sent EVERY door to one fixed schema would route the `iam` trust doors (the\n * external principal, the publish binding) into `custom` and get a PGRST202\n * naming the wrong schema.\n *\n * The cast itself stays HERE, once, where it is explained: a generated\n * `Database` type makes `schema().from().select()` enormous, and a host app that\n * passes its client straight into `config` gets `TS2589: Type instantiation is\n * excessively deep and possibly infinite` in its own build (matrx-frontend,\n * 2026-09-18, on all three campaign routes at once).\n */\n/*\n * ONE DATA SOURCE PER SUPABASE CLIENT (owner, 2026-10-02). The record store's data layer keys its\n * cache by the data source object, so a host that builds this adapter again on every mount (a\n * board tile woken or brought back by Undo) must get the SAME object back for the same client —\n * otherwise every remount is a stranger to the answers the last mount read.\n */\n// One cache per realm, never per bundle copy: this module ships in BOTH the root entry and\n// `@ai-matrx/records-ui/helpers` (`splitting: false`), and a module `let` would split it in two.\nconst dataSources = globalSlot(\"ai-matrx.records-ui.data-sources\", () => new WeakMap<object, Map<string, RecordsDataSource>>());\n\nexport function recordsDataSource(client: object, fallbackSchema = \"custom\"): RecordsDataSource {\n let bySchema = dataSources.get(client);\n if (!bySchema) {\n bySchema = new Map();\n dataSources.set(client, bySchema);\n }\n const held = bySchema.get(fallbackSchema);\n if (held) return held;\n const made = makeRecordsDataSource(client, fallbackSchema);\n bySchema.set(fallbackSchema, made);\n return made;\n}\n\nfunction makeRecordsDataSource(client: object, fallbackSchema: string): RecordsDataSource {\n const supabase = client as unknown as {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n schema: (name: string) => {\n rpc: (fn: string, args: Record<string, unknown>) => PromiseLike<unknown>;\n from: (table: string) => unknown;\n };\n auth?: { getSession?: () => Promise<{ data?: { session?: unknown } | null }> };\n };\n return {\n // PAGE-BUNDLE: the real adapter opens a table page with one `custom.table_page_bundle` call.\n opensInOneCall: true,\n async rpc(fn, args, options) {\n const schema = options?.schema ?? fallbackSchema;\n // 🚨 NO STORE DOOR LEAVES WITHOUT A PERSON (lane MONITOR-TRIAGE, 2026-10-01). `anon` holds\n // no USAGE on schema `custom`, so a door called with no session can only come back\n // \"42501 permission denied for schema custom\" (HTTP 401) — seven of them per signed-out\n // /data load (inbox, counts, home, portals…), every one a red row in ops.system_error.\n // A `custom` door with no session is answered HERE, with the store's own signed-out\n // sentence and no network call. Other schemas (`iam`, `platform`) serve guests by design\n // and are never short-circuited. A client without `auth` (a server or test seam) is\n // passed straight through.\n if (schema === \"custom\" && supabase.auth?.getSession && !(await hasSession(supabase.auth.getSession))) {\n return { data: null, error: SIGNED_OUT } as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n }\n const on = supabase.schema(schema);\n return (await on.rpc(fn, args)) as Awaited<ReturnType<RecordsDataSource[\"rpc\"]>>;\n },\n schema(name) {\n return supabase.schema(name) as ReturnType<RecordsDataSource[\"schema\"]>;\n },\n };\n}\n\n/** The read door's own sentence for a call with nobody signed in (`custom.read_records_page`, DOOR-1). */\nconst SIGNED_OUT = {\n code: \"42501\",\n message: \"Nobody is signed in, so there is nothing to read.\",\n hint: \"Sign in, then try again.\",\n details: null,\n} as const;\n\nasync function hasSession(getSession: () => Promise<{ data?: { session?: unknown } | null }>): Promise<boolean> {\n try {\n const answer = await getSession();\n return Boolean(answer?.data?.session);\n } catch {\n // Auth could not say: let the request go and the database's answer stand.\n return true;\n }\n}\n","import { formatRelativeTime } from \"@ai-matrx/kit/format\";\nimport { globalSlot } from \"@ai-matrx/kit/global-slot\";\nimport { humanizeIdentifier } from \"@ai-matrx/kit/text-case\";\n// src/whoChanged.ts — @ai-matrx/records-ui · SCR-17, the cell's half\n//\n// \"WHO?\" IS A QUESTION. A SCREEN IS SUPPOSED TO ANSWER IT.\n//\n// 🚨 WHAT A CLINIC SAW (crew B2, 2026-09-21, ten real patients on the live app):\n//\n// \"Every single cell shows a small 'who?' hover badge next to its value instead\n// of a resolved author name, an agent/rule label, or even 'system' — the\n// attribution feature is visibly wired up (it renders on every cell) but never\n// resolves to anything readable.\"\n//\n// They were right that it never resolved, and the reason was that nothing ever\n// asked. The badge opened a panel; it never looked anything up. Meanwhile the\n// store had the answer the whole time: `custom.field_history` on those exact ten\n// patients answers `kind: user, name: admin` on every one of them, and has since\n// they were written.\n//\n// So the badge asks, on the gesture that already reaches it — a hover or a Tab —\n// for the ONE cell being asked about. Nothing is fetched for a page of two\n// hundred cells nobody points at.\n//\n// THE THREE WORDS, AND NEVER A UUID. VAL-8 fixes the vocabulary at `user`,\n// `agent`, `system` and there is no fourth. An agent ALWAYS names the person it\n// acted for (AGT-N-4: it carries exactly that person's authority, so a screen\n// showing the machine without the person would be hiding who is answerable). The\n// system is \"the system\" — a platform word a person can read, not a null. And a\n// person whose name the door did not carry is resolved through the app's ONE\n// organization-scoped roster (the `members` port, FIX-7B's rule: the people of\n// THIS organization and nobody else). If even that cannot name them, the sentence\n// says so in words. It never prints an id: SCR-N-5 forbids showing one to a\n// person, and \"87a6e699…\" answers nobody's question anyway.\n\nimport type { FieldHistoryEntry, HistoryActor, Uuid } from \"@ai-matrx/records\";\n\n// Read the same realm-wide slot set by design-system's setDisplayTimeZone. This\n// helper is also exported by the light /data-source entry, so it cannot import\n// design-system's field-format bundle merely to read the saved zone.\nconst displayZone = globalSlot<{ zone: string | null }>(\"ai-matrx.design-system.display-time-zone\", () => ({ zone: null }));\n\n/** What the roster can tell us about a user id. `null` when it cannot. */\nexport type ResolveName = (userId: Uuid) => string | null;\n\n/** The honest stand-in when nobody and nothing can put a name to the author. */\nexport const SOMEBODY = \"somebody in this organization\";\n\n/** The platform's own word for itself. Never \"null\", never \"system_user\". */\nexport const THE_SYSTEM = \"Matrx\";\n\n/**\n * WHO, in the words a person reads. One place, so the grid cell, the record\n * timeline and the column history cannot drift into three different answers.\n */\nexport function actorWords(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const named = actor.name?.trim() || (actor.user_id && resolve ? resolve(actor.user_id)?.trim() : null) || null;\n if (actor.kind === \"agent\") {\n // An agent without the person it acted for cannot happen at the door — the\n // store refuses that write — but a screen still says something true if it does.\n const on = actor.on_behalf_of;\n const person = on?.name?.trim() || (on?.user_id && resolve ? resolve(on.user_id)?.trim() : null) || SOMEBODY;\n const approver = actor.approved_by\n ? actor.approved_by.name?.trim() || (resolve ? resolve(actor.approved_by.user_id)?.trim() : null) || SOMEBODY\n : null;\n return `${named ?? \"an assistant\"}, for ${person}${approver ? `, approved by ${approver}` : \"\"}`;\n }\n return named ?? SOMEBODY;\n}\n\n/** How long ago, in the words a person uses out loud. */\nexport function whenWords(at: string, now: Date = new Date()): string {\n const then = new Date(at);\n const age = now.getTime() - then.getTime();\n if (!Number.isFinite(age)) return \"at an unknown time\";\n if (age < 30 * 86_400_000) return formatRelativeTime(then, { style: \"intl\", now: now.getTime() });\n return then.toLocaleDateString(undefined, displayZone.zone ? { timeZone: displayZone.zone } : undefined);\n}\n\n/**\n * THE WHOLE ANSWER, as one sentence, ending in what to do to see the rest.\n * `null` is a real state and gets its own sentence: this column has never been\n * changed on this record since the store started keeping versions, which is not\n * the same as \"we could not find out\".\n */\n/**\n * WHAT HAPPENED, IN A PERSON'S WORDS (BREAKER-2 B2-29). The store words four operations and\n * lowercases any other (`RETYPE` → \"retype\"), so the panel read \"retype · admin · part of a bigger\n * change\". Every word the store can send is worded here; an unknown one is still written the way\n * a person writes it, never as a token. A soft delete is an archive, and says so.\n */\nconst OPERATION_WORDS: Record<string, string> = {\n created: \"Created\",\n edited: \"Edited\",\n deleted: \"Archived\",\n archived: \"Archived\",\n restored: \"Restored\",\n retype: \"Column type changed\",\n delete: \"Removed\",\n soft_delete: \"Archived\",\n insert: \"Created\",\n update: \"Edited\",\n restore: \"Restored\",\n};\n\nexport function operationWords(label: string | null | undefined): string {\n const raw = (label ?? \"\").trim();\n if (raw === \"\") return \"Changed\";\n const known = OPERATION_WORDS[raw.toLowerCase()];\n if (known) return known;\n const words = humanizeIdentifier(raw).toLowerCase();\n return words.charAt(0).toUpperCase() + words.slice(1);\n}\n\nexport function lastChangeSentence(\n fieldLabel: string,\n entry: FieldHistoryEntry | null,\n resolve?: ResolveName | undefined,\n): string {\n if (!entry) {\n return `Nothing is recorded against ${fieldLabel} on this record yet. Press H for the whole history of this column.`;\n }\n const verb = operationWords(entry.operation_label).toLowerCase();\n return `${fieldLabel} — ${verb} by ${actorWords(entry.actor, resolve)}, ${whenWords(entry.occurred_at)}. Press H for the whole history.`;\n}\n\n/**\n * The SHORT form the badge wears once it knows: a name a person recognizes at a\n * glance, in the width of a cell corner. Never a uuid, never an email's domain.\n */\nexport function actorBadge(actor: HistoryActor, resolve?: ResolveName | undefined): string {\n if (actor.kind === \"system\") return THE_SYSTEM;\n const words = actorWords(actor, resolve);\n if (words === SOMEBODY) return \"somebody\";\n const first = words.split(\",\")[0]!.trim();\n const at = first.indexOf(\"@\");\n return at > 0 ? first.slice(0, at) : first;\n}\n"]}
|
package/dist/helpers.cjs
CHANGED
|
@@ -6,7 +6,7 @@ var fieldKinds = require('@ai-matrx/records/field-kinds');
|
|
|
6
6
|
var uuid = require('@ai-matrx/kit/uuid');
|
|
7
7
|
var textCase = require('@ai-matrx/kit/text-case');
|
|
8
8
|
var format = require('@ai-matrx/kit/format');
|
|
9
|
-
require('@ai-matrx/design-system/field-formats');
|
|
9
|
+
var fieldFormats = require('@ai-matrx/design-system/field-formats');
|
|
10
10
|
var base = require('@ai-matrx/records/views');
|
|
11
11
|
var forms = require('@ai-matrx/records/forms');
|
|
12
12
|
var delimited = require('@ai-matrx/kit/delimited');
|
|
@@ -99,6 +99,7 @@ function setPersonTimeZone(next) {
|
|
|
99
99
|
if (clean === state.zone) return;
|
|
100
100
|
state.zone = clean;
|
|
101
101
|
tableStyle.setColorRuleTimeZone(clean);
|
|
102
|
+
tableStyle.setDisplayTimeZone(clean);
|
|
102
103
|
state.listeners.forEach((l) => l());
|
|
103
104
|
}
|
|
104
105
|
function getPersonTimeZone() {
|
|
@@ -269,6 +270,7 @@ function cardTitleField(fields, titleKey, exclude = []) {
|
|
|
269
270
|
}
|
|
270
271
|
return ordered.find((f) => f.type === "text" && canTitle(f, excluded)) ?? ordered.find((f) => canTitle(f, excluded));
|
|
271
272
|
}
|
|
273
|
+
var displayZone = globalSlot.globalSlot("ai-matrx.design-system.display-time-zone", () => ({ zone: null }));
|
|
272
274
|
var SOMEBODY = "somebody in this organization";
|
|
273
275
|
var THE_SYSTEM = "Matrx";
|
|
274
276
|
function actorWords(actor, resolve) {
|
|
@@ -287,7 +289,7 @@ function whenWords(at, now = /* @__PURE__ */ new Date()) {
|
|
|
287
289
|
const age = now.getTime() - then.getTime();
|
|
288
290
|
if (!Number.isFinite(age)) return "at an unknown time";
|
|
289
291
|
if (age < 30 * 864e5) return format.formatRelativeTime(then, { style: "intl", now: now.getTime() });
|
|
290
|
-
return then.toLocaleDateString();
|
|
292
|
+
return then.toLocaleDateString(void 0, displayZone.zone ? { timeZone: displayZone.zone } : void 0);
|
|
291
293
|
}
|
|
292
294
|
var OPERATION_WORDS = {
|
|
293
295
|
created: "Created",
|
|
@@ -487,8 +489,6 @@ function fieldTypeLabel(field) {
|
|
|
487
489
|
};
|
|
488
490
|
return plain[kind] ?? textCase.humanizeIdentifier(kind);
|
|
489
491
|
}
|
|
490
|
-
|
|
491
|
-
// src/tablePickerEntries.ts
|
|
492
492
|
var PLATFORM_TABLE_PREFIX = "records_ui_";
|
|
493
493
|
function keptByPlatform(table) {
|
|
494
494
|
return table.platform_owned === true || table.kept_by_the_app === true;
|
|
@@ -530,7 +530,7 @@ function madeOn(stamp) {
|
|
|
530
530
|
if (!stamp) return null;
|
|
531
531
|
const at = new Date(stamp);
|
|
532
532
|
if (Number.isNaN(at.getTime())) return null;
|
|
533
|
-
return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric", year: "numeric" }).format(at);
|
|
533
|
+
return new Intl.DateTimeFormat(void 0, { month: "short", day: "numeric", year: "numeric", ...fieldFormats.momentZoneOptions(at) }).format(at);
|
|
534
534
|
}
|
|
535
535
|
function parseGanttLook(raw) {
|
|
536
536
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return void 0;
|
|
@@ -910,8 +910,8 @@ function googleCalendarUrl(httpsUrl) {
|
|
|
910
910
|
var FIELD_SENSITIVITY_LABEL = {
|
|
911
911
|
public: "Anyone who can open the record",
|
|
912
912
|
internal: "People in this organization",
|
|
913
|
-
confidential: "
|
|
914
|
-
restricted: "
|
|
913
|
+
confidential: "Editors and administrators",
|
|
914
|
+
restricted: "Administrators only"
|
|
915
915
|
};
|
|
916
916
|
var STORE_BEHAVIOUR = new Map(fieldKinds.DECLARABLE_FIELD_KINDS.map((row) => [row.kind, row.behavior]));
|
|
917
917
|
function holdsAValueOnAStandardTable(kind) {
|