@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.
- package/dist/actives/actives.contract.d.ts +1582 -0
- package/dist/actives/actives.contract.d.ts.map +1 -0
- package/dist/actives/actives.contract.js +252 -0
- package/dist/client-contacts/client-contacts.contract.d.ts +152 -152
- package/dist/client-contacts/client-contacts.contract.d.ts.map +1 -1
- package/dist/client-contacts/client-contacts.contract.js +8 -2
- package/dist/clients/clients.contract.d.ts +138 -95
- package/dist/clients/clients.contract.d.ts.map +1 -1
- package/dist/clients/clients.contract.js +51 -22
- package/dist/index.d.ts +3775 -1322
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/users/users.contract.d.ts +1442 -0
- package/dist/users/users.contract.d.ts.map +1 -0
- package/dist/users/users.contract.js +214 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"users.contract.d.ts","sourceRoot":"","sources":["../../contracts/users/users.contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuBxB,eAAO,MAAM,iBAAiB;;;;;;;;;EAW5B,CAAC;AAEH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBM,CAAC;AAE9B,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EASM,CAAC;AAEpC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;EAE3B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB3B,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;EAYM,CAAC;AAEjC,eAAO,MAAM,8BAA8B;;;;;;;;;;;;EAMM,CAAC;AAElD,eAAO,MAAM,2BAA2B;;;;;;;;;EAYM,CAAC;AAE/C,e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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FzB,CAAC"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usersContract = exports.PaginatedUserResponseSchema = exports.UserAutocompleteQuerySchema = exports.UserAutocompleteResponseSchema = exports.ProfileSchema = exports.FilterUserSchema = exports.UpdateUserSchema = exports.CreateUserSchema = exports.UserSchema = exports.RolesFilterSchema = void 0;
|
|
4
|
+
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
5
|
+
const core_1 = require("@ts-rest/core");
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const error_schemas_1 = require("../common/error-schemas");
|
|
8
|
+
const pagination_schema_1 = require("../common/pagination.schema");
|
|
9
|
+
(0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
10
|
+
const UserRoleSchema = zod_1.z.enum([
|
|
11
|
+
'ADMIN',
|
|
12
|
+
'SECOND_AGENT',
|
|
13
|
+
'FIRST_AGENT',
|
|
14
|
+
'COMPANY_CHECKING',
|
|
15
|
+
]);
|
|
16
|
+
const SortOrderSchema = zod_1.z.enum(['ASC', 'DESC']);
|
|
17
|
+
const UserSortableFieldsSchema = zod_1.z.enum([
|
|
18
|
+
'lastName',
|
|
19
|
+
'firstName',
|
|
20
|
+
'email',
|
|
21
|
+
'phone',
|
|
22
|
+
'createdAt',
|
|
23
|
+
]);
|
|
24
|
+
exports.RolesFilterSchema = zod_1.z.object({
|
|
25
|
+
values: zod_1.z
|
|
26
|
+
.array(UserRoleSchema)
|
|
27
|
+
.optional()
|
|
28
|
+
.describe('Array of roles to filter by'),
|
|
29
|
+
requireAll: zod_1.z
|
|
30
|
+
.boolean()
|
|
31
|
+
.optional()
|
|
32
|
+
.describe('If true, user must have ALL roles. If false, user must have ANY role. Default: false'),
|
|
33
|
+
});
|
|
34
|
+
exports.UserSchema = zod_1.z
|
|
35
|
+
.object({
|
|
36
|
+
id: zod_1.z.string().uuid().describe('The unique identifier of the user.'),
|
|
37
|
+
firstName: zod_1.z.string().describe("The user's first name."),
|
|
38
|
+
lastName: zod_1.z.string().describe("The user's last name."),
|
|
39
|
+
email: zod_1.z.string().email().describe("The user's email address."),
|
|
40
|
+
phone: zod_1.z.string().describe("The user's phone number."),
|
|
41
|
+
roles: zod_1.z.array(UserRoleSchema).optional().describe("The user's roles."),
|
|
42
|
+
createdAt: zod_1.z
|
|
43
|
+
.union([zod_1.z.string().datetime(), zod_1.z.date()])
|
|
44
|
+
.transform((val) => (val instanceof Date ? val.toISOString() : val))
|
|
45
|
+
.describe('The date and time the user was created.'),
|
|
46
|
+
updatedAt: zod_1.z
|
|
47
|
+
.union([zod_1.z.string().datetime(), zod_1.z.date()])
|
|
48
|
+
.transform((val) => (val instanceof Date ? val.toISOString() : val))
|
|
49
|
+
.describe('The date and time the user was last updated.'),
|
|
50
|
+
})
|
|
51
|
+
.openapi({ title: 'User' });
|
|
52
|
+
exports.CreateUserSchema = zod_1.z
|
|
53
|
+
.object({
|
|
54
|
+
firstName: zod_1.z.string().min(1).describe('Enter first name'),
|
|
55
|
+
lastName: zod_1.z.string().min(1).describe('Enter last name'),
|
|
56
|
+
email: zod_1.z.string().email().describe('Enter email address'),
|
|
57
|
+
phone: zod_1.z.string().min(1).describe('Enter phone number'), // Basic validation, can be enhanced
|
|
58
|
+
password: zod_1.z.string().min(8).optional().describe('Enter password'),
|
|
59
|
+
roles: zod_1.z.array(UserRoleSchema).optional().describe('Select roles'),
|
|
60
|
+
})
|
|
61
|
+
.openapi({ title: 'CreateUser' });
|
|
62
|
+
exports.UpdateUserSchema = exports.CreateUserSchema.partial().openapi({
|
|
63
|
+
title: 'UpdateUser',
|
|
64
|
+
});
|
|
65
|
+
exports.FilterUserSchema = zod_1.z.object({
|
|
66
|
+
page: zod_1.z.coerce.number().default(1).describe('The page number to retrieve.'),
|
|
67
|
+
limit: zod_1.z.coerce
|
|
68
|
+
.number()
|
|
69
|
+
.default(50)
|
|
70
|
+
.describe('The number of items to return per page.'),
|
|
71
|
+
name: zod_1.z
|
|
72
|
+
.string()
|
|
73
|
+
.optional()
|
|
74
|
+
.describe('Filter users by name using fuzzy search (searches firstName and lastName)'),
|
|
75
|
+
email: zod_1.z
|
|
76
|
+
.string()
|
|
77
|
+
.optional()
|
|
78
|
+
.describe('Filter users by email (case-insensitive, partial match)'),
|
|
79
|
+
phone: zod_1.z
|
|
80
|
+
.string()
|
|
81
|
+
.optional()
|
|
82
|
+
.describe('Filter users by phone number (partial match)'),
|
|
83
|
+
roles: exports.RolesFilterSchema.optional().describe('Filter users by roles.'),
|
|
84
|
+
sortBy: UserSortableFieldsSchema.optional().describe('Field to sort users by.'),
|
|
85
|
+
sortOrder: SortOrderSchema.optional().describe('Sort order (ASC or DESC)'),
|
|
86
|
+
});
|
|
87
|
+
exports.ProfileSchema = zod_1.z
|
|
88
|
+
.object({
|
|
89
|
+
id: zod_1.z.string().describe('The unique identifier of the user.'),
|
|
90
|
+
email: zod_1.z.string().describe('The email address of the user.'),
|
|
91
|
+
firstName: zod_1.z.string().optional().describe('The first name of the user.'),
|
|
92
|
+
lastName: zod_1.z.string().optional().describe('The last name of the user.'),
|
|
93
|
+
phone: zod_1.z.string().optional().describe('The phone number of the user.'),
|
|
94
|
+
roles: zod_1.z
|
|
95
|
+
.array(UserRoleSchema)
|
|
96
|
+
.optional()
|
|
97
|
+
.describe('The roles assigned to the user.'),
|
|
98
|
+
})
|
|
99
|
+
.openapi({ title: 'Profile' });
|
|
100
|
+
exports.UserAutocompleteResponseSchema = zod_1.z
|
|
101
|
+
.object({
|
|
102
|
+
id: zod_1.z.string().describe('The unique identifier of the user.'),
|
|
103
|
+
firstName: zod_1.z.string().describe('The first name of the user.'),
|
|
104
|
+
lastName: zod_1.z.string().describe('The last name of the user.'),
|
|
105
|
+
})
|
|
106
|
+
.openapi({ title: 'UserAutocompleteResponse' });
|
|
107
|
+
exports.UserAutocompleteQuerySchema = zod_1.z
|
|
108
|
+
.object({
|
|
109
|
+
query: zod_1.z
|
|
110
|
+
.string()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe('Search query string to filter results'),
|
|
113
|
+
id: zod_1.z
|
|
114
|
+
.string()
|
|
115
|
+
.uuid()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe('Specific record ID to include in results'),
|
|
118
|
+
})
|
|
119
|
+
.openapi({ title: 'UserAutocompleteQuery' });
|
|
120
|
+
exports.PaginatedUserResponseSchema = (0, pagination_schema_1.createPaginatedResponseSchema)(exports.UserSchema)
|
|
121
|
+
.describe('Resources retrieved successfully.')
|
|
122
|
+
.openapi({ title: 'UsersPaginatedResponse' });
|
|
123
|
+
const c = (0, core_1.initContract)();
|
|
124
|
+
exports.usersContract = c.router({
|
|
125
|
+
create: {
|
|
126
|
+
method: 'POST',
|
|
127
|
+
path: '/v2/users',
|
|
128
|
+
responses: {
|
|
129
|
+
201: exports.UserSchema,
|
|
130
|
+
409: error_schemas_1.ErrorResponseSchema,
|
|
131
|
+
},
|
|
132
|
+
body: exports.CreateUserSchema,
|
|
133
|
+
summary: 'Create a new user',
|
|
134
|
+
metadata: { tags: ['Users'] },
|
|
135
|
+
},
|
|
136
|
+
findAll: {
|
|
137
|
+
method: 'GET',
|
|
138
|
+
path: '/v2/users',
|
|
139
|
+
responses: {
|
|
140
|
+
200: exports.PaginatedUserResponseSchema,
|
|
141
|
+
},
|
|
142
|
+
query: exports.FilterUserSchema,
|
|
143
|
+
summary: 'Get all users',
|
|
144
|
+
metadata: { tags: ['Users'] },
|
|
145
|
+
},
|
|
146
|
+
autocomplete: {
|
|
147
|
+
method: 'GET',
|
|
148
|
+
path: '/v2/users/autocomplete',
|
|
149
|
+
responses: {
|
|
150
|
+
200: zod_1.z.array(exports.UserAutocompleteResponseSchema),
|
|
151
|
+
},
|
|
152
|
+
query: exports.UserAutocompleteQuerySchema,
|
|
153
|
+
summary: 'Get users for autocomplete',
|
|
154
|
+
metadata: { tags: ['Users'] },
|
|
155
|
+
},
|
|
156
|
+
me: {
|
|
157
|
+
method: 'GET',
|
|
158
|
+
path: '/v2/users/me',
|
|
159
|
+
responses: {
|
|
160
|
+
200: exports.ProfileSchema,
|
|
161
|
+
},
|
|
162
|
+
summary: 'Get current user profile',
|
|
163
|
+
metadata: { tags: ['Users'] },
|
|
164
|
+
},
|
|
165
|
+
findOne: {
|
|
166
|
+
method: 'GET',
|
|
167
|
+
path: '/v2/users/:id',
|
|
168
|
+
responses: {
|
|
169
|
+
200: exports.UserSchema,
|
|
170
|
+
404: error_schemas_1.ErrorResponseSchema,
|
|
171
|
+
},
|
|
172
|
+
pathParams: zod_1.z.object({
|
|
173
|
+
id: zod_1.z.string().uuid().describe('The ID of the resource (UUID format).'),
|
|
174
|
+
}),
|
|
175
|
+
summary: 'Get a user by ID',
|
|
176
|
+
metadata: { tags: ['Users'] },
|
|
177
|
+
},
|
|
178
|
+
update: {
|
|
179
|
+
method: 'PATCH',
|
|
180
|
+
path: '/v2/users/:id',
|
|
181
|
+
responses: {
|
|
182
|
+
200: exports.UserSchema,
|
|
183
|
+
404: error_schemas_1.ErrorResponseSchema,
|
|
184
|
+
409: error_schemas_1.ErrorResponseSchema,
|
|
185
|
+
},
|
|
186
|
+
pathParams: zod_1.z.object({
|
|
187
|
+
id: zod_1.z.string().uuid().describe('The ID of the resource (UUID format).'),
|
|
188
|
+
}),
|
|
189
|
+
body: exports.UpdateUserSchema,
|
|
190
|
+
summary: 'Update a user by ID',
|
|
191
|
+
metadata: { tags: ['Users'] },
|
|
192
|
+
},
|
|
193
|
+
remove: {
|
|
194
|
+
method: 'DELETE',
|
|
195
|
+
path: '/v2/users/:id',
|
|
196
|
+
responses: {
|
|
197
|
+
204: zod_1.z.undefined(),
|
|
198
|
+
404: error_schemas_1.ErrorResponseSchema,
|
|
199
|
+
},
|
|
200
|
+
pathParams: zod_1.z.object({
|
|
201
|
+
id: zod_1.z.string().uuid().describe('The ID of the resource (UUID format).'),
|
|
202
|
+
}),
|
|
203
|
+
body: c.noBody(),
|
|
204
|
+
summary: 'Delete a user by ID',
|
|
205
|
+
metadata: { tags: ['Users'] },
|
|
206
|
+
},
|
|
207
|
+
}, {
|
|
208
|
+
commonResponses: {
|
|
209
|
+
400: error_schemas_1.ErrorResponseSchema,
|
|
210
|
+
401: error_schemas_1.ErrorResponseSchema,
|
|
211
|
+
403: error_schemas_1.ErrorResponseSchema,
|
|
212
|
+
500: error_schemas_1.ErrorResponseSchema,
|
|
213
|
+
},
|
|
214
|
+
});
|