@deepintel-ltd/farmpro-contracts 1.36.3 → 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.
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/routes/farm-fertilizers.routes.d.ts +1139 -0
- package/dist/routes/{fertilizer-stock.routes.d.ts.map → farm-fertilizers.routes.d.ts.map} +1 -1
- package/dist/routes/{fertilizer-stock.routes.js → farm-fertilizers.routes.js} +16 -9
- package/dist/routes/index.d.ts +3 -3
- package/dist/routes/index.js +2 -2
- package/dist/routes/integrations.routes.d.ts +4 -4
- package/dist/schemas/farm-fertilizers.schemas.d.ts +1174 -0
- package/dist/schemas/farm-fertilizers.schemas.d.ts.map +1 -0
- package/dist/schemas/{fertilizer-stock.schemas.js → farm-fertilizers.schemas.js} +60 -35
- package/dist/schemas/integrations.schemas.d.ts +6 -6
- package/package.json +1 -1
- package/dist/routes/fertilizer-stock.routes.d.ts +0 -868
- package/dist/schemas/fertilizer-stock.schemas.d.ts +0 -855
- package/dist/schemas/fertilizer-stock.schemas.d.ts.map +0 -1
|
@@ -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,eAA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AAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export const
|
|
2
|
+
export const applicationMethodSchema = z.enum(['fertigation', 'foliar', 'soil']);
|
|
3
3
|
export const fertilizerFormSchema = z.enum(['soluble', 'granular', 'liquid']);
|
|
4
4
|
const percent = z.number().min(0).max(100);
|
|
5
5
|
/** What reading a bag photo returns. Nothing in it reaches a plan until the farmer confirms it. */
|
|
6
|
-
export const
|
|
6
|
+
export const fertilizerLabelDraftSchema = z.object({
|
|
7
7
|
name: z.string(),
|
|
8
8
|
brand: z.string().nullable(),
|
|
9
9
|
nitrogen: percent,
|
|
@@ -14,8 +14,8 @@ export const fertilizerDraftSchema = z.object({
|
|
|
14
14
|
sulfate: z.boolean(),
|
|
15
15
|
micronutrients: z.record(z.string(), z.number()).nullable(),
|
|
16
16
|
form: fertilizerFormSchema,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
applicationMethods: z.array(applicationMethodSchema),
|
|
18
|
+
labelDirections: z.string().nullable(),
|
|
19
19
|
bagSizeKg: z.number().nullable(),
|
|
20
20
|
catalogueProductId: z.string().nullable(),
|
|
21
21
|
/** Whether the analysis was printed on the bag or filled in from the standard salt. */
|
|
@@ -37,17 +37,23 @@ export const farmFertilizerSchema = z.object({
|
|
|
37
37
|
sulfate: z.boolean(),
|
|
38
38
|
micronutrients: z.record(z.string(), z.number()).nullable(),
|
|
39
39
|
form: fertilizerFormSchema,
|
|
40
|
-
|
|
40
|
+
applicationMethods: z.array(applicationMethodSchema),
|
|
41
41
|
roles: z.array(z.string()),
|
|
42
|
-
|
|
42
|
+
labelDirections: z.string().nullable(),
|
|
43
43
|
bagSizeKg: z.number().nullable(),
|
|
44
44
|
/** Kilograms on hand, or null when stock is not tracked. */
|
|
45
45
|
stockKg: z.number().nullable(),
|
|
46
46
|
/** The plan may put it through the drip. */
|
|
47
|
-
|
|
47
|
+
fertigationSafe: z.boolean(),
|
|
48
48
|
});
|
|
49
49
|
export const farmFertilizerListSchema = z.object({ items: z.array(farmFertilizerSchema) });
|
|
50
|
-
|
|
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({
|
|
51
57
|
name: z.string().trim().min(1).max(200),
|
|
52
58
|
brand: z.string().trim().max(100).nullable().optional(),
|
|
53
59
|
nitrogen: percent,
|
|
@@ -58,67 +64,86 @@ export const createFarmFertilizerBodySchema = z.object({
|
|
|
58
64
|
sulfate: z.boolean().default(false),
|
|
59
65
|
micronutrients: z.record(z.string(), z.number().min(0).max(100)).nullable().optional(),
|
|
60
66
|
form: fertilizerFormSchema.default('soluble'),
|
|
61
|
-
|
|
62
|
-
|
|
67
|
+
applicationMethods: z.array(applicationMethodSchema).min(1),
|
|
68
|
+
labelDirections: z.string().max(1000).nullable().optional(),
|
|
63
69
|
bagSizeKg: z.number().positive().max(1000).nullable().optional(),
|
|
64
70
|
catalogueProductId: z.string().max(60).nullable().optional(),
|
|
65
71
|
/** Kilograms on hand now (bags times bag size). Omit to leave stock untracked. */
|
|
66
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'],
|
|
67
77
|
});
|
|
68
78
|
export const updateFarmFertilizerBodySchema = z.object({
|
|
69
79
|
name: z.string().trim().min(1).max(200).optional(),
|
|
70
|
-
|
|
80
|
+
applicationMethods: z.array(applicationMethodSchema).min(1).optional(),
|
|
71
81
|
bagSizeKg: z.number().positive().max(1000).nullable().optional(),
|
|
72
82
|
stockKg: z.number().min(0).max(1_000_000).optional(),
|
|
73
83
|
});
|
|
74
|
-
const
|
|
84
|
+
const guidanceSchema = z.object({
|
|
75
85
|
why: z.string(),
|
|
76
86
|
when: z.string(),
|
|
77
87
|
how: z.array(z.string()),
|
|
78
88
|
warning: z.string().nullable(),
|
|
79
89
|
});
|
|
80
|
-
|
|
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({
|
|
81
95
|
id: z.string(),
|
|
82
96
|
name: z.string(),
|
|
83
97
|
brand: z.string().nullable(),
|
|
84
98
|
role: z.string().nullable(),
|
|
85
99
|
tank: z.enum(['A', 'B']).nullable(),
|
|
86
|
-
/** on-farm: confirmed and counted.
|
|
87
|
-
|
|
88
|
-
|
|
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(),
|
|
89
103
|
fieldKgPerFeed: z.number().nullable(),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/** Kilograms
|
|
93
|
-
|
|
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(),
|
|
94
112
|
stockKg: z.number().nullable(),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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(),
|
|
98
118
|
bagSizeKg: z.number().nullable(),
|
|
99
119
|
/** Anything else the bag supplies, e.g. "Boron 0.3%". */
|
|
100
|
-
|
|
120
|
+
additionalNutrients: z.string().nullable(),
|
|
101
121
|
/** The label's own words on use and rate. */
|
|
102
|
-
|
|
122
|
+
labelDirections: z.string().nullable(),
|
|
123
|
+
guidance: guidanceSchema,
|
|
103
124
|
});
|
|
104
|
-
export const
|
|
125
|
+
export const uncoveredRoleSchema = z.object({
|
|
105
126
|
role: z.string(),
|
|
106
|
-
|
|
107
|
-
|
|
127
|
+
message: z.string(),
|
|
128
|
+
suggestedProduct: z.string().nullable(),
|
|
108
129
|
});
|
|
109
|
-
export const
|
|
130
|
+
export const fertilizerRequirementsResponseSchema = z.object({
|
|
110
131
|
fieldId: z.string(),
|
|
111
132
|
status: z.enum(['ok', 'no-plan']),
|
|
112
133
|
message: z.string().nullable(),
|
|
113
134
|
stage: z.object({ id: z.string(), label: z.string() }).nullable(),
|
|
114
135
|
fertilizerSet: z.object({ id: z.string(), name: z.string() }).nullable(),
|
|
115
136
|
/** True when the plan is built from the fertilizers this farm confirmed. */
|
|
116
|
-
|
|
137
|
+
usesFarmFertilizers: z.boolean(),
|
|
117
138
|
plantCount: z.number().nullable(),
|
|
118
|
-
|
|
119
|
-
drip
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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),
|
|
123
148
|
warnings: z.array(z.string()),
|
|
124
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"]>;
|