@deepintel-ltd/farmpro-contracts 1.36.7 → 1.36.9

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,66 @@
1
+ import { initContract } from '@ts-rest/core';
2
+ import { z } from 'zod';
3
+ import { harvestHoldResponseSchema, pillarAdjustmentsResponseSchema, pillarSchema, resolvedPillarSchema, } from '../schemas/care-pillar.schemas';
4
+ const c = initContract();
5
+ const ymd = z.string().regex(/^\d{4}-\d{2}-\d{2}/);
6
+ export const carePillarRouter = c.router({
7
+ /**
8
+ * One pillar's plan (pest management, water, weeds or pruning) for a crop and planting clock. Follows the
9
+ * crop-care stage, so every pillar agrees on the day. File bank only; does not call a model.
10
+ */
11
+ resolve: {
12
+ method: 'GET',
13
+ path: '/care-pillars/:pillar/plans/:cropId',
14
+ pathParams: z.object({
15
+ pillar: pillarSchema,
16
+ cropId: z.string().min(1).max(120),
17
+ }),
18
+ query: z.object({
19
+ plantingDate: ymd.optional(),
20
+ transplantedAt: ymd.optional(),
21
+ cropStage: z.string().max(40).optional(),
22
+ /** Client calendar date, so the stage matches the farmer's day rather than the server's. */
23
+ today: ymd.optional(),
24
+ }),
25
+ responses: {
26
+ 200: resolvedPillarSchema,
27
+ 404: z.object({ message: z.string() }),
28
+ },
29
+ summary: 'Resolve a care-pillar plan for a crop and planting clock',
30
+ },
31
+ /**
32
+ * Field-level adjustments (weather, satellite anomalies, PHI holds) for a pillar.
33
+ */
34
+ adjustments: {
35
+ method: 'GET',
36
+ path: '/farms/:farmId/fields/:fieldId/care-pillars/:pillar/adjustments',
37
+ pathParams: z.object({
38
+ farmId: z.string().uuid(),
39
+ fieldId: z.string().uuid(),
40
+ pillar: pillarSchema,
41
+ }),
42
+ responses: {
43
+ 200: pillarAdjustmentsResponseSchema,
44
+ 404: z.object({ message: z.string() }),
45
+ },
46
+ summary: 'Weather, satellite and PHI adjustments for a care pillar on a specific field',
47
+ },
48
+ /**
49
+ * Whether a harvest on `date` (default today) must wait for a spray's waiting period. The apps call it before a
50
+ * harvest is saved and ask the farmer to confirm when it says hold or unknown.
51
+ */
52
+ harvestHold: {
53
+ method: 'GET',
54
+ path: '/farms/:farmId/fields/:fieldId/harvest-hold',
55
+ pathParams: z.object({
56
+ farmId: z.string().uuid(),
57
+ fieldId: z.string().uuid(),
58
+ }),
59
+ query: z.object({ date: ymd.optional() }),
60
+ responses: {
61
+ 200: harvestHoldResponseSchema,
62
+ 404: z.object({ message: z.string() }),
63
+ },
64
+ summary: 'Waiting-period check for a harvest on a given day',
65
+ },
66
+ });