@entifix/next-shell 0.20.3 → 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.
Files changed (62) hide show
  1. package/README.md +16 -1
  2. package/dist/lib/command-palette/use-records-source.d.ts.map +1 -1
  3. package/dist/lib/command-palette/use-records-source.js +5 -2
  4. package/dist/lib/command-palette/use-records-source.js.map +1 -1
  5. package/dist/lib/crud/index.d.ts +2 -0
  6. package/dist/lib/crud/index.d.ts.map +1 -1
  7. package/dist/lib/crud/index.js +2 -0
  8. package/dist/lib/crud/index.js.map +1 -1
  9. package/dist/lib/crud/make-entity-crud.d.ts.map +1 -1
  10. package/dist/lib/crud/make-entity-crud.js +131 -58
  11. package/dist/lib/crud/make-entity-crud.js.map +1 -1
  12. package/dist/lib/crud/make-entity-crud.types.d.ts +68 -1
  13. package/dist/lib/crud/make-entity-crud.types.d.ts.map +1 -1
  14. package/dist/lib/crud/make-entity-crud.types.js.map +1 -1
  15. package/dist/lib/crud/reference-labels.d.ts +27 -0
  16. package/dist/lib/crud/reference-labels.d.ts.map +1 -0
  17. package/dist/lib/crud/reference-labels.js +159 -0
  18. package/dist/lib/crud/reference-labels.js.map +1 -0
  19. package/dist/lib/crud/regions.d.ts +25 -0
  20. package/dist/lib/crud/regions.d.ts.map +1 -0
  21. package/dist/lib/crud/regions.js +82 -0
  22. package/dist/lib/crud/regions.js.map +1 -0
  23. package/dist/lib/crud/related-columns.d.ts +29 -0
  24. package/dist/lib/crud/related-columns.d.ts.map +1 -0
  25. package/dist/lib/crud/related-columns.js +141 -0
  26. package/dist/lib/crud/related-columns.js.map +1 -0
  27. package/dist/lib/crud/use-entity-link-sources.d.ts.map +1 -1
  28. package/dist/lib/crud/use-entity-link-sources.js +5 -1
  29. package/dist/lib/crud/use-entity-link-sources.js.map +1 -1
  30. package/dist/lib/crud/use-entity-total.d.ts +27 -0
  31. package/dist/lib/crud/use-entity-total.d.ts.map +1 -0
  32. package/dist/lib/crud/use-entity-total.js +39 -0
  33. package/dist/lib/crud/use-entity-total.js.map +1 -0
  34. package/dist/lib/i18n/catalog/en.d.ts.map +1 -1
  35. package/dist/lib/i18n/catalog/en.js +6 -0
  36. package/dist/lib/i18n/catalog/en.js.map +1 -1
  37. package/dist/lib/i18n/catalog/es.d.ts +8 -0
  38. package/dist/lib/i18n/catalog/es.d.ts.map +1 -1
  39. package/dist/lib/i18n/catalog/es.js +7 -1
  40. package/dist/lib/i18n/catalog/es.js.map +1 -1
  41. package/dist/lib/i18n/catalog/index.d.ts +12 -0
  42. package/dist/lib/i18n/catalog/index.d.ts.map +1 -1
  43. package/dist/lib/search/record-search-route.d.ts +2 -0
  44. package/dist/lib/search/record-search-route.d.ts.map +1 -1
  45. package/dist/lib/search/record-search-route.js +21 -5
  46. package/dist/lib/search/record-search-route.js.map +1 -1
  47. package/dist/lib/search/record-search-source.d.ts +11 -4
  48. package/dist/lib/search/record-search-source.d.ts.map +1 -1
  49. package/dist/lib/search/record-search-source.js +17 -19
  50. package/dist/lib/search/record-search-source.js.map +1 -1
  51. package/dist/lib/search/record-search.types.d.ts +4 -3
  52. package/dist/lib/search/record-search.types.d.ts.map +1 -1
  53. package/dist/lib/search/record-search.types.js.map +1 -1
  54. package/dist/lib/search/search-records.d.ts +3 -1
  55. package/dist/lib/search/search-records.d.ts.map +1 -1
  56. package/dist/lib/search/search-records.js +2 -1
  57. package/dist/lib/search/search-records.js.map +1 -1
  58. package/package.json +9 -9
  59. package/dist/lib/crud/use-link-labels.d.ts +0 -32
  60. package/dist/lib/crud/use-link-labels.d.ts.map +0 -1
  61. package/dist/lib/crud/use-link-labels.js +0 -76
  62. package/dist/lib/crud/use-link-labels.js.map +0 -1
