@burdenoff/microfe-healthybowl 2026.716.1 → 2026.716.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.
@@ -9,20 +9,21 @@ function o() {
9
9
  if (!e) throw Error("useHealthyBowl must be used within a HealthyBowlProvider");
10
10
  return e;
11
11
  }
12
- var s = ({ children: t, basePath: n = "/", navigate: o = () => {}, currentUser: s, workspaceId: c = "", apiGatewayUrl: l = "", authToken: u = "", googleMapsApiKey: d }) => {
13
- e({ googleMapsApiKey: d });
14
- let f = {
12
+ var s = ({ children: t, basePath: n = "/", navigate: o = () => {}, currentUser: s, workspaceId: c = "", apiGatewayUrl: l = "", globalGatewayUrl: u = "", authToken: d = "", googleMapsApiKey: f }) => {
13
+ e({ googleMapsApiKey: f });
14
+ let p = {
15
15
  basePath: n,
16
16
  navigate: o,
17
17
  currentUser: s,
18
18
  workspaceId: c,
19
19
  apiGatewayUrl: l,
20
- authToken: u
21
- }, p = /* @__PURE__ */ i(a.Provider, {
22
- value: f,
20
+ globalGatewayUrl: u,
21
+ authToken: d
22
+ }, m = /* @__PURE__ */ i(a.Provider, {
23
+ value: p,
23
24
  children: t
24
25
  });
25
- return n && n !== "/" ? p : /* @__PURE__ */ i(r, { children: p });
26
+ return n && n !== "/" ? m : /* @__PURE__ */ i(r, { children: m });
26
27
  };
27
28
  //#endregion
28
29
  export { s as HealthyBowlProvider, o as useHealthyBowl };
@@ -1 +1 @@
1
- {"version":3,"file":"HealthyBowlContext.js","names":[],"sources":["../../../src/healthybowl/context/HealthyBowlContext.tsx"],"sourcesContent":["/**\n * HealthyBowl Context Provider\n * @module healthybowl\n */\n\nimport { createContext, useContext, type FC, type PropsWithChildren } from 'react';\nimport { MemoryRouter } from 'react-router-dom';\nimport type { HealthyBowlRootProps } from '../types';\nimport { configureGeocoder } from '../utils/geocode';\n\ninterface HealthyBowlContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: HealthyBowlRootProps['currentUser'];\n workspaceId: string;\n apiGatewayUrl: string;\n authToken: string;\n}\n\nconst HealthyBowlContext = createContext<HealthyBowlContextValue | null>(null);\n\nexport function useHealthyBowl(): HealthyBowlContextValue {\n const context = useContext(HealthyBowlContext);\n if (!context) {\n throw new Error('useHealthyBowl must be used within a HealthyBowlProvider');\n }\n return context;\n}\n\nexport const HealthyBowlProvider: FC<PropsWithChildren<HealthyBowlRootProps>> = ({\n children,\n basePath = '/',\n navigate = () => {},\n currentUser,\n workspaceId = '',\n apiGatewayUrl = '',\n authToken = '',\n googleMapsApiKey,\n}) => {\n // Inject the host app's Google Maps key into the (non-React) geocoder. Done\n // synchronously in render (not useEffect) so it's set before child map effects\n // run — child effects fire before parent effects. Idempotent module assignment.\n configureGeocoder({ googleMapsApiKey });\n\n const contextValue: HealthyBowlContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n apiGatewayUrl,\n authToken,\n };\n\n const content = <HealthyBowlContext.Provider value={contextValue}>{children}</HealthyBowlContext.Provider>;\n\n // If basePath is provided, we're running inside the host shell (which has BrowserRouter)\n if (basePath && basePath !== '/') return content;\n\n // Standalone mode: wrap in MemoryRouter\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;AAmBA,IAAM,IAAqB,EAA8C,KAAK;AAE9E,SAAgB,IAA0C;CACxD,IAAM,IAAU,EAAW,EAAmB;AAC9C,KAAI,CAAC,EACH,OAAU,MAAM,2DAA2D;AAE7E,QAAO;;AAGT,IAAa,KAAoE,EAC/E,aACA,cAAW,KACX,oBAAiB,IACjB,gBACA,iBAAc,IACd,mBAAgB,IAChB,eAAY,IACZ,0BACI;AAIJ,GAAkB,EAAE,qBAAkB,CAAC;CAEvC,IAAM,IAAwC;EAC5C;EACA;EACA;EACA;EACA;EACA;EACD,EAEK,IAAU,kBAAC,EAAmB,UAApB;EAA6B,OAAO;EAAe;EAAuC,CAAA;AAM1G,QAHI,KAAY,MAAa,MAAY,IAGlC,kBAAC,GAAD,EAAA,UAAe,GAAuB,CAAA"}
1
+ {"version":3,"file":"HealthyBowlContext.js","names":[],"sources":["../../../src/healthybowl/context/HealthyBowlContext.tsx"],"sourcesContent":["/**\n * HealthyBowl Context Provider\n * @module healthybowl\n */\n\nimport { createContext, useContext, type FC, type PropsWithChildren } from 'react';\nimport { MemoryRouter } from 'react-router-dom';\nimport type { HealthyBowlRootProps } from '../types';\nimport { configureGeocoder } from '../utils/geocode';\n\ninterface HealthyBowlContextValue {\n basePath: string;\n navigate: (path: string) => void;\n currentUser: HealthyBowlRootProps['currentUser'];\n workspaceId: string;\n apiGatewayUrl: string;\n globalGatewayUrl: string;\n authToken: string;\n}\n\nconst HealthyBowlContext = createContext<HealthyBowlContextValue | null>(null);\n\nexport function useHealthyBowl(): HealthyBowlContextValue {\n const context = useContext(HealthyBowlContext);\n if (!context) {\n throw new Error('useHealthyBowl must be used within a HealthyBowlProvider');\n }\n return context;\n}\n\nexport const HealthyBowlProvider: FC<PropsWithChildren<HealthyBowlRootProps>> = ({\n children,\n basePath = '/',\n navigate = () => {},\n currentUser,\n workspaceId = '',\n apiGatewayUrl = '',\n globalGatewayUrl = '',\n authToken = '',\n googleMapsApiKey,\n}) => {\n // Inject the host app's Google Maps key into the (non-React) geocoder. Done\n // synchronously in render (not useEffect) so it's set before child map effects\n // run — child effects fire before parent effects. Idempotent module assignment.\n configureGeocoder({ googleMapsApiKey });\n\n const contextValue: HealthyBowlContextValue = {\n basePath,\n navigate,\n currentUser,\n workspaceId,\n apiGatewayUrl,\n globalGatewayUrl,\n authToken,\n };\n\n const content = <HealthyBowlContext.Provider value={contextValue}>{children}</HealthyBowlContext.Provider>;\n\n // If basePath is provided, we're running inside the host shell (which has BrowserRouter)\n if (basePath && basePath !== '/') return content;\n\n // Standalone mode: wrap in MemoryRouter\n return <MemoryRouter>{content}</MemoryRouter>;\n};\n"],"mappings":";;;;;AAoBA,IAAM,IAAqB,EAA8C,KAAK;AAE9E,SAAgB,IAA0C;CACxD,IAAM,IAAU,EAAW,EAAmB;AAC9C,KAAI,CAAC,EACH,OAAU,MAAM,2DAA2D;AAE7E,QAAO;;AAGT,IAAa,KAAoE,EAC/E,aACA,cAAW,KACX,oBAAiB,IACjB,gBACA,iBAAc,IACd,mBAAgB,IAChB,sBAAmB,IACnB,eAAY,IACZ,0BACI;AAIJ,GAAkB,EAAE,qBAAkB,CAAC;CAEvC,IAAM,IAAwC;EAC5C;EACA;EACA;EACA;EACA;EACA;EACA;EACD,EAEK,IAAU,kBAAC,EAAmB,UAApB;EAA6B,OAAO;EAAe;EAAuC,CAAA;AAM1G,QAHI,KAAY,MAAa,MAAY,IAGlC,kBAAC,GAAD,EAAA,UAAe,GAAuB,CAAA"}
@@ -0,0 +1,63 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useEffect as n, useState as r } from "react";
3
+ //#region src/healthybowl/hooks/useStoreProduce.ts
4
+ var i = "\n query MarketplaceStoreProduce($input: BrowseStoreInput!) {\n browseStore(input: $input) {\n products {\n id\n name\n slug\n description\n price\n currency\n icon\n category\n stockQuantity\n }\n totalCount\n }\n }\n";
5
+ function a(a = 12) {
6
+ let { globalGatewayUrl: o } = e(), [s, c] = r({
7
+ produce: [],
8
+ totalCount: 0,
9
+ loading: !!o,
10
+ error: null
11
+ }), l = t(async () => {
12
+ if (!o) {
13
+ c({
14
+ produce: [],
15
+ totalCount: 0,
16
+ loading: !1,
17
+ error: null
18
+ });
19
+ return;
20
+ }
21
+ c((e) => ({
22
+ ...e,
23
+ loading: !0,
24
+ error: null
25
+ }));
26
+ try {
27
+ let e = await (await fetch(`${o}/global/graphql`, {
28
+ method: "POST",
29
+ credentials: "include",
30
+ headers: { "content-type": "application/json" },
31
+ body: JSON.stringify({
32
+ query: i,
33
+ variables: { input: { filter: { nature: "PHYSICAL" } } }
34
+ })
35
+ })).json();
36
+ if (e.errors?.length) throw Error(e.errors[0]?.message ?? "browseStore request failed");
37
+ let t = e.data?.browseStore;
38
+ c({
39
+ produce: (t?.products ?? []).slice(0, a),
40
+ totalCount: t?.totalCount ?? 0,
41
+ loading: !1,
42
+ error: null
43
+ });
44
+ } catch (e) {
45
+ c({
46
+ produce: [],
47
+ totalCount: 0,
48
+ loading: !1,
49
+ error: e instanceof Error ? e.message : "Unknown error"
50
+ });
51
+ }
52
+ }, [o, a]);
53
+ return n(() => {
54
+ l();
55
+ }, [l]), {
56
+ ...s,
57
+ refetch: () => void l()
58
+ };
59
+ }
60
+ //#endregion
61
+ export { a as useStoreProduce };
62
+
63
+ //# sourceMappingURL=useStoreProduce.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStoreProduce.js","names":[],"sources":["../../../src/healthybowl/hooks/useStoreProduce.ts"],"sourcesContent":["/**\n * Reads the cross-farm store catalog (global-store `browseStore`) so published\n * physical/produce listings from other farms surface in the HealthyBowl marketplace.\n *\n * `browseStore` is a public query (@rbac public) that returns only PUBLISHED products\n * for non-admin callers, so no auth token is needed — just the global gateway URL the\n * host app injects. It lives on the GLOBAL gateway, not the wspace `apiGatewayUrl`.\n *\n * @module healthybowl\n */\n\nimport { useCallback, useEffect, useState } from 'react';\n\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nexport interface StoreProduceItem {\n id: string;\n name: string;\n slug: string;\n description: string | null;\n price: number;\n currency: string;\n icon: string | null;\n category: string | null;\n stockQuantity: number | null;\n}\n\ninterface StoreProduceState {\n produce: StoreProduceItem[];\n totalCount: number;\n loading: boolean;\n error: string | null;\n}\n\nconst BROWSE_STORE_PRODUCE = /* GraphQL */ `\n query MarketplaceStoreProduce($input: BrowseStoreInput!) {\n browseStore(input: $input) {\n products {\n id\n name\n slug\n description\n price\n currency\n icon\n category\n stockQuantity\n }\n totalCount\n }\n }\n`;\n\n/**\n * Fetch up to `limit` published physical products from the global store catalog.\n * Supplemental to the farm-native marketplace — failures degrade to an empty list\n * rather than breaking the page.\n */\nexport function useStoreProduce(limit = 12): StoreProduceState & { refetch: () => void } {\n const { globalGatewayUrl } = useHealthyBowl();\n const [state, setState] = useState<StoreProduceState>({\n produce: [],\n totalCount: 0,\n loading: Boolean(globalGatewayUrl),\n error: null,\n });\n\n const fetchProduce = useCallback(async () => {\n if (!globalGatewayUrl) {\n setState({ produce: [], totalCount: 0, loading: false, error: null });\n return;\n }\n setState((prev) => ({ ...prev, loading: true, error: null }));\n try {\n const res = await fetch(`${globalGatewayUrl}/global/graphql`, {\n method: 'POST',\n credentials: 'include',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({\n query: BROWSE_STORE_PRODUCE,\n variables: { input: { filter: { nature: 'PHYSICAL' } } },\n }),\n });\n const json: {\n data?: { browseStore?: { products?: StoreProduceItem[]; totalCount?: number } };\n errors?: { message?: string }[];\n } = await res.json();\n if (json.errors?.length) {\n throw new Error(json.errors[0]?.message ?? 'browseStore request failed');\n }\n const result = json.data?.browseStore;\n setState({\n produce: (result?.products ?? []).slice(0, limit),\n totalCount: result?.totalCount ?? 0,\n loading: false,\n error: null,\n });\n } catch (err) {\n setState({\n produce: [],\n totalCount: 0,\n loading: false,\n error: err instanceof Error ? err.message : 'Unknown error',\n });\n }\n }, [globalGatewayUrl, limit]);\n\n useEffect(() => {\n void fetchProduce();\n }, [fetchProduce]);\n\n return { ...state, refetch: () => void fetchProduce() };\n}\n"],"mappings":";;;AAkCA,IAAM,IAAqC;AAwB3C,SAAgB,EAAgB,IAAQ,IAAiD;CACvF,IAAM,EAAE,wBAAqB,GAAgB,EACvC,CAAC,GAAO,KAAY,EAA4B;EACpD,SAAS,EAAE;EACX,YAAY;EACZ,SAAS,EAAQ;EACjB,OAAO;EACR,CAAC,EAEI,IAAe,EAAY,YAAY;AAC3C,MAAI,CAAC,GAAkB;AACrB,KAAS;IAAE,SAAS,EAAE;IAAE,YAAY;IAAG,SAAS;IAAO,OAAO;IAAM,CAAC;AACrE;;AAEF,KAAU,OAAU;GAAE,GAAG;GAAM,SAAS;GAAM,OAAO;GAAM,EAAE;AAC7D,MAAI;GAUF,IAAM,IAGF,OAZQ,MAAM,MAAM,GAAG,EAAiB,kBAAkB;IAC5D,QAAQ;IACR,aAAa;IACb,SAAS,EAAE,gBAAgB,oBAAoB;IAC/C,MAAM,KAAK,UAAU;KACnB,OAAO;KACP,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,YAAY,EAAE,EAAE;KACzD,CAAC;IACH,CAAC,EAIY,MAAM;AACpB,OAAI,EAAK,QAAQ,OACf,OAAU,MAAM,EAAK,OAAO,IAAI,WAAW,6BAA6B;GAE1E,IAAM,IAAS,EAAK,MAAM;AAC1B,KAAS;IACP,UAAU,GAAQ,YAAY,EAAE,EAAE,MAAM,GAAG,EAAM;IACjD,YAAY,GAAQ,cAAc;IAClC,SAAS;IACT,OAAO;IACR,CAAC;WACK,GAAK;AACZ,KAAS;IACP,SAAS,EAAE;IACX,YAAY;IACZ,SAAS;IACT,OAAO,aAAe,QAAQ,EAAI,UAAU;IAC7C,CAAC;;IAEH,CAAC,GAAkB,EAAM,CAAC;AAM7B,QAJA,QAAgB;AACT,KAAc;IAClB,CAAC,EAAa,CAAC,EAEX;EAAE,GAAG;EAAO,eAAe,KAAK,GAAc;EAAE"}