@deepintel-ltd/farmpro-contracts 1.7.5 → 1.7.8

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 (31) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +2 -0
  4. package/dist/routes/geofences.routes.d.ts +1913 -0
  5. package/dist/routes/geofences.routes.d.ts.map +1 -0
  6. package/dist/routes/geofences.routes.js +105 -0
  7. package/dist/routes/index.d.ts +12 -0
  8. package/dist/routes/index.d.ts.map +1 -1
  9. package/dist/routes/index.js +8 -0
  10. package/dist/routes/livestock-groups.routes.d.ts +8343 -0
  11. package/dist/routes/livestock-groups.routes.d.ts.map +1 -0
  12. package/dist/routes/livestock-groups.routes.js +287 -0
  13. package/dist/routes/livestock-map.routes.d.ts +1319 -0
  14. package/dist/routes/livestock-map.routes.d.ts.map +1 -0
  15. package/dist/routes/livestock-map.routes.js +83 -0
  16. package/dist/routes/prescription-maps.routes.d.ts +1521 -0
  17. package/dist/routes/prescription-maps.routes.d.ts.map +1 -0
  18. package/dist/routes/prescription-maps.routes.js +69 -0
  19. package/dist/schemas/geofences.schemas.d.ts +358 -0
  20. package/dist/schemas/geofences.schemas.d.ts.map +1 -0
  21. package/dist/schemas/geofences.schemas.js +44 -0
  22. package/dist/schemas/livestock-groups.schemas.d.ts +2637 -0
  23. package/dist/schemas/livestock-groups.schemas.d.ts.map +1 -0
  24. package/dist/schemas/livestock-groups.schemas.js +297 -0
  25. package/dist/schemas/livestock-map.schemas.d.ts +328 -0
  26. package/dist/schemas/livestock-map.schemas.d.ts.map +1 -0
  27. package/dist/schemas/livestock-map.schemas.js +52 -0
  28. package/dist/schemas/prescription-maps.schemas.d.ts +615 -0
  29. package/dist/schemas/prescription-maps.schemas.d.ts.map +1 -0
  30. package/dist/schemas/prescription-maps.schemas.js +39 -0
  31. package/package.json +1 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liv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,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC3E,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC"}