@@ -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"}
@@ -1 +1 @@
1
- {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/en.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,cAAc,SAAS,EAAE,KAAK,CAAC;AAE9C,eAAO,MAAM,KAAK,EAAE,OAqFnB,CAAC"}
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/en.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,cAAc,SAAS,EAAE,KAAK,CAAC;AAE9C,eAAO,MAAM,KAAK,EAAE,OA6FnB,CAAC"}
@@ -49,6 +49,12 @@ export const shell = {
49
49
  expandGroup: 'Expand {{group}}',
50
50
  collapseGroup: 'Collapse {{group}}'
51
51
  },
52
+ /** A list column whose value lives in another entity, when more than one record matches. */ /** The section nav above a record's related regions. */ regions: {
53
+ nav: 'Record sections'
54
+ },
55
+ related: {
56
+ count: '{{count}} {{noun}}'
57
+ },
52
58
  session: {
53
59
  expiringSoon: 'Your session is about to expire. Save your work and sign in again to continue.'
54
60
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/i18n/catalog/en.ts"],"sourcesContent":["type EsShell = typeof import('./es.js').shell;\n\nexport const shell: EsShell = {\n nav: {\n primary: 'Primary',\n openInWorkspace: 'Open in workspace',\n openInNewTab: 'Open in a new tab',\n /** The one menu beside each destination: open it elsewhere. */\n itemActions: 'Options for {{label}}',\n /**\n * The screen taxonomy. Translated like every other string rather\n * than kept in Spanish: what that decision fixed was which *Spanish* word\n * ships to the default locale, not that the term is untranslatable.\n */\n screenType: {\n master: 'Definitions',\n operation: 'Operations',\n wizard: 'Wizards',\n report: 'Reports',\n },\n },\n commandPalette: {\n open: 'Search or run',\n title: 'Search or run',\n placeholder: 'Search a record, a screen or a command…',\n newPlaceholder: 'What would you like to create?',\n newLabel: 'New…',\n newTitle: 'New',\n back: 'Back',\n empty: 'No results',\n loading: 'Searching…',\n more_one: '{{count}} more',\n more_other: '{{count}} more',\n typeMore: 'Type at least {{count}} characters to search records.',\n groups: {\n actions: 'Actions',\n commands: 'Commands',\n navigation: 'Navigation',\n tabs: 'Open tabs',\n records: 'Records',\n },\n unavailableScope: 'Not available here: {{reason}}',\n unavailableReach: 'We could not reach this source: {{reason}}',\n openInWorkspaceHint: 'Tab',\n },\n sidebar: {\n /** The page's first stop: past the navigation, to the content. */\n skipToContent: 'Skip to content',\n expand: 'Expand sidebar',\n collapse: 'Collapse sidebar',\n openMenu: 'Open the menu',\n closeMenu: 'Close the menu',\n menu: 'Navigation menu',\n expandGroup: 'Expand {{group}}',\n collapseGroup: 'Collapse {{group}}',\n },\n session: {\n expiringSoon:\n 'Your session is about to expire. Save your work and sign in again to continue.',\n },\n breadcrumbs: {\n home: 'Home',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'New',\n },\n account: {\n profile: 'Profile',\n security: 'Security',\n sessions: 'Sessions',\n signOut: 'Sign out',\n },\n workspace: {\n copyLink: 'Copy link',\n empty: 'No open tabs. Pick a catalog from the sidebar to start.',\n unsupported: \"This tab can't be opened here.\",\n discardTitle: 'Discard changes',\n discard: 'This tab has unsaved changes. Closing it will lose them.',\n discardConfirm: 'Discard',\n // See the Spanish catalog for why a failure's reason is not a key here.\n pendingLabel: 'Save status',\n savePending_one: 'Saving 1 record…',\n savePending_other: 'Saving {{count}} records…',\n saveFailed: 'The record could not be saved.',\n saveFailedDismiss: 'Dismiss',\n },\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInNewTab","itemActions","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","skipToContent","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAEA,OAAO,MAAMA,QAAiB;IAC5BC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,cAAc;QACd,6DAA6D,GAC7DC,aAAa;QACb;;;;KAIC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACAC,gBAAgB;QACdC,MAAM;QACNC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACVC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACAC,kBAAkB;QAClBC,kBAAkB;QAClBC,qBAAqB;IACvB;IACAC,SAAS;QACP,gEAAgE,GAChEC,eAAe;QACfC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACAC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACAC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVlC,OAAO;QACPmC,aAAa;QACbC,cAAc;QACdC,SAAS;QACTC,gBAAgB;QAChB,wEAAwE;QACxEC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/lib/i18n/catalog/en.ts"],"sourcesContent":["type EsShell = typeof import('./es.js').shell;\n\nexport const shell: EsShell = {\n nav: {\n primary: 'Primary',\n openInWorkspace: 'Open in workspace',\n openInNewTab: 'Open in a new tab',\n /** The one menu beside each destination: open it elsewhere. */\n itemActions: 'Options for {{label}}',\n /**\n * The screen taxonomy. Translated like every other string rather\n * than kept in Spanish: what that decision fixed was which *Spanish* word\n * ships to the default locale, not that the term is untranslatable.\n */\n screenType: {\n master: 'Definitions',\n operation: 'Operations',\n wizard: 'Wizards',\n report: 'Reports',\n },\n },\n commandPalette: {\n open: 'Search or run',\n title: 'Search or run',\n placeholder: 'Search a record, a screen or a command…',\n newPlaceholder: 'What would you like to create?',\n newLabel: 'New…',\n newTitle: 'New',\n back: 'Back',\n empty: 'No results',\n loading: 'Searching…',\n more_one: '{{count}} more',\n more_other: '{{count}} more',\n typeMore: 'Type at least {{count}} characters to search records.',\n groups: {\n actions: 'Actions',\n commands: 'Commands',\n navigation: 'Navigation',\n tabs: 'Open tabs',\n records: 'Records',\n },\n unavailableScope: 'Not available here: {{reason}}',\n unavailableReach: 'We could not reach this source: {{reason}}',\n openInWorkspaceHint: 'Tab',\n },\n sidebar: {\n /** The page's first stop: past the navigation, to the content. */\n skipToContent: 'Skip to content',\n expand: 'Expand sidebar',\n collapse: 'Collapse sidebar',\n openMenu: 'Open the menu',\n closeMenu: 'Close the menu',\n menu: 'Navigation menu',\n expandGroup: 'Expand {{group}}',\n collapseGroup: 'Collapse {{group}}',\n },\n /** A list column whose value lives in another entity, when more than one record matches. */\n /** The section nav above a record's related regions. */\n regions: {\n nav: 'Record sections',\n },\n related: {\n count: '{{count}} {{noun}}',\n },\n session: {\n expiringSoon:\n 'Your session is about to expire. Save your work and sign in again to continue.',\n },\n breadcrumbs: {\n home: 'Home',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'New',\n },\n account: {\n profile: 'Profile',\n security: 'Security',\n sessions: 'Sessions',\n signOut: 'Sign out',\n },\n workspace: {\n copyLink: 'Copy link',\n empty: 'No open tabs. Pick a catalog from the sidebar to start.',\n unsupported: \"This tab can't be opened here.\",\n discardTitle: 'Discard changes',\n discard: 'This tab has unsaved changes. Closing it will lose them.',\n discardConfirm: 'Discard',\n // See the Spanish catalog for why a failure's reason is not a key here.\n pendingLabel: 'Save status',\n savePending_one: 'Saving 1 record…',\n savePending_other: 'Saving {{count}} records…',\n saveFailed: 'The record could not be saved.',\n saveFailedDismiss: 'Dismiss',\n },\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInNewTab","itemActions","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","skipToContent","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","regions","related","count","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAEA,OAAO,MAAMA,QAAiB;IAC5BC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,cAAc;QACd,6DAA6D,GAC7DC,aAAa;QACb;;;;KAIC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACAC,gBAAgB;QACdC,MAAM;QACNC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACVC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACAC,kBAAkB;QAClBC,kBAAkB;QAClBC,qBAAqB;IACvB;IACAC,SAAS;QACP,gEAAgE,GAChEC,eAAe;QACfC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACXC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACA,0FAA0F,GAC1F,sDAAsD,GACtDC,SAAS;QACPzC,KAAK;IACP;IACA0C,SAAS;QACPC,OAAO;IACT;IACAC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACAC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVrC,OAAO;QACPsC,aAAa;QACbC,cAAc;QACdC,SAAS;QACTC,gBAAgB;QAChB,wEAAwE;QACxEC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AACF,EAAE"}
@@ -76,6 +76,14 @@ export declare const shell: {
76
76
  * thing: nothing here counts down, since a number that moves invites a person
77
77
  * to watch it rather than to save their work.
78
78
  */
79
+ /** A list column whose value lives in another entity, when more than one record matches. */
80
+ /** The section nav above a record's related regions. */
81
+ regions: {
82
+ nav: string;
83
+ };
84
+ related: {
85
+ count: string;
86
+ };
79
87
  session: {
80
88
  expiringSoon: string;
81
89
  };
@@ -1 +1 @@
1
- {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/es.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,KAAK;;;;;QAKd,+DAA+D;;QAE/D;;;;;;WAMG;;;;;;;;IAQL;;;;OAIG;;QAED,4EAA4E;;QAE5E,qDAAqD;;;;;QAKrD,4EAA4E;;;;;;;QAO5E,2EAA2E;;;;;;;;;QAS3E;;;;WAIG;;;QAGH,uEAAuE;;;;QAIvE,kEAAkE;;;;;;;;;;IAapE;;;;;OAKG;;;;;;;;IAYH;;;;OAIG;;;;;;;;;;;;;;;;;;;;CAkCJ,CAAC"}
1
+ {"version":3,"file":"es.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/es.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,eAAO,MAAM,KAAK;;;;;QAKd,+DAA+D;;QAE/D;;;;;;WAMG;;;;;;;;IAQL;;;;OAIG;;QAED,4EAA4E;;QAE5E,qDAAqD;;;;;QAKrD,4EAA4E;;;;;;;QAO5E,2EAA2E;;;;;;;;;QAS3E;;;;WAIG;;;QAGH,uEAAuE;;;;QAIvE,kEAAkE;;;;;;;;;;IAapE;;;;;OAKG;IACH,4FAA4F;IAC5F,wDAAwD;;;;;;;;;;;;;;IAkBxD;;;;OAIG;;;;;;;;;;;;;;;;;;;;CAkCJ,CAAC"}
@@ -67,7 +67,13 @@
67
67
  * window before the absolute ceiling. One key, because the strip says one
68
68
  * thing: nothing here counts down, since a number that moves invites a person
69
69
  * to watch it rather than to save their work.
70
- */ session: {
70
+ */ /** A list column whose value lives in another entity, when more than one record matches. */ /** The section nav above a record's related regions. */ regions: {
71
+ nav: 'Secciones del registro'
72
+ },
73
+ related: {
74
+ count: '{{count}} {{noun}}'
75
+ },
76
+ session: {
71
77
  expiringSoon: 'Tu sesión está por expirar. Guarda tu trabajo e inicia sesión de nuevo para continuar.'
72
78
  },
73
79
  breadcrumbs: {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/i18n/catalog/es.ts"],"sourcesContent":["/** Copy owned by the Next shells — back-office chrome and the tab workspace. */\nexport const shell = {\n nav: {\n primary: 'Principal',\n openInWorkspace: 'Abrir en el espacio de trabajo',\n openInNewTab: 'Abrir en una pestaña nueva',\n /** The one menu beside each destination: open it elsewhere. */\n itemActions: 'Opciones de {{label}}',\n /**\n * The screen taxonomy — the sidebar's top tier, above the\n * domain. `Definiciones` rather than `Maestros` because the ERP term needs\n * the ERP background to parse, and rather than `Catálogos` or `Referencias`\n * because both already mean something else here: the product catalog, and a\n * product's code in `storefront.category.sortByCode`.\n */\n screenType: {\n master: 'Definiciones',\n operation: 'Operaciones',\n wizard: 'Asistentes',\n report: 'Consultas',\n },\n },\n /**\n * La paleta de comandos. Vive en `shell:` y no en `controls:`\n * porque el control es agnóstico —recibe copia ya resuelta— y quien la\n * arma es el back office.\n */\n commandPalette: {\n /** El disparador visible, que existe justo porque un atajo puede fallar. */\n open: 'Buscar o ejecutar',\n /** El nombre accesible del diálogo y de su campo. */\n title: 'Buscar o ejecutar',\n placeholder: 'Busca un registro, una pantalla o un comando…',\n newPlaceholder: '¿Qué quieres crear?',\n newLabel: 'Nuevo…',\n /** El nombre de la página apilada, y también el del control para volver. */\n newTitle: 'Nuevo',\n back: 'Volver',\n empty: 'Sin resultados',\n loading: 'Buscando…',\n more_one: '{{count}} más',\n more_other: '{{count}} más',\n /** Escribe al menos dos caracteres — el suelo que impone `/api/search`. */\n typeMore: 'Escribe al menos {{count}} caracteres para buscar registros.',\n groups: {\n actions: 'Acciones',\n commands: 'Comandos',\n navigation: 'Navegación',\n tabs: 'Pestañas abiertas',\n records: 'Registros',\n },\n /**\n * Dos redacciones para dos cosas distintas: «no es tuyo» es el estado\n * **normal** de un operador sin organización, y pintarlo como avería en\n * cada tecleo enseña a ignorar el aviso que sí importa.\n */\n unavailableScope: 'No disponible aquí: {{reason}}',\n unavailableReach: 'No pudimos consultar este origen: {{reason}}',\n /** Sufijo del comando que abre un destino como pestaña del espacio. */\n openInWorkspaceHint: 'Pestaña',\n },\n sidebar: {\n /** The page's first stop: past the navigation, to the content. */\n skipToContent: 'Saltar al contenido',\n expand: 'Expandir barra lateral',\n collapse: 'Contraer barra lateral',\n openMenu: 'Abrir el menú',\n closeMenu: 'Cerrar el menú',\n // The drawer is a dialog, so it needs a name of its own — the landmark\n // inside it is the nav, and a dialog with no accessible name is announced\n // as just \"dialog\".\n menu: 'Menú de navegación',\n expandGroup: 'Desplegar {{group}}',\n collapseGroup: 'Plegar {{group}}',\n },\n /**\n * The session strip, rendered by `SessionKeepalive` only inside the final\n * window before the absolute ceiling. One key, because the strip says one\n * thing: nothing here counts down, since a number that moves invites a person\n * to watch it rather than to save their work.\n */\n session: {\n expiringSoon:\n 'Tu sesión está por expirar. Guarda tu trabajo e inicia sesión de nuevo para continuar.',\n },\n breadcrumbs: {\n home: 'Inicio',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'Nuevo',\n },\n /**\n * The account surface. The auth shell owns the screens, but `ACCOUNT_DESTINATIONS`\n * — the one list every app builds its menu from — lives in the shell, so the\n * shell owns their names too and resolves them itself.\n */\n account: {\n profile: 'Perfil',\n security: 'Seguridad',\n sessions: 'Sesiones',\n signOut: 'Cerrar sesión',\n },\n workspace: {\n copyLink: 'Copiar enlace',\n empty:\n 'No hay pestañas abiertas. Elige un catálogo en la barra lateral para empezar.',\n unsupported: 'Esta pestaña no se puede abrir aquí.',\n // The confirmation that guards closing a dirty tab. The title carries the\n // question, so the message states the consequence rather than repeating it\n // — it was phrased as a question while `window.confirm` rendered it, which\n // had nowhere to put a title.\n discardTitle: 'Descartar cambios',\n discard:\n 'Esta pestaña tiene cambios sin guardar. Si la cierras, se perderán.',\n discardConfirm: 'Descartar',\n // What became of a write the server has not finished. `count` is the\n // number in flight; a failure names no reason here, because the only one a\n // transaction carries is a server exception string in whatever language it\n // was written in — that is rendered beside this, unlocalized and marked so.\n pendingLabel: 'Estado de los guardados',\n savePending_one: 'Guardando 1 registro…',\n savePending_other: 'Guardando {{count}} registros…',\n saveFailed: 'No se pudo guardar el registro.',\n saveFailedDismiss: 'Descartar',\n },\n /**\n * The storefront. Its pages live in `shells-next-marketplace`, so its copy\n * lives here and not in an app catalog — `app:` is reserved for `apps/`.\n */\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInNewTab","itemActions","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","skipToContent","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAAA,8EAA8E,GAC9E,OAAO,MAAMA,QAAQ;IACnBC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,cAAc;QACd,6DAA6D,GAC7DC,aAAa;QACb;;;;;;KAMC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACA;;;;GAIC,GACDC,gBAAgB;QACd,0EAA0E,GAC1EC,MAAM;QACN,mDAAmD,GACnDC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACV,0EAA0E,GAC1EC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZ,yEAAyE,GACzEC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACA;;;;KAIC,GACDC,kBAAkB;QAClBC,kBAAkB;QAClB,qEAAqE,GACrEC,qBAAqB;IACvB;IACAC,SAAS;QACP,gEAAgE,GAChEC,eAAe;QACfC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACX,uEAAuE;QACvE,0EAA0E;QAC1E,oBAAoB;QACpBC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACA;;;;;GAKC,GACDC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACA;;;;GAIC,GACDC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVlC,OACE;QACFmC,aAAa;QACb,0EAA0E;QAC1E,2EAA2E;QAC3E,2EAA2E;QAC3E,8BAA8B;QAC9BC,cAAc;QACdC,SACE;QACFC,gBAAgB;QAChB,qEAAqE;QACrE,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5EC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AAKF,EAAE"}
1
+ {"version":3,"sources":["../../../../src/lib/i18n/catalog/es.ts"],"sourcesContent":["/** Copy owned by the Next shells — back-office chrome and the tab workspace. */\nexport const shell = {\n nav: {\n primary: 'Principal',\n openInWorkspace: 'Abrir en el espacio de trabajo',\n openInNewTab: 'Abrir en una pestaña nueva',\n /** The one menu beside each destination: open it elsewhere. */\n itemActions: 'Opciones de {{label}}',\n /**\n * The screen taxonomy — the sidebar's top tier, above the\n * domain. `Definiciones` rather than `Maestros` because the ERP term needs\n * the ERP background to parse, and rather than `Catálogos` or `Referencias`\n * because both already mean something else here: the product catalog, and a\n * product's code in `storefront.category.sortByCode`.\n */\n screenType: {\n master: 'Definiciones',\n operation: 'Operaciones',\n wizard: 'Asistentes',\n report: 'Consultas',\n },\n },\n /**\n * La paleta de comandos. Vive en `shell:` y no en `controls:`\n * porque el control es agnóstico —recibe copia ya resuelta— y quien la\n * arma es el back office.\n */\n commandPalette: {\n /** El disparador visible, que existe justo porque un atajo puede fallar. */\n open: 'Buscar o ejecutar',\n /** El nombre accesible del diálogo y de su campo. */\n title: 'Buscar o ejecutar',\n placeholder: 'Busca un registro, una pantalla o un comando…',\n newPlaceholder: '¿Qué quieres crear?',\n newLabel: 'Nuevo…',\n /** El nombre de la página apilada, y también el del control para volver. */\n newTitle: 'Nuevo',\n back: 'Volver',\n empty: 'Sin resultados',\n loading: 'Buscando…',\n more_one: '{{count}} más',\n more_other: '{{count}} más',\n /** Escribe al menos dos caracteres — el suelo que impone `/api/search`. */\n typeMore: 'Escribe al menos {{count}} caracteres para buscar registros.',\n groups: {\n actions: 'Acciones',\n commands: 'Comandos',\n navigation: 'Navegación',\n tabs: 'Pestañas abiertas',\n records: 'Registros',\n },\n /**\n * Dos redacciones para dos cosas distintas: «no es tuyo» es el estado\n * **normal** de un operador sin organización, y pintarlo como avería en\n * cada tecleo enseña a ignorar el aviso que sí importa.\n */\n unavailableScope: 'No disponible aquí: {{reason}}',\n unavailableReach: 'No pudimos consultar este origen: {{reason}}',\n /** Sufijo del comando que abre un destino como pestaña del espacio. */\n openInWorkspaceHint: 'Pestaña',\n },\n sidebar: {\n /** The page's first stop: past the navigation, to the content. */\n skipToContent: 'Saltar al contenido',\n expand: 'Expandir barra lateral',\n collapse: 'Contraer barra lateral',\n openMenu: 'Abrir el menú',\n closeMenu: 'Cerrar el menú',\n // The drawer is a dialog, so it needs a name of its own — the landmark\n // inside it is the nav, and a dialog with no accessible name is announced\n // as just \"dialog\".\n menu: 'Menú de navegación',\n expandGroup: 'Desplegar {{group}}',\n collapseGroup: 'Plegar {{group}}',\n },\n /**\n * The session strip, rendered by `SessionKeepalive` only inside the final\n * window before the absolute ceiling. One key, because the strip says one\n * thing: nothing here counts down, since a number that moves invites a person\n * to watch it rather than to save their work.\n */\n /** A list column whose value lives in another entity, when more than one record matches. */\n /** The section nav above a record's related regions. */\n regions: {\n nav: 'Secciones del registro',\n },\n related: {\n count: '{{count}} {{noun}}',\n },\n session: {\n expiringSoon:\n 'Tu sesión está por expirar. Guarda tu trabajo e inicia sesión de nuevo para continuar.',\n },\n breadcrumbs: {\n home: 'Inicio',\n // The `/new` segment, which every domain's create route shares. It was\n // an auth-specific string until one host started serving two domains,\n // at which point a catalog page's breadcrumb read \"New user\".\n new: 'Nuevo',\n },\n /**\n * The account surface. The auth shell owns the screens, but `ACCOUNT_DESTINATIONS`\n * — the one list every app builds its menu from — lives in the shell, so the\n * shell owns their names too and resolves them itself.\n */\n account: {\n profile: 'Perfil',\n security: 'Seguridad',\n sessions: 'Sesiones',\n signOut: 'Cerrar sesión',\n },\n workspace: {\n copyLink: 'Copiar enlace',\n empty:\n 'No hay pestañas abiertas. Elige un catálogo en la barra lateral para empezar.',\n unsupported: 'Esta pestaña no se puede abrir aquí.',\n // The confirmation that guards closing a dirty tab. The title carries the\n // question, so the message states the consequence rather than repeating it\n // — it was phrased as a question while `window.confirm` rendered it, which\n // had nowhere to put a title.\n discardTitle: 'Descartar cambios',\n discard:\n 'Esta pestaña tiene cambios sin guardar. Si la cierras, se perderán.',\n discardConfirm: 'Descartar',\n // What became of a write the server has not finished. `count` is the\n // number in flight; a failure names no reason here, because the only one a\n // transaction carries is a server exception string in whatever language it\n // was written in — that is rendered beside this, unlocalized and marked so.\n pendingLabel: 'Estado de los guardados',\n savePending_one: 'Guardando 1 registro…',\n savePending_other: 'Guardando {{count}} registros…',\n saveFailed: 'No se pudo guardar el registro.',\n saveFailedDismiss: 'Descartar',\n },\n /**\n * The storefront. Its pages live in `shells-next-marketplace`, so its copy\n * lives here and not in an app catalog — `app:` is reserved for `apps/`.\n */\n};\n"],"names":["shell","nav","primary","openInWorkspace","openInNewTab","itemActions","screenType","master","operation","wizard","report","commandPalette","open","title","placeholder","newPlaceholder","newLabel","newTitle","back","empty","loading","more_one","more_other","typeMore","groups","actions","commands","navigation","tabs","records","unavailableScope","unavailableReach","openInWorkspaceHint","sidebar","skipToContent","expand","collapse","openMenu","closeMenu","menu","expandGroup","collapseGroup","regions","related","count","session","expiringSoon","breadcrumbs","home","new","account","profile","security","sessions","signOut","workspace","copyLink","unsupported","discardTitle","discard","discardConfirm","pendingLabel","savePending_one","savePending_other","saveFailed","saveFailedDismiss"],"mappings":"AAAA,8EAA8E,GAC9E,OAAO,MAAMA,QAAQ;IACnBC,KAAK;QACHC,SAAS;QACTC,iBAAiB;QACjBC,cAAc;QACd,6DAA6D,GAC7DC,aAAa;QACb;;;;;;KAMC,GACDC,YAAY;YACVC,QAAQ;YACRC,WAAW;YACXC,QAAQ;YACRC,QAAQ;QACV;IACF;IACA;;;;GAIC,GACDC,gBAAgB;QACd,0EAA0E,GAC1EC,MAAM;QACN,mDAAmD,GACnDC,OAAO;QACPC,aAAa;QACbC,gBAAgB;QAChBC,UAAU;QACV,0EAA0E,GAC1EC,UAAU;QACVC,MAAM;QACNC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZ,yEAAyE,GACzEC,UAAU;QACVC,QAAQ;YACNC,SAAS;YACTC,UAAU;YACVC,YAAY;YACZC,MAAM;YACNC,SAAS;QACX;QACA;;;;KAIC,GACDC,kBAAkB;QAClBC,kBAAkB;QAClB,qEAAqE,GACrEC,qBAAqB;IACvB;IACAC,SAAS;QACP,gEAAgE,GAChEC,eAAe;QACfC,QAAQ;QACRC,UAAU;QACVC,UAAU;QACVC,WAAW;QACX,uEAAuE;QACvE,0EAA0E;QAC1E,oBAAoB;QACpBC,MAAM;QACNC,aAAa;QACbC,eAAe;IACjB;IACA;;;;;GAKC,GACD,0FAA0F,GAC1F,sDAAsD,GACtDC,SAAS;QACPzC,KAAK;IACP;IACA0C,SAAS;QACPC,OAAO;IACT;IACAC,SAAS;QACPC,cACE;IACJ;IACAC,aAAa;QACXC,MAAM;QACN,uEAAuE;QACvE,sEAAsE;QACtE,8DAA8D;QAC9DC,KAAK;IACP;IACA;;;;GAIC,GACDC,SAAS;QACPC,SAAS;QACTC,UAAU;QACVC,UAAU;QACVC,SAAS;IACX;IACAC,WAAW;QACTC,UAAU;QACVrC,OACE;QACFsC,aAAa;QACb,0EAA0E;QAC1E,2EAA2E;QAC3E,2EAA2E;QAC3E,8BAA8B;QAC9BC,cAAc;QACdC,SACE;QACFC,gBAAgB;QAChB,qEAAqE;QACrE,2EAA2E;QAC3E,2EAA2E;QAC3E,4EAA4E;QAC5EC,cAAc;QACdC,iBAAiB;QACjBC,mBAAmB;QACnBC,YAAY;QACZC,mBAAmB;IACrB;AAKF,EAAE"}
@@ -52,6 +52,12 @@ export declare const shellCatalogs: {
52
52
  expandGroup: string;
53
53
  collapseGroup: string;
54
54
  };
55
+ regions: {
56
+ nav: string;
57
+ };
58
+ related: {
59
+ count: string;
60
+ };
55
61
  session: {
56
62
  expiringSoon: string;
57
63
  };
@@ -128,6 +134,12 @@ export declare const shellCatalogs: {
128
134
  expandGroup: string;
129
135
  collapseGroup: string;
130
136
  };
137
+ regions: {
138
+ nav: string;
139
+ };
140
+ related: {
141
+ count: string;
142
+ };
131
143
  session: {
132
144
  expiringSoon: string;
133
145
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/index.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGhB,CAAC;AAEX,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB,oBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/i18n/catalog/index.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGhB,CAAC;AAEX,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC;AAE1D,eAAO,MAAM,gBAAgB,oBAAqB,CAAC"}
@@ -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":"AAkBA,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;AAE1C;;;;;;;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;AA8FD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,GAAI,8CAIrC,wBAAwB,MAGC,SAAS,OAAO,KAAG,OAAO,CAAC,QAAQ,CAuD9D,CAAC"}
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 outcomes = await Promise.all(selected.map((source)=>runSource(source, term, limit, token, timeoutMs)));
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;AAE1C;;;;;;;CAOC,GACD,OAAO,MAAMC,kBAAkB,EAAE;AACjC,OAAO,MAAMC,sBAAsB,EAAE;AACrC,OAAO,MAAMC,kBAAkB,GAAG;AAClC,OAAO,MAAMC,4BAA4B,KAAM;AAmB/C,MAAMC,cAAc,CAClBC,QACAC,SACAC,SACmB,CAAA;QACnBC,IAAI;QACJJ,aAAa;YACXC,QAAQA,OAAOI,GAAG;YAClBC,QAAQL,OAAOK,MAAM;YACrBC,QAAQL,QAAQM,IAAI;YACpBC,UAAUP,QAAQO,QAAQ;WACtBN,WAAWO,YAAY,CAAC,IAAI;YAAEP;QAAO;IAE7C,CAAA;AAEA;;;;;;CAMC,GACD,MAAMQ,YAAY,OAChBV,QACAW,MACAC,OACAC,OACAC;IAEA,IAAIC;IACJ,IAAI;QACFA,WAAW,MAAMC,MAAMhB,OAAOiB,GAAG,CAACN,MAAMC,QAAQ;YAC9CM,SAAS5B,aAAauB;YACtBM,OAAO;YACPC,QAAQC,YAAYC,OAAO,CAACR;QAC9B;IACF,EAAE,OAAOS,OAAO;QACd,4EAA4E;QAC5E,0EAA0E;QAC1E,6CAA6C;QAC7C,OAAOxB,YACLC,QACA,AAACuB,MAA4BC,IAAI,KAAK,iBAClC,IAAIvC,QAAQ;YAAEwC,YAA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Z,GAAG,CAACjD,CAAAA,SAAUU,UAAUV,QAAQW,MAAMC,OAAOC,OAAOC;QAG/D,OAAOmD,OAAO;YACZtD;YACA,yEAAyE;YACzE,8DAA8D;YAC9DuD,QAAQC,SAASG,OAAO,CAACC,CAAAA,UAAYA,QAAQpE,EAAE,GAAG;oBAACoE,QAAQvC,KAAK;iBAAC,GAAG,EAAE;YACtEjC,aAAaoE,SAASG,OAAO,CAACC,CAAAA,UAC5BA,QAAQpE,EAAE,GAAG,EAAE,GAAG;oBAACoE,QAAQxE,WAAW;iBAAC;QAE3C;IACF;AACF,EAAE"}
1
+ {"version":3,"sources":["../../../src/lib/search/record-search-route.ts"],"sourcesContent":["import {\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,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;AAC1C,mFAAmF,GACnF,OAAO,MAAMC,sBAAsB,SAAS;AAE5C;;;;;;;CAOC,GACD,OAAO,MAAMC,kBAAkB,EAAE;AACjC,OAAO,MAAMC,sBAAsB,EAAE;AACrC,OAAO,MAAMC,kBAAkB,GAAG;AAClC,OAAO,MAAMC,4BAA4B,KAAM;AAmB/C,MAAMC,cAAc,CAClBC,QACAC,SACAC,SACmB,CAAA;QACnBC,IAAI;QACJJ,aAAa;YACXC,QAAQA,OAAOI,GAAG;YAClBC,QAAQL,OAAOK,MAAM;YACrBC,QAAQL,QAAQM,IAAI;YACpBC,UAAUP,QAAQO,QAAQ;WACtBN,WAAWO,YAAY,CAAC,IAAI;YAAEP;QAAO;IAE7C,CAAA;AAEA;;;;;;CAMC,GACD,MAAMQ,YAAY,OAChBV,QACAW,MACAC,OACAC,QACAC,OACAC;IAEA,IAAIC;IACJ,IAAI;QACFA,WAAW,MAAMC,MAAMjB,OAAOkB,GAAG,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Constructor, 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
- readonly url: (term: string, limit: number) => string;
37
- /** `undefined` when the body is not a readable `entityPage` envelope. */
38
- readonly read: (body: unknown) => {
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,EAMvB,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;IAC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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
- if (search.type !== 'string') {
35
- throw rejection(entityName, searchProperty, `the member is a ${search.type}, and a partial term is not a valid value for it.`, 'Search a string member instead.');
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
- // A localized label sorts one locale at a time, and a search that fans out
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 == null || raw === '' ? id : String(raw)
73
- }, sublabel !== undefined && row[sublabel.name] != null ? {
74
- sublabel: String(row[sublabel.name])
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.key,
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.key,
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,OAAOE,UAAU,EAAE;QACtB,MAAMlB,UACJC,YACAS,gBACA,wEACA;IAEJ;IACA,wEAAwE;IACxE,0EAA0E;IAC1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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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;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
- * because the server has no locale — and the entity catalogs already carry one
60
- * for every source, so record search introduces no copy of its own.
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,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;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