@avleon/core 0.0.45 → 0.0.48

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.
Files changed (131) hide show
  1. package/README.md +355 -369
  2. package/dist/chunk-9hOWP6kD.cjs +64 -0
  3. package/dist/chunk-DORXReHP.js +37 -0
  4. package/dist/index-BxIMWhgy.d.ts +1284 -0
  5. package/dist/index-DPn7qtzq.d.cts +1283 -0
  6. package/dist/index.cjs +3194 -0
  7. package/dist/index.cjs.map +1 -0
  8. package/dist/index.js +3022 -83
  9. package/dist/index.js.map +1 -0
  10. package/dist/lib-Bk8hUm06.cjs +7847 -0
  11. package/dist/lib-Bk8hUm06.cjs.map +1 -0
  12. package/dist/lib-CvDxBMkR.js +7843 -0
  13. package/dist/lib-CvDxBMkR.js.map +1 -0
  14. package/package.json +67 -116
  15. package/dist/application.d.ts +0 -47
  16. package/dist/application.js +0 -50
  17. package/dist/authentication.d.ts +0 -13
  18. package/dist/authentication.js +0 -16
  19. package/dist/cache.d.ts +0 -12
  20. package/dist/cache.js +0 -78
  21. package/dist/cache.test.d.ts +0 -1
  22. package/dist/cache.test.js +0 -36
  23. package/dist/collection.d.ts +0 -43
  24. package/dist/collection.js +0 -231
  25. package/dist/collection.test.d.ts +0 -1
  26. package/dist/collection.test.js +0 -59
  27. package/dist/config.d.ts +0 -18
  28. package/dist/config.js +0 -58
  29. package/dist/config.test.d.ts +0 -1
  30. package/dist/config.test.js +0 -40
  31. package/dist/constants.d.ts +0 -1
  32. package/dist/constants.js +0 -4
  33. package/dist/container.d.ts +0 -30
  34. package/dist/container.js +0 -55
  35. package/dist/controller.d.ts +0 -50
  36. package/dist/controller.js +0 -71
  37. package/dist/controller.test.d.ts +0 -1
  38. package/dist/controller.test.js +0 -111
  39. package/dist/decorators.d.ts +0 -15
  40. package/dist/decorators.js +0 -41
  41. package/dist/environment-variables.d.ts +0 -49
  42. package/dist/environment-variables.js +0 -130
  43. package/dist/environment-variables.test.d.ts +0 -1
  44. package/dist/environment-variables.test.js +0 -70
  45. package/dist/event-dispatcher.d.ts +0 -23
  46. package/dist/event-dispatcher.js +0 -100
  47. package/dist/event-subscriber.d.ts +0 -14
  48. package/dist/event-subscriber.js +0 -87
  49. package/dist/exceptions/http-exceptions.d.ts +0 -50
  50. package/dist/exceptions/http-exceptions.js +0 -85
  51. package/dist/exceptions/index.d.ts +0 -1
  52. package/dist/exceptions/index.js +0 -17
  53. package/dist/exceptions/system-exception.d.ts +0 -22
  54. package/dist/exceptions/system-exception.js +0 -26
  55. package/dist/file-storage.d.ts +0 -69
  56. package/dist/file-storage.js +0 -323
  57. package/dist/file-storage.test.d.ts +0 -1
  58. package/dist/file-storage.test.js +0 -104
  59. package/dist/helpers.d.ts +0 -44
  60. package/dist/helpers.js +0 -419
  61. package/dist/helpers.test.d.ts +0 -1
  62. package/dist/helpers.test.js +0 -95
  63. package/dist/icore.d.ts +0 -226
  64. package/dist/icore.js +0 -968
  65. package/dist/icore.test.d.ts +0 -1
  66. package/dist/icore.test.js +0 -14
  67. package/dist/index.d.ts +0 -55
  68. package/dist/interfaces/avleon-application.d.ts +0 -27
  69. package/dist/interfaces/avleon-application.js +0 -1
  70. package/dist/kenx-provider.d.ts +0 -7
  71. package/dist/kenx-provider.js +0 -44
  72. package/dist/kenx-provider.test.d.ts +0 -1
  73. package/dist/kenx-provider.test.js +0 -36
  74. package/dist/logger.d.ts +0 -12
  75. package/dist/logger.js +0 -87
  76. package/dist/logger.test.d.ts +0 -1
  77. package/dist/logger.test.js +0 -42
  78. package/dist/map-types.d.ts +0 -17
  79. package/dist/map-types.js +0 -89
  80. package/dist/middleware.d.ts +0 -27
  81. package/dist/middleware.js +0 -64
  82. package/dist/middleware.test.d.ts +0 -1
  83. package/dist/middleware.test.js +0 -121
  84. package/dist/multipart.d.ts +0 -17
  85. package/dist/multipart.js +0 -70
  86. package/dist/multipart.test.d.ts +0 -1
  87. package/dist/multipart.test.js +0 -87
  88. package/dist/openapi.d.ts +0 -343
  89. package/dist/openapi.js +0 -27
  90. package/dist/openapi.test.d.ts +0 -1
  91. package/dist/openapi.test.js +0 -111
  92. package/dist/params.d.ts +0 -17
  93. package/dist/params.js +0 -64
  94. package/dist/params.test.d.ts +0 -1
  95. package/dist/params.test.js +0 -83
  96. package/dist/queue.d.ts +0 -29
  97. package/dist/queue.js +0 -84
  98. package/dist/response.d.ts +0 -16
  99. package/dist/response.js +0 -56
  100. package/dist/results.d.ts +0 -20
  101. package/dist/results.js +0 -32
  102. package/dist/route-methods.d.ts +0 -25
  103. package/dist/route-methods.js +0 -49
  104. package/dist/route-methods.test.d.ts +0 -1
  105. package/dist/route-methods.test.js +0 -129
  106. package/dist/swagger-schema.d.ts +0 -43
  107. package/dist/swagger-schema.js +0 -452
  108. package/dist/swagger-schema.test.d.ts +0 -1
  109. package/dist/swagger-schema.test.js +0 -105
  110. package/dist/testing.d.ts +0 -55
  111. package/dist/testing.js +0 -196
  112. package/dist/types/app-builder.interface.d.ts +0 -15
  113. package/dist/types/app-builder.interface.js +0 -8
  114. package/dist/types/application.interface.d.ts +0 -8
  115. package/dist/types/application.interface.js +0 -2
  116. package/dist/utils/hash.d.ts +0 -4
  117. package/dist/utils/hash.js +0 -15
  118. package/dist/utils/index.d.ts +0 -2
  119. package/dist/utils/index.js +0 -18
  120. package/dist/utils/optional-require.d.ts +0 -8
  121. package/dist/utils/optional-require.js +0 -70
  122. package/dist/validation.d.ts +0 -39
  123. package/dist/validation.js +0 -111
  124. package/dist/validation.test.d.ts +0 -1
  125. package/dist/validation.test.js +0 -61
  126. package/dist/validator-extend.d.ts +0 -7
  127. package/dist/validator-extend.js +0 -28
  128. package/dist/websocket.d.ts +0 -7
  129. package/dist/websocket.js +0 -20
  130. package/dist/websocket.test.d.ts +0 -1
  131. package/dist/websocket.test.js +0 -27
