@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.
Files changed (57) hide show
  1. package/dist/index.js +50 -92
  2. package/dist/routes/admin.routes.js +13 -16
  3. package/dist/routes/agent-workflows.routes.js +81 -84
  4. package/dist/routes/agents.routes.js +29 -32
  5. package/dist/routes/analytics.routes.js +11 -14
  6. package/dist/routes/auth.routes.js +55 -58
  7. package/dist/routes/categories.routes.js +23 -26
  8. package/dist/routes/documents.routes.js +67 -70
  9. package/dist/routes/equipment.routes.js +55 -58
  10. package/dist/routes/farms.routes.js +32 -35
  11. package/dist/routes/field-monitoring.routes.d.ts +8 -1
  12. package/dist/routes/field-monitoring.routes.d.ts.map +1 -1
  13. package/dist/routes/field-monitoring.routes.js +77 -74
  14. package/dist/routes/field-observations.routes.js +41 -44
  15. package/dist/routes/fields.routes.js +44 -47
  16. package/dist/routes/finance.routes.js +121 -124
  17. package/dist/routes/harvest.routes.js +46 -49
  18. package/dist/routes/health.routes.js +6 -9
  19. package/dist/routes/index.js +51 -54
  20. package/dist/routes/input-usage.routes.js +14 -17
  21. package/dist/routes/inventory.routes.js +57 -60
  22. package/dist/routes/seasonal-plans.routes.js +14 -17
  23. package/dist/routes/soil-tests.routes.js +45 -48
  24. package/dist/routes/suppliers.routes.js +70 -73
  25. package/dist/routes/tasks.routes.js +65 -68
  26. package/dist/routes/team.routes.d.ts +306 -0
  27. package/dist/routes/team.routes.d.ts.map +1 -1
  28. package/dist/routes/team.routes.js +79 -60
  29. package/dist/routes/users.routes.js +13 -16
  30. package/dist/routes/weather.routes.js +10 -13
  31. package/dist/schemas/admin.schemas.js +43 -46
  32. package/dist/schemas/agent-workflows.schemas.js +34 -37
  33. package/dist/schemas/agents.schemas.js +46 -49
  34. package/dist/schemas/analytics.schemas.js +51 -54
  35. package/dist/schemas/auth.schemas.js +96 -99
  36. package/dist/schemas/categories.schemas.js +27 -30
  37. package/dist/schemas/common.schemas.js +89 -95
  38. package/dist/schemas/documents.schemas.js +59 -62
  39. package/dist/schemas/equipment.schemas.js +86 -89
  40. package/dist/schemas/farms.schemas.js +40 -43
  41. package/dist/schemas/field-monitoring.schemas.js +207 -210
  42. package/dist/schemas/field-observations.schemas.js +93 -96
  43. package/dist/schemas/fields.schemas.js +82 -85
  44. package/dist/schemas/finance.schemas.js +134 -137
  45. package/dist/schemas/harvest.schemas.js +46 -49
  46. package/dist/schemas/health.schemas.js +14 -17
  47. package/dist/schemas/input-usage.schemas.js +21 -24
  48. package/dist/schemas/inventory.schemas.js +58 -61
  49. package/dist/schemas/recommendations.schemas.js +22 -25
  50. package/dist/schemas/seasonal-plans.schemas.js +21 -24
  51. package/dist/schemas/soil-tests.schemas.js +70 -73
  52. package/dist/schemas/suppliers.schemas.js +90 -93
  53. package/dist/schemas/tasks.schemas.js +93 -96
  54. package/dist/schemas/team.schemas.js +35 -38
  55. package/dist/schemas/users.schemas.js +19 -22
  56. package/dist/schemas/weather.schemas.js +32 -35
  57. package/package.json +9 -1
@@ -1,121 +1,118 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.supplierTypeSchema = zod_1.z.enum(['seed', 'fertilizer', 'pesticide', 'equipment', 'labor', 'other']);
7
+ export const supplierTypeSchema = z.enum(['seed', 'fertilizer', 'pesticide', 'equipment', 'labor', 'other']);
11
8
  // Price history entry attributes
