@deepintel-ltd/farmpro-contracts 1.5.7 → 1.5.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.
- package/dist/index.js +50 -92
- package/dist/routes/admin.routes.js +13 -16
- package/dist/routes/agent-workflows.routes.js +81 -84
- package/dist/routes/agents.routes.js +29 -32
- package/dist/routes/analytics.routes.js +11 -14
- package/dist/routes/auth.routes.js +55 -58
- package/dist/routes/categories.routes.js +23 -26
- package/dist/routes/documents.routes.js +67 -70
- package/dist/routes/equipment.routes.js +55 -58
- package/dist/routes/farms.routes.js +32 -35
- package/dist/routes/field-monitoring.routes.js +70 -73
- package/dist/routes/field-observations.routes.js +41 -44
- package/dist/routes/fields.routes.js +44 -47
- package/dist/routes/finance.routes.js +121 -124
- package/dist/routes/harvest.routes.js +46 -49
- package/dist/routes/health.routes.js +6 -9
- package/dist/routes/index.js +51 -54
- package/dist/routes/input-usage.routes.js +14 -17
- package/dist/routes/inventory.routes.js +57 -60
- package/dist/routes/seasonal-plans.routes.js +14 -17
- package/dist/routes/soil-tests.routes.js +45 -48
- package/dist/routes/suppliers.routes.js +70 -73
- package/dist/routes/tasks.routes.js +65 -68
- package/dist/routes/team.routes.js +57 -60
- package/dist/routes/users.routes.js +13 -16
- package/dist/routes/weather.routes.js +10 -13
- package/dist/schemas/admin.schemas.js +43 -46
- package/dist/schemas/agent-workflows.schemas.js +34 -37
- package/dist/schemas/agents.schemas.js +46 -49
- package/dist/schemas/analytics.schemas.js +51 -54
- package/dist/schemas/auth.schemas.js +96 -99
- package/dist/schemas/categories.schemas.js +27 -30
- package/dist/schemas/common.schemas.js +89 -95
- package/dist/schemas/documents.schemas.js +59 -62
- package/dist/schemas/equipment.schemas.js +86 -89
- package/dist/schemas/farms.schemas.js +40 -43
- package/dist/schemas/field-monitoring.schemas.js +207 -210
- package/dist/schemas/field-observations.schemas.js +93 -96
- package/dist/schemas/fields.schemas.js +82 -85
- package/dist/schemas/finance.schemas.js +134 -137
- package/dist/schemas/harvest.schemas.js +46 -49
- package/dist/schemas/health.schemas.js +14 -17
- package/dist/schemas/input-usage.schemas.js +21 -24
- package/dist/schemas/inventory.schemas.js +58 -61
- package/dist/schemas/recommendations.schemas.js +22 -25
- package/dist/schemas/seasonal-plans.schemas.js +21 -24
- package/dist/schemas/soil-tests.schemas.js +70 -73
- package/dist/schemas/suppliers.schemas.js +90 -93
- package/dist/schemas/tasks.schemas.js +93 -96
- package/dist/schemas/team.schemas.js +35 -38
- package/dist/schemas/users.schemas.js +19 -22
- package/dist/schemas/weather.schemas.js +32 -35
- package/package.json +9 -1
|
@@ -1,52 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.financeSummaryResponseSchema = exports.financeSummaryResourceSchema = exports.revenueListResponseSchema = exports.revenueDetailResponseSchema = exports.revenueResponseSchema = exports.expenseListResponseSchema = exports.expenseDetailResponseSchema = exports.expenseResponseSchema = exports.budgetListResponseSchema = exports.budgetResponseSchema = exports.revenueDetailResourceSchema = exports.expenseDetailResourceSchema = exports.revenueResourceSchema = exports.expenseResourceSchema = exports.budgetResourceSchema = exports.updateRevenueSchema = exports.createRevenueSchema = exports.updateExpenseSchema = exports.createExpenseSchema = exports.updateBudgetSchema = exports.createBudgetSchema = exports.updateRevenueAttributesSchema = exports.createRevenueAttributesSchema = exports.revenueAttributesSchema = exports.updateExpenseAttributesSchema = exports.createExpenseAttributesSchema = exports.expenseAttributesSchema = exports.updateBudgetAttributesSchema = exports.createBudgetAttributesSchema = exports.budgetAttributesSchema = exports.expenseAllocationTypeSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const common_schemas_1 = require("./common.schemas");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema } from './common.schemas';
|
|
6
3
|
/**
|
|
7
4
|
* Finance schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Expense allocation type
|
|
10
|
-
|
|
7
|
+
export const expenseAllocationTypeSchema = z.enum(['field', 'crop', 'general']);
|
|
11
8
|
// Budget attributes schema (for JSON:API attributes object)
|
|
12
|
-
|
|
13
|
-
category:
|
|
14
|
-
planned:
|
|
15
|
-
actual:
|
|
16
|
-
remaining:
|
|
17
|
-
}).merge(
|
|
9
|
+
export const budgetAttributesSchema = z.object({
|
|
10
|
+
category: z.string(),
|
|
11
|
+
planned: z.number().nonnegative(),
|
|
12
|
+
actual: z.number().nonnegative().optional(), // Calculated from expenses
|
|
13
|
+
remaining: z.number().optional(), // planned - actual
|
|
14
|
+
}).merge(timestampsSchema);
|
|
18
15
|
// Budget attributes for creation (input)
|
|
19
|
-
|
|
20
|
-
category:
|
|
21
|
-
planned:
|
|
16
|
+
export const createBudgetAttributesSchema = z.object({
|
|
17
|
+
category: z.string().min(1).max(100),
|
|
18
|
+
planned: z.number().nonnegative(),
|
|
22
19
|
});
|
|
23
20
|
// Budget attributes for update (input)
|
|
24
|
-
|
|
25
|
-
category:
|
|
26
|
-
planned:
|
|
21
|
+
export const updateBudgetAttributesSchema = z.object({
|
|
22
|
+
category: z.string().min(1).max(100).optional(),
|
|
23
|
+
planned: z.number().nonnegative().optional(),
|
|
27
24
|
});
|
|
28
25
|
// Expense attributes schema (for JSON:API attributes object)
|
|
29
|
-
|
|
30
|
-
date:
|
|
31
|
-
category:
|
|
32
|
-
description:
|
|
33
|
-
amount:
|
|
34
|
-
allocationType:
|
|
35
|
-
fieldId:
|
|
36
|
-
fieldName:
|
|
37
|
-
cropId:
|
|
38
|
-
cropName:
|
|
39
|
-
}).merge(
|
|
26
|
+
export const expenseAttributesSchema = z.object({
|
|
27
|
+
date: z.string().datetime(),
|
|
28
|
+
category: z.string(),
|
|
29
|
+
description: z.string(),
|
|
30
|
+
amount: z.number().positive(),
|
|
31
|
+
allocationType: expenseAllocationTypeSchema,
|
|
32
|
+
fieldId: z.string().uuid().nullable(),
|
|
33
|
+
fieldName: z.string().nullable().optional(),
|
|
34
|
+
cropId: z.string().nullable(),
|
|
35
|
+
cropName: z.string().nullable().optional(),
|
|
36
|
+
}).merge(timestampsSchema);
|
|
40
37
|
// Expense attributes for creation (input)
|
|
41
|
-
|
|
42
|
-
date:
|
|
43
|
-
category:
|
|
44
|
-
description:
|
|
45
|
-
amount:
|
|
38
|
+
export const createExpenseAttributesSchema = z.object({
|
|
39
|
+
date: z.string().datetime(),
|
|
40
|
+
category: z.string().min(1),
|
|
41
|
+
description: z.string().min(1).max(500),
|
|
42
|
+
amount: z.number().positive(),
|
|
46
43
|
// Cost allocation
|
|
47
|
-
allocationType:
|
|
48
|
-
fieldId:
|
|
49
|
-
cropId:
|
|
44
|
+
allocationType: expenseAllocationTypeSchema.default('general'),
|
|
45
|
+
fieldId: z.string().uuid().optional(),
|
|
46
|
+
cropId: z.string().optional(),
|
|
50
47
|
}).refine((data) => {
|
|
51
48
|
// If allocationType is 'field', fieldId must be provided
|
|
52
49
|
if (data.allocationType === 'field' && !data.fieldId) {
|
|
@@ -61,135 +58,135 @@ exports.createExpenseAttributesSchema = zod_1.z.object({
|
|
|
61
58
|
message: 'Field or crop must be selected for field/crop allocation',
|
|
62
59
|
});
|
|
63
60
|
// Expense attributes for update (input)
|
|
64
|
-
|
|
65
|
-
date:
|
|
66
|
-
category:
|
|
67
|
-
description:
|
|
68
|
-
amount:
|
|
69
|
-
allocationType:
|
|
70
|
-
fieldId:
|
|
71
|
-
cropId:
|
|
61
|
+
export const updateExpenseAttributesSchema = z.object({
|
|
62
|
+
date: z.string().datetime().optional(),
|
|
63
|
+
category: z.string().min(1).optional(),
|
|
64
|
+
description: z.string().min(1).max(500).optional(),
|
|
65
|
+
amount: z.number().positive().optional(),
|
|
66
|
+
allocationType: expenseAllocationTypeSchema.optional(),
|
|
67
|
+
fieldId: z.string().uuid().nullable().optional(),
|
|
68
|
+
cropId: z.string().nullable().optional(),
|
|
72
69
|
});
|
|
73
70
|
// Revenue attributes schema (for JSON:API attributes object)
|
|
74
|
-
|
|
75
|
-
date:
|
|
76
|
-
crop:
|
|
77
|
-
quantity:
|
|
78
|
-
unit:
|
|
79
|
-
pricePerUnit:
|
|
80
|
-
totalAmount:
|
|
81
|
-
buyer:
|
|
82
|
-
fieldId:
|
|
83
|
-
fieldName:
|
|
84
|
-
harvestId:
|
|
85
|
-
}).merge(
|
|
71
|
+
export const revenueAttributesSchema = z.object({
|
|
72
|
+
date: z.string().datetime(),
|
|
73
|
+
crop: z.string(),
|
|
74
|
+
quantity: z.number().positive(),
|
|
75
|
+
unit: z.string(),
|
|
76
|
+
pricePerUnit: z.number().positive(),
|
|
77
|
+
totalAmount: z.number().positive(),
|
|
78
|
+
buyer: z.string().nullable(),
|
|
79
|
+
fieldId: z.string().uuid().nullable(),
|
|
80
|
+
fieldName: z.string().nullable().optional(),
|
|
81
|
+
harvestId: z.string().uuid().nullable(),
|
|
82
|
+
}).merge(timestampsSchema);
|
|
86
83
|
// Revenue attributes for creation (input)
|
|
87
|
-
|
|
88
|
-
date:
|
|
89
|
-
crop:
|
|
90
|
-
quantity:
|
|
91
|
-
unit:
|
|
92
|
-
pricePerUnit:
|
|
93
|
-
totalAmount:
|
|
94
|
-
buyer:
|
|
95
|
-
fieldId:
|
|
96
|
-
harvestId:
|
|
84
|
+
export const createRevenueAttributesSchema = z.object({
|
|
85
|
+
date: z.string().datetime(),
|
|
86
|
+
crop: z.string().min(1),
|
|
87
|
+
quantity: z.number().positive(),
|
|
88
|
+
unit: z.string().min(1), // e.g., "tons", "100kg", "bags"
|
|
89
|
+
pricePerUnit: z.number().positive(),
|
|
90
|
+
totalAmount: z.number().positive().optional(), // Calculated: quantity * pricePerUnit
|
|
91
|
+
buyer: z.string().optional(),
|
|
92
|
+
fieldId: z.string().uuid().optional(),
|
|
93
|
+
harvestId: z.string().uuid().optional(), // Link to harvest entry
|
|
97
94
|
});
|
|
98
95
|
// Revenue attributes for update (input)
|
|
99
|
-
|
|
100
|
-
date:
|
|
101
|
-
crop:
|
|
102
|
-
quantity:
|
|
103
|
-
unit:
|
|
104
|
-
pricePerUnit:
|
|
105
|
-
totalAmount:
|
|
106
|
-
buyer:
|
|
107
|
-
fieldId:
|
|
108
|
-
harvestId:
|
|
96
|
+
export const updateRevenueAttributesSchema = z.object({
|
|
97
|
+
date: z.string().datetime().optional(),
|
|
98
|
+
crop: z.string().min(1).optional(),
|
|
99
|
+
quantity: z.number().positive().optional(),
|
|
100
|
+
unit: z.string().min(1).optional(),
|
|
101
|
+
pricePerUnit: z.number().positive().optional(),
|
|
102
|
+
totalAmount: z.number().positive().optional(),
|
|
103
|
+
buyer: z.string().nullable().optional(),
|
|
104
|
+
fieldId: z.string().uuid().nullable().optional(),
|
|
105
|
+
harvestId: z.string().uuid().nullable().optional(),
|
|
109
106
|
});
|
|
110
107
|
// Create input schemas (JSON:API format)
|
|
111
|
-
|
|
112
|
-
type:
|
|
113
|
-
attributes:
|
|
108
|
+
export const createBudgetSchema = z.object({
|
|
109
|
+
type: z.literal('budgets'),
|
|
110
|
+
attributes: createBudgetAttributesSchema,
|
|
114
111
|
});
|
|
115
|
-
|
|
116
|
-
type:
|
|
117
|
-
id:
|
|
118
|
-
attributes:
|
|
112
|
+
export const updateBudgetSchema = z.object({
|
|
113
|
+
type: z.literal('budgets'),
|
|
114
|
+
id: z.string().uuid(),
|
|
115
|
+
attributes: updateBudgetAttributesSchema,
|
|
119
116
|
});
|
|
120
|
-
|
|
121
|
-
type:
|
|
122
|
-
attributes:
|
|
117
|
+
export const createExpenseSchema = z.object({
|
|
118
|
+
type: z.literal('expenses'),
|
|
119
|
+
attributes: createExpenseAttributesSchema,
|
|
123
120
|
});
|
|
124
|
-
|
|
125
|
-
type:
|
|
126
|
-
id:
|
|
127
|
-
attributes:
|
|
121
|
+
export const updateExpenseSchema = z.object({
|
|
122
|
+
type: z.literal('expenses'),
|
|
123
|
+
id: z.string().uuid(),
|
|
124
|
+
attributes: updateExpenseAttributesSchema,
|
|
128
125
|
});
|
|
129
|
-
|
|
130
|
-
type:
|
|
131
|
-
attributes:
|
|
126
|
+
export const createRevenueSchema = z.object({
|
|
127
|
+
type: z.literal('revenues'),
|
|
128
|
+
attributes: createRevenueAttributesSchema,
|
|
132
129
|
});
|
|
133
|
-
|
|
134
|
-
type:
|
|
135
|
-
id:
|
|
136
|
-
attributes:
|
|
130
|
+
export const updateRevenueSchema = z.object({
|
|
131
|
+
type: z.literal('revenues'),
|
|
132
|
+
id: z.string().uuid(),
|
|
133
|
+
attributes: updateRevenueAttributesSchema,
|
|
137
134
|
});
|
|
138
135
|
// Resource schemas (JSON:API resource objects)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
export const budgetResourceSchema = createJsonApiResourceSchema('budgets', budgetAttributesSchema);
|
|
137
|
+
export const expenseResourceSchema = createJsonApiResourceSchema('expenses', expenseAttributesSchema);
|
|
138
|
+
export const revenueResourceSchema = createJsonApiResourceSchema('revenues', revenueAttributesSchema);
|
|
142
139
|
// Detail resource schemas with relationships
|
|
143
|
-
|
|
144
|
-
relationships:
|
|
145
|
-
field:
|
|
146
|
-
links:
|
|
147
|
-
related:
|
|
140
|
+
export const expenseDetailResourceSchema = expenseResourceSchema.extend({
|
|
141
|
+
relationships: z.object({
|
|
142
|
+
field: z.object({
|
|
143
|
+
links: z.object({
|
|
144
|
+
related: z.string(),
|
|
148
145
|
}),
|
|
149
146
|
}).optional(),
|
|
150
147
|
}).optional(),
|
|
151
148
|
});
|
|
152
|
-
|
|
153
|
-
relationships:
|
|
154
|
-
field:
|
|
155
|
-
links:
|
|
156
|
-
related:
|
|
149
|
+
export const revenueDetailResourceSchema = revenueResourceSchema.extend({
|
|
150
|
+
relationships: z.object({
|
|
151
|
+
field: z.object({
|
|
152
|
+
links: z.object({
|
|
153
|
+
related: z.string(),
|
|
157
154
|
}),
|
|
158
155
|
}).optional(),
|
|
159
|
-
harvest:
|
|
160
|
-
links:
|
|
161
|
-
related:
|
|
156
|
+
harvest: z.object({
|
|
157
|
+
links: z.object({
|
|
158
|
+
related: z.string(),
|
|
162
159
|
}),
|
|
163
160
|
}).optional(),
|
|
164
161
|
}).optional(),
|
|
165
162
|
});
|
|
166
163
|
// Response schemas (JSON:API format)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
export const budgetResponseSchema = jsonApiSingleResponseSchema(budgetResourceSchema);
|
|
165
|
+
export const budgetListResponseSchema = jsonApiCollectionResponseSchema(budgetResourceSchema);
|
|
166
|
+
export const expenseResponseSchema = jsonApiSingleResponseSchema(expenseResourceSchema);
|
|
167
|
+
export const expenseDetailResponseSchema = jsonApiSingleResponseSchema(expenseDetailResourceSchema);
|
|
168
|
+
export const expenseListResponseSchema = jsonApiCollectionResponseSchema(expenseResourceSchema);
|
|
169
|
+
export const revenueResponseSchema = jsonApiSingleResponseSchema(revenueResourceSchema);
|
|
170
|
+
export const revenueDetailResponseSchema = jsonApiSingleResponseSchema(revenueDetailResourceSchema);
|
|
171
|
+
export const revenueListResponseSchema = jsonApiCollectionResponseSchema(revenueResourceSchema);
|
|
175
172
|
// Finance summary response (JSON:API format)
|
|
176
|
-
|
|
177
|
-
totalPlanned:
|
|
178
|
-
totalActual:
|
|
179
|
-
totalRevenue:
|
|
180
|
-
remainingBudget:
|
|
181
|
-
netProfit:
|
|
182
|
-
profitMargin:
|
|
173
|
+
export const financeSummaryResourceSchema = createJsonApiResourceSchema('finance-summaries', z.object({
|
|
174
|
+
totalPlanned: z.number().nonnegative(),
|
|
175
|
+
totalActual: z.number().nonnegative(),
|
|
176
|
+
totalRevenue: z.number().nonnegative(),
|
|
177
|
+
remainingBudget: z.number(),
|
|
178
|
+
netProfit: z.number(),
|
|
179
|
+
profitMargin: z.number(), // Percentage
|
|
183
180
|
}));
|
|
184
|
-
|
|
185
|
-
relationships:
|
|
186
|
-
budgets:
|
|
187
|
-
data:
|
|
188
|
-
type:
|
|
189
|
-
id:
|
|
181
|
+
export const financeSummaryResponseSchema = jsonApiSingleResponseSchema(financeSummaryResourceSchema.extend({
|
|
182
|
+
relationships: z.object({
|
|
183
|
+
budgets: z.object({
|
|
184
|
+
data: z.array(z.object({
|
|
185
|
+
type: z.literal('budgets'),
|
|
186
|
+
id: z.string(),
|
|
190
187
|
})),
|
|
191
|
-
links:
|
|
192
|
-
related:
|
|
188
|
+
links: z.object({
|
|
189
|
+
related: z.string(),
|
|
193
190
|
}),
|
|
194
191
|
}),
|
|
195
192
|
}).optional(),
|
|
@@ -1,71 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.harvestListResponseSchema = exports.harvestDetailResponseSchema = exports.harvestResponseSchema = exports.harvestDetailResourceSchema = exports.harvestResourceSchema = exports.updateHarvestSchema = exports.createHarvestSchema = exports.updateHarvestAttributesSchema = exports.createHarvestAttributesSchema = exports.harvestAttributesSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const common_schemas_1 = require("./common.schemas");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, jsonApiCollectionResponseSchema } from './common.schemas';
|
|
6
3
|
/**
|
|
7
4
|
* Harvest schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Harvest attributes schema (for JSON:API attributes object)
|
|
10
|
-
|
|
11
|
-
fieldId:
|
|
12
|
-
fieldName:
|
|
13
|
-
date:
|
|
14
|
-
crop:
|
|
15
|
-
quantity:
|
|
16
|
-
unit:
|
|
17
|
-
qualityGrade:
|
|
18
|
-
yieldPerHectare:
|
|
19
|
-
linkedRevenueId:
|
|
20
|
-
}).merge(
|
|
7
|
+
export const harvestAttributesSchema = z.object({
|
|
8
|
+
fieldId: z.string().uuid(),
|
|
9
|
+
fieldName: z.string().optional(),
|
|
10
|
+
date: z.string().datetime(),
|
|
11
|
+
crop: z.string(),
|
|
12
|
+
quantity: z.number().positive(),
|
|
13
|
+
unit: z.string(),
|
|
14
|
+
qualityGrade: z.string().nullable(),
|
|
15
|
+
yieldPerHectare: z.number().nullable().optional(), // Calculated from field area
|
|
16
|
+
linkedRevenueId: z.string().uuid().nullable().optional(), // Link to revenue entry
|
|
17
|
+
}).merge(timestampsSchema);
|
|
21
18
|
// Harvest attributes for creation (input)
|
|
22
|
-
|
|
23
|
-
fieldId:
|
|
24
|
-
date:
|
|
25
|
-
crop:
|
|
26
|
-
quantity:
|
|
27
|
-
unit:
|
|
28
|
-
qualityGrade:
|
|
19
|
+
export const createHarvestAttributesSchema = z.object({
|
|
20
|
+
fieldId: z.string().uuid(),
|
|
21
|
+
date: z.string().datetime(),
|
|
22
|
+
crop: z.string().min(1),
|
|
23
|
+
quantity: z.number().positive(),
|
|
24
|
+
unit: z.string().min(1), // 'tons', 'kg', '100kg', 'bags'
|
|
25
|
+
qualityGrade: z.string().optional(), // Optional quality rating
|
|
29
26
|
// Yield per hectare is calculated from field area
|
|
30
27
|
});
|
|
31
28
|
// Harvest attributes for update (input)
|
|
32
|
-
|
|
33
|
-
fieldId:
|
|
34
|
-
date:
|
|
35
|
-
crop:
|
|
36
|
-
quantity:
|
|
37
|
-
unit:
|
|
38
|
-
qualityGrade:
|
|
29
|
+
export const updateHarvestAttributesSchema = z.object({
|
|
30
|
+
fieldId: z.string().uuid().optional(),
|
|
31
|
+
date: z.string().datetime().optional(),
|
|
32
|
+
crop: z.string().min(1).optional(),
|
|
33
|
+
quantity: z.number().positive().optional(),
|
|
34
|
+
unit: z.string().min(1).optional(),
|
|
35
|
+
qualityGrade: z.string().nullable().optional(),
|
|
39
36
|
});
|
|
40
37
|
// Create harvest input (JSON:API format)
|
|
41
|
-
|
|
42
|
-
type:
|
|
43
|
-
attributes:
|
|
38
|
+
export const createHarvestSchema = z.object({
|
|
39
|
+
type: z.literal('harvests'),
|
|
40
|
+
attributes: createHarvestAttributesSchema,
|
|
44
41
|
});
|
|
45
42
|
// Update harvest input (JSON:API format)
|
|
46
|
-
|
|
47
|
-
type:
|
|
48
|
-
id:
|
|
49
|
-
attributes:
|
|
43
|
+
export const updateHarvestSchema = z.object({
|
|
44
|
+
type: z.literal('harvests'),
|
|
45
|
+
id: z.string().uuid(),
|
|
46
|
+
attributes: updateHarvestAttributesSchema,
|
|
50
47
|
});
|
|
51
48
|
// Harvest resource (JSON:API resource object)
|
|
52
|
-
|
|
49
|
+
export const harvestResourceSchema = createJsonApiResourceSchema('harvests', harvestAttributesSchema);
|
|
53
50
|
// Harvest detail resource with relationships
|
|
54
|
-
|
|
55
|
-
relationships:
|
|
56
|
-
field:
|
|
57
|
-
links:
|
|
58
|
-
related:
|
|
51
|
+
export const harvestDetailResourceSchema = harvestResourceSchema.extend({
|
|
52
|
+
relationships: z.object({
|
|
53
|
+
field: z.object({
|
|
54
|
+
links: z.object({
|
|
55
|
+
related: z.string(),
|
|
59
56
|
}),
|
|
60
57
|
}).optional(),
|
|
61
|
-
revenue:
|
|
62
|
-
links:
|
|
63
|
-
related:
|
|
58
|
+
revenue: z.object({
|
|
59
|
+
links: z.object({
|
|
60
|
+
related: z.string(),
|
|
64
61
|
}),
|
|
65
62
|
}).optional(),
|
|
66
63
|
}).optional(),
|
|
67
64
|
});
|
|
68
65
|
// Harvest responses (JSON:API format)
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
export const harvestResponseSchema = jsonApiSingleResponseSchema(harvestResourceSchema);
|
|
67
|
+
export const harvestDetailResponseSchema = jsonApiSingleResponseSchema(harvestDetailResourceSchema);
|
|
68
|
+
export const harvestListResponseSchema = jsonApiCollectionResponseSchema(harvestResourceSchema);
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.healthCheckResponseSchema = exports.serviceHealthSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
1
|
+
import { z } from 'zod';
|
|
5
2
|
/**
|
|
6
3
|
* Health status for individual services
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
status:
|
|
10
|
-
message:
|
|
11
|
-
responseTime:
|
|
5
|
+
export const serviceHealthSchema = z.object({
|
|
6
|
+
status: z.enum(['healthy', 'unhealthy', 'degraded']),
|
|
7
|
+
message: z.string().optional(),
|
|
8
|
+
responseTime: z.number().optional(), // in milliseconds
|
|
12
9
|
});
|
|
13
10
|
/**
|
|
14
11
|
* Overall health check response
|
|
15
12
|
*/
|
|
16
|
-
|
|
17
|
-
status:
|
|
18
|
-
timestamp:
|
|
19
|
-
uptime:
|
|
20
|
-
services:
|
|
21
|
-
database:
|
|
22
|
-
redis:
|
|
23
|
-
storage:
|
|
24
|
-
timescale:
|
|
13
|
+
export const healthCheckResponseSchema = z.object({
|
|
14
|
+
status: z.enum(['healthy', 'unhealthy', 'degraded']),
|
|
15
|
+
timestamp: z.string().datetime(),
|
|
16
|
+
uptime: z.number(), // in seconds
|
|
17
|
+
services: z.object({
|
|
18
|
+
database: serviceHealthSchema,
|
|
19
|
+
redis: serviceHealthSchema,
|
|
20
|
+
storage: serviceHealthSchema.optional(),
|
|
21
|
+
timescale: serviceHealthSchema.optional(),
|
|
25
22
|
}),
|
|
26
23
|
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getInputUsageQuerySchema = exports.inputUsageResponseSchema = exports.inputUsageResourceSchema = exports.inputUsageAttributesSchema = exports.inputUsageItemSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const common_schemas_1 = require("./common.schemas");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { timestampsSchema, createJsonApiResourceSchema, jsonApiSingleResponseSchema, } from './common.schemas';
|
|
6
3
|
/**
|
|
7
4
|
* Input Usage schemas - JSON:API compliant
|
|
8
5
|
*
|
|
@@ -10,28 +7,28 @@ const common_schemas_1 = require("./common.schemas");
|
|
|
10
7
|
* Data is calculated from tasks that reference inventory items
|
|
11
8
|
*/
|
|
12
9
|
// Input usage item schema
|
|
13
|
-
|
|
14
|
-
id:
|
|
15
|
-
name:
|
|
16
|
-
planned:
|
|
17
|
-
actual:
|
|
18
|
-
unit:
|
|
10
|
+
export const inputUsageItemSchema = z.object({
|
|
11
|
+
id: z.string(), // inventoryItemId
|
|
12
|
+
name: z.string(), // inventory item name
|
|
13
|
+
planned: z.number(),
|
|
14
|
+
actual: z.number(),
|
|
15
|
+
unit: z.string(), // from inventory item
|
|
19
16
|
});
|
|
20
17
|
// Input usage attributes schema
|
|
21
|
-
|
|
22
|
-
farmId:
|
|
23
|
-
season:
|
|
24
|
-
startDate:
|
|
25
|
-
endDate:
|
|
26
|
-
items:
|
|
27
|
-
}).merge(
|
|
18
|
+
export const inputUsageAttributesSchema = z.object({
|
|
19
|
+
farmId: z.string().uuid(),
|
|
20
|
+
season: z.string().optional(), // e.g., "2024-2025"
|
|
21
|
+
startDate: z.string().datetime().optional(),
|
|
22
|
+
endDate: z.string().datetime().optional(),
|
|
23
|
+
items: z.array(inputUsageItemSchema), // Usage items grouped by inventory item
|
|
24
|
+
}).merge(timestampsSchema);
|
|
28
25
|
// Input usage resource schema
|
|
29
|
-
|
|
26
|
+
export const inputUsageResourceSchema = createJsonApiResourceSchema('input-usage', inputUsageAttributesSchema);
|
|
30
27
|
// Input usage response schema
|
|
31
|
-
|
|
28
|
+
export const inputUsageResponseSchema = jsonApiSingleResponseSchema(inputUsageResourceSchema);
|
|
32
29
|
// Query parameters for getting input usage
|
|
33
|
-
|
|
34
|
-
season:
|
|
35
|
-
'filter[startDate]':
|
|
36
|
-
'filter[endDate]':
|
|
30
|
+
export const getInputUsageQuerySchema = z.object({
|
|
31
|
+
season: z.string().optional(), // e.g., "2024-2025"
|
|
32
|
+
'filter[startDate]': z.string().datetime().optional(),
|
|
33
|
+
'filter[endDate]': z.string().datetime().optional(),
|
|
37
34
|
});
|