@@ -1,452 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OpenApiProperty = OpenApiProperty;
4
- exports.CreateSwaggerObjectSchema = CreateSwaggerObjectSchema;
5
- exports.generateSwaggerSchema = generateSwaggerSchema;
6
- exports.OpenApiResponse = OpenApiResponse;
7
- /**
8
- * @copyright 2024
9
- * @author Tareq Hossain
10
- * @email xtrinsic96@gmail.com
11
- * @url https://github.com/xtareq
12
- */
13
- const class_validator_1 = require("class-validator");
14
- // Decorator to add OpenAPI metadata to properties
15
- function OpenApiProperty(options) {
16
- return function (target, propertyKey) {
17
- var _a;
18
- let meta = options ? { ...options } : {};
19
- if (meta.format === "binary") {
20
- if (meta.isArray) {
21
- meta = {
22
- ...meta,
23
- type: "array",
24
- items: (_a = meta.items) !== null && _a !== void 0 ? _a : { type: "string", format: "binary" },
25
- description: meta.description || "Array of files",
26
- };
27
- }
28
- else {
29
- meta = {
30
- ...meta,
31
- type: "string",
32
- format: "binary",
33
- description: meta.description || "File upload",
34
- };
35
- }
36
- }
37
- Reflect.defineMetadata("property:openapi", meta, target, propertyKey);
38
- };
39
- }
40
- function extractOpenApiFields(meta) {
41
- const result = {};
42
- const jsonSchemaFields = [
43
- "description",
44
- "deprecated",
45
- "example",
46
- "enum",
47
- "format",
48
- "default",
49
- "minimum",
50
- "maximum",
51
- "minLength",
52
- "maxLength",
53
- "pattern",
54
- "oneOf",
55
- "allOf",
56
- "anyOf",
57
- ];
58
- // Valid JSON Schema formats
59
- const validFormats = [
60
- "date-time",
61
- "date",
62
- "time",
63
- "duration",
64
- "email",
65
- "idn-email",
66
- "hostname",
67
- "idn-hostname",
68
- "ipv4",
69
- "ipv6",
70
- "uri",
71
- "uri-reference",
72
- "iri",
73
- "iri-reference",
74
- "uuid",
75
- "uri-template",
76
- "json-pointer",
77
- "relative-json-pointer",
78
- "regex",
79
- "int32",
80
- "int64",
81
- "float",
82
- "double",
83
- "byte",
84
- "binary",
85
- "password",
86
- ];
87
- jsonSchemaFields.forEach((field) => {
88
- if (meta[field] !== undefined) {
89
- // Validate format field
90
- if (field === "format") {
91
- const formatValue = meta[field];
92
- // Only add format if it's a valid format string
93
- if (validFormats.includes(formatValue)) {
94
- result[field] = formatValue;
95
- }
96
- // Skip invalid formats
97
- }
98
- else {
99
- result[field] = meta[field];
100
- }
101
- }
102
- });
103
- return result;
104
- }
105
- function CreateSwaggerObjectSchema(classType) {
106
- const metadataStorage = (0, class_validator_1.getMetadataStorage)();
107
- const validationMetadata = metadataStorage.getTargetValidationMetadatas(classType, "", true, false);
108
- const schema = {
109
- type: "object",
110
- properties: {},
111
- required: [],
112
- };
113
- const prototype = classType.prototype;
114
- const propertyKeys = new Set();
115
- // Collect property names
116
- Object.getOwnPropertyNames(prototype).forEach((k) => propertyKeys.add(k));
117
- Object.keys(prototype).forEach((k) => propertyKeys.add(k));
118
- validationMetadata.forEach((m) => propertyKeys.add(m.propertyName));
119
- try {
120
- const instance = new classType();
121
- Reflect.ownKeys(instance).forEach((k) => {
122
- if (typeof k === "string")
123
- propertyKeys.add(k);
124
- });
125
- }
126
- catch (_) { }
127
- propertyKeys.forEach((propertyName) => {
128
- var _a;
129
- if (!propertyName || propertyName === "constructor")
130
- return;
131
- // Get decorator metadata
132
- const openApiMeta = Reflect.getMetadata("property:openapi", prototype, propertyName);
133
- if (openApiMeta === null || openApiMeta === void 0 ? void 0 : openApiMeta.exclude)
134
- return;
135
- // Get TypeScript type
136
- const propertyType = Reflect.getMetadata("design:type", prototype, propertyName);
137
- let swaggerProperty = {};
138
- switch (propertyType) {
139
- case String:
140
- swaggerProperty.type = "string";
141
- break;
142
- case Number:
143
- swaggerProperty.type = "number";
144
- break;
145
- case Boolean:
146
- swaggerProperty.type = "boolean";
147
- break;
148
- case Date:
149
- swaggerProperty.type = "string";
150
- swaggerProperty.format = "date-time";
151
- break;
152
- case Array:
153
- swaggerProperty.type = "array";
154
- swaggerProperty.items = { type: "string" }; // fallback
155
- break;
156
- case Object:
157
- swaggerProperty = CreateSwaggerObjectSchema(propertyType);
158
- break;
159
- default:
160
- if (propertyType && typeof propertyType === "function") {
161
- swaggerProperty.$ref = `#/components/schemas/${propertyType.name}`;
162
- }
163
- else {
164
- swaggerProperty.type = ((_a = propertyType === null || propertyType === void 0 ? void 0 : propertyType.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "string";
165
- }
166
- }
167
- if (openApiMeta) {
168
- swaggerProperty = {
169
- ...swaggerProperty,
170
- ...openApiMeta,
171
- ...extractOpenApiFields(openApiMeta),
172
- };
173
- // 🪄 Auto-handle file uploads
174
- if (openApiMeta.format === "binary") {
175
- if (openApiMeta.isArray || propertyType === Array) {
176
- swaggerProperty = {
177
- type: "array",
178
- items: { type: "string", format: "binary" },
179
- description: openApiMeta.description || "Array of files",
180
- };
181
- }
182
- else {
183
- swaggerProperty = {
184
- type: "string",
185
- format: "binary",
186
- description: openApiMeta.description || "File upload",
187
- };
188
- }
189
- }
190
- }
191
- schema.properties[propertyName] = swaggerProperty;
192
- });
193
- // Handle validation decorators
194
- validationMetadata.forEach((meta) => {
195
- const propertyName = meta.propertyName;
196
- const property = schema.properties[propertyName];
197
- if (!property)
198
- return;
199
- switch (meta.name) {
200
- case "isNotEmpty":
201
- case "isDefined":
202
- if (!schema.required.includes(propertyName)) {
203
- schema.required.push(propertyName);
204
- }
205
- break;
206
- case "isOptional":
207
- schema.required = schema.required.filter((item) => item !== propertyName);
208
- break;
209
- case "minLength":
210
- property.minLength = meta.constraints[0];
211
- break;
212
- case "maxLength":
213
- property.maxLength = meta.constraints[0];
214
- break;
215
- case "min":
216
- property.minimum = meta.constraints[0];
217
- break;
218
- case "max":
219
- property.maximum = meta.constraints[0];
220
- break;
221
- case "isEmail":
222
- property.format = "email";
223
- break;
224
- case "isDate":
225
- property.format = "date-time";
226
- break;
227
- case "isIn":
228
- property.enum = meta.constraints[0];
229
- break;
230
- case "isNumber":
231
- property.type = "number";
232
- break;
233
- case "isInt":
234
- property.type = "integer";
235
- break;
236
- case "isBoolean":
237
- property.type = "boolean";
238
- break;
239
- case "isString":
240
- property.type = "string";
241
- break;
242
- }
243
- });
244
- if (schema.required.length === 0) {
245
- delete schema.required;
246
- }
247
- return schema;
248
- }
249
- function generateSwaggerSchema(classType) {
250
- const metadataStorage = (0, class_validator_1.getMetadataStorage)();
251
- const validationMetadata = metadataStorage.getTargetValidationMetadatas(classType, "", true, false);
252
- const schema = {
253
- type: "object",
254
- properties: {},
255
- required: [],
256
- };
257
- const prototype = classType.prototype;
258
- const propertyKeys = new Set([
259
- ...Object.getOwnPropertyNames(prototype),
260
- ...validationMetadata.map((m) => m.propertyName),
261
- ]);
262
- propertyKeys.forEach((propertyName) => {
263
- var _a;
264
- if (!propertyName || propertyName === "constructor")
265
- return;
266
- const openApiMeta = Reflect.getMetadata("property:openapi", prototype, propertyName);
267
- if (openApiMeta === null || openApiMeta === void 0 ? void 0 : openApiMeta.exclude)
268
- return;
269
- const propertyType = Reflect.getMetadata("design:type", prototype, propertyName);
270
- let swaggerProperty = {};
271
- switch (propertyType) {
272
- case String:
273
- swaggerProperty.type = "string";
274
- break;
275
- case Number:
276
- swaggerProperty.type = "number";
277
- break;
278
- case Boolean:
279
- swaggerProperty.type = "boolean";
280
- break;
281
- case Date:
282
- swaggerProperty.type = "string";
283
- swaggerProperty.format = "date-time";
284
- break;
285
- case Array:
286
- swaggerProperty.type = "array";
287
- swaggerProperty.items = { type: "string" }; // fallback
288
- break;
289
- case Object:
290
- swaggerProperty = generateSwaggerSchema(propertyType);
291
- break;
292
- default:
293
- swaggerProperty.type = ((_a = propertyType === null || propertyType === void 0 ? void 0 : propertyType.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || "string";
294
- }
295
- // Apply OpenApi metadata if present
296
- if (openApiMeta) {
297
- swaggerProperty = {
298
- ...swaggerProperty,
299
- ...extractOpenApiFields(openApiMeta),
300
- };
301
- }
302
- schema.properties[propertyName] = swaggerProperty;
303
- });
304
- // Handle validation rules
305
- validationMetadata.forEach((meta) => {
306
- const propertyName = meta.propertyName;
307
- switch (meta.name) {
308
- case "isNotEmpty":
309
- if (!schema.required.includes(propertyName)) {
310
- schema.required.push(propertyName);
311
- }
312
- break;
313
- case "isDefined":
314
- if (!schema.required.includes(propertyName)) {
315
- schema.required.push(propertyName);
316
- }
317
- break;
318
- case "isOptional":
319
- schema.required = schema.required.filter((item) => item !== propertyName);
320
- break;
321
- case "minLength":
322
- schema.properties[propertyName].minLength = meta.constraints[0];
323
- break;
324
- case "maxLength":
325
- schema.properties[propertyName].maxLength = meta.constraints[0];
326
- break;
327
- case "min":
328
- schema.properties[propertyName].minimum = meta.constraints[0];
329
- break;
330
- case "max":
331
- schema.properties[propertyName].maximum = meta.constraints[0];
332
- break;
333
- case "isEmail":
334
- schema.properties[propertyName].format = "email";
335
- break;
336
- case "isDate":
337
- schema.properties[propertyName].format = "date-time";
338
- break;
339
- case "isIn":
340
- schema.properties[propertyName].enum = meta.constraints[0];
341
- break;
342
- case "isNumber":
343
- schema.properties[propertyName].type = "number";
344
- break;
345
- case "isInt":
346
- schema.properties[propertyName].type = "integer";
347
- break;
348
- case "isBoolean":
349
- schema.properties[propertyName].type = "boolean";
350
- break;
351
- case "isString":
352
- schema.properties[propertyName].type = "string";
353
- break;
354
- }
355
- });
356
- return schema;
357
- }
358
- function OpenApiResponse(code = 200, model, description = "Successful response") {
359
- let dataSchema;
360
- if (typeof model === "function") {
361
- // Class or constructor
362
- dataSchema = generateSwaggerSchema(model);
363
- }
364
- else if (model && typeof model === "object") {
365
- // Example object
366
- dataSchema = inferSchemaFromExample(model);
367
- }
368
- else {
369
- // Fallback
370
- dataSchema = { type: "string" };
371
- }
372
- let message = "OK";
373
- switch (code) {
374
- case 400:
375
- message = "Error";
376
- description = "Error: Bad Request";
377
- break;
378
- case 401:
379
- message = "Error";
380
- description = "Error: Unauthorized";
381
- break;
382
- case 403:
383
- message = "Error";
384
- description = "Error: Forbidden";
385
- break;
386
- case 201:
387
- message = "Created";
388
- description = "Success: Created";
389
- break;
390
- case 500:
391
- message = "Error";
392
- description = "Error: InternalError";
393
- break;
394
- }
395
- return {
396
- description,
397
- content: {
398
- "application/json": {
399
- schema: {
400
- type: "object",
401
- properties: {
402
- code: { type: "number", example: code },
403
- status: { type: "string", example: message },
404
- data: dataSchema,
405
- },
406
- },
407
- },
408
- },
409
- };
410
- }
411
- /**
412
- * Infer a basic JSON schema from a plain JavaScript object.
413
- */
414
- function inferSchemaFromExample(obj) {
415
- var _a;
416
- if (Array.isArray(obj)) {
417
- return {
418
- type: "array",
419
- items: inferSchemaFromExample((_a = obj[0]) !== null && _a !== void 0 ? _a : {}),
420
- };
421
- }
422
- if (obj && typeof obj === "object") {
423
- const properties = {};
424
- for (const [key, value] of Object.entries(obj)) {
425
- properties[key] = inferType(value);
426
- }
427
- return { type: "object", properties };
428
- }
429
- return inferType(obj);
430
- }
431
- /**
432
- * Infer primitive schema type
433
- */
434
- function inferType(value) {
435
- const type = typeof value;
436
- switch (type) {
437
- case "string":
438
- return { type: "string", example: value };
439
- case "number":
440
- return { type: "number", example: value };
441
- case "boolean":
442
- return { type: "boolean", example: value };
443
- case "object":
444
- if (Array.isArray(value))
445
- return inferSchemaFromExample(value);
446
- if (value === null)
447
- return { type: "null" };
448
- return inferSchemaFromExample(value);
449
- default:
450
- return { type: "string" };
451
- }
452
- }
@@ -1 +0,0 @@
1
- import "reflect-metadata";
@@ -1,105 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- require("reflect-metadata");
4
- const swagger_schema_1 = require("./swagger-schema");
5
- // Mocks for class-validator metadata
6
- const mockValidationMetadatas = [
7
- { propertyName: "name", name: "isNotEmpty", constraints: [] },
8
- { propertyName: "age", name: "isInt", constraints: [] },
9
- { propertyName: "email", name: "isEmail", constraints: [] },
10
- { propertyName: "tags", name: "isOptional", constraints: [] },
11
- { propertyName: "desc", name: "minLength", constraints: [5] },
12
- { propertyName: "desc", name: "maxLength", constraints: [100] },
13
- ];
14
- const mockGetMetadataStorage = jest.fn(() => ({
15
- getTargetValidationMetadatas: jest.fn(() => mockValidationMetadatas),
16
- }));
17
- jest.mock("class-validator", () => ({
18
- getMetadataStorage: mockGetMetadataStorage,
19
- }));
20
- // Helper to set Reflect metadata for property types and openapi
21
- function setPropertyMetadata(target, property, type, openApi) {
22
- Reflect.defineMetadata("design:type", type, target, property);
23
- if (openApi) {
24
- Reflect.defineMetadata("property:openapi", openApi, target, property);
25
- }
26
- }
27
- // Test class
28
- class TestDto {
29
- }
30
- setPropertyMetadata(TestDto.prototype, "name", String);
31
- setPropertyMetadata(TestDto.prototype, "age", Number);
32
- setPropertyMetadata(TestDto.prototype, "email", String);
33
- setPropertyMetadata(TestDto.prototype, "tags", Array);
34
- setPropertyMetadata(TestDto.prototype, "desc", String, { description: "Description", example: "A desc" });
35
- setPropertyMetadata(TestDto.prototype, "ignored", String, { exclude: true });
36
- describe("generateSwaggerSchema", () => {
37
- it("should generate correct schema for class properties and validation", () => {
38
- const schema = (0, swagger_schema_1.generateSwaggerSchema)(TestDto);
39
- expect(schema).toEqual({
40
- type: "object",
41
- properties: {
42
- name: { type: "string" },
43
- age: { type: "integer" },
44
- email: { type: "string", format: "email" },
45
- tags: { type: "array", items: { type: "string" } },
46
- desc: {
47
- type: "string",
48
- description: "Description",
49
- example: "A desc",
50
- minLength: 5,
51
- maxLength: 100,
52
- },
53
- },
54
- required: ["name", "age", "email", "desc"],
55
- });
56
- expect(schema.properties.ignored).toBeUndefined();
57
- });
58
- it("should handle openapi metadata fields", () => {
59
- setPropertyMetadata(TestDto.prototype, "desc", String, {
60
- description: "desc field",
61
- example: "example",
62
- deprecated: true,
63
- enum: ["a", "b"],
64
- format: "custom-format",
65
- default: "default",
66
- minimum: 1,
67
- maximum: 10,
68
- minLength: 2,
69
- maxLength: 20,
70
- pattern: ".*",
71
- oneOf: [{ type: "string" }],
72
- allOf: [{ type: "string" }],
73
- anyOf: [{ type: "string" }],
74
- });
75
- const schema = (0, swagger_schema_1.generateSwaggerSchema)(TestDto);
76
- expect(schema.properties.desc).toMatchObject({
77
- description: "desc field",
78
- example: "example",
79
- deprecated: true,
80
- enum: ["a", "b"],
81
- format: "custom-format",
82
- default: "default",
83
- minimum: 1,
84
- maximum: 10,
85
- minLength: 2,
86
- maxLength: 20,
87
- pattern: ".*",
88
- oneOf: [{ type: "string" }],
89
- allOf: [{ type: "string" }],
90
- anyOf: [{ type: "string" }],
91
- type: "string",
92
- });
93
- });
94
- it("should not include excluded properties", () => {
95
- setPropertyMetadata(TestDto.prototype, "ignored", String, { exclude: true });
96
- const schema = (0, swagger_schema_1.generateSwaggerSchema)(TestDto);
97
- expect(schema.properties.ignored).toBeUndefined();
98
- });
99
- it("should fallback to string type if type is unknown", () => {
100
- setPropertyMetadata(TestDto.prototype, "unknown", undefined);
101
- mockValidationMetadatas.push({ propertyName: "unknown", name: "isNotEmpty", constraints: [] });
102
- const schema = (0, swagger_schema_1.generateSwaggerSchema)(TestDto);
103
- expect(schema.properties.unknown.type).toBe("string");
104
- });
105
- });
package/dist/testing.d.ts DELETED
@@ -1,55 +0,0 @@
1
- import "reflect-metadata";
2
- import { DataSourceOptions } from "typeorm";
3
- export declare class AvleonTestUtility {
4
- private static testDataSource;
5
- private static testContainer;
6
- /**
7
- * Initialize test environment
8
- */
9
- static init(options?: {
10
- dataSourceOptions?: DataSourceOptions;
11
- resetContainer?: boolean;
12
- }): Promise<typeof AvleonTestUtility>;
13
- /**
14
- * Mock a dependency for testing
15
- * @param token Dependency token
16
- * @param mockImplementation Mock implementation
17
- */
18
- static mockDependency<T>(token: any, mockImplementation: T): T;
19
- /**
20
- * Create an isolated test instance of a class
21
- * @param ClassType Class to instantiate
22
- * @param overrides Optional property overrides
23
- */
24
- static createTestInstance<T>(ClassType: new (...args: any[]) => T, overrides?: Partial<T>): T;
25
- /**
26
- * Cleanup test environment
27
- */
28
- static cleanup(): Promise<void>;
29
- }
30
- export declare class AvleonTestBuilder {
31
- private controllers;
32
- private testOptions;
33
- private mocks;
34
- /**
35
- * Add controllers for testing
36
- * @param controllers Controllers to add
37
- */
38
- addControllers(...controllers: any[]): this;
39
- /**
40
- * Mock a dependency
41
- * @param token Dependency token
42
- * @param mockImplementation Mock implementation
43
- */
44
- mockDependency(token: any, mockImplementation: any): this;
45
- /**
46
- * Set test options
47
- * @param options Test configuration options
48
- */
49
- setOptions(options: any): this;
50
- /**
51
- * Build test application
52
- */
53
- build(): Promise<import("./icore").TestApplication>;
54
- }
55
- export declare function UnitTest(): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;