@deepintel-ltd/farmpro-contracts 1.7.5 → 1.7.6

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":"livestock-groups.schemas.d.ts","sourceRoot":"","sources":["../../src/schemas/livestock-groups.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB;;;;;;;GAOG;AAGH,eAAO,MAAM,wBAAwB,4HAUnC,CAAC;AAGH,eAAO,MAAM,kBAAkB,8CAI7B,CAAC;AAGH,eAAO,MAAM,iBAAiB,sEAM5B,CAAC;AAGH,eAAO,MAAM,qBAAqB,gKAYhC,CAAC;AAGH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmCjB,CAAC;AAG3B,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB/C,CAAC;AAGH,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB/C,CAAC;AAGH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyBd,CAAC;AAG3B,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqB5C,CAAC;AAGH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC7E,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AACjF,MAAM,MAAM,qBAAqB,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
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deepintel-ltd/farmpro-contracts",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Type-safe API contracts for FarmPro API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",