@dakkitor/api-contracts 1.1.5 → 1.1.7

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.
@@ -7,22 +7,13 @@ const zod_1 = require("zod");
7
7
  const error_schemas_1 = require("../common/error-schemas");
8
8
  const pagination_schema_1 = require("../common/pagination.schema");
9
9
  (0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
10
- const ClientStatusSchema = zod_1.z.enum([
11
- 'APPROVED',
12
- 'PENDING_VERIFICATION',
13
- 'BLACKLISTED',
14
- ]);
15
- const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']);
16
- const ClientSortableFieldsSchema = zod_1.z.enum([
17
- 'name',
18
- 'director',
19
- 'createdAt',
20
- 'updatedAt',
21
- ]);
22
- const DateRangeSchema = zod_1.z.object({
23
- from: zod_1.z.string().datetime().optional(),
24
- to: zod_1.z.string().datetime().optional(),
25
- });
10
+ const ClientStatusSchema = zod_1.z
11
+ .enum(['APPROVED', 'PENDING_VERIFICATION', 'BLACKLISTED'])
12
+ .openapi({ title: 'ClientStatus' });
13
+ const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']).openapi({ title: 'SortOrder' });
14
+ const ClientSortableFieldsSchema = zod_1.z
15
+ .enum(['name', 'director', 'createdAt', 'updatedAt'])
16
+ .openapi({ title: 'ClientSortableFields' });
26
17
  exports.ClientUserSchema = zod_1.z.object({
27
18
  id: zod_1.z.string().uuid(),
28
19
  firstName: zod_1.z.string(),
@@ -43,8 +34,14 @@ exports.ClientSchema = zod_1.z
43
34
  .optional()
44
35
  .describe('Reason for Blacklisting'),
45
36
  lastUpdatedBy: exports.ClientUserSchema.describe('Last Updated By'),
46
- createdAt: zod_1.z.string().datetime().describe('Creation Date'),
47
- updatedAt: zod_1.z.string().datetime().describe('Last Update Date'),
37
+ createdAt: zod_1.z
38
+ .union([zod_1.z.string().datetime(), zod_1.z.date()])
39
+ .transform((val) => (val instanceof Date ? val.toISOString() : val))
40
+ .describe('Creation Date'),
41
+ updatedAt: zod_1.z
42
+ .union([zod_1.z.string().datetime(), zod_1.z.date()])
43
+ .transform((val) => (val instanceof Date ? val.toISOString() : val))
44
+ .describe('Last Update Date'),
48
45
  version: zod_1.z.number().describe('Version Number'),
49
46
  agentClientLinks: zod_1.z.object({ agentId: zod_1.z.string() }).describe('Agent Link'),
50
47
  })
@@ -85,7 +82,8 @@ exports.UpdateClientSchema = zod_1.z
85
82
  }, {
86
83
  message: 'blacklistReason is required when status is BLACKLISTED',
87
84
  path: ['blacklistReason'],
88
- });
85
+ })
86
+ .openapi({ title: 'UpdateClient' });
89
87
  exports.FilterClientSchema = zod_1.z.object({
90
88
  limit: zod_1.z.coerce
91
89
  .number()
@@ -95,15 +93,37 @@ exports.FilterClientSchema = zod_1.z.object({
95
93
  name: zod_1.z
96
94
  .string()
97
95
  .optional()
96
+ .nullable()
98
97
  .describe('Filter by client name (case-insensitive contains match)'),
99
- status: ClientStatusSchema.optional().describe('Filter by client status'),
98
+ status: ClientStatusSchema.optional()
99
+ .nullable()
100
+ .describe('Filter by client status'),
100
101
  director: zod_1.z
101
102
  .string()
102
103
  .optional()
104
+ .nullable()
103
105
  .describe('Filter by director name (case-insensitive contains match)'),
104
- createdAt: DateRangeSchema.optional().describe('Filter by created date range.'),
105
- sortBy: ClientSortableFieldsSchema.optional().describe('The field to sort the results by.'),
106
- sortOrder: SortOrderSchema.optional().describe('The order to sort the results by.'),
106
+ createdAt: zod_1.z
107
+ .object({
108
+ from: zod_1.z
109
+ .string()
110
+ .date()
111
+ .nullish()
112
+ .describe('Start of the date range (inclusive).'),
113
+ to: zod_1.z
114
+ .string()
115
+ .date()
116
+ .nullish()
117
+ .describe('End of the date range (inclusive).'),
118
+ })
119
+ .optional()
120
+ .describe('Filter by created date range.'),
121
+ sortBy: ClientSortableFieldsSchema.optional()
122
+ .nullable()
123
+ .describe('The field to sort the results by.'),
124
+ sortOrder: SortOrderSchema.optional()
125
+ .nullable()
126
+ .describe('The order to sort the results by.'),
107
127
  });
108
128
  exports.ClientAutocompleteResponseSchema = zod_1.z
109
129
  .object({
@@ -138,6 +158,7 @@ exports.clientsContractRouter = c.router({
138
158
  },
139
159
  body: exports.CreateClientSchema,
140
160
  summary: 'Create a new client',
161
+ metadata: { tags: ['Clients'], openApi: { operationId: 'createClient' } },
141
162
  },
142
163
  findAll: {
143
164
  method: 'GET',
@@ -147,6 +168,10 @@ exports.clientsContractRouter = c.router({
147
168
  },
148
169
  query: exports.FilterClientSchema,
149
170
  summary: 'Get all clients',
171
+ metadata: {
172
+ tags: ['Clients'],
173
+ openApi: { operationId: 'findAllClients' },
174
+ },
150
175
  },
151
176
  autocomplete: {
152
177
  method: 'GET',
@@ -156,6 +181,10 @@ exports.clientsContractRouter = c.router({
156
181
  },
157
182
  query: exports.AutocompleteQuerySchema,
158
183
  summary: 'Get clients for autocomplete',
184
+ metadata: {
185
+ tags: ['Clients'],
186
+ openApi: { operationId: 'autocompleteClients' },
187
+ },
159
188
  },
160
189
  findOne: {
161
190
  method: 'GET',
@@ -168,6 +197,10 @@ exports.clientsContractRouter = c.router({
168
197
  id: zod_1.z.string().uuid().describe('Client ID'),
169
198
  }),
170
199
  summary: 'Get a client by ID',
200
+ metadata: {
201
+ tags: ['Clients'],
202
+ openApi: { operationId: 'findClientById' },
203
+ },
171
204
  },
172
205
  update: {
173
206
  method: 'PATCH',
@@ -182,12 +215,13 @@ exports.clientsContractRouter = c.router({
182
215
  }),
183
216
  body: exports.UpdateClientSchema,
184
217
  summary: 'Update a client',
218
+ metadata: { tags: ['Clients'], openApi: { operationId: 'updateClient' } },
185
219
  },
186
220
  remove: {
187
221
  method: 'DELETE',
188
222
  path: '/v2/clients/:id',
189
223
  responses: {
190
- 204: zod_1.z.undefined(),
224
+ 224: zod_1.z.undefined(),
191
225
  404: error_schemas_1.ErrorResponseSchema,
192
226
  },
193
227
  pathParams: zod_1.z.object({
@@ -195,6 +229,7 @@ exports.clientsContractRouter = c.router({
195
229
  }),
196
230
  body: c.noBody(),
197
231
  summary: 'Delete a client',
232
+ metadata: { tags: ['Clients'], openApi: { operationId: 'deleteClient' } },
198
233
  },
199
234
  }, {
200
235
  commonResponses: {