@burdenoff/microfe-healthybowl 2026.1008.2 → 2026.1009.1

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.
@@ -1,13 +1,14 @@
1
+ import { normaliseRecordName as e } from "@burdenoff/fe-libs/shared/assistant/uiActions/recordNames";
1
2
  //#region src/components/assistant/recordAdapters.ts
2
- var e = "\n query AssistantFindAnimals($context: ContextInput!) {\n getHealthyBowlLivestockData(context: $context) {\n animals { id name tagNumber }\n }\n }\n", t = "\n query AssistantFindListings($context: ContextInput!) {\n getHealthyBowlMarketplaceData(context: $context) {\n marketplaceProducts { id name }\n }\n }\n", n = {
3
+ var t = "\n query AssistantFindAnimals($context: ContextInput!) {\n getHealthyBowlLivestockData(context: $context) {\n animals { id name tagNumber }\n }\n }\n", n = "\n query AssistantFindListings($context: ContextInput!) {\n getHealthyBowlMarketplaceData(context: $context) {\n marketplaceProducts { id name }\n }\n }\n", r = {
3
4
  graphqlFetch: async (e) => (await import("@burdenoff/fe-libs/shared/graphql")).graphqlFetch(e),
4
5
  getWorkspaceId: async () => (await import("@burdenoff/fe-libs/shared/graphql")).getStoredWorkspaceId()
5
- }, r = (e) => typeof e == "string" && e.trim().length > 0 ? e.trim() : null, i = (e) => e.normalize("NFKC").toLowerCase().replace(/[^\p{L}\p{N}\s]/gu, " ").replace(/\s+/g, " ").trim();
6
- function a(e, t) {
7
- let n = i(e);
8
- if (!n) return !1;
9
- let r = i(t).split(" ");
10
- return n.split(" ").every((e) => r.some((t) => t.startsWith(e)));
6
+ }, i = (e) => typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
7
+ function a(t, n) {
8
+ let r = e(t);
9
+ if (!r) return !1;
10
+ let i = e(n).split(" ");
11
+ return r.split(" ").every((e) => i.some((t) => t.startsWith(e)));
11
12
  }
12
13
  async function o(e, t, n, r, i, o, s, c) {
13
14
  let l = await e.getWorkspaceId();
@@ -37,7 +38,7 @@ async function o(e, t, n, r, i, o, s, c) {
37
38
  }
38
39
  return f;
39
40
  }
40
- function s(i = n) {
41
+ function s(e = r) {
41
42
  return [{
42
43
  id: "healthybowl-animal",
43
44
  nouns: ["animal", "animals"],
@@ -46,7 +47,7 @@ function s(i = n) {
46
47
  fallback: "animal"
47
48
  },
48
49
  entityRouteId: "healthybowl-animal",
49
- find: (t, n) => o(i, e, "AssistantFindAnimals", "getHealthyBowlLivestockData", "animals", t, n, (e) => r(e.name) ?? r(e.tagNumber))
50
+ find: (n, r) => o(e, t, "AssistantFindAnimals", "getHealthyBowlLivestockData", "animals", n, r, (e) => i(e.name) ?? i(e.tagNumber))
50
51
  }, {
51
52
  id: "healthybowl-listing",
52
53
  nouns: [
@@ -62,7 +63,7 @@ function s(i = n) {
62
63
  fallback: "marketplace listing"
63
64
  },
64
65
  entityRouteId: "healthybowl-listing",
65
- find: (e, n) => o(i, t, "AssistantFindListings", "getHealthyBowlMarketplaceData", "marketplaceProducts", e, n, (e) => r(e.name))
66
+ find: (t, r) => o(e, n, "AssistantFindListings", "getHealthyBowlMarketplaceData", "marketplaceProducts", t, r, (e) => i(e.name))
66
67
  }];
67
68
  }
68
69
  var c = s();
@@ -1 +1 @@
1
- {"version":3,"file":"recordAdapters.js","names":[],"sources":["../../../src/components/assistant/recordAdapters.ts"],"sourcesContent":["/**\n * HealthyBowl's named-record adapters for the shared assistant (BOFF-8060 N1b):\n * \"open Bella the cow\", \"open the organic tomatoes listing\".\n *\n * Two kinds, chosen because the product's own pages already read them and because\n * neither sits in the crop / field / catalog area that BOFF-7151 is changing:\n * - animals, from `getHealthyBowlLivestockData` (the Animal Registry's read);\n * - marketplace listings, from `getHealthyBowlMarketplaceData` (the Marketplace read).\n * Crops, fields, plans and harvests are deliberately NOT adapted here.\n *\n * An adapter only LOOKS A RECORD UP BY NAME, as the signed-in person: the workspace\n * token is theirs and the gateway's `@rbac` decides what the read returns. It\n * produces route params, never a path: fe-libs fills the entity route declared in\n * `assistantProductOptions.ts` (`ENTITY_ROUTES`), re-validates it, and only for a\n * person who can see the route's sidebar entry.\n *\n * ★ Neither read has a name search, so the adapter selects only id + name (the\n * existing queries select far more) and matches the name HERE. It must filter\n * itself: fe-libs caps what an adapter may return.\n *\n * ★★ A LEAF like `assistantProductOptions.ts`, which imports this: the fe-libs\n * graphql module is loaded lazily, on the first lookup, never at import time.\n *\n * ★ Nothing here writes, opens a form, or touches the DOM.\n */\nimport type {\n AssistantRecordAdapter,\n AssistantRecordMatch,\n} from '@burdenoff/fe-libs/shared/assistant/uiActions/recordNames';\nimport type { graphqlFetch as GraphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nexport const LIST_ANIMALS_FOR_ASSISTANT = `\n query AssistantFindAnimals($context: ContextInput!) {\n getHealthyBowlLivestockData(context: $context) {\n animals { id name tagNumber }\n }\n }\n`;\n\nexport const LIST_LISTINGS_FOR_ASSISTANT = `\n query AssistantFindListings($context: ContextInput!) {\n getHealthyBowlMarketplaceData(context: $context) {\n marketplaceProducts { id name }\n }\n }\n`;\n\n/** The two things the adapters need from the app; injectable so tests run without a network. */\nexport interface RecordAdapterDeps {\n graphqlFetch: typeof GraphqlFetch;\n getWorkspaceId: () => string | null | Promise<string | null>;\n}\nconst LIVE_DEPS: RecordAdapterDeps = {\n graphqlFetch: async (options) => (await import('@burdenoff/fe-libs/shared/graphql')).graphqlFetch(options),\n getWorkspaceId: async () => (await import('@burdenoff/fe-libs/shared/graphql')).getStoredWorkspaceId(),\n};\n\ninterface RawRow {\n id?: unknown;\n name?: unknown;\n tagNumber?: unknown;\n}\n\nconst text = (value: unknown): string | null =>\n typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;\n\nconst normalise = (value: string): string =>\n value\n .normalize('NFKC')\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\s]/gu, ' ')\n .replace(/\\s+/g, ' ')\n .trim();\n\n/** Every word said is the start of a word in the name (the rule fe-libs plans with). */\nexport function nameFits(said: string, name: string): boolean {\n const wanted = normalise(said);\n if (!wanted) return false;\n const words = normalise(name).split(' ');\n return wanted.split(' ').every((word) => words.some((candidate) => candidate.startsWith(word)));\n}\n\nasync function findByName(\n deps: RecordAdapterDeps,\n query: string,\n operationName: string,\n field: string,\n rowsKey: string,\n name: string,\n signal: AbortSignal,\n label: (row: RawRow) => string | null\n): Promise<readonly AssistantRecordMatch[]> {\n const workspaceId = await deps.getWorkspaceId();\n if (!workspaceId) return [];\n const result = await deps.graphqlFetch<Record<string, Record<string, unknown> | null | undefined>>({\n gateway: 'workspace',\n query,\n operationName,\n variables: { context: { workspaceId } },\n // The person's own workspace token, minted for THIS workspace.\n workspaceToken: true,\n workspaceId,\n organizationId: true,\n signal,\n suppressGlobalErrorEvent: true,\n });\n if (result.errors?.length) return [];\n const rows = result.data?.[field]?.[rowsKey];\n if (!Array.isArray(rows)) return [];\n const matches: AssistantRecordMatch[] = [];\n for (const row of rows as Array<RawRow | null>) {\n if (!row || typeof row.id !== 'string' || row.id.length === 0) continue;\n const shown = label(row);\n if (shown === null || !nameFits(name, shown)) continue;\n matches.push({ params: { id: row.id }, name: shown });\n }\n return matches;\n}\n\nexport function createHealthyBowlRecordAdapters(\n deps: RecordAdapterDeps = LIVE_DEPS\n): readonly AssistantRecordAdapter[] {\n const animals: AssistantRecordAdapter = {\n id: 'healthybowl-animal',\n nouns: ['animal', 'animals'],\n noun: { key: 'entity.animal', fallback: 'animal' },\n entityRouteId: 'healthybowl-animal',\n find: (name, signal) =>\n findByName(\n deps,\n LIST_ANIMALS_FOR_ASSISTANT,\n 'AssistantFindAnimals',\n 'getHealthyBowlLivestockData',\n 'animals',\n name,\n signal,\n // An animal with no name is called by its tag.\n (row) => text(row.name) ?? text(row.tagNumber)\n ),\n };\n const listings: AssistantRecordAdapter = {\n id: 'healthybowl-listing',\n nouns: ['listing', 'listings', 'marketplace listing', 'marketplace listings', 'product', 'products'],\n noun: { key: 'entity.listing', fallback: 'marketplace listing' },\n entityRouteId: 'healthybowl-listing',\n find: (name, signal) =>\n findByName(\n deps,\n LIST_LISTINGS_FOR_ASSISTANT,\n 'AssistantFindListings',\n 'getHealthyBowlMarketplaceData',\n 'marketplaceProducts',\n name,\n signal,\n (row) => text(row.name)\n ),\n };\n return [animals, listings];\n}\n\nexport const HEALTHYBOWL_RECORD_ADAPTERS: readonly AssistantRecordAdapter[] = createHealthyBowlRecordAdapters();\n"],"mappings":";AA+BA,IAAa,IAA6B,sKAQ7B,IAA8B,2KAarC,IAA+B;CACnC,cAAc,OAAO,OAAa,MAAM,OAAO,sCAAsC,aAAa,CAAO;CACzG,gBAAgB,aAAa,MAAM,OAAO,sCAAsC,qBAAqB;AACvG,GAQM,KAAQ,MACZ,OAAO,KAAU,YAAY,EAAM,KAAK,EAAE,SAAS,IAAI,EAAM,KAAK,IAAI,MAElE,KAAa,MACjB,EACG,UAAU,MAAM,EAChB,YAAY,EACZ,QAAQ,qBAAqB,GAAG,EAChC,QAAQ,QAAQ,GAAG,EACnB,KAAK;AAGV,SAAgB,EAAS,GAAc,GAAuB;CAC5D,IAAM,IAAS,EAAU,CAAI;CAC7B,IAAI,CAAC,GAAQ,OAAO;CACpB,IAAM,IAAQ,EAAU,CAAI,EAAE,MAAM,GAAG;CACvC,OAAO,EAAO,MAAM,GAAG,EAAE,OAAO,MAAS,EAAM,MAAM,MAAc,EAAU,WAAW,CAAI,CAAC,CAAC;AAChG;AAEA,eAAe,EACb,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GAC0C;CAC1C,IAAM,IAAc,MAAM,EAAK,eAAe;CAC9C,IAAI,CAAC,GAAa,OAAO,CAAC;CAC1B,IAAM,IAAS,MAAM,EAAK,aAAyE;EACjG,SAAS;EACT;EACA;EACA,WAAW,EAAE,SAAS,EAAE,eAAY,EAAE;EAEtC,gBAAgB;EAChB;EACA,gBAAgB;EAChB;EACA,0BAA0B;CAC5B,CAAC;CACD,IAAI,EAAO,QAAQ,QAAQ,OAAO,CAAC;CACnC,IAAM,IAAO,EAAO,OAAO,KAAS;CACpC,IAAI,CAAC,MAAM,QAAQ,CAAI,GAAG,OAAO,CAAC;CAClC,IAAM,IAAkC,CAAC;CACzC,KAAK,IAAM,KAAO,GAA8B;EAC9C,IAAI,CAAC,KAAO,OAAO,EAAI,MAAO,YAAY,EAAI,GAAG,WAAW,GAAG;EAC/D,IAAM,IAAQ,EAAM,CAAG;EACnB,MAAU,QAAQ,CAAC,EAAS,GAAM,CAAK,KAC3C,EAAQ,KAAK;GAAE,QAAQ,EAAE,IAAI,EAAI,GAAG;GAAG,MAAM;EAAM,CAAC;CACtD;CACA,OAAO;AACT;AAEA,SAAgB,EACd,IAA0B,GACS;CAoCnC,OAAO,CAAC;EAlCN,IAAI;EACJ,OAAO,CAAC,UAAU,SAAS;EAC3B,MAAM;GAAE,KAAK;GAAiB,UAAU;EAAS;EACjD,eAAe;EACf,OAAO,GAAM,MACX,EACE,GACA,GACA,wBACA,+BACA,WACA,GACA,IAEC,MAAQ,EAAK,EAAI,IAAI,KAAK,EAAK,EAAI,SAAS,CAC/C;CAmBI,GAAS;EAhBf,IAAI;EACJ,OAAO;GAAC;GAAW;GAAY;GAAuB;GAAwB;GAAW;EAAU;EACnG,MAAM;GAAE,KAAK;GAAkB,UAAU;EAAsB;EAC/D,eAAe;EACf,OAAO,GAAM,MACX,EACE,GACA,GACA,yBACA,iCACA,uBACA,GACA,IACC,MAAQ,EAAK,EAAI,IAAI,CACxB;CAEa,CAAQ;AAC3B;AAEA,IAAa,IAAiE,EAAgC"}
1
+ {"version":3,"file":"recordAdapters.js","names":[],"sources":["../../../src/components/assistant/recordAdapters.ts"],"sourcesContent":["/**\n * HealthyBowl's named-record adapters for the shared assistant (BOFF-8060 N1b):\n * \"open Bella the cow\", \"open the organic tomatoes listing\".\n *\n * Two kinds, chosen because the product's own pages already read them and because\n * neither sits in the crop / field / catalog area that BOFF-7151 is changing:\n * - animals, from `getHealthyBowlLivestockData` (the Animal Registry's read);\n * - marketplace listings, from `getHealthyBowlMarketplaceData` (the Marketplace read).\n * Crops, fields, plans and harvests are deliberately NOT adapted here.\n *\n * An adapter only LOOKS A RECORD UP BY NAME, as the signed-in person: the workspace\n * token is theirs and the gateway's `@rbac` decides what the read returns. It\n * produces route params, never a path: fe-libs fills the entity route declared in\n * `assistantProductOptions.ts` (`ENTITY_ROUTES`), re-validates it, and only for a\n * person who can see the route's sidebar entry.\n *\n * ★ Neither read has a name search, so the adapter selects only id + name (the\n * existing queries select far more) and matches the name HERE. It must filter\n * itself: fe-libs caps what an adapter may return.\n *\n * ★★ A LEAF like `assistantProductOptions.ts`, which imports this: the fe-libs\n * graphql module is loaded lazily, on the first lookup, never at import time.\n *\n * ★ Nothing here writes, opens a form, or touches the DOM.\n */\nimport { normaliseRecordName } from '@burdenoff/fe-libs/shared/assistant/uiActions/recordNames';\nimport type {\n AssistantRecordAdapter,\n AssistantRecordMatch,\n} from '@burdenoff/fe-libs/shared/assistant/uiActions/recordNames';\nimport type { graphqlFetch as GraphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nexport const LIST_ANIMALS_FOR_ASSISTANT = `\n query AssistantFindAnimals($context: ContextInput!) {\n getHealthyBowlLivestockData(context: $context) {\n animals { id name tagNumber }\n }\n }\n`;\n\nexport const LIST_LISTINGS_FOR_ASSISTANT = `\n query AssistantFindListings($context: ContextInput!) {\n getHealthyBowlMarketplaceData(context: $context) {\n marketplaceProducts { id name }\n }\n }\n`;\n\n/** The two things the adapters need from the app; injectable so tests run without a network. */\nexport interface RecordAdapterDeps {\n graphqlFetch: typeof GraphqlFetch;\n getWorkspaceId: () => string | null | Promise<string | null>;\n}\nconst LIVE_DEPS: RecordAdapterDeps = {\n graphqlFetch: async (options) => (await import('@burdenoff/fe-libs/shared/graphql')).graphqlFetch(options),\n getWorkspaceId: async () => (await import('@burdenoff/fe-libs/shared/graphql')).getStoredWorkspaceId(),\n};\n\ninterface RawRow {\n id?: unknown;\n name?: unknown;\n tagNumber?: unknown;\n}\n\nconst text = (value: unknown): string | null =>\n typeof value === 'string' && value.trim().length > 0 ? value.trim() : null;\n\n/** Every word said is the start of a word in the name (the rule fe-libs plans with). */\nexport function nameFits(said: string, name: string): boolean {\n // Use the command parser's canonical form: '&' means 'and', and vowel marks stay intact.\n const wanted = normaliseRecordName(said);\n if (!wanted) return false;\n const words = normaliseRecordName(name).split(' ');\n return wanted.split(' ').every((word) => words.some((candidate) => candidate.startsWith(word)));\n}\n\nasync function findByName(\n deps: RecordAdapterDeps,\n query: string,\n operationName: string,\n field: string,\n rowsKey: string,\n name: string,\n signal: AbortSignal,\n label: (row: RawRow) => string | null\n): Promise<readonly AssistantRecordMatch[]> {\n const workspaceId = await deps.getWorkspaceId();\n if (!workspaceId) return [];\n const result = await deps.graphqlFetch<Record<string, Record<string, unknown> | null | undefined>>({\n gateway: 'workspace',\n query,\n operationName,\n variables: { context: { workspaceId } },\n // The person's own workspace token, minted for THIS workspace.\n workspaceToken: true,\n workspaceId,\n organizationId: true,\n signal,\n suppressGlobalErrorEvent: true,\n });\n if (result.errors?.length) return [];\n const rows = result.data?.[field]?.[rowsKey];\n if (!Array.isArray(rows)) return [];\n const matches: AssistantRecordMatch[] = [];\n for (const row of rows as Array<RawRow | null>) {\n if (!row || typeof row.id !== 'string' || row.id.length === 0) continue;\n const shown = label(row);\n if (shown === null || !nameFits(name, shown)) continue;\n matches.push({ params: { id: row.id }, name: shown });\n }\n return matches;\n}\n\nexport function createHealthyBowlRecordAdapters(\n deps: RecordAdapterDeps = LIVE_DEPS\n): readonly AssistantRecordAdapter[] {\n const animals: AssistantRecordAdapter = {\n id: 'healthybowl-animal',\n nouns: ['animal', 'animals'],\n noun: { key: 'entity.animal', fallback: 'animal' },\n entityRouteId: 'healthybowl-animal',\n find: (name, signal) =>\n findByName(\n deps,\n LIST_ANIMALS_FOR_ASSISTANT,\n 'AssistantFindAnimals',\n 'getHealthyBowlLivestockData',\n 'animals',\n name,\n signal,\n // An animal with no name is called by its tag.\n (row) => text(row.name) ?? text(row.tagNumber)\n ),\n };\n const listings: AssistantRecordAdapter = {\n id: 'healthybowl-listing',\n nouns: ['listing', 'listings', 'marketplace listing', 'marketplace listings', 'product', 'products'],\n noun: { key: 'entity.listing', fallback: 'marketplace listing' },\n entityRouteId: 'healthybowl-listing',\n find: (name, signal) =>\n findByName(\n deps,\n LIST_LISTINGS_FOR_ASSISTANT,\n 'AssistantFindListings',\n 'getHealthyBowlMarketplaceData',\n 'marketplaceProducts',\n name,\n signal,\n (row) => text(row.name)\n ),\n };\n return [animals, listings];\n}\n\nexport const HEALTHYBOWL_RECORD_ADAPTERS: readonly AssistantRecordAdapter[] = createHealthyBowlRecordAdapters();\n"],"mappings":";;AAgCA,IAAa,IAA6B,sKAQ7B,IAA8B,2KAarC,IAA+B;CACnC,cAAc,OAAO,OAAa,MAAM,OAAO,sCAAsC,aAAa,CAAO;CACzG,gBAAgB,aAAa,MAAM,OAAO,sCAAsC,qBAAqB;AACvG,GAQM,KAAQ,MACZ,OAAO,KAAU,YAAY,EAAM,KAAK,EAAE,SAAS,IAAI,EAAM,KAAK,IAAI;AAGxE,SAAgB,EAAS,GAAc,GAAuB;CAE5D,IAAM,IAAS,EAAoB,CAAI;CACvC,IAAI,CAAC,GAAQ,OAAO;CACpB,IAAM,IAAQ,EAAoB,CAAI,EAAE,MAAM,GAAG;CACjD,OAAO,EAAO,MAAM,GAAG,EAAE,OAAO,MAAS,EAAM,MAAM,MAAc,EAAU,WAAW,CAAI,CAAC,CAAC;AAChG;AAEA,eAAe,EACb,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GAC0C;CAC1C,IAAM,IAAc,MAAM,EAAK,eAAe;CAC9C,IAAI,CAAC,GAAa,OAAO,CAAC;CAC1B,IAAM,IAAS,MAAM,EAAK,aAAyE;EACjG,SAAS;EACT;EACA;EACA,WAAW,EAAE,SAAS,EAAE,eAAY,EAAE;EAEtC,gBAAgB;EAChB;EACA,gBAAgB;EAChB;EACA,0BAA0B;CAC5B,CAAC;CACD,IAAI,EAAO,QAAQ,QAAQ,OAAO,CAAC;CACnC,IAAM,IAAO,EAAO,OAAO,KAAS;CACpC,IAAI,CAAC,MAAM,QAAQ,CAAI,GAAG,OAAO,CAAC;CAClC,IAAM,IAAkC,CAAC;CACzC,KAAK,IAAM,KAAO,GAA8B;EAC9C,IAAI,CAAC,KAAO,OAAO,EAAI,MAAO,YAAY,EAAI,GAAG,WAAW,GAAG;EAC/D,IAAM,IAAQ,EAAM,CAAG;EACnB,MAAU,QAAQ,CAAC,EAAS,GAAM,CAAK,KAC3C,EAAQ,KAAK;GAAE,QAAQ,EAAE,IAAI,EAAI,GAAG;GAAG,MAAM;EAAM,CAAC;CACtD;CACA,OAAO;AACT;AAEA,SAAgB,EACd,IAA0B,GACS;CAoCnC,OAAO,CAAC;EAlCN,IAAI;EACJ,OAAO,CAAC,UAAU,SAAS;EAC3B,MAAM;GAAE,KAAK;GAAiB,UAAU;EAAS;EACjD,eAAe;EACf,OAAO,GAAM,MACX,EACE,GACA,GACA,wBACA,+BACA,WACA,GACA,IAEC,MAAQ,EAAK,EAAI,IAAI,KAAK,EAAK,EAAI,SAAS,CAC/C;CAmBI,GAAS;EAhBf,IAAI;EACJ,OAAO;GAAC;GAAW;GAAY;GAAuB;GAAwB;GAAW;EAAU;EACnG,MAAM;GAAE,KAAK;GAAkB,UAAU;EAAsB;EAC/D,eAAe;EACf,OAAO,GAAM,MACX,EACE,GACA,GACA,yBACA,iCACA,uBACA,GACA,IACC,MAAQ,EAAK,EAAI,IAAI,CACxB;CAEa,CAAQ;AAC3B;AAEA,IAAa,IAAiE,EAAgC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.1008.2",
3
+ "version": "2026.1009.1",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [