@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
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/search/record-search.types.ts"],"sourcesContent":["import type { FailureCategory } from '@entifix/core';\n\n/**\n * The wire contract of `GET /api/search` — the cross-domain record search the\n * command palette reads.\n *\n * Types only, so both halves can name them: the route handler builds these on\n * the server, and the browser's `searchRecords` returns them. A type crosses the\n * client/server entry split freely because it erases.\n */\n\n/**\n * Why a source produced no group.\n *\n * The split is the point, and it is not cosmetic. `forbidden` and\n * `noActiveOrganization` are the **normal** state for some callers on some\n * sources — an operator holds no membership, so every tenant-plane search\n * answers `409` — and rendering \"we could not reach this\" for the ordinary case\n * teaches an operator to ignore the warning. `timeout`/`network`/`unexpected`\n * are the ones that mean something is actually wrong.\n *\n * Every member is a key in the shared `errors` catalog, so a caller renders one\n * through the documented runtime-key hatch rather than inventing copy.\n */\n/**\n * Why a source produced nothing: the code of the failure it answered with,\n * decoded from its problem body — `noActiveOrganization`, `forbidden`,\n * `upstreamUnavailable` — or `timeout` when it never answered in time. A\n * code, so the browser renders it through the `errors` catalog like any other\n * refusal.\n */\nexport type RecordSearchUnavailableReason = string;\n\n/** One record a caller can show and route to. */\nexport interface RecordSearchOption {\n readonly id: string;\n readonly label: string;\n /** A secondary line — a code, a role. Absent when the source declared none. */\n readonly sublabel?: string;\n /**\n * `envelopeEntityName(Ctor)` — `key ?? name`.\n *\n * Repeated on every option rather than left to the group, because an option is\n * routed on its own once a caller has flattened the list: `['entity', entity]`\n * is exactly `entityQueryScope`'s output, and `entity:<entity>:<id>` is the\n * workspace tab address.\n */\n readonly entity: string;\n /**\n * Where selecting this record lands, **without** a locale prefix — the caller\n * adds one, the same way every other internal href in the back office works.\n */\n readonly href: string;\n}\n\n/** One source's answer. */\nexport interface RecordSearchGroup {\n /** The source's declared key. Stable, and the caller's ordering. */\n readonly source: string;\n readonly entity: string;\n /**\n * The heading, as the entity's own `pluralKey`. A key rather than copy,\n * because the server has no locale — and the entity catalogs already carry one\n * for every source, so record search introduces no copy of its own.\n */\n readonly labelKey: string;\n readonly items: readonly RecordSearchOption[];\n /**\n * Matches **before** the per-group limit, so \"3 more\" is renderable. A\n * reachable source with no matches is a present group with an empty `items`,\n * never an omission — that distinction is the whole reason\n * {@link RecordSearchResponse.unavailable} exists.\n */\n readonly total: number;\n}\n\n/** One source that produced nothing, and why. */\nexport interface RecordSearchUnavailable {\n readonly source: string;\n readonly entity: string;\n readonly reason: RecordSearchUnavailableReason;\n /** The failure's category: what decides whether this is scope or an outage. */\n readonly category: FailureCategory;\n /** The upstream status, when there was a response. Absent on a throw. */\n readonly status?: number;\n}\n\n/**\n * The whole answer.\n *\n * A degraded source is **named**, never a silently missing group. An empty group\n * is a confident claim that there are no matching records, and a search that\n * confidently reports nothing when it in fact could not look is the failure\n * mode this shape exists to prevent.\n */\nexport interface RecordSearchResponse {\n readonly term: string;\n readonly groups: readonly RecordSearchGroup[];\n readonly unavailable: readonly RecordSearchUnavailable[];\n}\n"],"names":[],"mappings":"AAuFA;;;;;;;CAOC,GACD,WAIC"}
1
+ {"version":3,"sources":["../../../src/lib/search/record-search.types.ts"],"sourcesContent":["import type { FailureCategory } from '@entifix/core';\n\n/**\n * The wire contract of `GET /api/search` — the cross-domain record search the\n * command palette reads.\n *\n * Types only, so both halves can name them: the route handler builds these on\n * the server, and the browser's `searchRecords` returns them. A type crosses the\n * client/server entry split freely because it erases.\n */\n\n/**\n * Why a source produced no group.\n *\n * The split is the point, and it is not cosmetic. `forbidden` and\n * `noActiveOrganization` are the **normal** state for some callers on some\n * sources — an operator holds no membership, so every tenant-plane search\n * answers `409` — and rendering \"we could not reach this\" for the ordinary case\n * teaches an operator to ignore the warning. `timeout`/`network`/`unexpected`\n * are the ones that mean something is actually wrong.\n *\n * Every member is a key in the shared `errors` catalog, so a caller renders one\n * through the documented runtime-key hatch rather than inventing copy.\n */\n/**\n * Why a source produced nothing: the code of the failure it answered with,\n * decoded from its problem body — `noActiveOrganization`, `forbidden`,\n * `upstreamUnavailable` — or `timeout` when it never answered in time. A\n * code, so the browser renders it through the `errors` catalog like any other\n * refusal.\n */\nexport type RecordSearchUnavailableReason = string;\n\n/** One record a caller can show and route to. */\nexport interface RecordSearchOption {\n readonly id: string;\n readonly label: string;\n /** A secondary line — a code, a role. Absent when the source declared none. */\n readonly sublabel?: string;\n /**\n * `envelopeEntityName(Ctor)` — `key ?? name`.\n *\n * Repeated on every option rather than left to the group, because an option is\n * routed on its own once a caller has flattened the list: `['entity', entity]`\n * is exactly `entityQueryScope`'s output, and `entity:<entity>:<id>` is the\n * workspace tab address.\n */\n readonly entity: string;\n /**\n * Where selecting this record lands, **without** a locale prefix — the caller\n * adds one, the same way every other internal href in the back office works.\n */\n readonly href: string;\n}\n\n/** One source's answer. */\nexport interface RecordSearchGroup {\n /** The source's declared key. Stable, and the caller's ordering. */\n readonly source: string;\n readonly entity: string;\n /**\n * The heading, as the entity's own `pluralKey`. A key rather than copy:\n * the entity catalogs already carry one for every source, so record search\n * introduces no copy of its own. (The search runs in the reader's locale,\n * but only a localized member's value depends on it.)\n */\n readonly labelKey: string;\n readonly items: readonly RecordSearchOption[];\n /**\n * Matches **before** the per-group limit, so \"3 more\" is renderable. A\n * reachable source with no matches is a present group with an empty `items`,\n * never an omission — that distinction is the whole reason\n * {@link RecordSearchResponse.unavailable} exists.\n */\n readonly total: number;\n}\n\n/** One source that produced nothing, and why. */\nexport interface RecordSearchUnavailable {\n readonly source: string;\n readonly entity: string;\n readonly reason: RecordSearchUnavailableReason;\n /** The failure's category: what decides whether this is scope or an outage. */\n readonly category: FailureCategory;\n /** The upstream status, when there was a response. Absent on a throw. */\n readonly status?: number;\n}\n\n/**\n * The whole answer.\n *\n * A degraded source is **named**, never a silently missing group. An empty group\n * is a confident claim that there are no matching records, and a search that\n * confidently reports nothing when it in fact could not look is the failure\n * mode this shape exists to prevent.\n */\nexport interface RecordSearchResponse {\n readonly term: string;\n readonly groups: readonly RecordSearchGroup[];\n readonly unavailable: readonly RecordSearchUnavailable[];\n}\n"],"names":[],"mappings":"AAwFA;;;;;;;CAOC,GACD,WAIC"}
@@ -8,6 +8,8 @@ export interface SearchRecordsOptions {
8
8
  readonly sources?: readonly string[];
9
9
  /** Records per group. */
10
10
  readonly limit?: number;
11
+ /** The reader's locale, which a localized member is searched and read in. */
12
+ readonly locale?: string;
11
13
  }
