@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,22 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const common_schemas_1 = require("../schemas/common.schemas");
|
|
8
|
-
const c = (0, core_1.initContract)();
|
|
9
|
-
exports.authRouter = c.router({
|
|
1
|
+
import { initContract } from '@ts-rest/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { loginSchema, signupSchema, googleAuthInitiateSchema, googleAuthCallbackSchema, refreshTokenSchema, requestPasswordResetSchema, resetPasswordSchema, changePasswordSchema, verifyEmailSchema, resendVerificationSchema, logoutSchema, authResponseSchema, googleAuthInitiateResponseSchema, refreshTokenResponseSchema, passwordResetResponseSchema, logoutResponseSchema, emailVerificationResponseSchema, } from '../schemas/auth.schemas';
|
|
4
|
+
import { jsonApiErrorResponseSchema } from '../schemas/common.schemas';
|
|
5
|
+
const c = initContract();
|
|
6
|
+
export const authRouter = c.router({
|
|
10
7
|
// Login with email/password
|
|
11
8
|
login: {
|
|
12
9
|
method: 'POST',
|
|
13
10
|
path: '/auth/login',
|
|
14
|
-
body:
|
|
11
|
+
body: z.object({ data: loginSchema }),
|
|
15
12
|
responses: {
|
|
16
|
-
200:
|
|
17
|
-
401:
|
|
18
|
-
400:
|
|
19
|
-
422:
|
|
13
|
+
200: authResponseSchema,
|
|
14
|
+
401: jsonApiErrorResponseSchema,
|
|
15
|
+
400: jsonApiErrorResponseSchema,
|
|
16
|
+
422: jsonApiErrorResponseSchema,
|
|
20
17
|
},
|
|
21
18
|
summary: 'Login with email and password',
|
|
22
19
|
description: 'Authenticate user with email and password, returns user data and tokens',
|
|
@@ -25,12 +22,12 @@ exports.authRouter = c.router({
|
|
|
25
22
|
signup: {
|
|
26
23
|
method: 'POST',
|
|
27
24
|
path: '/auth/signup',
|
|
28
|
-
body:
|
|
25
|
+
body: z.object({ data: signupSchema }),
|
|
29
26
|
responses: {
|
|
30
|
-
201:
|
|
31
|
-
400:
|
|
32
|
-
409:
|
|
33
|
-
422:
|
|
27
|
+
201: authResponseSchema,
|
|
28
|
+
400: jsonApiErrorResponseSchema,
|
|
29
|
+
409: jsonApiErrorResponseSchema,
|
|
30
|
+
422: jsonApiErrorResponseSchema,
|
|
34
31
|
},
|
|
35
32
|
summary: 'Register new user',
|
|
36
33
|
description: 'Create a new user account with email and password',
|
|
@@ -39,11 +36,11 @@ exports.authRouter = c.router({
|
|
|
39
36
|
googleAuthInitiate: {
|
|
40
37
|
method: 'POST',
|
|
41
38
|
path: '/auth/google/initiate',
|
|
42
|
-
body:
|
|
39
|
+
body: z.object({ data: googleAuthInitiateSchema }),
|
|
43
40
|
responses: {
|
|
44
|
-
200:
|
|
45
|
-
400:
|
|
46
|
-
422:
|
|
41
|
+
200: googleAuthInitiateResponseSchema,
|
|
42
|
+
400: jsonApiErrorResponseSchema,
|
|
43
|
+
422: jsonApiErrorResponseSchema,
|
|
47
44
|
},
|
|
48
45
|
summary: 'Initiate Google OAuth flow',
|
|
49
46
|
description: 'Get Google OAuth authorization URL and state token',
|
|
@@ -52,12 +49,12 @@ exports.authRouter = c.router({
|
|
|
52
49
|
googleAuthCallback: {
|
|
53
50
|
method: 'POST',
|
|
54
51
|
path: '/auth/google/callback',
|
|
55
|
-
body:
|
|
52
|
+
body: z.object({ data: googleAuthCallbackSchema }),
|
|
56
53
|
responses: {
|
|
57
|
-
200:
|
|
58
|
-
400:
|
|
59
|
-
401:
|
|
60
|
-
422:
|
|
54
|
+
200: authResponseSchema,
|
|
55
|
+
400: jsonApiErrorResponseSchema,
|
|
56
|
+
401: jsonApiErrorResponseSchema,
|
|
57
|
+
422: jsonApiErrorResponseSchema,
|
|
61
58
|
},
|
|
62
59
|
summary: 'Handle Google OAuth callback',
|
|
63
60
|
description: 'Exchange Google OAuth code for access and refresh tokens',
|
|
@@ -66,11 +63,11 @@ exports.authRouter = c.router({
|
|
|
66
63
|
refreshToken: {
|
|
67
64
|
method: 'POST',
|
|
68
65
|
path: '/auth/refresh',
|
|
69
|
-
body:
|
|
66
|
+
body: z.object({ data: refreshTokenSchema }),
|
|
70
67
|
responses: {
|
|
71
|
-
200:
|
|
72
|
-
401:
|
|
73
|
-
422:
|
|
68
|
+
200: refreshTokenResponseSchema,
|
|
69
|
+
401: jsonApiErrorResponseSchema,
|
|
70
|
+
422: jsonApiErrorResponseSchema,
|
|
74
71
|
},
|
|
75
72
|
summary: 'Refresh access token',
|
|
76
73
|
description: 'Get a new access token using a valid refresh token',
|
|
@@ -79,10 +76,10 @@ exports.authRouter = c.router({
|
|
|
79
76
|
logout: {
|
|
80
77
|
method: 'POST',
|
|
81
78
|
path: '/auth/logout',
|
|
82
|
-
body:
|
|
79
|
+
body: z.object({ data: logoutSchema }),
|
|
83
80
|
responses: {
|
|
84
|
-
200:
|
|
85
|
-
401:
|
|
81
|
+
200: logoutResponseSchema,
|
|
82
|
+
401: jsonApiErrorResponseSchema,
|
|
86
83
|
},
|
|
87
84
|
summary: 'Logout user',
|
|
88
85
|
description: 'Invalidate user session and optionally refresh token',
|
|
@@ -91,11 +88,11 @@ exports.authRouter = c.router({
|
|
|
91
88
|
requestPasswordReset: {
|
|
92
89
|
method: 'POST',
|
|
93
90
|
path: '/auth/password/reset-request',
|
|
94
|
-
body:
|
|
91
|
+
body: z.object({ data: requestPasswordResetSchema }),
|
|
95
92
|
responses: {
|
|
96
|
-
200:
|
|
97
|
-
400:
|
|
98
|
-
422:
|
|
93
|
+
200: passwordResetResponseSchema,
|
|
94
|
+
400: jsonApiErrorResponseSchema,
|
|
95
|
+
422: jsonApiErrorResponseSchema,
|
|
99
96
|
},
|
|
100
97
|
summary: 'Request password reset',
|
|
101
98
|
description: 'Send password reset email to user',
|
|
@@ -104,12 +101,12 @@ exports.authRouter = c.router({
|
|
|
104
101
|
resetPassword: {
|
|
105
102
|
method: 'POST',
|
|
106
103
|
path: '/auth/password/reset',
|
|
107
|
-
body:
|
|
104
|
+
body: z.object({ data: resetPasswordSchema }),
|
|
108
105
|
responses: {
|
|
109
|
-
200:
|
|
110
|
-
400:
|
|
111
|
-
401:
|
|
112
|
-
422:
|
|
106
|
+
200: passwordResetResponseSchema,
|
|
107
|
+
400: jsonApiErrorResponseSchema,
|
|
108
|
+
401: jsonApiErrorResponseSchema,
|
|
109
|
+
422: jsonApiErrorResponseSchema,
|
|
113
110
|
},
|
|
114
111
|
summary: 'Reset password',
|
|
115
112
|
description: 'Reset password using token from email',
|
|
@@ -118,12 +115,12 @@ exports.authRouter = c.router({
|
|
|
118
115
|
changePassword: {
|
|
119
116
|
method: 'POST',
|
|
120
117
|
path: '/auth/password/change',
|
|
121
|
-
body:
|
|
118
|
+
body: z.object({ data: changePasswordSchema }),
|
|
122
119
|
responses: {
|
|
123
|
-
200:
|
|
124
|
-
400:
|
|
125
|
-
401:
|
|
126
|
-
422:
|
|
120
|
+
200: passwordResetResponseSchema,
|
|
121
|
+
400: jsonApiErrorResponseSchema,
|
|
122
|
+
401: jsonApiErrorResponseSchema,
|
|
123
|
+
422: jsonApiErrorResponseSchema,
|
|
127
124
|
},
|
|
128
125
|
summary: 'Change password',
|
|
129
126
|
description: 'Change password for authenticated user',
|
|
@@ -132,12 +129,12 @@ exports.authRouter = c.router({
|
|
|
132
129
|
verifyEmail: {
|
|
133
130
|
method: 'POST',
|
|
134
131
|
path: '/auth/email/verify',
|
|
135
|
-
body:
|
|
132
|
+
body: z.object({ data: verifyEmailSchema }),
|
|
136
133
|
responses: {
|
|
137
|
-
200:
|
|
138
|
-
400:
|
|
139
|
-
401:
|
|
140
|
-
422:
|
|
134
|
+
200: emailVerificationResponseSchema,
|
|
135
|
+
400: jsonApiErrorResponseSchema,
|
|
136
|
+
401: jsonApiErrorResponseSchema,
|
|
137
|
+
422: jsonApiErrorResponseSchema,
|
|
141
138
|
},
|
|
142
139
|
summary: 'Verify email address',
|
|
143
140
|
description: 'Verify email address using token from email',
|
|
@@ -146,11 +143,11 @@ exports.authRouter = c.router({
|
|
|
146
143
|
resendVerification: {
|
|
147
144
|
method: 'POST',
|
|
148
145
|
path: '/auth/email/resend-verification',
|
|
149
|
-
body:
|
|
146
|
+
body: z.object({ data: resendVerificationSchema }),
|
|
150
147
|
responses: {
|
|
151
|
-
200:
|
|
152
|
-
400:
|
|
153
|
-
422:
|
|
148
|
+
200: emailVerificationResponseSchema,
|
|
149
|
+
400: jsonApiErrorResponseSchema,
|
|
150
|
+
422: jsonApiErrorResponseSchema,
|
|
154
151
|
},
|
|
155
152
|
summary: 'Resend verification email',
|
|
156
153
|
description: 'Resend email verification link',
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const common_schemas_1 = require("../schemas/common.schemas");
|
|
7
|
-
const zod_1 = require("zod");
|
|
8
|
-
const c = (0, core_1.initContract)();
|
|
1
|
+
import { initContract } from '@ts-rest/core';
|
|
2
|
+
import { categoryListResponseSchema, categoryResponseSchema, createCategorySchema, updateCategorySchema, getCategoriesQuerySchema, } from '../schemas/categories.schemas';
|
|
3
|
+
import { jsonApiErrorResponseSchema } from '../schemas/common.schemas';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
const c = initContract();
|
|
9
6
|
/**
|
|
10
7
|
* Categories API contract
|
|
11
8
|
* Provides endpoints for managing universal categories (can be used for tasks, budgets, expenses)
|
|
12
9
|
*/
|
|
13
|
-
|
|
10
|
+
export const categoriesRouter = c.router({
|
|
14
11
|
/**
|
|
15
12
|
* Get categories
|
|
16
13
|
* Returns system defaults and optionally farm-specific categories
|
|
@@ -18,9 +15,9 @@ exports.categoriesRouter = c.router({
|
|
|
18
15
|
getCategories: {
|
|
19
16
|
method: 'GET',
|
|
20
17
|
path: '/categories',
|
|
21
|
-
query:
|
|
18
|
+
query: getCategoriesQuerySchema,
|
|
22
19
|
responses: {
|
|
23
|
-
200:
|
|
20
|
+
200: categoryListResponseSchema,
|
|
24
21
|
},
|
|
25
22
|
summary: 'Get categories',
|
|
26
23
|
description: 'Returns system default categories and optionally farm-specific categories. Categories are universal and can be used for tasks, budgets, and expenses.',
|
|
@@ -33,8 +30,8 @@ exports.categoriesRouter = c.router({
|
|
|
33
30
|
method: 'GET',
|
|
34
31
|
path: '/categories/default',
|
|
35
32
|
responses: {
|
|
36
|
-
200:
|
|
37
|
-
404:
|
|
33
|
+
200: categoryResponseSchema,
|
|
34
|
+
404: jsonApiErrorResponseSchema,
|
|
38
35
|
},
|
|
39
36
|
summary: 'Get default category',
|
|
40
37
|
description: 'Returns the system-wide default category that should be used when creating a task, budget, or expense without specifying a category.',
|
|
@@ -46,11 +43,11 @@ exports.categoriesRouter = c.router({
|
|
|
46
43
|
createCategory: {
|
|
47
44
|
method: 'POST',
|
|
48
45
|
path: '/categories',
|
|
49
|
-
body:
|
|
46
|
+
body: createCategorySchema,
|
|
50
47
|
responses: {
|
|
51
|
-
201:
|
|
52
|
-
400:
|
|
53
|
-
409:
|
|
48
|
+
201: categoryResponseSchema,
|
|
49
|
+
400: jsonApiErrorResponseSchema,
|
|
50
|
+
409: jsonApiErrorResponseSchema,
|
|
54
51
|
},
|
|
55
52
|
summary: 'Create a new category',
|
|
56
53
|
description: 'Creates a farm-specific category or system default category. Farm-specific categories override system defaults for that farm.',
|
|
@@ -62,13 +59,13 @@ exports.categoriesRouter = c.router({
|
|
|
62
59
|
updateCategory: {
|
|
63
60
|
method: 'PATCH',
|
|
64
61
|
path: '/categories/:id',
|
|
65
|
-
pathParams:
|
|
66
|
-
id:
|
|
62
|
+
pathParams: z.object({
|
|
63
|
+
id: z.string().uuid(),
|
|
67
64
|
}),
|
|
68
|
-
body:
|
|
65
|
+
body: updateCategorySchema,
|
|
69
66
|
responses: {
|
|
70
|
-
200:
|
|
71
|
-
404:
|
|
67
|
+
200: categoryResponseSchema,
|
|
68
|
+
404: jsonApiErrorResponseSchema,
|
|
72
69
|
},
|
|
73
70
|
summary: 'Update a category',
|
|
74
71
|
description: 'Updates a farm-specific category. System default categories cannot be updated through this endpoint.',
|
|
@@ -80,12 +77,12 @@ exports.categoriesRouter = c.router({
|
|
|
80
77
|
deleteCategory: {
|
|
81
78
|
method: 'DELETE',
|
|
82
79
|
path: '/categories/:id',
|
|
83
|
-
pathParams:
|
|
84
|
-
id:
|
|
80
|
+
pathParams: z.object({
|
|
81
|
+
id: z.string().uuid(),
|
|
85
82
|
}),
|
|
86
83
|
responses: {
|
|
87
|
-
204:
|
|
88
|
-
404:
|
|
84
|
+
204: z.object({}),
|
|
85
|
+
404: jsonApiErrorResponseSchema,
|
|
89
86
|
},
|
|
90
87
|
summary: 'Delete a category',
|
|
91
88
|
description: 'Deletes a farm-specific category. System default categories cannot be deleted.',
|
|
@@ -1,30 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const common_schemas_1 = require("../schemas/common.schemas");
|
|
8
|
-
const c = (0, core_1.initContract)();
|
|
9
|
-
exports.documentsRouter = c.router({
|
|
1
|
+
import { initContract } from '@ts-rest/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { createDocumentSchema, updateDocumentSchema, documentResponseSchema, documentListResponseSchema, uploadedFileResponseSchema, uploadFileBodySchema, documentTypeSchema, relatedEntityTypeSchema, } from '../schemas/documents.schemas';
|
|
4
|
+
import { jsonApiErrorResponseSchema, jsonApiSuccessResponseSchema, jsonApiPaginationQuerySchema, jsonApiSortQuerySchema, jsonApiIncludeQuerySchema, jsonApiFilterQuerySchema } from '../schemas/common.schemas';
|
|
5
|
+
const c = initContract();
|
|
6
|
+
export const documentsRouter = c.router({
|
|
10
7
|
// List documents for a farm
|
|
11
8
|
listDocuments: {
|
|
12
9
|
method: 'GET',
|
|
13
10
|
path: '/farms/:farmId/documents',
|
|
14
|
-
pathParams:
|
|
15
|
-
query:
|
|
16
|
-
.merge(
|
|
17
|
-
.merge(
|
|
18
|
-
.merge(
|
|
19
|
-
.merge(
|
|
20
|
-
'filter[type]':
|
|
21
|
-
'filter[relatedToType]':
|
|
22
|
-
'filter[relatedToId]':
|
|
11
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
12
|
+
query: jsonApiPaginationQuerySchema
|
|
13
|
+
.merge(jsonApiSortQuerySchema)
|
|
14
|
+
.merge(jsonApiIncludeQuerySchema)
|
|
15
|
+
.merge(jsonApiFilterQuerySchema)
|
|
16
|
+
.merge(z.object({
|
|
17
|
+
'filter[type]': documentTypeSchema.optional(),
|
|
18
|
+
'filter[relatedToType]': relatedEntityTypeSchema.optional(),
|
|
19
|
+
'filter[relatedToId]': z.string().uuid().optional(),
|
|
23
20
|
})),
|
|
24
21
|
responses: {
|
|
25
|
-
200:
|
|
26
|
-
404:
|
|
27
|
-
401:
|
|
22
|
+
200: documentListResponseSchema,
|
|
23
|
+
404: jsonApiErrorResponseSchema,
|
|
24
|
+
401: jsonApiErrorResponseSchema,
|
|
28
25
|
},
|
|
29
26
|
summary: 'List documents',
|
|
30
27
|
description: 'Get all documents for a farm with optional filtering',
|
|
@@ -34,13 +31,13 @@ exports.documentsRouter = c.router({
|
|
|
34
31
|
method: 'POST',
|
|
35
32
|
path: '/farms/:farmId/documents/upload',
|
|
36
33
|
contentType: 'multipart/form-data',
|
|
37
|
-
pathParams:
|
|
38
|
-
body:
|
|
34
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
35
|
+
body: z.union([uploadFileBodySchema, z.undefined()]),
|
|
39
36
|
responses: {
|
|
40
|
-
200:
|
|
41
|
-
400:
|
|
42
|
-
404:
|
|
43
|
-
401:
|
|
37
|
+
200: uploadedFileResponseSchema,
|
|
38
|
+
400: jsonApiErrorResponseSchema,
|
|
39
|
+
404: jsonApiErrorResponseSchema,
|
|
40
|
+
401: jsonApiErrorResponseSchema,
|
|
44
41
|
},
|
|
45
42
|
summary: 'Upload document file',
|
|
46
43
|
description: 'Upload a file and get back the file URL in JSON:API format',
|
|
@@ -50,16 +47,16 @@ exports.documentsRouter = c.router({
|
|
|
50
47
|
method: 'POST',
|
|
51
48
|
path: '/farms/:farmId/documents/:id/upload',
|
|
52
49
|
contentType: 'multipart/form-data',
|
|
53
|
-
pathParams:
|
|
54
|
-
farmId:
|
|
55
|
-
id:
|
|
50
|
+
pathParams: z.object({
|
|
51
|
+
farmId: z.string().uuid(),
|
|
52
|
+
id: z.string().uuid(),
|
|
56
53
|
}),
|
|
57
|
-
body:
|
|
54
|
+
body: uploadFileBodySchema,
|
|
58
55
|
responses: {
|
|
59
|
-
200:
|
|
60
|
-
400:
|
|
61
|
-
404:
|
|
62
|
-
401:
|
|
56
|
+
200: documentResponseSchema,
|
|
57
|
+
400: jsonApiErrorResponseSchema,
|
|
58
|
+
404: jsonApiErrorResponseSchema,
|
|
59
|
+
401: jsonApiErrorResponseSchema,
|
|
63
60
|
},
|
|
64
61
|
summary: 'Upload file to existing document',
|
|
65
62
|
description: 'Upload a file to an existing document record and update it with the file URL',
|
|
@@ -68,14 +65,14 @@ exports.documentsRouter = c.router({
|
|
|
68
65
|
createDocument: {
|
|
69
66
|
method: 'POST',
|
|
70
67
|
path: '/farms/:farmId/documents',
|
|
71
|
-
pathParams:
|
|
72
|
-
body:
|
|
68
|
+
pathParams: z.object({ farmId: z.string().uuid() }),
|
|
69
|
+
body: z.object({ data: createDocumentSchema }),
|
|
73
70
|
responses: {
|
|
74
|
-
201:
|
|
75
|
-
400:
|
|
76
|
-
404:
|
|
77
|
-
401:
|
|
78
|
-
422:
|
|
71
|
+
201: documentResponseSchema,
|
|
72
|
+
400: jsonApiErrorResponseSchema,
|
|
73
|
+
404: jsonApiErrorResponseSchema,
|
|
74
|
+
401: jsonApiErrorResponseSchema,
|
|
75
|
+
422: jsonApiErrorResponseSchema,
|
|
79
76
|
},
|
|
80
77
|
summary: 'Create document',
|
|
81
78
|
description: 'Upload and register a new document',
|
|
@@ -84,15 +81,15 @@ exports.documentsRouter = c.router({
|
|
|
84
81
|
getDocument: {
|
|
85
82
|
method: 'GET',
|
|
86
83
|
path: '/farms/:farmId/documents/:id',
|
|
87
|
-
pathParams:
|
|
88
|
-
farmId:
|
|
89
|
-
id:
|
|
84
|
+
pathParams: z.object({
|
|
85
|
+
farmId: z.string().uuid(),
|
|
86
|
+
id: z.string().uuid(),
|
|
90
87
|
}),
|
|
91
|
-
query:
|
|
88
|
+
query: jsonApiIncludeQuerySchema,
|
|
92
89
|
responses: {
|
|
93
|
-
200:
|
|
94
|
-
404:
|
|
95
|
-
401:
|
|
90
|
+
200: documentResponseSchema,
|
|
91
|
+
404: jsonApiErrorResponseSchema,
|
|
92
|
+
401: jsonApiErrorResponseSchema,
|
|
96
93
|
},
|
|
97
94
|
summary: 'Get document by ID',
|
|
98
95
|
description: 'Get detailed information about a document',
|
|
@@ -101,17 +98,17 @@ exports.documentsRouter = c.router({
|
|
|
101
98
|
updateDocument: {
|
|
102
99
|
method: 'PATCH',
|
|
103
100
|
path: '/farms/:farmId/documents/:id',
|
|
104
|
-
pathParams:
|
|
105
|
-
farmId:
|
|
106
|
-
id:
|
|
101
|
+
pathParams: z.object({
|
|
102
|
+
farmId: z.string().uuid(),
|
|
103
|
+
id: z.string().uuid(),
|
|
107
104
|
}),
|
|
108
|
-
body:
|
|
105
|
+
body: z.object({ data: updateDocumentSchema }),
|
|
109
106
|
responses: {
|
|
110
|
-
200:
|
|
111
|
-
400:
|
|
112
|
-
404:
|
|
113
|
-
401:
|
|
114
|
-
422:
|
|
107
|
+
200: documentResponseSchema,
|
|
108
|
+
400: jsonApiErrorResponseSchema,
|
|
109
|
+
404: jsonApiErrorResponseSchema,
|
|
110
|
+
401: jsonApiErrorResponseSchema,
|
|
111
|
+
422: jsonApiErrorResponseSchema,
|
|
115
112
|
},
|
|
116
113
|
summary: 'Update document',
|
|
117
114
|
description: 'Update document metadata',
|
|
@@ -120,14 +117,14 @@ exports.documentsRouter = c.router({
|
|
|
120
117
|
deleteDocument: {
|
|
121
118
|
method: 'DELETE',
|
|
122
119
|
path: '/farms/:farmId/documents/:id',
|
|
123
|
-
pathParams:
|
|
124
|
-
farmId:
|
|
125
|
-
id:
|
|
120
|
+
pathParams: z.object({
|
|
121
|
+
farmId: z.string().uuid(),
|
|
122
|
+
id: z.string().uuid(),
|
|
126
123
|
}),
|
|
127
124
|
responses: {
|
|
128
|
-
204:
|
|
129
|
-
404:
|
|
130
|
-
401:
|
|
125
|
+
204: jsonApiSuccessResponseSchema,
|
|
126
|
+
404: jsonApiErrorResponseSchema,
|
|
127
|
+
401: jsonApiErrorResponseSchema,
|
|
131
128
|
},
|
|
132
129
|
summary: 'Delete document',
|
|
133
130
|
description: 'Delete a document record',
|
|
@@ -135,14 +132,14 @@ exports.documentsRouter = c.router({
|
|
|
135
132
|
viewDocument: {
|
|
136
133
|
method: 'GET',
|
|
137
134
|
path: '/documents/view/:docId',
|
|
138
|
-
pathParams:
|
|
139
|
-
docId:
|
|
135
|
+
pathParams: z.object({
|
|
136
|
+
docId: z.string(),
|
|
140
137
|
}),
|
|
141
138
|
responses: {
|
|
142
|
-
200:
|
|
143
|
-
404:
|
|
144
|
-
401:
|
|
145
|
-
403:
|
|
139
|
+
200: z.any(),
|
|
140
|
+
404: jsonApiErrorResponseSchema,
|
|
141
|
+
401: jsonApiErrorResponseSchema,
|
|
142
|
+
403: jsonApiErrorResponseSchema,
|
|
146
143
|
},
|
|
147
144
|
summary: 'View document file',
|
|
148
145
|
description: 'Stream or download a document file by its UUID. Extension is optional - both /documents/view/{docId} and /documents/view/{docId}.{ext} work for the same file.',
|