@burdenoff/microfe-healthybowl 2026.812.10 → 2026.812.12

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.
@@ -55,122 +55,129 @@ var s = "00000000-0000-0000-0000-000000000001", c = [], l = "\n commodity\n va
55
55
  mutation AcknowledgeHealthyBowlPriceAlert($id: ID!, $context: ContextInput!) {
56
56
  acknowledgeHealthyBowlPriceAlert(context: $context, id: $id) { ${p} }
57
57
  }
58
- `;
59
- function T(i = {}) {
58
+ `, T = 2e3;
59
+ function E(i = {}) {
60
60
  let { workspaceId: l } = e(), u = l || s, d = r(() => ({ workspaceId: u }), [u]), f = i.filter, p = o(m, {
61
61
  variables: {
62
62
  context: d,
63
63
  filter: f
64
64
  },
65
65
  fetchPolicy: "cache-and-network"
66
- }), h = o(g, {
66
+ }), h = o(m, {
67
+ variables: r(() => ({
68
+ context: d,
69
+ filter: { limit: T }
70
+ }), [d]),
71
+ fetchPolicy: "cache-first"
72
+ }), E = o(g, {
67
73
  variables: { context: d },
68
74
  fetchPolicy: "cache-and-network"
69
- }), T = o(_, {
75
+ }), D = o(_, {
70
76
  variables: { context: d },
71
77
  fetchPolicy: "cache-and-network"
72
- }), E = o(v, {
78
+ }), O = o(v, {
73
79
  variables: { context: d },
74
80
  fetchPolicy: "cache-and-network"
75
- }), D = p.refetch, O = h.refetch, k = T.refetch, A = E.refetch, j = n(async (...e) => {
81
+ }), k = p.refetch, A = E.refetch, j = D.refetch, M = O.refetch, N = n(async (...e) => {
76
82
  await Promise.all(e.map((e) => e().catch(() => void 0)));
77
- }, []), [M] = a(y), [N] = a(b), [P] = a(x), [F] = a(S), [I] = a(C), [L] = a(w), R = n((e) => ({
83
+ }, []), [P] = a(y), [F] = a(b), [I] = a(x), [L] = a(S), [R] = a(C), [z] = a(w), B = n((e) => ({
78
84
  ...e,
79
85
  context: d
80
- }), [d]), z = r(() => p.data?.getHealthyBowlMandiPrices ?? c, [p.data]);
86
+ }), [d]), V = r(() => p.data?.getHealthyBowlMandiPrices ?? c, [p.data]);
81
87
  return {
82
- prices: z,
83
- commodities: r(() => t(z), [z]),
84
- watches: h.data?.getHealthyBowlPriceWatches ?? [],
85
- alertRules: T.data?.getHealthyBowlPriceAlertRules ?? [],
86
- alerts: E.data?.getHealthyBowlPriceAlerts ?? [],
88
+ prices: V,
89
+ commodities: r(() => t(V), [V]),
90
+ facetPrices: r(() => h.data?.getHealthyBowlMandiPrices ?? V, [h.data, V]),
91
+ watches: E.data?.getHealthyBowlPriceWatches ?? [],
92
+ alertRules: D.data?.getHealthyBowlPriceAlertRules ?? [],
93
+ alerts: O.data?.getHealthyBowlPriceAlerts ?? [],
87
94
  loading: p.loading,
88
95
  error: p.error ?? null,
89
- watchesLoading: h.loading,
90
- rulesLoading: T.loading,
91
- alertsLoading: E.loading,
92
- refetchAll: n(() => j(D, O, k, A), [
93
- j,
94
- D,
95
- O,
96
+ watchesLoading: E.loading,
97
+ rulesLoading: D.loading,
98
+ alertsLoading: O.loading,
99
+ refetchAll: n(() => N(k, A, j, M), [
100
+ N,
96
101
  k,
97
- A
102
+ A,
103
+ j,
104
+ M
98
105
  ]),
99
106
  createWatch: n(async (e) => {
100
- let t = await M({ variables: { input: R(e) } });
107
+ let t = await P({ variables: { input: B(e) } });
101
108
  if (t.error) throw t.error;
102
- return await j(O), t.data?.createHealthyBowlPriceWatch ?? null;
109
+ return await N(A), t.data?.createHealthyBowlPriceWatch ?? null;
103
110
  }, [
104
- M,
105
- R,
106
- j,
107
- O
111
+ P,
112
+ B,
113
+ N,
114
+ A
108
115
  ]),
109
116
  deleteWatch: n(async (e) => {
110
- let t = await N({ variables: {
117
+ let t = await F({ variables: {
111
118
  id: e,
112
119
  context: d
113
120
  } });
114
121
  if (t.error) throw t.error;
115
- await j(O);
122
+ await N(A);
116
123
  }, [
117
- N,
124
+ F,
118
125
  d,
119
- j,
120
- O
126
+ N,
127
+ A
121
128
  ]),
122
129
  createRule: n(async (e) => {
123
- let t = await P({ variables: { input: R(e) } });
130
+ let t = await I({ variables: { input: B(e) } });
124
131
  if (t.error) throw t.error;
125
- return await j(k, A), t.data?.createHealthyBowlPriceAlertRule ?? null;
132
+ return await N(j, M), t.data?.createHealthyBowlPriceAlertRule ?? null;
126
133
  }, [
127
- P,
128
- R,
134
+ I,
135
+ B,
136
+ N,
129
137
  j,
130
- k,
131
- A
138
+ M
132
139
  ]),
133
140
  updateRule: n(async (e) => {
134
- let t = await F({ variables: { input: R(e) } });
141
+ let t = await L({ variables: { input: B(e) } });
135
142
  if (t.error) throw t.error;
136
- return await j(k, A), t.data?.updateHealthyBowlPriceAlertRule ?? null;
143
+ return await N(j, M), t.data?.updateHealthyBowlPriceAlertRule ?? null;
137
144
  }, [
138
- F,
139
- R,
145
+ L,
146
+ B,
147
+ N,
140
148
  j,
141
- k,
142
- A
149
+ M
143
150
  ]),
144
151
  deleteRule: n(async (e) => {
145
- let t = await I({ variables: {
152
+ let t = await R({ variables: {
146
153
  id: e,
147
154
  context: d
148
155
  } });
149
156
  if (t.error) throw t.error;
150
- await j(k);
157
+ await N(j);
151
158
  }, [
152
- I,
159
+ R,
153
160
  d,
154
- j,
155
- k
161
+ N,
162
+ j
156
163
  ]),
157
164
  acknowledgeAlert: n(async (e) => {
158
- let t = await L({ variables: {
165
+ let t = await z({ variables: {
159
166
  id: e,
160
167
  context: d
161
168
  } });
162
169
  if (t.error) throw t.error;
163
- return await j(A), t.data?.acknowledgeHealthyBowlPriceAlert ?? null;
170
+ return await N(M), t.data?.acknowledgeHealthyBowlPriceAlert ?? null;
164
171
  }, [
165
- L,
172
+ z,
166
173
  d,
167
- j,
168
- A
174
+ N,
175
+ M
169
176
  ]),
170
177
  context: d
171
178
  };
172
179
  }
173
- function E(t = {}) {
180
+ function D(t = {}) {
174
181
  let { workspaceId: n } = e(), i = n || s, a = r(() => ({ workspaceId: i }), [i]), c = t.days ?? 30, l = o(h, {
175
182
  variables: {
176
183
  context: a,
@@ -188,6 +195,6 @@ function E(t = {}) {
188
195
  };
189
196
  }
190
197
  //#endregion
191
- export { E as useHealthyBowlMandiPriceTrend, T as useHealthyBowlMandiPrices };
198
+ export { D as useHealthyBowlMandiPriceTrend, E as useHealthyBowlMandiPrices };
192
199
 
193
200
  //# sourceMappingURL=useHealthyBowlMandiPrices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useHealthyBowlMandiPrices.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlMandiPrices.ts"],"sourcesContent":["/**\n * Mandi / Market-Price Intelligence — data hook (roadmap #28 · BOFF-4715).\n *\n * Documents are declared inline with `gql` (not `src/operations/wspace/*.graphql`)\n * because codegen validates operations against the committed `graphql/wspace.graphql`\n * snapshot, which doesn't yet carry the mandi subgraph (schema:pull needs a live\n * gateway) — the same escape hatch `useHealthyBowlSensors` / `useDiseaseWarning`\n * use. Types mirror the deployed `wspace-healthybowl-svc` mandi schema.\n *\n * Reads use `cache-and-network`; every write refetches the lists it invalidates.\n * The commodity roll-up is delegated to the pure `groupPricesByCommodity` helper\n * so it stays unit-testable.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport {\n groupPricesByCommodity,\n type CommodityRow,\n type MandiPrice,\n type MandiPriceTrendPoint,\n type PriceAlert,\n type PriceAlertRule,\n type PriceWatch,\n} from '../utils/mandiPrices';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n/** Stable empty reference so downstream `useMemo`s don't recompute every render. */\nconst EMPTY_PRICES: MandiPrice[] = [];\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\nconst MANDI_PRICE_FIELDS = `\n commodity\n variety\n marketName\n district\n state\n minPrice\n modalPrice\n maxPrice\n arrivalQty\n unit\n priceDate\n source\n`;\n\nconst TREND_POINT_FIELDS = `\n date\n label\n minPrice\n modalPrice\n maxPrice\n`;\n\nconst WATCH_FIELDS = `\n id\n commodity\n marketName\n district\n state\n`;\n\nconst RULE_FIELDS = `\n id\n commodity\n marketName\n comparator\n threshold\n enabled\n`;\n\nconst ALERT_FIELDS = `\n id\n commodity\n marketName\n comparator\n severity\n title\n message\n value\n threshold\n status\n read\n timestamp\n actionUrl\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────────\nconst GET_PRICES = gql`\n query GetHealthyBowlMandiPrices($context: ContextInput!, $filter: HealthyBowlMandiPriceFilterInput) {\n getHealthyBowlMandiPrices(context: $context, filter: $filter) { ${MANDI_PRICE_FIELDS} }\n }\n`;\n\nconst GET_TREND = gql`\n query GetHealthyBowlMandiPriceTrend(\n $context: ContextInput!\n $commodity: String!\n $marketName: String\n $days: Int\n ) {\n getHealthyBowlMandiPriceTrend(context: $context, commodity: $commodity, marketName: $marketName, days: $days) {\n ${TREND_POINT_FIELDS}\n }\n }\n`;\n\nconst GET_WATCHES = gql`\n query GetHealthyBowlPriceWatches($context: ContextInput!) {\n getHealthyBowlPriceWatches(context: $context) { ${WATCH_FIELDS} }\n }\n`;\n\nconst GET_RULES = gql`\n query GetHealthyBowlPriceAlertRules($context: ContextInput!) {\n getHealthyBowlPriceAlertRules(context: $context) { ${RULE_FIELDS} }\n }\n`;\n\nconst GET_ALERTS = gql`\n query GetHealthyBowlPriceAlerts($context: ContextInput!) {\n getHealthyBowlPriceAlerts(context: $context) { ${ALERT_FIELDS} }\n }\n`;\n\nconst CREATE_WATCH = gql`\n mutation CreateHealthyBowlPriceWatch($input: CreateHealthyBowlPriceWatchInput!) {\n createHealthyBowlPriceWatch(input: $input) { ${WATCH_FIELDS} }\n }\n`;\n\nconst DELETE_WATCH = gql`\n mutation DeleteHealthyBowlPriceWatch($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPriceWatch(context: $context, id: $id)\n }\n`;\n\nconst CREATE_RULE = gql`\n mutation CreateHealthyBowlPriceAlertRule($input: CreateHealthyBowlPriceAlertRuleInput!) {\n createHealthyBowlPriceAlertRule(input: $input) { ${RULE_FIELDS} }\n }\n`;\n\nconst UPDATE_RULE = gql`\n mutation UpdateHealthyBowlPriceAlertRule($input: UpdateHealthyBowlPriceAlertRuleInput!) {\n updateHealthyBowlPriceAlertRule(input: $input) { ${RULE_FIELDS} }\n }\n`;\n\nconst DELETE_RULE = gql`\n mutation DeleteHealthyBowlPriceAlertRule($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPriceAlertRule(context: $context, id: $id)\n }\n`;\n\n// A fired PriceAlert is a view over the HB Alert table; acknowledging flips its\n// `read` flag, which the resolver derives into status ACTIVE → ACKNOWLEDGED.\nconst ACKNOWLEDGE_ALERT = gql`\n mutation AcknowledgeHealthyBowlPriceAlert($id: ID!, $context: ContextInput!) {\n acknowledgeHealthyBowlPriceAlert(context: $context, id: $id) { ${ALERT_FIELDS} }\n }\n`;\n\nexport interface MandiPriceFilter {\n commodity?: string | null;\n marketName?: string | null;\n district?: string | null;\n state?: string | null;\n}\n\nexport interface UseMandiPricesOptions {\n /** Optional server-side filter; when omitted, all latest prices are returned. */\n filter?: MandiPriceFilter;\n}\n\nexport function useHealthyBowlMandiPrices(options: UseMandiPricesOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n const filter = options.filter;\n\n const pricesQuery = useQuery<\n { getHealthyBowlMandiPrices: MandiPrice[] },\n { context: HbContext; filter?: MandiPriceFilter }\n >(GET_PRICES, { variables: { context: ctx, filter }, fetchPolicy: 'cache-and-network' });\n const watchesQuery = useQuery<{ getHealthyBowlPriceWatches: PriceWatch[] }, { context: HbContext }>(GET_WATCHES, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n const rulesQuery = useQuery<{ getHealthyBowlPriceAlertRules: PriceAlertRule[] }, { context: HbContext }>(GET_RULES, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n const alertsQuery = useQuery<{ getHealthyBowlPriceAlerts: PriceAlert[] }, { context: HbContext }>(GET_ALERTS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n\n const refetchPrices = pricesQuery.refetch;\n const refetchWatches = watchesQuery.refetch;\n const refetchRules = rulesQuery.refetch;\n const refetchAlerts = alertsQuery.refetch;\n\n const reconcile = useCallback(async (...refetchers: Array<() => Promise<unknown>>) => {\n await Promise.all(refetchers.map((run) => run().catch(() => undefined)));\n }, []);\n\n const [createWatchMutation] = useMutation<\n { createHealthyBowlPriceWatch: PriceWatch },\n { input: Record<string, unknown> }\n >(CREATE_WATCH);\n const [deleteWatchMutation] = useMutation(DELETE_WATCH);\n const [createRuleMutation] = useMutation<\n { createHealthyBowlPriceAlertRule: PriceAlertRule },\n { input: Record<string, unknown> }\n >(CREATE_RULE);\n const [updateRuleMutation] = useMutation<\n { updateHealthyBowlPriceAlertRule: PriceAlertRule },\n { input: Record<string, unknown> }\n >(UPDATE_RULE);\n const [deleteRuleMutation] = useMutation(DELETE_RULE);\n const [acknowledgeAlertMutation] = useMutation<\n { acknowledgeHealthyBowlPriceAlert: PriceAlert },\n { id: string; context: HbContext }\n >(ACKNOWLEDGE_ALERT);\n\n const withCtx = useCallback((input: Record<string, unknown>) => ({ ...input, context: ctx }), [ctx]);\n\n const prices = useMemo(() => pricesQuery.data?.getHealthyBowlMandiPrices ?? EMPTY_PRICES, [pricesQuery.data]);\n const commodities = useMemo(() => groupPricesByCommodity(prices), [prices]);\n\n return {\n prices,\n /** Latest prices rolled up to one row per commodity. */\n commodities,\n watches: watchesQuery.data?.getHealthyBowlPriceWatches ?? [],\n alertRules: rulesQuery.data?.getHealthyBowlPriceAlertRules ?? [],\n alerts: alertsQuery.data?.getHealthyBowlPriceAlerts ?? [],\n\n loading: pricesQuery.loading,\n error: pricesQuery.error ?? null,\n watchesLoading: watchesQuery.loading,\n rulesLoading: rulesQuery.loading,\n alertsLoading: alertsQuery.loading,\n\n refetchAll: useCallback(\n () => reconcile(refetchPrices, refetchWatches, refetchRules, refetchAlerts),\n [reconcile, refetchPrices, refetchWatches, refetchRules, refetchAlerts]\n ),\n\n createWatch: useCallback(\n async (input: Record<string, unknown>): Promise<PriceWatch | null> => {\n const res = await createWatchMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchWatches);\n return res.data?.createHealthyBowlPriceWatch ?? null;\n },\n [createWatchMutation, withCtx, reconcile, refetchWatches]\n ),\n deleteWatch: useCallback(\n async (id: string) => {\n const res = await deleteWatchMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchWatches);\n },\n [deleteWatchMutation, ctx, reconcile, refetchWatches]\n ),\n\n createRule: useCallback(\n async (input: Record<string, unknown>): Promise<PriceAlertRule | null> => {\n const res = await createRuleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchRules, refetchAlerts);\n return res.data?.createHealthyBowlPriceAlertRule ?? null;\n },\n [createRuleMutation, withCtx, reconcile, refetchRules, refetchAlerts]\n ),\n updateRule: useCallback(\n async (input: Record<string, unknown>): Promise<PriceAlertRule | null> => {\n const res = await updateRuleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchRules, refetchAlerts);\n return res.data?.updateHealthyBowlPriceAlertRule ?? null;\n },\n [updateRuleMutation, withCtx, reconcile, refetchRules, refetchAlerts]\n ),\n deleteRule: useCallback(\n async (id: string) => {\n const res = await deleteRuleMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchRules);\n },\n [deleteRuleMutation, ctx, reconcile, refetchRules]\n ),\n acknowledgeAlert: useCallback(\n async (id: string): Promise<PriceAlert | null> => {\n const res = await acknowledgeAlertMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchAlerts);\n return res.data?.acknowledgeHealthyBowlPriceAlert ?? null;\n },\n [acknowledgeAlertMutation, ctx, reconcile, refetchAlerts]\n ),\n\n context: ctx,\n };\n}\n\nexport type { CommodityRow, MandiPrice, PriceAlert, PriceAlertRule, PriceWatch };\n\n// ── price trend (lazy, per selected commodity) ───────────────────────────────\nexport interface UseTrendOptions {\n commodity?: string;\n marketName?: string | null;\n days?: number;\n skip?: boolean;\n}\n\n/**\n * Loads a per-commodity price trend (a time series of daily observations).\n * Skipped until a commodity is selected, so a wrong/unknown market never fires\n * a request on page load; the caller renders it defensively.\n */\nexport function useHealthyBowlMandiPriceTrend(options: UseTrendOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n const days = options.days ?? 30;\n\n const trendQuery = useQuery<\n { getHealthyBowlMandiPriceTrend: MandiPriceTrendPoint[] },\n { context: HbContext; commodity: string; marketName: string | null; days: number }\n >(GET_TREND, {\n variables: {\n context: ctx,\n commodity: options.commodity ?? '',\n marketName: options.marketName ?? null,\n days,\n },\n skip: options.skip || !options.commodity,\n fetchPolicy: 'cache-and-network',\n });\n\n return {\n points: trendQuery.data?.getHealthyBowlMandiPriceTrend ?? [],\n loading: trendQuery.loading,\n error: trendQuery.error ?? null,\n };\n}\n"],"mappings":";;;;;;AA4BA,IAAM,IAAwB,wCAGxB,IAA6B,EAAE,EAO/B,IAAqB,oJAerB,IAAqB,6DAQrB,IAAe,4DAQf,IAAc,6EASd,IAAe,uJAiBf,IAAa,CAAG;;sEAEgD,EAAmB;;GAInF,IAAY,CAAG;;;;;;;;QAQb,EAAmB;;;GAKrB,IAAc,CAAG;;sDAE+B,EAAa;;GAI7D,IAAY,CAAG;;yDAEoC,EAAY;;GAI/D,IAAa,CAAG;;qDAE+B,EAAa;;GAI5D,IAAe,CAAG;;mDAE2B,EAAa;;GAI1D,IAAe,CAAG;;;;GAMlB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AO,OAAM,EAAI;AAEzB,UADA,MAAM,EAAU,GAAc,EAAc,EACrC,EAAI,MAAM,mCAAmC;KAEtD;GAAC;GAAoB;GAAS;GAAW;GAAc;GAAc,CACtE;EACD,YAAY,EACV,OAAO,MAAe;GACpB,IAAM,IAAM,MAAM,EAAmB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AACzE,OAAI,EAAI,MAAO,OAAM,EAAI;AACzB,SAAM,EAAU,EAAa;KAE/B;GAAC;GAAoB;GAAK;GAAW;GAAa,CACnD;EACD,kBAAkB,EAChB,OAAO,MAA2C;GAChD,IAAM,IAAM,MAAM,EAAyB,EAAE,WAAW;IAAE;IAAI,SAAS;IAAK,EAAE,CAAC;AAC/E,OAAI,EAAI,MAAO,OAAM,EAAI;AAEzB,UADA,MAAM,EAAU,EAAc,EACvB,EAAI,MAAM,oCAAoC;KAEvD;GAAC;GAA0B;GAAK;GAAW;GAAc,CAC1D;EAED,SAAS;EACV;;AAkBH,SAAgB,EAA8B,IAA2B,EAAE,EAAE;CAC3E,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAuB,KAAe,GACtC,IAAM,SAA0B,EAAE,aAAa,GAAsB,GAAG,CAAC,EAAqB,CAAC,EAC/F,IAAO,EAAQ,QAAQ,IAEvB,IAAa,EAGjB,GAAW;EACX,WAAW;GACT,SAAS;GACT,WAAW,EAAQ,aAAa;GAChC,YAAY,EAAQ,cAAc;GAClC;GACD;EACD,MAAM,EAAQ,QAAQ,CAAC,EAAQ;EAC/B,aAAa;EACd,CAAC;AAEF,QAAO;EACL,QAAQ,EAAW,MAAM,iCAAiC,EAAE;EAC5D,SAAS,EAAW;EACpB,OAAO,EAAW,SAAS;EAC5B"}
1
+ {"version":3,"file":"useHealthyBowlMandiPrices.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlMandiPrices.ts"],"sourcesContent":["/**\n * Mandi / Market-Price Intelligence — data hook (roadmap #28 · BOFF-4715).\n *\n * Documents are declared inline with `gql` (not `src/operations/wspace/*.graphql`)\n * because codegen validates operations against the committed `graphql/wspace.graphql`\n * snapshot, which doesn't yet carry the mandi subgraph (schema:pull needs a live\n * gateway) — the same escape hatch `useHealthyBowlSensors` / `useDiseaseWarning`\n * use. Types mirror the deployed `wspace-healthybowl-svc` mandi schema.\n *\n * Reads use `cache-and-network`; every write refetches the lists it invalidates.\n * The commodity roll-up is delegated to the pure `groupPricesByCommodity` helper\n * so it stays unit-testable.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\nimport {\n groupPricesByCommodity,\n type CommodityRow,\n type MandiPrice,\n type MandiPriceTrendPoint,\n type PriceAlert,\n type PriceAlertRule,\n type PriceWatch,\n} from '../utils/mandiPrices';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n/** Stable empty reference so downstream `useMemo`s don't recompute every render. */\nconst EMPTY_PRICES: MandiPrice[] = [];\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\nconst MANDI_PRICE_FIELDS = `\n commodity\n variety\n marketName\n district\n state\n minPrice\n modalPrice\n maxPrice\n arrivalQty\n unit\n priceDate\n source\n`;\n\nconst TREND_POINT_FIELDS = `\n date\n label\n minPrice\n modalPrice\n maxPrice\n`;\n\nconst WATCH_FIELDS = `\n id\n commodity\n marketName\n district\n state\n`;\n\nconst RULE_FIELDS = `\n id\n commodity\n marketName\n comparator\n threshold\n enabled\n`;\n\nconst ALERT_FIELDS = `\n id\n commodity\n marketName\n comparator\n severity\n title\n message\n value\n threshold\n status\n read\n timestamp\n actionUrl\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────────\nconst GET_PRICES = gql`\n query GetHealthyBowlMandiPrices($context: ContextInput!, $filter: HealthyBowlMandiPriceFilterInput) {\n getHealthyBowlMandiPrices(context: $context, filter: $filter) { ${MANDI_PRICE_FIELDS} }\n }\n`;\n\nconst GET_TREND = gql`\n query GetHealthyBowlMandiPriceTrend(\n $context: ContextInput!\n $commodity: String!\n $marketName: String\n $days: Int\n ) {\n getHealthyBowlMandiPriceTrend(context: $context, commodity: $commodity, marketName: $marketName, days: $days) {\n ${TREND_POINT_FIELDS}\n }\n }\n`;\n\nconst GET_WATCHES = gql`\n query GetHealthyBowlPriceWatches($context: ContextInput!) {\n getHealthyBowlPriceWatches(context: $context) { ${WATCH_FIELDS} }\n }\n`;\n\nconst GET_RULES = gql`\n query GetHealthyBowlPriceAlertRules($context: ContextInput!) {\n getHealthyBowlPriceAlertRules(context: $context) { ${RULE_FIELDS} }\n }\n`;\n\nconst GET_ALERTS = gql`\n query GetHealthyBowlPriceAlerts($context: ContextInput!) {\n getHealthyBowlPriceAlerts(context: $context) { ${ALERT_FIELDS} }\n }\n`;\n\nconst CREATE_WATCH = gql`\n mutation CreateHealthyBowlPriceWatch($input: CreateHealthyBowlPriceWatchInput!) {\n createHealthyBowlPriceWatch(input: $input) { ${WATCH_FIELDS} }\n }\n`;\n\nconst DELETE_WATCH = gql`\n mutation DeleteHealthyBowlPriceWatch($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPriceWatch(context: $context, id: $id)\n }\n`;\n\nconst CREATE_RULE = gql`\n mutation CreateHealthyBowlPriceAlertRule($input: CreateHealthyBowlPriceAlertRuleInput!) {\n createHealthyBowlPriceAlertRule(input: $input) { ${RULE_FIELDS} }\n }\n`;\n\nconst UPDATE_RULE = gql`\n mutation UpdateHealthyBowlPriceAlertRule($input: UpdateHealthyBowlPriceAlertRuleInput!) {\n updateHealthyBowlPriceAlertRule(input: $input) { ${RULE_FIELDS} }\n }\n`;\n\nconst DELETE_RULE = gql`\n mutation DeleteHealthyBowlPriceAlertRule($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPriceAlertRule(context: $context, id: $id)\n }\n`;\n\n// A fired PriceAlert is a view over the HB Alert table; acknowledging flips its\n// `read` flag, which the resolver derives into status ACTIVE → ACKNOWLEDGED.\nconst ACKNOWLEDGE_ALERT = gql`\n mutation AcknowledgeHealthyBowlPriceAlert($id: ID!, $context: ContextInput!) {\n acknowledgeHealthyBowlPriceAlert(context: $context, id: $id) { ${ALERT_FIELDS} }\n }\n`;\n\n/**\n * Mirrors `HealthyBowlMandiPriceFilterInput` (BOFF-6130).\n *\n * This type used to declare only four of the server's eight fields, so\n * `fromDate`/`toDate`/`variety`/`limit` were unreachable from the client even by\n * a caller that deliberately wanted them — the server half has always applied\n * the whole filter.\n *\n * Note the server matches EXACTLY and case-sensitively (`where.state = state`,\n * no `mode: 'insensitive'`); only `commodity` is normalised. So values sent here\n * must come from the data itself, never from a hand-written list.\n */\nexport interface MandiPriceFilter {\n commodity?: string | null;\n marketName?: string | null;\n district?: string | null;\n state?: string | null;\n variety?: string | null;\n /** Full ISO instant. Rows are stored at UTC midnight. */\n fromDate?: string | null;\n toDate?: string | null;\n limit?: number | null;\n}\n\n/**\n * How many rows the unfiltered facet query pulls to derive dropdown options.\n * The server caps at 2000 (priceDate desc), so the option lists are \"states\n * reporting recently\" rather than an exhaustive index — which is why the\n * control is labelled that way rather than \"All states in India\".\n */\nconst FACET_LIMIT = 2000;\n\nexport interface UseMandiPricesOptions {\n /** Optional server-side filter; when omitted, all latest prices are returned. */\n filter?: MandiPriceFilter;\n}\n\nexport function useHealthyBowlMandiPrices(options: UseMandiPricesOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n const filter = options.filter;\n\n const pricesQuery = useQuery<\n { getHealthyBowlMandiPrices: MandiPrice[] },\n { context: HbContext; filter?: MandiPriceFilter }\n >(GET_PRICES, { variables: { context: ctx, filter }, fetchPolicy: 'cache-and-network' });\n\n // A SECOND, deliberately unfiltered read (BOFF-6130).\n //\n // Every dropdown option — states, districts, and the commodity/market\n // datalists the watch and alert-rule modals use — must be derived from the\n // whole dataset, not from the filtered view. Deriving them from `prices`\n // would make the options collapse to whatever is currently selected: pick\n // Tamil Nadu and Tamil Nadu becomes the only state you can pick, with no way\n // back except a reload.\n //\n // Variables are CONSTANT so Apollo serves this from cache after the first\n // fetch and it never refires on a filter change.\n const facetVariables = useMemo(() => ({ context: ctx, filter: { limit: FACET_LIMIT } as MandiPriceFilter }), [ctx]);\n const facetQuery = useQuery<\n { getHealthyBowlMandiPrices: MandiPrice[] },\n { context: HbContext; filter?: MandiPriceFilter }\n >(GET_PRICES, { variables: facetVariables, fetchPolicy: 'cache-first' });\n const watchesQuery = useQuery<{ getHealthyBowlPriceWatches: PriceWatch[] }, { context: HbContext }>(GET_WATCHES, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n const rulesQuery = useQuery<{ getHealthyBowlPriceAlertRules: PriceAlertRule[] }, { context: HbContext }>(GET_RULES, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n const alertsQuery = useQuery<{ getHealthyBowlPriceAlerts: PriceAlert[] }, { context: HbContext }>(GET_ALERTS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n });\n\n const refetchPrices = pricesQuery.refetch;\n const refetchWatches = watchesQuery.refetch;\n const refetchRules = rulesQuery.refetch;\n const refetchAlerts = alertsQuery.refetch;\n\n const reconcile = useCallback(async (...refetchers: Array<() => Promise<unknown>>) => {\n await Promise.all(refetchers.map((run) => run().catch(() => undefined)));\n }, []);\n\n const [createWatchMutation] = useMutation<\n { createHealthyBowlPriceWatch: PriceWatch },\n { input: Record<string, unknown> }\n >(CREATE_WATCH);\n const [deleteWatchMutation] = useMutation(DELETE_WATCH);\n const [createRuleMutation] = useMutation<\n { createHealthyBowlPriceAlertRule: PriceAlertRule },\n { input: Record<string, unknown> }\n >(CREATE_RULE);\n const [updateRuleMutation] = useMutation<\n { updateHealthyBowlPriceAlertRule: PriceAlertRule },\n { input: Record<string, unknown> }\n >(UPDATE_RULE);\n const [deleteRuleMutation] = useMutation(DELETE_RULE);\n const [acknowledgeAlertMutation] = useMutation<\n { acknowledgeHealthyBowlPriceAlert: PriceAlert },\n { id: string; context: HbContext }\n >(ACKNOWLEDGE_ALERT);\n\n const withCtx = useCallback((input: Record<string, unknown>) => ({ ...input, context: ctx }), [ctx]);\n\n const prices = useMemo(() => pricesQuery.data?.getHealthyBowlMandiPrices ?? EMPTY_PRICES, [pricesQuery.data]);\n const commodities = useMemo(() => groupPricesByCommodity(prices), [prices]);\n // Falls back to the filtered set only while the facet read is still in\n // flight, so the dropdowns are never empty on first paint.\n const facetPrices = useMemo(() => facetQuery.data?.getHealthyBowlMandiPrices ?? prices, [facetQuery.data, prices]);\n\n return {\n prices,\n /** Latest prices rolled up to one row per commodity. */\n commodities,\n /**\n * The UNFILTERED set, for deriving dropdown options and datalists\n * (BOFF-6130). Never render this as the price list — it ignores the\n * caller's filter by design.\n */\n facetPrices,\n watches: watchesQuery.data?.getHealthyBowlPriceWatches ?? [],\n alertRules: rulesQuery.data?.getHealthyBowlPriceAlertRules ?? [],\n alerts: alertsQuery.data?.getHealthyBowlPriceAlerts ?? [],\n\n loading: pricesQuery.loading,\n error: pricesQuery.error ?? null,\n watchesLoading: watchesQuery.loading,\n rulesLoading: rulesQuery.loading,\n alertsLoading: alertsQuery.loading,\n\n refetchAll: useCallback(\n () => reconcile(refetchPrices, refetchWatches, refetchRules, refetchAlerts),\n [reconcile, refetchPrices, refetchWatches, refetchRules, refetchAlerts]\n ),\n\n createWatch: useCallback(\n async (input: Record<string, unknown>): Promise<PriceWatch | null> => {\n const res = await createWatchMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchWatches);\n return res.data?.createHealthyBowlPriceWatch ?? null;\n },\n [createWatchMutation, withCtx, reconcile, refetchWatches]\n ),\n deleteWatch: useCallback(\n async (id: string) => {\n const res = await deleteWatchMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchWatches);\n },\n [deleteWatchMutation, ctx, reconcile, refetchWatches]\n ),\n\n createRule: useCallback(\n async (input: Record<string, unknown>): Promise<PriceAlertRule | null> => {\n const res = await createRuleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchRules, refetchAlerts);\n return res.data?.createHealthyBowlPriceAlertRule ?? null;\n },\n [createRuleMutation, withCtx, reconcile, refetchRules, refetchAlerts]\n ),\n updateRule: useCallback(\n async (input: Record<string, unknown>): Promise<PriceAlertRule | null> => {\n const res = await updateRuleMutation({ variables: { input: withCtx(input) } });\n if (res.error) throw res.error;\n await reconcile(refetchRules, refetchAlerts);\n return res.data?.updateHealthyBowlPriceAlertRule ?? null;\n },\n [updateRuleMutation, withCtx, reconcile, refetchRules, refetchAlerts]\n ),\n deleteRule: useCallback(\n async (id: string) => {\n const res = await deleteRuleMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchRules);\n },\n [deleteRuleMutation, ctx, reconcile, refetchRules]\n ),\n acknowledgeAlert: useCallback(\n async (id: string): Promise<PriceAlert | null> => {\n const res = await acknowledgeAlertMutation({ variables: { id, context: ctx } });\n if (res.error) throw res.error;\n await reconcile(refetchAlerts);\n return res.data?.acknowledgeHealthyBowlPriceAlert ?? null;\n },\n [acknowledgeAlertMutation, ctx, reconcile, refetchAlerts]\n ),\n\n context: ctx,\n };\n}\n\nexport type { CommodityRow, MandiPrice, PriceAlert, PriceAlertRule, PriceWatch };\n\n// ── price trend (lazy, per selected commodity) ───────────────────────────────\nexport interface UseTrendOptions {\n commodity?: string;\n marketName?: string | null;\n days?: number;\n skip?: boolean;\n}\n\n/**\n * Loads a per-commodity price trend (a time series of daily observations).\n * Skipped until a commodity is selected, so a wrong/unknown market never fires\n * a request on page load; the caller renders it defensively.\n */\nexport function useHealthyBowlMandiPriceTrend(options: UseTrendOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n const days = options.days ?? 30;\n\n const trendQuery = useQuery<\n { getHealthyBowlMandiPriceTrend: MandiPriceTrendPoint[] },\n { context: HbContext; commodity: string; marketName: string | null; days: number }\n >(GET_TREND, {\n variables: {\n context: ctx,\n commodity: options.commodity ?? '',\n marketName: options.marketName ?? null,\n days,\n },\n skip: options.skip || !options.commodity,\n fetchPolicy: 'cache-and-network',\n });\n\n return {\n points: trendQuery.data?.getHealthyBowlMandiPriceTrend ?? [],\n loading: trendQuery.loading,\n error: trendQuery.error ?? null,\n };\n}\n"],"mappings":";;;;;;AA4BA,IAAM,IAAwB,wCAGxB,IAA6B,EAAE,EAO/B,IAAqB,oJAerB,IAAqB,6DAQrB,IAAe,4DAQf,IAAc,6EASd,IAAe,uJAiBf,IAAa,CAAG;;sEAEgD,EAAmB;;GAInF,IAAY,CAAG;;;;;;;;QAQb,EAAmB;;;GAKrB,IAAc,CAAG;;sDAE+B,EAAa;;GAI7D,IAAY,CAAG;;yDAEoC,EAAY;;GAI/D,IAAa,CAAG;;qDAE+B,EAAa;;GAI5D,IAAe,CAAG;;mDAE2B,EAAa;;GAI1D,IAAe,CAAG;;;;GAMlB,IAAc,CAAG;;uDAEgC,EAAY;;GAI7D,IAAc,CAAG;;uDAEgC,EAAY;;GAI7D,IAAc,CAAG;;;;GAQjB,IAAoB,CAAG;;qEAEwC,EAAa;;GAkC5E,IAAc;AAOpB,SAAgB,EAA0B,IAAiC,EAAE,EAAE;CAC7E,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAuB,KAAe,GACtC,IAAM,SAA0B,EAAE,aAAa,GAAsB,GAAG,CAAC,EAAqB,CAAC,EAC/F,IAAS,EAAQ,QAEjB,IAAc,EAGlB,GAAY;EAAE,WAAW;GAAE,SAAS;GAAK;GAAQ;EAAE,aAAa;EAAqB,CAAC,EAclF,IAAa,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