@deepintel-ltd/farmpro-contracts 1.5.8 → 1.5.10
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.d.ts +8 -1
- package/dist/routes/field-monitoring.routes.d.ts.map +1 -1
- package/dist/routes/field-monitoring.routes.js +77 -74
- 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.d.ts +306 -0
- package/dist/routes/team.routes.d.ts.map +1 -1
- package/dist/routes/team.routes.js +79 -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,89 +1,86 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.inventoryItemListResponseSchema = exports.inventoryItemDetailResponseSchema = exports.inventoryItemResponseSchema = exports.inventoryItemDetailResourceSchema = exports.inventoryItemResourceSchema = exports.logPurchaseSchema = exports.updateInventoryItemSchema = exports.createInventoryItemSchema = exports.logPurchaseAttributesSchema = exports.updateInventoryItemAttributesSchema = exports.createInventoryItemAttributesSchema = exports.inventoryItemAttributesSchema = 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
|
* Inventory schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Inventory item attributes schema (for JSON:API attributes object)
|
|
10
|
-
|
|
11
|
-
name:
|
|
12
|
-
category:
|
|
13
|
-
stock:
|
|
14
|
-
unit:
|
|
15
|
-
avgCost:
|
|
16
|
-
totalValue:
|
|
17
|
-
}).merge(
|
|
7
|
+
export const inventoryItemAttributesSchema = z.object({
|
|
8
|
+
name: z.string(),
|
|
9
|
+
category: z.string(),
|
|
10
|
+
stock: z.number().nonnegative(), // Current stock
|
|
11
|
+
unit: z.string(),
|
|
12
|
+
avgCost: z.number().nonnegative(), // Average cost per unit
|
|
13
|
+
totalValue: z.number().nonnegative().optional(), // stock * avgCost
|
|
14
|
+
}).merge(timestampsSchema);
|
|
18
15
|
// Inventory item attributes for creation (input)
|
|
19
|
-
|
|
20
|
-
name:
|
|
21
|
-
category:
|
|
22
|
-
unit:
|
|
23
|
-
initialStock:
|
|
24
|
-
initialCost:
|
|
16
|
+
export const createInventoryItemAttributesSchema = z.object({
|
|
17
|
+
name: z.string().min(1).max(200),
|
|
18
|
+
category: z.string().min(1),
|
|
19
|
+
unit: z.string().min(1),
|
|
20
|
+
initialStock: z.number().nonnegative().default(0).optional(),
|
|
21
|
+
initialCost: z.number().nonnegative().optional(),
|
|
25
22
|
});
|
|
26
23
|
// Inventory item attributes for update (input)
|
|
27
|
-
|
|
28
|
-
name:
|
|
29
|
-
category:
|
|
30
|
-
unit:
|
|
24
|
+
export const updateInventoryItemAttributesSchema = z.object({
|
|
25
|
+
name: z.string().min(1).max(200).optional(),
|
|
26
|
+
category: z.string().min(1).optional(),
|
|
27
|
+
unit: z.string().min(1).optional(),
|
|
31
28
|
});
|
|
32
29
|
// Log purchase attributes (creates inventory item and expense)
|
|
33
|
-
|
|
34
|
-
itemId:
|
|
35
|
-
name:
|
|
36
|
-
category:
|
|
37
|
-
quantity:
|
|
38
|
-
unit:
|
|
39
|
-
unitCost:
|
|
40
|
-
totalCost:
|
|
41
|
-
date:
|
|
42
|
-
supplier:
|
|
30
|
+
export const logPurchaseAttributesSchema = z.object({
|
|
31
|
+
itemId: z.string().uuid().optional(), // Existing inventory item ID (for restocking)
|
|
32
|
+
name: z.string().min(1).max(200).optional(), // New item name (if creating new item)
|
|
33
|
+
category: z.string().min(1).optional(), // Required if creating new item
|
|
34
|
+
quantity: z.number().positive(),
|
|
35
|
+
unit: z.string().min(1), // e.g., "bags", "liters", "kg"
|
|
36
|
+
unitCost: z.number().positive(),
|
|
37
|
+
totalCost: z.number().positive(), // quantity * unitCost
|
|
38
|
+
date: z.string().datetime(),
|
|
39
|
+
supplier: z.string().optional(),
|
|
43
40
|
// Expense allocation (optional)
|
|
44
|
-
fieldId:
|
|
45
|
-
cropId:
|
|
41
|
+
fieldId: z.string().uuid().optional(),
|
|
42
|
+
cropId: z.string().optional(),
|
|
46
43
|
});
|
|
47
44
|
// Create inventory item input (JSON:API format)
|
|
48
|
-
|
|
49
|
-
type:
|
|
50
|
-
attributes:
|
|
45
|
+
export const createInventoryItemSchema = z.object({
|
|
46
|
+
type: z.literal('inventory-items'),
|
|
47
|
+
attributes: createInventoryItemAttributesSchema,
|
|
51
48
|
});
|
|
52
49
|
// Update inventory item input (JSON:API format)
|
|
53
|
-
|
|
54
|
-
type:
|
|
55
|
-
id:
|
|
56
|
-
attributes:
|
|
50
|
+
export const updateInventoryItemSchema = z.object({
|
|
51
|
+
type: z.literal('inventory-items'),
|
|
52
|
+
id: z.string().uuid(),
|
|
53
|
+
attributes: updateInventoryItemAttributesSchema,
|
|
57
54
|
});
|
|
58
55
|
// Log purchase input (JSON:API format)
|
|
59
|
-
|
|
60
|
-
type:
|
|
61
|
-
attributes:
|
|
56
|
+
export const logPurchaseSchema = z.object({
|
|
57
|
+
type: z.literal('purchases'),
|
|
58
|
+
attributes: logPurchaseAttributesSchema,
|
|
62
59
|
});
|
|
63
60
|
// Inventory item resource (JSON:API resource object)
|
|
64
|
-
|
|
61
|
+
export const inventoryItemResourceSchema = createJsonApiResourceSchema('inventory-items', inventoryItemAttributesSchema);
|
|
65
62
|
// Inventory item detail resource with relationships
|
|
66
|
-
|
|
67
|
-
relationships:
|
|
68
|
-
tasks:
|
|
69
|
-
meta:
|
|
70
|
-
count:
|
|
63
|
+
export const inventoryItemDetailResourceSchema = inventoryItemResourceSchema.extend({
|
|
64
|
+
relationships: z.object({
|
|
65
|
+
tasks: z.object({
|
|
66
|
+
meta: z.object({
|
|
67
|
+
count: z.number().int().nonnegative(),
|
|
71
68
|
}),
|
|
72
|
-
links:
|
|
73
|
-
related:
|
|
69
|
+
links: z.object({
|
|
70
|
+
related: z.string(),
|
|
74
71
|
}),
|
|
75
72
|
}).optional(),
|
|
76
|
-
transactions:
|
|
77
|
-
meta:
|
|
78
|
-
count:
|
|
73
|
+
transactions: z.object({
|
|
74
|
+
meta: z.object({
|
|
75
|
+
count: z.number().int().nonnegative(),
|
|
79
76
|
}),
|
|
80
|
-
links:
|
|
81
|
-
related:
|
|
77
|
+
links: z.object({
|
|
78
|
+
related: z.string(),
|
|
82
79
|
}),
|
|
83
80
|
}).optional(),
|
|
84
81
|
}).optional(),
|
|
85
82
|
});
|
|
86
83
|
// Inventory item responses (JSON:API format)
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
export const inventoryItemResponseSchema = jsonApiSingleResponseSchema(inventoryItemResourceSchema);
|
|
85
|
+
export const inventoryItemDetailResponseSchema = jsonApiSingleResponseSchema(inventoryItemDetailResourceSchema);
|
|
86
|
+
export const inventoryItemListResponseSchema = jsonApiCollectionResponseSchema(inventoryItemResourceSchema);
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.recommendationSchema = exports.recommendationMaterialSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
1
|
+
import { z } from 'zod';
|
|
5
2
|
/**
|
|
6
3
|
* Centralized Recommendation Schemas
|
|
7
4
|
*/
|
|
8
5
|
// Schema for materials suggested in a recommendation
|
|
9
|
-
|
|
10
|
-
inventoryItemId:
|
|
11
|
-
name:
|
|
12
|
-
quantity:
|
|
13
|
-
unit:
|
|
14
|
-
costPerUnit:
|
|
15
|
-
totalCost:
|
|
16
|
-
availability:
|
|
6
|
+
export const recommendationMaterialSchema = z.object({
|
|
7
|
+
inventoryItemId: z.string().uuid().optional(),
|
|
8
|
+
name: z.string(),
|
|
9
|
+
quantity: z.number(),
|
|
10
|
+
unit: z.string(),
|
|
11
|
+
costPerUnit: z.number().optional(),
|
|
12
|
+
totalCost: z.number().optional(),
|
|
13
|
+
availability: z.string().optional(),
|
|
17
14
|
});
|
|
18
15
|
// The core, reusable recommendation schema
|
|
19
|
-
|
|
20
|
-
priority:
|
|
21
|
-
action:
|
|
22
|
-
details:
|
|
23
|
-
timing:
|
|
24
|
-
severity:
|
|
25
|
-
confidence:
|
|
26
|
-
materials:
|
|
27
|
-
applicationMethod:
|
|
28
|
-
expectedOutcome:
|
|
29
|
-
preventiveMeasures:
|
|
30
|
-
estimatedTime:
|
|
31
|
-
riskLevel:
|
|
16
|
+
export const recommendationSchema = z.object({
|
|
17
|
+
priority: z.number().min(1).max(5),
|
|
18
|
+
action: z.string(),
|
|
19
|
+
details: z.string(),
|
|
20
|
+
timing: z.string(),
|
|
21
|
+
severity: z.enum(['low', 'medium', 'high', 'critical']).optional(),
|
|
22
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
23
|
+
materials: z.array(recommendationMaterialSchema).optional(),
|
|
24
|
+
applicationMethod: z.string().optional(),
|
|
25
|
+
expectedOutcome: z.string().optional(),
|
|
26
|
+
preventiveMeasures: z.array(z.string()).optional(),
|
|
27
|
+
estimatedTime: z.string().optional(),
|
|
28
|
+
riskLevel: z.string().optional(),
|
|
32
29
|
});
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getSeasonalPlanQuerySchema = exports.seasonalPlanResponseSchema = exports.seasonalPlanResourceSchema = exports.seasonalPlanAttributesSchema = exports.seasonalPlanItemSchema = 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
|
* Seasonal Plans schemas - JSON:API compliant
|
|
8
5
|
*
|
|
@@ -10,28 +7,28 @@ const common_schemas_1 = require("./common.schemas");
|
|
|
10
7
|
* Data is calculated from tasks and field data
|
|
11
8
|
*/
|
|
12
9
|
// Seasonal plan item schema (for progress tracking)
|
|
13
|
-
|
|
14
|
-
id:
|
|
15
|
-
title:
|
|
16
|
-
planned:
|
|
17
|
-
actual:
|
|
18
|
-
unit:
|
|
10
|
+
export const seasonalPlanItemSchema = z.object({
|
|
11
|
+
id: z.string(),
|
|
12
|
+
title: z.string(), // e.g., "Planted Hectares", "Harvested Hectares"
|
|
13
|
+
planned: z.number(),
|
|
14
|
+
actual: z.number(),
|
|
15
|
+
unit: z.string(), // e.g., "Ha", "kg", "L"
|
|
19
16
|
});
|
|
20
17
|
// Seasonal plan attributes schema
|
|
21
|
-
|
|
22
|
-
farmId:
|
|
23
|
-
season:
|
|
24
|
-
startDate:
|
|
25
|
-
endDate:
|
|
26
|
-
items:
|
|
27
|
-
}).merge(
|
|
18
|
+
export const seasonalPlanAttributesSchema = z.object({
|
|
19
|
+
farmId: z.string().uuid(),
|
|
20
|
+
season: z.string(), // e.g., "2024-2025"
|
|
21
|
+
startDate: z.string().datetime().optional(),
|
|
22
|
+
endDate: z.string().datetime().optional(),
|
|
23
|
+
items: z.array(seasonalPlanItemSchema), // Progress items
|
|
24
|
+
}).merge(timestampsSchema);
|
|
28
25
|
// Seasonal plan resource schema
|
|
29
|
-
|
|
26
|
+
export const seasonalPlanResourceSchema = createJsonApiResourceSchema('seasonal-plans', seasonalPlanAttributesSchema);
|
|
30
27
|
// Seasonal plan response schema
|
|
31
|
-
|
|
28
|
+
export const seasonalPlanResponseSchema = jsonApiSingleResponseSchema(seasonalPlanResourceSchema);
|
|
32
29
|
// Query parameters for getting seasonal plan
|
|
33
|
-
|
|
34
|
-
season:
|
|
35
|
-
'filter[startDate]':
|
|
36
|
-
'filter[endDate]':
|
|
30
|
+
export const getSeasonalPlanQuerySchema = 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
|
});
|
|
@@ -1,102 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.soilTestListResponseSchema = exports.soilTestDetailResponseSchema = exports.soilTestResponseSchema = exports.soilTestDetailResourceSchema = exports.soilTestResourceSchema = exports.updateSoilTestSchema = exports.createSoilTestSchema = exports.updateSoilTestAttributesSchema = exports.createSoilTestAttributesSchema = exports.soilTestAttributesSchema = exports.fertilizerRecommendationSchema = exports.nutrientUnitSchema = 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
|
* Soil test schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Nutrient unit enum
|
|
10
|
-
|
|
7
|
+
export const nutrientUnitSchema = z.enum(['ppm', 'kg/ha']);
|
|
11
8
|
// Fertilizer recommendation schema (embedded in soil test attributes)
|
|
12
|
-
|
|
13
|
-
inventoryItemId:
|
|
14
|
-
quantity:
|
|
15
|
-
unit:
|
|
16
|
-
reason:
|
|
17
|
-
estimatedCost:
|
|
9
|
+
export const fertilizerRecommendationSchema = z.object({
|
|
10
|
+
inventoryItemId: z.string().uuid(),
|
|
11
|
+
quantity: z.number().positive(),
|
|
12
|
+
unit: z.string(),
|
|
13
|
+
reason: z.string(), // Simple explanation
|
|
14
|
+
estimatedCost: z.number().nonnegative().optional(),
|
|
18
15
|
});
|
|
19
16
|
// Soil test attributes schema (for JSON:API attributes object)
|
|
20
|
-
|
|
21
|
-
fieldId:
|
|
22
|
-
fieldName:
|
|
23
|
-
testDate:
|
|
24
|
-
testedBy:
|
|
25
|
-
labName:
|
|
26
|
-
cropAtTimeOfTest:
|
|
17
|
+
export const soilTestAttributesSchema = z.object({
|
|
18
|
+
fieldId: z.string().uuid(),
|
|
19
|
+
fieldName: z.string().optional(),
|
|
20
|
+
testDate: z.string().datetime(),
|
|
21
|
+
testedBy: z.string().nullable(),
|
|
22
|
+
labName: z.string().nullable(),
|
|
23
|
+
cropAtTimeOfTest: z.string().nullable(),
|
|
27
24
|
// Core properties
|
|
28
|
-
pH:
|
|
29
|
-
nitrogen:
|
|
30
|
-
nitrogenUnit:
|
|
31
|
-
phosphorus:
|
|
32
|
-
phosphorusUnit:
|
|
33
|
-
potassium:
|
|
34
|
-
potassiumUnit:
|
|
25
|
+
pH: z.number(),
|
|
26
|
+
nitrogen: z.number().nullable(),
|
|
27
|
+
nitrogenUnit: nutrientUnitSchema.nullable(),
|
|
28
|
+
phosphorus: z.number().nullable(),
|
|
29
|
+
phosphorusUnit: nutrientUnitSchema.nullable(),
|
|
30
|
+
potassium: z.number().nullable(),
|
|
31
|
+
potassiumUnit: nutrientUnitSchema.nullable(),
|
|
35
32
|
// Optional
|
|
36
|
-
organicMatter:
|
|
37
|
-
testCost:
|
|
38
|
-
notes:
|
|
39
|
-
documentUrl:
|
|
33
|
+
organicMatter: z.number().nullable(),
|
|
34
|
+
testCost: z.number().nullable(),
|
|
35
|
+
notes: z.string().nullable(),
|
|
36
|
+
documentUrl: z.string().url().nullable(),
|
|
40
37
|
// Recommendations (generated by backend)
|
|
41
|
-
recommendedFertilizers:
|
|
42
|
-
recommendations:
|
|
43
|
-
createdBy:
|
|
44
|
-
}).merge(
|
|
38
|
+
recommendedFertilizers: z.array(fertilizerRecommendationSchema).optional(),
|
|
39
|
+
recommendations: z.string().nullable().optional(), // Simple text recommendations
|
|
40
|
+
createdBy: z.string().uuid().nullable(),
|
|
41
|
+
}).merge(timestampsSchema);
|
|
45
42
|
// Soil test attributes for creation (input)
|
|
46
|
-
|
|
47
|
-
fieldId:
|
|
48
|
-
testDate:
|
|
49
|
-
testedBy:
|
|
50
|
-
labName:
|
|
51
|
-
cropAtTimeOfTest:
|
|
43
|
+
export const createSoilTestAttributesSchema = z.object({
|
|
44
|
+
fieldId: z.string().uuid(),
|
|
45
|
+
testDate: z.string().datetime(),
|
|
46
|
+
testedBy: z.string().optional(), // User ID or lab name
|
|
47
|
+
labName: z.string().optional(),
|
|
48
|
+
cropAtTimeOfTest: z.string().optional(), // What crop was growing when test was taken
|
|
52
49
|
// Core chemical properties
|
|
53
|
-
pH:
|
|
54
|
-
nitrogen:
|
|
55
|
-
nitrogenUnit:
|
|
56
|
-
phosphorus:
|
|
57
|
-
phosphorusUnit:
|
|
58
|
-
potassium:
|
|
59
|
-
potassiumUnit:
|
|
50
|
+
pH: z.number().min(0).max(14),
|
|
51
|
+
nitrogen: z.number().nonnegative().optional(),
|
|
52
|
+
nitrogenUnit: nutrientUnitSchema.optional(),
|
|
53
|
+
phosphorus: z.number().nonnegative().optional(),
|
|
54
|
+
phosphorusUnit: nutrientUnitSchema.optional(),
|
|
55
|
+
potassium: z.number().nonnegative().optional(),
|
|
56
|
+
potassiumUnit: nutrientUnitSchema.optional(),
|
|
60
57
|
// Optional
|
|
61
|
-
organicMatter:
|
|
62
|
-
testCost:
|
|
63
|
-
notes:
|
|
64
|
-
documentUrl:
|
|
58
|
+
organicMatter: z.number().nonnegative().optional(), // percentage
|
|
59
|
+
testCost: z.number().nonnegative().optional(),
|
|
60
|
+
notes: z.string().optional(),
|
|
61
|
+
documentUrl: z.string().url().optional(), // Link to uploaded test report
|
|
65
62
|
});
|
|
66
63
|
// Soil test attributes for update (input)
|
|
67
|
-
|
|
68
|
-
fieldId:
|
|
69
|
-
testDate:
|
|
64
|
+
export const updateSoilTestAttributesSchema = createSoilTestAttributesSchema.partial().extend({
|
|
65
|
+
fieldId: z.string().uuid().optional(),
|
|
66
|
+
testDate: z.string().datetime().optional(),
|
|
70
67
|
});
|
|
71
68
|
// Create soil test input (JSON:API format)
|
|
72
|
-
|
|
73
|
-
type:
|
|
74
|
-
attributes:
|
|
69
|
+
export const createSoilTestSchema = z.object({
|
|
70
|
+
type: z.literal('soil-tests'),
|
|
71
|
+
attributes: createSoilTestAttributesSchema,
|
|
75
72
|
});
|
|
76
73
|
// Update soil test input (JSON:API format)
|
|
77
|
-
|
|
78
|
-
type:
|
|
79
|
-
id:
|
|
80
|
-
attributes:
|
|
74
|
+
export const updateSoilTestSchema = z.object({
|
|
75
|
+
type: z.literal('soil-tests'),
|
|
76
|
+
id: z.string().uuid(),
|
|
77
|
+
attributes: updateSoilTestAttributesSchema,
|
|
81
78
|
});
|
|
82
79
|
// Soil test resource (JSON:API resource object)
|
|
83
|
-
|
|
80
|
+
export const soilTestResourceSchema = createJsonApiResourceSchema('soil-tests', soilTestAttributesSchema);
|
|
84
81
|
// Soil test detail resource with relationships
|
|
85
|
-
|
|
86
|
-
relationships:
|
|
87
|
-
field:
|
|
88
|
-
links:
|
|
89
|
-
related:
|
|
82
|
+
export const soilTestDetailResourceSchema = soilTestResourceSchema.extend({
|
|
83
|
+
relationships: z.object({
|
|
84
|
+
field: z.object({
|
|
85
|
+
links: z.object({
|
|
86
|
+
related: z.string(),
|
|
90
87
|
}),
|
|
91
88
|
}).optional(),
|
|
92
|
-
recommended_fertilizers:
|
|
93
|
-
links:
|
|
94
|
-
related:
|
|
89
|
+
recommended_fertilizers: z.object({
|
|
90
|
+
links: z.object({
|
|
91
|
+
related: z.string(),
|
|
95
92
|
}),
|
|
96
93
|
}).optional(),
|
|
97
94
|
}).optional(),
|
|
98
95
|
});
|
|
99
96
|
// Soil test responses (JSON:API format)
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
97
|
+
export const soilTestResponseSchema = jsonApiSingleResponseSchema(soilTestResourceSchema);
|
|
98
|
+
export const soilTestDetailResponseSchema = jsonApiSingleResponseSchema(soilTestDetailResourceSchema);
|
|
99
|
+
export const soilTestListResponseSchema = jsonApiCollectionResponseSchema(soilTestResourceSchema);
|