@deepintel-ltd/farmpro-contracts 1.5.19 → 1.5.21

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"organizations.routes.d.ts","sourceRoot":"","sources":["../../src/routes/organizations.routes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoBxB,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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zod';
3
+ import { createOrganizationSchema, updateOrganizationSchema, organizationResponseSchema, organizationListResponseSchema, createBankAccountSchema, updateBankAccountSchema, bankAccountResponseSchema, bankAccountListResponseSchema, } from '../schemas/organizations.schemas';
4
+ import { jsonApiErrorResponseSchema, idParamSchema, jsonApiPaginationQuerySchema, jsonApiSortQuerySchema, } from '../schemas/common.schemas';
5
+ const c = initContract();
6
+ export const organizationsRouter = c.router({
7
+ // List all organizations for the authenticated user
8
+ listOrganizations: {
9
+ method: 'GET',
10
+ path: '/organizations',
11
+ query: jsonApiPaginationQuerySchema
12
+ .merge(jsonApiSortQuerySchema),
13
+ responses: {
14
+ 200: organizationListResponseSchema,
15
+ 401: jsonApiErrorResponseSchema,
16
+ },
17
+ summary: 'List all organizations',
18
+ description: 'Get a paginated list of organizations for the authenticated user',
19
+ },
20
+ // Create a new organization
21
+ createOrganization: {
22
+ method: 'POST',
23
+ path: '/organizations',
24
+ body: z.object({ data: createOrganizationSchema }),
25
+ responses: {
26
+ 201: organizationResponseSchema,
27
+ 400: jsonApiErrorResponseSchema,
28
+ 401: jsonApiErrorResponseSchema,
29
+ 422: jsonApiErrorResponseSchema,
30
+ },
31
+ summary: 'Create a new organization',
32
+ description: 'Create a new organization. The creator automatically becomes the primary contact person.',
33
+ },
34
+ // Get organization by ID
35
+ getOrganization: {
36
+ method: 'GET',
37
+ path: '/organizations/:id',
38
+ pathParams: idParamSchema,
39
+ responses: {
40
+ 200: organizationResponseSchema,
41
+ 404: jsonApiErrorResponseSchema,
42
+ 401: jsonApiErrorResponseSchema,
43
+ },
44
+ summary: 'Get organization by ID',
45
+ description: 'Get detailed information about a specific organization',
46
+ },
47
+ // Update organization
48
+ updateOrganization: {
49
+ method: 'PATCH',
50
+ path: '/organizations/:id',
51
+ pathParams: idParamSchema,
52
+ body: z.object({ data: updateOrganizationSchema }),
53
+ responses: {
54
+ 200: organizationResponseSchema,
55
+ 400: jsonApiErrorResponseSchema,
56
+ 404: jsonApiErrorResponseSchema,
57
+ 401: jsonApiErrorResponseSchema,
58
+ 422: jsonApiErrorResponseSchema,
59
+ },
60
+ summary: 'Update organization',
61
+ description: 'Update organization information',
62
+ },
63
+ // ============================================================================
64
+ // Bank Account Routes
65
+ // ============================================================================
66
+ // List all bank accounts for an organization
67
+ listBankAccounts: {
68
+ method: 'GET',
69
+ path: '/organizations/:organizationId/bank-accounts',
70
+ pathParams: idParamSchema.extend({ organizationId: z.string().uuid() }),
71
+ query: jsonApiPaginationQuerySchema.merge(jsonApiSortQuerySchema),
72
+ responses: {
73
+ 200: bankAccountListResponseSchema,
74
+ 401: jsonApiErrorResponseSchema,
75
+ 404: jsonApiErrorResponseSchema,
76
+ },
77
+ summary: 'List bank accounts for an organization',
78
+ description: 'Get a paginated list of bank accounts for a specific organization',
79
+ },
80
+ // Create a new bank account
81
+ createBankAccount: {
82
+ method: 'POST',
83
+ path: '/organizations/:organizationId/bank-accounts',
84
+ pathParams: idParamSchema.extend({ organizationId: z.string().uuid() }),
85
+ body: z.object({ data: createBankAccountSchema }),
86
+ responses: {
87
+ 201: bankAccountResponseSchema,
88
+ 400: jsonApiErrorResponseSchema,
89
+ 401: jsonApiErrorResponseSchema,
90
+ 404: jsonApiErrorResponseSchema,
91
+ 422: jsonApiErrorResponseSchema,
92
+ },
93
+ summary: 'Create a new bank account',
94
+ description: 'Create a new bank account for an organization. If isDefault is true, this account becomes the default.',
95
+ },
96
+ // Get bank account by ID
97
+ getBankAccount: {
98
+ method: 'GET',
99
+ path: '/organizations/:organizationId/bank-accounts/:id',
100
+ pathParams: idParamSchema.extend({
101
+ organizationId: z.string().uuid(),
102
+ id: z.string().uuid(),
103
+ }),
104
+ responses: {
105
+ 200: bankAccountResponseSchema,
106
+ 404: jsonApiErrorResponseSchema,
107
+ 401: jsonApiErrorResponseSchema,
108
+ },
109
+ summary: 'Get bank account by ID',
110
+ description: 'Get detailed information about a specific bank account',
111
+ },
112
+ // Update bank account
113
+ updateBankAccount: {
114
+ method: 'PATCH',
115
+ path: '/organizations/:organizationId/bank-accounts/:id',
116
+ pathParams: idParamSchema.extend({
117
+ organizationId: z.string().uuid(),
118
+ id: z.string().uuid(),
119
+ }),
120
+ body: z.object({ data: updateBankAccountSchema }),
121
+ responses: {
122
+ 200: bankAccountResponseSchema,
123
+ 400: jsonApiErrorResponseSchema,
124
+ 404: jsonApiErrorResponseSchema,
125
+ 401: jsonApiErrorResponseSchema,
126
+ 422: jsonApiErrorResponseSchema,
127
+ },
128
+ summary: 'Update bank account',
129
+ description: 'Update bank account information. Setting isDefault to true will make this the default account.',
130
+ },
131
+ // Delete bank account
132
+ deleteBankAccount: {
133
+ method: 'DELETE',
134
+ path: '/organizations/:organizationId/bank-accounts/:id',
135
+ pathParams: idParamSchema.extend({
136
+ organizationId: z.string().uuid(),
137
+ id: z.string().uuid(),
138
+ }),
139
+ responses: {
140
+ 204: z.object({}),
141
+ 400: jsonApiErrorResponseSchema,
142
+ 404: jsonApiErrorResponseSchema,
143
+ 401: jsonApiErrorResponseSchema,
144
+ },
145
+ summary: 'Delete bank account',
146
+ description: 'Delete a bank account. Cannot delete if it is the default account or has associated invoices.',
147
+ },
148
+ });