@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,121 +1,118 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.buyerListResponseSchema = exports.buyerResponseSchema = exports.supplierListResponseSchema = exports.supplierResponseSchema = exports.buyerResourceSchema = exports.supplierResourceSchema = exports.updateBuyerSchema = exports.createBuyerSchema = exports.updateSupplierSchema = exports.createSupplierSchema = exports.updateBuyerAttributesSchema = exports.createBuyerAttributesSchema = exports.buyerAttributesSchema = exports.updateSupplierAttributesSchema = exports.createSupplierAttributesSchema = exports.supplierAttributesSchema = exports.priceHistoryEntryAttributesSchema = exports.supplierTypeSchema = 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
|
* Supplier and buyer schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Supplier type enum
|
|
10
|
-
|
|
7
|
+
export const supplierTypeSchema = z.enum(['seed', 'fertilizer', 'pesticide', 'equipment', 'labor', 'other']);
|
|
11
8
|
// Price history entry attributes
|
|
12
|
-
|
|
13
|
-
date:
|
|
14
|
-
item:
|
|
15
|
-
price:
|
|
16
|
-
unit:
|
|
17
|
-
quantity:
|
|
18
|
-
notes:
|
|
9
|
+
export const priceHistoryEntryAttributesSchema = z.object({
|
|
10
|
+
date: z.string().datetime(),
|
|
11
|
+
item: z.string().nullable(), // For suppliers: product name; For buyers: crop name
|
|
12
|
+
price: z.number().positive(),
|
|
13
|
+
unit: z.string().nullable(),
|
|
14
|
+
quantity: z.number().positive().nullable(),
|
|
15
|
+
notes: z.string().nullable(),
|
|
19
16
|
});
|
|
20
17
|
// Supplier attributes schema (for JSON:API attributes object)
|
|
21
|
-
|
|
22
|
-
farmId:
|
|
23
|
-
name:
|
|
24
|
-
type:
|
|
25
|
-
contactPerson:
|
|
26
|
-
email:
|
|
27
|
-
phone:
|
|
28
|
-
address:
|
|
29
|
-
rating:
|
|
30
|
-
notes:
|
|
31
|
-
priceHistory:
|
|
32
|
-
}).merge(
|
|
18
|
+
export const supplierAttributesSchema = z.object({
|
|
19
|
+
farmId: z.string().uuid(),
|
|
20
|
+
name: z.string(),
|
|
21
|
+
type: supplierTypeSchema,
|
|
22
|
+
contactPerson: z.string().nullable(),
|
|
23
|
+
email: z.string().nullable(),
|
|
24
|
+
phone: z.string().nullable(),
|
|
25
|
+
address: z.string().nullable(),
|
|
26
|
+
rating: z.number().int().min(1).max(5).nullable(),
|
|
27
|
+
notes: z.string().nullable(),
|
|
28
|
+
priceHistory: z.array(priceHistoryEntryAttributesSchema).optional(),
|
|
29
|
+
}).merge(timestampsSchema);
|
|
33
30
|
// Create supplier attributes (input)
|
|
34
|
-
|
|
35
|
-
name:
|
|
36
|
-
type:
|
|
37
|
-
contactPerson:
|
|
38
|
-
email:
|
|
39
|
-
phone:
|
|
40
|
-
address:
|
|
41
|
-
rating:
|
|
42
|
-
notes:
|
|
31
|
+
export const createSupplierAttributesSchema = z.object({
|
|
32
|
+
name: z.string().min(1).max(200),
|
|
33
|
+
type: supplierTypeSchema,
|
|
34
|
+
contactPerson: z.string().optional(),
|
|
35
|
+
email: z.string().email().optional(),
|
|
36
|
+
phone: z.string().optional(),
|
|
37
|
+
address: z.string().optional(),
|
|
38
|
+
rating: z.number().int().min(1).max(5).optional(), // 1-5 stars
|
|
39
|
+
notes: z.string().optional(),
|
|
43
40
|
});
|
|
44
41
|
// Update supplier attributes (input)
|
|
45
|
-
|
|
46
|
-
name:
|
|
47
|
-
type:
|
|
48
|
-
contactPerson:
|
|
49
|
-
email:
|
|
50
|
-
phone:
|
|
51
|
-
address:
|
|
52
|
-
rating:
|
|
53
|
-
notes:
|
|
42
|
+
export const updateSupplierAttributesSchema = z.object({
|
|
43
|
+
name: z.string().min(1).max(200).optional(),
|
|
44
|
+
type: supplierTypeSchema.optional(),
|
|
45
|
+
contactPerson: z.string().nullable().optional(),
|
|
46
|
+
email: z.string().email().nullable().optional(),
|
|
47
|
+
phone: z.string().nullable().optional(),
|
|
48
|
+
address: z.string().nullable().optional(),
|
|
49
|
+
rating: z.number().int().min(1).max(5).nullable().optional(),
|
|
50
|
+
notes: z.string().nullable().optional(),
|
|
54
51
|
});
|
|
55
52
|
// Buyer attributes schema (for JSON:API attributes object)
|
|
56
|
-
|
|
57
|
-
farmId:
|
|
58
|
-
name:
|
|
59
|
-
contactPerson:
|
|
60
|
-
email:
|
|
61
|
-
phone:
|
|
62
|
-
address:
|
|
63
|
-
crops:
|
|
64
|
-
rating:
|
|
65
|
-
notes:
|
|
66
|
-
priceHistory:
|
|
67
|
-
}).merge(
|
|
53
|
+
export const buyerAttributesSchema = z.object({
|
|
54
|
+
farmId: z.string().uuid(),
|
|
55
|
+
name: z.string(),
|
|
56
|
+
contactPerson: z.string().nullable(),
|
|
57
|
+
email: z.string().nullable(),
|
|
58
|
+
phone: z.string().nullable(),
|
|
59
|
+
address: z.string().nullable(),
|
|
60
|
+
crops: z.array(z.string()).optional(), // Crops they buy
|
|
61
|
+
rating: z.number().int().min(1).max(5).nullable(),
|
|
62
|
+
notes: z.string().nullable(),
|
|
63
|
+
priceHistory: z.array(priceHistoryEntryAttributesSchema).optional(),
|
|
64
|
+
}).merge(timestampsSchema);
|
|
68
65
|
// Create buyer attributes (input)
|
|
69
|
-
|
|
70
|
-
name:
|
|
71
|
-
contactPerson:
|
|
72
|
-
email:
|
|
73
|
-
phone:
|
|
74
|
-
address:
|
|
75
|
-
crops:
|
|
76
|
-
rating:
|
|
77
|
-
notes:
|
|
66
|
+
export const createBuyerAttributesSchema = z.object({
|
|
67
|
+
name: z.string().min(1).max(200),
|
|
68
|
+
contactPerson: z.string().optional(),
|
|
69
|
+
email: z.string().email().optional(),
|
|
70
|
+
phone: z.string().optional(),
|
|
71
|
+
address: z.string().optional(),
|
|
72
|
+
crops: z.array(z.string()).optional(), // Crops they buy
|
|
73
|
+
rating: z.number().int().min(1).max(5).optional(),
|
|
74
|
+
notes: z.string().optional(),
|
|
78
75
|
});
|
|
79
76
|
// Update buyer attributes (input)
|
|
80
|
-
|
|
81
|
-
name:
|
|
82
|
-
contactPerson:
|
|
83
|
-
email:
|
|
84
|
-
phone:
|
|
85
|
-
address:
|
|
86
|
-
crops:
|
|
87
|
-
rating:
|
|
88
|
-
notes:
|
|
77
|
+
export const updateBuyerAttributesSchema = z.object({
|
|
78
|
+
name: z.string().min(1).max(200).optional(),
|
|
79
|
+
contactPerson: z.string().nullable().optional(),
|
|
80
|
+
email: z.string().email().nullable().optional(),
|
|
81
|
+
phone: z.string().nullable().optional(),
|
|
82
|
+
address: z.string().nullable().optional(),
|
|
83
|
+
crops: z.array(z.string()).optional(),
|
|
84
|
+
rating: z.number().int().min(1).max(5).nullable().optional(),
|
|
85
|
+
notes: z.string().nullable().optional(),
|
|
89
86
|
});
|
|
90
87
|
// Create supplier input (JSON:API format)
|
|
91
|
-
|
|
92
|
-
type:
|
|
93
|
-
attributes:
|
|
88
|
+
export const createSupplierSchema = z.object({
|
|
89
|
+
type: z.literal('suppliers'),
|
|
90
|
+
attributes: createSupplierAttributesSchema,
|
|
94
91
|
});
|
|
95
92
|
// Update supplier input (JSON:API format)
|
|
96
|
-
|
|
97
|
-
type:
|
|
98
|
-
id:
|
|
99
|
-
attributes:
|
|
93
|
+
export const updateSupplierSchema = z.object({
|
|
94
|
+
type: z.literal('suppliers'),
|
|
95
|
+
id: z.string().uuid(),
|
|
96
|
+
attributes: updateSupplierAttributesSchema,
|
|
100
97
|
});
|
|
101
98
|
// Create buyer input (JSON:API format)
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
attributes:
|
|
99
|
+
export const createBuyerSchema = z.object({
|
|
100
|
+
type: z.literal('buyers'),
|
|
101
|
+
attributes: createBuyerAttributesSchema,
|
|
105
102
|
});
|
|
106
103
|
// Update buyer input (JSON:API format)
|
|
107
|
-
|
|
108
|
-
type:
|
|
109
|
-
id:
|
|
110
|
-
attributes:
|
|
104
|
+
export const updateBuyerSchema = z.object({
|
|
105
|
+
type: z.literal('buyers'),
|
|
106
|
+
id: z.string().uuid(),
|
|
107
|
+
attributes: updateBuyerAttributesSchema,
|
|
111
108
|
});
|
|
112
109
|
// Supplier resource (JSON:API resource object)
|
|
113
|
-
|
|
110
|
+
export const supplierResourceSchema = createJsonApiResourceSchema('suppliers', supplierAttributesSchema);
|
|
114
111
|
// Buyer resource (JSON:API resource object)
|
|
115
|
-
|
|
112
|
+
export const buyerResourceSchema = createJsonApiResourceSchema('buyers', buyerAttributesSchema);
|
|
116
113
|
// Supplier responses (JSON:API format)
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
export const supplierResponseSchema = jsonApiSingleResponseSchema(supplierResourceSchema);
|
|
115
|
+
export const supplierListResponseSchema = jsonApiCollectionResponseSchema(supplierResourceSchema);
|
|
119
116
|
// Buyer responses (JSON:API format)
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
export const buyerResponseSchema = jsonApiSingleResponseSchema(buyerResourceSchema);
|
|
118
|
+
export const buyerListResponseSchema = jsonApiCollectionResponseSchema(buyerResourceSchema);
|
|
@@ -1,93 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.taskListResponseSchema = exports.taskDetailResponseSchema = exports.taskResponseSchema = exports.taskDetailResourceSchema = exports.taskResourceSchema = exports.addTaskNoteSchema = exports.completeTaskSchema = exports.updateTaskSchema = exports.createTaskSchema = exports.addTaskNoteAttributesSchema = exports.completeTaskAttributesSchema = exports.updateTaskAttributesSchema = exports.createTaskAttributesSchema = exports.taskAttributesSchema = exports.taskNoteSchema = exports.taskStatusSchema = 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
|
* Task schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Task status enum
|
|
10
|
-
|
|
7
|
+
export const taskStatusSchema = z.enum(['pending', 'in-progress', 'completed', 'cancelled']);
|
|
11
8
|
// Task note schema (embedded in task attributes)
|
|
12
|
-
|
|
13
|
-
id:
|
|
14
|
-
authorId:
|
|
15
|
-
authorName:
|
|
16
|
-
text:
|
|
17
|
-
timestamp:
|
|
18
|
-
documentIds:
|
|
19
|
-
documents:
|
|
20
|
-
id:
|
|
21
|
-
fileUrl:
|
|
22
|
-
fileExtension:
|
|
23
|
-
fileName:
|
|
9
|
+
export const taskNoteSchema = z.object({
|
|
10
|
+
id: z.string().uuid(),
|
|
11
|
+
authorId: z.string().uuid(),
|
|
12
|
+
authorName: z.string(),
|
|
13
|
+
text: z.string(),
|
|
14
|
+
timestamp: z.string().datetime(),
|
|
15
|
+
documentIds: z.array(z.string().uuid()).optional(), // Document IDs referenced in this note
|
|
16
|
+
documents: z.array(z.object({
|
|
17
|
+
id: z.string().uuid(),
|
|
18
|
+
fileUrl: z.string(), // View URL path: /documents/view/{docId}
|
|
19
|
+
fileExtension: z.string().nullable().optional(),
|
|
20
|
+
fileName: z.string().optional(),
|
|
24
21
|
})).optional(), // Document relationships (included when fetching)
|
|
25
22
|
});
|
|
26
23
|
// Task attributes schema (for JSON:API attributes object)
|
|
27
|
-
|
|
28
|
-
title:
|
|
29
|
-
fieldId:
|
|
30
|
-
fieldName:
|
|
31
|
-
date:
|
|
32
|
-
status:
|
|
33
|
-
category:
|
|
24
|
+
export const taskAttributesSchema = z.object({
|
|
25
|
+
title: z.string(),
|
|
26
|
+
fieldId: z.string().uuid(),
|
|
27
|
+
fieldName: z.string().optional(), // Included for convenience
|
|
28
|
+
date: z.string().datetime(),
|
|
29
|
+
status: taskStatusSchema,
|
|
30
|
+
category: z.string(), // Task category
|
|
34
31
|
// Inventory linking
|
|
35
|
-
inventoryItemId:
|
|
36
|
-
inventoryItemName:
|
|
37
|
-
plannedQuantity:
|
|
38
|
-
actualQuantity:
|
|
32
|
+
inventoryItemId: z.string().uuid().nullable(),
|
|
33
|
+
inventoryItemName: z.string().nullable().optional(),
|
|
34
|
+
plannedQuantity: z.number().nullable(),
|
|
35
|
+
actualQuantity: z.number().nullable(),
|
|
39
36
|
// Team collaboration
|
|
40
|
-
assignedTo:
|
|
41
|
-
assignedToName:
|
|
42
|
-
assignedBy:
|
|
43
|
-
assignedDate:
|
|
37
|
+
assignedTo: z.string().uuid().nullable(),
|
|
38
|
+
assignedToName: z.string().nullable().optional(),
|
|
39
|
+
assignedBy: z.string().uuid().nullable(),
|
|
40
|
+
assignedDate: z.string().datetime().nullable(),
|
|
44
41
|
// Notes
|
|
45
|
-
notes:
|
|
42
|
+
notes: z.array(taskNoteSchema).optional(),
|
|
46
43
|
// Autonomous Agent Source Tracking
|
|
47
|
-
source:
|
|
48
|
-
type:
|
|
49
|
-
id:
|
|
44
|
+
source: z.object({
|
|
45
|
+
type: z.string(), // e.g., 'observation', 'satellite_monitoring', 'manual'
|
|
46
|
+
id: z.string(), // The ID of the source entity (e.g., observationId, alertId)
|
|
50
47
|
}).nullable().optional(),
|
|
51
|
-
contributingSources:
|
|
52
|
-
type:
|
|
53
|
-
id:
|
|
48
|
+
contributingSources: z.array(z.object({
|
|
49
|
+
type: z.string(),
|
|
50
|
+
id: z.string(),
|
|
54
51
|
})).optional(),
|
|
55
|
-
}).merge(
|
|
52
|
+
}).merge(timestampsSchema);
|
|
56
53
|
// Task attributes for creation (input)
|
|
57
|
-
|
|
58
|
-
title:
|
|
59
|
-
fieldId:
|
|
60
|
-
date:
|
|
61
|
-
status:
|
|
62
|
-
category:
|
|
54
|
+
export const createTaskAttributesSchema = z.object({
|
|
55
|
+
title: z.string().min(1).max(200),
|
|
56
|
+
fieldId: z.string().uuid(),
|
|
57
|
+
date: z.string().datetime(),
|
|
58
|
+
status: taskStatusSchema.default('pending').optional(),
|
|
59
|
+
category: z.string().min(1).max(100), // Required - frontend should use default category if user doesn't select
|
|
63
60
|
// Inventory linking
|
|
64
|
-
inventoryItemId:
|
|
65
|
-
plannedQuantity:
|
|
61
|
+
inventoryItemId: z.string().uuid().optional(),
|
|
62
|
+
plannedQuantity: z.number().positive().optional(),
|
|
66
63
|
// Team collaboration
|
|
67
|
-
assignedTo:
|
|
68
|
-
notes:
|
|
64
|
+
assignedTo: z.string().uuid().optional(), // TeamMember ID
|
|
65
|
+
notes: z.string().optional(), // Initial note
|
|
69
66
|
});
|
|
70
67
|
// Task attributes for update (input)
|
|
71
|
-
|
|
72
|
-
title:
|
|
73
|
-
fieldId:
|
|
74
|
-
date:
|
|
75
|
-
status:
|
|
76
|
-
category:
|
|
77
|
-
inventoryItemId:
|
|
78
|
-
plannedQuantity:
|
|
79
|
-
actualQuantity:
|
|
80
|
-
assignedTo:
|
|
68
|
+
export const updateTaskAttributesSchema = z.object({
|
|
69
|
+
title: z.string().min(1).max(200).optional(),
|
|
70
|
+
fieldId: z.string().uuid().optional(),
|
|
71
|
+
date: z.string().datetime().optional(),
|
|
72
|
+
status: taskStatusSchema.optional(),
|
|
73
|
+
category: z.string().min(1).max(100).optional(),
|
|
74
|
+
inventoryItemId: z.string().uuid().optional(),
|
|
75
|
+
plannedQuantity: z.number().positive().optional(),
|
|
76
|
+
actualQuantity: z.number().positive().optional(), // Set when completing task
|
|
77
|
+
assignedTo: z.string().uuid().nullable().optional(),
|
|
81
78
|
});
|
|
82
79
|
// Complete task attributes (for task completion workflow)
|
|
83
|
-
|
|
84
|
-
actualQuantity:
|
|
85
|
-
notes:
|
|
80
|
+
export const completeTaskAttributesSchema = z.object({
|
|
81
|
+
actualQuantity: z.number().positive().optional(), // Actual quantity used (for inventory deduction)
|
|
82
|
+
notes: z.string().optional(), // Completion notes
|
|
86
83
|
});
|
|
87
84
|
// Add note to task attributes
|
|
88
|
-
|
|
89
|
-
text:
|
|
90
|
-
documentIds:
|
|
85
|
+
export const addTaskNoteAttributesSchema = z.object({
|
|
86
|
+
text: z.string().default(''),
|
|
87
|
+
documentIds: z.array(z.string().uuid()).optional(), // Document IDs to attach to this note
|
|
91
88
|
}).refine((data) => {
|
|
92
89
|
// At least one of text (non-empty) or documentIds must be provided
|
|
93
90
|
const hasText = data.text && data.text.trim().length > 0;
|
|
@@ -98,50 +95,50 @@ exports.addTaskNoteAttributesSchema = zod_1.z.object({
|
|
|
98
95
|
path: ['text'],
|
|
99
96
|
});
|
|
100
97
|
// Create task input (JSON:API format)
|
|
101
|
-
|
|
102
|
-
type:
|
|
103
|
-
attributes:
|
|
98
|
+
export const createTaskSchema = z.object({
|
|
99
|
+
type: z.literal('tasks'),
|
|
100
|
+
attributes: createTaskAttributesSchema,
|
|
104
101
|
});
|
|
105
102
|
// Update task input (JSON:API format)
|
|
106
|
-
|
|
107
|
-
type:
|
|
108
|
-
id:
|
|
109
|
-
attributes:
|
|
103
|
+
export const updateTaskSchema = z.object({
|
|
104
|
+
type: z.literal('tasks'),
|
|
105
|
+
id: z.string().uuid(),
|
|
106
|
+
attributes: updateTaskAttributesSchema,
|
|
110
107
|
});
|
|
111
108
|
// Complete task input (JSON:API format)
|
|
112
|
-
|
|
113
|
-
type:
|
|
114
|
-
id:
|
|
115
|
-
attributes:
|
|
109
|
+
export const completeTaskSchema = z.object({
|
|
110
|
+
type: z.literal('tasks'),
|
|
111
|
+
id: z.string().uuid(),
|
|
112
|
+
attributes: completeTaskAttributesSchema,
|
|
116
113
|
});
|
|
117
114
|
// Add note to task input (JSON:API format)
|
|
118
|
-
|
|
119
|
-
type:
|
|
120
|
-
attributes:
|
|
115
|
+
export const addTaskNoteSchema = z.object({
|
|
116
|
+
type: z.literal('task-notes'),
|
|
117
|
+
attributes: addTaskNoteAttributesSchema,
|
|
121
118
|
});
|
|
122
119
|
// Task resource (JSON:API resource object)
|
|
123
|
-
|
|
120
|
+
export const taskResourceSchema = createJsonApiResourceSchema('tasks', taskAttributesSchema);
|
|
124
121
|
// Task detail resource with relationships
|
|
125
|
-
|
|
126
|
-
relationships:
|
|
127
|
-
field:
|
|
128
|
-
links:
|
|
129
|
-
related:
|
|
122
|
+
export const taskDetailResourceSchema = taskResourceSchema.extend({
|
|
123
|
+
relationships: z.object({
|
|
124
|
+
field: z.object({
|
|
125
|
+
links: z.object({
|
|
126
|
+
related: z.string(),
|
|
130
127
|
}),
|
|
131
128
|
}).optional(),
|
|
132
|
-
inventory_item:
|
|
133
|
-
links:
|
|
134
|
-
related:
|
|
129
|
+
inventory_item: z.object({
|
|
130
|
+
links: z.object({
|
|
131
|
+
related: z.string(),
|
|
135
132
|
}),
|
|
136
133
|
}).optional(),
|
|
137
|
-
assigned_to:
|
|
138
|
-
links:
|
|
139
|
-
related:
|
|
134
|
+
assigned_to: z.object({
|
|
135
|
+
links: z.object({
|
|
136
|
+
related: z.string(),
|
|
140
137
|
}),
|
|
141
138
|
}).optional(),
|
|
142
139
|
}).optional(),
|
|
143
140
|
});
|
|
144
141
|
// Task responses (JSON:API format)
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
142
|
+
export const taskResponseSchema = jsonApiSingleResponseSchema(taskResourceSchema);
|
|
143
|
+
export const taskDetailResponseSchema = jsonApiSingleResponseSchema(taskDetailResourceSchema);
|
|
144
|
+
export const taskListResponseSchema = jsonApiCollectionResponseSchema(taskResourceSchema);
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.teamMemberListResponseSchema = exports.teamMemberResponseSchema = exports.teamMemberResourceSchema = exports.updateTeamMemberSchema = exports.createTeamMemberSchema = exports.updateTeamMemberAttributesSchema = exports.createTeamMemberAttributesSchema = exports.teamMemberAttributesSchema = exports.teamMemberRoleSchema = 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
|
* Team management schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Team member role enum
|
|
10
|
-
|
|
7
|
+
export const teamMemberRoleSchema = z.enum([
|
|
11
8
|
'owner',
|
|
12
9
|
'farm-manager',
|
|
13
10
|
'agronomist',
|
|
@@ -16,46 +13,46 @@ exports.teamMemberRoleSchema = zod_1.z.enum([
|
|
|
16
13
|
'other',
|
|
17
14
|
]);
|
|
18
15
|
// Team member attributes schema (for JSON:API attributes object)
|
|
19
|
-
|
|
20
|
-
farmId:
|
|
21
|
-
userId:
|
|
22
|
-
name:
|
|
23
|
-
email:
|
|
24
|
-
role:
|
|
25
|
-
phone:
|
|
16
|
+
export const teamMemberAttributesSchema = z.object({
|
|
17
|
+
farmId: z.string().uuid(),
|
|
18
|
+
userId: z.string().uuid().nullable(), // User account ID (if user has account)
|
|
19
|
+
name: z.string(),
|
|
20
|
+
email: z.string().email(),
|
|
21
|
+
role: teamMemberRoleSchema,
|
|
22
|
+
phone: z.string().nullable(),
|
|
26
23
|
// Statistics (optional, for team dashboard)
|
|
27
|
-
tasksAssigned:
|
|
28
|
-
tasksCompleted:
|
|
29
|
-
tasksPending:
|
|
30
|
-
}).merge(
|
|
24
|
+
tasksAssigned: z.number().int().nonnegative().optional(),
|
|
25
|
+
tasksCompleted: z.number().int().nonnegative().optional(),
|
|
26
|
+
tasksPending: z.number().int().nonnegative().optional(),
|
|
27
|
+
}).merge(timestampsSchema);
|
|
31
28
|
// Create team member attributes (input)
|
|
32
|
-
|
|
33
|
-
name:
|
|
34
|
-
email:
|
|
35
|
-
role:
|
|
36
|
-
phone:
|
|
37
|
-
message:
|
|
29
|
+
export const createTeamMemberAttributesSchema = z.object({
|
|
30
|
+
name: z.string().min(1).max(200),
|
|
31
|
+
email: z.string().email(),
|
|
32
|
+
role: teamMemberRoleSchema,
|
|
33
|
+
phone: z.string().optional(),
|
|
34
|
+
message: z.string().optional(), // Optional personal message for invitation
|
|
38
35
|
});
|
|
39
36
|
// Update team member attributes (input)
|
|
40
|
-
|
|
41
|
-
name:
|
|
42
|
-
email:
|
|
43
|
-
role:
|
|
44
|
-
phone:
|
|
37
|
+
export const updateTeamMemberAttributesSchema = z.object({
|
|
38
|
+
name: z.string().min(1).max(200).optional(),
|
|
39
|
+
email: z.string().email().optional(),
|
|
40
|
+
role: teamMemberRoleSchema.optional(),
|
|
41
|
+
phone: z.string().nullable().optional(),
|
|
45
42
|
});
|
|
46
43
|
// Create team member input (JSON:API format)
|
|
47
|
-
|
|
48
|
-
type:
|
|
49
|
-
attributes:
|
|
44
|
+
export const createTeamMemberSchema = z.object({
|
|
45
|
+
type: z.literal('team-members'),
|
|
46
|
+
attributes: createTeamMemberAttributesSchema,
|
|
50
47
|
});
|
|
51
48
|
// Update team member input (JSON:API format)
|
|
52
|
-
|
|
53
|
-
type:
|
|
54
|
-
id:
|
|
55
|
-
attributes:
|
|
49
|
+
export const updateTeamMemberSchema = z.object({
|
|
50
|
+
type: z.literal('team-members'),
|
|
51
|
+
id: z.string().uuid(),
|
|
52
|
+
attributes: updateTeamMemberAttributesSchema,
|
|
56
53
|
});
|
|
57
54
|
// Team member resource (JSON:API resource object)
|
|
58
|
-
|
|
55
|
+
export const teamMemberResourceSchema = createJsonApiResourceSchema('team-members', teamMemberAttributesSchema);
|
|
59
56
|
// Team member responses (JSON:API format)
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
export const teamMemberResponseSchema = jsonApiSingleResponseSchema(teamMemberResourceSchema);
|
|
58
|
+
export const teamMemberListResponseSchema = jsonApiCollectionResponseSchema(teamMemberResourceSchema);
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.userResponseSchema = exports.userResourceSchema = exports.updateProfileSchema = exports.updateUserAttributesSchema = exports.userAttributesSchema = 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
|
* User profile schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// User attributes schema
|
|
10
|
-
|
|
11
|
-
name:
|
|
12
|
-
email:
|
|
13
|
-
phone:
|
|
14
|
-
emailVerified:
|
|
15
|
-
avatar:
|
|
16
|
-
}).merge(
|
|
7
|
+
export const userAttributesSchema = z.object({
|
|
8
|
+
name: z.string(),
|
|
9
|
+
email: z.string().email(),
|
|
10
|
+
phone: z.string().nullable(),
|
|
11
|
+
emailVerified: z.boolean(),
|
|
12
|
+
avatar: z.string().url().nullable(),
|
|
13
|
+
}).merge(timestampsSchema);
|
|
17
14
|
// Update user profile attributes
|
|
18
|
-
|
|
19
|
-
name:
|
|
20
|
-
phone:
|
|
21
|
-
avatar:
|
|
15
|
+
export const updateUserAttributesSchema = z.object({
|
|
16
|
+
name: z.string().min(1).max(200).optional(),
|
|
17
|
+
phone: z.string().optional(),
|
|
18
|
+
avatar: z.string().url().nullable().optional(),
|
|
22
19
|
});
|
|
23
20
|
// Update user profile input (JSON:API format)
|
|
24
|
-
|
|
25
|
-
type:
|
|
26
|
-
id:
|
|
27
|
-
attributes:
|
|
21
|
+
export const updateProfileSchema = z.object({
|
|
22
|
+
type: z.literal('users'),
|
|
23
|
+
id: z.string().uuid(),
|
|
24
|
+
attributes: updateUserAttributesSchema,
|
|
28
25
|
});
|
|
29
26
|
// User resource (JSON:API)
|
|
30
|
-
|
|
27
|
+
export const userResourceSchema = createJsonApiResourceSchema('users', userAttributesSchema);
|
|
31
28
|
// User response (JSON:API format)
|
|
32
|
-
|
|
29
|
+
export const userResponseSchema = jsonApiSingleResponseSchema(userResourceSchema);
|