@deepintel-ltd/farmpro-contracts 1.36.2 → 1.36.4

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"farm-fertilizers.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/farm-fertilizers.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,uBAAuB,8CAA4C,CAAC;AACjF,eAAO,MAAM,oBAAoB,8CAA4C,CAAC;AAI9E,mGAAmG;AACnG,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;IAerC,uFAAuF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOvF,CAAC;AACH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAEtF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;IAiB/B,4DAA4D;;IAE5D,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAE5C,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE1E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;QAPnC,4DAA4D;;QAE5D,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAK4C,CAAC;AAe3F,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;IAgBvC,kFAAkF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMlF,CAAC;AAEL,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;EAKzC,CAAC;AASH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;;;;;;QArB7C,kHAAkH;;;;;;QAMlH,sFAAsF;;QAEtF,8HAA8H;;QAE9H,yDAAyD;;;QAGzD,0DAA0D;;QAE1D,8EAA8E;;;;QAI9E,yDAAyD;;QAEzD,6CAA6C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA4B7C,uEAAuE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGvE,CAAC;AACH,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC"}
@@ -0,0 +1,149 @@
1
+ import { z } from 'zod';
2
+ export const applicationMethodSchema = z.enum(['fertigation', 'foliar', 'soil']);
3
+ export const fertilizerFormSchema = z.enum(['soluble', 'granular', 'liquid']);
4
+ const percent = z.number().min(0).max(100);
5
+ /** What reading a bag photo returns. Nothing in it reaches a plan until the farmer confirms it. */
6
+ export const fertilizerLabelDraftSchema = z.object({
7
+ name: z.string(),
8
+ brand: z.string().nullable(),
9
+ nitrogen: percent,
10
+ phosphorus: percent,
11
+ potassium: percent,
12
+ calcium: percent,
13
+ magnesium: percent,
14
+ sulfate: z.boolean(),
15
+ micronutrients: z.record(z.string(), z.number()).nullable(),
16
+ form: fertilizerFormSchema,
17
+ applicationMethods: z.array(applicationMethodSchema),
18
+ labelDirections: z.string().nullable(),
19
+ bagSizeKg: z.number().nullable(),
20
+ catalogueProductId: z.string().nullable(),
21
+ /** Whether the analysis was printed on the bag or filled in from the standard salt. */
22
+ analysisFrom: z.enum(['bag', 'catalogue']),
23
+ legibility: z.enum(['clear', 'partial', 'poor']),
24
+ roles: z.array(z.string()),
25
+ questions: z.array(z.object({ id: z.enum(['use-unclear', 'analysis-missing', 'stock']), text: z.string() })),
26
+ });
27
+ export const farmFertilizerSchema = z.object({
28
+ id: z.string(),
29
+ name: z.string(),
30
+ brand: z.string().nullable(),
31
+ catalogueProductId: z.string().nullable(),
32
+ nitrogen: percent,
33
+ phosphorus: percent,
34
+ potassium: percent,
35
+ calcium: percent,
36
+ magnesium: percent,
37
+ sulfate: z.boolean(),
38
+ micronutrients: z.record(z.string(), z.number()).nullable(),
39
+ form: fertilizerFormSchema,
40
+ applicationMethods: z.array(applicationMethodSchema),
41
+ roles: z.array(z.string()),
42
+ labelDirections: z.string().nullable(),
43
+ bagSizeKg: z.number().nullable(),
44
+ /** Kilograms on hand, or null when stock is not tracked. */
45
+ stockKg: z.number().nullable(),
46
+ /** The plan may put it through the drip. */
47
+ fertigationSafe: z.boolean(),
48
+ });
49
+ export const farmFertilizerListSchema = z.object({ items: z.array(farmFertilizerSchema) });
50
+ /** Percent of product mass can never add up past 100, and a bag with no analysis cannot be dosed. */
51
+ const analysisAddsUp = (value) => {
52
+ const total = value.nitrogen + value.phosphorus + value.potassium + value.calcium + value.magnesium;
53
+ return total > 0 && total <= 100;
54
+ };
55
+ export const createFarmFertilizerBodySchema = z
56
+ .object({
57
+ name: z.string().trim().min(1).max(200),
58
+ brand: z.string().trim().max(100).nullable().optional(),
59
+ nitrogen: percent,
60
+ phosphorus: percent,
61
+ potassium: percent,
62
+ calcium: percent,
63
+ magnesium: percent,
64
+ sulfate: z.boolean().default(false),
65
+ micronutrients: z.record(z.string(), z.number().min(0).max(100)).nullable().optional(),
66
+ form: fertilizerFormSchema.default('soluble'),
67
+ applicationMethods: z.array(applicationMethodSchema).min(1),
68
+ labelDirections: z.string().max(1000).nullable().optional(),
69
+ bagSizeKg: z.number().positive().max(1000).nullable().optional(),
70
+ catalogueProductId: z.string().max(60).nullable().optional(),
71
+ /** Kilograms on hand now (bags times bag size). Omit to leave stock untracked. */
72
+ stockKg: z.number().min(0).max(1_000_000).nullable().optional(),
73
+ })
74
+ .refine(analysisAddsUp, {
75
+ message: 'The analysis must add up to more than 0% and no more than 100%',
76
+ path: ['nitrogen'],
77
+ });
78
+ export const updateFarmFertilizerBodySchema = z.object({
79
+ name: z.string().trim().min(1).max(200).optional(),
80
+ applicationMethods: z.array(applicationMethodSchema).min(1).optional(),
81
+ bagSizeKg: z.number().positive().max(1000).nullable().optional(),
82
+ stockKg: z.number().min(0).max(1_000_000).optional(),
83
+ });
84
+ const guidanceSchema = z.object({
85
+ why: z.string(),
86
+ when: z.string(),
87
+ how: z.array(z.string()),
88
+ warning: z.string().nullable(),
89
+ });
90
+ /**
91
+ * One fertilizer's place in a field's plan: its dose from the live plan, what the field and the farm need over
92
+ * the planning weeks, what the farm has, what to buy, and the plain-language guidance for using it.
93
+ */
94
+ export const fertilizerRequirementSchema = z.object({
95
+ id: z.string(),
96
+ name: z.string(),
97
+ brand: z.string().nullable(),
98
+ role: z.string().nullable(),
99
+ tank: z.enum(['A', 'B']).nullable(),
100
+ /** on-farm: confirmed and counted. not-recorded: the plan's own suggestion; the farm has not said what it has. */
101
+ availability: z.enum(['on-farm', 'not-recorded']),
102
+ gramsPerPlantPerFeed: z.number().nullable(),
103
+ fieldKgPerFeed: z.number().nullable(),
104
+ gramsPerPlantPerWeek: z.number().nullable(),
105
+ fieldKgPerWeek: z.number().nullable(),
106
+ /** Kilograms this field needs over the planning weeks at the current stage's rate. */
107
+ fieldNeedKg: z.number().nullable(),
108
+ /** Kilograms every field on the farm needs over the planning weeks. Stock is one pool, so this is what it is held against. */
109
+ farmNeedKg: z.number().nullable(),
110
+ /** How many of the farm's fields use this fertilizer. */
111
+ fieldCount: z.number(),
112
+ stockKg: z.number().nullable(),
113
+ /** Weeks the farm's stock lasts across all its fields. */
114
+ weeksOfCover: z.number().nullable(),
115
+ /** Kilograms to buy so the farm covers every field for the planning weeks. */
116
+ purchaseKg: z.number().nullable(),
117
+ purchaseBags: z.number().nullable(),
118
+ bagSizeKg: z.number().nullable(),
119
+ /** Anything else the bag supplies, e.g. "Boron 0.3%". */
120
+ additionalNutrients: z.string().nullable(),
121
+ /** The label's own words on use and rate. */
122
+ labelDirections: z.string().nullable(),
123
+ guidance: guidanceSchema,
124
+ });
125
+ export const uncoveredRoleSchema = z.object({
126
+ role: z.string(),
127
+ message: z.string(),
128
+ suggestedProduct: z.string().nullable(),
129
+ });
130
+ export const fertilizerRequirementsResponseSchema = z.object({
131
+ fieldId: z.string(),
132
+ status: z.enum(['ok', 'no-plan']),
133
+ message: z.string().nullable(),
134
+ stage: z.object({ id: z.string(), label: z.string() }).nullable(),
135
+ fertilizerSet: z.object({ id: z.string(), name: z.string() }).nullable(),
136
+ /** True when the plan is built from the fertilizers this farm confirmed. */
137
+ usesFarmFertilizers: z.boolean(),
138
+ plantCount: z.number().nullable(),
139
+ planningWeeks: z.number(),
140
+ /** In the plan this stage, through the drip. */
141
+ fertigation: z.array(fertilizerRequirementSchema),
142
+ /** Confirmed for fertigation but with no job at this stage. */
143
+ standby: z.array(fertilizerRequirementSchema),
144
+ foliar: z.array(fertilizerRequirementSchema),
145
+ soil: z.array(fertilizerRequirementSchema),
146
+ /** Jobs the stage needs done that no fertilizer on the farm can do. */
147
+ uncoveredRoles: z.array(uncoveredRoleSchema),
148
+ warnings: z.array(z.string()),
149
+ });
@@ -265,6 +265,7 @@ export declare const outbreakEventSchema: z.ZodObject<{
265
265
  source: string;
266
266
  summary: string | null;
267
267
  disease: string;
268
+ guidance: string[];
268
269
  species: string[];
269
270
  admin1: string | null;
270
271
  admin2: string | null;
@@ -274,13 +275,13 @@ export declare const outbreakEventSchema: z.ZodObject<{
274
275
  sourceUrl: string | null;
275
276
  diseaseKey: string;
276
277
  notifiable: boolean;
277
- guidance: string[];
278
278
  }, {
279
279
  status: string;
280
280
  id: string;
281
281
  source: string;
282
282
  summary: string | null;
283
283
  disease: string;
284
+ guidance: string[];
284
285
  species: string[];
285
286
  admin1: string | null;
286
287
  admin2: string | null;
@@ -290,7 +291,6 @@ export declare const outbreakEventSchema: z.ZodObject<{
290
291
  sourceUrl: string | null;
291
292
  diseaseKey: string;
292
293
  notifiable: boolean;
293
- guidance: string[];
294
294
  }>;
295
295
  export declare const outbreakListSchema: z.ZodObject<{
296
296
  data: z.ZodArray<z.ZodObject<{
@@ -315,6 +315,7 @@ export declare const outbreakListSchema: z.ZodObject<{
315
315
  source: string;
316
316
  summary: string | null;
317
317
  disease: string;
318
+ guidance: string[];
318
319
  species: string[];
319
320
  admin1: string | null;
320
321
  admin2: string | null;
@@ -324,13 +325,13 @@ export declare const outbreakListSchema: z.ZodObject<{
324
325
  sourceUrl: string | null;
325
326
  diseaseKey: string;
326
327
  notifiable: boolean;
327
- guidance: string[];
328
328
  }, {
329
329
  status: string;
330
330
  id: string;
331
331
  source: string;
332
332
  summary: string | null;
333
333
  disease: string;
334
+ guidance: string[];
334
335
  species: string[];
335
336
  admin1: string | null;
336
337
  admin2: string | null;
@@ -340,7 +341,6 @@ export declare const outbreakListSchema: z.ZodObject<{
340
341
  sourceUrl: string | null;
341
342
  diseaseKey: string;
342
343
  notifiable: boolean;
343
- guidance: string[];
344
344
  }>, "many">;
345
345
  }, "strip", z.ZodTypeAny, {
346
346
  data: {
@@ -349,6 +349,7 @@ export declare const outbreakListSchema: z.ZodObject<{
349
349
  source: string;
350
350
  summary: string | null;
351
351
  disease: string;
352
+ guidance: string[];
352
353
  species: string[];
353
354
  admin1: string | null;
354
355
  admin2: string | null;
@@ -358,7 +359,6 @@ export declare const outbreakListSchema: z.ZodObject<{
358
359
  sourceUrl: string | null;
359
360
  diseaseKey: string;
360
361
  notifiable: boolean;
361
- guidance: string[];
362
362
  }[];
363
363
  }, {
364
364
  data: {
@@ -367,6 +367,7 @@ export declare const outbreakListSchema: z.ZodObject<{
367
367
  source: string;
368
368
  summary: string | null;
369
369
  disease: string;
370
+ guidance: string[];
370
371
  species: string[];
371
372
  admin1: string | null;
372
373
  admin2: string | null;
@@ -376,7 +377,6 @@ export declare const outbreakListSchema: z.ZodObject<{
376
377
  sourceUrl: string | null;
377
378
  diseaseKey: string;
378
379
  notifiable: boolean;
379
- guidance: string[];
380
380
  }[];
381
381
  }>;
382
382
  export declare const voiceLanguageSchema: z.ZodEnum<["en", "yo", "ha", "ig", "pcm"]>;
@@ -1692,7 +1692,7 @@ export declare const orchardPlanResponseSchema: z.ZodObject<{
1692
1692
  };
1693
1693
  }>>;
1694
1694
  }, "strip", z.ZodTypeAny, {
1695
- status: "ok" | "not-planted" | "no-plan";
1695
+ status: "ok" | "no-plan" | "not-planted";
1696
1696
  message: string | null;
1697
1697
  crop: string | null;
1698
1698
  fieldId: string;
@@ -1805,7 +1805,7 @@ export declare const orchardPlanResponseSchema: z.ZodObject<{
1805
1805
  };
1806
1806
  } | null;
1807
1807
  }, {
1808
- status: "ok" | "not-planted" | "no-plan";
1808
+ status: "ok" | "no-plan" | "not-planted";
1809
1809
  message: string | null;
1810
1810
  crop: string | null;
1811
1811
  fieldId: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepintel-ltd/farmpro-contracts",
3
- "version": "1.36.2",
3
+ "version": "1.36.4",
4
4
  "description": "Type-safe API contracts for FarmPro API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",