@@ -0,0 +1,297 @@
1
+ import { z } from 'zod';
2
+ import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema, } from './common.schemas';
3
+ import { livestockCategorySchema } from './livestock.schemas';
4
+ /**
5
+ * Livestock Groups & Batch Records schemas - JSON:API compliant
6
+ *
7
+ * Supports dual-mode tracking:
8
+ * - INDIVIDUAL: Each animal tracked separately (cattle, goats, sheep, pigs)
9
+ * - BATCH: Count-based tracking (poultry flocks, fish ponds)
10
+ * - HYBRID: Mix of individual and batch tracking
11
+ */
12
+ // Group type enum
13
+ export const livestockGroupTypeSchema = z.enum([
14
+ 'BREEDING_HERD',
15
+ 'FINISHING_HERD',
16
+ 'LAYER_FLOCK',
17
+ 'BROILER_BATCH',
18
+ 'POND',
19
+ 'CAGE',
20
+ 'PEN',
21
+ 'PASTURE',
22
+ 'CUSTOM',
23
+ ]);
24
+ // Tracking mode enum
25
+ export const trackingModeSchema = z.enum([
26
+ 'INDIVIDUAL',
27
+ 'BATCH',
28
+ 'HYBRID',
29
+ ]);
30
+ // Group status enum
31
+ export const groupStatusSchema = z.enum([
32
+ 'ACTIVE',
33
+ 'SOLD',
34
+ 'DEPLETED',
35
+ 'TRANSFERRED',
36
+ 'ARCHIVED',
37
+ ]);
38
+ // Batch record type enum
39
+ export const batchRecordTypeSchema = z.enum([
40
+ 'STOCKING',
41
+ 'MORTALITY',
42
+ 'CULLING',
43
+ 'VACCINATION',
44
+ 'TREATMENT',
45
+ 'FEEDING',
46
+ 'WEIGHT_SAMPLE',
47
+ 'EGG_COLLECTION',
48
+ 'HARVEST',
49
+ 'WATER_QUALITY',
50
+ 'OTHER',
51
+ ]);
52
+ // Livestock group attributes schema
53
+ export const livestockGroupAttributesSchema = z
54
+ .object({
55
+ farmId: z.string().uuid(),
56
+ name: z.string(),
57
+ groupCode: z.string(),
58
+ category: livestockCategorySchema,
59
+ groupType: livestockGroupTypeSchema,
60
+ trackingMode: trackingModeSchema,
61
+ initialCount: z.number().int().nonnegative().nullable(),
62
+ currentCount: z.number().int().nonnegative().nullable(),
63
+ breed: z.string().nullable(),
64
+ location: z.string().nullable(),
65
+ description: z.string().nullable(),
66
+ acquisitionDate: z.string().datetime().nullable(),
67
+ purchasePrice: z.number().nonnegative().nullable(),
68
+ currentValue: z.number().nonnegative().nullable(),
69
+ currency: z.string().default('NGN'),
70
+ // Performance metrics
71
+ averageWeight: z.number().positive().nullable(),
72
+ targetWeight: z.number().positive().nullable(),
73
+ feedConversionRatio: z.number().positive().nullable(),
74
+ mortalityRate: z.number().min(0).max(100).nullable(),
75
+ averageDailyGain: z.number().positive().nullable(),
76
+ // Poultry-specific
77
+ eggProductionRate: z.number().min(0).max(100).nullable(),
78
+ // Fish-specific
79
+ pondSize: z.number().positive().nullable(),
80
+ stockingDensity: z.number().positive().nullable(),
81
+ // Status
82
+ status: groupStatusSchema,
83
+ notes: z.string().nullable(),
84
+ // Computed fields (from relations)
85
+ memberCount: z.number().int().nonnegative().optional(),
86
+ batchRecordCount: z.number().int().nonnegative().optional(),
87
+ })
88
+ .merge(timestampsSchema);
89
+ // Create group attributes (input)
90
+ export const createLivestockGroupAttributesSchema = z.object({
91
+ name: z.string().min(1).max(200),
92
+ groupCode: z.string().min(1).max(50).optional(), // Auto-generated if not provided
93
+ category: livestockCategorySchema,
94
+ groupType: livestockGroupTypeSchema,
95
+ trackingMode: trackingModeSchema.default('INDIVIDUAL'),
96
+ initialCount: z.number().int().nonnegative().optional(),
97
+ currentCount: z.number().int().nonnegative().optional(),
98
+ breed: z.string().max(100).optional(),
99
+ location: z.string().max(200).optional(),
100
+ description: z.string().optional(),
101
+ acquisitionDate: z.string().datetime().optional(),
102
+ purchasePrice: z.number().nonnegative().optional(),
103
+ currentValue: z.number().nonnegative().optional(),
104
+ currency: z.string().max(3).default('NGN'),
105
+ averageWeight: z.number().positive().optional(),
106
+ targetWeight: z.number().positive().optional(),
107
+ feedConversionRatio: z.number().positive().optional(),
108
+ mortalityRate: z.number().min(0).max(100).optional(),
109
+ averageDailyGain: z.number().positive().optional(),
110
+ eggProductionRate: z.number().min(0).max(100).optional(),
111
+ pondSize: z.number().positive().optional(),
112
+ stockingDensity: z.number().positive().optional(),
113
+ status: groupStatusSchema.default('ACTIVE'),
114
+ notes: z.string().optional(),
115
+ });
116
+ // Update group attributes (input)
117
+ export const updateLivestockGroupAttributesSchema = z.object({
118
+ name: z.string().min(1).max(200).optional(),
119
+ groupCode: z.string().min(1).max(50).optional(),
120
+ category: livestockCategorySchema.optional(),
121
+ groupType: livestockGroupTypeSchema.optional(),
122
+ trackingMode: trackingModeSchema.optional(),
123
+ initialCount: z.number().int().nonnegative().nullable().optional(),
124
+ currentCount: z.number().int().nonnegative().nullable().optional(),
125
+ breed: z.string().max(100).nullable().optional(),
126
+ location: z.string().max(200).nullable().optional(),
127
+ description: z.string().nullable().optional(),
128
+ acquisitionDate: z.string().datetime().nullable().optional(),
129
+ purchasePrice: z.number().nonnegative().nullable().optional(),
130
+ currentValue: z.number().nonnegative().nullable().optional(),
131
+ currency: z.string().max(3).optional(),
132
+ averageWeight: z.number().positive().nullable().optional(),
133
+ targetWeight: z.number().positive().nullable().optional(),
134
+ feedConversionRatio: z.number().positive().nullable().optional(),
135
+ mortalityRate: z.number().min(0).max(100).nullable().optional(),
136
+ averageDailyGain: z.number().positive().nullable().optional(),
137
+ eggProductionRate: z.number().min(0).max(100).nullable().optional(),
138
+ pondSize: z.number().positive().nullable().optional(),
139
+ stockingDensity: z.number().positive().nullable().optional(),
140
+ status: groupStatusSchema.optional(),
141
+ notes: z.string().nullable().optional(),
142
+ });
143
+ // Batch record attributes schema
144
+ export const batchRecordAttributesSchema = z
145
+ .object({
146
+ id: z.string().uuid(),
147
+ groupId: z.string().uuid(),
148
+ recordDate: z.string().datetime(),
149
+ recordType: batchRecordTypeSchema,
150
+ countChange: z.number().int().nullable(),
151
+ affectedCount: z.number().int().nonnegative().nullable(),
152
+ sampleWeight: z.number().positive().nullable(),
153
+ sampleCount: z.number().int().positive().nullable(),
154
+ eggCount: z.number().int().nonnegative().nullable(),
155
+ brokenEggs: z.number().int().nonnegative().nullable(),
156
+ feedType: z.string().nullable(),
157
+ feedQuantity: z.number().positive().nullable(),
158
+ feedUnit: z.string().nullable(),
159
+ medication: z.string().nullable(),
160
+ vaccineName: z.string().nullable(),
161
+ dosage: z.string().nullable(),
162
+ cost: z.number().nonnegative().nullable(),
163
+ transactionValue: z.number().nonnegative().nullable(),
164
+ currency: z.string().default('NGN'),
165
+ description: z.string().nullable(),
166
+ notes: z.string().nullable(),
167
+ administeredBy: z.string().nullable(),
168
+ })
169
+ .merge(timestampsSchema);
170
+ // Create batch record attributes (input)
171
+ export const createBatchRecordAttributesSchema = z.object({
172
+ recordDate: z.string().datetime(),
173
+ recordType: batchRecordTypeSchema,
174
+ countChange: z.number().int().optional(),
175
+ affectedCount: z.number().int().nonnegative().optional(),
176
+ sampleWeight: z.number().positive().optional(),
177
+ sampleCount: z.number().int().positive().optional(),
178
+ eggCount: z.number().int().nonnegative().optional(),
179
+ brokenEggs: z.number().int().nonnegative().optional(),
180
+ feedType: z.string().max(100).optional(),
181
+ feedQuantity: z.number().positive().optional(),
182
+ feedUnit: z.string().max(10).default('kg'),
183
+ medication: z.string().max(200).optional(),
184
+ vaccineName: z.string().max(200).optional(),
185
+ dosage: z.string().max(100).optional(),
186
+ cost: z.number().nonnegative().optional(),
187
+ transactionValue: z.number().nonnegative().optional(),
188
+ currency: z.string().max(3).default('NGN'),
189
+ description: z.string().optional(),
190
+ notes: z.string().optional(),
191
+ administeredBy: z.string().max(200).optional(),
192
+ });
193
+ // JSON:API input wrappers
194
+ export const createLivestockGroupSchema = z.object({
195
+ type: z.literal('livestock-groups'),
196
+ attributes: createLivestockGroupAttributesSchema,
197
+ });
198
+ export const updateLivestockGroupSchema = z.object({
199
+ type: z.literal('livestock-groups'),
200
+ id: z.string().uuid(),
201
+ attributes: updateLivestockGroupAttributesSchema,
202
+ });
203
+ export const createBatchRecordSchema = z.object({
204
+ type: z.literal('batch-records'),
205
+ attributes: createBatchRecordAttributesSchema,
206
+ });
207
+ // JSON:API resource schemas
208
+ export const livestockGroupResourceSchema = createJsonApiResourceSchema('livestock-groups', livestockGroupAttributesSchema);
209
+ export const batchRecordResourceSchema = createJsonApiResourceSchema('batch-records', batchRecordAttributesSchema);
210
+ // JSON:API response schemas
211
+ export const livestockGroupResponseSchema = jsonApiSingleResponseSchema(livestockGroupResourceSchema);
212
+ export const livestockGroupListResponseSchema = jsonApiCollectionResponseSchema(livestockGroupResourceSchema);
213
+ export const batchRecordResponseSchema = jsonApiSingleResponseSchema(batchRecordResourceSchema);
214
+ export const batchRecordListResponseSchema = jsonApiCollectionResponseSchema(batchRecordResourceSchema);
215
+ // Group statistics schema
216
+ export const groupStatsSchema = z.object({
217
+ totalGroups: z.number().int().nonnegative(),
218
+ totalAnimals: z.number().int().nonnegative(),
219
+ byCategory: z.record(livestockCategorySchema, z.number().int().nonnegative()),
220
+ byGroupType: z.record(livestockGroupTypeSchema, z.number().int().nonnegative()),
221
+ byTrackingMode: z.record(trackingModeSchema, z.number().int().nonnegative()),
222
+ byStatus: z.record(groupStatusSchema, z.number().int().nonnegative()),
223
+ totalValue: z.number().nonnegative(),
224
+ currency: z.string(),
225
+ // Aggregated performance
226
+ averageFCR: z.number().positive().nullable(),
227
+ averageMortalityRate: z.number().min(0).max(100).nullable(),
228
+ totalEggProduction: z.number().int().nonnegative().nullable(),
229
+ });
230
+ export const groupStatsResponseSchema = z.object({
231
+ data: groupStatsSchema,
232
+ meta: z.record(z.unknown()).optional(),
233
+ });
234
+ // Bulk operations schemas
235
+ export const bulkAddMembersSchema = z.object({
236
+ livestockIds: z.array(z.string().uuid()).min(1).max(500),
237
+ });
238
+ export const bulkRemoveMembersSchema = z.object({
239
+ livestockIds: z.array(z.string().uuid()).min(1).max(500),
240
+ });
241
+ export const bulkCreateLivestockSchema = z.object({
242
+ type: z.literal('livestock-bulk'),
243
+ attributes: z.object({
244
+ groupId: z.string().uuid().optional(),
245
+ category: livestockCategorySchema,
246
+ breed: z.string().max(100).optional(),
247
+ sex: z.enum(['MALE', 'FEMALE', 'UNKNOWN']).default('UNKNOWN'),
248
+ location: z.string().max(200).optional(),
249
+ acquisitionDate: z.string().datetime().optional(),
250
+ acquisitionType: z.enum(['born', 'purchased', 'transferred', 'gifted']).default('purchased'),
251
+ purchasePrice: z.number().nonnegative().optional(),
252
+ currency: z.string().max(3).default('NGN'),
253
+ // Either provide count for auto-generated tags, or provide explicit tags
254
+ count: z.number().int().positive().max(1000).optional(),
255
+ tagPrefix: z.string().max(50).optional(),
256
+ // Or provide explicit entries
257
+ entries: z.array(z.object({
258
+ tagId: z.string().min(1).max(100),
259
+ name: z.string().max(200).optional(),
260
+ weight: z.number().positive().optional(),
261
+ dateOfBirth: z.string().datetime().optional(),
262
+ sex: z.enum(['MALE', 'FEMALE', 'UNKNOWN']).optional(),
263
+ })).max(500).optional(),
264
+ }),
265
+ });
266
+ export const bulkHealthRecordSchema = z.object({
267
+ type: z.literal('bulk-health-records'),
268
+ attributes: z.object({
269
+ groupId: z.string().uuid().optional(),
270
+ livestockIds: z.array(z.string().uuid()).max(500).optional(),
271
+ recordDate: z.string().datetime(),
272
+ recordType: z.enum(['vaccination', 'treatment', 'checkup', 'deworming', 'surgery', 'other']),
273
+ description: z.string().min(1),
274
+ medication: z.string().max(200).optional(),
275
+ dosage: z.string().max(100).optional(),
276
+ vaccineName: z.string().max(200).optional(),
277
+ batchNumber: z.string().max(100).optional(),
278
+ nextDueDate: z.string().datetime().optional(),
279
+ cost: z.number().nonnegative().optional(),
280
+ currency: z.string().max(3).default('NGN'),
281
+ administeredBy: z.string().max(200).optional(),
282
+ notes: z.string().optional(),
283
+ }),
284
+ });
285
+ export const bulkOperationResponseSchema = z.object({
286
+ data: z.object({
287
+ processed: z.number().int().nonnegative(),
288
+ succeeded: z.number().int().nonnegative(),
289
+ failed: z.number().int().nonnegative(),
290
+ errors: z.array(z.object({
291
+ index: z.number().int().nonnegative().optional(),
292
+ id: z.string().optional(),
293
+ message: z.string(),
294
+ })).optional(),
295
+ }),
296
+ meta: z.record(z.unknown()).optional(),
297
+ });
@@ -0,0 +1,328 @@
1
+ import { z } from 'zod';
2
+ export declare const livestockLocationSchema: z.ZodObject<{
3
+ id: z.ZodString;
4
+ livestockId: z.ZodOptional<z.ZodString>;
5
+ groupId: z.ZodOptional<z.ZodString>;
6
+ coordinates: z.ZodObject<{
7
+ lat: z.ZodNumber;
8
+ lng: z.ZodNumber;
9
+ accuracy: z.ZodOptional<z.ZodNumber>;
10
+ }, "strip", z.ZodTypeAny, {
11
+ lat: number;
12
+ lng: number;
13
+ accuracy?: number | undefined;
14
+ }, {
15
+ lat: number;
16
+ lng: number;
17
+ accuracy?: number | undefined;
18
+ }>;
19
+ timestamp: z.ZodString;
20
+ source: z.ZodEnum<["gps_collar", "manual", "rfid_reader", "app"]>;
21
+ batteryLevel: z.ZodOptional<z.ZodNumber>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ coordinates: {
24
+ lat: number;
25
+ lng: number;
26
+ accuracy?: number | undefined;
27
+ };
28
+ id: string;
29
+ source: "manual" | "gps_collar" | "rfid_reader" | "app";
30
+ timestamp: string;
31
+ batteryLevel?: number | undefined;
32
+ groupId?: string | undefined;
33
+ livestockId?: string | undefined;
34
+ }, {
35
+ coordinates: {
36
+ lat: number;
37
+ lng: number;
38
+ accuracy?: number | undefined;
39
+ };
40
+ id: string;
41
+ source: "manual" | "gps_collar" | "rfid_reader" | "app";
42
+ timestamp: string;
43
+ batteryLevel?: number | undefined;
44
+ groupId?: string | undefined;
45
+ livestockId?: string | undefined;
46
+ }>;
47
+ export declare const movementTrailPointSchema: z.ZodObject<{
48
+ lat: z.ZodNumber;
49
+ lng: z.ZodNumber;
50
+ timestamp: z.ZodString;
51
+ }, "strip", z.ZodTypeAny, {
52
+ timestamp: string;
53
+ lat: number;
54
+ lng: number;
55
+ }, {
56
+ timestamp: string;
57
+ lat: number;
58
+ lng: number;
59
+ }>;
60
+ export declare const livestockMovementTrailSchema: z.ZodObject<{
61
+ livestockId: z.ZodString;
62
+ points: z.ZodArray<z.ZodObject<{
63
+ lat: z.ZodNumber;
64
+ lng: z.ZodNumber;
65
+ timestamp: z.ZodString;
66
+ }, "strip", z.ZodTypeAny, {
67
+ timestamp: string;
68
+ lat: number;
69
+ lng: number;
70
+ }, {
71
+ timestamp: string;
72
+ lat: number;
73
+ lng: number;
74
+ }>, "many">;
75
+ dateRange: z.ZodObject<{
76
+ start: z.ZodString;
77
+ end: z.ZodString;
78
+ }, "strip", z.ZodTypeAny, {
79
+ start: string;
80
+ end: string;
81
+ }, {
82
+ start: string;
83
+ end: string;
84
+ }>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ dateRange: {
87
+ start: string;
88
+ end: string;
89
+ };
90
+ livestockId: string;
91
+ points: {
92
+ timestamp: string;
93
+ lat: number;
94
+ lng: number;
95
+ }[];
96
+ }, {
97
+ dateRange: {
98
+ start: string;
99
+ end: string;
100
+ };
101
+ livestockId: string;
102
+ points: {
103
+ timestamp: string;
104
+ lat: number;
105
+ lng: number;
106
+ }[];
107
+ }>;
108
+ export declare const heatmapPointSchema: z.ZodObject<{
109
+ lat: z.ZodNumber;
110
+ lng: z.ZodNumber;
111
+ intensity: z.ZodNumber;
112
+ }, "strip", z.ZodTypeAny, {
113
+ lat: number;
114
+ lng: number;
115
+ intensity: number;
116
+ }, {
117
+ lat: number;
118
+ lng: number;
119
+ intensity: number;
120
+ }>;
121
+ export declare const grazingZoneSchema: z.ZodObject<{
122
+ id: z.ZodString;
123
+ name: z.ZodString;
124
+ geometry: z.ZodObject<{
125
+ type: z.ZodEnum<["Polygon", "MultiPolygon", "Point", "LineString"]>;
126
+ coordinates: z.ZodUnion<[z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">, "many">, z.ZodArray<z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">, "many">, "many">, z.ZodArray<z.ZodNumber, "many">, z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">]>;
127
+ }, "strip", z.ZodTypeAny, {
128
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
129
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
130
+ }, {
131
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
132
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
133
+ }>;
134
+ type: z.ZodEnum<["paddock", "shelter", "water_source", "feeding_area"]>;
135
+ currentOccupancy: z.ZodOptional<z.ZodNumber>;
136
+ capacity: z.ZodOptional<z.ZodNumber>;
137
+ }, "strip", z.ZodTypeAny, {
138
+ type: "paddock" | "shelter" | "water_source" | "feeding_area";
139
+ id: string;
140
+ name: string;
141
+ geometry: {
142
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
143
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
144
+ };
145
+ currentOccupancy?: number | undefined;
146
+ capacity?: number | undefined;
147
+ }, {
148
+ type: "paddock" | "shelter" | "water_source" | "feeding_area";
149
+ id: string;
150
+ name: string;
151
+ geometry: {
152
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
153
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
154
+ };
155
+ currentOccupancy?: number | undefined;
156
+ capacity?: number | undefined;
157
+ }>;
158
+ export declare const updateLocationBodySchema: z.ZodObject<{
159
+ coordinates: z.ZodObject<{
160
+ lat: z.ZodNumber;
161
+ lng: z.ZodNumber;
162
+ }, "strip", z.ZodTypeAny, {
163
+ lat: number;
164
+ lng: number;
165
+ }, {
166
+ lat: number;
167
+ lng: number;
168
+ }>;
169
+ }, "strip", z.ZodTypeAny, {
170
+ coordinates: {
171
+ lat: number;
172
+ lng: number;
173
+ };
174
+ }, {
175
+ coordinates: {
176
+ lat: number;
177
+ lng: number;
178
+ };
179
+ }>;
180
+ export declare const livestockLocationListResponseSchema: z.ZodArray<z.ZodObject<{
181
+ id: z.ZodString;
182
+ livestockId: z.ZodOptional<z.ZodString>;
183
+ groupId: z.ZodOptional<z.ZodString>;
184
+ coordinates: z.ZodObject<{
185
+ lat: z.ZodNumber;
186
+ lng: z.ZodNumber;
187
+ accuracy: z.ZodOptional<z.ZodNumber>;
188
+ }, "strip", z.ZodTypeAny, {
189
+ lat: number;
190
+ lng: number;
191
+ accuracy?: number | undefined;
192
+ }, {
193
+ lat: number;
194
+ lng: number;
195
+ accuracy?: number | undefined;
196
+ }>;
197
+ timestamp: z.ZodString;
198
+ source: z.ZodEnum<["gps_collar", "manual", "rfid_reader", "app"]>;
199
+ batteryLevel: z.ZodOptional<z.ZodNumber>;
200
+ }, "strip", z.ZodTypeAny, {
201
+ coordinates: {
202
+ lat: number;
203
+ lng: number;
204
+ accuracy?: number | undefined;
205
+ };
206
+ id: string;
207
+ source: "manual" | "gps_collar" | "rfid_reader" | "app";
208
+ timestamp: string;
209
+ batteryLevel?: number | undefined;
210
+ groupId?: string | undefined;
211
+ livestockId?: string | undefined;
212
+ }, {
213
+ coordinates: {
214
+ lat: number;
215
+ lng: number;
216
+ accuracy?: number | undefined;
217
+ };
218
+ id: string;
219
+ source: "manual" | "gps_collar" | "rfid_reader" | "app";
220
+ timestamp: string;
221
+ batteryLevel?: number | undefined;
222
+ groupId?: string | undefined;
223
+ livestockId?: string | undefined;
224
+ }>, "many">;
225
+ export declare const movementTrailListResponseSchema: z.ZodArray<z.ZodObject<{
226
+ livestockId: z.ZodString;
227
+ points: z.ZodArray<z.ZodObject<{
228
+ lat: z.ZodNumber;
229
+ lng: z.ZodNumber;
230
+ timestamp: z.ZodString;
231
+ }, "strip", z.ZodTypeAny, {
232
+ timestamp: string;
233
+ lat: number;
234
+ lng: number;
235
+ }, {
236
+ timestamp: string;
237
+ lat: number;
238
+ lng: number;
239
+ }>, "many">;
240
+ dateRange: z.ZodObject<{
241
+ start: z.ZodString;
242
+ end: z.ZodString;
243
+ }, "strip", z.ZodTypeAny, {
244
+ start: string;
245
+ end: string;
246
+ }, {
247
+ start: string;
248
+ end: string;
249
+ }>;
250
+ }, "strip", z.ZodTypeAny, {
251
+ dateRange: {
252
+ start: string;
253
+ end: string;
254
+ };
255
+ livestockId: string;
256
+ points: {
257
+ timestamp: string;
258
+ lat: number;
259
+ lng: number;
260
+ }[];
261
+ }, {
262
+ dateRange: {
263
+ start: string;
264
+ end: string;
265
+ };
266
+ livestockId: string;
267
+ points: {
268
+ timestamp: string;
269
+ lat: number;
270
+ lng: number;
271
+ }[];
272
+ }>, "many">;
273
+ export declare const heatmapResponseSchema: z.ZodArray<z.ZodObject<{
274
+ lat: z.ZodNumber;
275
+ lng: z.ZodNumber;
276
+ intensity: z.ZodNumber;
277
+ }, "strip", z.ZodTypeAny, {
278
+ lat: number;
279
+ lng: number;
280
+ intensity: number;
281
+ }, {
282
+ lat: number;
283
+ lng: number;
284
+ intensity: number;
285
+ }>, "many">;
286
+ export declare const grazingZoneListResponseSchema: z.ZodArray<z.ZodObject<{
287
+ id: z.ZodString;
288
+ name: z.ZodString;
289
+ geometry: z.ZodObject<{
290
+ type: z.ZodEnum<["Polygon", "MultiPolygon", "Point", "LineString"]>;
291
+ coordinates: z.ZodUnion<[z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">, "many">, z.ZodArray<z.ZodArray<z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">, "many">, "many">, z.ZodArray<z.ZodNumber, "many">, z.ZodArray<z.ZodArray<z.ZodNumber, "many">, "many">]>;
292
+ }, "strip", z.ZodTypeAny, {
293
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
294
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
295
+ }, {
296
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
297
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
298
+ }>;
299
+ type: z.ZodEnum<["paddock", "shelter", "water_source", "feeding_area"]>;
300
+ currentOccupancy: z.ZodOptional<z.ZodNumber>;
301
+ capacity: z.ZodOptional<z.ZodNumber>;
302
+ }, "strip", z.ZodTypeAny, {
303
+ type: "paddock" | "shelter" | "water_source" | "feeding_area";
304
+ id: string;
305
+ name: string;
306
+ geometry: {
307
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
308
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
309
+ };
310
+ currentOccupancy?: number | undefined;
311
+ capacity?: number | undefined;
312
+ }, {
313
+ type: "paddock" | "shelter" | "water_source" | "feeding_area";
314
+ id: string;
315
+ name: string;
316
+ geometry: {
317
+ type: "Polygon" | "MultiPolygon" | "Point" | "LineString";
318
+ coordinates: number[] | number[][] | number[][][] | number[][][][];
319
+ };
320
+ currentOccupancy?: number | undefined;
321
+ capacity?: number | undefined;
322
+ }>, "many">;
323
+ export type LivestockLocationResponse = z.infer<typeof livestockLocationSchema>;
324
+ export type LivestockMovementTrailResponse = z.infer<typeof livestockMovementTrailSchema>;
325
+ export type HeatmapPointResponse = z.infer<typeof heatmapPointSchema>;
326
+ export type GrazingZoneResponse = z.infer<typeof grazingZoneSchema>;
327
+ export type UpdateLocationBody = z.infer<typeof updateLocationBodySchema>;
328
+ //# sourceMappingURL=livestock-map.schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"livestock-map.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/livestock-map.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYlC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;EAInC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAOvC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAI7B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO5B,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;EAKnC,CAAC;AAEH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAmC,CAAC;AACpF,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAAwC,CAAC;AACrF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;WAA8B,CAAC;AACjE,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAA6B,CAAC;AAExE,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAChF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAC1F,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AACpE,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { z } from 'zod';
2
+ import { geoJSONGeometrySchema } from './common.schemas';
3
+ const locationSourceSchema = z.enum(['gps_collar', 'manual', 'rfid_reader', 'app']);
4
+ export const livestockLocationSchema = z.object({
5
+ id: z.string().uuid(),
6
+ livestockId: z.string().uuid().optional(),
7
+ groupId: z.string().uuid().optional(),
8
+ coordinates: z.object({
9
+ lat: z.number(),
10
+ lng: z.number(),
11
+ accuracy: z.number().optional(),
12
+ }),
13
+ timestamp: z.string().datetime(),
14
+ source: locationSourceSchema,
15
+ batteryLevel: z.number().min(0).max(100).optional(),
16
+ });
17
+ export const movementTrailPointSchema = z.object({
18
+ lat: z.number(),
19
+ lng: z.number(),
20
+ timestamp: z.string().datetime(),
21
+ });
22
+ export const livestockMovementTrailSchema = z.object({
23
+ livestockId: z.string().uuid(),
24
+ points: z.array(movementTrailPointSchema),
25
+ dateRange: z.object({
26
+ start: z.string().datetime(),
27
+ end: z.string().datetime(),
28
+ }),
29
+ });
30
+ export const heatmapPointSchema = z.object({
31
+ lat: z.number(),
32
+ lng: z.number(),
33
+ intensity: z.number(),
34
+ });
35
+ export const grazingZoneSchema = z.object({
36
+ id: z.string().uuid(),
37
+ name: z.string(),
38
+ geometry: geoJSONGeometrySchema,
39
+ type: z.enum(['paddock', 'shelter', 'water_source', 'feeding_area']),
40
+ currentOccupancy: z.number().optional(),
41
+ capacity: z.number().optional(),
42
+ });
43
+ export const updateLocationBodySchema = z.object({
44
+ coordinates: z.object({
45
+ lat: z.number(),
46
+ lng: z.number(),
47
+ }),
48
+ });
49
+ export const livestockLocationListResponseSchema = z.array(livestockLocationSchema);
50
+ export const movementTrailListResponseSchema = z.array(livestockMovementTrailSchema);
51
+ export const heatmapResponseSchema = z.array(heatmapPointSchema);
52
+ export const grazingZoneListResponseSchema = z.array(grazingZoneSchema);