@dakkitor/api-contracts 1.1.5 → 1.1.6

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,19 @@ 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({
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' });
17
+ const DateRangeSchema = zod_1.z
18
+ .object({
23
19
  from: zod_1.z.string().datetime().optional(),
24
20
  to: zod_1.z.string().datetime().optional(),
25
- });
21
+ })
22
+ .openapi({ title: 'DateRange' });
26
23
  exports.ClientUserSchema = zod_1.z.object({
27
24
  id: zod_1.z.string().uuid(),
28
25
  firstName: zod_1.z.string(),
@@ -43,8 +40,14 @@ exports.ClientSchema = zod_1.z
43
40
  .optional()
44
41
  .describe('Reason for Blacklisting'),
45
42
  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'),
43
+ createdAt: zod_1.z
44
+ .union([zod_1.z.string().datetime(), zod_1.z.date()])
45
+ .transform((val) => (val instanceof Date ? val.toISOString() : val))
46
+ .describe('Creation Date'),
47
+ updatedAt: zod_1.z
48
+ .union([zod_1.z.string().datetime(), zod_1.z.date()])
49
+ .transform((val) => (val instanceof Date ? val.toISOString() : val))
50
+ .describe('Last Update Date'),
48
51
  version: zod_1.z.number().describe('Version Number'),
49
52
  agentClientLinks: zod_1.z.object({ agentId: zod_1.z.string() }).describe('Agent Link'),
50
53
  })
@@ -85,7 +88,8 @@ exports.UpdateClientSchema = zod_1.z
85
88
  }, {
86
89
  message: 'blacklistReason is required when status is BLACKLISTED',
87
90
  path: ['blacklistReason'],
88
- });
91
+ })
92
+ .openapi({ title: 'UpdateClient' });
89
93
  exports.FilterClientSchema = zod_1.z.object({
90
94
  limit: zod_1.z.coerce
91
95
  .number()
@@ -95,15 +99,25 @@ exports.FilterClientSchema = zod_1.z.object({
95
99
  name: zod_1.z
96
100
  .string()
97
101
  .optional()
102
+ .nullable()
98
103
  .describe('Filter by client name (case-insensitive contains match)'),
99
- status: ClientStatusSchema.optional().describe('Filter by client status'),
104
+ status: ClientStatusSchema.optional()
105
+ .nullable()
106
+ .describe('Filter by client status'),
100
107
  director: zod_1.z
101
108
  .string()
102
109
  .optional()
110
+ .nullable()
103
111
  .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.'),
112
+ createdAt: DateRangeSchema.optional()
113
+ .nullable()
114
+ .describe('Filter by created date range.'),
115
+ sortBy: ClientSortableFieldsSchema.optional()
116
+ .nullable()
117
+ .describe('The field to sort the results by.'),
118
+ sortOrder: SortOrderSchema.optional()
119
+ .nullable()
120
+ .describe('The order to sort the results by.'),
107
121
  });
108
122
  exports.ClientAutocompleteResponseSchema = zod_1.z
109
123
  .object({
@@ -138,6 +152,7 @@ exports.clientsContractRouter = c.router({
138
152
  },
139
153
  body: exports.CreateClientSchema,
140
154
  summary: 'Create a new client',
155
+ metadata: { tags: ['Clients'], openApi: { operationId: 'createClient' } },
141
156
  },
142
157
  findAll: {
143
158
  method: 'GET',
@@ -147,6 +162,10 @@ exports.clientsContractRouter = c.router({
147
162
  },
148
163
  query: exports.FilterClientSchema,
149
164
  summary: 'Get all clients',
165
+ metadata: {
166
+ tags: ['Clients'],
167
+ openApi: { operationId: 'findAllClients' },
168
+ },
150
169
  },
151
170
  autocomplete: {
152
171
  method: 'GET',
@@ -156,6 +175,10 @@ exports.clientsContractRouter = c.router({
156
175
  },
157
176
  query: exports.AutocompleteQuerySchema,
158
177
  summary: 'Get clients for autocomplete',
178
+ metadata: {
179
+ tags: ['Clients'],
180
+ openApi: { operationId: 'autocompleteClients' },
181
+ },
159
182
  },
160
183
  findOne: {
161
184
  method: 'GET',
@@ -168,6 +191,10 @@ exports.clientsContractRouter = c.router({
168
191
  id: zod_1.z.string().uuid().describe('Client ID'),
169
192
  }),
170
193
  summary: 'Get a client by ID',
194
+ metadata: {
195
+ tags: ['Clients'],
196
+ openApi: { operationId: 'findClientById' },
197
+ },
171
198
  },
172
199
  update: {
173
200
  method: 'PATCH',
@@ -182,12 +209,13 @@ exports.clientsContractRouter = c.router({
182
209
  }),
183
210
  body: exports.UpdateClientSchema,
184
211
  summary: 'Update a client',
212
+ metadata: { tags: ['Clients'], openApi: { operationId: 'updateClient' } },
185
213
  },
186
214
  remove: {
187
215
  method: 'DELETE',
188
216
  path: '/v2/clients/:id',
189
217
  responses: {
190
- 204: zod_1.z.undefined(),
218
+ 224: zod_1.z.undefined(),
191
219
  404: error_schemas_1.ErrorResponseSchema,
192
220
  },
193
221
  pathParams: zod_1.z.object({
@@ -195,6 +223,7 @@ exports.clientsContractRouter = c.router({
195
223
  }),
196
224
  body: c.noBody(),
197
225
  summary: 'Delete a client',
226
+ metadata: { tags: ['Clients'], openApi: { operationId: 'deleteClient' } },
198
227
  },
199
228
  }, {
200
229
  commonResponses: {