@deepintel-ltd/farmpro-contracts 1.5.8 → 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,73 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.analyticsResponseSchema = exports.analyticsResourceSchema = exports.analyticsAttributesSchema = exports.profitabilityAnalysisSchema = exports.fieldPerformanceSchema = exports.marketDataSchema = exports.yieldDataSchema = exports.performanceDataPointSchema = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const common_schemas_1 = require("./common.schemas");
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { createJsonApiResourceSchema, jsonApiSingleResponseSchema } from './common.schemas';
|
|
6
3
|
/**
|
|
7
4
|
* Analytics schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Performance data point (for trend charts)
|
|
10
|
-
|
|
11
|
-
date:
|
|
12
|
-
ndvi:
|
|
13
|
-
moisture:
|
|
14
|
-
rainfall:
|
|
7
|
+
export const performanceDataPointSchema = z.object({
|
|
8
|
+
date: z.string().datetime(),
|
|
9
|
+
ndvi: z.number().nullable(),
|
|
10
|
+
moisture: z.number().nullable(),
|
|
11
|
+
rainfall: z.number().nullable(),
|
|
15
12
|
});
|
|
16
13
|
// Yield data
|
|
17
|
-
|
|
18
|
-
forecast:
|
|
19
|
-
target:
|
|
20
|
-
revenue:
|
|
21
|
-
costs:
|
|
14
|
+
export const yieldDataSchema = z.object({
|
|
15
|
+
forecast: z.number().nonnegative(),
|
|
16
|
+
target: z.number().nonnegative(),
|
|
17
|
+
revenue: z.number().nonnegative(),
|
|
18
|
+
costs: z.number().nonnegative(),
|
|
22
19
|
});
|
|
23
20
|
// Market data
|
|
24
|
-
|
|
25
|
-
id:
|
|
26
|
-
crop:
|
|
27
|
-
price:
|
|
28
|
-
trend:
|
|
21
|
+
export const marketDataSchema = z.object({
|
|
22
|
+
id: z.string().uuid(),
|
|
23
|
+
crop: z.string(),
|
|
24
|
+
price: z.string(), // e.g., "₦28,500/100kg"
|
|
25
|
+
trend: z.enum(['up', 'down', 'stable']),
|
|
29
26
|
});
|
|
30
27
|
// Field performance
|
|
31
|
-
|
|
32
|
-
id:
|
|
33
|
-
name:
|
|
34
|
-
ndvi:
|
|
35
|
-
trend:
|
|
36
|
-
moisture:
|
|
37
|
-
issue:
|
|
28
|
+
export const fieldPerformanceSchema = z.object({
|
|
29
|
+
id: z.string().uuid(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
ndvi: z.number(),
|
|
32
|
+
trend: z.enum(['up', 'down', 'stable']),
|
|
33
|
+
moisture: z.string(),
|
|
34
|
+
issue: z.string().nullable(),
|
|
38
35
|
});
|
|
39
36
|
// Profitability analysis
|
|
40
|
-
|
|
41
|
-
totalRevenue:
|
|
42
|
-
totalCosts:
|
|
43
|
-
netProfit:
|
|
44
|
-
profitMargin:
|
|
45
|
-
fieldBreakdown:
|
|
46
|
-
fieldId:
|
|
47
|
-
fieldName:
|
|
48
|
-
revenue:
|
|
49
|
-
costs:
|
|
50
|
-
profit:
|
|
51
|
-
margin:
|
|
37
|
+
export const profitabilityAnalysisSchema = z.object({
|
|
38
|
+
totalRevenue: z.number().nonnegative(),
|
|
39
|
+
totalCosts: z.number().nonnegative(),
|
|
40
|
+
netProfit: z.number(),
|
|
41
|
+
profitMargin: z.number(), // Percentage
|
|
42
|
+
fieldBreakdown: z.array(z.object({
|
|
43
|
+
fieldId: z.string().uuid(),
|
|
44
|
+
fieldName: z.string(),
|
|
45
|
+
revenue: z.number().nonnegative(),
|
|
46
|
+
costs: z.number().nonnegative(),
|
|
47
|
+
profit: z.number(),
|
|
48
|
+
margin: z.number(),
|
|
52
49
|
})).optional(),
|
|
53
|
-
cropBreakdown:
|
|
54
|
-
crop:
|
|
55
|
-
revenue:
|
|
56
|
-
costs:
|
|
57
|
-
profit:
|
|
58
|
-
margin:
|
|
50
|
+
cropBreakdown: z.array(z.object({
|
|
51
|
+
crop: z.string(),
|
|
52
|
+
revenue: z.number().nonnegative(),
|
|
53
|
+
costs: z.number().nonnegative(),
|
|
54
|
+
profit: z.number(),
|
|
55
|
+
margin: z.number(),
|
|
59
56
|
})).optional(),
|
|
60
57
|
});
|
|
61
58
|
// Analytics attributes schema (for JSON:API attributes object)
|
|
62
|
-
|
|
63
|
-
farmId:
|
|
64
|
-
performanceData:
|
|
65
|
-
yield:
|
|
66
|
-
marketData:
|
|
67
|
-
fieldPerformance:
|
|
68
|
-
profitability:
|
|
59
|
+
export const analyticsAttributesSchema = z.object({
|
|
60
|
+
farmId: z.string().uuid(),
|
|
61
|
+
performanceData: z.array(performanceDataPointSchema),
|
|
62
|
+
yield: yieldDataSchema,
|
|
63
|
+
marketData: z.array(marketDataSchema),
|
|
64
|
+
fieldPerformance: z.array(fieldPerformanceSchema),
|
|
65
|
+
profitability: profitabilityAnalysisSchema.optional(),
|
|
69
66
|
});
|
|
70
67
|
// Analytics resource (JSON:API resource object)
|
|
71
|
-
|
|
68
|
+
export const analyticsResourceSchema = createJsonApiResourceSchema('analytics', analyticsAttributesSchema);
|
|
72
69
|
// Analytics response (JSON:API format)
|
|
73
|
-
|
|
70
|
+
export const analyticsResponseSchema = jsonApiSingleResponseSchema(analyticsResourceSchema);
|
|
@@ -1,159 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.emailVerificationResponseSchema = exports.logoutResponseSchema = exports.passwordResetResponseSchema = exports.refreshTokenResponseSchema = exports.googleAuthInitiateResponseSchema = exports.authResponseSchema = exports.refreshTokenResourceSchema = exports.googleAuthInitiateResourceSchema = exports.authSessionResourceSchema = exports.authUserResourceSchema = exports.refreshTokenResponseAttributesSchema = exports.googleAuthInitiateResponseAttributesSchema = exports.authSessionAttributesSchema = exports.authUserAttributesSchema = exports.logoutSchema = exports.resendVerificationSchema = exports.verifyEmailSchema = exports.changePasswordSchema = exports.resetPasswordSchema = exports.requestPasswordResetSchema = exports.refreshTokenSchema = exports.googleAuthCallbackSchema = exports.googleAuthInitiateSchema = exports.signupSchema = exports.loginSchema = exports.logoutAttributesSchema = exports.resendVerificationAttributesSchema = exports.verifyEmailAttributesSchema = exports.changePasswordAttributesSchema = exports.resetPasswordAttributesSchema = exports.requestPasswordResetAttributesSchema = exports.refreshTokenAttributesSchema = exports.googleAuthCallbackAttributesSchema = exports.googleAuthInitiateAttributesSchema = exports.signupAttributesSchema = exports.loginAttributesSchema = 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, jsonApiSuccessResponseSchema } from './common.schemas';
|
|
6
3
|
/**
|
|
7
4
|
* Authentication schemas - JSON:API compliant
|
|
8
5
|
*/
|
|
9
6
|
// Login attributes
|
|
10
|
-
|
|
11
|
-
email:
|
|
12
|
-
password:
|
|
7
|
+
export const loginAttributesSchema = z.object({
|
|
8
|
+
email: z.string().email(),
|
|
9
|
+
password: z.string().min(8),
|
|
13
10
|
});
|
|
14
11
|
// Signup attributes
|
|
15
|
-
|
|
16
|
-
name:
|
|
17
|
-
email:
|
|
18
|
-
password:
|
|
12
|
+
export const signupAttributesSchema = z.object({
|
|
13
|
+
name: z.string().min(1).max(200),
|
|
14
|
+
email: z.string().email(),
|
|
15
|
+
password: z.string().min(8).regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
|
|
19
16
|
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
|
|
20
17
|
.regex(/[0-9]/, 'Password must contain at least one number'),
|
|
21
18
|
});
|
|
22
19
|
// Google OAuth initiate attributes
|
|
23
|
-
|
|
24
|
-
redirectUri:
|
|
20
|
+
export const googleAuthInitiateAttributesSchema = z.object({
|
|
21
|
+
redirectUri: z.string().url().optional(),
|
|
25
22
|
});
|
|
26
23
|
// Google OAuth callback attributes
|
|
27
|
-
|
|
28
|
-
code:
|
|
29
|
-
state:
|
|
24
|
+
export const googleAuthCallbackAttributesSchema = z.object({
|
|
25
|
+
code: z.string().min(1),
|
|
26
|
+
state: z.string().optional(),
|
|
30
27
|
});
|
|
31
28
|
// Token refresh attributes
|
|
32
|
-
|
|
33
|
-
refreshToken:
|
|
29
|
+
export const refreshTokenAttributesSchema = z.object({
|
|
30
|
+
refreshToken: z.string().min(1),
|
|
34
31
|
});
|
|
35
32
|
// Password reset request attributes
|
|
36
|
-
|
|
37
|
-
email:
|
|
33
|
+
export const requestPasswordResetAttributesSchema = z.object({
|
|
34
|
+
email: z.string().email(),
|
|
38
35
|
});
|
|
39
36
|
// Password reset attributes
|
|
40
|
-
|
|
41
|
-
token:
|
|
42
|
-
newPassword:
|
|
37
|
+
export const resetPasswordAttributesSchema = z.object({
|
|
38
|
+
token: z.string().min(1),
|
|
39
|
+
newPassword: z.string().min(8).regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
|
|
43
40
|
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
|
|
44
41
|
.regex(/[0-9]/, 'Password must contain at least one number'),
|
|
45
42
|
});
|
|
46
43
|
// Change password attributes
|
|
47
|
-
|
|
48
|
-
currentPassword:
|
|
49
|
-
newPassword:
|
|
44
|
+
export const changePasswordAttributesSchema = z.object({
|
|
45
|
+
currentPassword: z.string().min(1),
|
|
46
|
+
newPassword: z.string().min(8).regex(/[A-Z]/, 'Password must contain at least one uppercase letter')
|
|
50
47
|
.regex(/[a-z]/, 'Password must contain at least one lowercase letter')
|
|
51
48
|
.regex(/[0-9]/, 'Password must contain at least one number'),
|
|
52
49
|
});
|
|
53
50
|
// Verify email attributes
|
|
54
|
-
|
|
55
|
-
token:
|
|
51
|
+
export const verifyEmailAttributesSchema = z.object({
|
|
52
|
+
token: z.string().min(1),
|
|
56
53
|
});
|
|
57
54
|
// Resend verification attributes
|
|
58
|
-
|
|
59
|
-
email:
|
|
55
|
+
export const resendVerificationAttributesSchema = z.object({
|
|
56
|
+
email: z.string().email(),
|
|
60
57
|
});
|
|
61
58
|
// Logout attributes
|
|
62
|
-
|
|
63
|
-
refreshToken:
|
|
59
|
+
export const logoutAttributesSchema = z.object({
|
|
60
|
+
refreshToken: z.string().optional(),
|
|
64
61
|
});
|
|
65
62
|
// JSON:API input schemas
|
|
66
|
-
|
|
67
|
-
type:
|
|
68
|
-
attributes:
|
|
63
|
+
export const loginSchema = z.object({
|
|
64
|
+
type: z.literal('auth'),
|
|
65
|
+
attributes: loginAttributesSchema,
|
|
69
66
|
});
|
|
70
|
-
|
|
71
|
-
type:
|
|
72
|
-
attributes:
|
|
67
|
+
export const signupSchema = z.object({
|
|
68
|
+
type: z.literal('users'),
|
|
69
|
+
attributes: signupAttributesSchema,
|
|
73
70
|
});
|
|
74
|
-
|
|
75
|
-
type:
|
|
76
|
-
attributes:
|
|
71
|
+
export const googleAuthInitiateSchema = z.object({
|
|
72
|
+
type: z.literal('auth'),
|
|
73
|
+
attributes: googleAuthInitiateAttributesSchema,
|
|
77
74
|
});
|
|
78
|
-
|
|
79
|
-
type:
|
|
80
|
-
attributes:
|
|
75
|
+
export const googleAuthCallbackSchema = z.object({
|
|
76
|
+
type: z.literal('auth'),
|
|
77
|
+
attributes: googleAuthCallbackAttributesSchema,
|
|
81
78
|
});
|
|
82
|
-
|
|
83
|
-
type:
|
|
84
|
-
attributes:
|
|
79
|
+
export const refreshTokenSchema = z.object({
|
|
80
|
+
type: z.literal('auth'),
|
|
81
|
+
attributes: refreshTokenAttributesSchema,
|
|
85
82
|
});
|
|
86
|
-
|
|
87
|
-
type:
|
|
88
|
-
attributes:
|
|
83
|
+
export const requestPasswordResetSchema = z.object({
|
|
84
|
+
type: z.literal('auth'),
|
|
85
|
+
attributes: requestPasswordResetAttributesSchema,
|
|
89
86
|
});
|
|
90
|
-
|
|
91
|
-
type:
|
|
92
|
-
attributes:
|
|
87
|
+
export const resetPasswordSchema = z.object({
|
|
88
|
+
type: z.literal('auth'),
|
|
89
|
+
attributes: resetPasswordAttributesSchema,
|
|
93
90
|
});
|
|
94
|
-
|
|
95
|
-
type:
|
|
96
|
-
attributes:
|
|
91
|
+
export const changePasswordSchema = z.object({
|
|
92
|
+
type: z.literal('auth'),
|
|
93
|
+
attributes: changePasswordAttributesSchema,
|
|
97
94
|
});
|
|
98
|
-
|
|
99
|
-
type:
|
|
100
|
-
attributes:
|
|
95
|
+
export const verifyEmailSchema = z.object({
|
|
96
|
+
type: z.literal('auth'),
|
|
97
|
+
attributes: verifyEmailAttributesSchema,
|
|
101
98
|
});
|
|
102
|
-
|
|
103
|
-
type:
|
|
104
|
-
attributes:
|
|
99
|
+
export const resendVerificationSchema = z.object({
|
|
100
|
+
type: z.literal('auth'),
|
|
101
|
+
attributes: resendVerificationAttributesSchema,
|
|
105
102
|
});
|
|
106
|
-
|
|
107
|
-
type:
|
|
108
|
-
attributes:
|
|
103
|
+
export const logoutSchema = z.object({
|
|
104
|
+
type: z.literal('auth'),
|
|
105
|
+
attributes: logoutAttributesSchema,
|
|
109
106
|
});
|
|
110
107
|
// User attributes schema (for auth responses)
|
|
111
|
-
|
|
112
|
-
name:
|
|
113
|
-
email:
|
|
114
|
-
phone:
|
|
115
|
-
emailVerified:
|
|
116
|
-
avatar:
|
|
117
|
-
}).merge(
|
|
108
|
+
export const authUserAttributesSchema = z.object({
|
|
109
|
+
name: z.string(),
|
|
110
|
+
email: z.string().email(),
|
|
111
|
+
phone: z.string().nullable(),
|
|
112
|
+
emailVerified: z.boolean(),
|
|
113
|
+
avatar: z.string().url().nullable(),
|
|
114
|
+
}).merge(timestampsSchema);
|
|
118
115
|
// Auth session attributes schema
|
|
119
|
-
|
|
120
|
-
accessToken:
|
|
121
|
-
refreshToken:
|
|
122
|
-
expiresIn:
|
|
123
|
-
tokenType:
|
|
116
|
+
export const authSessionAttributesSchema = z.object({
|
|
117
|
+
accessToken: z.string(),
|
|
118
|
+
refreshToken: z.string(),
|
|
119
|
+
expiresIn: z.number(), // seconds
|
|
120
|
+
tokenType: z.literal('Bearer').default('Bearer'),
|
|
124
121
|
});
|
|
125
122
|
// Google OAuth initiate response attributes
|
|
126
|
-
|
|
127
|
-
authUrl:
|
|
128
|
-
state:
|
|
123
|
+
export const googleAuthInitiateResponseAttributesSchema = z.object({
|
|
124
|
+
authUrl: z.string().url(),
|
|
125
|
+
state: z.string(),
|
|
129
126
|
});
|
|
130
127
|
// Token refresh response attributes
|
|
131
|
-
|
|
132
|
-
accessToken:
|
|
133
|
-
refreshToken:
|
|
134
|
-
expiresIn:
|
|
135
|
-
tokenType:
|
|
128
|
+
export const refreshTokenResponseAttributesSchema = z.object({
|
|
129
|
+
accessToken: z.string(),
|
|
130
|
+
refreshToken: z.string().optional(),
|
|
131
|
+
expiresIn: z.number(),
|
|
132
|
+
tokenType: z.literal('Bearer').default('Bearer'),
|
|
136
133
|
});
|
|
137
134
|
// User resource (JSON:API)
|
|
138
|
-
|
|
135
|
+
export const authUserResourceSchema = createJsonApiResourceSchema('users', authUserAttributesSchema);
|
|
139
136
|
// Auth session resource (JSON:API)
|
|
140
|
-
|
|
137
|
+
export const authSessionResourceSchema = createJsonApiResourceSchema('sessions', authSessionAttributesSchema);
|
|
141
138
|
// Google OAuth initiate resource
|
|
142
|
-
|
|
139
|
+
export const googleAuthInitiateResourceSchema = createJsonApiResourceSchema('auth-urls', googleAuthInitiateResponseAttributesSchema);
|
|
143
140
|
// Token refresh resource
|
|
144
|
-
|
|
141
|
+
export const refreshTokenResourceSchema = createJsonApiResourceSchema('sessions', refreshTokenResponseAttributesSchema);
|
|
145
142
|
// Auth response (login/signup) - compound document with user and session
|
|
146
|
-
|
|
147
|
-
data:
|
|
148
|
-
meta:
|
|
149
|
-
message:
|
|
143
|
+
export const authResponseSchema = z.object({
|
|
144
|
+
data: z.array(z.union([authUserResourceSchema, authSessionResourceSchema])),
|
|
145
|
+
meta: z.object({
|
|
146
|
+
message: z.string().optional(),
|
|
150
147
|
}).optional(),
|
|
151
148
|
});
|
|
152
149
|
// Google OAuth initiate response
|
|
153
|
-
|
|
150
|
+
export const googleAuthInitiateResponseSchema = jsonApiSingleResponseSchema(googleAuthInitiateResourceSchema);
|
|
154
151
|
// Token refresh response
|
|
155
|
-
|
|
152
|
+
export const refreshTokenResponseSchema = jsonApiSingleResponseSchema(refreshTokenResourceSchema);
|
|
156
153
|
// Simple success responses
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
154
|
+
export const passwordResetResponseSchema = jsonApiSuccessResponseSchema;
|
|
155
|
+
export const logoutResponseSchema = jsonApiSuccessResponseSchema;
|
|
156
|
+
export const emailVerificationResponseSchema = jsonApiSuccessResponseSchema;
|
|
@@ -1,47 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getCategoriesQuerySchema = exports.categoryListResponseSchema = exports.categoryResponseSchema = exports.categoryResourceSchema = exports.updateCategorySchema = exports.createCategorySchema = exports.updateCategoryAttributesSchema = exports.createCategoryAttributesSchema = exports.categoryAttributesSchema = 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
|
* Category schemas - JSON:API compliant
|
|
8
5
|
* Categories are universal and can be used for tasks, budgets, and expenses
|
|
9
6
|
*/
|
|
10
7
|
// Category attributes schema (for JSON:API attributes object)
|
|
11
|
-
|
|
12
|
-
name:
|
|
13
|
-
farmId:
|
|
14
|
-
isDefault:
|
|
15
|
-
}).merge(
|
|
8
|
+
export const categoryAttributesSchema = z.object({
|
|
9
|
+
name: z.string(),
|
|
10
|
+
farmId: z.string().uuid().nullable(),
|
|
11
|
+
isDefault: z.boolean(),
|
|
12
|
+
}).merge(timestampsSchema);
|
|
16
13
|
// Category attributes for creation (input)
|
|
17
|
-
|
|
18
|
-
name:
|
|
19
|
-
farmId:
|
|
20
|
-
isDefault:
|
|
14
|
+
export const createCategoryAttributesSchema = z.object({
|
|
15
|
+
name: z.string().min(1).max(100),
|
|
16
|
+
farmId: z.string().uuid().optional(), // Optional - if not provided, creates system default
|
|
17
|
+
isDefault: z.boolean().optional().default(false),
|
|
21
18
|
});
|
|
22
19
|
// Category attributes for update (input)
|
|
23
|
-
|
|
24
|
-
name:
|
|
25
|
-
isDefault:
|
|
20
|
+
export const updateCategoryAttributesSchema = z.object({
|
|
21
|
+
name: z.string().min(1).max(100).optional(),
|
|
22
|
+
isDefault: z.boolean().optional(),
|
|
26
23
|
});
|
|
27
24
|
// Create category input (JSON:API format)
|
|
28
|
-
|
|
29
|
-
type:
|
|
30
|
-
attributes:
|
|
25
|
+
export const createCategorySchema = z.object({
|
|
26
|
+
type: z.literal('categories'),
|
|
27
|
+
attributes: createCategoryAttributesSchema,
|
|
31
28
|
});
|
|
32
29
|
// Update category input (JSON:API format)
|
|
33
|
-
|
|
34
|
-
type:
|
|
35
|
-
id:
|
|
36
|
-
attributes:
|
|
30
|
+
export const updateCategorySchema = z.object({
|
|
31
|
+
type: z.literal('categories'),
|
|
32
|
+
id: z.string().uuid(),
|
|
33
|
+
attributes: updateCategoryAttributesSchema,
|
|
37
34
|
});
|
|
38
35
|
// Category resource (JSON:API resource object)
|
|
39
|
-
|
|
36
|
+
export const categoryResourceSchema = createJsonApiResourceSchema('categories', categoryAttributesSchema);
|
|
40
37
|
// Category responses (JSON:API format)
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
export const categoryResponseSchema = jsonApiSingleResponseSchema(categoryResourceSchema);
|
|
39
|
+
export const categoryListResponseSchema = jsonApiCollectionResponseSchema(categoryResourceSchema);
|
|
43
40
|
// Get categories query parameters
|
|
44
|
-
|
|
45
|
-
farmId:
|
|
46
|
-
includeDefaults:
|
|
41
|
+
export const getCategoriesQuerySchema = z.object({
|
|
42
|
+
farmId: z.string().uuid().optional(),
|
|
43
|
+
includeDefaults: z.coerce.boolean().optional().default(true),
|
|
47
44
|
});
|