@dakkitor/api-contracts 1.1.3 → 1.1.5
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/client-contacts/client-contacts.contract.d.ts +762 -465
- package/dist/client-contacts/client-contacts.contract.d.ts.map +1 -1
- package/dist/client-contacts/client-contacts.contract.js +25 -37
- package/dist/clients/clients.contract.d.ts +434 -348
- package/dist/clients/clients.contract.d.ts.map +1 -1
- package/dist/clients/clients.contract.js +80 -51
- 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/common/pagination.schema.d.ts +12 -6
- package/dist/common/pagination.schema.d.ts.map +1 -1
- package/dist/common/pagination.schema.js +6 -4
- package/dist/index.d.ts +701 -659
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- 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;AA0BxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAK3B,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmBM,CAAC;AAEhC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAUM,CAAC;AAEtC,eAAO,MAAM,kBAAkB;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8EjC,CAAC"}
|
|
@@ -1,22 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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");
|
|
9
|
+
(0, zod_openapi_1.extendZodWithOpenApi)(zod_1.z);
|
|
8
10
|
const ClientStatusSchema = zod_1.z.enum([
|
|
9
11
|
'APPROVED',
|
|
10
12
|
'PENDING_VERIFICATION',
|
|
11
13
|
'BLACKLISTED',
|
|
12
14
|
]);
|
|
13
|
-
const
|
|
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
|
+
});
|
|
26
|
+
exports.ClientUserSchema = zod_1.z.object({
|
|
14
27
|
id: zod_1.z.string().uuid(),
|
|
15
28
|
firstName: zod_1.z.string(),
|
|
16
29
|
lastName: zod_1.z.string(),
|
|
17
30
|
email: zod_1.z.string().email(),
|
|
18
31
|
});
|
|
19
|
-
exports.ClientSchema = zod_1.z
|
|
32
|
+
exports.ClientSchema = zod_1.z
|
|
33
|
+
.object({
|
|
20
34
|
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
21
35
|
name: zod_1.z.string().describe('Client Name'),
|
|
22
36
|
crn: zod_1.z.string().describe('Company Registration Number'),
|
|
@@ -28,17 +42,24 @@ exports.ClientSchema = zod_1.z.object({
|
|
|
28
42
|
.nullable()
|
|
29
43
|
.optional()
|
|
30
44
|
.describe('Reason for Blacklisting'),
|
|
31
|
-
lastUpdatedBy:
|
|
45
|
+
lastUpdatedBy: exports.ClientUserSchema.describe('Last Updated By'),
|
|
32
46
|
createdAt: zod_1.z.string().datetime().describe('Creation Date'),
|
|
33
47
|
updatedAt: zod_1.z.string().datetime().describe('Last Update Date'),
|
|
34
48
|
version: zod_1.z.number().describe('Version Number'),
|
|
35
49
|
agentClientLinks: zod_1.z.object({ agentId: zod_1.z.string() }).describe('Agent Link'),
|
|
36
|
-
})
|
|
37
|
-
|
|
50
|
+
})
|
|
51
|
+
.openapi({ title: 'Client' });
|
|
52
|
+
exports.CreateClientSchema = zod_1.z
|
|
53
|
+
.object({
|
|
38
54
|
name: zod_1.z.string().max(255).describe('Client Name'),
|
|
39
|
-
govLink: zod_1.z
|
|
55
|
+
govLink: zod_1.z
|
|
56
|
+
.string()
|
|
57
|
+
.url()
|
|
58
|
+
.max(2048)
|
|
59
|
+
.describe('Government Registration Link'),
|
|
40
60
|
director: zod_1.z.string().max(255).describe('Director Name'),
|
|
41
|
-
})
|
|
61
|
+
})
|
|
62
|
+
.openapi({ title: 'CreateClient' });
|
|
42
63
|
exports.UpdateClientSchema = zod_1.z
|
|
43
64
|
.object({
|
|
44
65
|
name: zod_1.z.string().max(255).optional().describe('Client Name'),
|
|
@@ -66,31 +87,54 @@ exports.UpdateClientSchema = zod_1.z
|
|
|
66
87
|
path: ['blacklistReason'],
|
|
67
88
|
});
|
|
68
89
|
exports.FilterClientSchema = zod_1.z.object({
|
|
69
|
-
limit: zod_1.z.coerce
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
90
|
+
limit: zod_1.z.coerce
|
|
91
|
+
.number()
|
|
92
|
+
.default(50)
|
|
93
|
+
.describe('The number of items to return per page.'),
|
|
94
|
+
page: zod_1.z.coerce.number().default(1).describe('The page number to retrieve.'),
|
|
95
|
+
name: zod_1.z
|
|
96
|
+
.string()
|
|
97
|
+
.optional()
|
|
98
|
+
.describe('Filter by client name (case-insensitive contains match)'),
|
|
99
|
+
status: ClientStatusSchema.optional().describe('Filter by client status'),
|
|
100
|
+
director: zod_1.z
|
|
101
|
+
.string()
|
|
102
|
+
.optional()
|
|
103
|
+
.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.'),
|
|
73
107
|
});
|
|
74
|
-
exports.ClientAutocompleteResponseSchema = zod_1.z
|
|
108
|
+
exports.ClientAutocompleteResponseSchema = zod_1.z
|
|
109
|
+
.object({
|
|
75
110
|
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
76
111
|
name: zod_1.z.string().describe('Client Name'),
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
112
|
+
})
|
|
113
|
+
.openapi({ title: 'ClientAutocomplete' });
|
|
114
|
+
exports.AutocompleteQuerySchema = zod_1.z
|
|
115
|
+
.object({
|
|
116
|
+
query: zod_1.z
|
|
117
|
+
.string()
|
|
118
|
+
.optional()
|
|
119
|
+
.describe('Search query string to filter results'),
|
|
120
|
+
id: zod_1.z
|
|
121
|
+
.string()
|
|
122
|
+
.uuid()
|
|
123
|
+
.optional()
|
|
124
|
+
.describe('Specific record ID to include in results'),
|
|
125
|
+
})
|
|
126
|
+
.openapi({ title: 'AutocompleteQuery' });
|
|
127
|
+
exports.PaginatedResponseSchema = (0, pagination_schema_1.createPaginatedResponseSchema)(exports.ClientSchema)
|
|
128
|
+
.describe('Resources retrieved successfully.')
|
|
129
|
+
.openapi({ title: 'ClientsPaginatedResponse' });
|
|
82
130
|
const c = (0, core_1.initContract)();
|
|
83
|
-
|
|
131
|
+
exports.clientsContractRouter = c.router({
|
|
84
132
|
create: {
|
|
85
133
|
method: 'POST',
|
|
86
134
|
path: '/v2/clients',
|
|
87
135
|
responses: {
|
|
88
136
|
201: exports.ClientSchema,
|
|
89
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
90
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
91
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
92
137
|
409: error_schemas_1.ErrorResponseSchema,
|
|
93
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
94
138
|
},
|
|
95
139
|
body: exports.CreateClientSchema,
|
|
96
140
|
summary: 'Create a new client',
|
|
@@ -100,10 +144,6 @@ const clientsContractConfig = {
|
|
|
100
144
|
path: '/v2/clients',
|
|
101
145
|
responses: {
|
|
102
146
|
200: exports.PaginatedResponseSchema,
|
|
103
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
104
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
105
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
106
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
107
147
|
},
|
|
108
148
|
query: exports.FilterClientSchema,
|
|
109
149
|
summary: 'Get all clients',
|
|
@@ -113,10 +153,6 @@ const clientsContractConfig = {
|
|
|
113
153
|
path: '/v2/clients/autocomplete',
|
|
114
154
|
responses: {
|
|
115
155
|
200: zod_1.z.array(exports.ClientAutocompleteResponseSchema),
|
|
116
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
117
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
118
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
119
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
120
156
|
},
|
|
121
157
|
query: exports.AutocompleteQuerySchema,
|
|
122
158
|
summary: 'Get clients for autocomplete',
|
|
@@ -126,14 +162,10 @@ const clientsContractConfig = {
|
|
|
126
162
|
path: '/v2/clients/:id',
|
|
127
163
|
responses: {
|
|
128
164
|
200: exports.ClientSchema,
|
|
129
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
130
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
131
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
132
165
|
404: error_schemas_1.ErrorResponseSchema,
|
|
133
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
134
166
|
},
|
|
135
167
|
pathParams: zod_1.z.object({
|
|
136
|
-
id: zod_1.z.string().uuid(),
|
|
168
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
137
169
|
}),
|
|
138
170
|
summary: 'Get a client by ID',
|
|
139
171
|
},
|
|
@@ -142,15 +174,11 @@ const clientsContractConfig = {
|
|
|
142
174
|
path: '/v2/clients/:id',
|
|
143
175
|
responses: {
|
|
144
176
|
200: exports.ClientSchema,
|
|
145
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
146
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
147
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
148
177
|
404: error_schemas_1.ErrorResponseSchema,
|
|
149
178
|
409: error_schemas_1.ErrorResponseSchema,
|
|
150
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
151
179
|
},
|
|
152
180
|
pathParams: zod_1.z.object({
|
|
153
|
-
id: zod_1.z.string().uuid(),
|
|
181
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
154
182
|
}),
|
|
155
183
|
body: exports.UpdateClientSchema,
|
|
156
184
|
summary: 'Update a client',
|
|
@@ -159,19 +187,20 @@ const clientsContractConfig = {
|
|
|
159
187
|
method: 'DELETE',
|
|
160
188
|
path: '/v2/clients/:id',
|
|
161
189
|
responses: {
|
|
162
|
-
204: zod_1.z.
|
|
163
|
-
400: error_schemas_1.ErrorResponseSchema,
|
|
164
|
-
401: error_schemas_1.ErrorResponseSchema,
|
|
165
|
-
403: error_schemas_1.ErrorResponseSchema,
|
|
190
|
+
204: zod_1.z.undefined(),
|
|
166
191
|
404: error_schemas_1.ErrorResponseSchema,
|
|
167
|
-
500: error_schemas_1.ErrorResponseSchema,
|
|
168
192
|
},
|
|
169
193
|
pathParams: zod_1.z.object({
|
|
170
|
-
id: zod_1.z.string().uuid(),
|
|
194
|
+
id: zod_1.z.string().uuid().describe('Client ID'),
|
|
171
195
|
}),
|
|
172
|
-
body:
|
|
196
|
+
body: c.noBody(),
|
|
173
197
|
summary: 'Delete a client',
|
|
174
198
|
},
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
199
|
+
}, {
|
|
200
|
+
commonResponses: {
|
|
201
|
+
400: error_schemas_1.ErrorResponseSchema,
|
|
202
|
+
401: error_schemas_1.ErrorResponseSchema,
|
|
203
|
+
403: error_schemas_1.ErrorResponseSchema,
|
|
204
|
+
500: error_schemas_1.ErrorResponseSchema,
|
|
205
|
+
},
|
|
206
|
+
});
|
|
@@ -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"}
|