@digitaldefiance/node-express-suite 3.11.32 → 3.12.0
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/README.md +858 -0
- package/package.json +1 -1
- package/src/controllers/openapi.d.ts +67 -0
- package/src/controllers/openapi.d.ts.map +1 -0
- package/src/controllers/openapi.js +89 -0
- package/src/controllers/openapi.js.map +1 -0
- package/src/decorators/auth.d.ts +128 -0
- package/src/decorators/auth.d.ts.map +1 -0
- package/src/decorators/auth.js +230 -0
- package/src/decorators/auth.js.map +1 -0
- package/src/decorators/base-controller.d.ts +144 -6
- package/src/decorators/base-controller.d.ts.map +1 -1
- package/src/decorators/base-controller.js +487 -31
- package/src/decorators/base-controller.js.map +1 -1
- package/src/decorators/controller.d.ts +63 -7
- package/src/decorators/controller.d.ts.map +1 -1
- package/src/decorators/controller.js +70 -39
- package/src/decorators/controller.js.map +1 -1
- package/src/decorators/handler-args.d.ts +68 -0
- package/src/decorators/handler-args.d.ts.map +1 -0
- package/src/decorators/handler-args.js +83 -0
- package/src/decorators/handler-args.js.map +1 -0
- package/src/decorators/http-methods.d.ts +143 -0
- package/src/decorators/http-methods.d.ts.map +1 -0
- package/src/decorators/http-methods.js +265 -0
- package/src/decorators/http-methods.js.map +1 -0
- package/src/decorators/index.d.ts +22 -0
- package/src/decorators/index.d.ts.map +1 -1
- package/src/decorators/index.js +56 -0
- package/src/decorators/index.js.map +1 -1
- package/src/decorators/lifecycle.d.ts +248 -0
- package/src/decorators/lifecycle.d.ts.map +1 -0
- package/src/decorators/lifecycle.js +301 -0
- package/src/decorators/lifecycle.js.map +1 -0
- package/src/decorators/metadata-collector.d.ts +175 -0
- package/src/decorators/metadata-collector.d.ts.map +1 -0
- package/src/decorators/metadata-collector.js +272 -0
- package/src/decorators/metadata-collector.js.map +1 -0
- package/src/decorators/metadata-keys.d.ts +121 -0
- package/src/decorators/metadata-keys.d.ts.map +1 -0
- package/src/decorators/metadata-keys.js +116 -0
- package/src/decorators/metadata-keys.js.map +1 -0
- package/src/decorators/middleware.d.ts +181 -0
- package/src/decorators/middleware.d.ts.map +1 -0
- package/src/decorators/middleware.js +400 -0
- package/src/decorators/middleware.js.map +1 -0
- package/src/decorators/openapi-params.d.ts +192 -0
- package/src/decorators/openapi-params.d.ts.map +1 -0
- package/src/decorators/openapi-params.js +332 -0
- package/src/decorators/openapi-params.js.map +1 -0
- package/src/decorators/openapi.d.ts +201 -0
- package/src/decorators/openapi.d.ts.map +1 -0
- package/src/decorators/openapi.js +334 -0
- package/src/decorators/openapi.js.map +1 -0
- package/src/decorators/params.d.ts +217 -0
- package/src/decorators/params.d.ts.map +1 -0
- package/src/decorators/params.js +323 -0
- package/src/decorators/params.js.map +1 -0
- package/src/decorators/response.d.ts +200 -0
- package/src/decorators/response.d.ts.map +1 -0
- package/src/decorators/response.js +315 -0
- package/src/decorators/response.js.map +1 -0
- package/src/decorators/schema.d.ts +99 -0
- package/src/decorators/schema.d.ts.map +1 -0
- package/src/decorators/schema.js +329 -0
- package/src/decorators/schema.js.map +1 -0
- package/src/decorators/transaction.d.ts +69 -0
- package/src/decorators/transaction.d.ts.map +1 -0
- package/src/decorators/transaction.js +80 -0
- package/src/decorators/transaction.js.map +1 -0
- package/src/decorators/validation.d.ts +188 -0
- package/src/decorators/validation.d.ts.map +1 -0
- package/src/decorators/validation.js +269 -0
- package/src/decorators/validation.js.map +1 -0
- package/src/decorators/zod-validation.d.ts +164 -4
- package/src/decorators/zod-validation.d.ts.map +1 -1
- package/src/decorators/zod-validation.js +692 -13
- package/src/decorators/zod-validation.js.map +1 -1
- package/src/index.d.ts +1 -0
- package/src/index.d.ts.map +1 -1
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/interfaces/openApi/decoratorOptions.d.ts +760 -0
- package/src/interfaces/openApi/decoratorOptions.d.ts.map +1 -0
- package/src/interfaces/openApi/decoratorOptions.js +734 -0
- package/src/interfaces/openApi/decoratorOptions.js.map +1 -0
- package/src/interfaces/openApi/index.d.ts +1 -0
- package/src/interfaces/openApi/index.d.ts.map +1 -1
- package/src/interfaces/openApi/index.js +23 -0
- package/src/interfaces/openApi/index.js.map +1 -1
- package/src/interfaces/openApi/parameter.d.ts +2 -0
- package/src/interfaces/openApi/parameter.d.ts.map +1 -1
- package/src/interfaces/openApi/parameter.js +3 -1
- package/src/interfaces/openApi/parameter.js.map +1 -1
- package/src/interfaces/openApi/parameterSchema.d.ts +2 -0
- package/src/interfaces/openApi/parameterSchema.d.ts.map +1 -1
- package/src/interfaces/openApi/parameterSchema.js +3 -0
- package/src/interfaces/openApi/parameterSchema.js.map +1 -1
- package/src/openapi/builder.d.ts +249 -0
- package/src/openapi/builder.d.ts.map +1 -0
- package/src/openapi/builder.js +352 -0
- package/src/openapi/builder.js.map +1 -0
- package/src/openapi/controller.d.ts +153 -0
- package/src/openapi/controller.d.ts.map +1 -0
- package/src/openapi/controller.js +331 -0
- package/src/openapi/controller.js.map +1 -0
- package/src/openapi/index.d.ts +12 -0
- package/src/openapi/index.d.ts.map +1 -0
- package/src/openapi/index.js +20 -0
- package/src/openapi/index.js.map +1 -0
- package/src/openapi/markdown-generator.d.ts +52 -0
- package/src/openapi/markdown-generator.d.ts.map +1 -0
- package/src/openapi/markdown-generator.js +569 -0
- package/src/openapi/markdown-generator.js.map +1 -0
- package/src/openapi/middleware/index.d.ts +9 -0
- package/src/openapi/middleware/index.d.ts.map +1 -0
- package/src/openapi/middleware/index.js +15 -0
- package/src/openapi/middleware/index.js.map +1 -0
- package/src/openapi/middleware/redoc.d.ts +314 -0
- package/src/openapi/middleware/redoc.d.ts.map +1 -0
- package/src/openapi/middleware/redoc.js +181 -0
- package/src/openapi/middleware/redoc.js.map +1 -0
- package/src/openapi/middleware/swagger-ui.d.ts +123 -0
- package/src/openapi/middleware/swagger-ui.d.ts.map +1 -0
- package/src/openapi/middleware/swagger-ui.js +227 -0
- package/src/openapi/middleware/swagger-ui.js.map +1 -0
- package/src/openapi/schemas.d.ts +170 -0
- package/src/openapi/schemas.d.ts.map +1 -0
- package/src/openapi/schemas.js +340 -0
- package/src/openapi/schemas.js.map +1 -0
- package/src/registry/controller-registry.d.ts +78 -0
- package/src/registry/controller-registry.d.ts.map +1 -0
- package/src/registry/controller-registry.js +86 -0
- package/src/registry/controller-registry.js.map +1 -0
- package/src/registry/index.d.ts +2 -0
- package/src/registry/index.d.ts.map +1 -1
- package/src/registry/index.js +3 -1
- package/src/registry/index.js.map +1 -1
- package/src/routers/api.d.ts +2 -1
- package/src/routers/api.d.ts.map +1 -1
- package/src/routers/api.js +7 -1
- package/src/routers/api.js.map +1 -1
- package/src/types.d.ts +1 -0
- package/src/types.d.ts.map +1 -1
- package/src/types.js +1 -0
- package/src/types.js.map +1 -1
|
@@ -0,0 +1,734 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Decorator options interfaces for the Express Suite decorator API.
|
|
4
|
+
* Provides TypeScript interfaces for all decorator configuration options.
|
|
5
|
+
* @module interfaces/openApi/decoratorOptions
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.isApiControllerOptions = isApiControllerOptions;
|
|
9
|
+
exports.isRouteDecoratorOptions = isRouteDecoratorOptions;
|
|
10
|
+
exports.isAuthDecoratorOptions = isAuthDecoratorOptions;
|
|
11
|
+
exports.isParamDecoratorOptions = isParamDecoratorOptions;
|
|
12
|
+
exports.isParamMetadata = isParamMetadata;
|
|
13
|
+
exports.isReturnsDecoratorOptions = isReturnsDecoratorOptions;
|
|
14
|
+
exports.isResponseMetadata = isResponseMetadata;
|
|
15
|
+
exports.isPaginatedDecoratorOptions = isPaginatedDecoratorOptions;
|
|
16
|
+
exports.isCacheDecoratorOptions = isCacheDecoratorOptions;
|
|
17
|
+
exports.isRateLimitDecoratorOptions = isRateLimitDecoratorOptions;
|
|
18
|
+
exports.isTransactionalDecoratorOptions = isTransactionalDecoratorOptions;
|
|
19
|
+
exports.isApiParamDecoratorOptions = isApiParamDecoratorOptions;
|
|
20
|
+
exports.isOpenAPIParamMetadata = isOpenAPIParamMetadata;
|
|
21
|
+
exports.isApiRequestBodyDecoratorOptions = isApiRequestBodyDecoratorOptions;
|
|
22
|
+
exports.isLifecycleMetadata = isLifecycleMetadata;
|
|
23
|
+
exports.isApiSchemaDecoratorOptions = isApiSchemaDecoratorOptions;
|
|
24
|
+
exports.isApiPropertyDecoratorOptions = isApiPropertyDecoratorOptions;
|
|
25
|
+
exports.isSchemaPropertyMetadata = isSchemaPropertyMetadata;
|
|
26
|
+
exports.isSchemaMetadata = isSchemaMetadata;
|
|
27
|
+
exports.isApiOperationDecoratorOptions = isApiOperationDecoratorOptions;
|
|
28
|
+
exports.isApiExampleDecoratorOptions = isApiExampleDecoratorOptions;
|
|
29
|
+
exports.isAuthMetadata = isAuthMetadata;
|
|
30
|
+
exports.isValidationMetadata = isValidationMetadata;
|
|
31
|
+
exports.isMiddlewareMetadata = isMiddlewareMetadata;
|
|
32
|
+
exports.isTransactionMetadata = isTransactionMetadata;
|
|
33
|
+
const zod_1 = require("zod");
|
|
34
|
+
/**
|
|
35
|
+
* Type guard to check if an object is a valid ApiControllerOptions.
|
|
36
|
+
* @param obj - Object to validate
|
|
37
|
+
* @returns True if object matches ApiControllerOptions interface
|
|
38
|
+
*/
|
|
39
|
+
function isApiControllerOptions(obj) {
|
|
40
|
+
if (!obj || typeof obj !== 'object') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const options = obj;
|
|
44
|
+
if (options.tags !== undefined) {
|
|
45
|
+
if (!Array.isArray(options.tags) ||
|
|
46
|
+
!options.tags.every((t) => typeof t === 'string')) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (options.description !== undefined &&
|
|
51
|
+
typeof options.description !== 'string') {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (options.deprecated !== undefined &&
|
|
55
|
+
typeof options.deprecated !== 'boolean') {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
if (options.name !== undefined && typeof options.name !== 'string') {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Type guard to check if an object is a valid RouteDecoratorOptions.
|
|
65
|
+
* @param obj - Object to validate
|
|
66
|
+
* @returns True if object matches RouteDecoratorOptions interface
|
|
67
|
+
*/
|
|
68
|
+
function isRouteDecoratorOptions(obj) {
|
|
69
|
+
if (!obj || typeof obj !== 'object') {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
const options = obj;
|
|
73
|
+
if (options.middleware !== undefined && !Array.isArray(options.middleware)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (options.auth !== undefined && typeof options.auth !== 'boolean') {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
if (options.cryptoAuth !== undefined &&
|
|
80
|
+
typeof options.cryptoAuth !== 'boolean') {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
if (options.rawJson !== undefined && typeof options.rawJson !== 'boolean') {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (options.transaction !== undefined &&
|
|
87
|
+
typeof options.transaction !== 'boolean') {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
if (options.transactionTimeout !== undefined &&
|
|
91
|
+
typeof options.transactionTimeout !== 'number') {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
if (options.summary !== undefined && typeof options.summary !== 'string') {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
if (options.description !== undefined &&
|
|
98
|
+
typeof options.description !== 'string') {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (options.tags !== undefined) {
|
|
102
|
+
if (!Array.isArray(options.tags) ||
|
|
103
|
+
!options.tags.every((t) => typeof t === 'string')) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (options.operationId !== undefined &&
|
|
108
|
+
typeof options.operationId !== 'string') {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (options.deprecated !== undefined &&
|
|
112
|
+
typeof options.deprecated !== 'boolean') {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Type guard to check if an object is a valid AuthDecoratorOptions.
|
|
119
|
+
* @param obj - Object to validate
|
|
120
|
+
* @returns True if object matches AuthDecoratorOptions interface
|
|
121
|
+
*/
|
|
122
|
+
function isAuthDecoratorOptions(obj) {
|
|
123
|
+
if (!obj || typeof obj !== 'object') {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
const options = obj;
|
|
127
|
+
if (options.failureStatusCode !== undefined &&
|
|
128
|
+
typeof options.failureStatusCode !== 'number') {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Type guard to check if an object is a valid ParamDecoratorOptions.
|
|
135
|
+
* @param obj - Object to validate
|
|
136
|
+
* @returns True if object matches ParamDecoratorOptions interface
|
|
137
|
+
*/
|
|
138
|
+
function isParamDecoratorOptions(obj) {
|
|
139
|
+
if (!obj || typeof obj !== 'object') {
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
const options = obj;
|
|
143
|
+
if (options.description !== undefined &&
|
|
144
|
+
typeof options.description !== 'string') {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
if (options.required !== undefined && typeof options.required !== 'boolean') {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (options.deprecated !== undefined &&
|
|
151
|
+
typeof options.deprecated !== 'boolean') {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
// schema and example can be complex types, basic validation only
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Type guard to check if an object is a valid ParamMetadata.
|
|
159
|
+
* @param obj - Object to validate
|
|
160
|
+
* @returns True if object matches ParamMetadata interface
|
|
161
|
+
*/
|
|
162
|
+
function isParamMetadata(obj) {
|
|
163
|
+
if (!obj || typeof obj !== 'object') {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
const metadata = obj;
|
|
167
|
+
if (typeof metadata.index !== 'number') {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
const validTypes = [
|
|
171
|
+
'param',
|
|
172
|
+
'body',
|
|
173
|
+
'query',
|
|
174
|
+
'header',
|
|
175
|
+
'user',
|
|
176
|
+
'eciesUser',
|
|
177
|
+
'req',
|
|
178
|
+
'res',
|
|
179
|
+
'next',
|
|
180
|
+
];
|
|
181
|
+
if (typeof metadata.type !== 'string' ||
|
|
182
|
+
!validTypes.includes(metadata.type)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (metadata.name !== undefined && typeof metadata.name !== 'string') {
|
|
186
|
+
return false;
|
|
187
|
+
}
|
|
188
|
+
if (metadata.options !== undefined &&
|
|
189
|
+
!isParamDecoratorOptions(metadata.options)) {
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Type guard to check if an object is a valid ReturnsDecoratorOptions.
|
|
196
|
+
* @param obj - Object to validate
|
|
197
|
+
* @returns True if object matches ReturnsDecoratorOptions interface
|
|
198
|
+
*/
|
|
199
|
+
function isReturnsDecoratorOptions(obj) {
|
|
200
|
+
if (!obj || typeof obj !== 'object') {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
const options = obj;
|
|
204
|
+
if (options.description !== undefined &&
|
|
205
|
+
typeof options.description !== 'string') {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
// example can be any type
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Type guard to check if an object is a valid ResponseMetadata.
|
|
213
|
+
* @param obj - Object to validate
|
|
214
|
+
* @returns True if object matches ResponseMetadata interface
|
|
215
|
+
*/
|
|
216
|
+
function isResponseMetadata(obj) {
|
|
217
|
+
if (!obj || typeof obj !== 'object') {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
const metadata = obj;
|
|
221
|
+
if (typeof metadata.statusCode !== 'number') {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
if (metadata.schema !== undefined && typeof metadata.schema !== 'string') {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
if (metadata.description !== undefined &&
|
|
228
|
+
typeof metadata.description !== 'string') {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Type guard to check if an object is a valid PaginatedDecoratorOptions.
|
|
235
|
+
* @param obj - Object to validate
|
|
236
|
+
* @returns True if object matches PaginatedDecoratorOptions interface
|
|
237
|
+
*/
|
|
238
|
+
function isPaginatedDecoratorOptions(obj) {
|
|
239
|
+
if (!obj || typeof obj !== 'object') {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
const options = obj;
|
|
243
|
+
if (options.defaultPageSize !== undefined &&
|
|
244
|
+
typeof options.defaultPageSize !== 'number') {
|
|
245
|
+
return false;
|
|
246
|
+
}
|
|
247
|
+
if (options.maxPageSize !== undefined &&
|
|
248
|
+
typeof options.maxPageSize !== 'number') {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
if (options.useOffset !== undefined &&
|
|
252
|
+
typeof options.useOffset !== 'boolean') {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Type guard to check if an object is a valid CacheDecoratorOptions.
|
|
259
|
+
* @param obj - Object to validate
|
|
260
|
+
* @returns True if object matches CacheDecoratorOptions interface
|
|
261
|
+
*/
|
|
262
|
+
function isCacheDecoratorOptions(obj) {
|
|
263
|
+
if (!obj || typeof obj !== 'object') {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
const options = obj;
|
|
267
|
+
if (typeof options.ttl !== 'number') {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
if (options.keyPrefix !== undefined &&
|
|
271
|
+
typeof options.keyPrefix !== 'string') {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
if (options.varyByUser !== undefined &&
|
|
275
|
+
typeof options.varyByUser !== 'boolean') {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
if (options.varyByQuery !== undefined) {
|
|
279
|
+
if (!Array.isArray(options.varyByQuery) ||
|
|
280
|
+
!options.varyByQuery.every((q) => typeof q === 'string')) {
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Type guard to check if an object is a valid RateLimitDecoratorOptions.
|
|
288
|
+
* @param obj - Object to validate
|
|
289
|
+
* @returns True if object matches RateLimitDecoratorOptions interface
|
|
290
|
+
*/
|
|
291
|
+
function isRateLimitDecoratorOptions(obj) {
|
|
292
|
+
if (!obj || typeof obj !== 'object') {
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
const options = obj;
|
|
296
|
+
if (typeof options.requests !== 'number') {
|
|
297
|
+
return false;
|
|
298
|
+
}
|
|
299
|
+
if (typeof options.window !== 'number') {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
if (options.message !== undefined && typeof options.message !== 'string') {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
if (options.byUser !== undefined && typeof options.byUser !== 'boolean') {
|
|
306
|
+
return false;
|
|
307
|
+
}
|
|
308
|
+
if (options.keyGenerator !== undefined &&
|
|
309
|
+
typeof options.keyGenerator !== 'function') {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
return true;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* Type guard to check if an object is a valid TransactionalDecoratorOptions.
|
|
316
|
+
* @param obj - Object to validate
|
|
317
|
+
* @returns True if object matches TransactionalDecoratorOptions interface
|
|
318
|
+
*/
|
|
319
|
+
function isTransactionalDecoratorOptions(obj) {
|
|
320
|
+
if (!obj || typeof obj !== 'object') {
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
const options = obj;
|
|
324
|
+
if (options.timeout !== undefined && typeof options.timeout !== 'number') {
|
|
325
|
+
return false;
|
|
326
|
+
}
|
|
327
|
+
return true;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Type guard to check if an object is a valid ApiParamDecoratorOptions.
|
|
331
|
+
* @param obj - Object to validate
|
|
332
|
+
* @returns True if object matches ApiParamDecoratorOptions interface
|
|
333
|
+
*/
|
|
334
|
+
function isApiParamDecoratorOptions(obj) {
|
|
335
|
+
if (!obj || typeof obj !== 'object') {
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
const options = obj;
|
|
339
|
+
if (options.description !== undefined &&
|
|
340
|
+
typeof options.description !== 'string') {
|
|
341
|
+
return false;
|
|
342
|
+
}
|
|
343
|
+
if (options.required !== undefined && typeof options.required !== 'boolean') {
|
|
344
|
+
return false;
|
|
345
|
+
}
|
|
346
|
+
if (options.deprecated !== undefined &&
|
|
347
|
+
typeof options.deprecated !== 'boolean') {
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
if (options.enum !== undefined) {
|
|
351
|
+
if (!Array.isArray(options.enum) ||
|
|
352
|
+
!options.enum.every((e) => typeof e === 'string')) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return true;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Type guard to check if an object is a valid OpenAPIParamMetadata.
|
|
360
|
+
* @param obj - Object to validate
|
|
361
|
+
* @returns True if object matches OpenAPIParamMetadata interface
|
|
362
|
+
*/
|
|
363
|
+
function isOpenAPIParamMetadata(obj) {
|
|
364
|
+
if (!obj || typeof obj !== 'object') {
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
const metadata = obj;
|
|
368
|
+
if (typeof metadata.name !== 'string') {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
const validLocations = ['path', 'query', 'header', 'cookie'];
|
|
372
|
+
if (typeof metadata.in !== 'string' ||
|
|
373
|
+
!validLocations.includes(metadata.in)) {
|
|
374
|
+
return false;
|
|
375
|
+
}
|
|
376
|
+
if (!metadata.options || !isApiParamDecoratorOptions(metadata.options)) {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
return true;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Type guard to check if an object is a valid ApiRequestBodyDecoratorOptions.
|
|
383
|
+
* @param obj - Object to validate
|
|
384
|
+
* @returns True if object matches ApiRequestBodyDecoratorOptions interface
|
|
385
|
+
*/
|
|
386
|
+
function isApiRequestBodyDecoratorOptions(obj) {
|
|
387
|
+
if (!obj || typeof obj !== 'object') {
|
|
388
|
+
return false;
|
|
389
|
+
}
|
|
390
|
+
const options = obj;
|
|
391
|
+
// schema is required and can be string or ZodSchema
|
|
392
|
+
if (options.schema === undefined) {
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
if (typeof options.schema !== 'string' &&
|
|
396
|
+
!(options.schema instanceof zod_1.z.ZodType)) {
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
if (options.description !== undefined &&
|
|
400
|
+
typeof options.description !== 'string') {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
if (options.required !== undefined && typeof options.required !== 'boolean') {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
if (options.contentType !== undefined &&
|
|
407
|
+
typeof options.contentType !== 'string') {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Type guard to check if an object is a valid LifecycleMetadata.
|
|
414
|
+
* @param obj - Object to validate
|
|
415
|
+
* @returns True if object matches LifecycleMetadata interface
|
|
416
|
+
*/
|
|
417
|
+
function isLifecycleMetadata(obj) {
|
|
418
|
+
if (!obj || typeof obj !== 'object') {
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
const metadata = obj;
|
|
422
|
+
const validateCallbackArray = (arr) => {
|
|
423
|
+
if (!Array.isArray(arr)) {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
return arr.every((cb) => typeof cb === 'function');
|
|
427
|
+
};
|
|
428
|
+
if (metadata.onSuccess !== undefined &&
|
|
429
|
+
!validateCallbackArray(metadata.onSuccess)) {
|
|
430
|
+
return false;
|
|
431
|
+
}
|
|
432
|
+
if (metadata.onError !== undefined &&
|
|
433
|
+
!validateCallbackArray(metadata.onError)) {
|
|
434
|
+
return false;
|
|
435
|
+
}
|
|
436
|
+
if (metadata.before !== undefined &&
|
|
437
|
+
!validateCallbackArray(metadata.before)) {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
if (metadata.after !== undefined && !validateCallbackArray(metadata.after)) {
|
|
441
|
+
return false;
|
|
442
|
+
}
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Type guard to check if an object is a valid ApiSchemaDecoratorOptions.
|
|
447
|
+
* @param obj - Object to validate
|
|
448
|
+
* @returns True if object matches ApiSchemaDecoratorOptions interface
|
|
449
|
+
*/
|
|
450
|
+
function isApiSchemaDecoratorOptions(obj) {
|
|
451
|
+
if (!obj || typeof obj !== 'object') {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
const options = obj;
|
|
455
|
+
if (options.name !== undefined && typeof options.name !== 'string') {
|
|
456
|
+
return false;
|
|
457
|
+
}
|
|
458
|
+
if (options.description !== undefined &&
|
|
459
|
+
typeof options.description !== 'string') {
|
|
460
|
+
return false;
|
|
461
|
+
}
|
|
462
|
+
return true;
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Type guard to check if an object is a valid ApiPropertyDecoratorOptions.
|
|
466
|
+
* @param obj - Object to validate
|
|
467
|
+
* @returns True if object matches ApiPropertyDecoratorOptions interface
|
|
468
|
+
*/
|
|
469
|
+
function isApiPropertyDecoratorOptions(obj) {
|
|
470
|
+
if (!obj || typeof obj !== 'object') {
|
|
471
|
+
return false;
|
|
472
|
+
}
|
|
473
|
+
const options = obj;
|
|
474
|
+
if (options.type !== undefined && typeof options.type !== 'string') {
|
|
475
|
+
return false;
|
|
476
|
+
}
|
|
477
|
+
if (options.format !== undefined && typeof options.format !== 'string') {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (options.description !== undefined &&
|
|
481
|
+
typeof options.description !== 'string') {
|
|
482
|
+
return false;
|
|
483
|
+
}
|
|
484
|
+
if (options.required !== undefined && typeof options.required !== 'boolean') {
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
if (options.nullable !== undefined && typeof options.nullable !== 'boolean') {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
if (options.minimum !== undefined && typeof options.minimum !== 'number') {
|
|
491
|
+
return false;
|
|
492
|
+
}
|
|
493
|
+
if (options.maximum !== undefined && typeof options.maximum !== 'number') {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
if (options.minLength !== undefined &&
|
|
497
|
+
typeof options.minLength !== 'number') {
|
|
498
|
+
return false;
|
|
499
|
+
}
|
|
500
|
+
if (options.maxLength !== undefined &&
|
|
501
|
+
typeof options.maxLength !== 'number') {
|
|
502
|
+
return false;
|
|
503
|
+
}
|
|
504
|
+
if (options.pattern !== undefined && typeof options.pattern !== 'string') {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
if (options.$ref !== undefined && typeof options.$ref !== 'string') {
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
if (options.enum !== undefined) {
|
|
511
|
+
if (!Array.isArray(options.enum) ||
|
|
512
|
+
!options.enum.every((e) => typeof e === 'string')) {
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return true;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Type guard to check if an object is a valid SchemaPropertyMetadata.
|
|
520
|
+
* @param obj - Object to validate
|
|
521
|
+
* @returns True if object matches SchemaPropertyMetadata interface
|
|
522
|
+
*/
|
|
523
|
+
function isSchemaPropertyMetadata(obj) {
|
|
524
|
+
if (!obj || typeof obj !== 'object') {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
const metadata = obj;
|
|
528
|
+
if (typeof metadata.propertyKey !== 'string') {
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
if (!metadata.options || !isApiPropertyDecoratorOptions(metadata.options)) {
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
return true;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Type guard to check if an object is a valid SchemaMetadata.
|
|
538
|
+
* @param obj - Object to validate
|
|
539
|
+
* @returns True if object matches SchemaMetadata interface
|
|
540
|
+
*/
|
|
541
|
+
function isSchemaMetadata(obj) {
|
|
542
|
+
if (!obj || typeof obj !== 'object') {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
const metadata = obj;
|
|
546
|
+
if (typeof metadata.name !== 'string') {
|
|
547
|
+
return false;
|
|
548
|
+
}
|
|
549
|
+
if (!metadata.options || !isApiSchemaDecoratorOptions(metadata.options)) {
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
if (!Array.isArray(metadata.properties)) {
|
|
553
|
+
return false;
|
|
554
|
+
}
|
|
555
|
+
if (!metadata.properties.every((p) => isSchemaPropertyMetadata(p))) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
/**
|
|
561
|
+
* Type guard to check if an object is a valid ApiOperationDecoratorOptions.
|
|
562
|
+
* @param obj - Object to validate
|
|
563
|
+
* @returns True if object matches ApiOperationDecoratorOptions interface
|
|
564
|
+
*/
|
|
565
|
+
function isApiOperationDecoratorOptions(obj) {
|
|
566
|
+
if (!obj || typeof obj !== 'object') {
|
|
567
|
+
return false;
|
|
568
|
+
}
|
|
569
|
+
const options = obj;
|
|
570
|
+
if (options.summary !== undefined && typeof options.summary !== 'string') {
|
|
571
|
+
return false;
|
|
572
|
+
}
|
|
573
|
+
if (options.description !== undefined &&
|
|
574
|
+
typeof options.description !== 'string') {
|
|
575
|
+
return false;
|
|
576
|
+
}
|
|
577
|
+
if (options.tags !== undefined) {
|
|
578
|
+
if (!Array.isArray(options.tags) ||
|
|
579
|
+
!options.tags.every((t) => typeof t === 'string')) {
|
|
580
|
+
return false;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (options.operationId !== undefined &&
|
|
584
|
+
typeof options.operationId !== 'string') {
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
if (options.deprecated !== undefined &&
|
|
588
|
+
typeof options.deprecated !== 'boolean') {
|
|
589
|
+
return false;
|
|
590
|
+
}
|
|
591
|
+
return true;
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
* Type guard to check if an object is a valid ApiExampleDecoratorOptions.
|
|
595
|
+
* @param obj - Object to validate
|
|
596
|
+
* @returns True if object matches ApiExampleDecoratorOptions interface
|
|
597
|
+
*/
|
|
598
|
+
function isApiExampleDecoratorOptions(obj) {
|
|
599
|
+
if (!obj || typeof obj !== 'object') {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
const options = obj;
|
|
603
|
+
// value is required
|
|
604
|
+
if (options.value === undefined) {
|
|
605
|
+
return false;
|
|
606
|
+
}
|
|
607
|
+
if (options.name !== undefined && typeof options.name !== 'string') {
|
|
608
|
+
return false;
|
|
609
|
+
}
|
|
610
|
+
if (options.summary !== undefined && typeof options.summary !== 'string') {
|
|
611
|
+
return false;
|
|
612
|
+
}
|
|
613
|
+
if (options.description !== undefined &&
|
|
614
|
+
typeof options.description !== 'string') {
|
|
615
|
+
return false;
|
|
616
|
+
}
|
|
617
|
+
if (options.type !== undefined &&
|
|
618
|
+
options.type !== 'request' &&
|
|
619
|
+
options.type !== 'response') {
|
|
620
|
+
return false;
|
|
621
|
+
}
|
|
622
|
+
if (options.statusCode !== undefined &&
|
|
623
|
+
typeof options.statusCode !== 'number') {
|
|
624
|
+
return false;
|
|
625
|
+
}
|
|
626
|
+
return true;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Type guard to check if an object is a valid AuthMetadata.
|
|
630
|
+
* @param obj - Object to validate
|
|
631
|
+
* @returns True if object matches AuthMetadata interface
|
|
632
|
+
*/
|
|
633
|
+
function isAuthMetadata(obj) {
|
|
634
|
+
if (!obj || typeof obj !== 'object') {
|
|
635
|
+
return false;
|
|
636
|
+
}
|
|
637
|
+
const metadata = obj;
|
|
638
|
+
if (metadata.requireAuth !== undefined &&
|
|
639
|
+
typeof metadata.requireAuth !== 'boolean') {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
if (metadata.requireCryptoAuth !== undefined &&
|
|
643
|
+
typeof metadata.requireCryptoAuth !== 'boolean') {
|
|
644
|
+
return false;
|
|
645
|
+
}
|
|
646
|
+
if (metadata.isPublic !== undefined &&
|
|
647
|
+
typeof metadata.isPublic !== 'boolean') {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
if (metadata.failureStatusCode !== undefined &&
|
|
651
|
+
typeof metadata.failureStatusCode !== 'number') {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
return true;
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Type guard to check if an object is a valid ValidationMetadata.
|
|
658
|
+
* Note: This performs basic structural validation only.
|
|
659
|
+
* @param obj - Object to validate
|
|
660
|
+
* @returns True if object matches ValidationMetadata interface
|
|
661
|
+
*/
|
|
662
|
+
function isValidationMetadata(obj) {
|
|
663
|
+
if (!obj || typeof obj !== 'object') {
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
const metadata = obj;
|
|
667
|
+
// Each field can be a ZodSchema, ValidationChain[], or function
|
|
668
|
+
// We can only do basic type checking here
|
|
669
|
+
const validateField = (field) => {
|
|
670
|
+
if (field === undefined) {
|
|
671
|
+
return true;
|
|
672
|
+
}
|
|
673
|
+
// Check if it's a function
|
|
674
|
+
if (typeof field === 'function') {
|
|
675
|
+
return true;
|
|
676
|
+
}
|
|
677
|
+
// Check if it's an array (ValidationChain[])
|
|
678
|
+
if (Array.isArray(field)) {
|
|
679
|
+
return true;
|
|
680
|
+
}
|
|
681
|
+
// Check if it's a ZodSchema (has _def property)
|
|
682
|
+
if (field instanceof zod_1.z.ZodType) {
|
|
683
|
+
return true;
|
|
684
|
+
}
|
|
685
|
+
return false;
|
|
686
|
+
};
|
|
687
|
+
if (!validateField(metadata.body)) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
if (!validateField(metadata.params)) {
|
|
691
|
+
return false;
|
|
692
|
+
}
|
|
693
|
+
if (!validateField(metadata.query)) {
|
|
694
|
+
return false;
|
|
695
|
+
}
|
|
696
|
+
return true;
|
|
697
|
+
}
|
|
698
|
+
/**
|
|
699
|
+
* Type guard to check if an object is a valid MiddlewareMetadata.
|
|
700
|
+
* @param obj - Object to validate
|
|
701
|
+
* @returns True if object matches MiddlewareMetadata interface
|
|
702
|
+
*/
|
|
703
|
+
function isMiddlewareMetadata(obj) {
|
|
704
|
+
if (!obj || typeof obj !== 'object') {
|
|
705
|
+
return false;
|
|
706
|
+
}
|
|
707
|
+
const metadata = obj;
|
|
708
|
+
if (!Array.isArray(metadata.middleware)) {
|
|
709
|
+
return false;
|
|
710
|
+
}
|
|
711
|
+
if (!metadata.middleware.every((m) => typeof m === 'function')) {
|
|
712
|
+
return false;
|
|
713
|
+
}
|
|
714
|
+
return true;
|
|
715
|
+
}
|
|
716
|
+
/**
|
|
717
|
+
* Type guard to check if an object is a valid TransactionMetadata.
|
|
718
|
+
* @param obj - Object to validate
|
|
719
|
+
* @returns True if object matches TransactionMetadata interface
|
|
720
|
+
*/
|
|
721
|
+
function isTransactionMetadata(obj) {
|
|
722
|
+
if (!obj || typeof obj !== 'object') {
|
|
723
|
+
return false;
|
|
724
|
+
}
|
|
725
|
+
const metadata = obj;
|
|
726
|
+
if (typeof metadata.useTransaction !== 'boolean') {
|
|
727
|
+
return false;
|
|
728
|
+
}
|
|
729
|
+
if (metadata.timeout !== undefined && typeof metadata.timeout !== 'number') {
|
|
730
|
+
return false;
|
|
731
|
+
}
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
//# sourceMappingURL=decoratorOptions.js.map
|