@burdenoff/microfe-healthybowl 2026.1004.1 → 2026.1005.2
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,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { HEALTHYBOWL_RECORD_ADAPTERS as e } from "./recordAdapters.js";
|
|
2
|
+
var t = {
|
|
2
3
|
themeWords: "any",
|
|
3
4
|
entityRoutes: [
|
|
4
5
|
{
|
|
@@ -87,9 +88,10 @@ var e = {
|
|
|
87
88
|
fallback: "Connected Systems"
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
]
|
|
91
|
-
|
|
91
|
+
],
|
|
92
|
+
records: e
|
|
93
|
+
}, n = "proposal-v1";
|
|
92
94
|
//#endregion
|
|
93
|
-
export {
|
|
95
|
+
export { t as LOCAL_UI_COMMANDS, n as WRITE_APPROVAL };
|
|
94
96
|
|
|
95
97
|
//# sourceMappingURL=assistantProductOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistantProductOptions.js","names":[],"sources":["../../../src/components/assistant/assistantProductOptions.ts"],"sourcesContent":["/**\n * The three answers fe-libs 2026.929.1 asks every product for, beyond the ones\n * HealthyBowl already gave (BOFF-7801, BOFF-7802, BOFF-7803 5a), plus the list\n * of every answer the panel wrapper gives.\n *\n * ★ A LEAF, deliberately. Its imports are types only, so they are erased at\n * build time, and it loads nothing at run time. The wrapper that mounts the\n * provider (`AIAssistantPanel.tsx`) imports the shared panel, whose\n * react-markdown touches `document` at module scope. Tests that need these\n * VALUES, to run them through fe-libs' own readers, would then need a DOM just\n * to read three constants. So the values live here and the wrapper hands them\n * to the provider.\n */\nimport type { LocalUiCommandOptions } from '@burdenoff/fe-libs/shared/assistant/localUiCommands';\nimport type { AssistantEntityRoute } from '@burdenoff/fe-libs/shared/assistant/uiActions/entityRoutes';\nimport type { AssistantProductCapabilities } from '@burdenoff/fe-libs/shared/assistant/product';\nimport type { WriteApprovalMode } from '@burdenoff/fe-libs/shared/assistant/writeProposals';\n\n/**\n * The pages of ONE record that no sidebar entry names (BOFF-8060 N1b), so \"take me\n * there\" can open them from a link in the assistant's own reply.\n *\n * ★★ `exclude` lists the router's STATIC siblings of each `:id` segment\n * (`HealthyBowlRoutes.tsx`): `crops/:id` would otherwise swallow `crops/fields`,\n * which is a list page, not a crop. `entityRoutes.test.ts` renders every template\n * through the real route table and checks every static sibling against them, so\n * the two lists cannot drift from the router unnoticed.\n *\n * ★ `visibleWith` is the nav entry the person must be able to SEE (a role that\n * cannot see Crops is not taken to a crop). `/integrations/connections` has none:\n * HealthyBowl has no Integrations entry in its navigation (a reviewed product\n * decision), and the page is reached from the user menu.\n */\nexport const ENTITY_ROUTES: readonly AssistantEntityRoute[] = [\n {\n id: 'healthybowl-field',\n pattern: '/healthybowl/crops/fields/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.field', fallback: 'field' },\n },\n {\n id: 'healthybowl-crop',\n pattern: '/healthybowl/crops/:id',\n params: { id: { kind: 'id', exclude: ['fields', 'planning', 'harvest'] } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.crop', fallback: 'crop' },\n },\n {\n id: 'healthybowl-plan',\n pattern: '/healthybowl/crops/planning/:id',\n params: { id: { kind: 'id', exclude: ['calendar', 'report'] } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.plan', fallback: 'crop plan' },\n },\n {\n id: 'healthybowl-harvest',\n pattern: '/healthybowl/crops/harvest/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.harvest', fallback: 'harvest' },\n },\n {\n id: 'healthybowl-animal',\n pattern: '/healthybowl/livestock/animals/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-livestock',\n noun: { key: 'entity.animal', fallback: 'animal' },\n },\n {\n id: 'healthybowl-listing',\n pattern: '/healthybowl/marketplace/:id',\n params: { id: { kind: 'id', exclude: ['cart', 'wishlist', 'orders'] } },\n visibleWith: 'hb-marketplace',\n noun: { key: 'entity.listing', fallback: 'marketplace listing' },\n },\n {\n id: 'healthybowl-connections',\n pattern: '/integrations/connections',\n params: {},\n noun: { key: 'entity.connections', fallback: 'Connected Systems' },\n },\n];\n\n/**\n * How the panel reads a UI command it carries out itself (BOFF-7802).\n *\n * ★★ `any`, fe-libs' default, stated rather than left implicit. fe-libs'\n * guidance: pick `mode-only` only when the product's CONTENT has themes of its\n * own (a BigConsole dashboard, a document designer), where \"use the dark theme\"\n * is about the content and must reach the model. HealthyBowl's content (farms,\n * crops, livestock, orders, the marketplace) has no theme of its own. The only\n * theme a farmer can mean is the app's, so \"use the dark theme\" and \"dark mode\"\n * both change it locally, with no turn spent on the model.\n */\nexport const LOCAL_UI_COMMANDS: LocalUiCommandOptions = { themeWords: 'any', entityRoutes: ENTITY_ROUTES };\n\n/**\n * Whether HealthyBowl's finished turns feed the production latency histograms\n * (BOFF-7801).\n *\n * ★ On. That is fe-libs' own default (on unless `false`) and what HealthyBowl\n * does today: the provider never set the field, so its turns have been reported\n * by default. The reports carry timings and coarse dimensions only, and the\n * proposal flow's latency is a measurement the 5a rollout needs.\n */\nexport const REPORT_TURN_TIMINGS: boolean = true;\n\n/**\n * Which write-approval flow HealthyBowl's assistant REQUESTS (BOFF-7803 5a).\n *\n * ★★★ At `proposal-v1` fe-libs provisions Ask and Take action through the\n * `assistant:use`-gated `provisionAssistantSandbox`, requests the proposal flow\n * for Take action, and lets a spoken Take-action turn through only when the\n * sandbox's own `/health` also says v1. Every change then waits for the button\n * on its card; the sandbox and wspace-sandbox-svc decide whether it runs.\n *\n * ★★ That provisioning path has NO `createSandbox` fallback: while\n * wspace-sandbox-svc cannot answer it (its session relay switched off), the\n * assistant cannot start at all. This flag reaches users only when\n * healthybowl-app pins the microfe version that carries it, so the app bump is\n * the release switch.\n *\n * ★ It decides what the panel ASKS FOR, never which UI it shows: cards, the\n * confirm dialog and the prompt's write rules all follow the issuing sandbox's\n * own `/health`.\n */\nexport const WRITE_APPROVAL: WriteApprovalMode = 'proposal-v1';\n\n/**\n * Every question the shared panel asks that HealthyBowl answers, each passed to\n * `<AssistantProductProvider>` in `AIAssistantPanel.tsx` as `field={VALUE}`.\n * `productSeam.test.ts` checks the wrapper source against this list.\n */\nexport const ANSWERED_CAPABILITIES = [\n 'modes',\n 'describeCurrentPage',\n 'gatherPageContext',\n 'buildPrompt',\n 'reportTokenUsage',\n 'storageFolders',\n 'localUiCommands',\n 'reportTurnTimings',\n 'writeApproval',\n] as const satisfies readonly (keyof AssistantProductCapabilities)[];\n\n/**\n * The one question HealthyBowl leaves to fe-libs ON PURPOSE.\n *\n * ★★ `confirmWrite`: with none, a HIGH-risk write proposal is confirmed in\n * fe-libs' shared `AssistantWriteConfirmDialog` (BOFF-7803 5a), because that is\n * the STRONGER of the two dialogs HealthyBowl could use.\n *\n * HealthyBowl does have a dialog of its own: `ConfirmProvider` / `useConfirm`\n * in `src/healthybowl/components/ConfirmDialog.tsx`, mounted in\n * `HealthyBowlRoot.tsx`. It is a generic OK/Cancel `AlertDialog` (title,\n * message, two buttons) built for delete prompts. It has no server readback,\n * no target count, no consequences, no 600 ms arming, no trusted-click check\n * and no Enter guard, so an adapter over it cannot meet the contract fe-libs\n * sets for `confirmWrite` (readback, `targetCount`, consequences, the exact\n * `confirmLabel`, payload options read-only, sensitive values masked). The\n * shared dialog meets all of it. (It is also mounted only inside\n * `HealthyBowlRoot`, while the assistant panel mounts in the app shell outside\n * it, where `useConfirm` throws.)\n *\n * This keeps the operator's 09-26 intent, \"HIGH proposals use the stronger\n * dialog\". It DEPARTS from the write-approval contract §3.4 and checklist W3.3,\n * which planned an adapter over HealthyBowl's `ConfirmProvider`; the departure\n * is recorded on BOFF-7803. Adopt `confirmWrite` only with a HealthyBowl dialog\n * that meets the whole contract, plus a contract test.\n */\nexport const LEFT_TO_FE_LIBS = ['confirmWrite'] as const satisfies readonly (keyof AssistantProductCapabilities)[];\n\n/**\n * ★★ Compile-time, enforced by `type:check`: every field of fe-libs'\n * `AssistantProductCapabilities` is either answered above or deliberately left\n * to fe-libs. Every field there is OPTIONAL, so a field fe-libs adds would\n * otherwise go unanswered with no error anywhere. It silently takes fe-libs'\n * default, which is how a product ends up on a behaviour nobody chose. When\n * this line fails, decide the new field and add it to one of the two lists.\n */\ntype Unanswered = Exclude<\n keyof AssistantProductCapabilities,\n (typeof ANSWERED_CAPABILITIES)[number] | (typeof LEFT_TO_FE_LIBS)[number]\n>;\nexport const EVERY_CAPABILITY_DECIDED: [Unanswered] extends [never] ? true : false = true;\n"],"mappings":"AA+FA,IAAa,IAA2C;CAAE,YAAY;CAAO,cAAc;EA7DzF;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAgB,UAAU;GAAQ;EACjD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS;KAAC;KAAU;KAAY;IAAS;GAAE,EAAE;GACzE,aAAa;GACb,MAAM;IAAE,KAAK;IAAe,UAAU;GAAO;EAC/C;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS,CAAC,YAAY,QAAQ;GAAE,EAAE;GAC9D,aAAa;GACb,MAAM;IAAE,KAAK;IAAe,UAAU;GAAY;EACpD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAkB,UAAU;GAAU;EACrD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAiB,UAAU;GAAS;EACnD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS;KAAC;KAAQ;KAAY;IAAQ;GAAE,EAAE;GACtE,aAAa;GACb,MAAM;IAAE,KAAK;IAAkB,UAAU;GAAsB;EACjE;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,CAAC;GACT,MAAM;IAAE,KAAK;IAAsB,UAAU;GAAoB;EACnE;CAcyF;AAAc,GAgC5F,IAAoC"}
|
|
1
|
+
{"version":3,"file":"assistantProductOptions.js","names":[],"sources":["../../../src/components/assistant/assistantProductOptions.ts"],"sourcesContent":["/**\n * The three answers fe-libs 2026.929.1 asks every product for, beyond the ones\n * HealthyBowl already gave (BOFF-7801, BOFF-7802, BOFF-7803 5a), plus the list\n * of every answer the panel wrapper gives.\n *\n * ★ A LEAF, deliberately. Its imports are types only, so they are erased at\n * build time, and it loads nothing at run time. The wrapper that mounts the\n * provider (`AIAssistantPanel.tsx`) imports the shared panel, whose\n * react-markdown touches `document` at module scope. Tests that need these\n * VALUES, to run them through fe-libs' own readers, would then need a DOM just\n * to read three constants. So the values live here and the wrapper hands them\n * to the provider.\n */\nimport type { LocalUiCommandOptions } from '@burdenoff/fe-libs/shared/assistant/localUiCommands';\nimport type { AssistantEntityRoute } from '@burdenoff/fe-libs/shared/assistant/uiActions/entityRoutes';\nimport type { AssistantProductCapabilities } from '@burdenoff/fe-libs/shared/assistant/product';\nimport type { WriteApprovalMode } from '@burdenoff/fe-libs/shared/assistant/writeProposals';\n\nimport { HEALTHYBOWL_RECORD_ADAPTERS } from './recordAdapters';\n\n/**\n * The pages of ONE record that no sidebar entry names (BOFF-8060 N1b), so \"take me\n * there\" can open them from a link in the assistant's own reply.\n *\n * ★★ `exclude` lists the router's STATIC siblings of each `:id` segment\n * (`HealthyBowlRoutes.tsx`): `crops/:id` would otherwise swallow `crops/fields`,\n * which is a list page, not a crop. `entityRoutes.test.ts` renders every template\n * through the real route table and checks every static sibling against them, so\n * the two lists cannot drift from the router unnoticed.\n *\n * ★ `visibleWith` is the nav entry the person must be able to SEE (a role that\n * cannot see Crops is not taken to a crop). `/integrations/connections` has none:\n * HealthyBowl has no Integrations entry in its navigation (a reviewed product\n * decision), and the page is reached from the user menu.\n */\nexport const ENTITY_ROUTES: readonly AssistantEntityRoute[] = [\n {\n id: 'healthybowl-field',\n pattern: '/healthybowl/crops/fields/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.field', fallback: 'field' },\n },\n {\n id: 'healthybowl-crop',\n pattern: '/healthybowl/crops/:id',\n params: { id: { kind: 'id', exclude: ['fields', 'planning', 'harvest'] } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.crop', fallback: 'crop' },\n },\n {\n id: 'healthybowl-plan',\n pattern: '/healthybowl/crops/planning/:id',\n params: { id: { kind: 'id', exclude: ['calendar', 'report'] } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.plan', fallback: 'crop plan' },\n },\n {\n id: 'healthybowl-harvest',\n pattern: '/healthybowl/crops/harvest/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-crops',\n noun: { key: 'entity.harvest', fallback: 'harvest' },\n },\n {\n id: 'healthybowl-animal',\n pattern: '/healthybowl/livestock/animals/:id',\n params: { id: { kind: 'id' } },\n visibleWith: 'hb-grp-livestock',\n noun: { key: 'entity.animal', fallback: 'animal' },\n },\n {\n id: 'healthybowl-listing',\n pattern: '/healthybowl/marketplace/:id',\n params: { id: { kind: 'id', exclude: ['cart', 'wishlist', 'orders'] } },\n visibleWith: 'hb-marketplace',\n noun: { key: 'entity.listing', fallback: 'marketplace listing' },\n },\n {\n id: 'healthybowl-connections',\n pattern: '/integrations/connections',\n params: {},\n noun: { key: 'entity.connections', fallback: 'Connected Systems' },\n },\n];\n\n/**\n * How the panel reads a UI command it carries out itself (BOFF-7802).\n *\n * ★★ `any`, fe-libs' default, stated rather than left implicit. fe-libs'\n * guidance: pick `mode-only` only when the product's CONTENT has themes of its\n * own (a BigConsole dashboard, a document designer), where \"use the dark theme\"\n * is about the content and must reach the model. HealthyBowl's content (farms,\n * crops, livestock, orders, the marketplace) has no theme of its own. The only\n * theme a farmer can mean is the app's, so \"use the dark theme\" and \"dark mode\"\n * both change it locally, with no turn spent on the model.\n */\nexport const LOCAL_UI_COMMANDS: LocalUiCommandOptions = {\n themeWords: 'any',\n entityRoutes: ENTITY_ROUTES,\n // BOFF-8060 N1b: \"open Bella the cow\", \"open the organic tomatoes listing\", by name.\n // Animals and marketplace listings only: crops and fields are BOFF-7151's.\n records: HEALTHYBOWL_RECORD_ADAPTERS,\n};\n\n/**\n * Whether HealthyBowl's finished turns feed the production latency histograms\n * (BOFF-7801).\n *\n * ★ On. That is fe-libs' own default (on unless `false`) and what HealthyBowl\n * does today: the provider never set the field, so its turns have been reported\n * by default. The reports carry timings and coarse dimensions only, and the\n * proposal flow's latency is a measurement the 5a rollout needs.\n */\nexport const REPORT_TURN_TIMINGS: boolean = true;\n\n/**\n * Which write-approval flow HealthyBowl's assistant REQUESTS (BOFF-7803 5a).\n *\n * ★★★ At `proposal-v1` fe-libs provisions Ask and Take action through the\n * `assistant:use`-gated `provisionAssistantSandbox`, requests the proposal flow\n * for Take action, and lets a spoken Take-action turn through only when the\n * sandbox's own `/health` also says v1. Every change then waits for the button\n * on its card; the sandbox and wspace-sandbox-svc decide whether it runs.\n *\n * ★★ That provisioning path has NO `createSandbox` fallback: while\n * wspace-sandbox-svc cannot answer it (its session relay switched off), the\n * assistant cannot start at all. This flag reaches users only when\n * healthybowl-app pins the microfe version that carries it, so the app bump is\n * the release switch.\n *\n * ★ It decides what the panel ASKS FOR, never which UI it shows: cards, the\n * confirm dialog and the prompt's write rules all follow the issuing sandbox's\n * own `/health`.\n */\nexport const WRITE_APPROVAL: WriteApprovalMode = 'proposal-v1';\n\n/**\n * Every question the shared panel asks that HealthyBowl answers, each passed to\n * `<AssistantProductProvider>` in `AIAssistantPanel.tsx` as `field={VALUE}`.\n * `productSeam.test.ts` checks the wrapper source against this list.\n */\nexport const ANSWERED_CAPABILITIES = [\n 'modes',\n 'describeCurrentPage',\n 'gatherPageContext',\n 'buildPrompt',\n 'reportTokenUsage',\n 'storageFolders',\n 'localUiCommands',\n 'reportTurnTimings',\n 'writeApproval',\n] as const satisfies readonly (keyof AssistantProductCapabilities)[];\n\n/**\n * The one question HealthyBowl leaves to fe-libs ON PURPOSE.\n *\n * ★★ `confirmWrite`: with none, a HIGH-risk write proposal is confirmed in\n * fe-libs' shared `AssistantWriteConfirmDialog` (BOFF-7803 5a), because that is\n * the STRONGER of the two dialogs HealthyBowl could use.\n *\n * HealthyBowl does have a dialog of its own: `ConfirmProvider` / `useConfirm`\n * in `src/healthybowl/components/ConfirmDialog.tsx`, mounted in\n * `HealthyBowlRoot.tsx`. It is a generic OK/Cancel `AlertDialog` (title,\n * message, two buttons) built for delete prompts. It has no server readback,\n * no target count, no consequences, no 600 ms arming, no trusted-click check\n * and no Enter guard, so an adapter over it cannot meet the contract fe-libs\n * sets for `confirmWrite` (readback, `targetCount`, consequences, the exact\n * `confirmLabel`, payload options read-only, sensitive values masked). The\n * shared dialog meets all of it. (It is also mounted only inside\n * `HealthyBowlRoot`, while the assistant panel mounts in the app shell outside\n * it, where `useConfirm` throws.)\n *\n * This keeps the operator's 09-26 intent, \"HIGH proposals use the stronger\n * dialog\". It DEPARTS from the write-approval contract §3.4 and checklist W3.3,\n * which planned an adapter over HealthyBowl's `ConfirmProvider`; the departure\n * is recorded on BOFF-7803. Adopt `confirmWrite` only with a HealthyBowl dialog\n * that meets the whole contract, plus a contract test.\n */\nexport const LEFT_TO_FE_LIBS = ['confirmWrite'] as const satisfies readonly (keyof AssistantProductCapabilities)[];\n\n/**\n * ★★ Compile-time, enforced by `type:check`: every field of fe-libs'\n * `AssistantProductCapabilities` is either answered above or deliberately left\n * to fe-libs. Every field there is OPTIONAL, so a field fe-libs adds would\n * otherwise go unanswered with no error anywhere. It silently takes fe-libs'\n * default, which is how a product ends up on a behaviour nobody chose. When\n * this line fails, decide the new field and add it to one of the two lists.\n */\ntype Unanswered = Exclude<\n keyof AssistantProductCapabilities,\n (typeof ANSWERED_CAPABILITIES)[number] | (typeof LEFT_TO_FE_LIBS)[number]\n>;\nexport const EVERY_CAPABILITY_DECIDED: [Unanswered] extends [never] ? true : false = true;\n"],"mappings":";AAiGA,IAAa,IAA2C;CACtD,YAAY;CACZ,cAAc;EA/Dd;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAgB,UAAU;GAAQ;EACjD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS;KAAC;KAAU;KAAY;IAAS;GAAE,EAAE;GACzE,aAAa;GACb,MAAM;IAAE,KAAK;IAAe,UAAU;GAAO;EAC/C;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS,CAAC,YAAY,QAAQ;GAAE,EAAE;GAC9D,aAAa;GACb,MAAM;IAAE,KAAK;IAAe,UAAU;GAAY;EACpD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAkB,UAAU;GAAU;EACrD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI,EAAE,MAAM,KAAK,EAAE;GAC7B,aAAa;GACb,MAAM;IAAE,KAAK;IAAiB,UAAU;GAAS;EACnD;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,EAAE,IAAI;IAAE,MAAM;IAAM,SAAS;KAAC;KAAQ;KAAY;IAAQ;GAAE,EAAE;GACtE,aAAa;GACb,MAAM;IAAE,KAAK;IAAkB,UAAU;GAAsB;EACjE;EACA;GACE,IAAI;GACJ,SAAS;GACT,QAAQ,CAAC;GACT,MAAM;IAAE,KAAK;IAAsB,UAAU;GAAoB;EACnE;CAgBc;CAGd,SAAS;AACX,GAgCa,IAAoC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#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
|
+
graphqlFetch: async (e) => (await import("@burdenoff/fe-libs/shared/graphql")).graphqlFetch(e),
|
|
4
|
+
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)));
|
|
11
|
+
}
|
|
12
|
+
async function o(e, t, n, r, i, o, s, c) {
|
|
13
|
+
let l = await e.getWorkspaceId();
|
|
14
|
+
if (!l) return [];
|
|
15
|
+
let u = await e.graphqlFetch({
|
|
16
|
+
gateway: "workspace",
|
|
17
|
+
query: t,
|
|
18
|
+
operationName: n,
|
|
19
|
+
variables: { context: { workspaceId: l } },
|
|
20
|
+
workspaceToken: !0,
|
|
21
|
+
workspaceId: l,
|
|
22
|
+
organizationId: !0,
|
|
23
|
+
signal: s,
|
|
24
|
+
suppressGlobalErrorEvent: !0
|
|
25
|
+
});
|
|
26
|
+
if (u.errors?.length) return [];
|
|
27
|
+
let d = u.data?.[r]?.[i];
|
|
28
|
+
if (!Array.isArray(d)) return [];
|
|
29
|
+
let f = [];
|
|
30
|
+
for (let e of d) {
|
|
31
|
+
if (!e || typeof e.id != "string" || e.id.length === 0) continue;
|
|
32
|
+
let t = c(e);
|
|
33
|
+
t === null || !a(o, t) || f.push({
|
|
34
|
+
params: { id: e.id },
|
|
35
|
+
name: t
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return f;
|
|
39
|
+
}
|
|
40
|
+
function s(i = n) {
|
|
41
|
+
return [{
|
|
42
|
+
id: "healthybowl-animal",
|
|
43
|
+
nouns: ["animal", "animals"],
|
|
44
|
+
noun: {
|
|
45
|
+
key: "entity.animal",
|
|
46
|
+
fallback: "animal"
|
|
47
|
+
},
|
|
48
|
+
entityRouteId: "healthybowl-animal",
|
|
49
|
+
find: (t, n) => o(i, e, "AssistantFindAnimals", "getHealthyBowlLivestockData", "animals", t, n, (e) => r(e.name) ?? r(e.tagNumber))
|
|
50
|
+
}, {
|
|
51
|
+
id: "healthybowl-listing",
|
|
52
|
+
nouns: [
|
|
53
|
+
"listing",
|
|
54
|
+
"listings",
|
|
55
|
+
"marketplace listing",
|
|
56
|
+
"marketplace listings",
|
|
57
|
+
"product",
|
|
58
|
+
"products"
|
|
59
|
+
],
|
|
60
|
+
noun: {
|
|
61
|
+
key: "entity.listing",
|
|
62
|
+
fallback: "marketplace listing"
|
|
63
|
+
},
|
|
64
|
+
entityRouteId: "healthybowl-listing",
|
|
65
|
+
find: (e, n) => o(i, t, "AssistantFindListings", "getHealthyBowlMarketplaceData", "marketplaceProducts", e, n, (e) => r(e.name))
|
|
66
|
+
}];
|
|
67
|
+
}
|
|
68
|
+
var c = s();
|
|
69
|
+
//#endregion
|
|
70
|
+
export { c as HEALTHYBOWL_RECORD_ADAPTERS };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=recordAdapters.js.map
|
|
@@ -0,0 +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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-healthybowl",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1005.2",
|
|
4
4
|
"description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apollo/client": "^4.0.11",
|
|
51
|
-
"@burdenoff/fe-libs": "2026.
|
|
51
|
+
"@burdenoff/fe-libs": "2026.1005.1",
|
|
52
52
|
"@burdenoff/planmagnet-fe-sdk": "2026.831.1",
|
|
53
53
|
"@tanstack/react-query": "^5.90.16",
|
|
54
54
|
"clsx": "^2.1.1",
|