@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
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Project: Internal Recruitment Platform API
|
|
4
|
+
* File: openapi-metadata.ts
|
|
5
|
+
*
|
|
6
|
+
* Description: TypeScript types for OpenAPI metadata that can be attached to ts-rest routes.
|
|
7
|
+
* This metadata structure matches the patterns from api-responses.decorator.ts and will be
|
|
8
|
+
* used to post-process the generated OpenAPI spec.
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.createStandardMetadata = exports.STANDARD_ERROR_RESPONSES = void 0;
|
|
12
|
+
/**
|
|
13
|
+
* Standard error response examples and descriptions
|
|
14
|
+
*/
|
|
15
|
+
exports.STANDARD_ERROR_RESPONSES = {
|
|
16
|
+
400: {
|
|
17
|
+
description: 'Bad Request. The request could not be understood by the server due to malformed syntax or invalid data.',
|
|
18
|
+
example: {
|
|
19
|
+
statusCode: 400,
|
|
20
|
+
message: 'Input validation failed or request is malformed.',
|
|
21
|
+
code: 'VALIDATION_ERROR',
|
|
22
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
23
|
+
path: '/v2/example-endpoint',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
401: {
|
|
27
|
+
description: 'Unauthorized. The user is not authenticated or token is missing/invalid.',
|
|
28
|
+
example: {
|
|
29
|
+
statusCode: 401,
|
|
30
|
+
message: 'Authentication required or token is invalid.',
|
|
31
|
+
code: 'UNAUTHORIZED',
|
|
32
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
33
|
+
path: '/v2/example-endpoint',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
403: {
|
|
37
|
+
description: 'Forbidden. The user does not have the necessary permissions for this resource.',
|
|
38
|
+
example: {
|
|
39
|
+
statusCode: 403,
|
|
40
|
+
message: 'Access to this resource is forbidden.',
|
|
41
|
+
code: 'FORBIDDEN',
|
|
42
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
43
|
+
path: '/v2/example-endpoint',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
404: {
|
|
47
|
+
description: 'Not Found. The requested resource could not be found.',
|
|
48
|
+
example: {
|
|
49
|
+
statusCode: 404,
|
|
50
|
+
message: 'The requested resource could not be found.',
|
|
51
|
+
code: 'RESOURCE_NOT_FOUND',
|
|
52
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
53
|
+
path: '/v2/example-endpoint',
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
409: {
|
|
57
|
+
description: 'Conflict. The resource already exists.',
|
|
58
|
+
example: {
|
|
59
|
+
statusCode: 409,
|
|
60
|
+
message: 'A conflict occurred with the current state of the resource.',
|
|
61
|
+
code: 'RESOURCE_CONFLICT',
|
|
62
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
63
|
+
path: '/v2/example-endpoint',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
500: {
|
|
67
|
+
description: 'Internal Server Error. An unexpected error occurred on the server.',
|
|
68
|
+
example: {
|
|
69
|
+
statusCode: 500,
|
|
70
|
+
message: 'An unexpected error occurred on the server.',
|
|
71
|
+
code: 'INTERNAL_SERVER_ERROR',
|
|
72
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
73
|
+
path: '/v2/example-endpoint',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Helper to create metadata for standard CRUD operations
|
|
79
|
+
*/
|
|
80
|
+
exports.createStandardMetadata = {
|
|
81
|
+
/**
|
|
82
|
+
* Metadata for CREATE operations (201)
|
|
83
|
+
*/
|
|
84
|
+
create: (customResponses) => ({
|
|
85
|
+
responses: {
|
|
86
|
+
201: {
|
|
87
|
+
description: 'Resource created successfully.',
|
|
88
|
+
},
|
|
89
|
+
...exports.STANDARD_ERROR_RESPONSES,
|
|
90
|
+
409: exports.STANDARD_ERROR_RESPONSES[409],
|
|
91
|
+
...customResponses,
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
/**
|
|
95
|
+
* Metadata for FIND ONE operations (200)
|
|
96
|
+
*/
|
|
97
|
+
findOne: (customResponses) => ({
|
|
98
|
+
responses: {
|
|
99
|
+
200: {
|
|
100
|
+
description: 'Resource retrieved successfully.',
|
|
101
|
+
},
|
|
102
|
+
...exports.STANDARD_ERROR_RESPONSES,
|
|
103
|
+
404: exports.STANDARD_ERROR_RESPONSES[404],
|
|
104
|
+
...customResponses,
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
/**
|
|
108
|
+
* Metadata for FIND ALL operations (200)
|
|
109
|
+
*/
|
|
110
|
+
findAll: (customResponses) => ({
|
|
111
|
+
responses: {
|
|
112
|
+
200: {
|
|
113
|
+
description: 'Resources retrieved successfully.',
|
|
114
|
+
},
|
|
115
|
+
...exports.STANDARD_ERROR_RESPONSES,
|
|
116
|
+
...customResponses,
|
|
117
|
+
},
|
|
118
|
+
}),
|
|
119
|
+
/**
|
|
120
|
+
* Metadata for UPDATE operations (200)
|
|
121
|
+
*/
|
|
122
|
+
update: (customResponses) => ({
|
|
123
|
+
responses: {
|
|
124
|
+
200: {
|
|
125
|
+
description: 'Resource updated successfully.',
|
|
126
|
+
},
|
|
127
|
+
...exports.STANDARD_ERROR_RESPONSES,
|
|
128
|
+
404: exports.STANDARD_ERROR_RESPONSES[404],
|
|
129
|
+
409: {
|
|
130
|
+
description: 'Conflict. The resource already exists or the update causes a conflict.',
|
|
131
|
+
example: {
|
|
132
|
+
statusCode: 409,
|
|
133
|
+
message: 'A conflict occurred with the current state of the resource during update.',
|
|
134
|
+
code: 'RESOURCE_CONFLICT',
|
|
135
|
+
timestamp: '2024-01-01T12:00:00.000Z',
|
|
136
|
+
path: '/v2/example-endpoint',
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
...customResponses,
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
/**
|
|
143
|
+
* Metadata for DELETE operations (204)
|
|
144
|
+
*/
|
|
145
|
+
delete: (customResponses) => ({
|
|
146
|
+
responses: {
|
|
147
|
+
204: {
|
|
148
|
+
description: 'Resource deleted successfully.',
|
|
149
|
+
},
|
|
150
|
+
...exports.STANDARD_ERROR_RESPONSES,
|
|
151
|
+
404: exports.STANDARD_ERROR_RESPONSES[404],
|
|
152
|
+
...customResponses,
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
};
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const createPaginatedResponseSchema: <T extends z.ZodTypeAny>(itemSchema: T) => z.ZodObject<{
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
items: z.ZodArray<T, "many">;
|
|
4
|
+
totalCount: z.ZodNumber;
|
|
5
5
|
limit: z.ZodNumber;
|
|
6
6
|
skip: z.ZodNumber;
|
|
7
|
+
currentPage: z.ZodNumber;
|
|
8
|
+
totalPages: z.ZodNumber;
|
|
7
9
|
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
items: T["_output"][];
|
|
11
|
+
totalCount: number;
|
|
10
12
|
limit: number;
|
|
11
13
|
skip: number;
|
|
14
|
+
currentPage: number;
|
|
15
|
+
totalPages: number;
|
|
12
16
|
}, {
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
items: T["_input"][];
|
|
18
|
+
totalCount: number;
|
|
15
19
|
limit: number;
|
|
16
20
|
skip: number;
|
|
21
|
+
currentPage: number;
|
|
22
|
+
totalPages: number;
|
|
17
23
|
}>;
|
|
18
24
|
//# sourceMappingURL=pagination.schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.schema.d.ts","sourceRoot":"","sources":["../../contracts/common/pagination.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAClE,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"pagination.schema.d.ts","sourceRoot":"","sources":["../../contracts/common/pagination.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,6BAA6B,GAAI,CAAC,SAAS,CAAC,CAAC,UAAU,EAClE,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;EAUd,CAAC"}
|
|
@@ -4,10 +4,12 @@ exports.createPaginatedResponseSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const createPaginatedResponseSchema = (itemSchema) => {
|
|
6
6
|
return zod_1.z.object({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
limit: zod_1.z.number().describe('
|
|
10
|
-
skip: zod_1.z.number().describe('
|
|
7
|
+
items: zod_1.z.array(itemSchema).describe('Array of items for the current page'),
|
|
8
|
+
totalCount: zod_1.z.number().describe('Total number of items available'),
|
|
9
|
+
limit: zod_1.z.number().describe('Number of items per page'),
|
|
10
|
+
skip: zod_1.z.number().describe('Number of items skipped (offset)'),
|
|
11
|
+
currentPage: zod_1.z.number().describe('Current page number'),
|
|
12
|
+
totalPages: zod_1.z.number().describe('Total number of pages'),
|
|
11
13
|
});
|
|
12
14
|
};
|
|
13
15
|
exports.createPaginatedResponseSchema = createPaginatedResponseSchema;
|