@deepintel-ltd/farmpro-contracts 1.2.1 → 1.3.1

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":"field-observations.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/field-observations.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AAGH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiId,CAAC;AAG3B,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8B5C,CAAC;AAGH,eAAO,MAAM,uCAAuC;;;;;;;;;;;;EAIlD,CAAC;AAGH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EACkB,CAAC;AAG7D,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;EASrC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;EAGtC,CAAC;AAGH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,iCAAiC,CACzC,CAAC;AACF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CACrD,OAAO,uCAAuC,CAC/C,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAChD,OAAO,kCAAkC,CAC1C,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAC9E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.observationStatsQuerySchema = exports.observationListQuerySchema = exports.observationListResponseSchema = exports.observationResponseSchema = exports.updateObservationActionInputSchema = exports.createObservationInputSchema = exports.observationResourceSchema = exports.updateObservationActionAttributesSchema = exports.createObservationAttributesSchema = exports.observationAttributesSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const common_schemas_1 = require("./common.schemas");
6
+ /**
7
+ * Field Observation schemas - JSON:API compliant
8
+ */
9
+ // Observation attributes schema
10
+ exports.observationAttributesSchema = zod_1.z.object({
11
+ fieldId: zod_1.z.string().uuid().nullable(),
12
+ farmId: zod_1.z.string().uuid(),
13
+ uploadedBy: zod_1.z.string().uuid(),
14
+ photoUrl: zod_1.z.string().url(),
15
+ photoThumbnail: zod_1.z.string().url().nullable(),
16
+ location: zod_1.z
17
+ .object({
18
+ lat: zod_1.z.number().min(-90).max(90),
19
+ lng: zod_1.z.number().min(-180).max(180),
20
+ accuracy: zod_1.z.number().positive().optional(),
21
+ })
22
+ .nullable(),
23
+ capturedAt: zod_1.z.date(),
24
+ observationType: zod_1.z.enum([
25
+ 'disease',
26
+ 'pest',
27
+ 'nutrient',
28
+ 'weed',
29
+ 'general',
30
+ 'health_check',
31
+ ]),
32
+ userNotes: zod_1.z.string().nullable(),
33
+ cropStageAtTime: zod_1.z
34
+ .enum([
35
+ 'planted',
36
+ 'germination',
37
+ 'vegetative',
38
+ 'flowering',
39
+ 'fruiting',
40
+ 'mature',
41
+ 'harvested',
42
+ ])
43
+ .nullable(),
44
+ analysisStatus: zod_1.z.enum(['pending', 'processing', 'completed', 'failed']),
45
+ analysisCompletedAt: zod_1.z.date().nullable(),
46
+ identifiedCrop: zod_1.z.string().nullable(),
47
+ identifiedCropConfidence: zod_1.z.number().min(0).max(1).nullable(),
48
+ diagnosisType: zod_1.z.string().nullable(),
49
+ diagnosisConfidence: zod_1.z.number().min(0).max(1).nullable(),
50
+ severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']).nullable(),
51
+ affectedArea: zod_1.z
52
+ .enum(['localized', 'widespread', 'entire_field'])
53
+ .nullable(),
54
+ healthScore: zod_1.z.number().min(0).max(100).nullable(),
55
+ analysisDetails: zod_1.z
56
+ .object({
57
+ plantIdentification: zod_1.z
58
+ .object({
59
+ scientificName: zod_1.z.string(),
60
+ commonNames: zod_1.z.array(zod_1.z.string()),
61
+ confidence: zod_1.z.number(),
62
+ provider: zod_1.z.string(),
63
+ })
64
+ .optional(),
65
+ primaryIssue: zod_1.z
66
+ .object({
67
+ name: zod_1.z.string(),
68
+ category: zod_1.z.string(),
69
+ confidence: zod_1.z.number(),
70
+ provider: zod_1.z.string(),
71
+ visualIndicators: zod_1.z.array(zod_1.z.string()),
72
+ })
73
+ .optional(),
74
+ secondaryIssues: zod_1.z
75
+ .array(zod_1.z.object({
76
+ name: zod_1.z.string(),
77
+ confidence: zod_1.z.number(),
78
+ reasoning: zod_1.z.string(),
79
+ }))
80
+ .optional(),
81
+ environmentalFactors: zod_1.z.record(zod_1.z.string()).optional(),
82
+ satelliteCorrelation: zod_1.z.record(zod_1.z.any()).optional(),
83
+ historicalMatches: zod_1.z.array(zod_1.z.any()).optional(),
84
+ })
85
+ .nullable(),
86
+ recommendations: zod_1.z
87
+ .array(zod_1.z.object({
88
+ priority: zod_1.z.number(),
89
+ action: zod_1.z.string(),
90
+ details: zod_1.z.string(),
91
+ timing: zod_1.z.string(),
92
+ materials: zod_1.z
93
+ .array(zod_1.z.object({
94
+ inventoryItemId: zod_1.z.string().uuid().optional(),
95
+ name: zod_1.z.string(),
96
+ quantity: zod_1.z.number(),
97
+ unit: zod_1.z.string(),
98
+ costPerUnit: zod_1.z.number().optional(),
99
+ totalCost: zod_1.z.number().optional(),
100
+ availability: zod_1.z.string().optional(),
101
+ }))
102
+ .optional(),
103
+ applicationMethod: zod_1.z.string().optional(),
104
+ expectedOutcome: zod_1.z.string().optional(),
105
+ preventiveMeasures: zod_1.z.array(zod_1.z.string()).optional(),
106
+ estimatedTime: zod_1.z.string().optional(),
107
+ riskLevel: zod_1.z.string().optional(),
108
+ }))
109
+ .nullable(),
110
+ estimatedCost: zod_1.z.number().nullable(),
111
+ urgencyScore: zod_1.z.number().min(1).max(10).nullable(),
112
+ similarCasesCount: zod_1.z.number().nullable(),
113
+ actionStatus: zod_1.z.enum(['pending', 'in_progress', 'completed', 'dismissed']),
114
+ actionTakenAt: zod_1.z.date().nullable(),
115
+ actionNotes: zod_1.z.string().nullable(),
116
+ generatedAlertId: zod_1.z.string().uuid().nullable(),
117
+ relatedTaskId: zod_1.z.string().uuid().nullable(),
118
+ analysisProvider: zod_1.z.string().nullable(),
119
+ processingTime: zod_1.z.number().nullable(),
120
+ modelVersion: zod_1.z.string().nullable(),
121
+ phase: zod_1.z.string().nullable(),
122
+ }).merge(common_schemas_1.timestampsSchema);
123
+ // Observation attributes for creation (input)
124
+ exports.createObservationAttributesSchema = zod_1.z.object({
125
+ fieldId: zod_1.z.string().uuid().optional(),
126
+ observationType: zod_1.z.enum([
127
+ 'disease',
128
+ 'pest',
129
+ 'nutrient',
130
+ 'weed',
131
+ 'general',
132
+ 'health_check',
133
+ ]),
134
+ userNotes: zod_1.z.string().max(1000).optional(),
135
+ cropStageAtTime: zod_1.z
136
+ .enum([
137
+ 'planted',
138
+ 'germination',
139
+ 'vegetative',
140
+ 'flowering',
141
+ 'fruiting',
142
+ 'mature',
143
+ 'harvested',
144
+ ])
145
+ .optional(),
146
+ location: zod_1.z
147
+ .object({
148
+ lat: zod_1.z.number().min(-90).max(90),
149
+ lng: zod_1.z.number().min(-180).max(180),
150
+ accuracy: zod_1.z.number().positive().optional(),
151
+ })
152
+ .optional(),
153
+ capturedAt: zod_1.z.string().datetime().optional(),
154
+ });
155
+ // Observation attributes for update (input)
156
+ exports.updateObservationActionAttributesSchema = zod_1.z.object({
157
+ actionStatus: zod_1.z.enum(['in_progress', 'completed', 'dismissed']),
158
+ actionNotes: zod_1.z.string().max(2000).optional(),
159
+ relatedTaskId: zod_1.z.string().uuid().optional(),
160
+ });
161
+ // JSON:API resource schemas
162
+ exports.observationResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('observations', exports.observationAttributesSchema);
163
+ exports.createObservationInputSchema = (0, common_schemas_1.createJsonApiResourceSchema)('observations', exports.createObservationAttributesSchema);
164
+ exports.updateObservationActionInputSchema = (0, common_schemas_1.createJsonApiResourceSchema)('observations', exports.updateObservationActionAttributesSchema);
165
+ // Response schemas
166
+ exports.observationResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.observationResourceSchema);
167
+ exports.observationListResponseSchema = (0, common_schemas_1.jsonApiCollectionResponseSchema)(exports.observationResourceSchema);
168
+ // Query schemas
169
+ exports.observationListQuerySchema = zod_1.z.object({
170
+ fieldId: zod_1.z.string().uuid().optional(),
171
+ status: zod_1.z.enum(['pending', 'processing', 'completed', 'failed']).optional(),
172
+ observationType: zod_1.z.string().optional(),
173
+ severity: zod_1.z.enum(['low', 'medium', 'high', 'critical']).optional(),
174
+ startDate: zod_1.z.string().datetime().optional(),
175
+ endDate: zod_1.z.string().datetime().optional(),
176
+ page: zod_1.z.string().default('1'),
177
+ pageSize: zod_1.z.string().default('20'),
178
+ });
179
+ exports.observationStatsQuerySchema = zod_1.z.object({
180
+ startDate: zod_1.z.string().datetime().optional(),
181
+ endDate: zod_1.z.string().datetime().optional(),
182
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepintel-ltd/farmpro-contracts",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "Type-safe API contracts for FarmPro API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",