@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,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateBaseClass = generateBaseClass;
|
|
4
|
+
exports.addPropertyToClass = addPropertyToClass;
|
|
5
|
+
exports.applyPropertyDecorator = applyPropertyDecorator;
|
|
6
|
+
exports.applyPropertyDecorators = applyPropertyDecorators;
|
|
7
|
+
exports.applyClassDecorator = applyClassDecorator;
|
|
8
|
+
exports.applyMultipleClassDecorators = applyMultipleClassDecorators;
|
|
9
|
+
exports.getPropertyMetadata = getPropertyMetadata;
|
|
10
|
+
exports.setPropertyMetadata = setPropertyMetadata;
|
|
11
|
+
exports.getDefinedProperties = getDefinedProperties;
|
|
12
|
+
exports.cloneClass = cloneClass;
|
|
13
|
+
require("reflect-metadata");
|
|
14
|
+
/**
|
|
15
|
+
* Generates a base class with the specified options.
|
|
16
|
+
* This is the foundation for creating dynamic DTO classes.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Configuration for the class generation
|
|
19
|
+
* @returns A dynamically created class constructor
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const MyClass = generateBaseClass({
|
|
24
|
+
* className: 'ProductWhereFields',
|
|
25
|
+
* metadata: { version: '1.0' }
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const instance = new MyClass();
|
|
29
|
+
* console.log(instance.constructor.name); // 'ProductWhereFields'
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
function generateBaseClass(options) {
|
|
33
|
+
const { className, baseClass, metadata } = options;
|
|
34
|
+
// Create the dynamic class
|
|
35
|
+
let DynamicClass;
|
|
36
|
+
if (baseClass) {
|
|
37
|
+
// Extend from base class if provided
|
|
38
|
+
DynamicClass = class extends baseClass {
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Create standalone class
|
|
43
|
+
DynamicClass = class {
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
// Set the class name
|
|
47
|
+
Object.defineProperty(DynamicClass, 'name', {
|
|
48
|
+
value: className,
|
|
49
|
+
configurable: true
|
|
50
|
+
});
|
|
51
|
+
// Apply custom metadata if provided
|
|
52
|
+
if (metadata) {
|
|
53
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
54
|
+
Reflect.defineMetadata(key, value, DynamicClass);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return DynamicClass;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Adds a property to a class prototype with proper descriptors.
|
|
61
|
+
* This function is used to dynamically add fields to generated DTO classes.
|
|
62
|
+
*
|
|
63
|
+
* @param targetClass - The class to add the property to
|
|
64
|
+
* @param propertyName - Name of the property to add
|
|
65
|
+
* @param options - Configuration for the property
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const MyClass = generateBaseClass({ className: 'TestClass' });
|
|
70
|
+
*
|
|
71
|
+
* addPropertyToClass(MyClass, 'name', {
|
|
72
|
+
* type: String,
|
|
73
|
+
* isOptional: true,
|
|
74
|
+
* description: 'The name field'
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* const instance = new MyClass();
|
|
78
|
+
* instance.name = 'test'; // Property is now available
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function addPropertyToClass(targetClass, propertyName, options) {
|
|
82
|
+
const { type, isOptional = true } = options;
|
|
83
|
+
// Define the property on the prototype
|
|
84
|
+
Object.defineProperty(targetClass.prototype, propertyName, {
|
|
85
|
+
writable: true,
|
|
86
|
+
enumerable: true,
|
|
87
|
+
configurable: true,
|
|
88
|
+
value: undefined
|
|
89
|
+
});
|
|
90
|
+
// Set design-time type metadata for reflection
|
|
91
|
+
Reflect.defineMetadata('design:type', type, targetClass.prototype, propertyName);
|
|
92
|
+
// Set parameter types metadata (for constructor injection if needed)
|
|
93
|
+
const existingParamTypes = Reflect.getMetadata('design:paramtypes', targetClass) || [];
|
|
94
|
+
Reflect.defineMetadata('design:paramtypes', existingParamTypes, targetClass);
|
|
95
|
+
// Store additional property metadata
|
|
96
|
+
const propertyMetadata = {
|
|
97
|
+
type,
|
|
98
|
+
isOptional,
|
|
99
|
+
description: options.description,
|
|
100
|
+
example: options.example,
|
|
101
|
+
deprecated: options.deprecated
|
|
102
|
+
};
|
|
103
|
+
Reflect.defineMetadata(`property:${propertyName}`, propertyMetadata, targetClass.prototype);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Applies a decorator to a class property.
|
|
107
|
+
* This is a utility function for applying decorators dynamically.
|
|
108
|
+
*
|
|
109
|
+
* @param decorator - The decorator function to apply
|
|
110
|
+
* @param targetClass - The class containing the property
|
|
111
|
+
* @param propertyName - The name of the property to decorate
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* import { IsOptional } from 'class-validator';
|
|
116
|
+
*
|
|
117
|
+
* applyPropertyDecorator(
|
|
118
|
+
* IsOptional(),
|
|
119
|
+
* MyClass,
|
|
120
|
+
* 'name'
|
|
121
|
+
* );
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
function applyPropertyDecorator(decorator, targetClass, propertyName) {
|
|
125
|
+
decorator(targetClass.prototype, propertyName);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Applies multiple decorators to a class property.
|
|
129
|
+
*
|
|
130
|
+
* @param decorators - Array of decorators to apply
|
|
131
|
+
* @param targetClass - The class containing the property
|
|
132
|
+
* @param propertyName - The name of the property to decorate
|
|
133
|
+
*/
|
|
134
|
+
function applyPropertyDecorators(decorators, targetClass, propertyName) {
|
|
135
|
+
for (const decorator of decorators) {
|
|
136
|
+
applyPropertyDecorator(decorator, targetClass, propertyName);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Applies a decorator to a class.
|
|
141
|
+
*
|
|
142
|
+
* @param decorator - The class decorator to apply
|
|
143
|
+
* @param targetClass - The class to decorate
|
|
144
|
+
*/
|
|
145
|
+
function applyClassDecorator(decorator, targetClass) {
|
|
146
|
+
decorator(targetClass);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Applies multiple decorators to a class.
|
|
150
|
+
*
|
|
151
|
+
* @param decorators - Array of class decorators to apply
|
|
152
|
+
* @param targetClass - The class to decorate
|
|
153
|
+
*/
|
|
154
|
+
function applyMultipleClassDecorators(decorators, targetClass) {
|
|
155
|
+
for (const decorator of decorators) {
|
|
156
|
+
applyClassDecorator(decorator, targetClass);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Gets metadata for a property from a class.
|
|
161
|
+
*
|
|
162
|
+
* @param targetClass - The class to get metadata from
|
|
163
|
+
* @param propertyName - The property name
|
|
164
|
+
* @param metadataKey - The metadata key to retrieve
|
|
165
|
+
* @returns The metadata value or undefined
|
|
166
|
+
*/
|
|
167
|
+
function getPropertyMetadata(targetClass, propertyName, metadataKey) {
|
|
168
|
+
return Reflect.getMetadata(metadataKey, targetClass.prototype, propertyName);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Sets metadata for a property on a class.
|
|
172
|
+
*
|
|
173
|
+
* @param targetClass - The class to set metadata on
|
|
174
|
+
* @param propertyName - The property name
|
|
175
|
+
* @param metadataKey - The metadata key
|
|
176
|
+
* @param metadataValue - The metadata value
|
|
177
|
+
*/
|
|
178
|
+
function setPropertyMetadata(targetClass, propertyName, metadataKey, metadataValue) {
|
|
179
|
+
Reflect.defineMetadata(metadataKey, metadataValue, targetClass.prototype, propertyName);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Gets all property names that have been defined on a class.
|
|
183
|
+
*
|
|
184
|
+
* @param targetClass - The class to inspect
|
|
185
|
+
* @returns Array of property names
|
|
186
|
+
*/
|
|
187
|
+
function getDefinedProperties(targetClass) {
|
|
188
|
+
const properties = [];
|
|
189
|
+
const prototype = targetClass.prototype;
|
|
190
|
+
// Get own property names
|
|
191
|
+
const ownProps = Object.getOwnPropertyNames(prototype);
|
|
192
|
+
properties.push(...ownProps.filter(prop => prop !== 'constructor'));
|
|
193
|
+
// Walk up the prototype chain to get inherited properties
|
|
194
|
+
let currentProto = Object.getPrototypeOf(prototype);
|
|
195
|
+
while (currentProto && currentProto !== Object.prototype) {
|
|
196
|
+
const protoProps = Object.getOwnPropertyNames(currentProto);
|
|
197
|
+
properties.push(...protoProps.filter(prop => prop !== 'constructor' && !properties.includes(prop)));
|
|
198
|
+
currentProto = Object.getPrototypeOf(currentProto);
|
|
199
|
+
}
|
|
200
|
+
return properties;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Clones a class constructor, creating a new class with the same properties.
|
|
204
|
+
* This is useful for creating variations of existing classes.
|
|
205
|
+
*
|
|
206
|
+
* @param sourceClass - The class to clone
|
|
207
|
+
* @param newClassName - Name for the new class
|
|
208
|
+
* @returns A new class constructor
|
|
209
|
+
*/
|
|
210
|
+
function cloneClass(sourceClass, newClassName) {
|
|
211
|
+
// Create new class extending the source
|
|
212
|
+
const ClonedClass = class extends sourceClass {
|
|
213
|
+
};
|
|
214
|
+
// Set the new name
|
|
215
|
+
Object.defineProperty(ClonedClass, 'name', {
|
|
216
|
+
value: newClassName,
|
|
217
|
+
configurable: true
|
|
218
|
+
});
|
|
219
|
+
return ClonedClass;
|
|
220
|
+
}
|
|
221
|
+
//# sourceMappingURL=class-generator.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-generator.helper.js","sourceRoot":"","sources":["../../../src/helpers/args-helpers/class-generator.helper.ts"],"names":[],"mappings":";;AA6CA,8CA4BC;AAwBD,gDAgCC;AAqBD,wDAMC;AASD,0DAQC;AAQD,kDAKC;AAQD,oEAOC;AAUD,kDAMC;AAUD,kDAOC;AAQD,oDAmBC;AAUD,gCAWC;AAzRD,4BAA0B;AA0B1B;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,iBAAiB,CAAC,OAA8B;IAC9D,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEnD,2BAA2B;IAC3B,IAAI,YAAuB,CAAC;IAE5B,IAAI,SAAS,EAAE,CAAC;QACd,qCAAqC;QACrC,YAAY,GAAG,KAAM,SAAQ,SAAS;SAAG,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,0BAA0B;QAC1B,YAAY,GAAG;SAAQ,CAAC;IAC1B,CAAC;IAED,qBAAqB;IACrB,MAAM,CAAC,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE;QAC1C,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IAEH,oCAAoC;IACpC,IAAI,QAAQ,EAAE,CAAC;QACb,KAAK,MAAM,CAAC,GAAG,EAA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IAAI,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC;IAEpE,0DAA0D;IAC1D,IAAI,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IACpD,OAAO,YAAY,IAAI,YAAY,KAAK,MAAM,CAAC,SAAS,EAAE,CAAC;QACzD,MAAM,UAAU,GAAG,MAAM,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAC5D,UAAU,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAC1C,IAAI,KAAK,aAAa,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,CACrD,CAAC,CAAC;QACH,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;IACrD,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,UAAU,CAAC,WAAsB,EAAE,YAAoB;IACrE,wCAAwC;IACxC,MAAM,WAAW,GAAG,KAAM,SAAQ,WAAW;KAAG,CAAC;IAEjD,mBAAmB;IACnB,MAAM,CAAC,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE;QACzC,KAAK,EAAE,YAAY;QACnB,YAAY,EAAE,IAAI;KACnB,CAAC,CAAC;IAEH,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core GroupByRequest Helper - Common Infrastructure
|
|
3
|
+
*
|
|
4
|
+
* This module provides the shared logic for creating GroupByRequest classes.
|
|
5
|
+
* It's used by the package-specific implementations in rest-api, graphql, and rest-graphql packages.
|
|
6
|
+
*/
|
|
7
|
+
import { Type } from '@nestjs/common';
|
|
8
|
+
import { type ClassOptions } from './field-config.helper';
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for creating a GroupByRequest class
|
|
11
|
+
*/
|
|
12
|
+
export interface GroupByRequestConfig {
|
|
13
|
+
/** The GroupByFields class containing field definitions */
|
|
14
|
+
fields: Type<any>;
|
|
15
|
+
/** Optional custom class name (defaults to `${fields.name}Request`) */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Optional description for the GroupByRequest */
|
|
18
|
+
description?: string;
|
|
19
|
+
/** Optional class-level configuration */
|
|
20
|
+
classOptions?: ClassOptions;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Parsed and validated GroupByRequest configuration
|
|
24
|
+
*/
|
|
25
|
+
export interface ParsedGroupByRequestConfig {
|
|
26
|
+
fieldsType: Type<any>;
|
|
27
|
+
className: string;
|
|
28
|
+
description: string;
|
|
29
|
+
classOptions: ClassOptions;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Validates and parses GroupByRequest configuration
|
|
33
|
+
*
|
|
34
|
+
* @param config - Raw configuration object
|
|
35
|
+
* @returns Parsed and validated configuration
|
|
36
|
+
* @throws Error if configuration is invalid
|
|
37
|
+
*/
|
|
38
|
+
export declare function parseGroupByRequestConfig(config: GroupByRequestConfig): ParsedGroupByRequestConfig;
|
|
39
|
+
/**
|
|
40
|
+
* Creates the base GroupByRequest class with shared logic.
|
|
41
|
+
* This is the core implementation used by package-specific helpers.
|
|
42
|
+
*
|
|
43
|
+
* @param config - Configuration for GroupByRequest creation
|
|
44
|
+
* @returns Base class ready for decorator application
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* // This is typically used by package-specific implementations
|
|
49
|
+
* const BaseClass = createGroupByRequestBase({
|
|
50
|
+
* fields: ProductGroupByFields,
|
|
51
|
+
* className: 'ProductGroupByRequest'
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* // Then apply package-specific decorators...
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function createGroupByRequestBase(config: GroupByRequestConfig): Type<any>;
|
|
58
|
+
/**
|
|
59
|
+
* Gets GroupByRequest metadata from a class
|
|
60
|
+
*
|
|
61
|
+
* @param target - The GroupByRequest class
|
|
62
|
+
* @returns Metadata object or undefined if not found
|
|
63
|
+
*/
|
|
64
|
+
export declare function getGroupByRequestMetadata(target: Type<any>): any;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a class was created using createGroupByRequest helpers
|
|
67
|
+
*
|
|
68
|
+
* @param target - The class to check
|
|
69
|
+
* @returns True if it's a GroupByRequest class
|
|
70
|
+
*/
|
|
71
|
+
export declare function isGroupByRequestClass(target: Type<any>): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Base class that can be extended by GroupByRequest implementations
|
|
74
|
+
* Provides common structure and can be used for type checking
|
|
75
|
+
*/
|
|
76
|
+
export declare abstract class GroupByRequestInput {
|
|
77
|
+
/** Fields to group by */
|
|
78
|
+
fields?: any;
|
|
79
|
+
/** Optional aggregates configuration (for future use) */
|
|
80
|
+
aggregates?: any[];
|
|
81
|
+
}
|
|
82
|
+
export type { GroupByRequestConfig as GroupByRequestConfigType };
|
|
83
|
+
//# sourceMappingURL=create-groupby-request.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-groupby-request.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/args-helpers/create-groupby-request.helper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEnG;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2DAA2D;IAC3D,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAClB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,oBAAoB,GAAG,0BAA0B,CAkClG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,CA+BhF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAEhE;AAED;;;GAGG;AACH,8BAAsB,mBAAmB;IACvC,yBAAyB;IACzB,MAAM,CAAC,EAAE,GAAG,CAAC;IAEb,yDAAyD;IACzD,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;CACpB;AAGD,YAAY,EAAE,oBAAoB,IAAI,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Core GroupByRequest Helper - Common Infrastructure
|
|
4
|
+
*
|
|
5
|
+
* This module provides the shared logic for creating GroupByRequest classes.
|
|
6
|
+
* It's used by the package-specific implementations in rest-api, graphql, and rest-graphql packages.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.GroupByRequestInput = void 0;
|
|
10
|
+
exports.parseGroupByRequestConfig = parseGroupByRequestConfig;
|
|
11
|
+
exports.createGroupByRequestBase = createGroupByRequestBase;
|
|
12
|
+
exports.getGroupByRequestMetadata = getGroupByRequestMetadata;
|
|
13
|
+
exports.isGroupByRequestClass = isGroupByRequestClass;
|
|
14
|
+
const class_generation_1 = require("../class-generation");
|
|
15
|
+
const field_config_helper_1 = require("./field-config.helper");
|
|
16
|
+
/**
|
|
17
|
+
* Validates and parses GroupByRequest configuration
|
|
18
|
+
*
|
|
19
|
+
* @param config - Raw configuration object
|
|
20
|
+
* @returns Parsed and validated configuration
|
|
21
|
+
* @throws Error if configuration is invalid
|
|
22
|
+
*/
|
|
23
|
+
function parseGroupByRequestConfig(config) {
|
|
24
|
+
if (!config) {
|
|
25
|
+
throw new Error('GroupByRequestConfig is required');
|
|
26
|
+
}
|
|
27
|
+
if (!config.fields) {
|
|
28
|
+
throw new Error('fields is required in GroupByRequestConfig');
|
|
29
|
+
}
|
|
30
|
+
if (typeof config.fields !== 'function') {
|
|
31
|
+
throw new Error('fields must be a class constructor (Type<any>)');
|
|
32
|
+
}
|
|
33
|
+
// Validate class options if provided
|
|
34
|
+
if (config.classOptions) {
|
|
35
|
+
(0, field_config_helper_1.validateClassOptions)(config.classOptions);
|
|
36
|
+
}
|
|
37
|
+
// Generate class name
|
|
38
|
+
const className = config.className || `${config.fields.name}Request`;
|
|
39
|
+
// Parse class options
|
|
40
|
+
const classOptions = (0, field_config_helper_1.parseClassOptions)(config.fields.name, 'Request', config.classOptions);
|
|
41
|
+
return {
|
|
42
|
+
fieldsType: config.fields,
|
|
43
|
+
className,
|
|
44
|
+
description: config.description || `GroupBy request with ${config.fields.name}`,
|
|
45
|
+
classOptions
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates the base GroupByRequest class with shared logic.
|
|
50
|
+
* This is the core implementation used by package-specific helpers.
|
|
51
|
+
*
|
|
52
|
+
* @param config - Configuration for GroupByRequest creation
|
|
53
|
+
* @returns Base class ready for decorator application
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // This is typically used by package-specific implementations
|
|
58
|
+
* const BaseClass = createGroupByRequestBase({
|
|
59
|
+
* fields: ProductGroupByFields,
|
|
60
|
+
* className: 'ProductGroupByRequest'
|
|
61
|
+
* });
|
|
62
|
+
*
|
|
63
|
+
* // Then apply package-specific decorators...
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
function createGroupByRequestBase(config) {
|
|
67
|
+
const parsedConfig = parseGroupByRequestConfig(config);
|
|
68
|
+
// Generate base class
|
|
69
|
+
const BaseClass = (0, class_generation_1.generateBaseClass)({
|
|
70
|
+
className: parsedConfig.className,
|
|
71
|
+
metadata: {
|
|
72
|
+
'groupby-request:config': {
|
|
73
|
+
fieldsType: parsedConfig.fieldsType.name,
|
|
74
|
+
className: parsedConfig.className,
|
|
75
|
+
description: parsedConfig.description,
|
|
76
|
+
},
|
|
77
|
+
...parsedConfig.classOptions.metadata
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
// Add fields property to prototype (will be decorated by package-specific implementations)
|
|
81
|
+
Object.defineProperty(BaseClass.prototype, 'fields', {
|
|
82
|
+
writable: true,
|
|
83
|
+
enumerable: true,
|
|
84
|
+
configurable: true
|
|
85
|
+
});
|
|
86
|
+
// Add aggregates property to prototype (optional, for future aggregation support)
|
|
87
|
+
Object.defineProperty(BaseClass.prototype, 'aggregates', {
|
|
88
|
+
writable: true,
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true
|
|
91
|
+
});
|
|
92
|
+
return BaseClass;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Gets GroupByRequest metadata from a class
|
|
96
|
+
*
|
|
97
|
+
* @param target - The GroupByRequest class
|
|
98
|
+
* @returns Metadata object or undefined if not found
|
|
99
|
+
*/
|
|
100
|
+
function getGroupByRequestMetadata(target) {
|
|
101
|
+
return Reflect.getMetadata('groupby-request:config', target);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Checks if a class was created using createGroupByRequest helpers
|
|
105
|
+
*
|
|
106
|
+
* @param target - The class to check
|
|
107
|
+
* @returns True if it's a GroupByRequest class
|
|
108
|
+
*/
|
|
109
|
+
function isGroupByRequestClass(target) {
|
|
110
|
+
return !!getGroupByRequestMetadata(target);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Base class that can be extended by GroupByRequest implementations
|
|
114
|
+
* Provides common structure and can be used for type checking
|
|
115
|
+
*/
|
|
116
|
+
class GroupByRequestInput {
|
|
117
|
+
}
|
|
118
|
+
exports.GroupByRequestInput = GroupByRequestInput;
|
|
119
|
+
//# sourceMappingURL=create-groupby-request.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-groupby-request.helper.js","sourceRoot":"","sources":["../../../src/helpers/args-helpers/create-groupby-request.helper.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAqCH,8DAkCC;AAoBD,4DA+BC;AAQD,8DAEC;AAQD,sDAEC;AA3ID,0DAAoF;AACpF,+DAAmG;AA0BnG;;;;;;GAMG;AACH,SAAgB,yBAAyB,CAAC,MAA4B;IACpE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IAED,qCAAqC;IACrC,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACxB,IAAA,0CAAoB,EAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED,sBAAsB;IACtB,MAAM,SAAS,GAAG,MAAM,CAAC,SAAS,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC;IAErE,sBAAsB;IACtB,MAAM,YAAY,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;AAC/D,CAAC;AAED;;;;;GAKG;AACH,SAAgB,qBAAqB,CAAC,MAAiB;IACrD,OAAO,CAAC,CAAC,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC7C,CAAC;AAED;;;GAGG;AACH,MAAsB,mBAAmB;CAMxC;AAND,kDAMC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import 'reflect-metadata';
|
|
3
|
+
/**
|
|
4
|
+
* Common decorator configuration interface
|
|
5
|
+
*/
|
|
6
|
+
export interface DecoratorConfig {
|
|
7
|
+
description?: string;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
example?: any;
|
|
10
|
+
deprecated?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface for decorator builders that create property decorators
|
|
14
|
+
*/
|
|
15
|
+
export interface DecoratorBuilder {
|
|
16
|
+
/**
|
|
17
|
+
* Creates validation decorators for a property
|
|
18
|
+
*/
|
|
19
|
+
createValidationDecorators(config: DecoratorConfig): PropertyDecorator[];
|
|
20
|
+
/**
|
|
21
|
+
* Creates type transformation decorators
|
|
22
|
+
*/
|
|
23
|
+
createTransformDecorators(type: Type<any>, config: DecoratorConfig): PropertyDecorator[];
|
|
24
|
+
/**
|
|
25
|
+
* Creates documentation decorators (Swagger/GraphQL)
|
|
26
|
+
*/
|
|
27
|
+
createDocumentationDecorators(type: Type<any>, config: DecoratorConfig): PropertyDecorator[];
|
|
28
|
+
/**
|
|
29
|
+
* Creates all decorators for a property and applies them to the target class
|
|
30
|
+
*/
|
|
31
|
+
applyAllDecorators(targetClass: Type<any>, propertyName: string, type: Type<any>, config: DecoratorConfig): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Base decorator builder with common validation decorators
|
|
35
|
+
*/
|
|
36
|
+
export declare abstract class BaseDecoratorBuilder implements DecoratorBuilder {
|
|
37
|
+
abstract createValidationDecorators(config: DecoratorConfig): PropertyDecorator[];
|
|
38
|
+
abstract createTransformDecorators(type: Type<any>, config: DecoratorConfig): PropertyDecorator[];
|
|
39
|
+
abstract createDocumentationDecorators(type: Type<any>, config: DecoratorConfig): PropertyDecorator[];
|
|
40
|
+
/**
|
|
41
|
+
* Creates all decorators for a property and applies them to the target class
|
|
42
|
+
*
|
|
43
|
+
* @param targetClass - The class to apply decorators to
|
|
44
|
+
* @param propertyName - The property name
|
|
45
|
+
* @param type - The property type
|
|
46
|
+
* @param config - Decorator configuration
|
|
47
|
+
*/
|
|
48
|
+
applyAllDecorators(targetClass: Type<any>, propertyName: string, type: Type<any>, config: DecoratorConfig): void;
|
|
49
|
+
/**
|
|
50
|
+
* Creates common validation decorators that are used across all packages
|
|
51
|
+
*
|
|
52
|
+
* @param config - Configuration for the decorators
|
|
53
|
+
* @returns Array of common validation decorators
|
|
54
|
+
*/
|
|
55
|
+
protected createCommonValidationDecorators(config: DecoratorConfig): PropertyDecorator[];
|
|
56
|
+
/**
|
|
57
|
+
* Creates common transformation decorators
|
|
58
|
+
*
|
|
59
|
+
* @param type - The property type
|
|
60
|
+
* @param config - Configuration for the decorators
|
|
61
|
+
* @returns Array of transformation decorators
|
|
62
|
+
*/
|
|
63
|
+
protected createCommonTransformDecorators(type: Type<any>, config: DecoratorConfig): PropertyDecorator[];
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Utility functions for working with decorators
|
|
67
|
+
*/
|
|
68
|
+
export declare class DecoratorUtils {
|
|
69
|
+
/**
|
|
70
|
+
* Checks if a decorator has already been applied to a property
|
|
71
|
+
*
|
|
72
|
+
* @param targetClass - The class to check
|
|
73
|
+
* @param propertyName - The property name
|
|
74
|
+
* @param decoratorKey - The metadata key to look for
|
|
75
|
+
* @returns True if the decorator has been applied
|
|
76
|
+
*/
|
|
77
|
+
static hasDecorator(targetClass: Type<any>, propertyName: string, decoratorKey: string): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Gets decorator metadata for a property
|
|
80
|
+
*
|
|
81
|
+
* @param targetClass - The class to get metadata from
|
|
82
|
+
* @param propertyName - The property name
|
|
83
|
+
* @param decoratorKey - The metadata key
|
|
84
|
+
* @returns The decorator metadata
|
|
85
|
+
*/
|
|
86
|
+
static getDecoratorMetadata(targetClass: Type<any>, propertyName: string, decoratorKey: string): any;
|
|
87
|
+
/**
|
|
88
|
+
* Sets decorator metadata for a property
|
|
89
|
+
*
|
|
90
|
+
* @param targetClass - The class to set metadata on
|
|
91
|
+
* @param propertyName - The property name
|
|
92
|
+
* @param decoratorKey - The metadata key
|
|
93
|
+
* @param metadata - The metadata to set
|
|
94
|
+
*/
|
|
95
|
+
static setDecoratorMetadata(targetClass: Type<any>, propertyName: string, decoratorKey: string, metadata: any): void;
|
|
96
|
+
/**
|
|
97
|
+
* Merges decorator metadata with existing metadata
|
|
98
|
+
*
|
|
99
|
+
* @param targetClass - The class to merge metadata on
|
|
100
|
+
* @param propertyName - The property name
|
|
101
|
+
* @param decoratorKey - The metadata key
|
|
102
|
+
* @param newMetadata - The new metadata to merge
|
|
103
|
+
*/
|
|
104
|
+
static mergeDecoratorMetadata(targetClass: Type<any>, propertyName: string, decoratorKey: string, newMetadata: any): void;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Factory function for creating decorator builders
|
|
108
|
+
* This will be implemented by each package (rest-api, graphql, rest-graphql)
|
|
109
|
+
*/
|
|
110
|
+
export interface DecoratorBuilderFactory {
|
|
111
|
+
/**
|
|
112
|
+
* Creates a decorator builder for WhereFields
|
|
113
|
+
*/
|
|
114
|
+
createWhereFieldsDecoratorBuilder(): DecoratorBuilder;
|
|
115
|
+
/**
|
|
116
|
+
* Creates a decorator builder for OrderByFields
|
|
117
|
+
*/
|
|
118
|
+
createOrderByFieldsDecoratorBuilder(): DecoratorBuilder;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a decorator builder for GroupByFields
|
|
121
|
+
*/
|
|
122
|
+
createGroupByFieldsDecoratorBuilder(): DecoratorBuilder;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Registry for decorator builder factories
|
|
126
|
+
* Each package will register its factory here
|
|
127
|
+
*/
|
|
128
|
+
export declare class DecoratorBuilderRegistry {
|
|
129
|
+
private static factories;
|
|
130
|
+
/**
|
|
131
|
+
* Registers a decorator builder factory for a package
|
|
132
|
+
*
|
|
133
|
+
* @param packageName - Name of the package (e.g., 'rest-api', 'graphql', 'rest-graphql')
|
|
134
|
+
* @param factory - The factory instance
|
|
135
|
+
*/
|
|
136
|
+
static registerFactory(packageName: string, factory: DecoratorBuilderFactory): void;
|
|
137
|
+
/**
|
|
138
|
+
* Gets a decorator builder factory for a package
|
|
139
|
+
*
|
|
140
|
+
* @param packageName - Name of the package
|
|
141
|
+
* @returns The factory instance or undefined if not found
|
|
142
|
+
*/
|
|
143
|
+
static getFactory(packageName: string): DecoratorBuilderFactory | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* Gets all registered package names
|
|
146
|
+
*
|
|
147
|
+
* @returns Array of registered package names
|
|
148
|
+
*/
|
|
149
|
+
static getRegisteredPackages(): string[];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Applies logical operator fields (_and, _or) to a WhereFields class
|
|
153
|
+
* This is common functionality used across all packages
|
|
154
|
+
*
|
|
155
|
+
* @param targetClass - The WhereFields class to add operators to
|
|
156
|
+
* @param decoratorBuilder - The decorator builder to use
|
|
157
|
+
* @param className - The class name for nested types
|
|
158
|
+
*/
|
|
159
|
+
export declare function addLogicalOperators(targetClass: Type<any>, decoratorBuilder: DecoratorBuilder, className: string): void;
|
|
160
|
+
//# sourceMappingURL=decorator-builder.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorator-builder.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/args-helpers/decorator-builder.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEtC,OAAO,kBAAkB,CAAC;AAE1B;;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