@dakkitor/api-contracts 1.1.4 → 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 +203 -203
- package/dist/client-contacts/client-contacts.contract.d.ts.map +1 -1
- package/dist/client-contacts/client-contacts.contract.js +20 -8
- package/dist/clients/clients.contract.d.ts +194 -91
- package/dist/clients/clients.contract.d.ts.map +1 -1
- package/dist/clients/clients.contract.js +104 -27
- package/dist/common/api-responses.d.ts +105 -0
- package/dist/common/api-responses.d.ts.map +1 -0
- package/dist/common/api-responses.js +107 -0
- package/dist/common/error-schemas.d.ts.map +1 -1
- package/dist/common/error-schemas.js +6 -2
- package/dist/common/openapi-metadata.d.ts +65 -0
- package/dist/common/openapi-metadata.d.ts.map +1 -0
- package/dist/common/openapi-metadata.js +155 -0
- package/dist/index.d.ts +3732 -1248
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- 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 +7 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clients.contract.d.ts","sourceRoot":"","sources":["../../contracts/clients/clients.contract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clients.contract.d.ts","sourceRoot":"","sources":["../../contracts/clients/clients.contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,QAAA,MAAM,kBAAkB,gEAEa,CAAC;AAEtC,QAAA,MAAM,eAAe,4BAA0D,CAAC;AAEhF,QAAA,MAAM,0BAA0B,2DAEa,CAAC;AAS9C,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FjC,CAAC"}
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clientsContractRouter = exports.PaginatedResponseSchema = exports.AutocompleteQuerySchema = exports.ClientAutocompleteResponseSchema = exports.FilterClientSchema = exports.UpdateClientSchema = exports.CreateClientSchema = exports.ClientSchema = exports.ClientUserSchema = void 0;
|
|
4
|
+
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
4
5
|
const core_1 = require("@ts-rest/core");
|
|
5
6
|
const zod_1 = require("zod");
|
|
6
7
|
const error_schemas_1 = require("../common/error-schemas");
|
|
7
8
|
const pagination_schema_1 = require("../common/pagination.schema");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'PENDING_VERIFICATION',
|
|
11
|
-
'
|
|
12
|
-
]);
|
|
9
|
+
(0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
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({
|
|
19
|
+
from: zod_1.z.string().datetime().optional(),
|
|
20
|
+
to: zod_1.z.string().datetime().optional(),
|
|
21
|
+
})
|
|
22
|
+
.openapi({ title: 'DateRange' });
|
|
13
23
|
exports.ClientUserSchema = zod_1.z.object({
|
|
14
24
|
id: zod_1.z.string().uuid(),
|
|
15
25
|
firstName: zod_1.z.string(),
|
|
16
26
|
lastName: zod_1.z.string(),
|
|
17
27
|
email: zod_1.z.string().email(),
|
|
18
28
|
});
|
|
19
|
-
exports.ClientSchema = zod_1.z
|
|
29
|
+
exports.ClientSchema = zod_1.z
|
|
30
|
+
.object({
|
|
20
31
|
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
21
32
|
name: zod_1.z.string().describe('Client Name'),
|
|
22
33
|
crn: zod_1.z.string().describe('Company Registration Number'),
|
|
@@ -29,16 +40,29 @@ exports.ClientSchema = zod_1.z.object({
|
|
|
29
40
|
.optional()
|
|
30
41
|
.describe('Reason for Blacklisting'),
|
|
31
42
|
lastUpdatedBy: exports.ClientUserSchema.describe('Last Updated By'),
|
|
32
|
-
createdAt: zod_1.z
|
|
33
|
-
|
|
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'),
|
|
34
51
|
version: zod_1.z.number().describe('Version Number'),
|
|
35
52
|
agentClientLinks: zod_1.z.object({ agentId: zod_1.z.string() }).describe('Agent Link'),
|
|
36
|
-
})
|
|
37
|
-
|
|
53
|
+
})
|
|
54
|
+
.openapi({ title: 'Client' });
|
|
55
|
+
exports.CreateClientSchema = zod_1.z
|
|
56
|
+
.object({
|
|
38
57
|
name: zod_1.z.string().max(255).describe('Client Name'),
|
|
39
|
-
govLink: zod_1.z
|
|
58
|
+
govLink: zod_1.z
|
|
59
|
+
.string()
|
|
60
|
+
.url()
|
|
61
|
+
.max(2048)
|
|
62
|
+
.describe('Government Registration Link'),
|
|
40
63
|
director: zod_1.z.string().max(255).describe('Director Name'),
|
|
41
|
-
})
|
|
64
|
+
})
|
|
65
|
+
.openapi({ title: 'CreateClient' });
|
|
42
66
|
exports.UpdateClientSchema = zod_1.z
|
|
43
67
|
.object({
|
|
44
68
|
name: zod_1.z.string().max(255).optional().describe('Client Name'),
|
|
@@ -64,21 +88,59 @@ exports.UpdateClientSchema = zod_1.z
|
|
|
64
88
|
}, {
|
|
65
89
|
message: 'blacklistReason is required when status is BLACKLISTED',
|
|
66
90
|
path: ['blacklistReason'],
|
|
67
|
-
})
|
|
91
|
+
})
|
|
92
|
+
.openapi({ title: 'UpdateClient' });
|
|
68
93
|
exports.FilterClientSchema = zod_1.z.object({
|
|
69
|
-
limit: zod_1.z.coerce
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
94
|
+
limit: zod_1.z.coerce
|
|
95
|
+
.number()
|
|
96
|
+
.default(50)
|
|
97
|
+
.describe('The number of items to return per page.'),
|
|
98
|
+
page: zod_1.z.coerce.number().default(1).describe('The page number to retrieve.'),
|
|
99
|
+
name: zod_1.z
|
|
100
|
+
.string()
|
|
101
|
+
.optional()
|
|
102
|
+
.nullable()
|
|
103
|
+
.describe('Filter by client name (case-insensitive contains match)'),
|
|
104
|
+
status: ClientStatusSchema.optional()
|
|
105
|
+
.nullable()
|
|
106
|
+
.describe('Filter by client status'),
|
|
107
|
+
director: zod_1.z
|
|
108
|
+
.string()
|
|
109
|
+
.optional()
|
|
110
|
+
.nullable()
|
|
111
|
+
.describe('Filter by director name (case-insensitive contains match)'),
|
|
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.'),
|
|
73
121
|
});
|
|
74
|
-
exports.ClientAutocompleteResponseSchema = zod_1.z
|
|
122
|
+
exports.ClientAutocompleteResponseSchema = zod_1.z
|
|
123
|
+
.object({
|
|
75
124
|
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
76
125
|
name: zod_1.z.string().describe('Client Name'),
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
126
|
+
})
|
|
127
|
+
.openapi({ title: 'ClientAutocomplete' });
|
|
128
|
+
exports.AutocompleteQuerySchema = zod_1.z
|
|
129
|
+
.object({
|
|
130
|
+
query: zod_1.z
|
|
131
|
+
.string()
|
|
132
|
+
.optional()
|
|
133
|
+
.describe('Search query string to filter results'),
|
|
134
|
+
id: zod_1.z
|
|
135
|
+
.string()
|
|
136
|
+
.uuid()
|
|
137
|
+
.optional()
|
|
138
|
+
.describe('Specific record ID to include in results'),
|
|
139
|
+
})
|
|
140
|
+
.openapi({ title: 'AutocompleteQuery' });
|
|
141
|
+
exports.PaginatedResponseSchema = (0, pagination_schema_1.createPaginatedResponseSchema)(exports.ClientSchema)
|
|
142
|
+
.describe('Resources retrieved successfully.')
|
|
143
|
+
.openapi({ title: 'ClientsPaginatedResponse' });
|
|
82
144
|
const c = (0, core_1.initContract)();
|
|
83
145
|
exports.clientsContractRouter = c.router({
|
|
84
146
|
create: {
|
|
@@ -90,6 +152,7 @@ exports.clientsContractRouter = c.router({
|
|
|
90
152
|
},
|
|
91
153
|
body: exports.CreateClientSchema,
|
|
92
154
|
summary: 'Create a new client',
|
|
155
|
+
metadata: { tags: ['Clients'], openApi: { operationId: 'createClient' } },
|
|
93
156
|
},
|
|
94
157
|
findAll: {
|
|
95
158
|
method: 'GET',
|
|
@@ -99,6 +162,10 @@ exports.clientsContractRouter = c.router({
|
|
|
99
162
|
},
|
|
100
163
|
query: exports.FilterClientSchema,
|
|
101
164
|
summary: 'Get all clients',
|
|
165
|
+
metadata: {
|
|
166
|
+
tags: ['Clients'],
|
|
167
|
+
openApi: { operationId: 'findAllClients' },
|
|
168
|
+
},
|
|
102
169
|
},
|
|
103
170
|
autocomplete: {
|
|
104
171
|
method: 'GET',
|
|
@@ -108,6 +175,10 @@ exports.clientsContractRouter = c.router({
|
|
|
108
175
|
},
|
|
109
176
|
query: exports.AutocompleteQuerySchema,
|
|
110
177
|
summary: 'Get clients for autocomplete',
|
|
178
|
+
metadata: {
|
|
179
|
+
tags: ['Clients'],
|
|
180
|
+
openApi: { operationId: 'autocompleteClients' },
|
|
181
|
+
},
|
|
111
182
|
},
|
|
112
183
|
findOne: {
|
|
113
184
|
method: 'GET',
|
|
@@ -117,9 +188,13 @@ exports.clientsContractRouter = c.router({
|
|
|
117
188
|
404: error_schemas_1.ErrorResponseSchema,
|
|
118
189
|
},
|
|
119
190
|
pathParams: zod_1.z.object({
|
|
120
|
-
id: zod_1.z.string().uuid(),
|
|
191
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
121
192
|
}),
|
|
122
193
|
summary: 'Get a client by ID',
|
|
194
|
+
metadata: {
|
|
195
|
+
tags: ['Clients'],
|
|
196
|
+
openApi: { operationId: 'findClientById' },
|
|
197
|
+
},
|
|
123
198
|
},
|
|
124
199
|
update: {
|
|
125
200
|
method: 'PATCH',
|
|
@@ -130,23 +205,25 @@ exports.clientsContractRouter = c.router({
|
|
|
130
205
|
409: error_schemas_1.ErrorResponseSchema,
|
|
131
206
|
},
|
|
132
207
|
pathParams: zod_1.z.object({
|
|
133
|
-
id: zod_1.z.string().uuid(),
|
|
208
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
134
209
|
}),
|
|
135
210
|
body: exports.UpdateClientSchema,
|
|
136
211
|
summary: 'Update a client',
|
|
212
|
+
metadata: { tags: ['Clients'], openApi: { operationId: 'updateClient' } },
|
|
137
213
|
},
|
|
138
214
|
remove: {
|
|
139
215
|
method: 'DELETE',
|
|
140
216
|
path: '/v2/clients/:id',
|
|
141
217
|
responses: {
|
|
142
|
-
|
|
218
|
+
224: zod_1.z.undefined(),
|
|
143
219
|
404: error_schemas_1.ErrorResponseSchema,
|
|
144
220
|
},
|
|
145
221
|
pathParams: zod_1.z.object({
|
|
146
|
-
id: zod_1.z.string().uuid(),
|
|
222
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
147
223
|
}),
|
|
148
224
|
body: c.noBody(),
|
|
149
225
|
summary: 'Delete a client',
|
|
226
|
+
metadata: { tags: ['Clients'], openApi: { operationId: 'deleteClient' } },
|
|
150
227
|
},
|
|
151
228
|
}, {
|
|
152
229
|
commonResponses: {
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export declare const CommonErrorResponses: {
|
|
2
|
+
readonly 400: {
|
|
3
|
+
readonly description: "Bad Request. The request could not be understood by the server due to malformed syntax or invalid data.";
|
|
4
|
+
readonly content: {
|
|
5
|
+
readonly 'application/json': {
|
|
6
|
+
readonly schema: {
|
|
7
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
8
|
+
};
|
|
9
|
+
readonly example: {
|
|
10
|
+
readonly statusCode: 400;
|
|
11
|
+
readonly message: "Input validation failed or request is malformed.";
|
|
12
|
+
readonly code: "VALIDATION_ERROR";
|
|
13
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
14
|
+
readonly path: "/v1/example-endpoint";
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly 401: {
|
|
20
|
+
readonly description: "Unauthorized. The user is not authenticated or token is missing/invalid.";
|
|
21
|
+
readonly content: {
|
|
22
|
+
readonly 'application/json': {
|
|
23
|
+
readonly schema: {
|
|
24
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
25
|
+
};
|
|
26
|
+
readonly example: {
|
|
27
|
+
readonly statusCode: 401;
|
|
28
|
+
readonly message: "Authentication required or token is invalid.";
|
|
29
|
+
readonly code: "UNAUTHORIZED";
|
|
30
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
31
|
+
readonly path: "/v1/example-endpoint";
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly 403: {
|
|
37
|
+
readonly description: "Forbidden. The user does not have the necessary permissions for this resource.";
|
|
38
|
+
readonly content: {
|
|
39
|
+
readonly 'application/json': {
|
|
40
|
+
readonly schema: {
|
|
41
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
42
|
+
};
|
|
43
|
+
readonly example: {
|
|
44
|
+
readonly statusCode: 403;
|
|
45
|
+
readonly message: "Access to this resource is forbidden.";
|
|
46
|
+
readonly code: "FORBIDDEN";
|
|
47
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
48
|
+
readonly path: "/v1/example-endpoint";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly 404: {
|
|
54
|
+
readonly description: "Not Found. The requested resource could not be found.";
|
|
55
|
+
readonly content: {
|
|
56
|
+
readonly 'application/json': {
|
|
57
|
+
readonly schema: {
|
|
58
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
59
|
+
};
|
|
60
|
+
readonly example: {
|
|
61
|
+
readonly statusCode: 404;
|
|
62
|
+
readonly message: "The requested resource could not be found.";
|
|
63
|
+
readonly code: "RESOURCE_NOT_FOUND";
|
|
64
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
65
|
+
readonly path: "/v1/example-endpoint";
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
readonly 409: {
|
|
71
|
+
readonly description: "Conflict. The resource already exists.";
|
|
72
|
+
readonly content: {
|
|
73
|
+
readonly 'application/json': {
|
|
74
|
+
readonly schema: {
|
|
75
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
76
|
+
};
|
|
77
|
+
readonly example: {
|
|
78
|
+
readonly statusCode: 409;
|
|
79
|
+
readonly message: "A conflict occurred with the current state of the resource.";
|
|
80
|
+
readonly code: "RESOURCE_CONFLICT";
|
|
81
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
82
|
+
readonly path: "/v1/example-endpoint";
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
readonly 500: {
|
|
88
|
+
readonly description: "Internal Server Error. An unexpected error occurred on the server.";
|
|
89
|
+
readonly content: {
|
|
90
|
+
readonly 'application/json': {
|
|
91
|
+
readonly schema: {
|
|
92
|
+
readonly $ref: "#/components/schemas/ErrorResponse";
|
|
93
|
+
};
|
|
94
|
+
readonly example: {
|
|
95
|
+
readonly statusCode: 500;
|
|
96
|
+
readonly message: "An unexpected error occurred on the server.";
|
|
97
|
+
readonly code: "INTERNAL_SERVER_ERROR";
|
|
98
|
+
readonly timestamp: "2024-01-01T12:00:00.000Z";
|
|
99
|
+
readonly path: "/v1/example-endpoint";
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=api-responses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-responses.d.ts","sourceRoot":"","sources":["../../contracts/common/api-responses.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4GvB,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommonErrorResponses = void 0;
|
|
4
|
+
exports.CommonErrorResponses = {
|
|
5
|
+
400: {
|
|
6
|
+
description: 'Bad Request. The request could not be understood by the server due to malformed syntax or invalid data.',
|
|
7
|
+
content: {
|
|
8
|
+
'application/json': {
|
|
9
|
+
schema: {
|
|
10
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
11
|
+
},
|
|
12
|
+
example: {
|
|
13
|
+
statusCode: 400,
|
|
14
|
+
message: 'Input validation failed or request is malformed.',
|
|
15
|
+
code: 'VALIDATION_ERROR',
|
|
16
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
17
|
+
path: '/v1/example-endpoint',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
401: {
|
|
23
|
+
description: 'Unauthorized. The user is not authenticated or token is missing/invalid.',
|
|
24
|
+
content: {
|
|
25
|
+
'application/json': {
|
|
26
|
+
schema: {
|
|
27
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
28
|
+
},
|
|
29
|
+
example: {
|
|
30
|
+
statusCode: 401,
|
|
31
|
+
message: 'Authentication required or token is invalid.',
|
|
32
|
+
code: 'UNAUTHORIZED',
|
|
33
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
34
|
+
path: '/v1/example-endpoint',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
403: {
|
|
40
|
+
description: 'Forbidden. The user does not have the necessary permissions for this resource.',
|
|
41
|
+
content: {
|
|
42
|
+
'application/json': {
|
|
43
|
+
schema: {
|
|
44
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
45
|
+
},
|
|
46
|
+
example: {
|
|
47
|
+
statusCode: 403,
|
|
48
|
+
message: 'Access to this resource is forbidden.',
|
|
49
|
+
code: 'FORBIDDEN',
|
|
50
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
51
|
+
path: '/v1/example-endpoint',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
404: {
|
|
57
|
+
description: 'Not Found. The requested resource could not be found.',
|
|
58
|
+
content: {
|
|
59
|
+
'application/json': {
|
|
60
|
+
schema: {
|
|
61
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
62
|
+
},
|
|
63
|
+
example: {
|
|
64
|
+
statusCode: 404,
|
|
65
|
+
message: 'The requested resource could not be found.',
|
|
66
|
+
code: 'RESOURCE_NOT_FOUND',
|
|
67
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
68
|
+
path: '/v1/example-endpoint',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
409: {
|
|
74
|
+
description: 'Conflict. The resource already exists.',
|
|
75
|
+
content: {
|
|
76
|
+
'application/json': {
|
|
77
|
+
schema: {
|
|
78
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
79
|
+
},
|
|
80
|
+
example: {
|
|
81
|
+
statusCode: 409,
|
|
82
|
+
message: 'A conflict occurred with the current state of the resource.',
|
|
83
|
+
code: 'RESOURCE_CONFLICT',
|
|
84
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
85
|
+
path: '/v1/example-endpoint',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
500: {
|
|
91
|
+
description: 'Internal Server Error. An unexpected error occurred on the server.',
|
|
92
|
+
content: {
|
|
93
|
+
'application/json': {
|
|
94
|
+
schema: {
|
|
95
|
+
$ref: '#/components/schemas/ErrorResponse',
|
|
96
|
+
},
|
|
97
|
+
example: {
|
|
98
|
+
statusCode: 500,
|
|
99
|
+
message: 'An unexpected error occurred on the server.',
|
|
100
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
101
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
102
|
+
path: '/v1/example-endpoint',
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-schemas.d.ts","sourceRoot":"","sources":["../../contracts/common/error-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error-schemas.d.ts","sourceRoot":"","sources":["../../contracts/common/error-schemas.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAUM,CAAC;AAEvC,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ErrorResponseSchema = void 0;
|
|
4
|
+
const zod_openapi_1 = require("@anatine/zod-openapi");
|
|
4
5
|
const zod_1 = require("zod");
|
|
6
|
+
(0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
5
7
|
/**
|
|
6
8
|
* Shared error response schema matching IErrorResponse interface.
|
|
7
9
|
* This ensures type consistency between backend error handling and contract definitions.
|
|
8
10
|
*/
|
|
9
|
-
exports.ErrorResponseSchema = zod_1.z
|
|
11
|
+
exports.ErrorResponseSchema = zod_1.z
|
|
12
|
+
.object({
|
|
10
13
|
statusCode: zod_1.z.number().describe('HTTP Status Code'),
|
|
11
14
|
message: zod_1.z.string().describe('Human-readable error message'),
|
|
12
15
|
code: zod_1.z.string().describe('Machine-readable error code'),
|
|
@@ -14,4 +17,5 @@ exports.ErrorResponseSchema = zod_1.z.object({
|
|
|
14
17
|
timestamp: zod_1.z.string().describe('Error timestamp'),
|
|
15
18
|
path: zod_1.z.string().describe('Request path'),
|
|
16
19
|
correlationId: zod_1.z.string().optional().describe('Request correlation ID'),
|
|
17
|
-
})
|
|
20
|
+
})
|
|
21
|
+
.openapi({ title: 'ErrorResponse' });
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project: Internal Recruitment Platform API
|
|
3
|
+
* File: openapi-metadata.ts
|
|
4
|
+
*
|
|
5
|
+
* Description: TypeScript types for OpenAPI metadata that can be attached to ts-rest routes.
|
|
6
|
+
* This metadata structure matches the patterns from api-responses.decorator.ts and will be
|
|
7
|
+
* used to post-process the generated OpenAPI spec.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Metadata for a single response status code.
|
|
11
|
+
*/
|
|
12
|
+
export interface ResponseMetadata {
|
|
13
|
+
/**
|
|
14
|
+
* Description of the response.
|
|
15
|
+
*/
|
|
16
|
+
description?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Example response data.
|
|
19
|
+
*/
|
|
20
|
+
example?: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Metadata for OpenAPI documentation that can be attached to ts-rest routes.
|
|
24
|
+
*/
|
|
25
|
+
export interface OpenApiMetadata {
|
|
26
|
+
/**
|
|
27
|
+
* Tags for grouping endpoints in Swagger UI.
|
|
28
|
+
*/
|
|
29
|
+
tags?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Custom response metadata for each status code.
|
|
32
|
+
* Keys are status codes (e.g., '200', '201', '400', '401', etc.)
|
|
33
|
+
*/
|
|
34
|
+
responses?: Record<string, ResponseMetadata>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Standard error response examples and descriptions
|
|
38
|
+
*/
|
|
39
|
+
export declare const STANDARD_ERROR_RESPONSES: Record<number, ResponseMetadata>;
|
|
40
|
+
/**
|
|
41
|
+
* Helper to create metadata for standard CRUD operations
|
|
42
|
+
*/
|
|
43
|
+
export declare const createStandardMetadata: {
|
|
44
|
+
/**
|
|
45
|
+
* Metadata for CREATE operations (201)
|
|
46
|
+
*/
|
|
47
|
+
create: (customResponses?: Record<string, ResponseMetadata>) => OpenApiMetadata;
|
|
48
|
+
/**
|
|
49
|
+
* Metadata for FIND ONE operations (200)
|
|
50
|
+
*/
|
|
51
|
+
findOne: (customResponses?: Record<string, ResponseMetadata>) => OpenApiMetadata;
|
|
52
|
+
/**
|
|
53
|
+
* Metadata for FIND ALL operations (200)
|
|
54
|
+
*/
|
|
55
|
+
findAll: (customResponses?: Record<string, ResponseMetadata>) => OpenApiMetadata;
|
|
56
|
+
/**
|
|
57
|
+
* Metadata for UPDATE operations (200)
|
|
58
|
+
*/
|
|
59
|
+
update: (customResponses?: Record<string, ResponseMetadata>) => OpenApiMetadata;
|
|
60
|
+
/**
|
|
61
|
+
* Metadata for DELETE operations (204)
|
|
62
|
+
*/
|
|
63
|
+
delete: (customResponses?: Record<string, ResponseMetadata>) => OpenApiMetadata;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=openapi-metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi-metadata.d.ts","sourceRoot":"","sources":["../../contracts/common/openapi-metadata.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAiErE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;IACjC;;OAEG;+BAEiB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KACjD,eAAe;IAWlB;;OAEG;gCAEiB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KACjD,eAAe;IAWlB;;OAEG;gCAEiB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KACjD,eAAe;IAUlB;;OAEG;+BAEiB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KACjD,eAAe;IAuBlB;;OAEG;+BAEiB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KACjD,eAAe;CAUnB,CAAC"}
|