@burdenoff/microfe-healthybowl 2026.714.3 → 2026.714.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/healthybowl/HealthyBowlRoot.js +114 -106
  2. package/dist/healthybowl/HealthyBowlRoot.js.map +1 -1
  3. package/dist/healthybowl/HealthyBowlRoutes.js +141 -113
  4. package/dist/healthybowl/HealthyBowlRoutes.js.map +1 -1
  5. package/dist/healthybowl/hooks/useHealthyBowlContacts.js +149 -0
  6. package/dist/healthybowl/hooks/useHealthyBowlContacts.js.map +1 -0
  7. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js +200 -0
  8. package/dist/healthybowl/hooks/useHealthyBowlLivestockDepth.js.map +1 -0
  9. package/dist/healthybowl/hooks/useHealthyBowlStorage.js +162 -0
  10. package/dist/healthybowl/hooks/useHealthyBowlStorage.js.map +1 -0
  11. package/dist/healthybowl/hooks/usePlantScans.js +131 -0
  12. package/dist/healthybowl/hooks/usePlantScans.js.map +1 -0
  13. package/dist/healthybowl/pages/contacts/ContactDetailPage.js +224 -0
  14. package/dist/healthybowl/pages/contacts/ContactDetailPage.js.map +1 -0
  15. package/dist/healthybowl/pages/contacts/ContactFormModal.js +147 -0
  16. package/dist/healthybowl/pages/contacts/ContactFormModal.js.map +1 -0
  17. package/dist/healthybowl/pages/contacts/ContactsPage.js +241 -0
  18. package/dist/healthybowl/pages/contacts/ContactsPage.js.map +1 -0
  19. package/dist/healthybowl/pages/contacts/CsvImportModal.js +155 -0
  20. package/dist/healthybowl/pages/contacts/CsvImportModal.js.map +1 -0
  21. package/dist/healthybowl/pages/contacts/RecordOrderModal.js +131 -0
  22. package/dist/healthybowl/pages/contacts/RecordOrderModal.js.map +1 -0
  23. package/dist/healthybowl/pages/contacts/labels.js +46 -0
  24. package/dist/healthybowl/pages/contacts/labels.js.map +1 -0
  25. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js +152 -0
  26. package/dist/healthybowl/pages/livestock/AnimalDepthFormModal.js.map +1 -0
  27. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js +245 -0
  28. package/dist/healthybowl/pages/livestock/AnimalDepthPage.js.map +1 -0
  29. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js +210 -0
  30. package/dist/healthybowl/pages/livestock/AnimalGroupModal.js.map +1 -0
  31. package/dist/healthybowl/pages/livestock/HerdDepthPage.js +189 -0
  32. package/dist/healthybowl/pages/livestock/HerdDepthPage.js.map +1 -0
  33. package/dist/healthybowl/pages/livestock/RecordWeightModal.js +100 -0
  34. package/dist/healthybowl/pages/livestock/RecordWeightModal.js.map +1 -0
  35. package/dist/healthybowl/pages/livestock/depthLabels.js +31 -0
  36. package/dist/healthybowl/pages/livestock/depthLabels.js.map +1 -0
  37. package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js +726 -0
  38. package/dist/healthybowl/pages/pest-management/AiPestDetectionPage.js.map +1 -0
  39. package/dist/healthybowl/pages/pest-management/PestOverviewPage.js +98 -88
  40. package/dist/healthybowl/pages/pest-management/PestOverviewPage.js.map +1 -1
  41. package/dist/healthybowl/pages/storage/PlaceLotModal.js +150 -0
  42. package/dist/healthybowl/pages/storage/PlaceLotModal.js.map +1 -0
  43. package/dist/healthybowl/pages/storage/RecordMovementModal.js +140 -0
  44. package/dist/healthybowl/pages/storage/RecordMovementModal.js.map +1 -0
  45. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js +139 -0
  46. package/dist/healthybowl/pages/storage/StorageLocationFormModal.js.map +1 -0
  47. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js +150 -0
  48. package/dist/healthybowl/pages/storage/StorageLotDetailPage.js.map +1 -0
  49. package/dist/healthybowl/pages/storage/StoragePage.js +251 -0
  50. package/dist/healthybowl/pages/storage/StoragePage.js.map +1 -0
  51. package/dist/healthybowl/pages/storage/labels.js +67 -0
  52. package/dist/healthybowl/pages/storage/labels.js.map +1 -0
  53. package/dist/healthybowl/utils/imageDownscale.js +76 -0
  54. package/dist/healthybowl/utils/imageDownscale.js.map +1 -0
  55. package/package.json +1 -1
