@entifix/next-shell 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/command-palette/use-records-source.d.ts.map +1 -1
- package/dist/lib/command-palette/use-records-source.js +5 -2
- package/dist/lib/command-palette/use-records-source.js.map +1 -1
- package/dist/lib/crud/index.d.ts +1 -0
- package/dist/lib/crud/index.d.ts.map +1 -1
- package/dist/lib/crud/index.js +1 -0
- package/dist/lib/crud/index.js.map +1 -1
- package/dist/lib/crud/make-entity-crud.d.ts.map +1 -1
- package/dist/lib/crud/make-entity-crud.js +7 -4
- package/dist/lib/crud/make-entity-crud.js.map +1 -1
- package/dist/lib/crud/use-entity-link-sources.d.ts.map +1 -1
- package/dist/lib/crud/use-entity-link-sources.js +5 -1
- package/dist/lib/crud/use-entity-link-sources.js.map +1 -1
- package/dist/lib/crud/use-entity-total.d.ts +27 -0
- package/dist/lib/crud/use-entity-total.d.ts.map +1 -0
- package/dist/lib/crud/use-entity-total.js +39 -0
- package/dist/lib/crud/use-entity-total.js.map +1 -0
- package/dist/lib/search/record-search-route.d.ts +2 -0
- package/dist/lib/search/record-search-route.d.ts.map +1 -1
- package/dist/lib/search/record-search-route.js +21 -5
- package/dist/lib/search/record-search-route.js.map +1 -1
- package/dist/lib/search/record-search-source.d.ts +11 -4
- package/dist/lib/search/record-search-source.d.ts.map +1 -1
- package/dist/lib/search/record-search-source.js +17 -19
- package/dist/lib/search/record-search-source.js.map +1 -1
- package/dist/lib/search/record-search.types.d.ts +4 -3
- package/dist/lib/search/record-search.types.d.ts.map +1 -1
- package/dist/lib/search/record-search.types.js.map +1 -1
- package/dist/lib/search/search-records.d.ts +3 -1
- package/dist/lib/search/search-records.d.ts.map +1 -1
- package/dist/lib/search/search-records.js +2 -1
- package/dist/lib/search/search-records.js.map +1 -1
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-records-source.d.ts","sourceRoot":"","sources":["../../../src/lib/command-palette/use-records-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,eAAe,CAAC;AA0CvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,aAAa,
|
|
1
|
+
{"version":3,"file":"use-records-source.d.ts","sourceRoot":"","sources":["../../../src/lib/command-palette/use-records-source.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,aAAa,EAGd,MAAM,eAAe,CAAC;AA0CvB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,aAAa,CAiJf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
3
|
-
import { useT, useTranslateKey } from '@entifix/react-controls';
|
|
3
|
+
import { useLocale, useT, useTranslateKey } from '@entifix/react-controls';
|
|
4
4
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
5
5
|
import { useLocaleHref } from '../i18n/index.js';
|
|
6
6
|
import { searchRecords } from '../search/search-records.js';
|
|
@@ -42,6 +42,7 @@ const NOTHING_YET = {
|
|
|
42
42
|
*/ export function useRecordsSource(term, enabled) {
|
|
43
43
|
const t = useT('shell');
|
|
44
44
|
const translateKey = useTranslateKey();
|
|
45
|
+
const locale = useLocale();
|
|
45
46
|
const withLocale = useLocaleHref();
|
|
46
47
|
const [state, setState] = useState(NOTHING_YET);
|
|
47
48
|
// The term the request in flight is for. A ref, not state: it changes on every
|
|
@@ -61,7 +62,8 @@ const NOTHING_YET = {
|
|
|
61
62
|
pending.current = term;
|
|
62
63
|
const timer = setTimeout(()=>{
|
|
63
64
|
void searchRecords(term, {
|
|
64
|
-
signal: controller.signal
|
|
65
|
+
signal: controller.signal,
|
|
66
|
+
locale
|
|
65
67
|
}).then((response)=>{
|
|
66
68
|
if (pending.current !== term) return;
|
|
67
69
|
setState({
|
|
@@ -85,6 +87,7 @@ const NOTHING_YET = {
|
|
|
85
87
|
};
|
|
86
88
|
}, [
|
|
87
89
|
active,
|
|
90
|
+
locale,
|
|
88
91
|
term
|
|
89
92
|
]);
|
|
90
93
|
return useMemo(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/command-palette/use-records-source.ts"],"sourcesContent":["'use client';\n\nimport type {\n CommandGroup,\n CommandSource,\n CommandUnavailableSeverity,\n FailureCategory,\n} from '@entifix/core';\nimport { useT, useTranslateKey } from '@entifix/react-controls';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useLocaleHref } from '../i18n/index.js';\nimport type { RecordSearchResponse } from '../search/record-search.types.js';\nimport { searchRecords } from '../search/search-records.js';\nimport {\n RECORD_SEARCH_DEBOUNCE_MS,\n RECORD_SEARCH_MIN_TERM,\n} from './palette-command.js';\n\n/**\n * Which reasons are the caller's ordinary state, and which mean something broke.\n *\n * The split is the record search's, restated as severity because that is what the palette\n * renders. An operator holds no membership, so every tenant-plane source answers\n * `409` on every keystroke — painting that as an outage teaches them to ignore\n * the row entirely, and then the `timeout` that does matter goes unread too.\n */\nconst SCOPE_CODES: ReadonlySet<string> = new Set(['noActiveOrganization']);\n\nconst severityOf = (degraded: {\n readonly reason: string;\n readonly category: FailureCategory;\n}): CommandUnavailableSeverity =>\n degraded.category === 'unauthenticated' ||\n degraded.category === 'forbidden' ||\n SCOPE_CODES.has(degraded.reason)\n ? 'scope'\n : 'reachability';\n\n/** What the browser is currently showing for records. */\ninterface RecordsState {\n /** The term this answer is for, so a stale response cannot overwrite a newer one. */\n readonly term: string;\n readonly response?: RecordSearchResponse;\n readonly failed: boolean;\n}\n\nconst NOTHING_YET: RecordsState = { term: '', failed: false };\n\n/**\n * Records matching the term, one group per source, in the order the host\n * declared them.\n *\n * The whole of the *keystroke* policy lives here rather than in `searchRecords`,\n * which is deliberately a bare typed `fetch`: the palette is the thing that\n * knows a keystroke is not a query. So this owns the debounce, the abort and the\n * two-character floor, while the route owns the fan-out, the per-source timeout\n * and the authorization.\n *\n * **No index, ever.** Every option here came back from `/api/search` for this\n * principal and this organization, on this keystroke. A prefetched client index\n * is the shape that surfaces another organization's record the first time a\n * session's scope moves under it, so there is none, ever.\n *\n * Below the two-character floor the group is present and **says why** rather\n * than being empty or absent: empty would claim nothing matched a search that\n * never ran, and absent would leave someone wondering whether records are\n * searchable here at all.\n */\nexport function useRecordsSource(\n term: string,\n enabled: boolean,\n): CommandSource {\n const t = useT('shell');\n const translateKey = useTranslateKey();\n const withLocale = useLocaleHref();\n\n const [state, setState] = useState<RecordsState>(NOTHING_YET);\n // The term the request in flight is for. A ref, not state: it changes on every\n // keystroke and nothing renders from it.\n const pending = useRef<string | null>(null);\n\n const active = enabled && term.length >= RECORD_SEARCH_MIN_TERM;\n\n useEffect(() => {\n // Nothing is cleared here on purpose. A `setState` in an effect body is a\n // cascading render, and there is nothing to clear: the memo below returns no\n // groups while inactive, so a previous answer is unreachable rather than\n // stale — and the host empties the term when it opens the palette.\n if (!active) {\n pending.current = null;\n return;\n }\n\n const controller = new AbortController();\n pending.current = term;\n\n const timer = setTimeout(() => {\n void searchRecords(term, { signal: controller.signal })\n .then(response => {\n if (pending.current !== term) return;\n setState({ term, response, failed: false });\n })\n .catch(() => {\n // An abort lands here too and must not be shown: the term moved on,\n // so there is nothing to report about the request that did not finish.\n if (controller.signal.aborted || pending.current !== term) return;\n setState({ term, failed: true });\n });\n }, RECORD_SEARCH_DEBOUNCE_MS);\n\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [active, term]);\n\n return useMemo(() => {\n const heading = t('commandPalette.groups.records');\n\n if (!active) {\n // Someone who has typed one character is mid-word, not looking at an\n // answer. Saying so is better than both alternatives: an empty group would\n // claim nothing matched a search that never ran, and an absent one would\n // leave them wondering whether records are searchable at all.\n if (!enabled || term.length === 0) return { key: 'records', groups: [] };\n return {\n key: 'records',\n groups: [\n {\n key: 'records',\n label: heading,\n options: [],\n isLoading: false,\n unavailable: {\n message: t('commandPalette.typeMore', {\n count: RECORD_SEARCH_MIN_TERM,\n }),\n severity: 'scope',\n },\n },\n ],\n };\n }\n // A newer term is in flight. The previous answer stays on screen with its\n // groups marked loading rather than blanking: a list that empties between\n // keystrokes flickers, and the rows it drops were correct a moment ago.\n const isLoading = state.term !== term;\n\n if (state.response === undefined) {\n return {\n key: 'records',\n groups: [\n {\n key: 'records',\n label: heading,\n options: [],\n isLoading: !state.failed,\n // The whole endpoint failed — a lapsed session or a `400`, both of\n // which arrive as a rejection rather than inside a `200`. It is\n // named for the same reason a single degraded source is.\n ...(state.failed\n ? {\n unavailable: {\n message: t('commandPalette.unavailableReach', {\n reason: translateKey('errors:unexpected'),\n }),\n severity: 'reachability' as const,\n },\n }\n : {}),\n },\n ],\n };\n }\n\n const groups: CommandGroup[] = state.response.groups.map(group => ({\n key: `record:${group.source}`,\n // The entity's own `pluralKey`, so record search introduces no copy of\n // its own and a group is titled exactly as its screen is.\n label: translateKey(group.labelKey),\n options: group.items.map(item => ({\n id: `record:${group.source}:${item.id}`,\n label: item.label,\n ...(item.sublabel === undefined ? {} : { sublabel: item.sublabel }),\n href: withLocale(item.href),\n })),\n total: group.total,\n isLoading,\n }));\n\n for (const degraded of state.response.unavailable) {\n const severity = severityOf(degraded);\n groups.push({\n key: `record:${degraded.source}`,\n // Derived from the entity rather than from the source key, which is an\n // identifier and would render as `product-specification`. Every\n // searchable entity declares a `pluralKey` — `catalogSurface` throws\n // without one — so this always resolves.\n label: translateKey(`entity:${degraded.entity}.plural`),\n options: [],\n isLoading: false,\n unavailable: {\n message: t(\n severity === 'scope'\n ? 'commandPalette.unavailableScope'\n : 'commandPalette.unavailableReach',\n { reason: translateKey(`errors:${degraded.reason}`) },\n ),\n severity,\n },\n });\n }\n\n return { key: 'records', groups };\n }, [active, enabled, state, term, t, translateKey, withLocale]);\n}\n"],"names":["useT","useTranslateKey","useEffect","useMemo","useRef","useState","useLocaleHref","searchRecords","RECORD_SEARCH_DEBOUNCE_MS","RECORD_SEARCH_MIN_TERM","SCOPE_CODES","Set","severityOf","degraded","category","has","reason","NOTHING_YET","term","failed","useRecordsSource","enabled","t","translateKey","withLocale","state","setState","pending","active","length","current","controller","AbortController","timer","setTimeout","signal","then","response","catch","aborted","clearTimeout","abort","heading","key","groups","label","options","isLoading","unavailable","message","count","severity","undefined","map","group","source","labelKey","items","item","id","sublabel","href","total","push","entity"],"mappings":"AAAA;;AAQA,SAASA,IAAI,EAAEC,eAAe,QAAQ,0BAA0B;AAChE,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE7D,SAASC,aAAa,QAAQ,mBAAmB;AAEjD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SACEC,yBAAyB,EACzBC,sBAAsB,QACjB,uBAAuB;AAE9B;;;;;;;CAOC,GACD,MAAMC,cAAmC,IAAIC,IAAI;IAAC;CAAuB;AAEzE,MAAMC,aAAa,CAACC,WAIlBA,SAASC,QAAQ,KAAK,qBACtBD,SAASC,QAAQ,KAAK,eACtBJ,YAAYK,GAAG,CAACF,SAASG,MAAM,IAC3B,UACA;AAUN,MAAMC,cAA4B;IAAEC,MAAM;IAAIC,QAAQ;AAAM;AAE5D;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,iBACdF,IAAY,EACZG,OAAgB;IAEhB,MAAMC,IAAItB,KAAK;IACf,MAAMuB,eAAetB;IACrB,MAAMuB,aAAalB;IAEnB,MAAM,CAACmB,OAAOC,SAAS,GAAGrB,SAAuBY;IACjD,+EAA+E;IAC/E,yCAAyC;IACzC,MAAMU,UAAUvB,OAAsB;IAEtC,MAAMwB,SAASP,WAAWH,KAAKW,MAAM,IAAIpB;IAEzCP,UAAU;QACR,0EAA0E;QAC1E,6EAA6E;QAC7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CACJ;wBAAEnC,QAAQO,aAAa,CAAC,OAAO,EAAEV,SAASG,MAAM,EAAE;oBAAE;oBAEtDmC;gBACF;YACF;QACF;QAEA,OAAO;YAAER,KAAK;YAAWC;QAAO;IAClC,GAAG;QAAChB;QAAQP;QAASI;QAAOP;QAAMI;QAAGC;QAAcC;KAAW;AAChE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/command-palette/use-records-source.ts"],"sourcesContent":["'use client';\n\nimport type {\n CommandGroup,\n CommandSource,\n CommandUnavailableSeverity,\n FailureCategory,\n} from '@entifix/core';\nimport { useLocale, useT, useTranslateKey } from '@entifix/react-controls';\nimport { useEffect, useMemo, useRef, useState } from 'react';\n\nimport { useLocaleHref } from '../i18n/index.js';\nimport type { RecordSearchResponse } from '../search/record-search.types.js';\nimport { searchRecords } from '../search/search-records.js';\nimport {\n RECORD_SEARCH_DEBOUNCE_MS,\n RECORD_SEARCH_MIN_TERM,\n} from './palette-command.js';\n\n/**\n * Which reasons are the caller's ordinary state, and which mean something broke.\n *\n * The split is the record search's, restated as severity because that is what the palette\n * renders. An operator holds no membership, so every tenant-plane source answers\n * `409` on every keystroke — painting that as an outage teaches them to ignore\n * the row entirely, and then the `timeout` that does matter goes unread too.\n */\nconst SCOPE_CODES: ReadonlySet<string> = new Set(['noActiveOrganization']);\n\nconst severityOf = (degraded: {\n readonly reason: string;\n readonly category: FailureCategory;\n}): CommandUnavailableSeverity =>\n degraded.category === 'unauthenticated' ||\n degraded.category === 'forbidden' ||\n SCOPE_CODES.has(degraded.reason)\n ? 'scope'\n : 'reachability';\n\n/** What the browser is currently showing for records. */\ninterface RecordsState {\n /** The term this answer is for, so a stale response cannot overwrite a newer one. */\n readonly term: string;\n readonly response?: RecordSearchResponse;\n readonly failed: boolean;\n}\n\nconst NOTHING_YET: RecordsState = { term: '', failed: false };\n\n/**\n * Records matching the term, one group per source, in the order the host\n * declared them.\n *\n * The whole of the *keystroke* policy lives here rather than in `searchRecords`,\n * which is deliberately a bare typed `fetch`: the palette is the thing that\n * knows a keystroke is not a query. So this owns the debounce, the abort and the\n * two-character floor, while the route owns the fan-out, the per-source timeout\n * and the authorization.\n *\n * **No index, ever.** Every option here came back from `/api/search` for this\n * principal and this organization, on this keystroke. A prefetched client index\n * is the shape that surfaces another organization's record the first time a\n * session's scope moves under it, so there is none, ever.\n *\n * Below the two-character floor the group is present and **says why** rather\n * than being empty or absent: empty would claim nothing matched a search that\n * never ran, and absent would leave someone wondering whether records are\n * searchable here at all.\n */\nexport function useRecordsSource(\n term: string,\n enabled: boolean,\n): CommandSource {\n const t = useT('shell');\n const translateKey = useTranslateKey();\n const locale = useLocale();\n const withLocale = useLocaleHref();\n\n const [state, setState] = useState<RecordsState>(NOTHING_YET);\n // The term the request in flight is for. A ref, not state: it changes on every\n // keystroke and nothing renders from it.\n const pending = useRef<string | null>(null);\n\n const active = enabled && term.length >= RECORD_SEARCH_MIN_TERM;\n\n useEffect(() => {\n // Nothing is cleared here on purpose. A `setState` in an effect body is a\n // cascading render, and there is nothing to clear: the memo below returns no\n // groups while inactive, so a previous answer is unreachable rather than\n // stale — and the host empties the term when it opens the palette.\n if (!active) {\n pending.current = null;\n return;\n }\n\n const controller = new AbortController();\n pending.current = term;\n\n const timer = setTimeout(() => {\n void searchRecords(term, { signal: controller.signal, locale })\n .then(response => {\n if (pending.current !== term) return;\n setState({ term, response, failed: false });\n })\n .catch(() => {\n // An abort lands here too and must not be shown: the term moved on,\n // so there is nothing to report about the request that did not finish.\n if (controller.signal.aborted || pending.current !== term) return;\n setState({ term, failed: true });\n });\n }, RECORD_SEARCH_DEBOUNCE_MS);\n\n return () => {\n clearTimeout(timer);\n controller.abort();\n };\n }, [active, locale, term]);\n\n return useMemo(() => {\n const heading = t('commandPalette.groups.records');\n\n if (!active) {\n // Someone who has typed one character is mid-word, not looking at an\n // answer. Saying so is better than both alternatives: an empty group would\n // claim nothing matched a search that never ran, and an absent one would\n // leave them wondering whether records are searchable at all.\n if (!enabled || term.length === 0) return { key: 'records', groups: [] };\n return {\n key: 'records',\n groups: [\n {\n key: 'records',\n label: heading,\n options: [],\n isLoading: false,\n unavailable: {\n message: t('commandPalette.typeMore', {\n count: RECORD_SEARCH_MIN_TERM,\n }),\n severity: 'scope',\n },\n },\n ],\n };\n }\n // A newer term is in flight. The previous answer stays on screen with its\n // groups marked loading rather than blanking: a list that empties between\n // keystrokes flickers, and the rows it drops were correct a moment ago.\n const isLoading = state.term !== term;\n\n if (state.response === undefined) {\n return {\n key: 'records',\n groups: [\n {\n key: 'records',\n label: heading,\n options: [],\n isLoading: !state.failed,\n // The whole endpoint failed — a lapsed session or a `400`, both of\n // which arrive as a rejection rather than inside a `200`. It is\n // named for the same reason a single degraded source is.\n ...(state.failed\n ? {\n unavailable: {\n message: t('commandPalette.unavailableReach', {\n reason: translateKey('errors:unexpected'),\n }),\n severity: 'reachability' as const,\n },\n }\n : {}),\n },\n ],\n };\n }\n\n const groups: CommandGroup[] = state.response.groups.map(group => ({\n key: `record:${group.source}`,\n // The entity's own `pluralKey`, so record search introduces no copy of\n // its own and a group is titled exactly as its screen is.\n label: translateKey(group.labelKey),\n options: group.items.map(item => ({\n id: `record:${group.source}:${item.id}`,\n label: item.label,\n ...(item.sublabel === undefined ? {} : { sublabel: item.sublabel }),\n href: withLocale(item.href),\n })),\n total: group.total,\n isLoading,\n }));\n\n for (const degraded of state.response.unavailable) {\n const severity = severityOf(degraded);\n groups.push({\n key: `record:${degraded.source}`,\n // Derived from the entity rather than from the source key, which is an\n // identifier and would render as `product-specification`. Every\n // searchable entity declares a `pluralKey` — `catalogSurface` throws\n // without one — so this always resolves.\n label: translateKey(`entity:${degraded.entity}.plural`),\n options: [],\n isLoading: false,\n unavailable: {\n message: t(\n severity === 'scope'\n ? 'commandPalette.unavailableScope'\n : 'commandPalette.unavailableReach',\n { reason: translateKey(`errors:${degraded.reason}`) },\n ),\n severity,\n },\n });\n }\n\n return { key: 'records', groups };\n }, [active, enabled, state, term, t, translateKey, withLocale]);\n}\n"],"names":["useLocale","useT","useTranslateKey","useEffect","useMemo","useRef","useState","useLocaleHref","searchRecords","RECORD_SEARCH_DEBOUNCE_MS","RECORD_SEARCH_MIN_TERM","SCOPE_CODES","Set","severityOf","degraded","category","has","reason","NOTHING_YET","term","failed","useRecordsSource","enabled","t","translateKey","locale","withLocale","state","setState","pending","active","length","current","controller","AbortController","timer","setTimeout","signal","then","response","catch","aborted","clearTimeout","abort","heading","key","groups","label","options","isLoading","unavailable","message","count","severity","undefined","map","group","source","labelKey","items","item","id","sublabel","href","total","push","entity"],"mappings":"AAAA;;AAQA,SAASA,SAAS,EAAEC,IAAI,EAAEC,eAAe,QAAQ,0BAA0B;AAC3E,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAE7D,SAASC,aAAa,QAAQ,mBAAmB;AAEjD,SAASC,aAAa,QAAQ,8BAA8B;AAC5D,SACEC,yBAAyB,EACzBC,sBAAsB,QACjB,uBAAuB;AAE9B;;;;;;;CAOC,GACD,MAAMC,cAAmC,IAAIC,IAAI;IAAC;CAAuB;AAEzE,MAAMC,aAAa,CAACC,WAIlBA,SAASC,QAAQ,KAAK,qBACtBD,SAASC,QAAQ,KAAK,eACtBJ,YAAYK,GAAG,CAACF,SAASG,MAAM,IAC3B,UACA;AAUN,MAAMC,cAA4B;IAAEC,MAAM;IAAIC,QAAQ;AAAM;AAE5D;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,SAASC,iBACdF,IAAY,EACZG,OAAgB;IAEhB,MAAMC,IAAItB,KAAK;IACf,MAAMuB,eAAetB;IACrB,MAAMuB,SAASzB;IACf,MAAM0B,aAAanB;IAEnB,MAAM,CAACoB,OAAOC,SAAS,GAAGtB,SAAuBY;IACjD,+EAA+E;IAC/E,yCAAyC;IACzC,MAAMW,UAAUxB,OAAsB;IAEtC,MAAMyB,SAASR,WAAWH,KAAKY,MAAM,IAAIrB;IAEzCP,UAAU;QACR,0EAA0E;QA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AS5B,EACP8B,aAAa,UACT,oCACA,mCACJ;wBAAEpC,QAAQO,aAAa,CAAC,OAAO,EAAEV,SAASG,MAAM,EAAE;oBAAE;oBAEtDoC;gBACF;YACF;QACF;QAEA,OAAO;YAAER,KAAK;YAAWC;QAAO;IAClC,GAAG;QAAChB;QAAQR;QAASK;QAAOR;QAAMI;QAAGC;QAAcE;KAAW;AAChE"}
|
package/dist/lib/crud/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC"}
|
package/dist/lib/crud/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/crud/index.ts"],"sourcesContent":["export * from './entity-crud-form.js';\nexport * from './make-entity-crud.js';\nexport * from './make-entity-crud.types.js';\nexport * from './reference-labels.js';\nexport * from './slug.js';\nexport * from './use-crud-render-link.js';\nexport * from './use-entity-affordances.js';\nexport * from './use-entity-bulk.js';\nexport * from './use-entity-link-sources.js';\n"],"names":[],"mappings":"AAAA,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,8BAA8B;AAC5C,cAAc,wBAAwB;AACtC,cAAc,YAAY;AAC1B,cAAc,4BAA4B;AAC1C,cAAc,8BAA8B;AAC5C,cAAc,uBAAuB;AACrC,cAAc,+BAA+B"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/crud/index.ts"],"sourcesContent":["export * from './entity-crud-form.js';\nexport * from './make-entity-crud.js';\nexport * from './make-entity-crud.types.js';\nexport * from './reference-labels.js';\nexport * from './slug.js';\nexport * from './use-crud-render-link.js';\nexport * from './use-entity-affordances.js';\nexport * from './use-entity-bulk.js';\nexport * from './use-entity-link-sources.js';\nexport * from './use-entity-total.js';\n"],"names":[],"mappings":"AAAA,cAAc,wBAAwB;AACtC,cAAc,wBAAwB;AACtC,cAAc,8BAA8B;AAC5C,cAAc,wBAAwB;AACtC,cAAc,YAAY;AAC1B,cAAc,4BAA4B;AAC1C,cAAc,8BAA8B;AAC5C,cAAc,uBAAuB;AACrC,cAAc,+BAA+B;AAC7C,cAAc,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-entity-crud.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/make-entity-crud.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,mBAAmB,EAKzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,iBAAiB,EAevB,MAAM,eAAe,CAAC;AAmBvB,OAAO,EAAS,OAAO,EAAgB,MAAM,QAAQ,CAAC;AAQtD,OAAO,KAAK,EAEV,UAAU,EAEV,iBAAiB,EAGlB,MAAM,6BAA6B,CAAC;AAmBrC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,SAAS,EACrC,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAE9B;AAsID,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,EAC9D,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAC7C,OAAO,EAAE,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,GAC7C,UAAU,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"make-entity-crud.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/make-entity-crud.tsx"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,mBAAmB,EAKzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIL,KAAK,MAAM,EACX,KAAK,iBAAiB,EAevB,MAAM,eAAe,CAAC;AAmBvB,OAAO,EAAS,OAAO,EAAgB,MAAM,QAAQ,CAAC;AAQtD,OAAO,KAAK,EAEV,UAAU,EAEV,iBAAiB,EAGlB,MAAM,6BAA6B,CAAC;AAmBrC;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE9C;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,SAAS,EACrC,QAAQ,EAAE,SAAS,EACnB,UAAU,EAAE,MAAM,SAAS,GAC1B,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAE9B;AAsID,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,SAAS,EAC9D,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,EAC7C,OAAO,EAAE,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,GAC7C,UAAU,CAAC,OAAO,CAAC,CAipBrB"}
|
|
@@ -359,10 +359,13 @@ export function makeEntityCrud(entityConstructor, options) {
|
|
|
359
359
|
}, regionPageSize === undefined ? {} : {
|
|
360
360
|
listPageSize: regionPageSize
|
|
361
361
|
}, {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
362
|
+
// The row's menu hands focus back to its trigger as it closes, and
|
|
363
|
+
// a verb that settles fast settles before that. Focusing on the
|
|
364
|
+
// next frame lands after the menu's restore, never under it.
|
|
365
|
+
onVerbSettled: ()=>requestAnimationFrame(()=>{
|
|
366
|
+
var _headingRef_current;
|
|
367
|
+
return (_headingRef_current = headingRef.current) == null ? void 0 : _headingRef_current.focus();
|
|
368
|
+
})
|
|
366
369
|
}))
|
|
367
370
|
]
|
|
368
371
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/crud/make-entity-crud.tsx"],"sourcesContent":["'use client';\n\nimport {\n deleteUCFactory,\n type EntityFacetCounterTag,\n EntityIdTag,\n type EntityRepositoryTag,\n EntityTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n coerceFiltering,\n describeEntityColumns,\n type EntifixFailure,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityMetadataSource,\n type EntitySelection,\n type EntityUseCaseRunner,\n type EntityWriter,\n envelopeEntityName,\n extractMetaEntity,\n type FilterGroup,\n Internal,\n isFailure,\n parseRsql,\n serializeRsql,\n settled,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport {\n EntityTable,\n useCasesForSurface,\n useFocusOnArrival,\n useRecordLabel,\n useT,\n useToasts,\n useTranslateKey,\n} from '@entifix/react-controls';\nimport {\n entityQueryScope,\n type OptimisticMutation,\n useDataLoading,\n useEntityRecord,\n useFacetCounts,\n useOptimisticMutation,\n} from '@entifix/react-integration';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { Cause, Context, Effect, Exit } from 'effect';\nimport { useParams, useRouter, useSearchParams } from 'next/navigation';\nimport { useEffect, useId, useMemo, useRef } from 'react';\n\nimport { useBreadcrumbLabel } from '../back-office/breadcrumb-labels.js';\nimport { useLocaleHref } from '../i18n/index.js';\nimport { useEntityNavHost } from '../workspace/entity-nav.js';\nimport { EntityCrudForm } from './entity-crud-form.js';\nimport type {\n AnyFilterGroup,\n EntityCrud,\n EntityCrudLinkSource,\n EntityCrudOptions,\n EntityCrudRelatedListProps,\n EntityCrudSingleViewProps,\n} from './make-entity-crud.types.js';\nimport {\n PREFILL_PARAM,\n readPrefill,\n RecordRegions,\n useRegion,\n} from './regions.js';\nimport { planRelated, useRelatedColumns } from './related-columns.js';\nimport { CATALOG_NEW_SLUG, slugToEntityId } from './slug.js';\nimport { useCrudRenderLink } from './use-crud-render-link.js';\nimport { useEntityAffordances } from './use-entity-affordances.js';\nimport { useEntityBulk } from './use-entity-bulk.js';\n\n/** What a picker defaults to reading off its target. */\nconst TARGET_NAME_PROPERTY = 'name';\n\n/** A prefilled create with no host draft store keeps nothing between visits. */\nconst ignoreDraft = () => undefined;\n\n/**\n * What the generated pages' use-cases run against: one repository adapter.\n * Exported because a hand-built screen — a wizard reading records and\n * resolving pickers — runs against exactly the same.\n */\nexport type CrudContext = EntityRepositoryTag;\n\n/**\n * One repository adapter, by its key, as the context the use-cases run\n * against.\n *\n * The cast is the price of naming adapters by key: `AdapterKey` narrows which\n * names may be *offered*, but TypeScript will not carry that narrowing through\n * an index access on a generic record.\n */\nexport function crudContextOf<TAdapters>(\n adapters: TAdapters,\n repository: keyof TAdapters,\n): Context.Context<CrudContext> {\n return adapters[repository] as Context.Context<EntityRepositoryTag>;\n}\n\n/**\n * Builds the list page and the single-record page for one entity.\n *\n * Every catalog entity used to cost ~10 files and ~300 lines whose only variable\n * was a class name: two organisms with a `.types.ts` each, two client pages, two\n * route files. The route files stay (Next needs a module per path); everything\n * between them is derived from the entity's own metadata, so a new reference\n * entity is this call plus a nav entry.\n *\n * Two things are checked here rather than at the call site, because both fail\n * silently otherwise. The catalog key must be the entity's own `@entity({ key })`\n * — they are the same string by convention, and a drifted one titles the form\n * after a different entity in a way only a reader of both catalogs would catch.\n * And a `links` entry must name a real member — a picker aimed at nothing renders\n * identically to a read-only field.\n *\n * **Serves compile-time `@entity()` classes only.** Operator reference data ships\n * with the code, so making this spec-driven would trade type safety for nothing;\n * a vendor-authored `EntitySpecification` renders through a separate path.\n */\n/**\n * A rejected write, as something the form's error slot can render.\n *\n * A typed failure is kept as it is: `useErrorMessage` translates its own code,\n * a business refusal and an outage alike. Anything else is a bug that reached\n * the screen, and is shown as `Internal` — never with its own text, which\n * nobody wrote for a user.\n */\nfunction asFailure(failure: unknown): EntifixFailure {\n return isFailure(failure) ? failure : new Internal();\n}\n\n/**\n * What a write failed with *synchronously* — before any flow took it — or\n * `undefined`. A flow's own failure is toasted by the `PendingFlowsProvider`\n * that settles it, so showing it in the error slot too would tell the operator\n * twice.\n */\nfunction syncFailure(\n mutation: OptimisticMutation<never, unknown>,\n): EntifixFailure | undefined {\n return mutation.status === 'failed' && mutation.flowId === undefined\n ? asFailure(mutation.failure)\n : undefined;\n}\n\n/**\n * A runner's verbs, looked up by the key the served `$metadata` named. A\n * single verb answers either settle mode, so it is run through the optimistic\n * API; a bulk run reports per row and is awaited as a promise whose rejection\n * carries the failure itself.\n */\nfunction verbsOf(\n runner: EntityUseCaseRunner | undefined,\n served: readonly UseCaseDescriptor[] | undefined,\n) {\n if (runner === undefined) return undefined;\n // The key always comes from the served document, so it names a verb in it.\n const descriptor = (key: string) =>\n served?.find(candidate => candidate.key === key) as UseCaseDescriptor;\n return {\n run: (key: string, id: EntityId) => runner.run(descriptor(key), id),\n bulk: (key: string, selection: EntitySelection<Entity>) =>\n Effect.runPromiseExit(runner.bulk(descriptor(key), selection)).then(\n exit =>\n Exit.isSuccess(exit)\n ? exit.value\n : Promise.reject(Cause.squash(exit.cause)),\n ),\n };\n}\n\ntype Verbs = NonNullable<ReturnType<typeof verbsOf>>;\n\n/**\n * One verb on one record, through the optimistic API: `done` runs once the\n * verb took effect — at once when it settled, or when the flow it was handed\n * to completed.\n */\nfunction useVerb(verbs: Verbs | undefined, done: () => void) {\n const verb = useOptimisticMutation<\n { readonly key: string; readonly id: EntityId },\n unknown\n >({\n // Only ever sent from a handler that exists because `verbs` does.\n write: ({ key, id }) => (verbs as Verbs).run(key, id),\n confirm: done,\n });\n const run = (key: string, id: EntityId) => {\n void verb.mutate({ key, id }).then(\n result => {\n if (result._tag === 'settled') done();\n },\n // Shown through `syncFailure`, from the mutation's own state.\n () => undefined,\n );\n };\n return { verb, run };\n}\n\n/** Whether the component is still mounted: a flow can settle after it left. */\nfunction useMounted() {\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n return mounted;\n}\n\n/**\n * Runs each link's `useBaseFiltering` against the record being edited, in link\n * order, with `undefined` for a link that declares none.\n *\n * Legal for the reason `useEntityLinkSources` gives: the links are a\n * factory-time array, and whether a link carries a rule is fixed with it, so\n * the same hooks run in the same order on every render. The lint rule cannot\n * see a hook called through a member, so there is nothing for it to flag.\n */\nfunction useLinkFilters<TEntity extends Entity>(\n links: readonly {\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n }[],\n record: TEntity | undefined,\n): (AnyFilterGroup | undefined)[] {\n return links.map(link => link.useBaseFiltering?.(record));\n}\n\nexport function makeEntityCrud<TEntity extends Entity, TAdapters>(\n entityConstructor: EntityConstructor<TEntity>,\n options: EntityCrudOptions<TAdapters, TEntity>,\n): EntityCrud<TEntity> {\n const {\n useAdapters,\n basePath,\n catalogKey,\n repository,\n hiddenFields = [],\n columns,\n toolbar,\n pageSize,\n initialFiltering,\n links = [],\n related = [],\n regions,\n metadataSource: givenMetadataSource,\n metadata,\n useCases,\n write,\n delete: deletePolicy = 'confirm',\n facets,\n } = options;\n\n if (givenMetadataSource !== undefined && metadata !== undefined) {\n throw new Error(\n `${entityConstructor.name} was given both metadataSource and metadata; pass one`,\n );\n }\n // An adapter value, so it is resolved per render from the same `useAdapters()`\n // the records come from — the host's composition, never the caller's module.\n const metadataSourceOf = (adapters: TAdapters) =>\n metadata === undefined\n ? givenMetadataSource\n : (adapters[metadata] as EntityMetadataSource);\n\n // Through the service's own trust boundary rather than a second walk of the\n // tree: serialized the way a load request carries it, then coerced against\n // the entity's `filterable` allowlist exactly as a service coerces a query.\n // Whatever would answer `400` on the wire throws here instead, when the\n // screen is generated, naming the member.\n // An emptied group serializes to nothing and filters nothing, so there is\n // nothing to check.\n const initialRsql =\n initialFiltering === undefined ? '' : serializeRsql([initialFiltering]);\n if (initialRsql !== '') {\n coerceFiltering(entityConstructor, parseRsql(initialRsql));\n }\n\n const meta = extractMetaEntity(entityConstructor);\n if (meta.key !== catalogKey) {\n throw new Error(\n `${entityConstructor.name} declares key \"${String(meta.key)}\" but was given catalog key \"${catalogKey}\"`,\n );\n }\n // Read off `@entity()` rather than rebuilt from `catalogKey`. Both spellings\n // produce the same string today, and that is exactly the problem: a second\n // place that knows how an entity's catalog subtree is laid out is a second\n // place to fix when one moves. `MetaEntityOptions` makes them optional, so an\n // entity that never declared them fails here — where a screen is generated —\n // rather than on the render that first tries to title a tab with `undefined`.\n const { labelKey: entityLabelKey, pluralKey: entityPluralKey } = meta;\n if (entityLabelKey === undefined || entityPluralKey === undefined) {\n throw new Error(\n `${entityConstructor.name} must declare labelKey and pluralKey on @entity() to be generated`,\n );\n }\n // Narrowed once, for the closures below that TypeScript cannot follow.\n const pluralKey: string = entityPluralKey;\n\n // Computed once: a descriptor is a property of the class, so nothing about it\n // depends on the record being edited. `linkLabelProperty`/`linkSearchProperty`\n // are overridden here because a scalar foreign key's `@accessor()` cannot name\n // the target's members — it may not import the target at all.\n // The wire name, which is also what a pending flow's intent records and what\n // `entityQueryScopeFor` keys on — one derivation, so the two can never\n // disagree about which entity they mean.\n const entityName = envelopeEntityName(entityConstructor);\n const descriptors = describeEntityColumns(entityConstructor);\n /** The members a filter panel offers choices for, and so counts. */\n const facetMembers = descriptors\n .filter(\n descriptor =>\n descriptor.filterable &&\n (descriptor.type === 'enum' || descriptor.type === 'boolean'),\n )\n .map(({ name, key }) => ({ name, key }));\n const relatedPlans = planRelated(\n entityConstructor as EntityConstructor<Entity>,\n descriptors,\n related,\n );\n const linkPlans = links.map(link => {\n const descriptor = descriptors.find(entry => entry.name === link.field);\n if (descriptor === undefined) {\n throw new Error(\n `${entityConstructor.name} has no member \"${link.field}\" for a link source`,\n );\n }\n return {\n ...link,\n descriptor: {\n ...descriptor,\n linkLabelProperty: link.labelProperty ?? TARGET_NAME_PROPERTY,\n linkSearchProperty: link.searchProperty ?? TARGET_NAME_PROPERTY,\n },\n };\n });\n\n /**\n * The generated list itself — the table, its reads, its verbs — shared by the\n * list page and by a related region on another record's page. A region holds\n * it to a fixed filter that is not a removable chip and keeps its pager in\n * component state, never in the URL.\n */\n function ListBody({\n baseFiltering,\n newHref: givenNewHref,\n listPageSize = pageSize,\n listInitialFiltering,\n onVerbSettled,\n }: {\n baseFiltering?: FilterGroup<TEntity>;\n newHref?: string;\n listPageSize?: number;\n listInitialFiltering?: FilterGroup<TEntity>;\n onVerbSettled?: () => void;\n }) {\n const adapters = useAdapters();\n // Every internal href carries the locale. An unprefixed one still resolves —\n // the middleware redirects it — but the visitor pays a round trip per click.\n const withLocale = useLocaleHref();\n\n const queryClient = useQueryClient();\n const scope = entityQueryScope(entityConstructor);\n const metadataSource = metadataSourceOf(adapters);\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const renderLink = useCrudRenderLink(catalogKey);\n\n const pager = useDataLoading<TEntity, CrudContext>({\n uc: loadUCFactory<TEntity>(),\n ctx: crudContextOf(adapters, repository),\n // Scoped rather than left to the per-instance fallback, which is correct\n // but unshared: with the entity's own scope one invalidation refreshes\n // every page and filter of it, which is what a bulk run needs — and it is\n // the same prefix `useReactiveInvalidation`already targets, so a generated\n // list now also refreshes on a reactive change event.\n queryKey: scope,\n ...(listPageSize === undefined ? {} : { initialPageSize: listPageSize }),\n ...(listInitialFiltering === undefined\n ? {}\n : { initialFiltering: listInitialFiltering }),\n ...(baseFiltering === undefined ? {} : { baseFiltering }),\n });\n\n // Values that live in another entity, one read per column per page.\n const relatedColumns = useRelatedColumns<TAdapters, TEntity>(\n relatedPlans,\n pager.items,\n plan => crudContextOf(adapters, plan.repository),\n );\n\n const facetCounts = useFacetCounts<TEntity>({\n ctx:\n facets === undefined\n ? undefined\n : (adapters[facets] as Context.Context<EntityFacetCounterTag>),\n members: facetMembers,\n filtering: pager.filtering,\n scope,\n });\n\n // Only when this caller may actually run something over a selection.\n //\n // Measured live: an `admin` holds `catalog-reference:*:read` and no\n // `retire`, so the service filters the verb out of `$metadata` — but the\n // selection column still rendered, offering a set that no action could be\n // taken on. A checkbox that can lead nowhere is worse than no checkbox: it\n // reads as a permission the user does not have.\n //\n // Decided from the served document rather than from the runner, because\n // the runner is a property of the *shell* (it knows the route) and the\n // grant is a property of the *caller*. The column therefore appears when\n // the document lands, which is the asynchrony serving affordances accepts\n // for every action surface.\n const canRunBulk =\n useCasesForSurface('bulk-bar', affordances.metadata?.useCases).length > 0;\n\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n\n const bulk = useEntityBulk<TEntity>({\n run:\n canRunBulk && verbs !== undefined\n ? (key, selection) =>\n verbs.bulk(key, selection as EntitySelection<Entity>)\n : undefined,\n // A bulk write changed the rows underneath the listing, so the page is\n // re-read; the selection deliberately survives it (\"the selection\n // is still there afterwards\"), because the operator's next act is usually\n // to retry the failures or run a second verb on the same rows.\n onCompleted: () => {\n void queryClient.invalidateQueries({ queryKey: scope });\n },\n });\n\n // What a row's overflow menu runs, and the one place the list reports a\n // verb that failed.\n //\n // ⚠️ **A row verb and the form's are the same runner with different\n // arguments.** `EntityTable` hands back the whole record, because that is\n // what it has; the runner takes an id, because that is what a route needs.\n // The list has no error slot of its own, so a failure lands in the\n // table's own error region — the same one a failed page read uses.\n const rowVerb = useVerb(verbs, () => {\n void queryClient.invalidateQueries({ queryKey: scope });\n onVerbSettled?.();\n });\n // Called unconditionally and the *result* gated, the way the surfaces are\n // read in `EntityForm`: the name begins with `use`, so short-circuiting it\n // reads to `react-hooks/rules-of-hooks` as a conditional hook.\n const rowUseCases = useCasesForSurface(\n 'row-menu',\n affordances.metadata?.useCases,\n );\n const canRunRowUseCase = verbs !== undefined && rowUseCases.length > 0;\n\n const handleRowUseCase = canRunRowUseCase\n ? (key: string, item: TEntity) => {\n if (item.id == null) return;\n rowVerb.run(key, item.id);\n }\n : undefined;\n\n return (\n <EntityTable\n entityConstructor={entityConstructor}\n {...pager}\n items={pager.items}\n totalItems={pager.totalItems}\n hrefFor={id => withLocale(`${basePath}/${String(id)}`)}\n newHref={withLocale(givenNewHref ?? `${basePath}/${CATALOG_NEW_SLUG}`)}\n renderLink={renderLink}\n {...affordances}\n {...bulk.tableProps}\n onUseCase={handleRowUseCase}\n onRetry={pager.refetch}\n facets={facetCounts}\n error={syncFailure(rowVerb.verb) ?? pager.error}\n >\n {columns}\n {relatedColumns}\n {/* After the host's own: a host column for the same member wins. */}\n {toolbar}\n </EntityTable>\n );\n }\n\n function ListPage() {\n // The list's heading, and where focus lands when a save or a delete\n // brings the reader back here rather than falling to `<body>`.\n const heading = useRef<HTMLHeadingElement>(null);\n useFocusOnArrival(heading);\n const et = useT('entity');\n\n return (\n <div className=\"flex flex-col gap-s\">\n <h1\n ref={heading}\n tabIndex={-1}\n className=\"m-0 text-step-2 font-semibold text-content focus-ring\"\n >\n {et(pluralKey.replace(/^entity:/, ''))}\n </h1>\n <ListBody\n {...(initialFiltering === undefined\n ? {}\n : { listInitialFiltering: initialFiltering })}\n />\n </div>\n );\n }\n\n /**\n * This entity's records that refer to another record, as a region of that\n * record's page\n * ([ADR 0030](../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):\n * the generated list held to `filtering`, which is fixed and shown as no\n * chip, under its own `h2`, with its own states and its own writes. A verb\n * that settles inside it moves focus to that heading; nothing else on the\n * page is re-read or touched. `prefill` names the members a \"New\" from here\n * opens already set — the parent record's id.\n */\n function RelatedList({\n filtering,\n labelKey: headingKey,\n prefill,\n newHref,\n pageSize: regionPageSize,\n }: EntityCrudRelatedListProps<TEntity>) {\n const headingRef = useRef<HTMLHeadingElement>(null);\n const id = useId();\n const heading = useTranslateKey()(headingKey);\n useRegion(id, heading);\n const query = new URLSearchParams(\n Object.entries(prefill ?? {}).map(([member, value]): [string, string] => [\n `${PREFILL_PARAM}${member}`,\n value,\n ]),\n ).toString();\n return (\n <section\n id={id}\n aria-labelledby={`${id}-heading`}\n className=\"flex flex-col gap-s\"\n >\n <h2\n id={`${id}-heading`}\n ref={headingRef}\n tabIndex={-1}\n className=\"m-0 text-step-1 font-semibold text-content focus-ring\"\n >\n {heading}\n </h2>\n <ListBody\n baseFiltering={filtering}\n newHref={\n newHref ??\n `${basePath}/${CATALOG_NEW_SLUG}${query === '' ? '' : `?${query}`}`\n }\n {...(regionPageSize === undefined\n ? {}\n : { listPageSize: regionPageSize })}\n onVerbSettled={() => headingRef.current?.focus()}\n />\n </section>\n );\n }\n\n /**\n * Dual-host: as a route it reads its slug from the URL and returns to the list\n * on save; in a workspace tab it takes the slug and the post-save action as\n * props.\n */\n function SingleViewPage({\n slug,\n onSaved,\n onDeleted,\n draft,\n }: EntityCrudSingleViewProps = {}) {\n const adapters = useAdapters();\n const metadataSource = metadataSourceOf(adapters);\n // The same served document the form reads its buttons from, so a key the\n // form hands back always names a verb in it.\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const router = useRouter();\n const withLocale = useLocaleHref();\n const params = useParams<{ slug: string }>();\n const mounted = useMounted();\n const id = slugToEntityId(slug ?? params.slug);\n\n // A create opened from a related region starts with the parent record set:\n // `?prefill.<member>=<value>`, layered under any draft the host restores.\n const searchParams = useSearchParams();\n const prefill =\n id == null ? readPrefill(searchParams, descriptors) : undefined;\n const prefillKey = prefill === undefined ? '' : JSON.stringify(prefill);\n const formDraft = useMemo(\n () =>\n prefill === undefined\n ? draft\n : {\n draft: { ...prefill, ...draft?.draft },\n save: draft?.save ?? ignoreDraft,\n clear: draft?.clear ?? ignoreDraft,\n },\n // Keyed on the values, not the object a render builds them into.\n [draft, prefillKey],\n );\n\n const ctx = crudContextOf(adapters, repository);\n\n const {\n entity,\n isLoading,\n error: loadError,\n reload,\n } = useEntityRecord<TEntity, CrudContext>({\n uc: getUCFactory<TEntity>(),\n ctx,\n id,\n });\n\n // Against the record as loaded, not the draft: the rule is about which\n // record this is, not what the operator has typed into it.\n const linkFilters = useLinkFilters(linkPlans, entity);\n\n // Rebuilt inline on every render on purpose: `useEntityLinkSource` holds\n // these in a ref and keeps them out of its query keys, precisely so a caller\n // does not have to memoise them.\n const linkSources: EntityCrudLinkSource[] = linkPlans.map(\n (plan, index) => ({\n field: plan.field,\n descriptor: plan.descriptor,\n config: {\n entityConstructor: plan.entityConstructor,\n loadUc: loadUCFactory(),\n getUc: getUCFactory(),\n ctx: crudContextOf(adapters, plan.repository),\n // The config's target is erased to `Entity`, and the host's filter to\n // `any`; the two meet here, where neither type is the real target's.\n baseFiltering: linkFilters[index] as FilterGroup<Entity> | undefined,\n },\n }),\n );\n\n // Inside a workspace tab, \"back to the list\" is the list's tab, not a URL\n // that would leave the workspace. A host's own callbacks still win.\n const host = useEntityNavHost();\n const renderLink = useCrudRenderLink(catalogKey);\n const queryClient = useQueryClient();\n // The list this page returns to has its page cached, and it is no longer\n // true. Invalidated rather than patched: the service is the authority on\n // the row it stored.\n //\n // ⚠️ Invisible while every Open was a document load, which threw the cache\n // away anyway (#20): the first client-side navigation back to the list\n // showed the record as it was before the save.\n const refreshList = () =>\n queryClient.invalidateQueries({\n queryKey: entityQueryScope(entityConstructor),\n });\n const toList = () =>\n host === undefined\n ? router.push(withLocale(basePath))\n : host.toList(catalogKey);\n const afterSave = onSaved ?? toList;\n const afterDelete = onDeleted ?? toList;\n\n // Through the host's writer when it named one, which answers both settle\n // modes; otherwise through the repository, where every write settles.\n const writer =\n write === undefined ? undefined : (adapters[write] as EntityWriter);\n\n // The draft is spent once the write *commits*, and only here is that known:\n // `useEntityForm` neither fetches nor saves, so it cannot clear its own.\n // A failed write — or a failed flow — deliberately keeps the draft and the\n // form: the edit is still the user's only copy of what they typed.\n //\n // ⚠️ A flow can complete after the operator left this page, so leaving it\n // is guarded on still being here: a navigation from a form nobody is\n // looking at would pull them away from wherever they went.\n const saveMutation = useOptimisticMutation<TEntity, TEntity>({\n write: next =>\n writer === undefined\n ? Effect.map(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, next)),\n ),\n settled,\n )\n : writer.save(next),\n intent: () => ({ entity: entityName, write: 'save' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterSave();\n },\n });\n const deleteMutation = useOptimisticMutation<EntityId, void>({\n write: target =>\n writer === undefined\n ? Effect.as(\n Effect.provide(\n deleteUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityIdTag, target)),\n ),\n settled(undefined),\n )\n : writer.delete(target),\n intent: () => ({ entity: entityName, write: 'delete' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterDelete();\n },\n });\n\n const handleSave = async (next: TEntity) => {\n const result = await saveMutation.mutate(next).catch(() => undefined);\n // Failed, or pending: the form stays, and the mutation says which. A\n // pending write leaves through the mutation's `confirm`, once its flow\n // completed.\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said in the toast region every route shares, so it survives the\n // navigation that follows (ADR 0028).\n toasts?.show({\n tone: 'success',\n message: ct('state.saved', {\n object: recordNoun(next),\n }),\n });\n afterSave();\n };\n\n const toasts = useToasts();\n const ct = useT('controls');\n const nameOf = useRecordLabel();\n /**\n * What an announcement names: the record, through the one derivation every\n * surface shares, or the entity for one not loaded.\n */\n const recordNoun = (record: TEntity | undefined) =>\n nameOf(entityConstructor, record);\n // The breadcrumb for this page's segment names the record, never its id:\n // \"Nuevo\" for a create, the record once it has loaded.\n useBreadcrumbLabel(\n slug ?? params.slug,\n id == null ? ct('form.new') : entity && recordNoun(entity),\n );\n /**\n * Saves a deleted record back under its id: what Undo runs under the\n * `undo` policy.\n */\n const restore = (record: TEntity) =>\n Effect.runPromise(\n writer === undefined\n ? Effect.asVoid(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, record)),\n ),\n )\n : Effect.asVoid(writer.save(record)),\n ).then(\n () => refreshList(),\n (failure: unknown) => {\n toasts?.show({ tone: 'failure', failure: asFailure(failure) });\n },\n );\n\n const handleDelete = async () => {\n const snapshot = entity;\n const result = await deleteMutation.mutate(id).catch(() => undefined);\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said once, in the toast region every route shares, so it survives the\n // navigation back to the list.\n const object = recordNoun(snapshot);\n const message = ct('confirm.deleted', { object });\n if (deletePolicy === 'undo' && snapshot !== undefined)\n toasts?.show({\n tone: 'undo',\n message,\n action: {\n label: ct('confirm.undo'),\n onAction: () => void restore(snapshot),\n },\n });\n else toasts?.show({ tone: 'success', message });\n afterDelete();\n };\n\n /**\n * An `entity`-bound verb, on the record being shown.\n *\n * It **reloads** — once the verb took effect, which for one the server\n * handed to a flow is when the flow completed — rather than patching what it has: the service decides the\n * resulting state — a `publish` may land on `published` from four different\n * places — and a client that assumed the new value would show the wrong one\n * the first time the rule changed. `id == null` means the create form,\n * where there is no record to act on and the form renders no verbs anyway.\n *\n * ⚠️ The rejection is **caught and shown**, never left to the promise.\n * `EntityForm`'s `onUseCase` returns `void`, so an uncaught rejection here\n * reaches the console and nothing else — measured on an offering refusing\n * `unpublish` from `draft`: the service answered `409` with a coded body,\n * the record correctly did not move, and the operator saw a button that\n * appeared to do nothing at all.\n */\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n const recordVerb = useVerb(verbs, () => void reload());\n const handleUseCase =\n verbs === undefined || id == null\n ? undefined\n : (key: string) => recordVerb.run(key, id);\n\n const form = (\n <EntityCrudForm<TEntity>\n // Remounts (and reseeds the fields) once the record arrives.\n key={String(entity?.id ?? CATALOG_NEW_SLUG)}\n entityConstructor={entityConstructor}\n catalogKey={catalogKey}\n metadataSource={metadataSource}\n hiddenFields={hiddenFields}\n links={linkSources}\n entity={entity}\n isLoading={isLoading}\n isSaving={saveMutation.status === 'running'}\n isPending={[saveMutation, deleteMutation, recordVerb.verb].some(\n mutation => mutation.status === 'pending',\n )}\n isDeleting={deleteMutation.status === 'running'}\n error={\n loadError ??\n syncFailure(saveMutation) ??\n syncFailure(deleteMutation) ??\n syncFailure(recordVerb.verb)\n }\n onSave={handleSave}\n onRetry={loadError === undefined ? undefined : reload}\n onDelete={id == null ? undefined : handleDelete}\n deletePolicy={deletePolicy}\n onUseCase={handleUseCase}\n backHref={withLocale(basePath)}\n renderLink={renderLink}\n draft={formDraft}\n />\n );\n // The records that refer to this one, under its form: an existing record\n // only, since a record being created has nothing referring to it yet.\n if (regions === undefined || id == null || entity === undefined)\n return form;\n return (\n <div className=\"flex flex-col gap-l\">\n {form}\n <RecordRegions>{regions(entity)}</RecordRegions>\n </div>\n );\n }\n\n return {\n entityConstructor,\n entityKey: catalogKey,\n entityLabelKey,\n entityPluralKey,\n basePath,\n ListPage,\n SingleViewPage,\n RelatedList,\n };\n}\n"],"names":["deleteUCFactory","EntityIdTag","EntityTag","getUCFactory","loadUCFactory","saveUCFactory","coerceFiltering","describeEntityColumns","envelopeEntityName","extractMetaEntity","Internal","isFailure","parseRsql","serializeRsql","settled","EntityTable","useCasesForSurface","useFocusOnArrival","useRecordLabel","useT","useToasts","useTranslateKey","entityQueryScope","useDataLoading","useEntityRecord","useFacetCounts","useOptimisticMutation","useQueryClient","Cause","Context","Effect","Exit","useParams","useRouter","useSearchParams","useEffect","useId","useMemo","useRef","useBreadcrumbLabel","useLocaleHref","useEntityNavHost","EntityCrudForm","PREFILL_PARAM","readPrefill","RecordRegions","useRegion","planRelated","useRelatedColumns","CATALOG_NEW_SLUG","slugToEntityId","useCrudRenderLink","useEntityAffordances","useEntityBulk","TARGET_NAME_PROPERTY","ignoreDraft","undefined","crudContextOf","adapters","repository","asFailure","failure","syncFailure","mutation","status","flowId","verbsOf","runner","served","descriptor","key","find","candidate","run","id","bulk","selection","runPromiseExit","then","exit","isSuccess","value","Promise","reject","squash","cause","useVerb","verbs","done","verb","write","confirm","mutate","result","_tag","useMounted","mounted","current","useLinkFilters","links","record","map","link","useBaseFiltering","makeEntityCrud","entityConstructor","options","useAdapters","basePath","catalogKey","hiddenFields","columns","toolbar","pageSize","initialFiltering","related","regions","metadataSource","givenMetadataSource","metadata","useCases","delete","deletePolicy","facets","Error","name","metadataSourceOf","initialRsql","meta","String","labelKey","entityLabelKey","pluralKey","entityPluralKey","entityName","descriptors","facetMembers","filter","filterable","type","relatedPlans","linkPlans","entry","field","linkLabelProperty","labelProperty","linkSearchProperty","searchProperty","ListBody","baseFiltering","newHref","givenNewHref","listPageSize","listInitialFiltering","onVerbSettled","affordances","withLocale","queryClient","scope","renderLink","pager","uc","ctx","queryKey","initialPageSize","relatedColumns","items","plan","facetCounts","members","filtering","canRunBulk","length","onCompleted","invalidateQueries","rowVerb","rowUseCases","canRunRowUseCase","handleRowUseCase","item","totalItems","hrefFor","tableProps","onUseCase","onRetry","refetch","error","ListPage","heading","et","div","className","h1","ref","tabIndex","replace","RelatedList","headingKey","prefill","regionPageSize","headingRef","query","URLSearchParams","Object","entries","member","toString","section","aria-labelledby","h2","focus","SingleViewPage","slug","onSaved","onDeleted","draft","loadError","router","params","searchParams","prefillKey","JSON","stringify","formDraft","save","clear","entity","isLoading","reload","linkFilters","linkSources","index","config","loadUc","getUc","host","refreshList","toList","push","afterSave","afterDelete","writer","saveMutation","next","provide","pipe","add","intent","deleteMutation","target","as","handleSave","catch","toasts","show","tone","message","ct","object","recordNoun","nameOf","restore","runPromise","asVoid","handleDelete","snapshot","action","label","onAction","recordVerb","handleUseCase","form","isSaving","isPending","some","isDeleting","onSave","onDelete","backHref","entityKey"],"mappings":"AAAA;;;AAEA,SACEA,eAAe,EAEfC,WAAW,EAEXC,SAAS,EACTC,YAAY,EAC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F,gBAAOiG,0BAAAA,OAAQxJ,EAAE,oBAAIzB;QA6B9B,yEAAyE;QACzE,sEAAsE;QACtE,IAAImE,YAAY5D,aAAakB,MAAM,QAAQwJ,WAAW1K,WACpD,OAAOuN;QACT,qBACE,MAACjF;YAAIC,WAAU;;gBACZgF;8BACD,KAAClO;8BAAeuE,QAAQ8G;;;;IAG9B;IAEA,OAAO;QACLzH;QACA8K,WAAW1K;QACXsB;QACAE;QACAzB;QACA+E;QACAwB;QACAf;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/crud/make-entity-crud.tsx"],"sourcesContent":["'use client';\n\nimport {\n deleteUCFactory,\n type EntityFacetCounterTag,\n EntityIdTag,\n type EntityRepositoryTag,\n EntityTag,\n getUCFactory,\n loadUCFactory,\n saveUCFactory,\n} from '@entifix/business';\nimport {\n coerceFiltering,\n describeEntityColumns,\n type EntifixFailure,\n type Entity,\n type EntityConstructor,\n type EntityId,\n type EntityMetadataSource,\n type EntitySelection,\n type EntityUseCaseRunner,\n type EntityWriter,\n envelopeEntityName,\n extractMetaEntity,\n type FilterGroup,\n Internal,\n isFailure,\n parseRsql,\n serializeRsql,\n settled,\n type UseCaseDescriptor,\n} from '@entifix/core';\nimport {\n EntityTable,\n useCasesForSurface,\n useFocusOnArrival,\n useRecordLabel,\n useT,\n useToasts,\n useTranslateKey,\n} from '@entifix/react-controls';\nimport {\n entityQueryScope,\n type OptimisticMutation,\n useDataLoading,\n useEntityRecord,\n useFacetCounts,\n useOptimisticMutation,\n} from '@entifix/react-integration';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { Cause, Context, Effect, Exit } from 'effect';\nimport { useParams, useRouter, useSearchParams } from 'next/navigation';\nimport { useEffect, useId, useMemo, useRef } from 'react';\n\nimport { useBreadcrumbLabel } from '../back-office/breadcrumb-labels.js';\nimport { useLocaleHref } from '../i18n/index.js';\nimport { useEntityNavHost } from '../workspace/entity-nav.js';\nimport { EntityCrudForm } from './entity-crud-form.js';\nimport type {\n AnyFilterGroup,\n EntityCrud,\n EntityCrudLinkSource,\n EntityCrudOptions,\n EntityCrudRelatedListProps,\n EntityCrudSingleViewProps,\n} from './make-entity-crud.types.js';\nimport {\n PREFILL_PARAM,\n readPrefill,\n RecordRegions,\n useRegion,\n} from './regions.js';\nimport { planRelated, useRelatedColumns } from './related-columns.js';\nimport { CATALOG_NEW_SLUG, slugToEntityId } from './slug.js';\nimport { useCrudRenderLink } from './use-crud-render-link.js';\nimport { useEntityAffordances } from './use-entity-affordances.js';\nimport { useEntityBulk } from './use-entity-bulk.js';\n\n/** What a picker defaults to reading off its target. */\nconst TARGET_NAME_PROPERTY = 'name';\n\n/** A prefilled create with no host draft store keeps nothing between visits. */\nconst ignoreDraft = () => undefined;\n\n/**\n * What the generated pages' use-cases run against: one repository adapter.\n * Exported because a hand-built screen — a wizard reading records and\n * resolving pickers — runs against exactly the same.\n */\nexport type CrudContext = EntityRepositoryTag;\n\n/**\n * One repository adapter, by its key, as the context the use-cases run\n * against.\n *\n * The cast is the price of naming adapters by key: `AdapterKey` narrows which\n * names may be *offered*, but TypeScript will not carry that narrowing through\n * an index access on a generic record.\n */\nexport function crudContextOf<TAdapters>(\n adapters: TAdapters,\n repository: keyof TAdapters,\n): Context.Context<CrudContext> {\n return adapters[repository] as Context.Context<EntityRepositoryTag>;\n}\n\n/**\n * Builds the list page and the single-record page for one entity.\n *\n * Every catalog entity used to cost ~10 files and ~300 lines whose only variable\n * was a class name: two organisms with a `.types.ts` each, two client pages, two\n * route files. The route files stay (Next needs a module per path); everything\n * between them is derived from the entity's own metadata, so a new reference\n * entity is this call plus a nav entry.\n *\n * Two things are checked here rather than at the call site, because both fail\n * silently otherwise. The catalog key must be the entity's own `@entity({ key })`\n * — they are the same string by convention, and a drifted one titles the form\n * after a different entity in a way only a reader of both catalogs would catch.\n * And a `links` entry must name a real member — a picker aimed at nothing renders\n * identically to a read-only field.\n *\n * **Serves compile-time `@entity()` classes only.** Operator reference data ships\n * with the code, so making this spec-driven would trade type safety for nothing;\n * a vendor-authored `EntitySpecification` renders through a separate path.\n */\n/**\n * A rejected write, as something the form's error slot can render.\n *\n * A typed failure is kept as it is: `useErrorMessage` translates its own code,\n * a business refusal and an outage alike. Anything else is a bug that reached\n * the screen, and is shown as `Internal` — never with its own text, which\n * nobody wrote for a user.\n */\nfunction asFailure(failure: unknown): EntifixFailure {\n return isFailure(failure) ? failure : new Internal();\n}\n\n/**\n * What a write failed with *synchronously* — before any flow took it — or\n * `undefined`. A flow's own failure is toasted by the `PendingFlowsProvider`\n * that settles it, so showing it in the error slot too would tell the operator\n * twice.\n */\nfunction syncFailure(\n mutation: OptimisticMutation<never, unknown>,\n): EntifixFailure | undefined {\n return mutation.status === 'failed' && mutation.flowId === undefined\n ? asFailure(mutation.failure)\n : undefined;\n}\n\n/**\n * A runner's verbs, looked up by the key the served `$metadata` named. A\n * single verb answers either settle mode, so it is run through the optimistic\n * API; a bulk run reports per row and is awaited as a promise whose rejection\n * carries the failure itself.\n */\nfunction verbsOf(\n runner: EntityUseCaseRunner | undefined,\n served: readonly UseCaseDescriptor[] | undefined,\n) {\n if (runner === undefined) return undefined;\n // The key always comes from the served document, so it names a verb in it.\n const descriptor = (key: string) =>\n served?.find(candidate => candidate.key === key) as UseCaseDescriptor;\n return {\n run: (key: string, id: EntityId) => runner.run(descriptor(key), id),\n bulk: (key: string, selection: EntitySelection<Entity>) =>\n Effect.runPromiseExit(runner.bulk(descriptor(key), selection)).then(\n exit =>\n Exit.isSuccess(exit)\n ? exit.value\n : Promise.reject(Cause.squash(exit.cause)),\n ),\n };\n}\n\ntype Verbs = NonNullable<ReturnType<typeof verbsOf>>;\n\n/**\n * One verb on one record, through the optimistic API: `done` runs once the\n * verb took effect — at once when it settled, or when the flow it was handed\n * to completed.\n */\nfunction useVerb(verbs: Verbs | undefined, done: () => void) {\n const verb = useOptimisticMutation<\n { readonly key: string; readonly id: EntityId },\n unknown\n >({\n // Only ever sent from a handler that exists because `verbs` does.\n write: ({ key, id }) => (verbs as Verbs).run(key, id),\n confirm: done,\n });\n const run = (key: string, id: EntityId) => {\n void verb.mutate({ key, id }).then(\n result => {\n if (result._tag === 'settled') done();\n },\n // Shown through `syncFailure`, from the mutation's own state.\n () => undefined,\n );\n };\n return { verb, run };\n}\n\n/** Whether the component is still mounted: a flow can settle after it left. */\nfunction useMounted() {\n const mounted = useRef(true);\n useEffect(() => {\n mounted.current = true;\n return () => {\n mounted.current = false;\n };\n }, []);\n return mounted;\n}\n\n/**\n * Runs each link's `useBaseFiltering` against the record being edited, in link\n * order, with `undefined` for a link that declares none.\n *\n * Legal for the reason `useEntityLinkSources` gives: the links are a\n * factory-time array, and whether a link carries a rule is fixed with it, so\n * the same hooks run in the same order on every render. The lint rule cannot\n * see a hook called through a member, so there is nothing for it to flag.\n */\nfunction useLinkFilters<TEntity extends Entity>(\n links: readonly {\n readonly useBaseFiltering?: (\n record: TEntity | undefined,\n ) => AnyFilterGroup | undefined;\n }[],\n record: TEntity | undefined,\n): (AnyFilterGroup | undefined)[] {\n return links.map(link => link.useBaseFiltering?.(record));\n}\n\nexport function makeEntityCrud<TEntity extends Entity, TAdapters>(\n entityConstructor: EntityConstructor<TEntity>,\n options: EntityCrudOptions<TAdapters, TEntity>,\n): EntityCrud<TEntity> {\n const {\n useAdapters,\n basePath,\n catalogKey,\n repository,\n hiddenFields = [],\n columns,\n toolbar,\n pageSize,\n initialFiltering,\n links = [],\n related = [],\n regions,\n metadataSource: givenMetadataSource,\n metadata,\n useCases,\n write,\n delete: deletePolicy = 'confirm',\n facets,\n } = options;\n\n if (givenMetadataSource !== undefined && metadata !== undefined) {\n throw new Error(\n `${entityConstructor.name} was given both metadataSource and metadata; pass one`,\n );\n }\n // An adapter value, so it is resolved per render from the same `useAdapters()`\n // the records come from — the host's composition, never the caller's module.\n const metadataSourceOf = (adapters: TAdapters) =>\n metadata === undefined\n ? givenMetadataSource\n : (adapters[metadata] as EntityMetadataSource);\n\n // Through the service's own trust boundary rather than a second walk of the\n // tree: serialized the way a load request carries it, then coerced against\n // the entity's `filterable` allowlist exactly as a service coerces a query.\n // Whatever would answer `400` on the wire throws here instead, when the\n // screen is generated, naming the member.\n // An emptied group serializes to nothing and filters nothing, so there is\n // nothing to check.\n const initialRsql =\n initialFiltering === undefined ? '' : serializeRsql([initialFiltering]);\n if (initialRsql !== '') {\n coerceFiltering(entityConstructor, parseRsql(initialRsql));\n }\n\n const meta = extractMetaEntity(entityConstructor);\n if (meta.key !== catalogKey) {\n throw new Error(\n `${entityConstructor.name} declares key \"${String(meta.key)}\" but was given catalog key \"${catalogKey}\"`,\n );\n }\n // Read off `@entity()` rather than rebuilt from `catalogKey`. Both spellings\n // produce the same string today, and that is exactly the problem: a second\n // place that knows how an entity's catalog subtree is laid out is a second\n // place to fix when one moves. `MetaEntityOptions` makes them optional, so an\n // entity that never declared them fails here — where a screen is generated —\n // rather than on the render that first tries to title a tab with `undefined`.\n const { labelKey: entityLabelKey, pluralKey: entityPluralKey } = meta;\n if (entityLabelKey === undefined || entityPluralKey === undefined) {\n throw new Error(\n `${entityConstructor.name} must declare labelKey and pluralKey on @entity() to be generated`,\n );\n }\n // Narrowed once, for the closures below that TypeScript cannot follow.\n const pluralKey: string = entityPluralKey;\n\n // Computed once: a descriptor is a property of the class, so nothing about it\n // depends on the record being edited. `linkLabelProperty`/`linkSearchProperty`\n // are overridden here because a scalar foreign key's `@accessor()` cannot name\n // the target's members — it may not import the target at all.\n // The wire name, which is also what a pending flow's intent records and what\n // `entityQueryScopeFor` keys on — one derivation, so the two can never\n // disagree about which entity they mean.\n const entityName = envelopeEntityName(entityConstructor);\n const descriptors = describeEntityColumns(entityConstructor);\n /** The members a filter panel offers choices for, and so counts. */\n const facetMembers = descriptors\n .filter(\n descriptor =>\n descriptor.filterable &&\n (descriptor.type === 'enum' || descriptor.type === 'boolean'),\n )\n .map(({ name, key }) => ({ name, key }));\n const relatedPlans = planRelated(\n entityConstructor as EntityConstructor<Entity>,\n descriptors,\n related,\n );\n const linkPlans = links.map(link => {\n const descriptor = descriptors.find(entry => entry.name === link.field);\n if (descriptor === undefined) {\n throw new Error(\n `${entityConstructor.name} has no member \"${link.field}\" for a link source`,\n );\n }\n return {\n ...link,\n descriptor: {\n ...descriptor,\n linkLabelProperty: link.labelProperty ?? TARGET_NAME_PROPERTY,\n linkSearchProperty: link.searchProperty ?? TARGET_NAME_PROPERTY,\n },\n };\n });\n\n /**\n * The generated list itself — the table, its reads, its verbs — shared by the\n * list page and by a related region on another record's page. A region holds\n * it to a fixed filter that is not a removable chip and keeps its pager in\n * component state, never in the URL.\n */\n function ListBody({\n baseFiltering,\n newHref: givenNewHref,\n listPageSize = pageSize,\n listInitialFiltering,\n onVerbSettled,\n }: {\n baseFiltering?: FilterGroup<TEntity>;\n newHref?: string;\n listPageSize?: number;\n listInitialFiltering?: FilterGroup<TEntity>;\n onVerbSettled?: () => void;\n }) {\n const adapters = useAdapters();\n // Every internal href carries the locale. An unprefixed one still resolves —\n // the middleware redirects it — but the visitor pays a round trip per click.\n const withLocale = useLocaleHref();\n\n const queryClient = useQueryClient();\n const scope = entityQueryScope(entityConstructor);\n const metadataSource = metadataSourceOf(adapters);\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const renderLink = useCrudRenderLink(catalogKey);\n\n const pager = useDataLoading<TEntity, CrudContext>({\n uc: loadUCFactory<TEntity>(),\n ctx: crudContextOf(adapters, repository),\n // Scoped rather than left to the per-instance fallback, which is correct\n // but unshared: with the entity's own scope one invalidation refreshes\n // every page and filter of it, which is what a bulk run needs — and it is\n // the same prefix `useReactiveInvalidation`already targets, so a generated\n // list now also refreshes on a reactive change event.\n queryKey: scope,\n ...(listPageSize === undefined ? {} : { initialPageSize: listPageSize }),\n ...(listInitialFiltering === undefined\n ? {}\n : { initialFiltering: listInitialFiltering }),\n ...(baseFiltering === undefined ? {} : { baseFiltering }),\n });\n\n // Values that live in another entity, one read per column per page.\n const relatedColumns = useRelatedColumns<TAdapters, TEntity>(\n relatedPlans,\n pager.items,\n plan => crudContextOf(adapters, plan.repository),\n );\n\n const facetCounts = useFacetCounts<TEntity>({\n ctx:\n facets === undefined\n ? undefined\n : (adapters[facets] as Context.Context<EntityFacetCounterTag>),\n members: facetMembers,\n filtering: pager.filtering,\n scope,\n });\n\n // Only when this caller may actually run something over a selection.\n //\n // Measured live: an `admin` holds `catalog-reference:*:read` and no\n // `retire`, so the service filters the verb out of `$metadata` — but the\n // selection column still rendered, offering a set that no action could be\n // taken on. A checkbox that can lead nowhere is worse than no checkbox: it\n // reads as a permission the user does not have.\n //\n // Decided from the served document rather than from the runner, because\n // the runner is a property of the *shell* (it knows the route) and the\n // grant is a property of the *caller*. The column therefore appears when\n // the document lands, which is the asynchrony serving affordances accepts\n // for every action surface.\n const canRunBulk =\n useCasesForSurface('bulk-bar', affordances.metadata?.useCases).length > 0;\n\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n\n const bulk = useEntityBulk<TEntity>({\n run:\n canRunBulk && verbs !== undefined\n ? (key, selection) =>\n verbs.bulk(key, selection as EntitySelection<Entity>)\n : undefined,\n // A bulk write changed the rows underneath the listing, so the page is\n // re-read; the selection deliberately survives it (\"the selection\n // is still there afterwards\"), because the operator's next act is usually\n // to retry the failures or run a second verb on the same rows.\n onCompleted: () => {\n void queryClient.invalidateQueries({ queryKey: scope });\n },\n });\n\n // What a row's overflow menu runs, and the one place the list reports a\n // verb that failed.\n //\n // ⚠️ **A row verb and the form's are the same runner with different\n // arguments.** `EntityTable` hands back the whole record, because that is\n // what it has; the runner takes an id, because that is what a route needs.\n // The list has no error slot of its own, so a failure lands in the\n // table's own error region — the same one a failed page read uses.\n const rowVerb = useVerb(verbs, () => {\n void queryClient.invalidateQueries({ queryKey: scope });\n onVerbSettled?.();\n });\n // Called unconditionally and the *result* gated, the way the surfaces are\n // read in `EntityForm`: the name begins with `use`, so short-circuiting it\n // reads to `react-hooks/rules-of-hooks` as a conditional hook.\n const rowUseCases = useCasesForSurface(\n 'row-menu',\n affordances.metadata?.useCases,\n );\n const canRunRowUseCase = verbs !== undefined && rowUseCases.length > 0;\n\n const handleRowUseCase = canRunRowUseCase\n ? (key: string, item: TEntity) => {\n if (item.id == null) return;\n rowVerb.run(key, item.id);\n }\n : undefined;\n\n return (\n <EntityTable\n entityConstructor={entityConstructor}\n {...pager}\n items={pager.items}\n totalItems={pager.totalItems}\n hrefFor={id => withLocale(`${basePath}/${String(id)}`)}\n newHref={withLocale(givenNewHref ?? `${basePath}/${CATALOG_NEW_SLUG}`)}\n renderLink={renderLink}\n {...affordances}\n {...bulk.tableProps}\n onUseCase={handleRowUseCase}\n onRetry={pager.refetch}\n facets={facetCounts}\n error={syncFailure(rowVerb.verb) ?? pager.error}\n >\n {columns}\n {relatedColumns}\n {/* After the host's own: a host column for the same member wins. */}\n {toolbar}\n </EntityTable>\n );\n }\n\n function ListPage() {\n // The list's heading, and where focus lands when a save or a delete\n // brings the reader back here rather than falling to `<body>`.\n const heading = useRef<HTMLHeadingElement>(null);\n useFocusOnArrival(heading);\n const et = useT('entity');\n\n return (\n <div className=\"flex flex-col gap-s\">\n <h1\n ref={heading}\n tabIndex={-1}\n className=\"m-0 text-step-2 font-semibold text-content focus-ring\"\n >\n {et(pluralKey.replace(/^entity:/, ''))}\n </h1>\n <ListBody\n {...(initialFiltering === undefined\n ? {}\n : { listInitialFiltering: initialFiltering })}\n />\n </div>\n );\n }\n\n /**\n * This entity's records that refer to another record, as a region of that\n * record's page\n * ([ADR 0030](../../../../../../docs/adr/0030-a-reference-names-its-target-through-the-owners-read-port.md)):\n * the generated list held to `filtering`, which is fixed and shown as no\n * chip, under its own `h2`, with its own states and its own writes. A verb\n * that settles inside it moves focus to that heading; nothing else on the\n * page is re-read or touched. `prefill` names the members a \"New\" from here\n * opens already set — the parent record's id.\n */\n function RelatedList({\n filtering,\n labelKey: headingKey,\n prefill,\n newHref,\n pageSize: regionPageSize,\n }: EntityCrudRelatedListProps<TEntity>) {\n const headingRef = useRef<HTMLHeadingElement>(null);\n const id = useId();\n const heading = useTranslateKey()(headingKey);\n useRegion(id, heading);\n const query = new URLSearchParams(\n Object.entries(prefill ?? {}).map(([member, value]): [string, string] => [\n `${PREFILL_PARAM}${member}`,\n value,\n ]),\n ).toString();\n return (\n <section\n id={id}\n aria-labelledby={`${id}-heading`}\n className=\"flex flex-col gap-s\"\n >\n <h2\n id={`${id}-heading`}\n ref={headingRef}\n tabIndex={-1}\n className=\"m-0 text-step-1 font-semibold text-content focus-ring\"\n >\n {heading}\n </h2>\n <ListBody\n baseFiltering={filtering}\n newHref={\n newHref ??\n `${basePath}/${CATALOG_NEW_SLUG}${query === '' ? '' : `?${query}`}`\n }\n {...(regionPageSize === undefined\n ? {}\n : { listPageSize: regionPageSize })}\n // The row's menu hands focus back to its trigger as it closes, and\n // a verb that settles fast settles before that. Focusing on the\n // next frame lands after the menu's restore, never under it.\n onVerbSettled={() =>\n requestAnimationFrame(() => headingRef.current?.focus())\n }\n />\n </section>\n );\n }\n\n /**\n * Dual-host: as a route it reads its slug from the URL and returns to the list\n * on save; in a workspace tab it takes the slug and the post-save action as\n * props.\n */\n function SingleViewPage({\n slug,\n onSaved,\n onDeleted,\n draft,\n }: EntityCrudSingleViewProps = {}) {\n const adapters = useAdapters();\n const metadataSource = metadataSourceOf(adapters);\n // The same served document the form reads its buttons from, so a key the\n // form hands back always names a verb in it.\n const affordances = useEntityAffordances(entityConstructor, metadataSource);\n const router = useRouter();\n const withLocale = useLocaleHref();\n const params = useParams<{ slug: string }>();\n const mounted = useMounted();\n const id = slugToEntityId(slug ?? params.slug);\n\n // A create opened from a related region starts with the parent record set:\n // `?prefill.<member>=<value>`, layered under any draft the host restores.\n const searchParams = useSearchParams();\n const prefill =\n id == null ? readPrefill(searchParams, descriptors) : undefined;\n const prefillKey = prefill === undefined ? '' : JSON.stringify(prefill);\n const formDraft = useMemo(\n () =>\n prefill === undefined\n ? draft\n : {\n draft: { ...prefill, ...draft?.draft },\n save: draft?.save ?? ignoreDraft,\n clear: draft?.clear ?? ignoreDraft,\n },\n // Keyed on the values, not the object a render builds them into.\n [draft, prefillKey],\n );\n\n const ctx = crudContextOf(adapters, repository);\n\n const {\n entity,\n isLoading,\n error: loadError,\n reload,\n } = useEntityRecord<TEntity, CrudContext>({\n uc: getUCFactory<TEntity>(),\n ctx,\n id,\n });\n\n // Against the record as loaded, not the draft: the rule is about which\n // record this is, not what the operator has typed into it.\n const linkFilters = useLinkFilters(linkPlans, entity);\n\n // Rebuilt inline on every render on purpose: `useEntityLinkSource` holds\n // these in a ref and keeps them out of its query keys, precisely so a caller\n // does not have to memoise them.\n const linkSources: EntityCrudLinkSource[] = linkPlans.map(\n (plan, index) => ({\n field: plan.field,\n descriptor: plan.descriptor,\n config: {\n entityConstructor: plan.entityConstructor,\n loadUc: loadUCFactory(),\n getUc: getUCFactory(),\n ctx: crudContextOf(adapters, plan.repository),\n // The config's target is erased to `Entity`, and the host's filter to\n // `any`; the two meet here, where neither type is the real target's.\n baseFiltering: linkFilters[index] as FilterGroup<Entity> | undefined,\n },\n }),\n );\n\n // Inside a workspace tab, \"back to the list\" is the list's tab, not a URL\n // that would leave the workspace. A host's own callbacks still win.\n const host = useEntityNavHost();\n const renderLink = useCrudRenderLink(catalogKey);\n const queryClient = useQueryClient();\n // The list this page returns to has its page cached, and it is no longer\n // true. Invalidated rather than patched: the service is the authority on\n // the row it stored.\n //\n // ⚠️ Invisible while every Open was a document load, which threw the cache\n // away anyway (#20): the first client-side navigation back to the list\n // showed the record as it was before the save.\n const refreshList = () =>\n queryClient.invalidateQueries({\n queryKey: entityQueryScope(entityConstructor),\n });\n const toList = () =>\n host === undefined\n ? router.push(withLocale(basePath))\n : host.toList(catalogKey);\n const afterSave = onSaved ?? toList;\n const afterDelete = onDeleted ?? toList;\n\n // Through the host's writer when it named one, which answers both settle\n // modes; otherwise through the repository, where every write settles.\n const writer =\n write === undefined ? undefined : (adapters[write] as EntityWriter);\n\n // The draft is spent once the write *commits*, and only here is that known:\n // `useEntityForm` neither fetches nor saves, so it cannot clear its own.\n // A failed write — or a failed flow — deliberately keeps the draft and the\n // form: the edit is still the user's only copy of what they typed.\n //\n // ⚠️ A flow can complete after the operator left this page, so leaving it\n // is guarded on still being here: a navigation from a form nobody is\n // looking at would pull them away from wherever they went.\n const saveMutation = useOptimisticMutation<TEntity, TEntity>({\n write: next =>\n writer === undefined\n ? Effect.map(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, next)),\n ),\n settled,\n )\n : writer.save(next),\n intent: () => ({ entity: entityName, write: 'save' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterSave();\n },\n });\n const deleteMutation = useOptimisticMutation<EntityId, void>({\n write: target =>\n writer === undefined\n ? Effect.as(\n Effect.provide(\n deleteUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityIdTag, target)),\n ),\n settled(undefined),\n )\n : writer.delete(target),\n intent: () => ({ entity: entityName, write: 'delete' }),\n confirm: () => {\n draft?.clear();\n void refreshList();\n if (mounted.current) afterDelete();\n },\n });\n\n const handleSave = async (next: TEntity) => {\n const result = await saveMutation.mutate(next).catch(() => undefined);\n // Failed, or pending: the form stays, and the mutation says which. A\n // pending write leaves through the mutation's `confirm`, once its flow\n // completed.\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said in the toast region every route shares, so it survives the\n // navigation that follows (ADR 0028).\n toasts?.show({\n tone: 'success',\n message: ct('state.saved', {\n object: recordNoun(next),\n }),\n });\n afterSave();\n };\n\n const toasts = useToasts();\n const ct = useT('controls');\n const nameOf = useRecordLabel();\n /**\n * What an announcement names: the record, through the one derivation every\n * surface shares, or the entity for one not loaded.\n */\n const recordNoun = (record: TEntity | undefined) =>\n nameOf(entityConstructor, record);\n // The breadcrumb for this page's segment names the record, never its id:\n // \"Nuevo\" for a create, the record once it has loaded.\n useBreadcrumbLabel(\n slug ?? params.slug,\n id == null ? ct('form.new') : entity && recordNoun(entity),\n );\n /**\n * Saves a deleted record back under its id: what Undo runs under the\n * `undo` policy.\n */\n const restore = (record: TEntity) =>\n Effect.runPromise(\n writer === undefined\n ? Effect.asVoid(\n Effect.provide(\n saveUCFactory<TEntity>(),\n ctx.pipe(Context.add(EntityTag, record)),\n ),\n )\n : Effect.asVoid(writer.save(record)),\n ).then(\n () => refreshList(),\n (failure: unknown) => {\n toasts?.show({ tone: 'failure', failure: asFailure(failure) });\n },\n );\n\n const handleDelete = async () => {\n const snapshot = entity;\n const result = await deleteMutation.mutate(id).catch(() => undefined);\n if (result?._tag !== 'settled') return;\n draft?.clear();\n void refreshList();\n // Said once, in the toast region every route shares, so it survives the\n // navigation back to the list.\n const object = recordNoun(snapshot);\n const message = ct('confirm.deleted', { object });\n if (deletePolicy === 'undo' && snapshot !== undefined)\n toasts?.show({\n tone: 'undo',\n message,\n action: {\n label: ct('confirm.undo'),\n onAction: () => void restore(snapshot),\n },\n });\n else toasts?.show({ tone: 'success', message });\n afterDelete();\n };\n\n /**\n * An `entity`-bound verb, on the record being shown.\n *\n * It **reloads** — once the verb took effect, which for one the server\n * handed to a flow is when the flow completed — rather than patching what it has: the service decides the\n * resulting state — a `publish` may land on `published` from four different\n * places — and a client that assumed the new value would show the wrong one\n * the first time the rule changed. `id == null` means the create form,\n * where there is no record to act on and the form renders no verbs anyway.\n *\n * ⚠️ The rejection is **caught and shown**, never left to the promise.\n * `EntityForm`'s `onUseCase` returns `void`, so an uncaught rejection here\n * reaches the console and nothing else — measured on an offering refusing\n * `unpublish` from `draft`: the service answered `409` with a coded body,\n * the record correctly did not move, and the operator saw a button that\n * appeared to do nothing at all.\n */\n const verbs = verbsOf(\n useCases === undefined\n ? undefined\n : (adapters[useCases] as EntityUseCaseRunner),\n affordances.metadata?.useCases,\n );\n const recordVerb = useVerb(verbs, () => void reload());\n const handleUseCase =\n verbs === undefined || id == null\n ? undefined\n : (key: string) => recordVerb.run(key, id);\n\n const form = (\n <EntityCrudForm<TEntity>\n // Remounts (and reseeds the fields) once the record arrives.\n key={String(entity?.id ?? CATALOG_NEW_SLUG)}\n entityConstructor={entityConstructor}\n catalogKey={catalogKey}\n metadataSource={metadataSource}\n hiddenFields={hiddenFields}\n links={linkSources}\n entity={entity}\n isLoading={isLoading}\n isSaving={saveMutation.status === 'running'}\n isPending={[saveMutation, deleteMutation, recordVerb.verb].some(\n mutation => mutation.status === 'pending',\n )}\n isDeleting={deleteMutation.status === 'running'}\n error={\n loadError ??\n syncFailure(saveMutation) ??\n syncFailure(deleteMutation) ??\n syncFailure(recordVerb.verb)\n }\n onSave={handleSave}\n onRetry={loadError === undefined ? undefined : reload}\n onDelete={id == null ? undefined : handleDelete}\n deletePolicy={deletePolicy}\n onUseCase={handleUseCase}\n backHref={withLocale(basePath)}\n renderLink={renderLink}\n draft={formDraft}\n />\n );\n // The records that refer to this one, under its form: an existing record\n // only, since a record being created has nothing referring to it yet.\n if (regions === undefined || id == null || entity === undefined)\n return form;\n return (\n <div className=\"flex flex-col gap-l\">\n {form}\n <RecordRegions>{regions(entity)}</RecordRegions>\n </div>\n );\n }\n\n return {\n entityConstructor,\n entityKey: catalogKey,\n entityLabelKey,\n entityPluralKey,\n basePath,\n ListPage,\n SingleViewPage,\n RelatedList,\n };\n}\n"],"names":["deleteUCFactory","EntityIdTag","EntityTag","getUCFactory","loadUCFactory","saveUCFactory","coerceFiltering","describeEntityColumns","envelopeEntityName","extractMetaEntity","Internal","isFailure","parseRsql","serializeRsql","settled","EntityTable","useCasesForSurface","useFocusOnArrival","useRecordLabel","useT","useToasts","useTranslateKey","entityQueryScope","useDataLoading","useEntityRecord","useFacetCounts","useOptimisticMutation","useQueryClient","Cause","Context","Effect","Exit","useParams","useRouter","useSearchParams","useEffect","useId","useMemo","useRef","useBreadcrumbLabel","useLocaleHref","useEntityNavHost","EntityCrudForm","PREFILL_PARAM","readPrefill","RecordRegions","useRegion","planRelated","useRelatedColumns","CATALOG_NEW_SLUG","slugToEntityId","useCrudRenderLink","useEntityAffordances","useEntityBulk","TARGET_NAME_PROPERTY","ignoreDraft","undefined","crudContextOf","adapters","repository","asFailure","failure","syncFailure","mutation","status","flowId","verbsOf","runner","served","descriptor","key","find","candidate","run","id","bulk","selection","runPromiseExit","then","exit","isSuccess","value","Promise","reject","squash","cause","useVerb","verbs","done","verb","write","confirm","mutate","result","_tag","useMounted","mounted","current","useLinkFilters","links","record","map","link","useBaseFiltering","makeEntityCrud","entityConstructor","options","useAdapters","basePath","catalogKey","hiddenFields","columns","toolbar","pageSize","initialFiltering","related","regions","metadataSource","givenMetadataSource","metadata","useCases","delete","deletePolicy","facets","Error","name","metadataSourceOf","initialRsql","meta","String","labelKey","entityLabelKey","pluralKey","entityPluralKey","entityName","descriptors","facetMembers","filter","filterable","type","relatedPlans","linkPlans","entry","field","linkLabelProperty","labelProperty","linkSearchProperty","searchProperty","ListBody","baseFiltering","newHref","givenNewHref","listPageSize","listInitialFiltering","onVerbSettled","affordances","withLocale","queryClient","scope","renderLink","pager","uc","ctx","queryKey","initialPageSize","relatedColumns","items","plan","facetCounts","members","filtering","canRunBulk","length","onCompleted","invalidateQueries","rowVerb","rowUseCases","canRunRowUseCase","handleRowUseCase","item","totalItems","hrefFor","tableProps","onUseCase","onRetry","refetch","error","ListPage","heading","et","div","className","h1","ref","tabIndex","replace","RelatedList","headingKey","prefill","regionPageSize","headingRef","query","URLSearchParams","Object","entries","member","toString","section","aria-labelledby","h2","requestAnimationFrame","focus","SingleViewPage","slug","onSaved","onDeleted","draft","loadError","router","params","searchParams","prefillKey","JSON","stringify","formDraft","save","clear","entity","isLoading","reload","linkFilters","linkSources","index","config","loadUc","getUc","host","refreshList","toList","push","afterSave","afterDelete","writer","saveMutation","next","provide","pipe","add","intent","deleteMutation","target","as","handleSave","catch","toasts","show","tone","message","ct","object","recordNoun","nameOf","restore","runPromise","asVoid","handleDelete","snapshot","action","label","onAction","recordVerb","handleUseCase","form","isSaving","isPending","some","isDe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YACRpE,SAASiC,cAAcjK,YAAYA,YAAY6K;YAC/CiD,UAAU5M,MAAM,OAAOlB,YAAYiN;YACnC/I,cAAcA;YACd6D,WAAWwF;YACXQ,UAAU3H,WAAWhD;YACrBmD,YAAYA;YACZyD,OAAOQ;WA1BF/F,gBAAOkG,0BAAAA,OAAQzJ,EAAE,oBAAIzB;QA6B9B,yEAAyE;QACzE,sEAAsE;QACtE,IAAImE,YAAY5D,aAAakB,MAAM,QAAQyJ,WAAW3K,WACpD,OAAOwN;QACT,qBACE,MAAClF;YAAIC,WAAU;;gBACZiF;8BACD,KAACnO;8BAAeuE,QAAQ+G;;;;IAG9B;IAEA,OAAO;QACL1H;QACA+K,WAAW3K;QACXsB;QACAE;QACAzB;QACA+E;QACAyB;QACAhB;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-entity-link-sources.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/use-entity-link-sources.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"use-entity-link-sources.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/use-entity-link-sources.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EAEtB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,WAAW,2BAA2B;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,mBAAmB,CAAC;CACzC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,oBAAoB,EAAE,EACtC,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,2BAA2B,GACjD,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAoB1C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { readDraftString } from '@entifix/core';
|
|
3
|
+
import { useLocale } from '@entifix/react-controls';
|
|
3
4
|
import { useEntityLinkSource } from '@entifix/react-integration';
|
|
4
5
|
/**
|
|
5
6
|
* Turns a fixed list of pickers into the `linkSources` map `EntityForm` takes.
|
|
@@ -16,6 +17,8 @@ import { useEntityLinkSource } from '@entifix/react-integration';
|
|
|
16
17
|
* upward — would put the sources one render behind the draft that feeds them,
|
|
17
18
|
* which is a stale suggestion list rather than a lint error.
|
|
18
19
|
*/ export function useEntityLinkSources(links, { values, selection }) {
|
|
20
|
+
// A localized member is searched and read in the reader's own locale.
|
|
21
|
+
const locale = useLocale();
|
|
19
22
|
const sources = {};
|
|
20
23
|
for (const link of links){
|
|
21
24
|
// Read as a string: a relation's draft value is a foreign key, and a
|
|
@@ -28,7 +31,8 @@ import { useEntityLinkSource } from '@entifix/react-integration';
|
|
|
28
31
|
// An empty draft entry is "unset", not an id. Nothing enforces the
|
|
29
32
|
// reference across a store boundary, so `''` would be a dangling id.
|
|
30
33
|
selectedId: held === '' ? undefined : held,
|
|
31
|
-
selectedEntity: selection[link.field]
|
|
34
|
+
selectedEntity: selection[link.field],
|
|
35
|
+
locale
|
|
32
36
|
});
|
|
33
37
|
}
|
|
34
38
|
return sources;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/crud/use-entity-link-sources.ts"],"sourcesContent":["'use client';\n\nimport {\n type Entity,\n type EntityDraft,\n type EntityLinkSelection,\n type EntityLinkSource,\n readDraftString,\n} from '@entifix/core';\nimport { useEntityLinkSource } from '@entifix/react-integration';\n\nimport type { EntityCrudLinkSource } from './make-entity-crud.types.js';\n\nexport interface UseEntityLinkSourcesOptions {\n /** The form's current draft — ids are the truth. */\n readonly values: EntityDraft;\n /** The picked-instance sidecar, so a chosen name needs no round trip. */\n readonly selection: EntityLinkSelection;\n}\n\n/**\n * Turns a fixed list of pickers into the `linkSources` map `EntityForm` takes.\n *\n * **Why the rule is disabled below.** `links` is built once, at factory time,\n * and closed over by the generated form — it is the same array object on every\n * render of a given component, so the hook count is fixed. That is exactly the\n * invariant `react-hooks/rules-of-hooks` exists to protect and exactly the one\n * it cannot see, because it reasons syntactically about the loop rather than\n * about the array's provenance. The loop is isolated in this module so the\n * disable is written once, with its reason, instead of once per generated form.\n *\n * The alternative — one child component per picker, reporting its source\n * upward — would put the sources one render behind the draft that feeds them,\n * which is a stale suggestion list rather than a lint error.\n */\nexport function useEntityLinkSources(\n links: readonly EntityCrudLinkSource[],\n { values, selection }: UseEntityLinkSourcesOptions,\n): Record<string, EntityLinkSource<Entity>> {\n const sources: Record<string, EntityLinkSource<Entity>> = {};\n for (const link of links) {\n // Read as a string: a relation's draft value is a foreign key, and a\n // member that came back from storage in any other shape must read as unset\n // rather than be handed to the picker as an id.\n const held = readDraftString(values, link.field);\n // eslint-disable-next-line react-hooks/rules-of-hooks -- fixed-length loop over a factory-time array; see the note above.\n sources[link.field] = useEntityLinkSource(link.config, {\n descriptor: link.descriptor,\n // An empty draft entry is \"unset\", not an id. Nothing enforces the\n // reference across a store boundary, so `''` would be a dangling id.\n selectedId: held === '' ? undefined : held,\n selectedEntity: selection[link.field],\n });\n }\n return sources;\n}\n"],"names":["readDraftString","useEntityLinkSource","useEntityLinkSources","links","values","selection","sources","link","held","field","config","descriptor","selectedId","undefined","selectedEntity"],"mappings":"AAAA;AAEA,SAKEA,eAAe,QACV,gBAAgB;AACvB,SAASC,mBAAmB,QAAQ,6BAA6B;AAWjE;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,qBACdC,KAAsC,EACtC,EAAEC,MAAM,EAAEC,SAAS,EAA+B;IAElD,MAAMC,UAAoD,CAAC;IAC3D,KAAK,MAAMC,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/crud/use-entity-link-sources.ts"],"sourcesContent":["'use client';\n\nimport {\n type Entity,\n type EntityDraft,\n type EntityLinkSelection,\n type EntityLinkSource,\n readDraftString,\n} from '@entifix/core';\nimport { useLocale } from '@entifix/react-controls';\nimport { useEntityLinkSource } from '@entifix/react-integration';\n\nimport type { EntityCrudLinkSource } from './make-entity-crud.types.js';\n\nexport interface UseEntityLinkSourcesOptions {\n /** The form's current draft — ids are the truth. */\n readonly values: EntityDraft;\n /** The picked-instance sidecar, so a chosen name needs no round trip. */\n readonly selection: EntityLinkSelection;\n}\n\n/**\n * Turns a fixed list of pickers into the `linkSources` map `EntityForm` takes.\n *\n * **Why the rule is disabled below.** `links` is built once, at factory time,\n * and closed over by the generated form — it is the same array object on every\n * render of a given component, so the hook count is fixed. That is exactly the\n * invariant `react-hooks/rules-of-hooks` exists to protect and exactly the one\n * it cannot see, because it reasons syntactically about the loop rather than\n * about the array's provenance. The loop is isolated in this module so the\n * disable is written once, with its reason, instead of once per generated form.\n *\n * The alternative — one child component per picker, reporting its source\n * upward — would put the sources one render behind the draft that feeds them,\n * which is a stale suggestion list rather than a lint error.\n */\nexport function useEntityLinkSources(\n links: readonly EntityCrudLinkSource[],\n { values, selection }: UseEntityLinkSourcesOptions,\n): Record<string, EntityLinkSource<Entity>> {\n // A localized member is searched and read in the reader's own locale.\n const locale = useLocale();\n const sources: Record<string, EntityLinkSource<Entity>> = {};\n for (const link of links) {\n // Read as a string: a relation's draft value is a foreign key, and a\n // member that came back from storage in any other shape must read as unset\n // rather than be handed to the picker as an id.\n const held = readDraftString(values, link.field);\n // eslint-disable-next-line react-hooks/rules-of-hooks -- fixed-length loop over a factory-time array; see the note above.\n sources[link.field] = useEntityLinkSource(link.config, {\n descriptor: link.descriptor,\n // An empty draft entry is \"unset\", not an id. Nothing enforces the\n // reference across a store boundary, so `''` would be a dangling id.\n selectedId: held === '' ? undefined : held,\n selectedEntity: selection[link.field],\n locale,\n });\n }\n return sources;\n}\n"],"names":["readDraftString","useLocale","useEntityLinkSource","useEntityLinkSources","links","values","selection","locale","sources","link","held","field","config","descriptor","selectedId","undefined","selectedEntity"],"mappings":"AAAA;AAEA,SAKEA,eAAe,QACV,gBAAgB;AACvB,SAASC,SAAS,QAAQ,0BAA0B;AACpD,SAASC,mBAAmB,QAAQ,6BAA6B;AAWjE;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASC,qBACdC,KAAsC,EACtC,EAAEC,MAAM,EAAEC,SAAS,EAA+B;IAElD,sEAAsE;IACtE,MAAMC,SAASN;IACf,MAAMO,UAAoD,CAAC;IAC3D,KAAK,MAAMC,QAAQL,MAAO;QACxB,qEAAqE;QACrE,2EAA2E;QAC3E,gDAAgD;QAChD,MAAMM,OAAOV,gBAAgBK,QAAQI,KAAKE,KAAK;QAC/C,0HAA0H;QAC1HH,OAAO,CAACC,KAAKE,KAAK,CAAC,GAAGT,oBAAoBO,KAAKG,MAAM,EAAE;YACrDC,YAAYJ,KAAKI,UAAU;YAC3B,mEAAmE;YACnE,qEAAqE;YACrEC,YAAYJ,SAAS,KAAKK,YAAYL;YACtCM,gBAAgBV,SAAS,CAACG,KAAKE,KAAK,CAAC;YACrCJ;QACF;IACF;IACA,OAAOC;AACT"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type EntityRepositoryTag } from '@entifix/business';
|
|
2
|
+
import type { Entity, EntityConstructor, FilterGroup } from '@entifix/core';
|
|
3
|
+
import { Context } from 'effect';
|
|
4
|
+
export interface UseEntityTotalOptions<TEntity extends Entity> {
|
|
5
|
+
/** The entity counted; its query scope is the count's, so a push refreshes it. */
|
|
6
|
+
readonly entity: EntityConstructor<TEntity>;
|
|
7
|
+
/** Where its records are read. Without one nothing is counted and the count stays loading. */
|
|
8
|
+
readonly ctx: Context.Context<EntityRepositoryTag> | undefined;
|
|
9
|
+
/** Which records count — "awaiting dispatch". All of them when omitted. */
|
|
10
|
+
readonly filtering?: FilterGroup<TEntity>;
|
|
11
|
+
}
|
|
12
|
+
/** A count in the shape a summary tile takes it. */
|
|
13
|
+
export interface EntityTotal {
|
|
14
|
+
readonly state: 'loading' | 'ready' | 'failed';
|
|
15
|
+
/** How many records match, once read. */
|
|
16
|
+
readonly total: number | undefined;
|
|
17
|
+
/** Reads the count again. */
|
|
18
|
+
readonly retry: () => void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* How many records of an entity match a filtering, read as a one-record page
|
|
22
|
+
* whose `total` is the answer — the list's own read, so the same narrowing and
|
|
23
|
+
* the same authorization apply. Keyed under the entity's query scope: a pushed
|
|
24
|
+
* change to that entity, or a write through its list, refreshes the count.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useEntityTotal<TEntity extends Entity>({ entity, ctx, filtering, }: UseEntityTotalOptions<TEntity>): EntityTotal;
|
|
27
|
+
//# sourceMappingURL=use-entity-total.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-entity-total.d.ts","sourceRoot":"","sources":["../../../src/lib/crud/use-entity-total.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EAGjB,WAAW,EACZ,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,OAAO,EAAU,MAAM,QAAQ,CAAC;AAEzC,MAAM,WAAW,qBAAqB,CAAC,OAAO,SAAS,MAAM;IAC3D,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC5C,8FAA8F;IAC9F,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,GAAG,SAAS,CAAC;IAC/D,2EAA2E;IAC3E,QAAQ,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;CAC3C;AAED,oDAAoD;AACpD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC/C,yCAAyC;IACzC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,6BAA6B;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,SAAS,MAAM,EAAE,EACrD,MAAM,EACN,GAAG,EACH,SAAS,GACV,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,WAAW,CA4B9C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
3
|
+
import { EntityLoadRequestTag, loadUCFactory } from '@entifix/business';
|
|
4
|
+
import { entityQueryScope } from '@entifix/react-integration';
|
|
5
|
+
import { useQuery } from '@tanstack/react-query';
|
|
6
|
+
import { Context, Effect } from 'effect';
|
|
7
|
+
/**
|
|
8
|
+
* How many records of an entity match a filtering, read as a one-record page
|
|
9
|
+
* whose `total` is the answer — the list's own read, so the same narrowing and
|
|
10
|
+
* the same authorization apply. Keyed under the entity's query scope: a pushed
|
|
11
|
+
* change to that entity, or a write through its list, refreshes the count.
|
|
12
|
+
*/ export function useEntityTotal({ entity, ctx, filtering }) {
|
|
13
|
+
// The repository behind the tag reads any entity's records, so the request
|
|
14
|
+
// crosses it untyped — exactly as the list's own read does.
|
|
15
|
+
const request = _extends({}, filtering === undefined ? {} : {
|
|
16
|
+
filtering: [
|
|
17
|
+
filtering
|
|
18
|
+
]
|
|
19
|
+
}, {
|
|
20
|
+
page: 1,
|
|
21
|
+
pageSize: 1
|
|
22
|
+
});
|
|
23
|
+
const { data, isError, refetch } = useQuery({
|
|
24
|
+
enabled: ctx !== undefined,
|
|
25
|
+
queryKey: [
|
|
26
|
+
...entityQueryScope(entity),
|
|
27
|
+
'$total',
|
|
28
|
+
request
|
|
29
|
+
],
|
|
30
|
+
queryFn: ()=>Effect.runPromise(Effect.provide(loadUCFactory(), ctx.pipe(Context.add(EntityLoadRequestTag, request)))).then((page)=>page.total)
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
state: isError ? 'failed' : data === undefined ? 'loading' : 'ready',
|
|
34
|
+
total: data,
|
|
35
|
+
retry: ()=>void refetch()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=use-entity-total.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/crud/use-entity-total.ts"],"sourcesContent":["'use client';\n\nimport {\n EntityLoadRequestTag,\n type EntityRepositoryTag,\n loadUCFactory,\n} from '@entifix/business';\nimport type {\n Entity,\n EntityConstructor,\n EntityFiltering,\n EntityLoadRequest,\n FilterGroup,\n} from '@entifix/core';\nimport { entityQueryScope } from '@entifix/react-integration';\nimport { useQuery } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\n\nexport interface UseEntityTotalOptions<TEntity extends Entity> {\n /** The entity counted; its query scope is the count's, so a push refreshes it. */\n readonly entity: EntityConstructor<TEntity>;\n /** Where its records are read. Without one nothing is counted and the count stays loading. */\n readonly ctx: Context.Context<EntityRepositoryTag> | undefined;\n /** Which records count — \"awaiting dispatch\". All of them when omitted. */\n readonly filtering?: FilterGroup<TEntity>;\n}\n\n/** A count in the shape a summary tile takes it. */\nexport interface EntityTotal {\n readonly state: 'loading' | 'ready' | 'failed';\n /** How many records match, once read. */\n readonly total: number | undefined;\n /** Reads the count again. */\n readonly retry: () => void;\n}\n\n/**\n * How many records of an entity match a filtering, read as a one-record page\n * whose `total` is the answer — the list's own read, so the same narrowing and\n * the same authorization apply. Keyed under the entity's query scope: a pushed\n * change to that entity, or a write through its list, refreshes the count.\n */\nexport function useEntityTotal<TEntity extends Entity>({\n entity,\n ctx,\n filtering,\n}: UseEntityTotalOptions<TEntity>): EntityTotal {\n // The repository behind the tag reads any entity's records, so the request\n // crosses it untyped — exactly as the list's own read does.\n const request: EntityLoadRequest = {\n ...(filtering === undefined\n ? {}\n : { filtering: [filtering as unknown as EntityFiltering<Entity>] }),\n page: 1,\n pageSize: 1,\n };\n const { data, isError, refetch } = useQuery({\n enabled: ctx !== undefined,\n queryKey: [...entityQueryScope(entity), '$total', request],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n loadUCFactory<TEntity>(),\n (ctx as Context.Context<EntityRepositoryTag>).pipe(\n Context.add(EntityLoadRequestTag, request),\n ),\n ),\n ).then(page => page.total),\n });\n return {\n state: isError ? 'failed' : data === undefined ? 'loading' : 'ready',\n total: data,\n retry: () => void refetch(),\n };\n}\n"],"names":["EntityLoadRequestTag","loadUCFactory","entityQueryScope","useQuery","Context","Effect","useEntityTotal","entity","ctx","filtering","request","undefined","page","pageSize","data","isError","refetch","enabled","queryKey","queryFn","runPromise","provide","pipe","add","then","total","state","retry"],"mappings":"AAAA;;AAEA,SACEA,oBAAoB,EAEpBC,aAAa,QACR,oBAAoB;AAQ3B,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,QAAQ,QAAQ,wBAAwB;AACjD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAoBzC;;;;;CAKC,GACD,OAAO,SAASC,eAAuC,EACrDC,MAAM,EACNC,GAAG,EACHC,SAAS,EACsB;IAC/B,2EAA2E;IAC3E,4DAA4D;IAC5D,MAAMC,UAA6B,aAC7BD,cAAcE,YACd,CAAC,IACD;QAAEF,WAAW;YAACA;SAAgD;IAAC;QACnEG,MAAM;QACNC,UAAU;;IAEZ,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGb,SAAS;QAC1Cc,SAAST,QAAQG;QACjBO,UAAU;eAAIhB,iBAAiBK;YAAS;YAAUG;SAAQ;QAC1DS,SAAS,IACPd,OAAOe,UAAU,CACff,OAAOgB,OAAO,CACZpB,iBACA,AAACO,IAA6Cc,IAAI,CAChDlB,QAAQmB,GAAG,CAACvB,sBAAsBU,YAGtCc,IAAI,CAACZ,CAAAA,OAAQA,KAAKa,KAAK;IAC7B;IACA,OAAO;QACLC,OAAOX,UAAU,WAAWD,SAASH,YAAY,YAAY;QAC7Dc,OAAOX;QACPa,OAAO,IAAM,KAAKX;IACpB;AACF"}
|
|
@@ -2,6 +2,8 @@ import type { RecordSearchSource } from './record-search-source.js';
|
|
|
2
2
|
export declare const SEARCH_TERM_PARAM = "q";
|
|
3
3
|
export declare const SEARCH_SOURCES_PARAM = "sources";
|
|
4
4
|
export declare const SEARCH_LIMIT_PARAM = "limit";
|
|
5
|
+
/** The reader's locale, which a localized member is searched, sorted and read in. */
|
|
6
|
+
export declare const SEARCH_LOCALE_PARAM = "locale";
|
|
5
7
|
/**
|
|
6
8
|
* Below this, nothing is queried at all.
|
|
7
9
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-search-route.d.ts","sourceRoot":"","sources":["../../../src/lib/search/record-search-route.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"record-search-route.d.ts","sourceRoot":"","sources":["../../../src/lib/search/record-search-route.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAC1C,qFAAqF;AACrF,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,eAAe,KAAK,CAAC;AAClC,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAE/C,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAChD,4EAA4E;IAC5E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAkHD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAAI,8CAIrC,wBAAwB,MAGC,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CA0D9D,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
-
import { decodeProblem, InvalidQuery, ProtocolFailure, Timeout, Unauthenticated, UpstreamUnavailable } from '@entifix/core';
|
|
2
|
+
import { decodeProblem, defaultLocale, InvalidQuery, isLocale, LOCALE_COOKIE, LOCALE_HEADER, ProtocolFailure, Timeout, Unauthenticated, UpstreamUnavailable } from '@entifix/core';
|
|
3
3
|
import { NextResponse } from 'next/server';
|
|
4
4
|
import { problemResponse } from '../config/problem-response.js';
|
|
5
5
|
import { bearerHeader, sessionToken } from '../session/bearer.js';
|
|
6
6
|
export const SEARCH_TERM_PARAM = 'q';
|
|
7
7
|
export const SEARCH_SOURCES_PARAM = 'sources';
|
|
8
8
|
export const SEARCH_LIMIT_PARAM = 'limit';
|
|
9
|
+
/** The reader's locale, which a localized member is searched, sorted and read in. */ export const SEARCH_LOCALE_PARAM = 'locale';
|
|
9
10
|
/**
|
|
10
11
|
* Below this, nothing is queried at all.
|
|
11
12
|
*
|
|
@@ -34,10 +35,10 @@ const unavailable = (source, failure, status)=>({
|
|
|
34
35
|
* Returning a typed outcome rather than throwing is what makes the fan-out a
|
|
35
36
|
* plain `Promise.all`: isolation comes from this catch, not from
|
|
36
37
|
* `allSettled` — whose rejected arm would then be unreachable and untestable.
|
|
37
|
-
*/ const runSource = async (source, term, limit, token, timeoutMs)=>{
|
|
38
|
+
*/ const runSource = async (source, term, limit, locale, token, timeoutMs)=>{
|
|
38
39
|
let upstream;
|
|
39
40
|
try {
|
|
40
|
-
upstream = await fetch(source.url(term, limit), {
|
|
41
|
+
upstream = await fetch(source.url(term, limit, locale), {
|
|
41
42
|
headers: bearerHeader(token),
|
|
42
43
|
cache: 'no-store',
|
|
43
44
|
signal: AbortSignal.timeout(timeoutMs)
|
|
@@ -59,7 +60,7 @@ const unavailable = (source, failure, status)=>({
|
|
|
59
60
|
return unavailable(source, decodeProblem(body, upstream.status), upstream.status);
|
|
60
61
|
}
|
|
61
62
|
const body = await upstream.json().catch(()=>undefined);
|
|
62
|
-
const page = source.read(body);
|
|
63
|
+
const page = source.read(body, locale);
|
|
63
64
|
return page === undefined ? unavailable(source, new ProtocolFailure({
|
|
64
65
|
reason: `${source.key} answered a page the source cannot read`,
|
|
65
66
|
upstreamStatus: upstream.status
|
|
@@ -74,6 +75,20 @@ const unavailable = (source, failure, status)=>({
|
|
|
74
75
|
}
|
|
75
76
|
};
|
|
76
77
|
};
|
|
78
|
+
/**
|
|
79
|
+
* The locale a search runs in: the one the caller names, else the one the
|
|
80
|
+
* host's locale proxy forwarded, else the reader's locale cookie, else the
|
|
81
|
+
* host's default. Anything that is not a declared locale is passed over.
|
|
82
|
+
*/ const requestLocale = (request, params)=>{
|
|
83
|
+
var _request_headers_get, _find;
|
|
84
|
+
var _split_map_find;
|
|
85
|
+
const cookie = (_split_map_find = ((_request_headers_get = request.headers.get('cookie')) != null ? _request_headers_get : '').split(';').map((part)=>part.trim().split('=')).find(([name])=>name === LOCALE_COOKIE)) == null ? void 0 : _split_map_find[1];
|
|
86
|
+
return (_find = [
|
|
87
|
+
params.get(SEARCH_LOCALE_PARAM),
|
|
88
|
+
request.headers.get(LOCALE_HEADER),
|
|
89
|
+
cookie
|
|
90
|
+
].find(isLocale)) != null ? _find : defaultLocale();
|
|
91
|
+
};
|
|
77
92
|
const clampLimit = (raw, fallback)=>{
|
|
78
93
|
const asked = Number(raw);
|
|
79
94
|
if (!Number.isInteger(asked) || asked < 1) return fallback;
|
|
@@ -136,7 +151,8 @@ const clampLimit = (raw, fallback)=>{
|
|
|
136
151
|
});
|
|
137
152
|
}
|
|
138
153
|
const limit = clampLimit(params.get(SEARCH_LIMIT_PARAM), defaultLimit);
|
|
139
|
-
const
|
|
154
|
+
const locale = requestLocale(request, params);
|
|
155
|
+
const outcomes = await Promise.all(selected.map((source)=>runSource(source, term, limit, locale, token, timeoutMs)));
|
|
140
156
|
return answer({
|
|
141
157
|
term,
|
|
142
158
|
// Declared order, never completion order — otherwise the list reshuffles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/search/record-search-route.ts"],"sourcesContent":["import {\n decodeProblem,\n type EntifixFailure,\n InvalidQuery,\n ProtocolFailure,\n Timeout,\n Unauthenticated,\n UpstreamUnavailable,\n} from '@entifix/core';\nimport { NextResponse } from 'next/server';\n\nimport { problemResponse } from '../config/problem-response.js';\nimport { bearerHeader, sessionToken } from '../session/bearer.js';\nimport type {\n RecordSearchGroup,\n RecordSearchResponse,\n RecordSearchUnavailable,\n} from './record-search.types.js';\nimport type { RecordSearchSource } from './record-search-source.js';\n\nexport const SEARCH_TERM_PARAM = 'q';\nexport const SEARCH_SOURCES_PARAM = 'sources';\nexport const SEARCH_LIMIT_PARAM = 'limit';\n\n/**\n * Below this, nothing is queried at all.\n *\n * A `like` becomes an unanchored `$regex` that ignores accents and case, which no index can\n * serve — so this endpoint is a collection scan by construction. One character\n * matches most of every collection and is worth nothing to the person typing, so\n * the floor costs them nothing and saves four scans per keystroke.\n */\nexport const MIN_TERM_LENGTH = 2;\nexport const DEFAULT_GROUP_LIMIT = 5;\nexport const MAX_GROUP_LIMIT = 20;\nexport const DEFAULT_SOURCE_TIMEOUT_MS = 1_500;\n\nexport interface RecordSearchRouteOptions {\n /**\n * The sources to fan out over, **in the order results are presented**. That\n * order is the ranking: an operator learns where a kind of record lands, which\n * a relevance score across four unrelated entities cannot offer.\n */\n readonly sources: readonly RecordSearchSource[];\n /** Per-source budget. Concurrent, so this also bounds the whole request. */\n readonly timeoutMs?: number;\n /** Records per group. */\n readonly limit?: number;\n}\n\ntype SourceOutcome =\n | { readonly ok: true; readonly group: RecordSearchGroup }\n | { readonly ok: false; readonly unavailable: RecordSearchUnavailable };\n\nconst unavailable = (\n source: RecordSearchSource,\n failure: EntifixFailure,\n status?: number,\n): SourceOutcome => ({\n ok: false,\n unavailable: {\n source: source.key,\n entity: source.entity,\n reason: failure.code,\n category: failure.category,\n ...(status === undefined ? {} : { status }),\n },\n});\n\n/**\n * Ask one source, and **never reject**.\n *\n * Returning a typed outcome rather than throwing is what makes the fan-out a\n * plain `Promise.all`: isolation comes from this catch, not from\n * `allSettled` — whose rejected arm would then be unreachable and untestable.\n */\nconst runSource = async (\n source: RecordSearchSource,\n term: string,\n limit: number,\n token: string | undefined,\n timeoutMs: number,\n): Promise<SourceOutcome> => {\n let upstream: Response;\n try {\n upstream = await fetch(source.url(term, limit), {\n headers: bearerHeader(token),\n cache: 'no-store',\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n // `AbortSignal.timeout` rejects with a `DOMException` named `TimeoutError`;\n // branching on the name rather than the class keeps this reachable from a\n // test without fabricating a platform error.\n return unavailable(\n source,\n (error as { name?: string }).name === 'TimeoutError'\n ? new Timeout({ dependency: source.key })\n : new UpstreamUnavailable({ upstream: source.key }),\n );\n }\n\n // The service says why, in a problem body; the code is the reason. A body\n // that is not one decodes as `protocol` — still named, never silent.\n if (!upstream.ok) {\n const body: unknown = await upstream.json().catch(() => undefined);\n return unavailable(\n source,\n decodeProblem(body, upstream.status),\n upstream.status,\n );\n }\n\n const body = await upstream.json().catch(() => undefined);\n const page = source.read(body);\n return page === undefined\n ? unavailable(\n source,\n new ProtocolFailure({\n reason: `${source.key} answered a page the source cannot read`,\n upstreamStatus: upstream.status,\n }),\n upstream.status,\n )\n : {\n ok: true,\n group: {\n source: source.key,\n entity: source.entity,\n labelKey: source.labelKey,\n items: page.items,\n total: page.total,\n },\n };\n};\n\nconst clampLimit = (raw: string | null, fallback: number): number => {\n const asked = Number(raw);\n if (!Number.isInteger(asked) || asked < 1) return fallback;\n return Math.min(asked, MAX_GROUP_LIMIT);\n};\n\n/**\n * `GET /api/search` — records matching a term, across every source this host\n * mounts.\n *\n * The caller's own session is the only credential that crosses: each source is\n * asked over the same guarded route its screens use, so what comes back is\n * already authorized for this principal and this organization. There is no\n * index, and there must never be one — a prefetched index is a tenant leak, and\n * it is the reason this is a fan-out rather than a search service.\n *\n * A source that fails is **named** in `unavailable` rather than dropped. An\n * absent group renders as \"no matches\", which is a confident claim the server is\n * in no position to make about a service it could not reach.\n */\nexport const createRecordSearchRoute = ({\n sources,\n timeoutMs = DEFAULT_SOURCE_TIMEOUT_MS,\n limit: defaultLimit = DEFAULT_GROUP_LIMIT,\n}: RecordSearchRouteOptions) => {\n const byKey = new Map(sources.map(source => [source.key, source]));\n\n return async function GET(request: Request): Promise<Response> {\n // The services decide what this caller may read; this only carries the\n // token. But the gate is not redundant: `catalog-reference` reads are\n // unauthenticated at the service by design, so without it a signed-out\n // caller gets brand matches back and the answer reads as a real search —\n // and the endpoint becomes an anonymous amplifier against that service.\n const token = await sessionToken();\n if (token === undefined) {\n return problemResponse(new Unauthenticated());\n }\n\n const params = new URL(request.url).searchParams;\n\n const asked = (params.get(SEARCH_SOURCES_PARAM) ?? '')\n .split(',')\n .filter(name => name !== '');\n const unknown = asked.find(name => !byKey.has(name));\n if (unknown !== undefined) {\n // Loud rather than ignored: no keystroke can produce this, only a caller\n // naming a source that does not exist — and silently searching everything\n // instead would answer a question nobody asked.\n return problemResponse(\n new InvalidQuery({ reason: `unknown search source \"${unknown}\"` }),\n );\n }\n const selected =\n asked.length === 0\n ? sources\n : sources.filter(source => asked.includes(source.key));\n\n const term = (params.get(SEARCH_TERM_PARAM) ?? '').trim();\n const answer = (body: RecordSearchResponse) =>\n // The body is scoped to one principal and one organization. `no-store` is\n // correctness here, not tuning.\n NextResponse.json(body, { headers: { 'cache-control': 'no-store' } });\n\n if (term.length < MIN_TERM_LENGTH) {\n return answer({ term, groups: [], unavailable: [] });\n }\n\n const limit = clampLimit(params.get(SEARCH_LIMIT_PARAM), defaultLimit);\n const outcomes = await Promise.all(\n selected.map(source => runSource(source, term, limit, token, timeoutMs)),\n );\n\n return answer({\n term,\n // Declared order, never completion order — otherwise the list reshuffles\n // with the network and nobody can learn where anything lands.\n groups: outcomes.flatMap(outcome => (outcome.ok ? [outcome.group] : [])),\n unavailable: outcomes.flatMap(outcome =>\n outcome.ok ? [] : [outcome.unavailable],\n ),\n });\n };\n};\n"],"names":["decodeProblem","InvalidQuery","ProtocolFailure","Timeout","Unauthenticated","UpstreamUnavailable","NextResponse","problemResponse","bearerHeader","sessionToken","SEARCH_TERM_PARAM","SEARCH_SOURCES_PARAM","SEARCH_LIMIT_PARAM","MIN_TERM_LENGTH","DEFAULT_GROUP_LIMIT","MAX_GROUP_LIMIT","DEFAULT_SOURCE_TIMEOUT_MS","unavailable","source","failure","status","ok","key","entity","reason","code","category","undefined","runSource","term","limit","token","timeoutMs","upstream","fetch","url","headers","cache","signal","AbortSignal","timeout","error","name","dependency","body","json","catch","page","read","upstreamStatus","group","labelKey","items","total","clampLimit","raw","fallback","asked","Number","isInteger","Math","min","createRecordSearchRoute","sources","defaultLimit","byKey","Map","map","GET","request","params","URL","searchParams","get","split","filter","unknown","find","has","selected","length","includes","trim","answer","groups","outcomes","Promise","all","flatMap","outcome"],"mappings":";AAAA,SACEA,aAAa,EAEbC,YAAY,EACZC,eAAe,EACfC,OAAO,EACPC,eAAe,EACfC,mBAAmB,QACd,gBAAgB;AACvB,SAASC,YAAY,QAAQ,cAAc;AAE3C,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,YAAY,EAAEC,YAAY,QAAQ,uBAAuB;AAQlE,OAAO,MAAMC,oBAAoB,IAAI;AACrC,OAAO,MAAMC,uBAAuB,UAAU;AAC9C,OAAO,MAAMC,qBAAqB,QAAQ;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n decodeProblem,\n defaultLocale,\n type EntifixFailure,\n InvalidQuery,\n isLocale,\n type Locale,\n LOCALE_COOKIE,\n LOCALE_HEADER,\n ProtocolFailure,\n Timeout,\n Unauthenticated,\n UpstreamUnavailable,\n} from '@entifix/core';\nimport { NextResponse } from 'next/server';\n\nimport { problemResponse } from '../config/problem-response.js';\nimport { bearerHeader, sessionToken } from '../session/bearer.js';\nimport type {\n RecordSearchGroup,\n RecordSearchResponse,\n RecordSearchUnavailable,\n} from './record-search.types.js';\nimport type { RecordSearchSource } from './record-search-source.js';\n\nexport const SEARCH_TERM_PARAM = 'q';\nexport const SEARCH_SOURCES_PARAM = 'sources';\nexport const SEARCH_LIMIT_PARAM = 'limit';\n/** The reader's locale, which a localized member is searched, sorted and read in. */\nexport const SEARCH_LOCALE_PARAM = 'locale';\n\n/**\n * Below this, nothing is queried at all.\n *\n * A `like` becomes an unanchored `$regex` that ignores accents and case, which no index can\n * serve — so this endpoint is a collection scan by construction. One character\n * matches most of every collection and is worth nothing to the person typing, so\n * the floor costs them nothing and saves four scans per keystroke.\n */\nexport const MIN_TERM_LENGTH = 2;\nexport const DEFAULT_GROUP_LIMIT = 5;\nexport const MAX_GROUP_LIMIT = 20;\nexport const DEFAULT_SOURCE_TIMEOUT_MS = 1_500;\n\nexport interface RecordSearchRouteOptions {\n /**\n * The sources to fan out over, **in the order results are presented**. That\n * order is the ranking: an operator learns where a kind of record lands, which\n * a relevance score across four unrelated entities cannot offer.\n */\n readonly sources: readonly RecordSearchSource[];\n /** Per-source budget. Concurrent, so this also bounds the whole request. */\n readonly timeoutMs?: number;\n /** Records per group. */\n readonly limit?: number;\n}\n\ntype SourceOutcome =\n | { readonly ok: true; readonly group: RecordSearchGroup }\n | { readonly ok: false; readonly unavailable: RecordSearchUnavailable };\n\nconst unavailable = (\n source: RecordSearchSource,\n failure: EntifixFailure,\n status?: number,\n): SourceOutcome => ({\n ok: false,\n unavailable: {\n source: source.key,\n entity: source.entity,\n reason: failure.code,\n category: failure.category,\n ...(status === undefined ? {} : { status }),\n },\n});\n\n/**\n * Ask one source, and **never reject**.\n *\n * Returning a typed outcome rather than throwing is what makes the fan-out a\n * plain `Promise.all`: isolation comes from this catch, not from\n * `allSettled` — whose rejected arm would then be unreachable and untestable.\n */\nconst runSource = async (\n source: RecordSearchSource,\n term: string,\n limit: number,\n locale: Locale,\n token: string | undefined,\n timeoutMs: number,\n): Promise<SourceOutcome> => {\n let upstream: Response;\n try {\n upstream = await fetch(source.url(term, limit, locale), {\n headers: bearerHeader(token),\n cache: 'no-store',\n signal: AbortSignal.timeout(timeoutMs),\n });\n } catch (error) {\n // `AbortSignal.timeout` rejects with a `DOMException` named `TimeoutError`;\n // branching on the name rather than the class keeps this reachable from a\n // test without fabricating a platform error.\n return unavailable(\n source,\n (error as { name?: string }).name === 'TimeoutError'\n ? new Timeout({ dependency: source.key })\n : new UpstreamUnavailable({ upstream: source.key }),\n );\n }\n\n // The service says why, in a problem body; the code is the reason. A body\n // that is not one decodes as `protocol` — still named, never silent.\n if (!upstream.ok) {\n const body: unknown = await upstream.json().catch(() => undefined);\n return unavailable(\n source,\n decodeProblem(body, upstream.status),\n upstream.status,\n );\n }\n\n const body = await upstream.json().catch(() => undefined);\n const page = source.read(body, locale);\n return page === undefined\n ? unavailable(\n source,\n new ProtocolFailure({\n reason: `${source.key} answered a page the source cannot read`,\n upstreamStatus: upstream.status,\n }),\n upstream.status,\n )\n : {\n ok: true,\n group: {\n source: source.key,\n entity: source.entity,\n labelKey: source.labelKey,\n items: page.items,\n total: page.total,\n },\n };\n};\n\n/**\n * The locale a search runs in: the one the caller names, else the one the\n * host's locale proxy forwarded, else the reader's locale cookie, else the\n * host's default. Anything that is not a declared locale is passed over.\n */\nconst requestLocale = (request: Request, params: URLSearchParams): Locale => {\n const cookie = (request.headers.get('cookie') ?? '')\n .split(';')\n .map(part => part.trim().split('='))\n .find(([name]) => name === LOCALE_COOKIE)?.[1];\n return (\n [\n params.get(SEARCH_LOCALE_PARAM),\n request.headers.get(LOCALE_HEADER),\n cookie,\n ].find(isLocale) ?? defaultLocale()\n );\n};\n\nconst clampLimit = (raw: string | null, fallback: number): number => {\n const asked = Number(raw);\n if (!Number.isInteger(asked) || asked < 1) return fallback;\n return Math.min(asked, MAX_GROUP_LIMIT);\n};\n\n/**\n * `GET /api/search` — records matching a term, across every source this host\n * mounts.\n *\n * The caller's own session is the only credential that crosses: each source is\n * asked over the same guarded route its screens use, so what comes back is\n * already authorized for this principal and this organization. There is no\n * index, and there must never be one — a prefetched index is a tenant leak, and\n * it is the reason this is a fan-out rather than a search service.\n *\n * A source that fails is **named** in `unavailable` rather than dropped. An\n * absent group renders as \"no matches\", which is a confident claim the server is\n * in no position to make about a service it could not reach.\n */\nexport const createRecordSearchRoute = ({\n sources,\n timeoutMs = DEFAULT_SOURCE_TIMEOUT_MS,\n limit: defaultLimit = DEFAULT_GROUP_LIMIT,\n}: RecordSearchRouteOptions) => {\n const byKey = new Map(sources.map(source => [source.key, source]));\n\n return async function GET(request: Request): Promise<Response> {\n // The services decide what this caller may read; this only carries the\n // token. But the gate is not redundant: `catalog-reference` reads are\n // unauthenticated at the service by design, so without it a signed-out\n // caller gets brand matches back and the answer reads as a real search —\n // and the endpoint becomes an anonymous amplifier against that service.\n const token = await sessionToken();\n if (token === undefined) {\n return problemResponse(new Unauthenticated());\n }\n\n const params = new URL(request.url).searchParams;\n\n const asked = (params.get(SEARCH_SOURCES_PARAM) ?? '')\n .split(',')\n .filter(name => name !== '');\n const unknown = asked.find(name => !byKey.has(name));\n if (unknown !== undefined) {\n // Loud rather than ignored: no keystroke can produce this, only a caller\n // naming a source that does not exist — and silently searching everything\n // instead would answer a question nobody asked.\n return problemResponse(\n new InvalidQuery({ reason: `unknown search source \"${unknown}\"` }),\n );\n }\n const selected =\n asked.length === 0\n ? sources\n : sources.filter(source => asked.includes(source.key));\n\n const term = (params.get(SEARCH_TERM_PARAM) ?? '').trim();\n const answer = (body: RecordSearchResponse) =>\n // The body is scoped to one principal and one organization. `no-store` is\n // correctness here, not tuning.\n NextResponse.json(body, { headers: { 'cache-control': 'no-store' } });\n\n if (term.length < MIN_TERM_LENGTH) {\n return answer({ term, groups: [], unavailable: [] });\n }\n\n const limit = clampLimit(params.get(SEARCH_LIMIT_PARAM), defaultLimit);\n const locale = requestLocale(request, params);\n const outcomes = await Promise.all(\n selected.map(source =>\n runSource(source, term, limit, locale, token, timeoutMs),\n ),\n );\n\n return answer({\n term,\n // Declared order, never completion order — otherwise the list reshuffles\n // with the network and nobody can learn where anything lands.\n groups: outcomes.flatMap(outcome => (outcome.ok ? [outcome.group] : [])),\n unavailable: outcomes.flatMap(outcome =>\n outcome.ok ? [] : [outcome.unavailable],\n ),\n });\n };\n};\n"],"names":["decodeProblem","defaultLocale","InvalidQuery","isLocale","LOCALE_COOKIE","LOCALE_HEADER","ProtocolFailure","Timeout","Unauthenticated","UpstreamUnavailable","NextResponse","problemResponse","bearerHeader","sessionToken","SEARCH_TERM_PARAM","SEARCH_SOURCES_PARAM","SEARCH_LIMIT_PARAM","SEARCH_LOCALE_PARAM","MIN_TERM_LENGTH","DEFAULT_GROUP_LIMIT","MAX_GROUP_LIMIT","DEFAULT_SOURCE_TIMEOUT_MS","unavailable","source","failure","status","ok","key","entity","reason","code","category","undefined","runSource","term","limit","locale","token","timeoutMs","upstream","fetch","url","headers","cache","signal","AbortSignal","timeout","error","name","dependency","body","json","catch","page","read","upstreamStatus","group","labelKey","items","total","requestLocale","request","params","cookie","get","split","map","part","trim","find","clampLimit","raw","fallback","asked","Number","isInteger","Math","min","createRecordSearchRoute","sources","defaultLimit","byKey","Map","GET","URL","searchParams","filter","unknown","has","selected","length","includes","answer","groups","outcomes","Promise","all","flatMap","outcome"],"mappings":";AAAA,SACEA,aAAa,EACbC,aAAa,EAEbC,YAAY,EACZC,QAAQ,EAERC,aAAa,EACbC,aAAa,EACbC,eAAe,EACfC,OAAO,EACPC,eAAe,EACfC,mBAAmB,QACd,gBAAgB;AACvB,SAASC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,aAAayC,IAAI,CAACD,MAAM;gBAAER,SAAS;oBAAE,iBAAiB;gBAAW;YAAE;QAErE,IAAIR,KAAKwD,MAAM,GAAGxE,iBAAiB;YACjC,OAAO0E,OAAO;gBAAE1D;gBAAM2D,QAAQ,EAAE;gBAAEvE,aAAa,EAAE;YAAC;QACpD;QAEA,MAAMa,QAAQmC,WAAWR,OAAOE,GAAG,CAAChD,qBAAqBgE;QACzD,MAAM5C,SAASwB,cAAcC,SAASC;QACtC,MAAMgC,WAAW,MAAMC,QAAQC,GAAG,CAChCP,SAASvB,GAAG,CAAC3C,CAAAA,SACXU,UAAUV,QAAQW,MAAMC,OAAOC,QAAQC,OAAOC;QAIlD,OAAOsD,OAAO;YACZ1D;YACA,yEAAyE;YACzE,8DAA8D;YAC9D2D,QAAQC,SAASG,OAAO,CAACC,CAAAA,UAAYA,QAAQxE,EAAE,GAAG;oBAACwE,QAAQ1C,KAAK;iBAAC,GAAG,EAAE;YACtElC,aAAawE,SAASG,OAAO,CAACC,CAAAA,UAC5BA,QAAQxE,EAAE,GAAG,EAAE,GAAG;oBAACwE,QAAQ5E,WAAW;iBAAC;QAE3C;IACF;AACF,EAAE"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Entity, type EntityConstructor } from '@entifix/core';
|
|
1
|
+
import { type Entity, type EntityConstructor, type Locale } from '@entifix/core';
|
|
2
2
|
import type { RecordSearchOption } from './record-search.types.js';
|
|
3
3
|
/**
|
|
4
4
|
* What a host declares in order to make one entity searchable from the palette.
|
|
@@ -33,9 +33,16 @@ export interface RecordSearchSource {
|
|
|
33
33
|
readonly entity: string;
|
|
34
34
|
readonly labelKey: string;
|
|
35
35
|
/** The upstream URL for one term. */
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
/**
|
|
37
|
+
* The upstream URL for one term, in the reader's locale — which a localized
|
|
38
|
+
* search or label member is filtered and sorted in.
|
|
39
|
+
*/
|
|
40
|
+
readonly url: (term: string, limit: number, locale: Locale) => string;
|
|
41
|
+
/**
|
|
42
|
+
* `undefined` when the body is not a readable `entityPage` envelope. A
|
|
43
|
+
* localized label reads in `locale`.
|
|
44
|
+
*/
|
|
45
|
+
readonly read: (body: unknown, locale: Locale) => {
|
|
39
46
|
items: RecordSearchOption[];
|
|
40
47
|
total: number;
|
|
41
48
|
} | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-search-source.d.ts","sourceRoot":"","sources":["../../../src/lib/search/record-search-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"record-search-source.d.ts","sourceRoot":"","sources":["../../../src/lib/search/record-search-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,MAAM,EACX,KAAK,iBAAiB,EAItB,KAAK,MAAM,EAKZ,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE;;;;;;;;;GASG;AACH,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,MAAM;IAC9D,sEAAsE;IACtE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACvD,uEAAuE;IACvE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,sDAAsD;IACtD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,mDAAmD;IACnD,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED,qEAAqE;AACrE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAC;IACtE;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,CACb,IAAI,EAAE,OAAO,EACb,MAAM,EAAE,MAAM,KACX;QAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;CACjE;AAgBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wBAAwB,GAAI,OAAO,SAAS,MAAM,EAAE,uGAS9D,wBAAwB,CAAC,OAAO,CAAC,KAAG,kBA+ItC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
-
import { describeEntityColumns, envelopeEntityName, readEntityPageEnvelope, serializeLoadRequestParams } from '@entifix/core';
|
|
2
|
+
import { describeEntityColumns, envelopeEntityName, localizedQueryProperty, queryPropertyFor, readEntityPageEnvelope, serializeLoadRequestParams } from '@entifix/core';
|
|
3
3
|
import { Effect, Exit } from 'effect';
|
|
4
4
|
const descriptorOf = (columns, name)=>columns.find((column)=>column.name === name);
|
|
5
5
|
const rejection = (entityName, member, because, fix)=>new Error(`Cannot search ${entityName} by "${member}": ${because} ${fix}`);
|
|
@@ -30,9 +30,10 @@ const rejection = (entityName, member, because, fix)=>new Error(`Cannot search $
|
|
|
30
30
|
}
|
|
31
31
|
// A `like` against anything else reaches `coerceValue`, which rejects a
|
|
32
32
|
// partial term — so an enum member reads as declarable and is permanently
|
|
33
|
-
// broken: every keystroke short of a whole value answers `400`.
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// broken: every keystroke short of a whole value answers `400`. A localized
|
|
34
|
+
// member is text too, searched in the reader's locale.
|
|
35
|
+
if (search.type !== 'string' && search.type !== 'localized') {
|
|
36
|
+
throw rejection(entityName, searchProperty, `the member is a ${search.type}, and a partial term is not a valid value for it.`, 'Search a string or localized member instead.');
|
|
36
37
|
}
|
|
37
38
|
const label = descriptorOf(columns, labelProperty);
|
|
38
39
|
if (label === undefined) {
|
|
@@ -41,12 +42,8 @@ const rejection = (entityName, member, because, fix)=>new Error(`Cannot search $
|
|
|
41
42
|
// The group is sorted by the label, so the flag is load-bearing: without it
|
|
42
43
|
// the service rejects the sort and the group degrades whole. Unsorted was the
|
|
43
44
|
// alternative and is worse — the services apply no default order, so results
|
|
44
|
-
// would arrive in storage order and shuffle as records are rewritten.
|
|
45
|
-
//
|
|
46
|
-
// across services holds none: the bare member would answer `400`.
|
|
47
|
-
if (label.type === 'localized') {
|
|
48
|
-
throw rejection(entityName, labelProperty, 'the label member is localized, and the search has no locale to sort it in.', 'Label records by a string member.');
|
|
49
|
-
}
|
|
45
|
+
// would arrive in storage order and shuffle as records are rewritten. A
|
|
46
|
+
// localized label sorts in the reader's locale.
|
|
50
47
|
if (!label.sortable) {
|
|
51
48
|
throw rejection(entityName, labelProperty, 'the label member is not sortable, so the service would reject the sort.', 'Declare it `sortable` on the entity, or label records by another member.');
|
|
52
49
|
}
|
|
@@ -57,22 +54,23 @@ const rejection = (entityName, member, because, fix)=>new Error(`Cannot search $
|
|
|
57
54
|
throw rejection(entityName, sublabelProperty, 'the entity declares no such sublabel member.', 'Name a member the entity actually has, or drop `sublabelProperty`.');
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
|
-
const read = (body)=>{
|
|
57
|
+
const read = (body, locale)=>{
|
|
61
58
|
const page = Effect.runSyncExit(readEntityPageEnvelope(entityConstructor, body));
|
|
62
59
|
if (Exit.isFailure(page)) return undefined;
|
|
63
60
|
const items = page.value.items.filter((record)=>record.id != null).map((record)=>{
|
|
64
61
|
const row = record;
|
|
65
|
-
const raw = row[labelProperty];
|
|
62
|
+
const raw = localizedQueryProperty(label, locale).read(row[labelProperty]);
|
|
66
63
|
const id = String(record.id);
|
|
64
|
+
const sublabelText = sublabel === undefined ? undefined : localizedQueryProperty(sublabel, locale).read(row[sublabel.name]);
|
|
67
65
|
return _extends({
|
|
68
66
|
id,
|
|
69
67
|
// A blank label is as useless as a missing one, so both fall back to
|
|
70
68
|
// the id — an unnamed record must stay distinguishable from the one
|
|
71
69
|
// above it. Same rule the relation picker's `labelOf` applies.
|
|
72
|
-
label: raw
|
|
73
|
-
},
|
|
74
|
-
sublabel:
|
|
75
|
-
}
|
|
70
|
+
label: raw === undefined || raw === '' ? id : raw
|
|
71
|
+
}, sublabelText === undefined ? {} : {
|
|
72
|
+
sublabel: sublabelText
|
|
73
|
+
}, {
|
|
76
74
|
entity,
|
|
77
75
|
href: href(id)
|
|
78
76
|
});
|
|
@@ -91,11 +89,11 @@ const rejection = (entityName, member, because, fix)=>new Error(`Cannot search $
|
|
|
91
89
|
* correctness rather than tidiness: `encodeRsqlValue` quotes a term carrying
|
|
92
90
|
* any of `;,()'"=!<>\` or whitespace, so `Acme, Inc.` stays one value
|
|
93
91
|
* instead of splitting the expression into two comparisons.
|
|
94
|
-
*/ url: (term, limit)=>{
|
|
92
|
+
*/ url: (term, limit, locale)=>{
|
|
95
93
|
const request = {
|
|
96
94
|
filtering: [
|
|
97
95
|
{
|
|
98
|
-
property: search
|
|
96
|
+
property: queryPropertyFor(search, locale),
|
|
99
97
|
operator: 'like',
|
|
100
98
|
value: term
|
|
101
99
|
}
|
|
@@ -103,7 +101,7 @@ const rejection = (entityName, member, because, fix)=>new Error(`Cannot search $
|
|
|
103
101
|
sorting: [
|
|
104
102
|
{
|
|
105
103
|
0: {
|
|
106
|
-
property: label
|
|
104
|
+
property: queryPropertyFor(label, locale),
|
|
107
105
|
type: 'asc'
|
|
108
106
|
}
|
|
109
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/search/record-search-source.ts"],"sourcesContent":["import {\n describeEntityColumns,\n type Entity,\n type EntityConstructor,\n type EntityFieldDescriptor,\n type EntityLoadRequest,\n envelopeEntityName,\n readEntityPageEnvelope,\n serializeLoadRequestParams,\n} from '@entifix/core';\nimport { Effect, Exit } from 'effect';\n\nimport type { RecordSearchOption } from './record-search.types.js';\n\n/**\n * What a host declares in order to make one entity searchable from the palette.\n *\n * The search and label members are **declared**, not derived, and that is not an\n * oversight in the metadata: `linkSearchProperty`/`linkLabelProperty` are\n * properties of a *referring* accessor — they say how the owner of a relation\n * looks up its target — and an entity has no member that says \"this is what I am\n * called\". So the host that mounts the screens says it, next to the route those\n * screens live at.\n */\nexport interface RecordSearchSourceConfig<TEntity extends Entity> {\n /** Stable id, unique per host. Defaults to the entity's wire name. */\n readonly key?: string;\n readonly entityConstructor: EntityConstructor<TEntity>;\n /** Where the owning service listens, **without** the `/api` suffix. */\n readonly baseUrl: string;\n /** The `filterable` string member a term is matched against with `like`. */\n readonly searchProperty: string;\n /** The `sortable` member read as a record's label. */\n readonly labelProperty: string;\n /** An optional secondary line — a code, a role. */\n readonly sublabelProperty?: string;\n /** The group heading, as the entity's own `pluralKey`. */\n readonly labelKey: string;\n /** Where selecting a record lands. Locale-free; the caller prefixes it. */\n readonly href: (id: string) => string;\n}\n\n/** A declared source, reduced to what the fan-out actually calls. */\nexport interface RecordSearchSource {\n readonly key: string;\n readonly entity: string;\n readonly labelKey: string;\n /** The upstream URL for one term. */\n readonly url: (term: string, limit: number) => string;\n /** `undefined` when the body is not a readable `entityPage` envelope. */\n readonly read: (\n body: unknown,\n ) => { items: RecordSearchOption[]; total: number } | undefined;\n}\n\nconst descriptorOf = (\n columns: EntityFieldDescriptor[],\n name: string,\n): EntityFieldDescriptor | undefined =>\n columns.find(column => column.name === name);\n\nconst rejection = (\n entityName: string,\n member: string,\n because: string,\n fix: string,\n): Error =>\n new Error(`Cannot search ${entityName} by \"${member}\": ${because} ${fix}`);\n\n/**\n * Declare a record search source, validating it against the entity's own\n * metadata **now** rather than on the first keystroke.\n *\n * Every check here guards a failure that is otherwise silent at both ends: the\n * service answers `400`, and a caller renders that as a group it could not\n * reach — which reads as \"there are no products\". `assertSearchable` took the\n * same posture for the relation picker, for the same reason.\n *\n * ⚠️ This throws at **module load**, so a bad declaration fails the whole app at\n * boot rather than just search. That is deliberate — a source silently missing\n * from a palette is indistinguishable from a permission the caller lacks — but\n * the blast radius is wider than the picker's, which fails only its own render.\n */\nexport const defineRecordSearchSource = <TEntity extends Entity>({\n key,\n entityConstructor,\n baseUrl,\n searchProperty,\n labelProperty,\n sublabelProperty,\n labelKey,\n href,\n}: RecordSearchSourceConfig<TEntity>): RecordSearchSource => {\n const entity = envelopeEntityName(entityConstructor);\n const entityName = entityConstructor.name;\n const columns = describeEntityColumns(entityConstructor);\n\n const search = descriptorOf(columns, searchProperty);\n if (search === undefined) {\n throw rejection(\n entityName,\n searchProperty,\n 'the entity declares no such member.',\n 'Name a member the entity actually has.',\n );\n }\n // `filterable` is simultaneously the server-side RSQL allowlist.\n if (!search.filterable) {\n throw rejection(\n entityName,\n searchProperty,\n 'the member is not filterable, so the service would reject the query.',\n 'Declare it `filterable` on the entity, or search another member.',\n );\n }\n // A `like` against anything else reaches `coerceValue`, which rejects a\n // partial term — so an enum member reads as declarable and is permanently\n // broken: every keystroke short of a whole value answers `400`.\n if (search.type !== 'string') {\n throw rejection(\n entityName,\n searchProperty,\n `the member is a ${search.type}, and a partial term is not a valid value for it.`,\n 'Search a string member instead.',\n );\n }\n\n const label = descriptorOf(columns, labelProperty);\n if (label === undefined) {\n throw rejection(\n entityName,\n labelProperty,\n 'the entity declares no such label member.',\n 'Name a member the entity actually has.',\n );\n }\n // The group is sorted by the label, so the flag is load-bearing: without it\n // the service rejects the sort and the group degrades whole. Unsorted was the\n // alternative and is worse — the services apply no default order, so results\n // would arrive in storage order and shuffle as records are rewritten.\n // A localized label sorts one locale at a time, and a search that fans out\n // across services holds none: the bare member would answer `400`.\n if (label.type === 'localized') {\n throw rejection(\n entityName,\n labelProperty,\n 'the label member is localized, and the search has no locale to sort it in.',\n 'Label records by a string member.',\n );\n }\n if (!label.sortable) {\n throw rejection(\n entityName,\n labelProperty,\n 'the label member is not sortable, so the service would reject the sort.',\n 'Declare it `sortable` on the entity, or label records by another member.',\n );\n }\n\n let sublabel: EntityFieldDescriptor | undefined;\n if (sublabelProperty !== undefined) {\n sublabel = descriptorOf(columns, sublabelProperty);\n if (sublabel === undefined) {\n throw rejection(\n entityName,\n sublabelProperty,\n 'the entity declares no such sublabel member.',\n 'Name a member the entity actually has, or drop `sublabelProperty`.',\n );\n }\n }\n\n const read = (\n body: unknown,\n ): { items: RecordSearchOption[]; total: number } | undefined => {\n const page = Effect.runSyncExit(\n readEntityPageEnvelope(entityConstructor, body),\n );\n if (Exit.isFailure(page)) return undefined;\n\n const items = page.value.items\n .filter(record => (record as Entity).id != null)\n .map(record => {\n const row = record as unknown as Record<string, unknown>;\n const raw = row[labelProperty];\n const id = String((record as Entity).id);\n return {\n id,\n // A blank label is as useless as a missing one, so both fall back to\n // the id — an unnamed record must stay distinguishable from the one\n // above it. Same rule the relation picker's `labelOf` applies.\n label: raw == null || raw === '' ? id : String(raw),\n ...(sublabel !== undefined && row[sublabel.name] != null\n ? { sublabel: String(row[sublabel.name]) }\n : {}),\n entity,\n href: href(id),\n } satisfies RecordSearchOption;\n });\n\n return { items, total: page.value.total };\n };\n\n return {\n key: key ?? entity,\n entity,\n labelKey,\n /**\n * Built through `serializeLoadRequestParams`, never by hand. That is\n * correctness rather than tidiness: `encodeRsqlValue` quotes a term carrying\n * any of `;,()'\"=!<>\\` or whitespace, so `Acme, Inc.` stays one value\n * instead of splitting the expression into two comparisons.\n */\n url: (term, limit) => {\n const request = {\n filtering: [\n {\n property: search.key,\n operator: 'like' as const,\n value: term,\n },\n ],\n sorting: [{ 0: { property: label.key, type: 'asc' as const } }],\n page: 1,\n pageSize: limit,\n } as unknown as EntityLoadRequest;\n\n return `${baseUrl}/api/${entity}?${serializeLoadRequestParams(request).toString()}`;\n },\n read,\n };\n};\n"],"names":["describeEntityColumns","envelopeEntityName","readEntityPageEnvelope","serializeLoadRequestParams","Effect","Exit","descriptorOf","columns","name","find","column","rejection","entityName","member","because","fix","Error","defineRecordSearchSource","key","entityConstructor","baseUrl","searchProperty","labelProperty","sublabelProperty","labelKey","href","entity","search","undefined","filterable","type","label","sortable","sublabel","read","body","page","runSyncExit","isFailure","items","value","filter","record","id","map","row","raw","String","total","url","term","limit","request","filtering","property","operator","sorting","pageSize","toString"],"mappings":";AAAA,SACEA,qBAAqB,EAKrBC,kBAAkB,EAClBC,sBAAsB,EACtBC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AA6CtC,MAAMC,eAAe,CACnBC,SACAC,OAEAD,QAAQE,IAAI,CAACC,CAAAA,SAAUA,OAAOF,IAAI,KAAKA;AAEzC,MAAMG,YAAY,CAChBC,YACAC,QACAC,SACAC,MAEA,IAAIC,MAAM,CAAC,cAAc,EAAEJ,WAAW,KAAK,EAAEC,OAAO,GAAG,EAAEC,QAAQ,CAAC,EAAEC,KAAK;AAE3E;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAME,2BAA2B,CAAyB,EAC/DC,GAAG,EACHC,iBAAiB,EACjBC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,EACRC,IAAI,EAC8B;IAClC,MAAMC,SAASzB,mBAAmBkB;IAClC,MAAMP,aAAaO,kBAAkBX,IAAI;IACzC,MAAMD,UAAUP,sBAAsBmB;IAEtC,MAAMQ,SAASrB,aAAaC,SAASc;IACrC,IAAIM,WAAWC,WAAW;QACxB,MAAMjB,UACJC,YACAS,gBACA,uCACA;IAEJ;IACA,iEAAiE;IACjE,IAAI,CAACM,OAA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QAAQA,QAAQ,KAAKH,KAAKI,OAAOD;eAC3Cb,aAAaL,aAAaiB,GAAG,CAACZ,SAASzB,IAAI,CAAC,IAAI,OAChD;gBAAEyB,UAAUc,OAAOF,GAAG,CAACZ,SAASzB,IAAI,CAAC;YAAE,IACvC,CAAC;gBACLkB;gBACAD,MAAMA,KAAKkB;;QAEf;QAEF,OAAO;YAAEJ;YAAOS,OAAOZ,KAAKI,KAAK,CAACQ,KAAK;QAAC;IAC1C;IAEA,OAAO;QACL9B,GAAG,EAAEA,cAAAA,MAAOQ;QACZA;QACAF;QACA;;;;;KAKC,GACDyB,KAAK,CAACC,MAAMC;YACV,MAAMC,UAAU;gBACdC,WAAW;oBACT;wBACEC,UAAU3B,OAAOT,GAAG;wBACpBqC,UAAU;wBACVf,OAAOU;oBACT;iBACD;gBACDM,SAAS;oBAAC;wBAAE,GAAG;4BAAEF,UAAUvB,MAAMb,GAAG;4BAAEY,MAAM;wBAAe;oBAAE;iBAAE;gBAC/DM,MAAM;gBACNqB,UAAUN;YACZ;YAEA,OAAO,GAAG/B,QAAQ,KAAK,EAAEM,OAAO,CAAC,EAAEvB,2BAA2BiD,SAASM,QAAQ,IAAI;QACrF;QACAxB;IACF;AACF,EAAE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/search/record-search-source.ts"],"sourcesContent":["import {\n describeEntityColumns,\n type Entity,\n type EntityConstructor,\n type EntityFieldDescriptor,\n type EntityLoadRequest,\n envelopeEntityName,\n type Locale,\n localizedQueryProperty,\n queryPropertyFor,\n readEntityPageEnvelope,\n serializeLoadRequestParams,\n} from '@entifix/core';\nimport { Effect, Exit } from 'effect';\n\nimport type { RecordSearchOption } from './record-search.types.js';\n\n/**\n * What a host declares in order to make one entity searchable from the palette.\n *\n * The search and label members are **declared**, not derived, and that is not an\n * oversight in the metadata: `linkSearchProperty`/`linkLabelProperty` are\n * properties of a *referring* accessor — they say how the owner of a relation\n * looks up its target — and an entity has no member that says \"this is what I am\n * called\". So the host that mounts the screens says it, next to the route those\n * screens live at.\n */\nexport interface RecordSearchSourceConfig<TEntity extends Entity> {\n /** Stable id, unique per host. Defaults to the entity's wire name. */\n readonly key?: string;\n readonly entityConstructor: EntityConstructor<TEntity>;\n /** Where the owning service listens, **without** the `/api` suffix. */\n readonly baseUrl: string;\n /** The `filterable` string member a term is matched against with `like`. */\n readonly searchProperty: string;\n /** The `sortable` member read as a record's label. */\n readonly labelProperty: string;\n /** An optional secondary line — a code, a role. */\n readonly sublabelProperty?: string;\n /** The group heading, as the entity's own `pluralKey`. */\n readonly labelKey: string;\n /** Where selecting a record lands. Locale-free; the caller prefixes it. */\n readonly href: (id: string) => string;\n}\n\n/** A declared source, reduced to what the fan-out actually calls. */\nexport interface RecordSearchSource {\n readonly key: string;\n readonly entity: string;\n readonly labelKey: string;\n /** The upstream URL for one term. */\n /**\n * The upstream URL for one term, in the reader's locale — which a localized\n * search or label member is filtered and sorted in.\n */\n readonly url: (term: string, limit: number, locale: Locale) => string;\n /**\n * `undefined` when the body is not a readable `entityPage` envelope. A\n * localized label reads in `locale`.\n */\n readonly read: (\n body: unknown,\n locale: Locale,\n ) => { items: RecordSearchOption[]; total: number } | undefined;\n}\n\nconst descriptorOf = (\n columns: EntityFieldDescriptor[],\n name: string,\n): EntityFieldDescriptor | undefined =>\n columns.find(column => column.name === name);\n\nconst rejection = (\n entityName: string,\n member: string,\n because: string,\n fix: string,\n): Error =>\n new Error(`Cannot search ${entityName} by \"${member}\": ${because} ${fix}`);\n\n/**\n * Declare a record search source, validating it against the entity's own\n * metadata **now** rather than on the first keystroke.\n *\n * Every check here guards a failure that is otherwise silent at both ends: the\n * service answers `400`, and a caller renders that as a group it could not\n * reach — which reads as \"there are no products\". `assertSearchable` took the\n * same posture for the relation picker, for the same reason.\n *\n * ⚠️ This throws at **module load**, so a bad declaration fails the whole app at\n * boot rather than just search. That is deliberate — a source silently missing\n * from a palette is indistinguishable from a permission the caller lacks — but\n * the blast radius is wider than the picker's, which fails only its own render.\n */\nexport const defineRecordSearchSource = <TEntity extends Entity>({\n key,\n entityConstructor,\n baseUrl,\n searchProperty,\n labelProperty,\n sublabelProperty,\n labelKey,\n href,\n}: RecordSearchSourceConfig<TEntity>): RecordSearchSource => {\n const entity = envelopeEntityName(entityConstructor);\n const entityName = entityConstructor.name;\n const columns = describeEntityColumns(entityConstructor);\n\n const search = descriptorOf(columns, searchProperty);\n if (search === undefined) {\n throw rejection(\n entityName,\n searchProperty,\n 'the entity declares no such member.',\n 'Name a member the entity actually has.',\n );\n }\n // `filterable` is simultaneously the server-side RSQL allowlist.\n if (!search.filterable) {\n throw rejection(\n entityName,\n searchProperty,\n 'the member is not filterable, so the service would reject the query.',\n 'Declare it `filterable` on the entity, or search another member.',\n );\n }\n // A `like` against anything else reaches `coerceValue`, which rejects a\n // partial term — so an enum member reads as declarable and is permanently\n // broken: every keystroke short of a whole value answers `400`. A localized\n // member is text too, searched in the reader's locale.\n if (search.type !== 'string' && search.type !== 'localized') {\n throw rejection(\n entityName,\n searchProperty,\n `the member is a ${search.type}, and a partial term is not a valid value for it.`,\n 'Search a string or localized member instead.',\n );\n }\n\n const label = descriptorOf(columns, labelProperty);\n if (label === undefined) {\n throw rejection(\n entityName,\n labelProperty,\n 'the entity declares no such label member.',\n 'Name a member the entity actually has.',\n );\n }\n // The group is sorted by the label, so the flag is load-bearing: without it\n // the service rejects the sort and the group degrades whole. Unsorted was the\n // alternative and is worse — the services apply no default order, so results\n // would arrive in storage order and shuffle as records are rewritten. A\n // localized label sorts in the reader's locale.\n if (!label.sortable) {\n throw rejection(\n entityName,\n labelProperty,\n 'the label member is not sortable, so the service would reject the sort.',\n 'Declare it `sortable` on the entity, or label records by another member.',\n );\n }\n\n let sublabel: EntityFieldDescriptor | undefined;\n if (sublabelProperty !== undefined) {\n sublabel = descriptorOf(columns, sublabelProperty);\n if (sublabel === undefined) {\n throw rejection(\n entityName,\n sublabelProperty,\n 'the entity declares no such sublabel member.',\n 'Name a member the entity actually has, or drop `sublabelProperty`.',\n );\n }\n }\n\n const read = (\n body: unknown,\n locale: Locale,\n ): { items: RecordSearchOption[]; total: number } | undefined => {\n const page = Effect.runSyncExit(\n readEntityPageEnvelope(entityConstructor, body),\n );\n if (Exit.isFailure(page)) return undefined;\n\n const items = page.value.items\n .filter(record => (record as Entity).id != null)\n .map(record => {\n const row = record as unknown as Record<string, unknown>;\n const raw = localizedQueryProperty(label, locale).read(\n row[labelProperty],\n );\n const id = String((record as Entity).id);\n const sublabelText =\n sublabel === undefined\n ? undefined\n : localizedQueryProperty(sublabel, locale).read(row[sublabel.name]);\n return {\n id,\n // A blank label is as useless as a missing one, so both fall back to\n // the id — an unnamed record must stay distinguishable from the one\n // above it. Same rule the relation picker's `labelOf` applies.\n label: raw === undefined || raw === '' ? id : raw,\n ...(sublabelText === undefined ? {} : { sublabel: sublabelText }),\n entity,\n href: href(id),\n } satisfies RecordSearchOption;\n });\n\n return { items, total: page.value.total };\n };\n\n return {\n key: key ?? entity,\n entity,\n labelKey,\n /**\n * Built through `serializeLoadRequestParams`, never by hand. That is\n * correctness rather than tidiness: `encodeRsqlValue` quotes a term carrying\n * any of `;,()'\"=!<>\\` or whitespace, so `Acme, Inc.` stays one value\n * instead of splitting the expression into two comparisons.\n */\n url: (term, limit, locale) => {\n const request = {\n filtering: [\n {\n property: queryPropertyFor(search, locale),\n operator: 'like' as const,\n value: term,\n },\n ],\n sorting: [\n {\n 0: {\n property: queryPropertyFor(label, locale),\n type: 'asc' as const,\n },\n },\n ],\n page: 1,\n pageSize: limit,\n } as unknown as EntityLoadRequest;\n\n return `${baseUrl}/api/${entity}?${serializeLoadRequestParams(request).toString()}`;\n },\n read,\n };\n};\n"],"names":["describeEntityColumns","envelopeEntityName","localizedQueryProperty","queryPropertyFor","readEntityPageEnvelope","serializeLoadRequestParams","Effect","Exit","descriptorOf","columns","name","find","column","rejection","entityName","member","because","fix","Error","defineRecordSearchSource","key","entityConstructor","baseUrl","searchProperty","labelProperty","sublabelProperty","labelKey","href","entity","search","undefined","filterable","type","label","sortable","sublabel","read","body","locale","page","runSyncExit","isFailure","items","value","filter","record","id","map","row","raw","String","sublabelText","total","url","term","limit","request","filtering","property","operator","sorting","pageSize","toString"],"mappings":";AAAA,SACEA,qBAAqB,EAKrBC,kBAAkB,EAElBC,sBAAsB,EACtBC,gBAAgB,EAChBC,sBAAsB,EACtBC,0BAA0B,QACrB,gBAAgB;AACvB,SAASC,MAAM,EAAEC,IAAI,QAAQ,SAAS;AAqDtC,MAAMC,eAAe,CACnBC,SACAC,OAEAD,QAAQE,IAAI,CAACC,CAAAA,SAAUA,OAAOF,IAAI,KAAKA;AAEzC,MAAMG,YAAY,CAChBC,YACAC,QACAC,SACAC,MAEA,IAAIC,MAAM,CAAC,cAAc,EAAEJ,WAAW,KAAK,EAAEC,OAAO,GAAG,EAAEC,QAAQ,CAAC,EAAEC,KAAK;AAE3E;;;;;;;;;;;;;CAaC,GACD,OAAO,MAAME,2BAA2B,CAAyB,EAC/DC,GAAG,EACHC,iBAAiB,EACjBC,OAAO,EACPC,cAAc,EACdC,aAAa,EACbC,gBAAgB,EAChBC,QAAQ,EACRC,IAAI,EAC8B;IAClC,MAAMC,SAAS3B,mBAAmBoB;IAClC,MAAMP,aAAaO,kBAAkBX,IAAI;IACzC,MAAMD,UAAUT,sBAAsBqB;IAEtC,MAAMQ,SAASrB,aAAaC,SAASc;IACrC,IAAIM,WAAWC,WAAW;QACxB,MAAMjB,UACJC,YACAS,gBACA,uCACA;IAEJ;IACA,iEAAiE;IACjE,IAAI,CAACM,OAAOE,UAAU,EAAE;QACtB,MAAMlB,UACJC,YACAS,gBACA,wEACA;IAEJ;IACA,wEAAwE;IACxE,0EAA0E;IAC1E,4EAA4E;IAC5E,uDAAuD;IACvD,IAAIM,OAAOG,IAAI,KAAK,YAAYH,OAAOG,IAAI,KAAK,aAAa;QAC3D,MAAMnB,UACJC,YACAS,gBACA,CAAC,gBAAgB,EAAEM,OAAOG,IAAI,CAAC,iDAAiD,CAAC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,KAAK,CAACS,KAAK;QAAC;IAC1C;IAEA,OAAO;QACLhC,GAAG,EAAEA,cAAAA,MAAOQ;QACZA;QACAF;QACA;;;;;KAKC,GACD2B,KAAK,CAACC,MAAMC,OAAOjB;YACjB,MAAMkB,UAAU;gBACdC,WAAW;oBACT;wBACEC,UAAUvD,iBAAiB0B,QAAQS;wBACnCqB,UAAU;wBACVhB,OAAOW;oBACT;iBACD;gBACDM,SAAS;oBACP;wBACE,GAAG;4BACDF,UAAUvD,iBAAiB8B,OAAOK;4BAClCN,MAAM;wBACR;oBACF;iBACD;gBACDO,MAAM;gBACNsB,UAAUN;YACZ;YAEA,OAAO,GAAGjC,QAAQ,KAAK,EAAEM,OAAO,CAAC,EAAEvB,2BAA2BmD,SAASM,QAAQ,IAAI;QACrF;QACA1B;IACF;AACF,EAAE"}
|
|
@@ -55,9 +55,10 @@ export interface RecordSearchGroup {
|
|
|
55
55
|
readonly source: string;
|
|
56
56
|
readonly entity: string;
|
|
57
57
|
/**
|
|
58
|
-
* The heading, as the entity's own `pluralKey`. A key rather than copy
|
|
59
|
-
*
|
|
60
|
-
*
|
|
58
|
+
* The heading, as the entity's own `pluralKey`. A key rather than copy:
|
|
59
|
+
* the entity catalogs already carry one for every source, so record search
|
|
60
|
+
* introduces no copy of its own. (The search runs in the reader's locale,
|
|
61
|
+
* but only a localized member's value depends on it.)
|
|
61
62
|
*/
|
|
62
63
|
readonly labelKey: string;
|
|
63
64
|
readonly items: readonly RecordSearchOption[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record-search.types.d.ts","sourceRoot":"","sources":["../../../src/lib/search/record-search.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD;;;;;;;GAOG;AAEH;;;;;;;;;;;;GAYG;AACH;;;;;;GAMG;AACH,MAAM,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEnD,iDAAiD;AACjD,MAAM,WAAW,kBAA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,SAAS,kBAAkB,EAAE,CAAC;IAC9C;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,6BAA6B,CAAC;IAC/C,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC9C,QAAQ,CAAC,WAAW,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/search/record-search.types.ts"],"sourcesContent":["import type { FailureCategory } from '@entifix/core';\n\n/**\n * The wire contract of `GET /api/search` — the cross-domain record search the\n * command palette reads.\n *\n * Types only, so both halves can name them: the route handler builds these on\n * the server, and the browser's `searchRecords` returns them. A type crosses the\n * client/server entry split freely because it erases.\n */\n\n/**\n * Why a source produced no group.\n *\n * The split is the point, and it is not cosmetic. `forbidden` and\n * `noActiveOrganization` are the **normal** state for some callers on some\n * sources — an operator holds no membership, so every tenant-plane search\n * answers `409` — and rendering \"we could not reach this\" for the ordinary case\n * teaches an operator to ignore the warning. `timeout`/`network`/`unexpected`\n * are the ones that mean something is actually wrong.\n *\n * Every member is a key in the shared `errors` catalog, so a caller renders one\n * through the documented runtime-key hatch rather than inventing copy.\n */\n/**\n * Why a source produced nothing: the code of the failure it answered with,\n * decoded from its problem body — `noActiveOrganization`, `forbidden`,\n * `upstreamUnavailable` — or `timeout` when it never answered in time. A\n * code, so the browser renders it through the `errors` catalog like any other\n * refusal.\n */\nexport type RecordSearchUnavailableReason = string;\n\n/** One record a caller can show and route to. */\nexport interface RecordSearchOption {\n readonly id: string;\n readonly label: string;\n /** A secondary line — a code, a role. Absent when the source declared none. */\n readonly sublabel?: string;\n /**\n * `envelopeEntityName(Ctor)` — `key ?? name`.\n *\n * Repeated on every option rather than left to the group, because an option is\n * routed on its own once a caller has flattened the list: `['entity', entity]`\n * is exactly `entityQueryScope`'s output, and `entity:<entity>:<id>` is the\n * workspace tab address.\n */\n readonly entity: string;\n /**\n * Where selecting this record lands, **without** a locale prefix — the caller\n * adds one, the same way every other internal href in the back office works.\n */\n readonly href: string;\n}\n\n/** One source's answer. */\nexport interface RecordSearchGroup {\n /** The source's declared key. Stable, and the caller's ordering. */\n readonly source: string;\n readonly entity: string;\n /**\n * The heading, as the entity's own `pluralKey`. A key rather than copy
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/search/record-search.types.ts"],"sourcesContent":["import type { FailureCategory } from '@entifix/core';\n\n/**\n * The wire contract of `GET /api/search` — the cross-domain record search the\n * command palette reads.\n *\n * Types only, so both halves can name them: the route handler builds these on\n * the server, and the browser's `searchRecords` returns them. A type crosses the\n * client/server entry split freely because it erases.\n */\n\n/**\n * Why a source produced no group.\n *\n * The split is the point, and it is not cosmetic. `forbidden` and\n * `noActiveOrganization` are the **normal** state for some callers on some\n * sources — an operator holds no membership, so every tenant-plane search\n * answers `409` — and rendering \"we could not reach this\" for the ordinary case\n * teaches an operator to ignore the warning. `timeout`/`network`/`unexpected`\n * are the ones that mean something is actually wrong.\n *\n * Every member is a key in the shared `errors` catalog, so a caller renders one\n * through the documented runtime-key hatch rather than inventing copy.\n */\n/**\n * Why a source produced nothing: the code of the failure it answered with,\n * decoded from its problem body — `noActiveOrganization`, `forbidden`,\n * `upstreamUnavailable` — or `timeout` when it never answered in time. A\n * code, so the browser renders it through the `errors` catalog like any other\n * refusal.\n */\nexport type RecordSearchUnavailableReason = string;\n\n/** One record a caller can show and route to. */\nexport interface RecordSearchOption {\n readonly id: string;\n readonly label: string;\n /** A secondary line — a code, a role. Absent when the source declared none. */\n readonly sublabel?: string;\n /**\n * `envelopeEntityName(Ctor)` — `key ?? name`.\n *\n * Repeated on every option rather than left to the group, because an option is\n * routed on its own once a caller has flattened the list: `['entity', entity]`\n * is exactly `entityQueryScope`'s output, and `entity:<entity>:<id>` is the\n * workspace tab address.\n */\n readonly entity: string;\n /**\n * Where selecting this record lands, **without** a locale prefix — the caller\n * adds one, the same way every other internal href in the back office works.\n */\n readonly href: string;\n}\n\n/** One source's answer. */\nexport interface RecordSearchGroup {\n /** The source's declared key. Stable, and the caller's ordering. */\n readonly source: string;\n readonly entity: string;\n /**\n * The heading, as the entity's own `pluralKey`. A key rather than copy:\n * the entity catalogs already carry one for every source, so record search\n * introduces no copy of its own. (The search runs in the reader's locale,\n * but only a localized member's value depends on it.)\n */\n readonly labelKey: string;\n readonly items: readonly RecordSearchOption[];\n /**\n * Matches **before** the per-group limit, so \"3 more\" is renderable. A\n * reachable source with no matches is a present group with an empty `items`,\n * never an omission — that distinction is the whole reason\n * {@link RecordSearchResponse.unavailable} exists.\n */\n readonly total: number;\n}\n\n/** One source that produced nothing, and why. */\nexport interface RecordSearchUnavailable {\n readonly source: string;\n readonly entity: string;\n readonly reason: RecordSearchUnavailableReason;\n /** The failure's category: what decides whether this is scope or an outage. */\n readonly category: FailureCategory;\n /** The upstream status, when there was a response. Absent on a throw. */\n readonly status?: number;\n}\n\n/**\n * The whole answer.\n *\n * A degraded source is **named**, never a silently missing group. An empty group\n * is a confident claim that there are no matching records, and a search that\n * confidently reports nothing when it in fact could not look is the failure\n * mode this shape exists to prevent.\n */\nexport interface RecordSearchResponse {\n readonly term: string;\n readonly groups: readonly RecordSearchGroup[];\n readonly unavailable: readonly RecordSearchUnavailable[];\n}\n"],"names":[],"mappings":"AAwFA;;;;;;;CAOC,GACD,WAIC"}
|
|
@@ -8,6 +8,8 @@ export interface SearchRecordsOptions {
|
|
|
8
8
|
readonly sources?: readonly string[];
|
|
9
9
|
/** Records per group. */
|
|
10
10
|
readonly limit?: number;
|
|
11
|
+
/** The reader's locale, which a localized member is searched and read in. */
|
|
12
|
+
readonly locale?: string;
|
|
11
13
|
}
|
|
12
14
|
/**
|
|
13
15
|
* Ask the back office for records matching `term`.
|
|
@@ -21,5 +23,5 @@ export interface SearchRecordsOptions {
|
|
|
21
23
|
* cross-origin call would carry no session and every group would come back
|
|
22
24
|
* unavailable.
|
|
23
25
|
*/
|
|
24
|
-
export declare const searchRecords: (term: string, { signal, sources, limit }?: SearchRecordsOptions) => Promise<RecordSearchResponse>;
|
|
26
|
+
export declare const searchRecords: (term: string, { signal, sources, limit, locale }?: SearchRecordsOptions) => Promise<RecordSearchResponse>;
|
|
25
27
|
//# sourceMappingURL=search-records.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-records.d.ts","sourceRoot":"","sources":["../../../src/lib/search/search-records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"search-records.d.ts","sourceRoot":"","sources":["../../../src/lib/search/search-records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,qCAAoC,oBAAyB,KAC5D,OAAO,CAAC,oBAAoB,CAqB9B,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
11
11
|
* Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a
|
|
12
12
|
* cross-origin call would carry no session and every group would come back
|
|
13
13
|
* unavailable.
|
|
14
|
-
*/ export const searchRecords = async (term, { signal, sources, limit } = {})=>{
|
|
14
|
+
*/ export const searchRecords = async (term, { signal, sources, limit, locale } = {})=>{
|
|
15
15
|
const params = new URLSearchParams({
|
|
16
16
|
q: term
|
|
17
17
|
});
|
|
@@ -19,6 +19,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
19
19
|
params.set('sources', sources.join(','));
|
|
20
20
|
}
|
|
21
21
|
if (limit !== undefined) params.set('limit', String(limit));
|
|
22
|
+
if (locale !== undefined) params.set('locale', locale);
|
|
22
23
|
const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, _extends({
|
|
23
24
|
cache: 'no-store'
|
|
24
25
|
}, signal === undefined ? {} : {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/search/search-records.ts"],"sourcesContent":["import type { RecordSearchResponse } from './record-search.types.js';\n\n/** Where the aggregating route is mounted. Same-origin, so the cookie rides along. */\nexport const RECORD_SEARCH_PATH = '/api/search';\n\nexport interface SearchRecordsOptions {\n /** Aborts an in-flight request when the term moves on. */\n readonly signal?: AbortSignal;\n /** Narrow the fan-out to these source keys. Omit to ask every source. */\n readonly sources?: readonly string[];\n /** Records per group. */\n readonly limit?: number;\n}\n\n/**\n * Ask the back office for records matching `term`.\n *\n * Deliberately framework-free — no React, no router, no debounce, no retry. It\n * is a typed `fetch`, so the palette can own its own keystroke policy (which is\n * where debounce and abort belong) and a server component or a test can call the\n * same function.\n *\n * Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a\n * cross-origin call would carry no session and every group would come back\n * unavailable.\n */\nexport const searchRecords = async (\n term: string,\n { signal, sources, limit }: SearchRecordsOptions = {},\n): Promise<RecordSearchResponse> => {\n const params = new URLSearchParams({ q: term });\n if (sources !== undefined && sources.length > 0) {\n params.set('sources', sources.join(','));\n }\n if (limit !== undefined) params.set('limit', String(limit));\n\n const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, {\n cache: 'no-store',\n ...(signal === undefined ? {} : { signal }),\n });\n\n if (!response.ok) {\n // The route answers `401` for a lapsed session and `400` for a caller naming\n // a source that does not exist. Neither is a per-source degradation — those\n // arrive inside a `200` — so both are the caller's to handle.\n throw new Error(`record search failed with ${response.status}`);\n }\n\n return (await response.json()) as RecordSearchResponse;\n};\n"],"names":["RECORD_SEARCH_PATH","searchRecords","term","signal","sources","limit","params","URLSearchParams","q","undefined","length","set","join","String","response","fetch","toString","cache","ok","Error","status","json"],"mappings":";AAEA,oFAAoF,GACpF,OAAO,MAAMA,qBAAqB,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/search/search-records.ts"],"sourcesContent":["import type { RecordSearchResponse } from './record-search.types.js';\n\n/** Where the aggregating route is mounted. Same-origin, so the cookie rides along. */\nexport const RECORD_SEARCH_PATH = '/api/search';\n\nexport interface SearchRecordsOptions {\n /** Aborts an in-flight request when the term moves on. */\n readonly signal?: AbortSignal;\n /** Narrow the fan-out to these source keys. Omit to ask every source. */\n readonly sources?: readonly string[];\n /** Records per group. */\n readonly limit?: number;\n /** The reader's locale, which a localized member is searched and read in. */\n readonly locale?: string;\n}\n\n/**\n * Ask the back office for records matching `term`.\n *\n * Deliberately framework-free — no React, no router, no debounce, no retry. It\n * is a typed `fetch`, so the palette can own its own keystroke policy (which is\n * where debounce and abort belong) and a server component or a test can call the\n * same function.\n *\n * Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a\n * cross-origin call would carry no session and every group would come back\n * unavailable.\n */\nexport const searchRecords = async (\n term: string,\n { signal, sources, limit, locale }: SearchRecordsOptions = {},\n): Promise<RecordSearchResponse> => {\n const params = new URLSearchParams({ q: term });\n if (sources !== undefined && sources.length > 0) {\n params.set('sources', sources.join(','));\n }\n if (limit !== undefined) params.set('limit', String(limit));\n if (locale !== undefined) params.set('locale', locale);\n\n const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, {\n cache: 'no-store',\n ...(signal === undefined ? {} : { signal }),\n });\n\n if (!response.ok) {\n // The route answers `401` for a lapsed session and `400` for a caller naming\n // a source that does not exist. Neither is a per-source degradation — those\n // arrive inside a `200` — so both are the caller's to handle.\n throw new Error(`record search failed with ${response.status}`);\n }\n\n return (await response.json()) as RecordSearchResponse;\n};\n"],"names":["RECORD_SEARCH_PATH","searchRecords","term","signal","sources","limit","locale","params","URLSearchParams","q","undefined","length","set","join","String","response","fetch","toString","cache","ok","Error","status","json"],"mappings":";AAEA,oFAAoF,GACpF,OAAO,MAAMA,qBAAqB,cAAc;AAahD;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,gBAAgB,OAC3BC,MACA,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAwB,GAAG,CAAC,CAAC;IAE7D,MAAMC,SAAS,IAAIC,gBAAgB;QAAEC,GAAGP;IAAK;IAC7C,IAAIE,YAAYM,aAAaN,QAAQO,MAAM,GAAG,GAAG;QAC/CJ,OAAOK,GAAG,CAAC,WAAWR,QAAQS,IAAI,CAAC;IACrC;IACA,IAAIR,UAAUK,WAAWH,OAAOK,GAAG,CAAC,SAASE,OAAOT;IACpD,IAAIC,WAAWI,WAAWH,OAAOK,GAAG,CAAC,UAAUN;IAE/C,MAAMS,WAAW,MAAMC,MAAM,GAAGhB,mBAAmB,CAAC,EAAEO,OAAOU,QAAQ,IAAI,EAAE;QACzEC,OAAO;OACHf,WAAWO,YAAY,CAAC,IAAI;QAAEP;IAAO;IAG3C,IAAI,CAACY,SAASI,EAAE,EAAE;QAChB,6EAA6E;QAC7E,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEL,SAASM,MAAM,EAAE;IAChE;IAEA,OAAQ,MAAMN,SAASO,IAAI;AAC7B,EAAE"}
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
"version": "0.
|
|
24
|
+
"version": "0.22.0",
|
|
25
25
|
"description": "Next.js application shell: back-office chrome, workspace tabs, CRUD screens derived from entity metadata, and session and proxy routes.",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"repository": {
|
|
@@ -57,17 +57,17 @@
|
|
|
57
57
|
"react": "19.3.1",
|
|
58
58
|
"react-dom": "19.3.1",
|
|
59
59
|
"zustand": "^5.1.0",
|
|
60
|
-
"@entifix/testing-unit": "0.
|
|
60
|
+
"@entifix/testing-unit": "0.22.0"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"idb": "^8.0.4",
|
|
64
|
-
"@entifix/authz": "0.
|
|
65
|
-
"@entifix/business": "0.
|
|
66
|
-
"@entifix/core": "0.
|
|
67
|
-
"@entifix/i18n": "0.
|
|
68
|
-
"@entifix/react-controls": "0.
|
|
69
|
-
"@entifix/react-integration": "0.
|
|
70
|
-
"@entifix/transactions": "0.
|
|
64
|
+
"@entifix/authz": "0.22.0",
|
|
65
|
+
"@entifix/business": "0.22.0",
|
|
66
|
+
"@entifix/core": "0.22.0",
|
|
67
|
+
"@entifix/i18n": "0.22.0",
|
|
68
|
+
"@entifix/react-controls": "0.22.0",
|
|
69
|
+
"@entifix/react-integration": "0.22.0",
|
|
70
|
+
"@entifix/transactions": "0.22.0"
|
|
71
71
|
},
|
|
72
72
|
"files": [
|
|
73
73
|
"dist",
|