12
14
  /**
13
15
  * Ask the back office for records matching `term`.
@@ -21,5 +23,5 @@ export interface SearchRecordsOptions {
21
23
  * cross-origin call would carry no session and every group would come back
22
24
  * unavailable.
23
25
  */
24
- export declare const searchRecords: (term: string, { signal, sources, limit }?: SearchRecordsOptions) => Promise<RecordSearchResponse>;
26
+ export declare const searchRecords: (term: string, { signal, sources, limit, locale }?: SearchRecordsOptions) => Promise<RecordSearchResponse>;
25
27
  //# sourceMappingURL=search-records.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-records.d.ts","sourceRoot":"","sources":["../../../src/lib/search/search-records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,6BAA4B,oBAAyB,KACpD,OAAO,CAAC,oBAAoB,CAoB9B,CAAC"}
1
+ {"version":3,"file":"search-records.d.ts","sourceRoot":"","sources":["../../../src/lib/search/search-records.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,sFAAsF;AACtF,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAEhD,MAAM,WAAW,oBAAoB;IACnC,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B,yEAAyE;IACzE,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,yBAAyB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GACxB,MAAM,MAAM,EACZ,qCAAoC,oBAAyB,KAC5D,OAAO,CAAC,oBAAoB,CAqB9B,CAAC"}
@@ -11,7 +11,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
11
11
  * Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a
12
12
  * cross-origin call would carry no session and every group would come back
13
13
  * unavailable.
14
- */ export const searchRecords = async (term, { signal, sources, limit } = {})=>{
14
+ */ export const searchRecords = async (term, { signal, sources, limit, locale } = {})=>{
15
15
  const params = new URLSearchParams({
16
16
  q: term
17
17
  });
@@ -19,6 +19,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
19
19
  params.set('sources', sources.join(','));
20
20
  }
21
21
  if (limit !== undefined) params.set('limit', String(limit));
22
+ if (locale !== undefined) params.set('locale', locale);
22
23
  const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, _extends({
23
24
  cache: 'no-store'
24
25
  }, signal === undefined ? {} : {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/search/search-records.ts"],"sourcesContent":["import type { RecordSearchResponse } from './record-search.types.js';\n\n/** Where the aggregating route is mounted. Same-origin, so the cookie rides along. */\nexport const RECORD_SEARCH_PATH = '/api/search';\n\nexport interface SearchRecordsOptions {\n /** Aborts an in-flight request when the term moves on. */\n readonly signal?: AbortSignal;\n /** Narrow the fan-out to these source keys. Omit to ask every source. */\n readonly sources?: readonly string[];\n /** Records per group. */\n readonly limit?: number;\n}\n\n/**\n * Ask the back office for records matching `term`.\n *\n * Deliberately framework-free — no React, no router, no debounce, no retry. It\n * is a typed `fetch`, so the palette can own its own keystroke policy (which is\n * where debounce and abort belong) and a server component or a test can call the\n * same function.\n *\n * Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a\n * cross-origin call would carry no session and every group would come back\n * unavailable.\n */\nexport const searchRecords = async (\n term: string,\n { signal, sources, limit }: SearchRecordsOptions = {},\n): Promise<RecordSearchResponse> => {\n const params = new URLSearchParams({ q: term });\n if (sources !== undefined && sources.length > 0) {\n params.set('sources', sources.join(','));\n }\n if (limit !== undefined) params.set('limit', String(limit));\n\n const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, {\n cache: 'no-store',\n ...(signal === undefined ? {} : { signal }),\n });\n\n if (!response.ok) {\n // The route answers `401` for a lapsed session and `400` for a caller naming\n // a source that does not exist. Neither is a per-source degradation — those\n // arrive inside a `200` — so both are the caller's to handle.\n throw new Error(`record search failed with ${response.status}`);\n }\n\n return (await response.json()) as RecordSearchResponse;\n};\n"],"names":["RECORD_SEARCH_PATH","searchRecords","term","signal","sources","limit","params","URLSearchParams","q","undefined","length","set","join","String","response","fetch","toString","cache","ok","Error","status","json"],"mappings":";AAEA,oFAAoF,GACpF,OAAO,MAAMA,qBAAqB,cAAc;AAWhD;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,gBAAgB,OAC3BC,MACA,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAwB,GAAG,CAAC,CAAC;IAErD,MAAMC,SAAS,IAAIC,gBAAgB;QAAEC,GAAGN;IAAK;IAC7C,IAAIE,YAAYK,aAAaL,QAAQM,MAAM,GAAG,GAAG;QAC/CJ,OAAOK,GAAG,CAAC,WAAWP,QAAQQ,IAAI,CAAC;IACrC;IACA,IAAIP,UAAUI,WAAWH,OAAOK,GAAG,CAAC,SAASE,OAAOR;IAEpD,MAAMS,WAAW,MAAMC,MAAM,GAAGf,mBAAmB,CAAC,EAAEM,OAAOU,QAAQ,IAAI,EAAE;QACzEC,OAAO;OACHd,WAAWM,YAAY,CAAC,IAAI;QAAEN;IAAO;IAG3C,IAAI,CAACW,SAASI,EAAE,EAAE;QAChB,6EAA6E;QAC7E,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEL,SAASM,MAAM,EAAE;IAChE;IAEA,OAAQ,MAAMN,SAASO,IAAI;AAC7B,EAAE"}
1
+ {"version":3,"sources":["../../../src/lib/search/search-records.ts"],"sourcesContent":["import type { RecordSearchResponse } from './record-search.types.js';\n\n/** Where the aggregating route is mounted. Same-origin, so the cookie rides along. */\nexport const RECORD_SEARCH_PATH = '/api/search';\n\nexport interface SearchRecordsOptions {\n /** Aborts an in-flight request when the term moves on. */\n readonly signal?: AbortSignal;\n /** Narrow the fan-out to these source keys. Omit to ask every source. */\n readonly sources?: readonly string[];\n /** Records per group. */\n readonly limit?: number;\n /** The reader's locale, which a localized member is searched and read in. */\n readonly locale?: string;\n}\n\n/**\n * Ask the back office for records matching `term`.\n *\n * Deliberately framework-free — no React, no router, no debounce, no retry. It\n * is a typed `fetch`, so the palette can own its own keystroke policy (which is\n * where debounce and abort belong) and a server component or a test can call the\n * same function.\n *\n * Same-origin on purpose: `entifix_at` is httpOnly and `sameSite: 'lax'`, so a\n * cross-origin call would carry no session and every group would come back\n * unavailable.\n */\nexport const searchRecords = async (\n term: string,\n { signal, sources, limit, locale }: SearchRecordsOptions = {},\n): Promise<RecordSearchResponse> => {\n const params = new URLSearchParams({ q: term });\n if (sources !== undefined && sources.length > 0) {\n params.set('sources', sources.join(','));\n }\n if (limit !== undefined) params.set('limit', String(limit));\n if (locale !== undefined) params.set('locale', locale);\n\n const response = await fetch(`${RECORD_SEARCH_PATH}?${params.toString()}`, {\n cache: 'no-store',\n ...(signal === undefined ? {} : { signal }),\n });\n\n if (!response.ok) {\n // The route answers `401` for a lapsed session and `400` for a caller naming\n // a source that does not exist. Neither is a per-source degradation — those\n // arrive inside a `200` — so both are the caller's to handle.\n throw new Error(`record search failed with ${response.status}`);\n }\n\n return (await response.json()) as RecordSearchResponse;\n};\n"],"names":["RECORD_SEARCH_PATH","searchRecords","term","signal","sources","limit","locale","params","URLSearchParams","q","undefined","length","set","join","String","response","fetch","toString","cache","ok","Error","status","json"],"mappings":";AAEA,oFAAoF,GACpF,OAAO,MAAMA,qBAAqB,cAAc;AAahD;;;;;;;;;;;CAWC,GACD,OAAO,MAAMC,gBAAgB,OAC3BC,MACA,EAAEC,MAAM,EAAEC,OAAO,EAAEC,KAAK,EAAEC,MAAM,EAAwB,GAAG,CAAC,CAAC;IAE7D,MAAMC,SAAS,IAAIC,gBAAgB;QAAEC,GAAGP;IAAK;IAC7C,IAAIE,YAAYM,aAAaN,QAAQO,MAAM,GAAG,GAAG;QAC/CJ,OAAOK,GAAG,CAAC,WAAWR,QAAQS,IAAI,CAAC;IACrC;IACA,IAAIR,UAAUK,WAAWH,OAAOK,GAAG,CAAC,SAASE,OAAOT;IACpD,IAAIC,WAAWI,WAAWH,OAAOK,GAAG,CAAC,UAAUN;IAE/C,MAAMS,WAAW,MAAMC,MAAM,GAAGhB,mBAAmB,CAAC,EAAEO,OAAOU,QAAQ,IAAI,EAAE;QACzEC,OAAO;OACHf,WAAWO,YAAY,CAAC,IAAI;QAAEP;IAAO;IAG3C,IAAI,CAACY,SAASI,EAAE,EAAE;QAChB,6EAA6E;QAC7E,4EAA4E;QAC5E,8DAA8D;QAC9D,MAAM,IAAIC,MAAM,CAAC,0BAA0B,EAAEL,SAASM,MAAM,EAAE;IAChE;IAEA,OAAQ,MAAMN,SAASO,IAAI;AAC7B,EAAE"}
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  }
22
22
  }
23
23
  },
24
- "version": "0.20.3",
24
+ "version": "0.22.0",
25
25
  "description": "Next.js application shell: back-office chrome, workspace tabs, CRUD screens derived from entity metadata, and session and proxy routes.",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -57,17 +57,17 @@
57
57
  "react": "19.3.1",
58
58
  "react-dom": "19.3.1",
59
59
  "zustand": "^5.1.0",
60
- "@entifix/testing-unit": "0.20.3"
60
+ "@entifix/testing-unit": "0.22.0"
61
61
  },
62
62
  "dependencies": {
63
63
  "idb": "^8.0.4",
64
- "@entifix/authz": "0.20.3",
65
- "@entifix/business": "0.20.3",
66
- "@entifix/core": "0.20.3",
67
- "@entifix/i18n": "0.20.3",
68
- "@entifix/react-controls": "0.20.3",
69
- "@entifix/react-integration": "0.20.3",
70
- "@entifix/transactions": "0.20.3"
64
+ "@entifix/authz": "0.22.0",
65
+ "@entifix/business": "0.22.0",
66
+ "@entifix/core": "0.22.0",
67
+ "@entifix/i18n": "0.22.0",
68
+ "@entifix/react-controls": "0.22.0",
69
+ "@entifix/react-integration": "0.22.0",
70
+ "@entifix/transactions": "0.22.0"
71
71
  },
72
72
  "files": [
73
73
  "dist",
@@ -1,32 +0,0 @@
1
- import { type EntityRepositoryTag } from '@entifix/business';
2
- import { type Entity, type EntityConstructor, type Locale } from '@entifix/core';
3
- import { Context } from 'effect';
4
- /** One member a list shows as the record it names, and where to read it. */
5
- export interface LinkLabelPlan {
6
- readonly field: string;
7
- readonly entityConstructor: EntityConstructor<Entity>;
8
- readonly labelProperty: string;
9
- readonly ctx: Context.Context<EntityRepositoryTag>;
10
- }
11
- /** What a list cell knows about the record an id names. */
12
- export type LinkLabel = {
13
- readonly state: 'resolving';
14
- } | {
15
- readonly state: 'named';
16
- readonly label: string;
17
- } | {
18
- readonly state: 'unnamed';
19
- };
20
- /** A target's label member as a reader sees it: localized, or as text. */
21
- export declare const targetLabel: (raw: unknown, locale: Locale) => string | undefined;
22
- /**
23
- * The records a page of rows refers to by id, read once per distinct id and
24
- * cached under the target's own scope, so a list column can name each one
25
- * rather than print its key (#200).
26
- */
27
- export declare function useLinkLabels(plans: readonly LinkLabelPlan[], items: readonly Entity[]): (field: string, item: Entity) => LinkLabel | undefined;
28
- /** A list cell for an id: the record's name, a skeleton while it is read. */
29
- export declare function LinkLabelCell({ label }: {
30
- label: LinkLabel | undefined;
31
- }): import("react").JSX.Element;
32
- //# sour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AE;IAAE,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;CAAE,+BAKxE"}
@@ -1,76 +0,0 @@
1
- 'use client';
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { EntityIdTag, getUCFactory } from '@entifix/business';
4
- import { isLocalizedText, localize } from '@entifix/core';
5
- import { Skeleton, useLocale } from '@entifix/react-controls';
6
- import { entityQueryScope } from '@entifix/react-integration';
7
- import { useQueries } from '@tanstack/react-query';
8
- import { Context, Effect } from 'effect';
9
- const idOf = (item, field)=>{
10
- const raw = item[field];
11
- return raw == null || raw === '' ? undefined : String(raw);
12
- };
13
- /** A target's label member as a reader sees it: localized, or as text. */ export const targetLabel = (raw, locale)=>isLocalizedText(raw) ? localize(raw, locale) : raw == null || raw === '' ? undefined : String(raw);
14
- /**
15
- * The records a page of rows refers to by id, read once per distinct id and
16
- * cached under the target's own scope, so a list column can name each one
17
- * rather than print its key (#200).
18
- */ export function useLinkLabels(plans, items) {
19
- const locale = useLocale();
20
- const requests = plans.flatMap((plan)=>[
21
- ...new Set(items.map((item)=>idOf(item, plan.field)).filter((id)=>id !== undefined))
22
- ].map((id)=>({
23
- plan,
24
- id
25
- })));
26
- const results = useQueries({
27
- queries: requests.map(({ plan, id })=>({
28
- queryKey: [
29
- ...entityQueryScope(plan.entityConstructor),
30
- 'label',
31
- id
32
- ],
33
- queryFn: ()=>Effect.runPromise(Effect.provide(getUCFactory(), plan.ctx.pipe(Context.add(EntityIdTag, id))))
34
- }))
35
- });
36
- const byKey = new Map(requests.map(({ plan, id }, index)=>[
37
- `${plan.field}\u0000${id}`,
38
- {
39
- plan,
40
- result: results[index]
41
- }
42
- ]));
43
- return (field, item)=>{
44
- var _result_data;
45
- const id = idOf(item, field);
46
- if (id === undefined) return undefined;
47
- // Every id on the page was asked for above, so the entry is there.
48
- const { plan, result } = byKey.get(`${field}\u0000${id}`);
49
- if (result.isPending) return {
50
- state: 'resolving'
51
- };
52
- const raw = (_result_data = result.data) == null ? void 0 : _result_data[plan.labelProperty];
53
- const label = targetLabel(raw, locale);
54
- return label === undefined ? {
55
- state: 'unnamed'
56
- } : {
57
- state: 'named',
58
- label
59
- };
60
- };
61
- }
62
- /** A list cell for an id: the record's name, a skeleton while it is read. */ export function LinkLabelCell({ label }) {
63
- if ((label == null ? void 0 : label.state) === 'resolving') return /*#__PURE__*/ _jsx(Skeleton, {
64
- shape: "line",
65
- className: "w-16"
66
- });
67
- if ((label == null ? void 0 : label.state) === 'named') return /*#__PURE__*/ _jsx("span", {
68
- children: label.label
69
- });
70
- return /*#__PURE__*/ _jsx("span", {
71
- className: "text-content-muted",
72
- children: "—"
73
- });
74
- }
75
-
76
- //# sourceMappingURL=use-link-labels.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/crud/use-link-labels.tsx"],"sourcesContent":["'use client';\n\nimport {\n EntityIdTag,\n type EntityRepositoryTag,\n getUCFactory,\n} from '@entifix/business';\nimport {\n type Entity,\n type EntityConstructor,\n isLocalizedText,\n type Locale,\n localize,\n} from '@entifix/core';\nimport { Skeleton, useLocale } from '@entifix/react-controls';\nimport { entityQueryScope } from '@entifix/react-integration';\nimport { useQueries } from '@tanstack/react-query';\nimport { Context, Effect } from 'effect';\n\n/** One member a list shows as the record it names, and where to read it. */\nexport interface LinkLabelPlan {\n readonly field: string;\n readonly entityConstructor: EntityConstructor<Entity>;\n readonly labelProperty: string;\n readonly ctx: Context.Context<EntityRepositoryTag>;\n}\n\n/** What a list cell knows about the record an id names. */\nexport type LinkLabel =\n | { readonly state: 'resolving' }\n | { readonly state: 'named'; readonly label: string }\n | { readonly state: 'unnamed' };\n\nconst idOf = (item: Entity, field: string): string | undefined => {\n const raw = (item as unknown as Record<string, unknown>)[field];\n return raw == null || raw === '' ? undefined : String(raw);\n};\n\n/** A target's label member as a reader sees it: localized, or as text. */\nexport const targetLabel = (\n raw: unknown,\n locale: Locale,\n): string | undefined =>\n isLocalizedText(raw)\n ? localize(raw, locale)\n : raw == null || raw === ''\n ? undefined\n : String(raw);\n\n/**\n * The records a page of rows refers to by id, read once per distinct id and\n * cached under the target's own scope, so a list column can name each one\n * rather than print its key (#200).\n */\nexport function useLinkLabels(\n plans: readonly LinkLabelPlan[],\n items: readonly Entity[],\n): (field: string, item: Entity) => LinkLabel | undefined {\n const locale = useLocale();\n const requests = plans.flatMap(plan =>\n [\n ...new Set(\n items\n .map(item => idOf(item, plan.field))\n .filter((id): id is string => id !== undefined),\n ),\n ].map(id => ({ plan, id })),\n );\n\n const results = useQueries({\n queries: requests.map(({ plan, id }) => ({\n queryKey: [...entityQueryScope(plan.entityConstructor), 'label', id],\n queryFn: () =>\n Effect.runPromise(\n Effect.provide(\n getUCFactory<Entity>(),\n plan.ctx.pipe(Context.add(EntityIdTag, id)),\n ),\n ),\n })),\n });\n\n const byKey = new Map(\n requests.map(({ plan, id }, index) => [\n `${plan.field}\\u0000${id}`,\n { plan, result: results[index] },\n ]),\n );\n\n return (field, item) => {\n const id = idOf(item, field);\n if (id === undefined) return undefined;\n // Every id on the page was asked for above, so the entry is there.\n const { plan, result } = byKey.get(`${field}\\u0000${id}`) as {\n plan: LinkLabelPlan;\n result: (typeof results)[number];\n };\n if (result.isPending) return { state: 'resolving' };\n const raw = (result.data as Record<string, unknown> | undefined)?.[\n plan.labelProperty\n ];\n const label = targetLabel(raw, locale);\n return label === undefined\n ? { state: 'unnamed' }\n : { state: 'named', label };\n };\n}\n\n/** A list cell for an id: the record's name, a skeleton while it is read. */\nexport function LinkLabelCell({ label }: { label: LinkLabel | undefined }) {\n if (label?.state === 'resolving')\n return <Skeleton shape=\"line\" className=\"w-16\" />;\n if (label?.state === 'named') return <span>{label.label}</span>;\n return <span className=\"text-content-muted\">—</span>;\n}\n"],"names":["EntityIdTag","getUCFactory","isLocalizedText","localize","Skeleton","useLocale","entityQueryScope","useQueries","Context","Effect","idOf","item","field","raw","undefined","String","targetLabel","locale","useLinkLabels","plans","items","requests","flatMap","plan","Set","map","filter","id","results","queries","queryKey","entityConstructor","queryFn","runPromise","provide","ctx","pipe","add","byKey","Map","index","result","get","isPending","state","data","labelProperty","label","LinkLabelCell","shape","className","span"],"mappings":"AAAA;;AAEA,SACEA,WAAW,EAEXC,YAAY,QACP,oBAAoB;AAC3B,SAGEC,eAAe,EAEfC,QAAQ,QACH,gBAAgB;AACvB,SAASC,QAAQ,EAAEC,SAAS,QAAQ,0BAA0B;AAC9D,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,UAAU,QAAQ,wBAAwB;AACnD,SAASC,OAAO,EAAEC,MAAM,QAAQ,SAAS;AAgBzC,MAAMC,OAAO,CAACC,MAAcC;IAC1B,MAAMC,MAAM,AAACF,IAA2C,CAACC,MAAM;IAC/D,OAAOC,OAAO,QAAQA,QAAQ,KAAKC,YAAYC,OAAOF;AACxD;AAEA,wEAAwE,GACxE,OAAO,MAAMG,cAAc,CACzBH,KACAI,SAEAf,gBAAgBW,OACZV,SAASU,KAAKI,UACdJ,OAAO,QAAQA,QAAQ,KACrBC,YACAC,OAAOF,KAAK;AAEpB;;;;CAIC,GACD,OAAO,SAASK,cACdC,KAA+B,EAC/BC,KAAwB;IAExB,MAAMH,SAASZ;IACf,MAAMgB,WAAWF,MAAMG,OAAO,CAACC,CAAAA,OAC7B;eACK,IAAIC,IACLJ,MACGK,GAAG,CAACd,CAAAA,OAAQD,KAAKC,MAAMY,KAAKX,KAAK,GACjCc,MAAM,CAAC,CAACC,KAAqBA,OAAOb;SAE1C,CAACW,GAAG,CAACE,CAAAA,KAAO,CAAA;gBAAEJ;gBAAMI;YAAG,CAAA;IAG1B,MAAMC,UAAUrB,WAAW;QACzBsB,SAASR,SAASI,GAAG,CAAC,CAAC,EAAEF,IAAI,EAAEI,EAAE,EAAE,GAAM,CAAA;gBACvCG,UAAU;uBAAIxB,iBAAiBiB,KAAKQ,iBAAiB;oBAAG;oBAASJ;iBAAG;gBACpEK,SAAS,IACPvB,OAAOwB,UAAU,CACfxB,OAAOyB,OAAO,CACZjC,g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