@@ -0,0 +1,200 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts
6
+ var o = "00000000-0000-0000-0000-000000000001", s = "\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n", c = "\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n", l = `
7
+ animalId
8
+ tagNumber
9
+ eidTag
10
+ name
11
+ type
12
+ groupId
13
+ groupName
14
+ bodyConditionScore
15
+ adgKgPerDay
16
+ latestWeightKg
17
+ latestWeightAt
18
+ withdrawal { ${s} }
19
+ `, u = "\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n", d = `
20
+ animalId
21
+ tagNumber
22
+ eidTag
23
+ name
24
+ type
25
+ breed
26
+ status
27
+ groupId
28
+ groupName
29
+ bodyConditionScore
30
+ damId
31
+ damTag
32
+ sireId
33
+ sireTag
34
+ grazingPaddock
35
+ rotationDate
36
+ grazingNotes
37
+ adgKgPerDay
38
+ latestWeightKg
39
+ latestWeightAt
40
+ weightHistory { ${u} }
41
+ withdrawal { ${s} }
42
+ `, f = r`
43
+ query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {
44
+ healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {
45
+ rows { ${l} }
46
+ summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }
47
+ groups { ${c} }
48
+ }
49
+ }
50
+ `, p = r`
51
+ query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {
52
+ healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${d} }
53
+ }
54
+ `, m = r`
55
+ query HealthyBowlAnimalGroups($context: ContextInput!) {
56
+ healthyBowlAnimalGroups(context: $context) { ${c} }
57
+ }
58
+ `, h = r`
59
+ mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {
60
+ updateHealthyBowlAnimalDepth(input: $input) { ${d} }
61
+ }
62
+ `, g = r`
63
+ mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {
64
+ createHealthyBowlAnimalGroup(input: $input) { ${c} }
65
+ }
66
+ `, _ = r`
67
+ mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {
68
+ updateHealthyBowlAnimalGroup(input: $input) { ${c} }
69
+ }
70
+ `, v = r`
71
+ mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {
72
+ deleteHealthyBowlAnimalGroup(id: $id, context: $context)
73
+ }
74
+ `, y = r`
75
+ mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {
76
+ recordHealthyBowlAnimalWeight(input: $input) { ${u} }
77
+ }
78
+ `, b = r`
79
+ mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {
80
+ deleteHealthyBowlAnimalWeight(id: $id, context: $context)
81
+ }
82
+ `;
83
+ function x(r = {}) {
84
+ let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), u = r.herd === !0, d = r.groups === !0, x = r.animalId ?? null, S = a(f, {
85
+ variables: {
86
+ context: l,
87
+ groupId: r.herdGroupId ?? null,
88
+ search: r.herdSearch ?? null
89
+ },
90
+ fetchPolicy: "cache-and-network",
91
+ skip: !u
92
+ }), C = a(m, {
93
+ variables: { context: l },
94
+ fetchPolicy: "cache-and-network",
95
+ skip: !d
96
+ }), w = a(p, {
97
+ variables: {
98
+ context: l,
99
+ animalId: x ?? ""
100
+ },
101
+ fetchPolicy: "cache-and-network",
102
+ skip: !x
103
+ }), [T] = i(h), [E] = i(g), [D] = i(_), [O] = i(v), [k] = i(y), [A] = i(b), j = t(() => S.refetch(), [S]), M = t(() => C.refetch(), [C]), N = t(() => w.refetch(), [w]), P = t(async () => {
104
+ let e = [];
105
+ u && e.push(j().catch(() => void 0)), d && e.push(M().catch(() => void 0)), x && e.push(N().catch(() => void 0)), await Promise.all(e);
106
+ }, [
107
+ u,
108
+ d,
109
+ x,
110
+ j,
111
+ M,
112
+ N
113
+ ]), F = t(async (e) => {
114
+ let t = await T({ variables: { input: {
115
+ ...e,
116
+ context: l
117
+ } } });
118
+ return await P(), t.data?.updateHealthyBowlAnimalDepth;
119
+ }, [
120
+ T,
121
+ l,
122
+ P
123
+ ]), I = t(async (e) => {
124
+ let t = await E({ variables: { input: {
125
+ ...e,
126
+ context: l
127
+ } } });
128
+ return await P(), t.data?.createHealthyBowlAnimalGroup;
129
+ }, [
130
+ E,
131
+ l,
132
+ P
133
+ ]), L = t(async (e) => {
134
+ let t = await D({ variables: { input: {
135
+ ...e,
136
+ context: l
137
+ } } });
138
+ return await P(), t.data?.updateHealthyBowlAnimalGroup;
139
+ }, [
140
+ D,
141
+ l,
142
+ P
143
+ ]), R = t(async (e) => {
144
+ await O({ variables: {
145
+ id: e,
146
+ context: l
147
+ } }), await P();
148
+ }, [
149
+ O,
150
+ l,
151
+ P
152
+ ]), z = t(async (e) => {
153
+ let t = await k({ variables: { input: {
154
+ ...e,
155
+ context: l
156
+ } } });
157
+ return await P(), t.data?.recordHealthyBowlAnimalWeight;
158
+ }, [
159
+ k,
160
+ l,
161
+ P
162
+ ]), B = t(async (e) => {
163
+ await A({ variables: {
164
+ id: e,
165
+ context: l
166
+ } }), await P();
167
+ }, [
168
+ A,
169
+ l,
170
+ P
171
+ ]);
172
+ return {
173
+ herd: S.data?.healthyBowlHerdDepth ?? null,
174
+ groups: C.data?.healthyBowlAnimalGroups ?? S.data?.healthyBowlHerdDepth?.groups ?? [],
175
+ animalDepth: w.data?.healthyBowlAnimalDepth ?? null,
176
+ loading: {
177
+ herd: S.loading,
178
+ groups: C.loading,
179
+ animal: w.loading
180
+ },
181
+ errors: {
182
+ herd: S.error ?? null,
183
+ groups: C.error ?? null,
184
+ animal: w.error ?? null
185
+ },
186
+ refetchHerd: j,
187
+ refetchGroups: M,
188
+ refetchAnimal: N,
189
+ updateAnimalDepth: F,
190
+ createGroup: I,
191
+ updateGroup: L,
192
+ deleteGroup: R,
193
+ recordWeight: z,
194
+ deleteWeight: B
195
+ };
196
+ }
197
+ //#endregion
198
+ export { x as useHealthyBowlLivestockDepth };
199
+
200
+ //# sourceMappingURL=useHealthyBowlLivestockDepth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHealthyBowlLivestockDepth.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlLivestockDepth.ts"],"sourcesContent":["/**\n * Deep livestock records — data hook.\n * Roadmap 18 · BOFF-2890 · gap L-1.\n *\n * Broadens the animal record with EID/RFID, body-condition score, manual/smart groups, dam/sire\n * genealogy, grazing/rotation, and a weight history that yields ADG. The medication-withdrawal\n * end-date + \"do not sell\" compliance flag are REUSED from the shipped withdrawal sub-domain\n * (BOFF-2885) and surfaced here on the deep herd view. Documents are declared inline with `gql`\n * (the same escape hatch `useHealthyBowlWithdrawal`/`useHealthyBowlDistribution` use) because\n * codegen validates against the committed `graphql/wspace.graphql` snapshot. Types mirror\n * `wspace-healthybowl-svc/src/modules/healthybowl/schema/livestock-depth.gql`.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\n// ── types (mirror livestock-depth.gql) ─────────────────────────────────────────\n\nexport interface AnimalWithdrawalBadge {\n status: string;\n blocked: boolean;\n endDate: string | null;\n daysLeft: number;\n milkClearDate: string | null;\n meatClearDate: string | null;\n eggsClearDate: string | null;\n}\n\nexport interface HerdDepthRow {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n withdrawal: AnimalWithdrawalBadge;\n}\n\nexport interface AnimalGroup {\n id: string;\n name: string;\n description: string | null;\n kind: string;\n smartRule: Record<string, unknown> | null;\n color: string | null;\n animalCount: number;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface HerdComplianceSummary {\n totalAnimals: number;\n animalsInWithdrawal: number;\n animalsClear: number;\n complianceMessage: string;\n}\n\nexport interface HerdDepthView {\n rows: HerdDepthRow[];\n summary: HerdComplianceSummary;\n groups: AnimalGroup[];\n}\n\nexport interface WeightRecord {\n id: string;\n animalId: string;\n weightKg: number;\n measuredAt: string;\n method: string | null;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface AnimalDepthRecord {\n animalId: string;\n tagNumber: string;\n eidTag: string | null;\n name: string;\n type: string;\n breed: string | null;\n status: string;\n groupId: string | null;\n groupName: string | null;\n bodyConditionScore: number | null;\n damId: string | null;\n damTag: string | null;\n sireId: string | null;\n sireTag: string | null;\n grazingPaddock: string | null;\n rotationDate: string | null;\n grazingNotes: string | null;\n adgKgPerDay: number | null;\n latestWeightKg: number | null;\n latestWeightAt: string | null;\n weightHistory: WeightRecord[];\n withdrawal: AnimalWithdrawalBadge;\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\n// ── field fragments ─────────────────────────────────────────────────────────\n\nconst WITHDRAWAL_FIELDS = `\n status\n blocked\n endDate\n daysLeft\n milkClearDate\n meatClearDate\n eggsClearDate\n`;\n\nconst GROUP_FIELDS = `\n id\n name\n description\n kind\n smartRule\n color\n animalCount\n createdAt\n updatedAt\n`;\n\nconst HERD_ROW_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n groupId\n groupName\n bodyConditionScore\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\nconst WEIGHT_FIELDS = `\n id\n animalId\n weightKg\n measuredAt\n method\n notes\n createdAt\n`;\n\nconst ANIMAL_DEPTH_FIELDS = `\n animalId\n tagNumber\n eidTag\n name\n type\n breed\n status\n groupId\n groupName\n bodyConditionScore\n damId\n damTag\n sireId\n sireTag\n grazingPaddock\n rotationDate\n grazingNotes\n adgKgPerDay\n latestWeightKg\n latestWeightAt\n weightHistory { ${WEIGHT_FIELDS} }\n withdrawal { ${WITHDRAWAL_FIELDS} }\n`;\n\n// ── documents ─────────────────────────────────────────────────────────────\n\nconst GET_HERD_DEPTH = gql`\n query HealthyBowlHerdDepth($context: ContextInput!, $groupId: ID, $search: String) {\n healthyBowlHerdDepth(context: $context, groupId: $groupId, search: $search) {\n rows { ${HERD_ROW_FIELDS} }\n summary { totalAnimals animalsInWithdrawal animalsClear complianceMessage }\n groups { ${GROUP_FIELDS} }\n }\n }\n`;\n\nconst GET_ANIMAL_DEPTH = gql`\n query HealthyBowlAnimalDepth($context: ContextInput!, $animalId: ID!) {\n healthyBowlAnimalDepth(context: $context, animalId: $animalId) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst GET_GROUPS = gql`\n query HealthyBowlAnimalGroups($context: ContextInput!) {\n healthyBowlAnimalGroups(context: $context) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_ANIMAL_DEPTH = gql`\n mutation UpdateHealthyBowlAnimalDepth($input: UpdateHealthyBowlAnimalDepthInput!) {\n updateHealthyBowlAnimalDepth(input: $input) { ${ANIMAL_DEPTH_FIELDS} }\n }\n`;\n\nconst CREATE_GROUP = gql`\n mutation CreateHealthyBowlAnimalGroup($input: CreateHealthyBowlAnimalGroupInput!) {\n createHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst UPDATE_GROUP = gql`\n mutation UpdateHealthyBowlAnimalGroup($input: UpdateHealthyBowlAnimalGroupInput!) {\n updateHealthyBowlAnimalGroup(input: $input) { ${GROUP_FIELDS} }\n }\n`;\n\nconst DELETE_GROUP = gql`\n mutation DeleteHealthyBowlAnimalGroup($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalGroup(id: $id, context: $context)\n }\n`;\n\nconst RECORD_WEIGHT = gql`\n mutation RecordHealthyBowlAnimalWeight($input: RecordHealthyBowlAnimalWeightInput!) {\n recordHealthyBowlAnimalWeight(input: $input) { ${WEIGHT_FIELDS} }\n }\n`;\n\nconst DELETE_WEIGHT = gql`\n mutation DeleteHealthyBowlAnimalWeight($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlAnimalWeight(id: $id, context: $context)\n }\n`;\n\n// ── hook ─────────────────────────────────────────────────────────────────────\n\nexport interface UseLivestockDepthOptions {\n /** Fetch the deep herd view (rows + compliance summary + groups). */\n herd?: boolean;\n /** Optional group filter for the herd view. */\n herdGroupId?: string | null;\n /** Optional free-text search (tag / name / EID) for the herd view. */\n herdSearch?: string | null;\n /** Fetch the animal groups list. */\n groups?: boolean;\n /** Fetch a single animal's deep record. */\n animalId?: string | null;\n}\n\nexport function useHealthyBowlLivestockDepth(options: UseLivestockDepthOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableHerd = options.herd === true;\n const enableGroups = options.groups === true;\n const animalId = options.animalId ?? null;\n const herdGroupId = options.herdGroupId ?? null;\n const herdSearch = options.herdSearch ?? null;\n\n const herdQuery = useQuery<\n { healthyBowlHerdDepth: HerdDepthView },\n { context: HbContext; groupId: string | null; search: string | null }\n >(GET_HERD_DEPTH, {\n variables: { context: ctx, groupId: herdGroupId, search: herdSearch },\n fetchPolicy: 'cache-and-network',\n skip: !enableHerd,\n });\n\n const groupsQuery = useQuery<{ healthyBowlAnimalGroups: AnimalGroup[] }, { context: HbContext }>(GET_GROUPS, {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableGroups,\n });\n\n const animalQuery = useQuery<{ healthyBowlAnimalDepth: AnimalDepthRecord }, { context: HbContext; animalId: string }>(\n GET_ANIMAL_DEPTH,\n { variables: { context: ctx, animalId: animalId ?? '' }, fetchPolicy: 'cache-and-network', skip: !animalId }\n );\n\n const [updateAnimalDepthMutation] = useMutation(UPDATE_ANIMAL_DEPTH);\n const [createGroupMutation] = useMutation(CREATE_GROUP);\n const [updateGroupMutation] = useMutation(UPDATE_GROUP);\n const [deleteGroupMutation] = useMutation(DELETE_GROUP);\n const [recordWeightMutation] = useMutation(RECORD_WEIGHT);\n const [deleteWeightMutation] = useMutation(DELETE_WEIGHT);\n\n const refetchHerd = useCallback(() => herdQuery.refetch(), [herdQuery]);\n const refetchGroups = useCallback(() => groupsQuery.refetch(), [groupsQuery]);\n const refetchAnimal = useCallback(() => animalQuery.refetch(), [animalQuery]);\n\n const reconcile = useCallback(async () => {\n const runners: Array<Promise<unknown>> = [];\n if (enableHerd) runners.push(refetchHerd().catch(() => undefined));\n if (enableGroups) runners.push(refetchGroups().catch(() => undefined));\n if (animalId) runners.push(refetchAnimal().catch(() => undefined));\n await Promise.all(runners);\n }, [enableHerd, enableGroups, animalId, refetchHerd, refetchGroups, refetchAnimal]);\n\n const updateAnimalDepth = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalDepthRecord | undefined> => {\n const res = await updateAnimalDepthMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalDepth?: AnimalDepthRecord } | null)?.updateHealthyBowlAnimalDepth;\n },\n [updateAnimalDepthMutation, ctx, reconcile]\n );\n\n const createGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await createGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { createHealthyBowlAnimalGroup?: AnimalGroup } | null)?.createHealthyBowlAnimalGroup;\n },\n [createGroupMutation, ctx, reconcile]\n );\n\n const updateGroup = useCallback(\n async (input: Record<string, unknown>): Promise<AnimalGroup | undefined> => {\n const res = await updateGroupMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { updateHealthyBowlAnimalGroup?: AnimalGroup } | null)?.updateHealthyBowlAnimalGroup;\n },\n [updateGroupMutation, ctx, reconcile]\n );\n\n const deleteGroup = useCallback(\n async (id: string): Promise<void> => {\n await deleteGroupMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteGroupMutation, ctx, reconcile]\n );\n\n const recordWeight = useCallback(\n async (input: Record<string, unknown>): Promise<WeightRecord | undefined> => {\n const res = await recordWeightMutation({ variables: { input: { ...input, context: ctx } } });\n await reconcile();\n return (res.data as { recordHealthyBowlAnimalWeight?: WeightRecord } | null)?.recordHealthyBowlAnimalWeight;\n },\n [recordWeightMutation, ctx, reconcile]\n );\n\n const deleteWeight = useCallback(\n async (id: string): Promise<void> => {\n await deleteWeightMutation({ variables: { id, context: ctx } });\n await reconcile();\n },\n [deleteWeightMutation, ctx, reconcile]\n );\n\n return {\n herd: herdQuery.data?.healthyBowlHerdDepth ?? null,\n groups: groupsQuery.data?.healthyBowlAnimalGroups ?? herdQuery.data?.healthyBowlHerdDepth?.groups ?? [],\n animalDepth: animalQuery.data?.healthyBowlAnimalDepth ?? null,\n loading: {\n herd: herdQuery.loading,\n groups: groupsQuery.loading,\n animal: animalQuery.loading,\n },\n errors: {\n herd: herdQuery.error ?? null,\n groups: groupsQuery.error ?? null,\n animal: animalQuery.error ?? null,\n },\n refetchHerd,\n refetchGroups,\n refetchAnimal,\n updateAnimalDepth,\n createGroup,\n updateGroup,\n deleteGroup,\n recordWeight,\n deleteWeight,\n };\n}\n"],"mappings":";;;;;AAkBA,IAAM,IAAwB,wCA+FxB,IAAoB,qGAUpB,IAAe,0GAYf,IAAkB;;;;;;;;;;;;iBAYP,EAAkB;GAG7B,IAAgB,kFAUhB,IAAsB;;;;;;;;;;;;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tC,EAEK,IAAe,EACnB,OAAO,MAAsE;EAC3E,IAAM,IAAM,MAAM,EAAqB,EAAE,WAAW,EAAE,OAAO;GAAE,GAAG;GAAO,SAAS;GAAK,EAAE,EAAE,CAAC;AAE5F,SADA,MAAM,GAAW,EACT,EAAI,MAAkE;IAEhF;EAAC;EAAsB;EAAK;EAAU,CACvC,EAEK,IAAe,EACnB,OAAO,MAA8B;AAEnC,EADA,MAAM,EAAqB,EAAE,WAAW;GAAE;GAAI,SAAS;GAAK,EAAE,CAAC,EAC/D,MAAM,GAAW;IAEnB;EAAC;EAAsB;EAAK;EAAU,CACvC;AAED,QAAO;EACL,MAAM,EAAU,MAAM,wBAAwB;EAC9C,QAAQ,EAAY,MAAM,2BAA2B,EAAU,MAAM,sBAAsB,UAAU,EAAE;EACvG,aAAa,EAAY,MAAM,0BAA0B;EACzD,SAAS;GACP,MAAM,EAAU;GAChB,QAAQ,EAAY;GACpB,QAAQ,EAAY;GACrB;EACD,QAAQ;GACN,MAAM,EAAU,SAAS;GACzB,QAAQ,EAAY,SAAS;GAC7B,QAAQ,EAAY,SAAS;GAC9B;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,162 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useMemo as n } from "react";
3
+ import { gql as r } from "@apollo/client";
4
+ import { useMutation as i, useQuery as a } from "@apollo/client/react";
5
+ //#region src/healthybowl/hooks/useHealthyBowlStorage.ts
6
+ var o = "00000000-0000-0000-0000-000000000001", s = "id name kind storageType parentId capacity capacityUnit notes createdAt updatedAt", c = "id locationId locationName warehouseName lotCode produce productId productionBatchId traceBatchId harvestRecordId quantity unit status receivedAt expiryDate notes createdAt updatedAt", l = "id lotId lotCode produce locationId locationName direction quantity unit reason orderId reference occurredAt notes createdAt", u = r`
7
+ query HealthyBowlStorageOverview($context: ContextInput!) {
8
+ healthyBowlStorageOverview(context: $context) {
9
+ warehouses {
10
+ warehouse { ${s} }
11
+ usedCapacity
12
+ capacity
13
+ capacityUnit
14
+ capacityPct
15
+ binCount
16
+ lotCount
17
+ bins { location { ${s} } lots { ${c} } }
18
+ }
19
+ recentMovements { ${l} }
20
+ }
21
+ }
22
+ `, d = r`
23
+ query HealthyBowlStorageLocations($context: ContextInput!, $kind: String) {
24
+ healthyBowlStorageLocations(context: $context, kind: $kind) { ${s} }
25
+ }
26
+ `, f = r`
27
+ query HealthyBowlStorageLot($context: ContextInput!, $id: ID!) {
28
+ healthyBowlStorageLot(id: $id, context: $context) {
29
+ lot { ${c} }
30
+ movements { ${l} }
31
+ }
32
+ }
33
+ `, p = r`
34
+ mutation CreateHealthyBowlStorageLocation($input: CreateHealthyBowlStorageLocationInput!) {
35
+ createHealthyBowlStorageLocation(input: $input) { ${s} }
36
+ }
37
+ `, m = r`
38
+ mutation UpdateHealthyBowlStorageLocation($input: UpdateHealthyBowlStorageLocationInput!) {
39
+ updateHealthyBowlStorageLocation(input: $input) { ${s} }
40
+ }
41
+ `, h = r`
42
+ mutation DeleteHealthyBowlStorageLocation($id: ID!, $context: ContextInput!) {
43
+ deleteHealthyBowlStorageLocation(id: $id, context: $context)
44
+ }
45
+ `, g = r`
46
+ mutation PlaceHealthyBowlStorageLot($input: PlaceHealthyBowlStorageLotInput!) {
47
+ placeHealthyBowlStorageLot(input: $input) { ${c} }
48
+ }
49
+ `, _ = r`
50
+ mutation UpdateHealthyBowlStorageLot($input: UpdateHealthyBowlStorageLotInput!) {
51
+ updateHealthyBowlStorageLot(input: $input) { ${c} }
52
+ }
53
+ `, v = r`
54
+ mutation DeleteHealthyBowlStorageLot($id: ID!, $context: ContextInput!) {
55
+ deleteHealthyBowlStorageLot(id: $id, context: $context)
56
+ }
57
+ `, y = r`
58
+ mutation RecordHealthyBowlStockMovement($input: RecordHealthyBowlStockMovementInput!) {
59
+ recordHealthyBowlStockMovement(input: $input) { ${l} }
60
+ }
61
+ `;
62
+ function b(r = {}) {
63
+ let { workspaceId: s } = e(), c = s || o, l = n(() => ({ workspaceId: c }), [c]), b = r.overview === !0, x = r.locations === !0, S = r.lotId ?? null, C = a(u, {
64
+ variables: { context: l },
65
+ fetchPolicy: "cache-and-network",
66
+ skip: !b
67
+ }), w = a(d, {
68
+ variables: {
69
+ context: l,
70
+ kind: r.locationsKind ?? null
71
+ },
72
+ fetchPolicy: "cache-and-network",
73
+ skip: !x
74
+ }), T = a(f, {
75
+ variables: {
76
+ context: l,
77
+ id: S
78
+ },
79
+ fetchPolicy: "cache-and-network",
80
+ skip: !S
81
+ }), [E] = i(p), [D] = i(m), [O] = i(h), [k] = i(g), [A] = i(_), [j] = i(v), [M] = i(y), N = t(() => b ? C.refetch() : Promise.resolve(), [b, C]), P = t(() => x ? w.refetch() : Promise.resolve(), [x, w]), F = t(() => S ? T.refetch() : Promise.resolve(), [S, T]), I = t(async (e, t) => {
82
+ let n = await e;
83
+ return await Promise.all([N(), F()]), t(n.data);
84
+ }, [N, F]), L = t((e) => I(E({ variables: { input: {
85
+ ...e,
86
+ context: l
87
+ } } }), (e) => e.createHealthyBowlStorageLocation), [
88
+ E,
89
+ l,
90
+ I
91
+ ]), R = t((e) => I(D({ variables: { input: {
92
+ ...e,
93
+ context: l
94
+ } } }), (e) => e.updateHealthyBowlStorageLocation), [
95
+ D,
96
+ l,
97
+ I
98
+ ]), z = t((e) => I(O({ variables: {
99
+ id: e,
100
+ context: l
101
+ } }), (e) => !!e.deleteHealthyBowlStorageLocation), [
102
+ O,
103
+ l,
104
+ I
105
+ ]), B = t((e) => I(k({ variables: { input: {
106
+ ...e,
107
+ context: l
108
+ } } }), (e) => e.placeHealthyBowlStorageLot), [
109
+ k,
110
+ l,
111
+ I
112
+ ]), V = t((e) => I(A({ variables: { input: {
113
+ ...e,
114
+ context: l
115
+ } } }), (e) => e.updateHealthyBowlStorageLot), [
116
+ A,
117
+ l,
118
+ I
119
+ ]), H = t((e) => I(j({ variables: {
120
+ id: e,
121
+ context: l
122
+ } }), (e) => !!e.deleteHealthyBowlStorageLot), [
123
+ j,
124
+ l,
125
+ I
126
+ ]), U = t((e) => I(M({ variables: { input: {
127
+ ...e,
128
+ context: l
129
+ } } }), (e) => e.recordHealthyBowlStockMovement), [
130
+ M,
131
+ l,
132
+ I
133
+ ]);
134
+ return {
135
+ overview: C.data?.healthyBowlStorageOverview ?? null,
136
+ locations: w.data?.healthyBowlStorageLocations ?? [],
137
+ lotDetail: T.data?.healthyBowlStorageLot ?? null,
138
+ loading: {
139
+ overview: C.loading,
140
+ locations: w.loading,
141
+ lot: T.loading
142
+ },
143
+ errors: {
144
+ overview: C.error ?? null,
145
+ lot: T.error ?? null
146
+ },
147
+ refetchOverview: N,
148
+ refetchLocations: P,
149
+ refetchLot: F,
150
+ createLocation: L,
151
+ updateLocation: R,
152
+ deleteLocation: z,
153
+ placeLot: B,
154
+ updateLot: V,
155
+ deleteLot: H,
156
+ recordMovement: U
157
+ };
158
+ }
159
+ //#endregion
160
+ export { b as useHealthyBowlStorage };
161
+
162
+ //# sourceMappingURL=useHealthyBowlStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHealthyBowlStorage.js","names":[],"sources":["../../../src/healthybowl/hooks/useHealthyBowlStorage.ts"],"sourcesContent":["/**\n * Warehouse storage — data hook (roadmap 18 · BOFF-2890 · gap K-1).\n *\n * Storage locations (warehouse → bin), lots of produce/milk in a bin, and an IN/OUT\n * stock-movement ledger that keeps each lot's on-hand quantity in sync. Documents are inline\n * `gql` (escape hatch); types mirror `wspace-healthybowl-svc/.../schema/storage.gql`. Reads use\n * `cache-and-network`; writes throw on error then refetch (fe-libs clears the 15s read cache on\n * every successful mutation).\n */\n\nimport { useCallback, useMemo } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@apollo/client/react';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nconst FALLBACK_WORKSPACE_ID = '00000000-0000-0000-0000-000000000001';\n\nexport interface StorageLocation {\n id: string;\n name: string;\n kind: string;\n storageType: string | null;\n parentId: string | null;\n capacity: number | null;\n capacityUnit: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface StorageLot {\n id: string;\n locationId: string;\n locationName: string;\n warehouseName: string;\n lotCode: string;\n produce: string;\n productId: string | null;\n productionBatchId: string | null;\n traceBatchId: string | null;\n harvestRecordId: string | null;\n quantity: number;\n unit: string;\n status: string;\n receivedAt: string | null;\n expiryDate: string | null;\n notes: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface StockMovement {\n id: string;\n lotId: string | null;\n lotCode: string | null;\n produce: string | null;\n locationId: string | null;\n locationName: string | null;\n direction: string;\n quantity: number;\n unit: string;\n reason: string | null;\n orderId: string | null;\n reference: string | null;\n occurredAt: string;\n notes: string | null;\n createdAt: string;\n}\n\nexport interface WarehouseBin {\n location: StorageLocation;\n lots: StorageLot[];\n}\n\nexport interface WarehouseSummary {\n warehouse: StorageLocation;\n usedCapacity: number;\n capacity: number | null;\n capacityUnit: string;\n capacityPct: number | null;\n binCount: number;\n lotCount: number;\n bins: WarehouseBin[];\n}\n\nexport interface StorageOverview {\n warehouses: WarehouseSummary[];\n recentMovements: StockMovement[];\n}\n\nexport interface StorageLotDetail {\n lot: StorageLot;\n movements: StockMovement[];\n}\n\ninterface HbContext {\n workspaceId: string;\n}\n\nconst LOCATION_FIELDS = `id name kind storageType parentId capacity capacityUnit notes createdAt updatedAt`;\nconst LOT_FIELDS = `id locationId locationName warehouseName lotCode produce productId productionBatchId traceBatchId harvestRecordId quantity unit status receivedAt expiryDate notes createdAt updatedAt`;\nconst MOVEMENT_FIELDS = `id lotId lotCode produce locationId locationName direction quantity unit reason orderId reference occurredAt notes createdAt`;\n\nconst GET_OVERVIEW = gql`\n query HealthyBowlStorageOverview($context: ContextInput!) {\n healthyBowlStorageOverview(context: $context) {\n warehouses {\n warehouse { ${LOCATION_FIELDS} }\n usedCapacity\n capacity\n capacityUnit\n capacityPct\n binCount\n lotCount\n bins { location { ${LOCATION_FIELDS} } lots { ${LOT_FIELDS} } }\n }\n recentMovements { ${MOVEMENT_FIELDS} }\n }\n }\n`;\n\nconst GET_LOCATIONS = gql`\n query HealthyBowlStorageLocations($context: ContextInput!, $kind: String) {\n healthyBowlStorageLocations(context: $context, kind: $kind) { ${LOCATION_FIELDS} }\n }\n`;\n\nconst GET_LOT = gql`\n query HealthyBowlStorageLot($context: ContextInput!, $id: ID!) {\n healthyBowlStorageLot(id: $id, context: $context) {\n lot { ${LOT_FIELDS} }\n movements { ${MOVEMENT_FIELDS} }\n }\n }\n`;\n\nconst CREATE_LOCATION = gql`\n mutation CreateHealthyBowlStorageLocation($input: CreateHealthyBowlStorageLocationInput!) {\n createHealthyBowlStorageLocation(input: $input) { ${LOCATION_FIELDS} }\n }\n`;\nconst UPDATE_LOCATION = gql`\n mutation UpdateHealthyBowlStorageLocation($input: UpdateHealthyBowlStorageLocationInput!) {\n updateHealthyBowlStorageLocation(input: $input) { ${LOCATION_FIELDS} }\n }\n`;\nconst DELETE_LOCATION = gql`\n mutation DeleteHealthyBowlStorageLocation($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlStorageLocation(id: $id, context: $context)\n }\n`;\nconst PLACE_LOT = gql`\n mutation PlaceHealthyBowlStorageLot($input: PlaceHealthyBowlStorageLotInput!) {\n placeHealthyBowlStorageLot(input: $input) { ${LOT_FIELDS} }\n }\n`;\nconst UPDATE_LOT = gql`\n mutation UpdateHealthyBowlStorageLot($input: UpdateHealthyBowlStorageLotInput!) {\n updateHealthyBowlStorageLot(input: $input) { ${LOT_FIELDS} }\n }\n`;\nconst DELETE_LOT = gql`\n mutation DeleteHealthyBowlStorageLot($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlStorageLot(id: $id, context: $context)\n }\n`;\nconst RECORD_MOVEMENT = gql`\n mutation RecordHealthyBowlStockMovement($input: RecordHealthyBowlStockMovementInput!) {\n recordHealthyBowlStockMovement(input: $input) { ${MOVEMENT_FIELDS} }\n }\n`;\n\nexport interface UseStorageOptions {\n overview?: boolean;\n /** Fetch the flat location list (optionally filtered by kind) — used by the form Selects. */\n locations?: boolean;\n locationsKind?: string | null;\n lotId?: string | null;\n}\n\nexport function useHealthyBowlStorage(options: UseStorageOptions = {}) {\n const { workspaceId } = useHealthyBowl();\n const effectiveWorkspaceId = workspaceId || FALLBACK_WORKSPACE_ID;\n const ctx = useMemo<HbContext>(() => ({ workspaceId: effectiveWorkspaceId }), [effectiveWorkspaceId]);\n\n const enableOverview = options.overview === true;\n const enableLocations = options.locations === true;\n const lotId = options.lotId ?? null;\n\n const overviewQuery = useQuery<{ healthyBowlStorageOverview: StorageOverview }, { context: HbContext }>(\n GET_OVERVIEW,\n {\n variables: { context: ctx },\n fetchPolicy: 'cache-and-network',\n skip: !enableOverview,\n }\n );\n\n const locationsQuery = useQuery<{ healthyBowlStorageLocations: StorageLocation[] }, Record<string, unknown>>(\n GET_LOCATIONS,\n {\n variables: { context: ctx, kind: options.locationsKind ?? null },\n fetchPolicy: 'cache-and-network',\n skip: !enableLocations,\n }\n );\n\n const lotQuery = useQuery<{ healthyBowlStorageLot: StorageLotDetail }, Record<string, unknown>>(GET_LOT, {\n variables: { context: ctx, id: lotId },\n fetchPolicy: 'cache-and-network',\n skip: !lotId,\n });\n\n const [createLocationM] = useMutation(CREATE_LOCATION);\n const [updateLocationM] = useMutation(UPDATE_LOCATION);\n const [deleteLocationM] = useMutation(DELETE_LOCATION);\n const [placeLotM] = useMutation(PLACE_LOT);\n const [updateLotM] = useMutation(UPDATE_LOT);\n const [deleteLotM] = useMutation(DELETE_LOT);\n const [recordMovementM] = useMutation(RECORD_MOVEMENT);\n\n const refetchOverview = useCallback(\n () => (enableOverview ? overviewQuery.refetch() : Promise.resolve()),\n [enableOverview, overviewQuery]\n );\n const refetchLocations = useCallback(\n () => (enableLocations ? locationsQuery.refetch() : Promise.resolve()),\n [enableLocations, locationsQuery]\n );\n const refetchLot = useCallback(() => (lotId ? lotQuery.refetch() : Promise.resolve()), [lotId, lotQuery]);\n\n const run = useCallback(\n async <T>(promise: Promise<{ data?: unknown }>, pick: (d: unknown) => T): Promise<T> => {\n const res = await promise;\n await Promise.all([refetchOverview(), refetchLot()]);\n return pick(res.data);\n },\n [refetchOverview, refetchLot]\n );\n\n const createLocation = useCallback(\n (input: Record<string, unknown>) =>\n run(\n createLocationM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { createHealthyBowlStorageLocation: StorageLocation }).createHealthyBowlStorageLocation\n ),\n [createLocationM, ctx, run]\n );\n const updateLocation = useCallback(\n (input: Record<string, unknown>) =>\n run(\n updateLocationM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { updateHealthyBowlStorageLocation: StorageLocation }).updateHealthyBowlStorageLocation\n ),\n [updateLocationM, ctx, run]\n );\n const deleteLocation = useCallback(\n (id: string) =>\n run(deleteLocationM({ variables: { id, context: ctx } }), (d) =>\n Boolean((d as { deleteHealthyBowlStorageLocation: boolean }).deleteHealthyBowlStorageLocation)\n ),\n [deleteLocationM, ctx, run]\n );\n const placeLot = useCallback(\n (input: Record<string, unknown>) =>\n run(\n placeLotM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { placeHealthyBowlStorageLot: StorageLot }).placeHealthyBowlStorageLot\n ),\n [placeLotM, ctx, run]\n );\n const updateLot = useCallback(\n (input: Record<string, unknown>) =>\n run(\n updateLotM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { updateHealthyBowlStorageLot: StorageLot }).updateHealthyBowlStorageLot\n ),\n [updateLotM, ctx, run]\n );\n const deleteLot = useCallback(\n (id: string) =>\n run(deleteLotM({ variables: { id, context: ctx } }), (d) =>\n Boolean((d as { deleteHealthyBowlStorageLot: boolean }).deleteHealthyBowlStorageLot)\n ),\n [deleteLotM, ctx, run]\n );\n const recordMovement = useCallback(\n (input: Record<string, unknown>) =>\n run(\n recordMovementM({ variables: { input: { ...input, context: ctx } } }),\n (d) => (d as { recordHealthyBowlStockMovement: StockMovement }).recordHealthyBowlStockMovement\n ),\n [recordMovementM, ctx, run]\n );\n\n return {\n overview: overviewQuery.data?.healthyBowlStorageOverview ?? null,\n locations: locationsQuery.data?.healthyBowlStorageLocations ?? [],\n lotDetail: lotQuery.data?.healthyBowlStorageLot ?? null,\n loading: { overview: overviewQuery.loading, locations: locationsQuery.loading, lot: lotQuery.loading },\n errors: { overview: overviewQuery.error ?? null, lot: lotQuery.error ?? null },\n refetchOverview,\n refetchLocations,\n refetchLot,\n createLocation,\n updateLocation,\n deleteLocation,\n placeLot,\n updateLot,\n deleteLot,\n recordMovement,\n };\n}\n"],"mappings":";;;;;AAeA,IAAM,IAAwB,wCAoFxB,IAAkB,qFAClB,IAAa,0LACb,IAAkB,gIAElB,IAAe,CAAG;;;;sBAIF,EAAgB;;;;;;;4BAOV,EAAgB,YAAY,EAAW;;0BAEzC,EAAgB;;;GAKpC,IAAgB,CAAG;;oEAE2C,EAAgB;;GAI9E,IAAU,CAAG;;;cAGL,EAAW;oBACL,EAAgB;;;GAK9B,IAAkB,CAAG;;wDAE6B,EAAgB;;GAGlE,IAAkB,CAAG;;wDAE6B,EAAgB;;GAGlE,IAAkB,CAAG;;;;GAKrB,IAAY,CAAG;;kDAE6B,EAAW;;GAGvD,IAAa,CAAG;;mDAE6B,EAAW;;GAGxD,IAAa,CAAG;;;;GAKhB,IAAkB,CAAG;;sDAE2B,EAAgB;;;AAYtE,SAAgB,EAAsB,IAA6B,EAAE,EAAE;CACrE,IAAM,EAAE,mBAAgB,GAAgB,EAClC,IAAuB,KAAe,GACtC,IAAM,SAA0B,EAAE,aAAa,GAAsB,GAAG,CAAC,EAAqB,CAAC,EAE/F,IAAiB,EAAQ,aAAa,IACtC,IAAkB,EAAQ,cAAc,IACxC,IAAQ,EAAQ,SAAS,MAEzB,IAAgB,EACpB,GACA;EACE,WAAW,EAAE,SAAS,GAAK;EAC3B,aAAa;EACb,MAAM,CAAC;EACR,CACF,EAEK,IAAiB,EACrB,GACA;EACE,WAAW;GAAE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AAgB,EAAE,WAAW;EAAE;EAAI,SAAS;EAAK,EAAE,CAAC,GAAG,MACzD,EAAS,EAAoD,iCAC9D,EACH;EAAC;EAAiB;EAAK;EAAI,CAC5B,EACK,IAAW,GACd,MACC,EACE,EAAU,EAAE,WAAW,EAAE,OAAO;EAAE,GAAG;EAAO,SAAS;EAAK,EAAE,EAAE,CAAC,GAC9D,MAAO,EAAiD,2BAC1D,EACH;EAAC;EAAW;EAAK;EAAI,CACtB,EACK,IAAY,GACf,MACC,EACE,EAAW,EAAE,WAAW,EAAE,OAAO;EAAE,GAAG;EAAO,SAAS;EAAK,EAAE,EAAE,CAAC,GAC/D,MAAO,EAAkD,4BAC3D,EACH;EAAC;EAAY;EAAK;EAAI,CACvB,EACK,IAAY,GACf,MACC,EAAI,EAAW,EAAE,WAAW;EAAE;EAAI,SAAS;EAAK,EAAE,CAAC,GAAG,MACpD,EAAS,EAA+C,4BACzD,EACH;EAAC;EAAY;EAAK;EAAI,CACvB,EACK,IAAiB,GACpB,MACC,EACE,EAAgB,EAAE,WAAW,EAAE,OAAO;EAAE,GAAG;EAAO,SAAS;EAAK,EAAE,EAAE,CAAC,GACpE,MAAO,EAAwD,+BACjE,EACH;EAAC;EAAiB;EAAK;EAAI,CAC5B;AAED,QAAO;EACL,UAAU,EAAc,MAAM,8BAA8B;EAC5D,WAAW,EAAe,MAAM,+BAA+B,EAAE;EACjE,WAAW,EAAS,MAAM,yBAAyB;EACnD,SAAS;GAAE,UAAU,EAAc;GAAS,WAAW,EAAe;GAAS,KAAK,EAAS;GAAS;EACtG,QAAQ;GAAE,UAAU,EAAc,SAAS;GAAM,KAAK,EAAS,SAAS;GAAM;EAC9E;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -0,0 +1,131 @@
1
+ import { useHealthyBowl as e } from "../context/HealthyBowlContext.js";
2
+ import { useCallback as t, useEffect as n, useState as r } from "react";
3
+ import { graphqlFetch as i } from "@burdenoff/fe-libs/shared/graphql";
4
+ //#region src/healthybowl/hooks/usePlantScans.ts
5
+ var a = class extends Error {
6
+ code;
7
+ constructor(e, t) {
8
+ super(e), this.name = "PlantScanError", this.code = t;
9
+ }
10
+ };
11
+ function o(e) {
12
+ if (e && e.length > 0) {
13
+ let t = e[0];
14
+ throw new a(t.extensions?.userMessage ?? t.message, t.extensions?.code ?? "INTERNAL_SERVER_ERROR");
15
+ }
16
+ }
17
+ var s = "\n id fieldId fieldName cropName photoFileIds status isPlant isHealthy\n topDiagnosis topScientificName topType topConfidence severity\n candidates { name scientificName type confidence severity affectedPart symptoms }\n recommendedActions advisoryText advisorySource modelProvider modelName\n classesConsidered processingMs notes latitude longitude loggedPestIssueId\n capturedAt createdBy createdAt updatedAt\n", c = `
18
+ query GetHealthyBowlPlantScans($context: ContextInput!, $filter: PlantScanFilterInput) {
19
+ getHealthyBowlPlantScans(context: $context, filter: $filter) {
20
+ scans { ${s} }
21
+ stats { totalScans scansThisSeason issuesCaughtEarly avgConfidence }
22
+ updatedAt
23
+ }
24
+ }
25
+ `, l = `
26
+ mutation DiagnoseHealthyBowlPlantScan($input: DiagnosePlantScanInput!) {
27
+ diagnoseHealthyBowlPlantScan(input: $input) { ${s} }
28
+ }
29
+ `, u = "\n mutation LogHealthyBowlPlantScanToPestIssue($input: LogPlantScanToPestIssueInput!) {\n logHealthyBowlPlantScanToPestIssue(input: $input) {\n id pest type affectedCrop affectedField severity status detectedDate treatment\n }\n }\n", d = "\n mutation DeleteHealthyBowlPlantScan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantScan(id: $id, context: $context)\n }\n", f = "\n query HealthyBowlPlantScanImageUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n";
30
+ function p(s) {
31
+ let { workspaceId: f } = e(), [p, m] = r(null), [h, g] = r(!0), [_, v] = r(null), y = t(async (e) => {
32
+ if (!f) {
33
+ g(!1);
34
+ return;
35
+ }
36
+ g(!0), v(null);
37
+ try {
38
+ let t = await i({
39
+ gateway: "workspace",
40
+ query: c,
41
+ variables: {
42
+ context: { workspaceId: f },
43
+ filter: e ?? s ?? null
44
+ },
45
+ workspaceToken: !0,
46
+ workspaceId: f,
47
+ suppressGlobalErrorEvent: !0
48
+ });
49
+ o(t.errors), m(t.data?.getHealthyBowlPlantScans ?? null);
50
+ } catch (e) {
51
+ v(e instanceof Error ? e : Error(String(e)));
52
+ } finally {
53
+ g(!1);
54
+ }
55
+ }, [f, s]);
56
+ return n(() => {
57
+ y();
58
+ }, [y]), {
59
+ data: p,
60
+ loading: h,
61
+ error: _,
62
+ refetch: y,
63
+ diagnose: t(async (e) => {
64
+ let t = await i({
65
+ gateway: "workspace",
66
+ query: l,
67
+ variables: { input: {
68
+ context: { workspaceId: f },
69
+ ...e
70
+ } },
71
+ workspaceToken: !0,
72
+ workspaceId: f,
73
+ suppressGlobalErrorEvent: !0
74
+ });
75
+ o(t.errors);
76
+ let n = t.data?.diagnoseHealthyBowlPlantScan;
77
+ if (!n) throw new a("Empty diagnosis response", "INTERNAL_SERVER_ERROR");
78
+ return n;
79
+ }, [f]),
80
+ logToPest: t(async (e) => {
81
+ let t = await i({
82
+ gateway: "workspace",
83
+ query: u,
84
+ variables: { input: {
85
+ context: { workspaceId: f },
86
+ ...e
87
+ } },
88
+ workspaceToken: !0,
89
+ workspaceId: f,
90
+ suppressGlobalErrorEvent: !0
91
+ });
92
+ o(t.errors);
93
+ let n = t.data?.logHealthyBowlPlantScanToPestIssue;
94
+ if (!n) throw new a("Empty log response", "INTERNAL_SERVER_ERROR");
95
+ return n;
96
+ }, [f]),
97
+ deleteScan: t(async (e) => {
98
+ let t = await i({
99
+ gateway: "workspace",
100
+ query: d,
101
+ variables: {
102
+ id: e,
103
+ context: { workspaceId: f }
104
+ },
105
+ workspaceToken: !0,
106
+ workspaceId: f,
107
+ suppressGlobalErrorEvent: !0
108
+ });
109
+ return o(t.errors), t.data?.deleteHealthyBowlPlantScan ?? !1;
110
+ }, [f])
111
+ };
112
+ }
113
+ async function m(e, t) {
114
+ if (!e || !t) return null;
115
+ try {
116
+ return (await i({
117
+ gateway: "workspace",
118
+ query: f,
119
+ variables: { id: e },
120
+ workspaceToken: !0,
121
+ workspaceId: t,
122
+ suppressGlobalErrorEvent: !0
123
+ })).data?.getFileDownloadUrl ?? null;
124
+ } catch {
125
+ return null;
126
+ }
127
+ }
128
+ //#endregion
129
+ export { m as resolvePlantScanImageUrl, p as usePlantScans };
130
+
131
+ //# sourceMappingURL=usePlantScans.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePlantScans.js","names":[],"sources":["../../../src/healthybowl/hooks/usePlantScans.ts"],"sourcesContent":["/**\n * AI Pest & Disease Detection data hook (BOFF-2887).\n *\n * Talks to `wspace-healthybowl-svc` through the workspaces public gateway via the\n * fe-libs `graphqlFetch` helper (which re-derives the bearer + workspace dual-token\n * + x-workspace-id from profile storage on every call). We use raw operations here\n * rather than the codegen'd Apollo hooks so the feature does not depend on the new\n * subgraph already being composed into the FE's checked-in schema snapshot.\n *\n * The gateway enforces the `@rbac(scopeType:\"wspace\")` directives on every field.\n */\nimport { useCallback, useEffect, useState } from 'react';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\nimport { useHealthyBowl } from '../context/HealthyBowlContext';\n\nexport interface PlantDiagnosisCandidate {\n name: string;\n scientificName?: string | null;\n type: string;\n confidence: number;\n severity: string;\n affectedPart?: string | null;\n symptoms?: string | null;\n}\n\nexport interface PlantScan {\n id: string;\n fieldId?: string | null;\n fieldName?: string | null;\n cropName?: string | null;\n photoFileIds: string[];\n status: string;\n isPlant: boolean;\n isHealthy: boolean;\n topDiagnosis?: string | null;\n topScientificName?: string | null;\n topType?: string | null;\n topConfidence?: number | null;\n severity?: string | null;\n candidates: PlantDiagnosisCandidate[];\n recommendedActions: string[];\n advisoryText?: string | null;\n advisorySource: string;\n modelProvider?: string | null;\n modelName?: string | null;\n classesConsidered?: number | null;\n processingMs?: number | null;\n notes?: string | null;\n latitude?: number | null;\n longitude?: number | null;\n loggedPestIssueId?: string | null;\n capturedAt: string;\n createdBy: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface PlantScanStats {\n totalScans: number;\n scansThisSeason: number;\n issuesCaughtEarly: number;\n avgConfidence: number;\n}\n\nexport interface PlantScanListResult {\n scans: PlantScan[];\n stats: PlantScanStats;\n updatedAt: string;\n}\n\nexport interface DiagnoseInput {\n fieldId?: string | null;\n fieldName?: string | null;\n cropName?: string | null;\n photoFileId?: string | null;\n imageBase64?: string | null;\n imageUrl?: string | null;\n notes?: string | null;\n latitude?: number | null;\n longitude?: number | null;\n capturedAt?: string | null;\n}\n\nexport interface LogToPestInput {\n scanId: string;\n fieldId: string;\n pestName?: string | null;\n type?: string | null;\n cropAffected?: string | null;\n severity?: string | null;\n status?: string | null;\n treatment?: string | null;\n notes?: string | null;\n attachPhoto?: boolean;\n}\n\nexport interface LoggedPestIssue {\n id: string;\n pest: string;\n type: string;\n affectedCrop: string;\n affectedField: string;\n severity: string;\n status: string;\n detectedDate: string;\n treatment?: string | null;\n}\n\ninterface GqlError {\n message: string;\n extensions?: { code?: string; userMessage?: string };\n}\n\nexport class PlantScanError extends Error {\n code: string;\n constructor(message: string, code: string) {\n super(message);\n this.name = 'PlantScanError';\n this.code = code;\n }\n}\n\nfunction throwIfError(errors: GqlError[] | undefined): void {\n if (errors && errors.length > 0) {\n const e = errors[0];\n throw new PlantScanError(e.extensions?.userMessage ?? e.message, e.extensions?.code ?? 'INTERNAL_SERVER_ERROR');\n }\n}\n\nconst SCAN_FIELDS = `\n id fieldId fieldName cropName photoFileIds status isPlant isHealthy\n topDiagnosis topScientificName topType topConfidence severity\n candidates { name scientificName type confidence severity affectedPart symptoms }\n recommendedActions advisoryText advisorySource modelProvider modelName\n classesConsidered processingMs notes latitude longitude loggedPestIssueId\n capturedAt createdBy createdAt updatedAt\n`;\n\nconst LIST_QUERY = `\n query GetHealthyBowlPlantScans($context: ContextInput!, $filter: PlantScanFilterInput) {\n getHealthyBowlPlantScans(context: $context, filter: $filter) {\n scans { ${SCAN_FIELDS} }\n stats { totalScans scansThisSeason issuesCaughtEarly avgConfidence }\n updatedAt\n }\n }\n`;\n\nconst DIAGNOSE_MUTATION = `\n mutation DiagnoseHealthyBowlPlantScan($input: DiagnosePlantScanInput!) {\n diagnoseHealthyBowlPlantScan(input: $input) { ${SCAN_FIELDS} }\n }\n`;\n\nconst LOG_MUTATION = `\n mutation LogHealthyBowlPlantScanToPestIssue($input: LogPlantScanToPestIssueInput!) {\n logHealthyBowlPlantScanToPestIssue(input: $input) {\n id pest type affectedCrop affectedField severity status detectedDate treatment\n }\n }\n`;\n\nconst DELETE_MUTATION = `\n mutation DeleteHealthyBowlPlantScan($id: ID!, $context: ContextInput!) {\n deleteHealthyBowlPlantScan(id: $id, context: $context)\n }\n`;\n\nconst DOWNLOAD_URL_QUERY = `\n query HealthyBowlPlantScanImageUrl($id: ID!) {\n getFileDownloadUrl(id: $id)\n }\n`;\n\nexport interface PlantScanFilter {\n cropName?: string | null;\n status?: string | null;\n diagnosis?: string | null;\n limit?: number;\n offset?: number;\n}\n\nexport function usePlantScans(initialFilter?: PlantScanFilter) {\n const { workspaceId } = useHealthyBowl();\n const [data, setData] = useState<PlantScanListResult | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchList = useCallback(\n async (filter?: PlantScanFilter): Promise<void> => {\n if (!workspaceId) {\n setLoading(false);\n return;\n }\n setLoading(true);\n setError(null);\n try {\n const res = await graphqlFetch<{ getHealthyBowlPlantScans: PlantScanListResult }>({\n gateway: 'workspace',\n query: LIST_QUERY,\n variables: { context: { workspaceId }, filter: filter ?? initialFilter ?? null },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n });\n throwIfError(res.errors as GqlError[] | undefined);\n setData(res.data?.getHealthyBowlPlantScans ?? null);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(String(err)));\n } finally {\n setLoading(false);\n }\n },\n [workspaceId, initialFilter]\n );\n\n useEffect(() => {\n void fetchList();\n }, [fetchList]);\n\n const diagnose = useCallback(\n async (input: DiagnoseInput): Promise<PlantScan> => {\n const res = await graphqlFetch<{ diagnoseHealthyBowlPlantScan: PlantScan }>({\n gateway: 'workspace',\n query: DIAGNOSE_MUTATION,\n variables: { input: { context: { workspaceId }, ...input } },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n });\n throwIfError(res.errors as GqlError[] | undefined);\n const scan = res.data?.diagnoseHealthyBowlPlantScan;\n if (!scan) throw new PlantScanError('Empty diagnosis response', 'INTERNAL_SERVER_ERROR');\n return scan;\n },\n [workspaceId]\n );\n\n const logToPest = useCallback(\n async (input: LogToPestInput): Promise<LoggedPestIssue> => {\n const res = await graphqlFetch<{ logHealthyBowlPlantScanToPestIssue: LoggedPestIssue }>({\n gateway: 'workspace',\n query: LOG_MUTATION,\n variables: { input: { context: { workspaceId }, ...input } },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n });\n throwIfError(res.errors as GqlError[] | undefined);\n const issue = res.data?.logHealthyBowlPlantScanToPestIssue;\n if (!issue) throw new PlantScanError('Empty log response', 'INTERNAL_SERVER_ERROR');\n return issue;\n },\n [workspaceId]\n );\n\n const deleteScan = useCallback(\n async (id: string): Promise<boolean> => {\n const res = await graphqlFetch<{ deleteHealthyBowlPlantScan: boolean }>({\n gateway: 'workspace',\n query: DELETE_MUTATION,\n variables: { id, context: { workspaceId } },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n });\n throwIfError(res.errors as GqlError[] | undefined);\n return res.data?.deleteHealthyBowlPlantScan ?? false;\n },\n [workspaceId]\n );\n\n return { data, loading, error, refetch: fetchList, diagnose, logToPest, deleteScan };\n}\n\n/** Resolve an opaque files-svc id to a short-lived presigned URL for a thumbnail. */\nexport async function resolvePlantScanImageUrl(fileId: string, workspaceId: string): Promise<string | null> {\n if (!fileId || !workspaceId) return null;\n try {\n const res = await graphqlFetch<{ getFileDownloadUrl?: string | null }>({\n gateway: 'workspace',\n query: DOWNLOAD_URL_QUERY,\n variables: { id: fileId },\n workspaceToken: true,\n workspaceId,\n suppressGlobalErrorEvent: true,\n });\n return res.data?.getFileDownloadUrl ?? null;\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;AAiHA,IAAa,IAAb,cAAoC,MAAM;CACxC;CACA,YAAY,GAAiB,GAAc;AAGzC,EAFA,MAAM,EAAQ,EACd,KAAK,OAAO,kBACZ,KAAK,OAAO;;;AAIhB,SAAS,EAAa,GAAsC;AAC1D,KAAI,KAAU,EAAO,SAAS,GAAG;EAC/B,IAAM,IAAI,EAAO;AACjB,QAAM,IAAI,EAAe,EAAE,YAAY,eAAe,EAAE,SAAS,EAAE,YAAY,QAAQ,wBAAwB;;;AAInH,IAAM,IAAc,saASd,IAAa;;;gBAGH,EAAY;;;;;GAOtB,IAAoB;;oDAE0B,EAAY;;GAI1D,IAAe,yPAQf,IAAkB,mJAMlB,IAAqB;AAc3B,SAAgB,EAAc,GAAiC;CAC7D,IAAM,EAAE,mBAAgB,GAAgB,EAClC,CAAC,GAAM,KAAW,EAAqC,KAAK,EAC5D,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAEhD,IAAY,EAChB,OAAO,MAA4C;AACjD,MAAI,CAAC,GAAa;AAChB,KAAW,GAAM;AACjB;;AAGF,EADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,MAAI;GACF,IAAM,IAAM,MAAM,EAAgE;IAChF,SAAS;IACT,OAAO;IACP,WAAW;KAAE,SAAS,EAAE,gBAAa;KAAE,QAAQ,KAAU,KAAiB;KAAM;IAChF,gBAAgB;IAChB;IACA,0BAA0B;IAC3B,CAAC;AAEF,GADA,EAAa,EAAI,OAAiC,EAClD,EAAQ,EAAI,MAAM,4BAA4B,KAAK;WAC5C,GAAK;AACZ,KAAS,aAAe,QAAQ,IAAU,MAAM,OAAO,EAAI,CAAC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