@solid-nestjs/common 0.2.8 → 0.2.9
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/adapters/index.d.ts +7 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +23 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/validation.adapter.d.ts +20 -0
- package/dist/adapters/validation.adapter.d.ts.map +1 -0
- package/dist/adapters/validation.adapter.js +309 -0
- package/dist/adapters/validation.adapter.js.map +1 -0
- package/dist/decorator-registry/decorator-registry.d.ts +54 -0
- package/dist/decorator-registry/decorator-registry.d.ts.map +1 -0
- package/dist/decorator-registry/decorator-registry.js +161 -0
- package/dist/decorator-registry/decorator-registry.js.map +1 -0
- package/dist/decorator-registry/index.d.ts +2 -0
- package/dist/decorator-registry/index.d.ts.map +1 -0
- package/dist/decorator-registry/index.js +18 -0
- package/dist/decorator-registry/index.js.map +1 -0
- package/dist/decorators/index.d.ts +6 -0
- package/dist/decorators/index.d.ts.map +1 -1
- package/dist/decorators/index.js +6 -0
- package/dist/decorators/index.js.map +1 -1
- package/dist/decorators/solid-entity.decorator.d.ts +6 -0
- package/dist/decorators/solid-entity.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-entity.decorator.js +23 -0
- package/dist/decorators/solid-entity.decorator.js.map +1 -0
- package/dist/decorators/solid-field.decorator.d.ts +7 -0
- package/dist/decorators/solid-field.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-field.decorator.js +51 -0
- package/dist/decorators/solid-field.decorator.js.map +1 -0
- package/dist/decorators/solid-id.decorator.d.ts +9 -0
- package/dist/decorators/solid-id.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-id.decorator.js +27 -0
- package/dist/decorators/solid-id.decorator.js.map +1 -0
- package/dist/decorators/solid-input.decorator.d.ts +6 -0
- package/dist/decorators/solid-input.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-input.decorator.js +35 -0
- package/dist/decorators/solid-input.decorator.js.map +1 -0
- package/dist/decorators/solid-relation.decorator.d.ts +19 -0
- package/dist/decorators/solid-relation.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-relation.decorator.js +66 -0
- package/dist/decorators/solid-relation.decorator.js.map +1 -0
- package/dist/decorators/solid-timestamp.decorator.d.ts +13 -0
- package/dist/decorators/solid-timestamp.decorator.d.ts.map +1 -0
- package/dist/decorators/solid-timestamp.decorator.js +49 -0
- package/dist/decorators/solid-timestamp.decorator.js.map +1 -0
- package/dist/helpers/args-helpers/class-generator.helper.d.ts +143 -0
- package/dist/helpers/args-helpers/class-generator.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/class-generator.helper.js +221 -0
- package/dist/helpers/args-helpers/class-generator.helper.js.map +1 -0
- package/dist/helpers/args-helpers/create-groupby-request.helper.d.ts +83 -0
- package/dist/helpers/args-helpers/create-groupby-request.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/create-groupby-request.helper.js +119 -0
- package/dist/helpers/args-helpers/create-groupby-request.helper.js.map +1 -0
- package/dist/helpers/args-helpers/decorator-builder.helper.d.ts +160 -0
- package/dist/helpers/args-helpers/decorator-builder.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/decorator-builder.helper.js +161 -0
- package/dist/helpers/args-helpers/decorator-builder.helper.js.map +1 -0
- package/dist/helpers/args-helpers/field-config.helper.d.ts +98 -0
- package/dist/helpers/args-helpers/field-config.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/field-config.helper.js +143 -0
- package/dist/helpers/args-helpers/field-config.helper.js.map +1 -0
- package/dist/helpers/args-helpers/groupby-args-from.helper.d.ts +87 -0
- package/dist/helpers/args-helpers/groupby-args-from.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/groupby-args-from.helper.js +185 -0
- package/dist/helpers/args-helpers/groupby-args-from.helper.js.map +1 -0
- package/dist/helpers/args-helpers/index.d.ts +15 -0
- package/dist/helpers/args-helpers/index.d.ts.map +1 -0
- package/dist/helpers/args-helpers/index.js +58 -0
- package/dist/helpers/args-helpers/index.js.map +1 -0
- package/dist/helpers/args-helpers/type-inference.helper.d.ts +191 -0
- package/dist/helpers/args-helpers/type-inference.helper.d.ts.map +1 -0
- package/dist/helpers/args-helpers/type-inference.helper.js +330 -0
- package/dist/helpers/args-helpers/type-inference.helper.js.map +1 -0
- package/dist/helpers/class-generation/dynamic-class.helper.d.ts +101 -0
- package/dist/helpers/class-generation/dynamic-class.helper.d.ts.map +1 -0
- package/dist/helpers/class-generation/dynamic-class.helper.js +180 -0
- package/dist/helpers/class-generation/dynamic-class.helper.js.map +1 -0
- package/dist/helpers/class-generation/index.d.ts +9 -0
- package/dist/helpers/class-generation/index.d.ts.map +1 -0
- package/dist/helpers/class-generation/index.js +18 -0
- package/dist/helpers/class-generation/index.js.map +1 -0
- package/dist/helpers/decorators/decorator-utils.helper.d.ts +75 -0
- package/dist/helpers/decorators/decorator-utils.helper.d.ts.map +1 -0
- package/dist/helpers/decorators/decorator-utils.helper.js +92 -0
- package/dist/helpers/decorators/decorator-utils.helper.js.map +1 -0
- package/dist/helpers/decorators/index.d.ts +9 -0
- package/dist/helpers/decorators/index.d.ts.map +1 -0
- package/dist/helpers/decorators/index.js +16 -0
- package/dist/helpers/decorators/index.js.map +1 -0
- package/dist/helpers/dto-generator-base.helper.d.ts +19 -0
- package/dist/helpers/dto-generator-base.helper.d.ts.map +1 -0
- package/dist/helpers/dto-generator-base.helper.js +72 -0
- package/dist/helpers/dto-generator-base.helper.js.map +1 -0
- package/dist/helpers/index.d.ts +9 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/index.js +9 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/metadata-extractor.helper.d.ts +26 -0
- package/dist/helpers/metadata-extractor.helper.d.ts.map +1 -0
- package/dist/helpers/metadata-extractor.helper.js +67 -0
- package/dist/helpers/metadata-extractor.helper.js.map +1 -0
- package/dist/helpers/package-detector.helper.d.ts +33 -0
- package/dist/helpers/package-detector.helper.d.ts.map +1 -0
- package/dist/helpers/package-detector.helper.js +82 -0
- package/dist/helpers/package-detector.helper.js.map +1 -0
- package/dist/helpers/property-filter.helper.d.ts +15 -0
- package/dist/helpers/property-filter.helper.d.ts.map +1 -0
- package/dist/helpers/property-filter.helper.js +44 -0
- package/dist/helpers/property-filter.helper.js.map +1 -0
- package/dist/helpers/type-inference.helper.d.ts +76 -0
- package/dist/helpers/type-inference.helper.d.ts.map +1 -0
- package/dist/helpers/type-inference.helper.js +205 -0
- package/dist/helpers/type-inference.helper.js.map +1 -0
- package/dist/helpers/validation-inference.helper.d.ts +18 -0
- package/dist/helpers/validation-inference.helper.d.ts.map +1 -0
- package/dist/helpers/validation-inference.helper.js +100 -0
- package/dist/helpers/validation-inference.helper.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/interfaces/adapters/decorator-adapter.interface.d.ts +8 -0
- package/dist/interfaces/adapters/decorator-adapter.interface.d.ts.map +1 -0
- package/dist/interfaces/adapters/decorator-adapter.interface.js +3 -0
- package/dist/interfaces/adapters/decorator-adapter.interface.js.map +1 -0
- package/dist/interfaces/decorators/solid-field-options.interface.d.ts +55 -0
- package/dist/interfaces/decorators/solid-field-options.interface.d.ts.map +1 -0
- package/dist/interfaces/decorators/solid-field-options.interface.js +3 -0
- package/dist/interfaces/decorators/solid-field-options.interface.js.map +1 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/metadata/field-metadata.interface.d.ts +29 -0
- package/dist/interfaces/metadata/field-metadata.interface.d.ts.map +1 -0
- package/dist/interfaces/metadata/field-metadata.interface.js +3 -0
- package/dist/interfaces/metadata/field-metadata.interface.js.map +1 -0
- package/dist/metadata/index.d.ts +2 -0
- package/dist/metadata/index.d.ts.map +1 -0
- package/dist/metadata/index.js +18 -0
- package/dist/metadata/index.js.map +1 -0
- package/dist/metadata/metadata-storage.d.ts +54 -0
- package/dist/metadata/metadata-storage.d.ts.map +1 -0
- package/dist/metadata/metadata-storage.js +106 -0
- package/dist/metadata/metadata-storage.js.map +1 -0
- package/dist/registry/index.d.ts +2 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/index.js +18 -0
- package/dist/registry/index.js.map +1 -0
- package/dist/registry/relation-adapter-registry.d.ts +11 -0
- package/dist/registry/relation-adapter-registry.d.ts.map +1 -0
- package/dist/registry/relation-adapter-registry.js +30 -0
- package/dist/registry/relation-adapter-registry.js.map +1 -0
- package/dist/types/dto-generation.types.d.ts +46 -0
- package/dist/types/dto-generation.types.d.ts.map +1 -0
- package/dist/types/dto-generation.types.js +6 -0
- package/dist/types/dto-generation.types.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Applies a decorator to a class property.
|
|
4
|
+
* This is a utility function for applying decorators dynamically.
|
|
5
|
+
*
|
|
6
|
+
* @param decorator - The decorator function to apply
|
|
7
|
+
* @param targetClass - The class containing the property
|
|
8
|
+
* @param propertyName - The name of the property to decorate
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { IsOptional } from 'class-validator';
|
|
13
|
+
*
|
|
14
|
+
* applyDecoratorToProperty(
|
|
15
|
+
* IsOptional(),
|
|
16
|
+
* MyClass,
|
|
17
|
+
* 'name'
|
|
18
|
+
* );
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyDecoratorToProperty(decorator: PropertyDecorator, targetClass: Type<any>, propertyName: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* Applies multiple decorators to a class property.
|
|
24
|
+
*
|
|
25
|
+
* @param decorators - Array of decorators to apply
|
|
26
|
+
* @param targetClass - The class containing the property
|
|
27
|
+
* @param propertyName - The name of the property to decorate
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { IsOptional, IsString } from 'class-validator';
|
|
32
|
+
*
|
|
33
|
+
* applyDecoratorsToProperty(
|
|
34
|
+
* [IsOptional(), IsString()],
|
|
35
|
+
* MyClass,
|
|
36
|
+
* 'name'
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare function applyDecoratorsToProperty(decorators: PropertyDecorator[], targetClass: Type<any>, propertyName: string): void;
|
|
41
|
+
/**
|
|
42
|
+
* Applies a decorator to a class.
|
|
43
|
+
*
|
|
44
|
+
* @param decorator - The class decorator to apply
|
|
45
|
+
* @param targetClass - The class to decorate
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* import { Injectable } from '@nestjs/common';
|
|
50
|
+
*
|
|
51
|
+
* applyDecoratorToClass(
|
|
52
|
+
* Injectable(),
|
|
53
|
+
* MyClass
|
|
54
|
+
* );
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function applyDecoratorToClass(decorator: ClassDecorator, targetClass: Type<any>): void;
|
|
58
|
+
/**
|
|
59
|
+
* Applies multiple decorators to a class.
|
|
60
|
+
*
|
|
61
|
+
* @param decorators - Array of class decorators to apply
|
|
62
|
+
* @param targetClass - The class to decorate
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { Injectable, Controller } from '@nestjs/common';
|
|
67
|
+
*
|
|
68
|
+
* applyDecoratorsToClass(
|
|
69
|
+
* [Injectable(), Controller()],
|
|
70
|
+
* MyClass
|
|
71
|
+
* );
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function applyDecoratorsToClass(decorators: ClassDecorator[], targetClass: Type<any>): void;
|
|
75
|
+
//# sourceMappingURL=decorator-utils.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-utils.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/decorators/decorator-utils.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,iBAAiB,EAC5B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,EACtB,YAAY,EAAE,MAAM,GACnB,IAAI,CAEN;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,EACtB,YAAY,EAAE,MAAM,GACnB,IAAI,CAIN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,GACrB,IAAI,CAEN;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,cAAc,EAAE,EAC5B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,GACrB,IAAI,CAIN"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.applyDecoratorToProperty = applyDecoratorToProperty;
|
|
4
|
+
exports.applyDecoratorsToProperty = applyDecoratorsToProperty;
|
|
5
|
+
exports.applyDecoratorToClass = applyDecoratorToClass;
|
|
6
|
+
exports.applyDecoratorsToClass = applyDecoratorsToClass;
|
|
7
|
+
/**
|
|
8
|
+
* Applies a decorator to a class property.
|
|
9
|
+
* This is a utility function for applying decorators dynamically.
|
|
10
|
+
*
|
|
11
|
+
* @param decorator - The decorator function to apply
|
|
12
|
+
* @param targetClass - The class containing the property
|
|
13
|
+
* @param propertyName - The name of the property to decorate
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { IsOptional } from 'class-validator';
|
|
18
|
+
*
|
|
19
|
+
* applyDecoratorToProperty(
|
|
20
|
+
* IsOptional(),
|
|
21
|
+
* MyClass,
|
|
22
|
+
* 'name'
|
|
23
|
+
* );
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
function applyDecoratorToProperty(decorator, targetClass, propertyName) {
|
|
27
|
+
decorator(targetClass.prototype, propertyName);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Applies multiple decorators to a class property.
|
|
31
|
+
*
|
|
32
|
+
* @param decorators - Array of decorators to apply
|
|
33
|
+
* @param targetClass - The class containing the property
|
|
34
|
+
* @param propertyName - The name of the property to decorate
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* import { IsOptional, IsString } from 'class-validator';
|
|
39
|
+
*
|
|
40
|
+
* applyDecoratorsToProperty(
|
|
41
|
+
* [IsOptional(), IsString()],
|
|
42
|
+
* MyClass,
|
|
43
|
+
* 'name'
|
|
44
|
+
* );
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function applyDecoratorsToProperty(decorators, targetClass, propertyName) {
|
|
48
|
+
for (const decorator of decorators) {
|
|
49
|
+
applyDecoratorToProperty(decorator, targetClass, propertyName);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Applies a decorator to a class.
|
|
54
|
+
*
|
|
55
|
+
* @param decorator - The class decorator to apply
|
|
56
|
+
* @param targetClass - The class to decorate
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* import { Injectable } from '@nestjs/common';
|
|
61
|
+
*
|
|
62
|
+
* applyDecoratorToClass(
|
|
63
|
+
* Injectable(),
|
|
64
|
+
* MyClass
|
|
65
|
+
* );
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
function applyDecoratorToClass(decorator, targetClass) {
|
|
69
|
+
decorator(targetClass);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Applies multiple decorators to a class.
|
|
73
|
+
*
|
|
74
|
+
* @param decorators - Array of class decorators to apply
|
|
75
|
+
* @param targetClass - The class to decorate
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* import { Injectable, Controller } from '@nestjs/common';
|
|
80
|
+
*
|
|
81
|
+
* applyDecoratorsToClass(
|
|
82
|
+
* [Injectable(), Controller()],
|
|
83
|
+
* MyClass
|
|
84
|
+
* );
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
function applyDecoratorsToClass(decorators, targetClass) {
|
|
88
|
+
for (const decorator of decorators) {
|
|
89
|
+
applyDecoratorToClass(decorator, targetClass);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=decorator-utils.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-utils.helper.js","sourceRoot":"","sources":["../../../src/helpers/decorators/decorator-utils.helper.ts"],"names":[],"mappings":";;AAqBA,4DAMC;AAoBD,8DAQC;AAkBD,sDAKC;AAkBD,wDAOC;AArGD;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,wBAAwB,CACtC,SAA4B,EAC5B,WAAsB,EACtB,YAAoB;IAEpB,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;AACjD,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,yBAAyB,CACvC,UAA+B,EAC/B,WAAsB,EACtB,YAAoB;IAEpB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,wBAAwB,CAAC,SAAS,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,qBAAqB,CACnC,SAAyB,EACzB,WAAsB;IAEtB,SAAS,CAAC,WAAW,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,sBAAsB,CACpC,UAA4B,EAC5B,WAAsB;IAEtB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decorator Utilities
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities for applying decorators to classes and properties
|
|
5
|
+
* dynamically. These utilities can be used by any feature that needs to apply
|
|
6
|
+
* decorators at runtime.
|
|
7
|
+
*/
|
|
8
|
+
export { applyDecoratorToProperty, applyDecoratorsToProperty, applyDecoratorToClass, applyDecoratorsToClass } from './decorator-utils.helper';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/helpers/decorators/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator Utilities
|
|
4
|
+
*
|
|
5
|
+
* This module provides utilities for applying decorators to classes and properties
|
|
6
|
+
* dynamically. These utilities can be used by any feature that needs to apply
|
|
7
|
+
* decorators at runtime.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.applyDecoratorsToClass = exports.applyDecoratorToClass = exports.applyDecoratorsToProperty = exports.applyDecoratorToProperty = void 0;
|
|
11
|
+
var decorator_utils_helper_1 = require("./decorator-utils.helper");
|
|
12
|
+
Object.defineProperty(exports, "applyDecoratorToProperty", { enumerable: true, get: function () { return decorator_utils_helper_1.applyDecoratorToProperty; } });
|
|
13
|
+
Object.defineProperty(exports, "applyDecoratorsToProperty", { enumerable: true, get: function () { return decorator_utils_helper_1.applyDecoratorsToProperty; } });
|
|
14
|
+
Object.defineProperty(exports, "applyDecoratorToClass", { enumerable: true, get: function () { return decorator_utils_helper_1.applyDecoratorToClass; } });
|
|
15
|
+
Object.defineProperty(exports, "applyDecoratorsToClass", { enumerable: true, get: function () { return decorator_utils_helper_1.applyDecoratorsToClass; } });
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/decorators/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,mEAKkC;AAJhC,kIAAA,wBAAwB,OAAA;AACxB,mIAAA,yBAAyB,OAAA;AACzB,+HAAA,qBAAqB,OAAA;AACrB,gIAAA,sBAAsB,OAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Base class for DTO generators
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class DtoGeneratorBase {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new class with selected properties from source
|
|
8
|
+
*/
|
|
9
|
+
protected static createBaseClass<T>(sourceClass: Type<T>, properties: string[]): Type;
|
|
10
|
+
/**
|
|
11
|
+
* Main generation logic - to be used by specific implementations
|
|
12
|
+
*/
|
|
13
|
+
protected static generateDto<TEntity extends object>(EntityClass: Type<TEntity>, properties?: (keyof TEntity)[], decoratorTransferFn?: (sourceClass: Type, targetClass: Type, propertyKey: string) => void): Type<Partial<TEntity>>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Common helper to clean SOLID field options
|
|
17
|
+
*/
|
|
18
|
+
export declare function cleanSolidFieldOptions(options: any): any;
|
|
19
|
+
//# sourceMappingURL=dto-generator-base.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto-generator-base.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/dto-generator-base.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAItC;;GAEG;AACH,8BAAsB,gBAAgB;IACpC;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,EAChC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,EAAE,GACnB,IAAI;IAsCP;;OAEG;IACH,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,SAAS,MAAM,EACjD,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,EAC1B,UAAU,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,EAC9B,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GACxF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CAuB1B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,GAAG,GAAG,GAAG,CAYxD"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DtoGeneratorBase = void 0;
|
|
4
|
+
exports.cleanSolidFieldOptions = cleanSolidFieldOptions;
|
|
5
|
+
const metadata_extractor_helper_1 = require("./metadata-extractor.helper");
|
|
6
|
+
const property_filter_helper_1 = require("./property-filter.helper");
|
|
7
|
+
/**
|
|
8
|
+
* Base class for DTO generators
|
|
9
|
+
*/
|
|
10
|
+
class DtoGeneratorBase {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new class with selected properties from source
|
|
13
|
+
*/
|
|
14
|
+
static createBaseClass(sourceClass, properties) {
|
|
15
|
+
class GeneratedDto {
|
|
16
|
+
}
|
|
17
|
+
// Copy property descriptors
|
|
18
|
+
properties.forEach(prop => {
|
|
19
|
+
const descriptor = Object.getOwnPropertyDescriptor(sourceClass.prototype, prop);
|
|
20
|
+
if (descriptor) {
|
|
21
|
+
Object.defineProperty(GeneratedDto.prototype, prop, descriptor);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
// Create default descriptor for properties without descriptors
|
|
25
|
+
Object.defineProperty(GeneratedDto.prototype, prop, {
|
|
26
|
+
writable: true,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
// Set class name for debugging
|
|
33
|
+
Object.defineProperty(GeneratedDto, 'name', {
|
|
34
|
+
value: `Generated${sourceClass.name}Dto`
|
|
35
|
+
});
|
|
36
|
+
return GeneratedDto;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Main generation logic - to be used by specific implementations
|
|
40
|
+
*/
|
|
41
|
+
static generateDto(EntityClass, properties, decoratorTransferFn) {
|
|
42
|
+
// Extract all properties
|
|
43
|
+
const allProperties = (0, metadata_extractor_helper_1.extractAllPropertyNames)(EntityClass);
|
|
44
|
+
// Filter properties based on selection or defaults
|
|
45
|
+
const selectedProperties = (0, property_filter_helper_1.filterProperties)(EntityClass, allProperties, properties);
|
|
46
|
+
// Create base class with properties
|
|
47
|
+
const GeneratedDto = this.createBaseClass(EntityClass, selectedProperties);
|
|
48
|
+
// Transfer decorators if function provided
|
|
49
|
+
if (decoratorTransferFn) {
|
|
50
|
+
selectedProperties.forEach(prop => {
|
|
51
|
+
decoratorTransferFn(EntityClass, GeneratedDto, prop);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return GeneratedDto;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.DtoGeneratorBase = DtoGeneratorBase;
|
|
58
|
+
/**
|
|
59
|
+
* Common helper to clean SOLID field options
|
|
60
|
+
*/
|
|
61
|
+
function cleanSolidFieldOptions(options) {
|
|
62
|
+
if (!options)
|
|
63
|
+
return options;
|
|
64
|
+
const cleaned = { ...options };
|
|
65
|
+
// Remove TypeORM-specific configurations
|
|
66
|
+
if (cleaned.adapters?.typeorm) {
|
|
67
|
+
cleaned.adapters = { ...cleaned.adapters };
|
|
68
|
+
delete cleaned.adapters.typeorm;
|
|
69
|
+
}
|
|
70
|
+
return cleaned;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=dto-generator-base.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto-generator-base.helper.js","sourceRoot":"","sources":["../../src/helpers/dto-generator-base.helper.ts"],"names":[],"mappings":";;;AAuFA,wDAYC;AAlGD,2EAAsE;AACtE,qEAA4D;AAE5D;;GAEG;AACH,MAAsB,gBAAgB;IACpC;;OAEG;IACO,MAAM,CAAC,eAAe,CAC9B,WAAoB,EACpB,UAAoB;QAEpB,MAAM,YAAY;SAAG;QAErB,4BAA4B;QAC5B,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACxB,MAAM,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAChD,WAAW,CAAC,SAAS,EACrB,IAAI,CACL,CAAC;YAEF,IAAI,UAAU,EAAE,CAAC;gBACf,MAAM,CAAC,cAAc,CACnB,YAAY,CAAC,SAAS,EACtB,IAAI,EACJ,UAAU,CACX,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,+DAA+D;gBAC/D,MAAM,CAAC,cAAc,CACnB,YAAY,CAAC,SAAS,EACtB,IAAI,EACJ;oBACE,QAAQ,EAAE,IAAI;oBACd,UAAU,EAAE,IAAI;oBAChB,YAAY,EAAE,IAAI;iBACnB,CACF,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,+BAA+B;QAC/B,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE;YAC1C,KAAK,EAAE,YAAY,WAAW,CAAC,IAAI,KAAK;SACzC,CAAC,CAAC;QAEH,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACO,MAAM,CAAC,WAAW,CAC1B,WAA0B,EAC1B,UAA8B,EAC9B,mBAAyF;QAEzF,yBAAyB;QACzB,MAAM,aAAa,GAAG,IAAA,mDAAuB,EAAC,WAAW,CAAC,CAAC;QAE3D,mDAAmD;QACnD,MAAM,kBAAkB,GAAG,IAAA,yCAAgB,EACzC,WAAW,EACX,aAAa,EACb,UAAsB,CACvB,CAAC;QAEF,oCAAoC;QACpC,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;QAE3E,2CAA2C;QAC3C,IAAI,mBAAmB,EAAE,CAAC;YACxB,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBAChC,mBAAmB,CAAC,WAAW,EAAE,YAAY,EAAE,IAAI,CAAC,CAAC;YACvD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,YAAsC,CAAC;IAChD,CAAC;CACF;AA3ED,4CA2EC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,OAAY;IACjD,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAE7B,MAAM,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAE/B,yCAAyC;IACzC,IAAI,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC;QAC9B,OAAO,CAAC,QAAQ,GAAG,EAAE,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;IAClC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export * from './types.helper';
|
|
2
2
|
export * from './pagination.helper';
|
|
3
3
|
export * from './pipe-transform.helper';
|
|
4
|
+
export * from './class-generation';
|
|
5
|
+
export * from './decorators';
|
|
6
|
+
export * from './args-helpers';
|
|
7
|
+
export * from './type-inference.helper';
|
|
8
|
+
export * from './package-detector.helper';
|
|
9
|
+
export * from './metadata-extractor.helper';
|
|
10
|
+
export * from './property-filter.helper';
|
|
11
|
+
export * from './dto-generator-base.helper';
|
|
12
|
+
export * from './validation-inference.helper';
|
|
4
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC"}
|
package/dist/helpers/index.js
CHANGED
|
@@ -17,4 +17,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./types.helper"), exports);
|
|
18
18
|
__exportStar(require("./pagination.helper"), exports);
|
|
19
19
|
__exportStar(require("./pipe-transform.helper"), exports);
|
|
20
|
+
__exportStar(require("./class-generation"), exports);
|
|
21
|
+
__exportStar(require("./decorators"), exports);
|
|
22
|
+
__exportStar(require("./args-helpers"), exports);
|
|
23
|
+
__exportStar(require("./type-inference.helper"), exports);
|
|
24
|
+
__exportStar(require("./package-detector.helper"), exports);
|
|
25
|
+
__exportStar(require("./metadata-extractor.helper"), exports);
|
|
26
|
+
__exportStar(require("./property-filter.helper"), exports);
|
|
27
|
+
__exportStar(require("./dto-generator-base.helper"), exports);
|
|
28
|
+
__exportStar(require("./validation-inference.helper"), exports);
|
|
20
29
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC;AACpC,0DAAwC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC;AACpC,0DAAwC;AACxC,qDAAmC;AACnC,+CAA6B;AAC7B,iDAA+B;AAC/B,0DAAwC;AACxC,4DAA0C;AAC1C,8DAA4C;AAC5C,2DAAyC;AACzC,8DAA4C;AAC5C,gEAA8C"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Gets all property names from a class - SIMPLIFIED VERSION
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractAllPropertyNames(EntityClass: Type): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Gets the TypeScript design type for a property
|
|
8
|
+
*/
|
|
9
|
+
export declare function getPropertyDesignType(EntityClass: Type, propertyKey: string): any;
|
|
10
|
+
/**
|
|
11
|
+
* Extracts field metadata from an entity class using SOLID metadata storage
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractEntityFieldMetadata(EntityClass: Type): import("..").FieldMetadata[];
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a field is a system field (id, timestamps)
|
|
16
|
+
*/
|
|
17
|
+
export declare function isSystemField(propertyKey: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Checks if a field is relational (OneToMany, ManyToOne, etc.)
|
|
20
|
+
*/
|
|
21
|
+
export declare function isRelationalField(EntityClass: Type, propertyKey: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a type is a flat/simple type (string, number, boolean, Date)
|
|
24
|
+
*/
|
|
25
|
+
export declare function isFlatType(type: any): boolean;
|
|
26
|
+
//# sourceMappingURL=metadata-extractor.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-extractor.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/metadata-extractor.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGtC;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,IAAI,GAAG,MAAM,EAAE,CAoBnE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,IAAI,EACjB,WAAW,EAAE,MAAM,GAClB,GAAG,CAEL;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,IAAI,gCAE3D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAIjF;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,GAAG,GAAG,OAAO,CAK7C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extractAllPropertyNames = extractAllPropertyNames;
|
|
4
|
+
exports.getPropertyDesignType = getPropertyDesignType;
|
|
5
|
+
exports.extractEntityFieldMetadata = extractEntityFieldMetadata;
|
|
6
|
+
exports.isSystemField = isSystemField;
|
|
7
|
+
exports.isRelationalField = isRelationalField;
|
|
8
|
+
exports.isFlatType = isFlatType;
|
|
9
|
+
const metadata_storage_1 = require("../metadata/metadata-storage");
|
|
10
|
+
/**
|
|
11
|
+
* Gets all property names from a class - SIMPLIFIED VERSION
|
|
12
|
+
*/
|
|
13
|
+
function extractAllPropertyNames(EntityClass) {
|
|
14
|
+
const properties = new Set();
|
|
15
|
+
// Basic SOLID metadata detection (this works reliably)
|
|
16
|
+
const fieldMetadata = extractEntityFieldMetadata(EntityClass);
|
|
17
|
+
fieldMetadata.forEach(meta => {
|
|
18
|
+
if (typeof meta.propertyKey === 'string') {
|
|
19
|
+
properties.add(meta.propertyKey);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
// Simple prototype property detection (no complex inheritance handling)
|
|
23
|
+
const ownProps = Object.getOwnPropertyNames(EntityClass.prototype);
|
|
24
|
+
ownProps.forEach(prop => {
|
|
25
|
+
if (prop !== 'constructor') {
|
|
26
|
+
properties.add(prop);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return Array.from(properties);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Gets the TypeScript design type for a property
|
|
33
|
+
*/
|
|
34
|
+
function getPropertyDesignType(EntityClass, propertyKey) {
|
|
35
|
+
return Reflect.getMetadata('design:type', EntityClass.prototype, propertyKey);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Extracts field metadata from an entity class using SOLID metadata storage
|
|
39
|
+
*/
|
|
40
|
+
function extractEntityFieldMetadata(EntityClass) {
|
|
41
|
+
return metadata_storage_1.MetadataStorage.getAllFieldMetadata(EntityClass);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a field is a system field (id, timestamps)
|
|
45
|
+
*/
|
|
46
|
+
function isSystemField(propertyKey) {
|
|
47
|
+
const systemFields = ['id', 'createdAt', 'updatedAt', 'deletedAt'];
|
|
48
|
+
return systemFields.includes(propertyKey);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks if a field is relational (OneToMany, ManyToOne, etc.)
|
|
52
|
+
*/
|
|
53
|
+
function isRelationalField(EntityClass, propertyKey) {
|
|
54
|
+
// Simple check - if it's an object or array type, likely relational
|
|
55
|
+
const type = getPropertyDesignType(EntityClass, propertyKey);
|
|
56
|
+
return type && (type === Array || (typeof type === 'function' && type.name && type.name !== 'String' && type.name !== 'Number' && type.name !== 'Boolean' && type.name !== 'Date'));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks if a type is a flat/simple type (string, number, boolean, Date)
|
|
60
|
+
*/
|
|
61
|
+
function isFlatType(type) {
|
|
62
|
+
if (!type)
|
|
63
|
+
return false;
|
|
64
|
+
const flatTypes = [String, Number, Boolean, Date];
|
|
65
|
+
return flatTypes.includes(type);
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=metadata-extractor.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-extractor.helper.js","sourceRoot":"","sources":["../../src/helpers/metadata-extractor.helper.ts"],"names":[],"mappings":";;AAMA,0DAoBC;AAKD,sDAKC;AAKD,gEAEC;AAKD,sCAGC;AAKD,8CAIC;AAKD,gCAKC;AArED,mEAA+D;AAE/D;;GAEG;AACH,SAAgB,uBAAuB,CAAC,WAAiB;IACvD,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IAErC,uDAAuD;IACvD,MAAM,aAAa,GAAG,0BAA0B,CAAC,WAAW,CAAC,CAAC;IAC9D,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAC3B,IAAI,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,EAAE,CAAC;YACzC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,wEAAwE;IACxE,MAAM,QAAQ,GAAG,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IACnE,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACtB,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;YAC3B,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,WAAiB,EACjB,WAAmB;IAEnB,OAAO,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,WAAW,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,SAAgB,0BAA0B,CAAC,WAAiB;IAC1D,OAAO,kCAAe,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;AAC1D,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,WAAmB;IAC/C,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACnE,OAAO,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,WAAiB,EAAE,WAAmB;IACtE,oEAAoE;IACpE,MAAM,IAAI,GAAG,qBAAqB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC7D,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,OAAO,IAAI,KAAK,UAAU,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC;AACtL,CAAC;AAED;;GAEG;AACH,SAAgB,UAAU,CAAC,IAAS;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAExB,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,OAAO,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic function to check if a package is available
|
|
3
|
+
*/
|
|
4
|
+
declare function isPackageAvailable(packageName: string): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Generic function to check multiple packages at once
|
|
7
|
+
*/
|
|
8
|
+
export declare function arePackagesAvailable(packages: string[]): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Checks if class-validator package is available
|
|
11
|
+
*/
|
|
12
|
+
export declare function isClassValidatorAvailable(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Checks if class-transformer package is available
|
|
15
|
+
*/
|
|
16
|
+
export declare function isClassTransformerAvailable(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if validation packages are available
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidationAvailable(): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Clears all package availability caches
|
|
23
|
+
*/
|
|
24
|
+
export declare function clearPackageCache(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Preloads package availability checks for commonly used packages
|
|
27
|
+
*/
|
|
28
|
+
export declare function preloadCommonPackages(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Export the generic isPackageAvailable function for use by other packages
|
|
31
|
+
*/
|
|
32
|
+
export { isPackageAvailable };
|
|
33
|
+
//# sourceMappingURL=package-detector.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-detector.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/package-detector.helper.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,iBAAS,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAaxD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAEhE;AAED;;GAEG;AACH,wBAAgB,yBAAyB,IAAI,OAAO,CAKnD;AAED;;GAEG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAKrD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,IAAI,CAI5C;AAED;;GAEG;AACH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.arePackagesAvailable = arePackagesAvailable;
|
|
4
|
+
exports.isClassValidatorAvailable = isClassValidatorAvailable;
|
|
5
|
+
exports.isClassTransformerAvailable = isClassTransformerAvailable;
|
|
6
|
+
exports.isValidationAvailable = isValidationAvailable;
|
|
7
|
+
exports.clearPackageCache = clearPackageCache;
|
|
8
|
+
exports.preloadCommonPackages = preloadCommonPackages;
|
|
9
|
+
exports.isPackageAvailable = isPackageAvailable;
|
|
10
|
+
/**
|
|
11
|
+
* Cache for package availability checks to avoid repeated require.resolve calls
|
|
12
|
+
*/
|
|
13
|
+
const packageCache = new Map();
|
|
14
|
+
/**
|
|
15
|
+
* Cached results for availability checks
|
|
16
|
+
*/
|
|
17
|
+
let classValidatorAvailable;
|
|
18
|
+
let classTransformerAvailable;
|
|
19
|
+
/**
|
|
20
|
+
* Generic function to check if a package is available
|
|
21
|
+
*/
|
|
22
|
+
function isPackageAvailable(packageName) {
|
|
23
|
+
if (packageCache.has(packageName)) {
|
|
24
|
+
return packageCache.get(packageName);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
require.resolve(packageName);
|
|
28
|
+
packageCache.set(packageName, true);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
packageCache.set(packageName, false);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generic function to check multiple packages at once
|
|
38
|
+
*/
|
|
39
|
+
function arePackagesAvailable(packages) {
|
|
40
|
+
return packages.every(pkg => isPackageAvailable(pkg));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Checks if class-validator package is available
|
|
44
|
+
*/
|
|
45
|
+
function isClassValidatorAvailable() {
|
|
46
|
+
if (classValidatorAvailable === undefined) {
|
|
47
|
+
classValidatorAvailable = isPackageAvailable('class-validator');
|
|
48
|
+
}
|
|
49
|
+
return classValidatorAvailable;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Checks if class-transformer package is available
|
|
53
|
+
*/
|
|
54
|
+
function isClassTransformerAvailable() {
|
|
55
|
+
if (classTransformerAvailable === undefined) {
|
|
56
|
+
classTransformerAvailable = isPackageAvailable('class-transformer');
|
|
57
|
+
}
|
|
58
|
+
return classTransformerAvailable;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Checks if validation packages are available
|
|
62
|
+
*/
|
|
63
|
+
function isValidationAvailable() {
|
|
64
|
+
return isClassValidatorAvailable() || isClassTransformerAvailable();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Clears all package availability caches
|
|
68
|
+
*/
|
|
69
|
+
function clearPackageCache() {
|
|
70
|
+
packageCache.clear();
|
|
71
|
+
classValidatorAvailable = undefined;
|
|
72
|
+
classTransformerAvailable = undefined;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Preloads package availability checks for commonly used packages
|
|
76
|
+
*/
|
|
77
|
+
function preloadCommonPackages() {
|
|
78
|
+
// Only preload packages that are actually used by the common package
|
|
79
|
+
isClassValidatorAvailable();
|
|
80
|
+
isClassTransformerAvailable();
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=package-detector.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-detector.helper.js","sourceRoot":"","sources":["../../src/helpers/package-detector.helper.ts"],"names":[],"mappings":";;AAgCA,oDAEC;AAKD,8DAKC;AAKD,kEAKC;AAKD,sDAEC;AAKD,8CAIC;AAKD,sDAIC;AAKQ,gDAAkB;AApF3B;;GAEG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,EAAmB,CAAC;AAEhD;;GAEG;AACH,IAAI,uBAA4C,CAAC;AACjD,IAAI,yBAA8C,CAAC;AAEnD;;GAEG;AACH,SAAS,kBAAkB,CAAC,WAAmB;IAC7C,IAAI,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QAClC,OAAO,YAAY,CAAC,GAAG,CAAC,WAAW,CAAE,CAAC;IACxC,CAAC;IAED,IAAI,CAAC;QACH,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAC7B,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAC,QAAkB;IACrD,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,SAAgB,yBAAyB;IACvC,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;QAC1C,uBAAuB,GAAG,kBAAkB,CAAC,iBAAiB,CAAC,CAAC;IAClE,CAAC;IACD,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,SAAgB,2BAA2B;IACzC,IAAI,yBAAyB,KAAK,SAAS,EAAE,CAAC;QAC5C,yBAAyB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,yBAAyB,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB;IACnC,OAAO,yBAAyB,EAAE,IAAI,2BAA2B,EAAE,CAAC;AACtE,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB;IAC/B,YAAY,CAAC,KAAK,EAAE,CAAC;IACrB,uBAAuB,GAAG,SAAS,CAAC;IACpC,yBAAyB,GAAG,SAAS,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB;IACnC,qEAAqE;IACrE,yBAAyB,EAAE,CAAC;IAC5B,2BAA2B,EAAE,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Filters properties based on selection or defaults
|
|
4
|
+
*/
|
|
5
|
+
export declare function filterProperties(EntityClass: Type, allProperties: string[], selectedProperties?: string[]): string[];
|
|
6
|
+
/**
|
|
7
|
+
* Gets default properties (all flat properties except system fields)
|
|
8
|
+
*/
|
|
9
|
+
export declare function getDefaultProperties(EntityClass: Type, allProperties: string[]): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Validates that selected properties exist and are valid for DTO generation
|
|
12
|
+
* @param allowSystemFields - When true, allows system fields (id, timestamps) to be included
|
|
13
|
+
*/
|
|
14
|
+
export declare function validatePropertySelection(EntityClass: Type, allProperties: string[], selectedProperties: string[], allowSystemFields?: boolean): void;
|
|
15
|
+
//# sourceMappingURL=property-filter.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-filter.helper.d.ts","sourceRoot":"","sources":["../../src/helpers/property-filter.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAQtC;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,IAAI,EACjB,aAAa,EAAE,MAAM,EAAE,EACvB,kBAAkB,CAAC,EAAE,MAAM,EAAE,GAC5B,MAAM,EAAE,CASV;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,IAAI,EACjB,aAAa,EAAE,MAAM,EAAE,GACtB,MAAM,EAAE,CAYV;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,IAAI,EACjB,aAAa,EAAE,MAAM,EAAE,EACvB,kBAAkB,EAAE,MAAM,EAAE,EAC5B,iBAAiB,GAAE,OAAe,GACjC,IAAI,CAIN"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.filterProperties = filterProperties;
|
|
4
|
+
exports.getDefaultProperties = getDefaultProperties;
|
|
5
|
+
exports.validatePropertySelection = validatePropertySelection;
|
|
6
|
+
const metadata_extractor_helper_1 = require("./metadata-extractor.helper");
|
|
7
|
+
/**
|
|
8
|
+
* Filters properties based on selection or defaults
|
|
9
|
+
*/
|
|
10
|
+
function filterProperties(EntityClass, allProperties, selectedProperties) {
|
|
11
|
+
if (selectedProperties && selectedProperties.length > 0) {
|
|
12
|
+
// Validate selected properties
|
|
13
|
+
validatePropertySelection(EntityClass, allProperties, selectedProperties);
|
|
14
|
+
return selectedProperties;
|
|
15
|
+
}
|
|
16
|
+
// Default: all flat properties except system fields
|
|
17
|
+
return getDefaultProperties(EntityClass, allProperties);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Gets default properties (all flat properties except system fields)
|
|
21
|
+
*/
|
|
22
|
+
function getDefaultProperties(EntityClass, allProperties) {
|
|
23
|
+
return allProperties.filter(prop => {
|
|
24
|
+
// Skip system fields
|
|
25
|
+
if ((0, metadata_extractor_helper_1.isSystemField)(prop))
|
|
26
|
+
return false;
|
|
27
|
+
// Skip relational fields
|
|
28
|
+
if ((0, metadata_extractor_helper_1.isRelationalField)(EntityClass, prop))
|
|
29
|
+
return false;
|
|
30
|
+
// Only include flat types
|
|
31
|
+
const type = (0, metadata_extractor_helper_1.getPropertyDesignType)(EntityClass, prop);
|
|
32
|
+
return (0, metadata_extractor_helper_1.isFlatType)(type);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Validates that selected properties exist and are valid for DTO generation
|
|
37
|
+
* @param allowSystemFields - When true, allows system fields (id, timestamps) to be included
|
|
38
|
+
*/
|
|
39
|
+
function validatePropertySelection(EntityClass, allProperties, selectedProperties, allowSystemFields = false) {
|
|
40
|
+
// SIMPLIFIED: No validation - trust the user
|
|
41
|
+
// If they specify a property that doesn't exist, PickType will handle the error
|
|
42
|
+
// This eliminates all the complex property detection issues
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=property-filter.helper.js.map
|