12
- exports.priceHistoryEntryAttributesSchema = zod_1.z.object({
13
- date: zod_1.z.string().datetime(),
14
- item: zod_1.z.string().nullable(), // For suppliers: product name; For buyers: crop name
15
- price: zod_1.z.number().positive(),
16
- unit: zod_1.z.string().nullable(),
17
- quantity: zod_1.z.number().positive().nullable(),
18
- notes: zod_1.z.string().nullable(),
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
- exports.supplierAttributesSchema = zod_1.z.object({
22
- farmId: zod_1.z.string().uuid(),
23
- name: zod_1.z.string(),
24
- type: exports.supplierTypeSchema,
25
- contactPerson: zod_1.z.string().nullable(),
26
- email: zod_1.z.string().nullable(),
27
- phone: zod_1.z.string().nullable(),
28
- address: zod_1.z.string().nullable(),
29
- rating: zod_1.z.number().int().min(1).max(5).nullable(),
30
- notes: zod_1.z.string().nullable(),
31
- priceHistory: zod_1.z.array(exports.priceHistoryEntryAttributesSchema).optional(),
32
- }).merge(common_schemas_1.timestampsSchema);
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
- exports.createSupplierAttributesSchema = zod_1.z.object({
35
- name: zod_1.z.string().min(1).max(200),
36
- type: exports.supplierTypeSchema,
37
- contactPerson: zod_1.z.string().optional(),
38
- email: zod_1.z.string().email().optional(),
39
- phone: zod_1.z.string().optional(),
40
- address: zod_1.z.string().optional(),
41
- rating: zod_1.z.number().int().min(1).max(5).optional(), // 1-5 stars
42
- notes: zod_1.z.string().optional(),
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
- exports.updateSupplierAttributesSchema = zod_1.z.object({
46
- name: zod_1.z.string().min(1).max(200).optional(),
47
- type: exports.supplierTypeSchema.optional(),
48
- contactPerson: zod_1.z.string().nullable().optional(),
49
- email: zod_1.z.string().email().nullable().optional(),
50
- phone: zod_1.z.string().nullable().optional(),
51
- address: zod_1.z.string().nullable().optional(),
52
- rating: zod_1.z.number().int().min(1).max(5).nullable().optional(),
53
- notes: zod_1.z.string().nullable().optional(),
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
- exports.buyerAttributesSchema = zod_1.z.object({
57
- farmId: zod_1.z.string().uuid(),
58
- name: zod_1.z.string(),
59
- contactPerson: zod_1.z.string().nullable(),
60
- email: zod_1.z.string().nullable(),
61
- phone: zod_1.z.string().nullable(),
62
- address: zod_1.z.string().nullable(),
63
- crops: zod_1.z.array(zod_1.z.string()).optional(), // Crops they buy
64
- rating: zod_1.z.number().int().min(1).max(5).nullable(),
65
- notes: zod_1.z.string().nullable(),
66
- priceHistory: zod_1.z.array(exports.priceHistoryEntryAttributesSchema).optional(),
67
- }).merge(common_schemas_1.timestampsSchema);
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
- exports.createBuyerAttributesSchema = zod_1.z.object({
70
- name: zod_1.z.string().min(1).max(200),
71
- contactPerson: zod_1.z.string().optional(),
72
- email: zod_1.z.string().email().optional(),
73
- phone: zod_1.z.string().optional(),
74
- address: zod_1.z.string().optional(),
75
- crops: zod_1.z.array(zod_1.z.string()).optional(), // Crops they buy
76
- rating: zod_1.z.number().int().min(1).max(5).optional(),
77
- notes: zod_1.z.string().optional(),
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
- exports.updateBuyerAttributesSchema = zod_1.z.object({
81
- name: zod_1.z.string().min(1).max(200).optional(),
82
- contactPerson: zod_1.z.string().nullable().optional(),
83
- email: zod_1.z.string().email().nullable().optional(),
84
- phone: zod_1.z.string().nullable().optional(),
85
- address: zod_1.z.string().nullable().optional(),
86
- crops: zod_1.z.array(zod_1.z.string()).optional(),
87
- rating: zod_1.z.number().int().min(1).max(5).nullable().optional(),
88
- notes: zod_1.z.string().nullable().optional(),
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
- exports.createSupplierSchema = zod_1.z.object({
92
- type: zod_1.z.literal('suppliers'),
93
- attributes: exports.createSupplierAttributesSchema,
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
- exports.updateSupplierSchema = zod_1.z.object({
97
- type: zod_1.z.literal('suppliers'),
98
- id: zod_1.z.string().uuid(),
99
- attributes: exports.updateSupplierAttributesSchema,
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
- exports.createBuyerSchema = zod_1.z.object({
103
- type: zod_1.z.literal('buyers'),
104
- attributes: exports.createBuyerAttributesSchema,
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
- exports.updateBuyerSchema = zod_1.z.object({
108
- type: zod_1.z.literal('buyers'),
109
- id: zod_1.z.string().uuid(),
110
- attributes: exports.updateBuyerAttributesSchema,
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
- exports.supplierResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('suppliers', exports.supplierAttributesSchema);
110
+ export const supplierResourceSchema = createJsonApiResourceSchema('suppliers', supplierAttributesSchema);
114
111
  // Buyer resource (JSON:API resource object)
115
- exports.buyerResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('buyers', exports.buyerAttributesSchema);
112
+ export const buyerResourceSchema = createJsonApiResourceSchema('buyers', buyerAttributesSchema);
116
113
  // Supplier responses (JSON:API format)
117
- exports.supplierResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.supplierResourceSchema);
118
- exports.supplierListResponseSchema = (0, common_schemas_1.jsonApiCollectionResponseSchema)(exports.supplierResourceSchema);
114
+ export const supplierResponseSchema = jsonApiSingleResponseSchema(supplierResourceSchema);
115
+ export const supplierListResponseSchema = jsonApiCollectionResponseSchema(supplierResourceSchema);
119
116
  // Buyer responses (JSON:API format)
120
- exports.buyerResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.buyerResourceSchema);
121
- exports.buyerListResponseSchema = (0, common_schemas_1.jsonApiCollectionResponseSchema)(exports.buyerResourceSchema);
117
+ export const buyerResponseSchema = jsonApiSingleResponseSchema(buyerResourceSchema);
118
+ export const buyerListResponseSchema = jsonApiCollectionResponseSchema(buyerResourceSchema);
@@ -1,93 +1,90 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.taskStatusSchema = zod_1.z.enum(['pending', 'in-progress', 'completed', 'cancelled']);
7
+ export const taskStatusSchema = z.enum(['pending', 'in-progress', 'completed', 'cancelled']);
11
8
  // Task note schema (embedded in task attributes)
12
- exports.taskNoteSchema = zod_1.z.object({
13
- id: zod_1.z.string().uuid(),
14
- authorId: zod_1.z.string().uuid(),
15
- authorName: zod_1.z.string(),
16
- text: zod_1.z.string(),
17
- timestamp: zod_1.z.string().datetime(),
18
- documentIds: zod_1.z.array(zod_1.z.string().uuid()).optional(), // Document IDs referenced in this note
19
- documents: zod_1.z.array(zod_1.z.object({
20
- id: zod_1.z.string().uuid(),
21
- fileUrl: zod_1.z.string(), // View URL path: /documents/view/{docId}
22
- fileExtension: zod_1.z.string().nullable().optional(),
23
- fileName: zod_1.z.string().optional(),
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
- exports.taskAttributesSchema = zod_1.z.object({
28
- title: zod_1.z.string(),
29
- fieldId: zod_1.z.string().uuid(),
30
- fieldName: zod_1.z.string().optional(), // Included for convenience
31
- date: zod_1.z.string().datetime(),
32
- status: exports.taskStatusSchema,
33
- category: zod_1.z.string(), // Task 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: zod_1.z.string().uuid().nullable(),
36
- inventoryItemName: zod_1.z.string().nullable().optional(),
37
- plannedQuantity: zod_1.z.number().nullable(),
38
- actualQuantity: zod_1.z.number().nullable(),
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: zod_1.z.string().uuid().nullable(),
41
- assignedToName: zod_1.z.string().nullable().optional(),
42
- assignedBy: zod_1.z.string().uuid().nullable(),
43
- assignedDate: zod_1.z.string().datetime().nullable(),
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: zod_1.z.array(exports.taskNoteSchema).optional(),
42
+ notes: z.array(taskNoteSchema).optional(),
46
43
  // Autonomous Agent Source Tracking
47
- source: zod_1.z.object({
48
- type: zod_1.z.string(), // e.g., 'observation', 'satellite_monitoring', 'manual'
49
- id: zod_1.z.string(), // The ID of the source entity (e.g., observationId, alertId)
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: zod_1.z.array(zod_1.z.object({
52
- type: zod_1.z.string(),
53
- id: zod_1.z.string(),
48
+ contributingSources: z.array(z.object({
49
+ type: z.string(),
50
+ id: z.string(),
54
51
  })).optional(),
55
- }).merge(common_schemas_1.timestampsSchema);
52
+ }).merge(timestampsSchema);
56
53
  // Task attributes for creation (input)
57
- exports.createTaskAttributesSchema = zod_1.z.object({
58
- title: zod_1.z.string().min(1).max(200),
59
- fieldId: zod_1.z.string().uuid(),
60
- date: zod_1.z.string().datetime(),
61
- status: exports.taskStatusSchema.default('pending').optional(),
62
- category: zod_1.z.string().min(1).max(100), // Required - frontend should use default category if user doesn't select
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: zod_1.z.string().uuid().optional(),
65
- plannedQuantity: zod_1.z.number().positive().optional(),
61
+ inventoryItemId: z.string().uuid().optional(),
62
+ plannedQuantity: z.number().positive().optional(),
66
63
  // Team collaboration
67
- assignedTo: zod_1.z.string().uuid().optional(), // TeamMember ID
68
- notes: zod_1.z.string().optional(), // Initial note
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
- exports.updateTaskAttributesSchema = zod_1.z.object({
72
- title: zod_1.z.string().min(1).max(200).optional(),
73
- fieldId: zod_1.z.string().uuid().optional(),
74
- date: zod_1.z.string().datetime().optional(),
75
- status: exports.taskStatusSchema.optional(),
76
- category: zod_1.z.string().min(1).max(100).optional(),
77
- inventoryItemId: zod_1.z.string().uuid().optional(),
78
- plannedQuantity: zod_1.z.number().positive().optional(),
79
- actualQuantity: zod_1.z.number().positive().optional(), // Set when completing task
80
- assignedTo: zod_1.z.string().uuid().nullable().optional(),
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
- exports.completeTaskAttributesSchema = zod_1.z.object({
84
- actualQuantity: zod_1.z.number().positive().optional(), // Actual quantity used (for inventory deduction)
85
- notes: zod_1.z.string().optional(), // Completion 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
- exports.addTaskNoteAttributesSchema = zod_1.z.object({
89
- text: zod_1.z.string().default(''),
90
- documentIds: zod_1.z.array(zod_1.z.string().uuid()).optional(), // Document IDs to attach to this note
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
- exports.createTaskSchema = zod_1.z.object({
102
- type: zod_1.z.literal('tasks'),
103
- attributes: exports.createTaskAttributesSchema,
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
- exports.updateTaskSchema = zod_1.z.object({
107
- type: zod_1.z.literal('tasks'),
108
- id: zod_1.z.string().uuid(),
109
- attributes: exports.updateTaskAttributesSchema,
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
- exports.completeTaskSchema = zod_1.z.object({
113
- type: zod_1.z.literal('tasks'),
114
- id: zod_1.z.string().uuid(),
115
- attributes: exports.completeTaskAttributesSchema,
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
- exports.addTaskNoteSchema = zod_1.z.object({
119
- type: zod_1.z.literal('task-notes'),
120
- attributes: exports.addTaskNoteAttributesSchema,
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
- exports.taskResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('tasks', exports.taskAttributesSchema);
120
+ export const taskResourceSchema = createJsonApiResourceSchema('tasks', taskAttributesSchema);
124
121
  // Task detail resource with relationships
125
- exports.taskDetailResourceSchema = exports.taskResourceSchema.extend({
126
- relationships: zod_1.z.object({
127
- field: zod_1.z.object({
128
- links: zod_1.z.object({
129
- related: zod_1.z.string(),
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: zod_1.z.object({
133
- links: zod_1.z.object({
134
- related: zod_1.z.string(),
129
+ inventory_item: z.object({
130
+ links: z.object({
131
+ related: z.string(),
135
132
  }),
136
133
  }).optional(),
137
- assigned_to: zod_1.z.object({
138
- links: zod_1.z.object({
139
- related: zod_1.z.string(),
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
- exports.taskResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.taskResourceSchema);
146
- exports.taskDetailResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.taskDetailResourceSchema);
147
- exports.taskListResponseSchema = (0, common_schemas_1.jsonApiCollectionResponseSchema)(exports.taskResourceSchema);
142
+ export const taskResponseSchema = jsonApiSingleResponseSchema(taskResourceSchema);
143
+ export const taskDetailResponseSchema = jsonApiSingleResponseSchema(taskDetailResourceSchema);
144
+ export const taskListResponseSchema = jsonApiCollectionResponseSchema(taskResourceSchema);
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.teamMemberRoleSchema = zod_1.z.enum([
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
- exports.teamMemberAttributesSchema = zod_1.z.object({
20
- farmId: zod_1.z.string().uuid(),
21
- userId: zod_1.z.string().uuid().nullable(), // User account ID (if user has account)
22
- name: zod_1.z.string(),
23
- email: zod_1.z.string().email(),
24
- role: exports.teamMemberRoleSchema,
25
- phone: zod_1.z.string().nullable(),
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: zod_1.z.number().int().nonnegative().optional(),
28
- tasksCompleted: zod_1.z.number().int().nonnegative().optional(),
29
- tasksPending: zod_1.z.number().int().nonnegative().optional(),
30
- }).merge(common_schemas_1.timestampsSchema);
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
- exports.createTeamMemberAttributesSchema = zod_1.z.object({
33
- name: zod_1.z.string().min(1).max(200),
34
- email: zod_1.z.string().email(),
35
- role: exports.teamMemberRoleSchema,
36
- phone: zod_1.z.string().optional(),
37
- message: zod_1.z.string().optional(), // Optional personal message for invitation
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
- exports.updateTeamMemberAttributesSchema = zod_1.z.object({
41
- name: zod_1.z.string().min(1).max(200).optional(),
42
- email: zod_1.z.string().email().optional(),
43
- role: exports.teamMemberRoleSchema.optional(),
44
- phone: zod_1.z.string().nullable().optional(),
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
- exports.createTeamMemberSchema = zod_1.z.object({
48
- type: zod_1.z.literal('team-members'),
49
- attributes: exports.createTeamMemberAttributesSchema,
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
- exports.updateTeamMemberSchema = zod_1.z.object({
53
- type: zod_1.z.literal('team-members'),
54
- id: zod_1.z.string().uuid(),
55
- attributes: exports.updateTeamMemberAttributesSchema,
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
- exports.teamMemberResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('team-members', exports.teamMemberAttributesSchema);
55
+ export const teamMemberResourceSchema = createJsonApiResourceSchema('team-members', teamMemberAttributesSchema);
59
56
  // Team member responses (JSON:API format)
60
- exports.teamMemberResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.teamMemberResourceSchema);
61
- exports.teamMemberListResponseSchema = (0, common_schemas_1.jsonApiCollectionResponseSchema)(exports.teamMemberResourceSchema);
57
+ export const teamMemberResponseSchema = jsonApiSingleResponseSchema(teamMemberResourceSchema);
58
+ export const teamMemberListResponseSchema = jsonApiCollectionResponseSchema(teamMemberResourceSchema);
@@ -1,32 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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
- exports.userAttributesSchema = zod_1.z.object({
11
- name: zod_1.z.string(),
12
- email: zod_1.z.string().email(),
13
- phone: zod_1.z.string().nullable(),
14
- emailVerified: zod_1.z.boolean(),
15
- avatar: zod_1.z.string().url().nullable(),
16
- }).merge(common_schemas_1.timestampsSchema);
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
- exports.updateUserAttributesSchema = zod_1.z.object({
19
- name: zod_1.z.string().min(1).max(200).optional(),
20
- phone: zod_1.z.string().optional(),
21
- avatar: zod_1.z.string().url().nullable().optional(),
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
- exports.updateProfileSchema = zod_1.z.object({
25
- type: zod_1.z.literal('users'),
26
- id: zod_1.z.string().uuid(),
27
- attributes: exports.updateUserAttributesSchema,
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
- exports.userResourceSchema = (0, common_schemas_1.createJsonApiResourceSchema)('users', exports.userAttributesSchema);
27
+ export const userResourceSchema = createJsonApiResourceSchema('users', userAttributesSchema);
31
28
  // User response (JSON:API format)
32
- exports.userResponseSchema = (0, common_schemas_1.jsonApiSingleResponseSchema)(exports.userResourceSchema);
29
+ export const userResponseSchema = jsonApiSingleResponseSchema(userResourceSchema);