@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
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
export * from './current-context.decorator';
|
|
2
2
|
export * from './ignore-arg.decorator';
|
|
3
3
|
export * from './wrapped.decorator';
|
|
4
|
+
export * from './solid-field.decorator';
|
|
5
|
+
export * from './solid-id.decorator';
|
|
6
|
+
export * from './solid-entity.decorator';
|
|
7
|
+
export * from './solid-input.decorator';
|
|
8
|
+
export * from './solid-timestamp.decorator';
|
|
9
|
+
export * from './solid-relation.decorator';
|
|
4
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC"}
|
package/dist/decorators/index.js
CHANGED
|
@@ -17,4 +17,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./current-context.decorator"), exports);
|
|
18
18
|
__exportStar(require("./ignore-arg.decorator"), exports);
|
|
19
19
|
__exportStar(require("./wrapped.decorator"), exports);
|
|
20
|
+
__exportStar(require("./solid-field.decorator"), exports);
|
|
21
|
+
__exportStar(require("./solid-id.decorator"), exports);
|
|
22
|
+
__exportStar(require("./solid-entity.decorator"), exports);
|
|
23
|
+
__exportStar(require("./solid-input.decorator"), exports);
|
|
24
|
+
__exportStar(require("./solid-timestamp.decorator"), exports);
|
|
25
|
+
__exportStar(require("./solid-relation.decorator"), exports);
|
|
20
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,yDAAuC;AACvC,sDAAoC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8DAA4C;AAC5C,yDAAuC;AACvC,sDAAoC;AACpC,0DAAwC;AACxC,uDAAqC;AACrC,2DAAyC;AACzC,0DAAwC;AACxC,8DAA4C;AAC5C,6DAA2C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SolidEntityOptions } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Class decorator for entities with automatic database and API mappings
|
|
4
|
+
*/
|
|
5
|
+
export declare function SolidEntity(options?: SolidEntityOptions): ClassDecorator;
|
|
6
|
+
//# sourceMappingURL=solid-entity.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-entity.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-entity.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,eAAe,CAAC;AAInE;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,cAAc,CAexE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidEntity = SolidEntity;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
5
|
+
const decorator_registry_1 = require("../decorator-registry");
|
|
6
|
+
/**
|
|
7
|
+
* Class decorator for entities with automatic database and API mappings
|
|
8
|
+
*/
|
|
9
|
+
function SolidEntity(options) {
|
|
10
|
+
return function (target) {
|
|
11
|
+
// Create entity metadata
|
|
12
|
+
const metadata = {
|
|
13
|
+
target,
|
|
14
|
+
options: options || {},
|
|
15
|
+
type: 'entity'
|
|
16
|
+
};
|
|
17
|
+
// Store entity metadata
|
|
18
|
+
metadata_1.MetadataStorage.addEntityMetadata(metadata);
|
|
19
|
+
// Apply class-level decorators from all registered adapters
|
|
20
|
+
decorator_registry_1.DecoratorRegistry.applyClassDecorators(target, 'entity', options || {});
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=solid-entity.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-entity.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-entity.decorator.ts"],"names":[],"mappings":";;AAOA,kCAeC;AArBD,0CAA8C;AAC9C,8DAA0D;AAE1D;;GAEG;AACH,SAAgB,WAAW,CAAC,OAA4B;IACtD,OAAO,UAAU,MAAgB;QAC/B,yBAAyB;QACzB,MAAM,QAAQ,GAAmB;YAC/B,MAAM;YACN,OAAO,EAAE,OAAO,IAAI,EAAE;YACtB,IAAI,EAAE,QAAQ;SACf,CAAC;QAEF,wBAAwB;QACxB,0BAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAE5C,4DAA4D;QAC5D,sCAAiB,CAAC,oBAAoB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IAC1E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { SolidFieldOptions } from '../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* Universal field decorator that applies appropriate decorators based on context
|
|
5
|
+
*/
|
|
6
|
+
export declare function SolidField(options?: SolidFieldOptions): PropertyDecorator;
|
|
7
|
+
//# sourceMappingURL=solid-field.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-field.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-field.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,iBAAiB,EAAiB,MAAM,eAAe,CAAC;AAKjE;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,iBAAiB,CAqBzE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidField = SolidField;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("../metadata");
|
|
6
|
+
const decorator_registry_1 = require("../decorator-registry");
|
|
7
|
+
const helpers_1 = require("../helpers");
|
|
8
|
+
/**
|
|
9
|
+
* Universal field decorator that applies appropriate decorators based on context
|
|
10
|
+
*/
|
|
11
|
+
function SolidField(options) {
|
|
12
|
+
return function (target, propertyKey) {
|
|
13
|
+
// Get type information from TypeScript metadata
|
|
14
|
+
const type = Reflect.getMetadata('design:type', target, propertyKey);
|
|
15
|
+
const typeInfo = (0, helpers_1.inferTypeFromMetadata)(target, propertyKey);
|
|
16
|
+
// Create field metadata
|
|
17
|
+
const metadata = {
|
|
18
|
+
target: target.constructor,
|
|
19
|
+
propertyKey,
|
|
20
|
+
type,
|
|
21
|
+
options: options || {},
|
|
22
|
+
isOptional: typeInfo.isOptional || detectOptionalFromOptions(options),
|
|
23
|
+
};
|
|
24
|
+
// Store metadata for later use
|
|
25
|
+
metadata_1.MetadataStorage.addFieldMetadata(metadata);
|
|
26
|
+
// Apply decorators from all registered adapters
|
|
27
|
+
decorator_registry_1.DecoratorRegistry.applyDecorators(target, propertyKey, metadata);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Detects if a field should be optional based on options
|
|
32
|
+
*/
|
|
33
|
+
function detectOptionalFromOptions(options) {
|
|
34
|
+
if (!options)
|
|
35
|
+
return false;
|
|
36
|
+
// Explicit nullable setting
|
|
37
|
+
if (options.nullable === true)
|
|
38
|
+
return true;
|
|
39
|
+
if (options.nullable === false)
|
|
40
|
+
return false;
|
|
41
|
+
// Required setting (inverse of optional)
|
|
42
|
+
if (options.required === true)
|
|
43
|
+
return false;
|
|
44
|
+
if (options.required === false)
|
|
45
|
+
return true;
|
|
46
|
+
// Default value implies optional
|
|
47
|
+
if (options.defaultValue !== undefined)
|
|
48
|
+
return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=solid-field.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-field.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-field.decorator.ts"],"names":[],"mappings":";;AASA,gCAqBC;AA9BD,4BAA0B;AAE1B,0CAA8C;AAC9C,8DAA0D;AAC1D,wCAAmD;AA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SolidFieldOptions } from '../interfaces';
|
|
2
|
+
export interface SolidIdOptions extends Omit<SolidFieldOptions, 'isPrimaryKey' | 'required' | 'nullable'> {
|
|
3
|
+
generated?: 'uuid' | 'increment' | boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Specialized decorator for primary key fields
|
|
7
|
+
*/
|
|
8
|
+
export declare function SolidId(options?: SolidIdOptions): PropertyDecorator;
|
|
9
|
+
//# sourceMappingURL=solid-id.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-id.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-id.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,iBAAiB,EAAE,cAAc,GAAG,UAAU,GAAG,UAAU,CAAC;IACvG,SAAS,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC;CAC5C;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,iBAAiB,CAmBnE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidId = SolidId;
|
|
4
|
+
const solid_field_decorator_1 = require("./solid-field.decorator");
|
|
5
|
+
/**
|
|
6
|
+
* Specialized decorator for primary key fields
|
|
7
|
+
*/
|
|
8
|
+
function SolidId(options) {
|
|
9
|
+
return function (target, propertyKey) {
|
|
10
|
+
// Enhance options with primary key specific settings
|
|
11
|
+
const enhancedOptions = {
|
|
12
|
+
...options,
|
|
13
|
+
isPrimaryKey: true,
|
|
14
|
+
unique: true,
|
|
15
|
+
required: true,
|
|
16
|
+
nullable: false,
|
|
17
|
+
generated: options?.generated ?? 'uuid',
|
|
18
|
+
adapters: {
|
|
19
|
+
...options?.adapters
|
|
20
|
+
// Individual adapters will handle ID-specific logic internally
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Apply the enhanced SolidField decorator
|
|
24
|
+
return (0, solid_field_decorator_1.SolidField)(enhancedOptions)(target, propertyKey);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=solid-id.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-id.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-id.decorator.ts"],"names":[],"mappings":";;AAUA,0BAmBC;AA5BD,mEAAqD;AAMrD;;GAEG;AACH,SAAgB,OAAO,CAAC,OAAwB;IAC9C,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,qDAAqD;QACrD,MAAM,eAAe,GAAsB;YACzC,GAAG,OAAO;YACV,YAAY,EAAE,IAAI;YAClB,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,MAAM;YACvC,QAAQ,EAAE;gBACR,GAAG,OAAO,EAAE,QAAQ;gBACpB,+DAA+D;aAChE;SACF,CAAC;QAEF,0CAA0C;QAC1C,OAAO,IAAA,kCAAU,EAAC,eAAe,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SolidInputOptions } from '../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Class decorator for DTOs/Input types (skips database decorators by default)
|
|
4
|
+
*/
|
|
5
|
+
export declare function SolidInput(options?: SolidInputOptions): ClassDecorator;
|
|
6
|
+
//# sourceMappingURL=solid-input.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-input.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-input.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,eAAe,CAAC;AAIlE;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,iBAAiB,GAAG,cAAc,CA8BtE"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidInput = SolidInput;
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
5
|
+
const decorator_registry_1 = require("../decorator-registry");
|
|
6
|
+
/**
|
|
7
|
+
* Class decorator for DTOs/Input types (skips database decorators by default)
|
|
8
|
+
*/
|
|
9
|
+
function SolidInput(options) {
|
|
10
|
+
return function (target) {
|
|
11
|
+
// Default skip list for input types (typically skip database decorators)
|
|
12
|
+
const defaultSkip = options?.defaultSkip || [];
|
|
13
|
+
const skipList = [
|
|
14
|
+
...defaultSkip,
|
|
15
|
+
...(options?.skip || [])
|
|
16
|
+
];
|
|
17
|
+
// Remove duplicates
|
|
18
|
+
const uniqueSkipList = [...new Set(skipList)];
|
|
19
|
+
const enhancedOptions = {
|
|
20
|
+
...options,
|
|
21
|
+
skip: uniqueSkipList
|
|
22
|
+
};
|
|
23
|
+
// Create entity metadata
|
|
24
|
+
const metadata = {
|
|
25
|
+
target,
|
|
26
|
+
options: enhancedOptions,
|
|
27
|
+
type: 'input'
|
|
28
|
+
};
|
|
29
|
+
// Store entity metadata
|
|
30
|
+
metadata_1.MetadataStorage.addEntityMetadata(metadata);
|
|
31
|
+
// Apply class-level decorators from all registered adapters (excluding skipped ones)
|
|
32
|
+
decorator_registry_1.DecoratorRegistry.applyClassDecorators(target, 'input', enhancedOptions);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=solid-input.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-input.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-input.decorator.ts"],"names":[],"mappings":";;AAOA,gCA8BC;AApCD,0CAA8C;AAC9C,8DAA0D;AAE1D;;GAEG;AACH,SAAgB,UAAU,CAAC,OAA2B;IACpD,OAAO,UAAU,MAAgB;QAC/B,yEAAyE;QACzE,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,EAAE,CAAC;QAC/C,MAAM,QAAQ,GAAG;YACf,GAAG,WAAW;YACd,GAAG,CAAC,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC;SACzB,CAAC;QAEF,oBAAoB;QACpB,MAAM,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE9C,MAAM,eAAe,GAAG;YACtB,GAAG,OAAO;YACV,IAAI,EAAE,cAAc;SACrB,CAAC;QAEF,yBAAyB;QACzB,MAAM,QAAQ,GAAmB;YAC/B,MAAM;YACN,OAAO,EAAE,eAAe;YACxB,IAAI,EAAE,OAAO;SACd,CAAC;QAEF,wBAAwB;QACxB,0BAAe,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAE5C,qFAAqF;QACrF,sCAAiB,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { SolidFieldOptions } from '../interfaces';
|
|
2
|
+
export type RelationType = 'one-to-many' | 'many-to-one' | 'one-to-one' | 'many-to-many';
|
|
3
|
+
export interface SolidRelationOptions extends Omit<SolidFieldOptions, 'relation' | 'target' | 'inverseSide'> {
|
|
4
|
+
type: RelationType;
|
|
5
|
+
target: () => Function;
|
|
6
|
+
inverseSide?: string | ((object: any) => any);
|
|
7
|
+
onDelete?: 'RESTRICT' | 'CASCADE' | 'SET NULL';
|
|
8
|
+
onUpdate?: 'RESTRICT' | 'CASCADE' | 'SET NULL';
|
|
9
|
+
orphanedRowAction?: 'nullify' | 'delete' | 'soft-delete' | 'disable';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Decorator for entity relations with automatic adapter mappings
|
|
13
|
+
*/
|
|
14
|
+
export declare function SolidRelation(options: SolidRelationOptions): PropertyDecorator;
|
|
15
|
+
export declare const SolidOneToMany: (target: () => Function, inverseSide: string | ((object: any) => any), options?: Omit<SolidRelationOptions, "type" | "target" | "inverseSide">) => PropertyDecorator;
|
|
16
|
+
export declare const SolidManyToOne: (target: () => Function, inverseSide?: string | ((object: any) => any), options?: Omit<SolidRelationOptions, "type" | "target" | "inverseSide">) => PropertyDecorator;
|
|
17
|
+
export declare const SolidOneToOne: (target: () => Function, inverseSide?: string | ((object: any) => any), options?: Omit<SolidRelationOptions, "type" | "target" | "inverseSide">) => PropertyDecorator;
|
|
18
|
+
export declare const SolidManyToMany: (target: () => Function, inverseSide?: string | ((object: any) => any), options?: Omit<SolidRelationOptions, "type" | "target" | "inverseSide">) => PropertyDecorator;
|
|
19
|
+
//# sourceMappingURL=solid-relation.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-relation.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-relation.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIlD,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,GAAG,YAAY,GAAG,cAAc,CAAC;AAEzF,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC1G,IAAI,EAAE,YAAY,CAAC;IACnB,MAAM,EAAE,MAAM,QAAQ,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IAC9C,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C,iBAAiB,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;CACtE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,iBAAiB,CA4B9E;AAGD,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,QAAQ,EACtB,aAAa,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,EAC5C,UAAU,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC,sBAOrE,CAAC;AAEL,eAAO,MAAM,cAAc,GACzB,QAAQ,MAAM,QAAQ,EACtB,cAAc,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,EAC7C,UAAU,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC,sBAOrE,CAAC;AAEL,eAAO,MAAM,aAAa,GACxB,QAAQ,MAAM,QAAQ,EACtB,cAAc,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,EAC7C,UAAU,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC,sBAOrE,CAAC;AAEL,eAAO,MAAM,eAAe,GAC1B,QAAQ,MAAM,QAAQ,EACtB,cAAc,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,CAAC,EAC7C,UAAU,IAAI,CAAC,oBAAoB,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC,sBAOrE,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidManyToMany = exports.SolidOneToOne = exports.SolidManyToOne = exports.SolidOneToMany = void 0;
|
|
4
|
+
exports.SolidRelation = SolidRelation;
|
|
5
|
+
const solid_field_decorator_1 = require("./solid-field.decorator");
|
|
6
|
+
const registry_1 = require("../registry");
|
|
7
|
+
/**
|
|
8
|
+
* Decorator for entity relations with automatic adapter mappings
|
|
9
|
+
*/
|
|
10
|
+
function SolidRelation(options) {
|
|
11
|
+
return function (target, propertyKey) {
|
|
12
|
+
const { type, target: targetFn, inverseSide, ...restOptions } = options;
|
|
13
|
+
// Build enhanced options for SolidField
|
|
14
|
+
const enhancedOptions = {
|
|
15
|
+
...restOptions,
|
|
16
|
+
relation: type,
|
|
17
|
+
target: targetFn,
|
|
18
|
+
inverseSide: typeof inverseSide === 'string' ?
|
|
19
|
+
(obj) => obj[inverseSide] :
|
|
20
|
+
inverseSide,
|
|
21
|
+
adapters: {
|
|
22
|
+
...restOptions.adapters,
|
|
23
|
+
// Generate adapter options for all registered adapters
|
|
24
|
+
...registry_1.RelationAdapterRegistry.getRegisteredAdapters().reduce((acc, adapterName) => {
|
|
25
|
+
acc[adapterName] = {
|
|
26
|
+
...registry_1.RelationAdapterRegistry.getAdapterOptions(adapterName, type, targetFn, inverseSide, options),
|
|
27
|
+
...restOptions.adapters?.[adapterName]
|
|
28
|
+
};
|
|
29
|
+
return acc;
|
|
30
|
+
}, {})
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// Apply the enhanced SolidField decorator
|
|
34
|
+
return (0, solid_field_decorator_1.SolidField)(enhancedOptions)(target, propertyKey);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
// Convenience decorators for specific relation types
|
|
38
|
+
const SolidOneToMany = (target, inverseSide, options) => SolidRelation({
|
|
39
|
+
...options,
|
|
40
|
+
type: 'one-to-many',
|
|
41
|
+
target,
|
|
42
|
+
inverseSide
|
|
43
|
+
});
|
|
44
|
+
exports.SolidOneToMany = SolidOneToMany;
|
|
45
|
+
const SolidManyToOne = (target, inverseSide, options) => SolidRelation({
|
|
46
|
+
...options,
|
|
47
|
+
type: 'many-to-one',
|
|
48
|
+
target,
|
|
49
|
+
inverseSide
|
|
50
|
+
});
|
|
51
|
+
exports.SolidManyToOne = SolidManyToOne;
|
|
52
|
+
const SolidOneToOne = (target, inverseSide, options) => SolidRelation({
|
|
53
|
+
...options,
|
|
54
|
+
type: 'one-to-one',
|
|
55
|
+
target,
|
|
56
|
+
inverseSide
|
|
57
|
+
});
|
|
58
|
+
exports.SolidOneToOne = SolidOneToOne;
|
|
59
|
+
const SolidManyToMany = (target, inverseSide, options) => SolidRelation({
|
|
60
|
+
...options,
|
|
61
|
+
type: 'many-to-many',
|
|
62
|
+
target,
|
|
63
|
+
inverseSide
|
|
64
|
+
});
|
|
65
|
+
exports.SolidManyToMany = SolidManyToMany;
|
|
66
|
+
//# sourceMappingURL=solid-relation.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-relation.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-relation.decorator.ts"],"names":[],"mappings":";;;AAkBA,sCA4BC;AA7CD,mEAAqD;AACrD,0CAAsD;AAatD;;GAEG;AACH,SAAgB,aAAa,CAAC,OAA6B;IACzD,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC;QAExE,wCAAwC;QACxC,MAAM,eAAe,GAAsB;YACzC,GAAG,WAAW;YACd,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,QAAQ;YAChB,WAAW,EAAE,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC;gBAC5C,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;gBAChC,WAAW;YACb,QAAQ,EAAE;gBACR,GAAG,WAAW,CAAC,QAAQ;gBACvB,uDAAuD;gBACvD,GAAG,kCAAuB,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;oBAC7E,GA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
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SolidFieldOptions } from '../interfaces';
|
|
2
|
+
export type TimestampType = 'created' | 'updated' | 'deleted';
|
|
3
|
+
export interface SolidTimestampOptions extends Omit<SolidFieldOptions, 'nullable' | 'createdAt' | 'updatedAt' | 'deletedAt'> {
|
|
4
|
+
type?: TimestampType;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Decorator for timestamp fields (created, updated, deleted)
|
|
8
|
+
*/
|
|
9
|
+
export declare function SolidTimestamp(type?: TimestampType, options?: SolidTimestampOptions): PropertyDecorator;
|
|
10
|
+
export declare const SolidCreatedAt: (options?: Omit<SolidTimestampOptions, "type">) => PropertyDecorator;
|
|
11
|
+
export declare const SolidUpdatedAt: (options?: Omit<SolidTimestampOptions, "type">) => PropertyDecorator;
|
|
12
|
+
export declare const SolidDeletedAt: (options?: Omit<SolidTimestampOptions, "type">) => PropertyDecorator;
|
|
13
|
+
//# sourceMappingURL=solid-timestamp.decorator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-timestamp.decorator.d.ts","sourceRoot":"","sources":["../../src/decorators/solid-timestamp.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGlD,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,GAAG,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC;IAC1H,IAAI,CAAC,EAAE,aAAa,CAAC;CACtB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,IAAI,GAAE,aAAyB,EAC/B,OAAO,CAAC,EAAE,qBAAqB,GAC9B,iBAAiB,CAmCnB;AAGD,eAAO,MAAM,cAAc,GAAI,UAAU,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,sBACxC,CAAC;AAErC,eAAO,MAAM,cAAc,GAAI,UAAU,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,sBACxC,CAAC;AAErC,eAAO,MAAM,cAAc,GAAI,UAAU,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,sBACxC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SolidDeletedAt = exports.SolidUpdatedAt = exports.SolidCreatedAt = void 0;
|
|
4
|
+
exports.SolidTimestamp = SolidTimestamp;
|
|
5
|
+
const solid_field_decorator_1 = require("./solid-field.decorator");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator for timestamp fields (created, updated, deleted)
|
|
8
|
+
*/
|
|
9
|
+
function SolidTimestamp(type = 'created', options) {
|
|
10
|
+
return function (target, propertyKey) {
|
|
11
|
+
// Configuration for different timestamp types
|
|
12
|
+
const timestampConfig = {
|
|
13
|
+
created: {
|
|
14
|
+
description: 'Creation timestamp',
|
|
15
|
+
createdAt: true,
|
|
16
|
+
nullable: false,
|
|
17
|
+
},
|
|
18
|
+
updated: {
|
|
19
|
+
description: 'Last update timestamp',
|
|
20
|
+
updatedAt: true,
|
|
21
|
+
nullable: false,
|
|
22
|
+
},
|
|
23
|
+
deleted: {
|
|
24
|
+
description: 'Deletion timestamp (soft delete)',
|
|
25
|
+
deletedAt: true,
|
|
26
|
+
nullable: true,
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const config = timestampConfig[type];
|
|
30
|
+
const enhancedOptions = {
|
|
31
|
+
...options,
|
|
32
|
+
...config,
|
|
33
|
+
skip: ['validation'], // Timestamps don't need validation
|
|
34
|
+
adapters: {
|
|
35
|
+
...options?.adapters
|
|
36
|
+
// Individual adapters will handle timestamp-specific logic internally
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
return (0, solid_field_decorator_1.SolidField)(enhancedOptions)(target, propertyKey);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
// Convenience decorators
|
|
43
|
+
const SolidCreatedAt = (options) => SolidTimestamp('created', options);
|
|
44
|
+
exports.SolidCreatedAt = SolidCreatedAt;
|
|
45
|
+
const SolidUpdatedAt = (options) => SolidTimestamp('updated', options);
|
|
46
|
+
exports.SolidUpdatedAt = SolidUpdatedAt;
|
|
47
|
+
const SolidDeletedAt = (options) => SolidTimestamp('deleted', options);
|
|
48
|
+
exports.SolidDeletedAt = SolidDeletedAt;
|
|
49
|
+
//# sourceMappingURL=solid-timestamp.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"solid-timestamp.decorator.js","sourceRoot":"","sources":["../../src/decorators/solid-timestamp.decorator.ts"],"names":[],"mappings":";;;AAYA,wCAsCC;AAjDD,mEAAqD;AAQrD;;GAEG;AACH,SAAgB,cAAc,CAC5B,OAAsB,SAAS,EAC/B,OAA+B;IAE/B,OAAO,UAAU,MAAW,EAAE,WAA4B;QACxD,8CAA8C;QAC9C,MAAM,eAAe,GAAG;YACtB,OAAO,EAAE;gBACP,WAAW,EAAE,oBAAoB;gBACjC,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,KAAK;aAChB;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,uBAAuB;gBACpC,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,KAAK;aAChB;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,kCAAkC;gBAC/C,SAAS,EAAE,IAAI;gBACf,QAAQ,EAAE,IAAI;aACf;SACF,CAAC;QAEF,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QAErC,MAAM,eAAe,GAAsB;YACzC,GAAG,OAAO;YACV,GAAG,MAAM;YACT,IAAI,EAAE,CAAC,YAAY,CAAC,EAAE,mCAAmC;YACzD,QAAQ,EAAE;gBACR,GAAG,OAAO,EAAE,QAAQ;gBACpB,sEAAsE;aACvE;SACF,CAAC;QAEF,OAAO,IAAA,kCAAU,EAAC,eAAe,CAAC,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC;AAED,yBAAyB;AAClB,MAAM,cAAc,GAAG,CAAC,OAA6C,EAAE,EAAE,CAC9E,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AADxB,QAAA,cAAc,kBACU;AAE9B,MAAM,cAAc,GAAG,CAAC,OAA6C,EAAE,EAAE,CAC9E,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AADxB,QAAA,cAAc,kBACU;AAE9B,MAAM,cAAc,GAAG,CAAC,OAA6C,EAAE,EAAE,CAC9E,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AADxB,QAAA,cAAc,kBACU"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import 'reflect-metadata';
|
|
3
|
+
/**
|
|
4
|
+
* Options for generating a dynamic class
|
|
5
|
+
*/
|
|
6
|
+
export interface ClassGeneratorOptions {
|
|
7
|
+
className: string;
|
|
8
|
+
baseClass?: Type<any>;
|
|
9
|
+
interfaces?: Type<any>[];
|
|
10
|
+
metadata?: Record<string, any>;
|
|
11
|
+
isAbstract?: boolean;
|
|
12
|
+
description?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Options for adding a property to a class
|
|
16
|
+
*/
|
|
17
|
+
export interface PropertyOptions {
|
|
18
|
+
type: Type<any>;
|
|
19
|
+
isOptional?: boolean;
|
|
20
|
+
isArray?: boolean;
|
|
21
|
+
description?: string;
|
|
22
|
+
example?: any;
|
|
23
|
+
deprecated?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Generates a base class with the specified options.
|
|
27
|
+
* This is the foundation for creating dynamic DTO classes.
|
|
28
|
+
*
|
|
29
|
+
* @param options - Configuration for the class generation
|
|
30
|
+
* @returns A dynamically created class constructor
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const MyClass = generateBaseClass({
|
|
35
|
+
* className: 'ProductWhereFields',
|
|
36
|
+
* metadata: { version: '1.0' }
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const instance = new MyClass();
|
|
40
|
+
* console.log(instance.constructor.name); // 'ProductWhereFields'
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function generateBaseClass(options: ClassGeneratorOptions): Type<any>;
|
|
44
|
+
/**
|
|
45
|
+
* Adds a property to a class prototype with proper descriptors.
|
|
46
|
+
* This function is used to dynamically add fields to generated DTO classes.
|
|
47
|
+
*
|
|
48
|
+
* @param targetClass - The class to add the property to
|
|
49
|
+
* @param propertyName - Name of the property to add
|
|
50
|
+
* @param options - Configuration for the property
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const MyClass = generateBaseClass({ className: 'TestClass' });
|
|
55
|
+
*
|
|
56
|
+
* addPropertyToClass(MyClass, 'name', {
|
|
57
|
+
* type: String,
|
|
58
|
+
* isOptional: true,
|
|
59
|
+
* description: 'The name field'
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* const instance = new MyClass();
|
|
63
|
+
* instance.name = 'test'; // Property is now available
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare function addPropertyToClass(targetClass: Type<any>, propertyName: string, options: PropertyOptions): void;
|
|
67
|
+
/**
|
|
68
|
+
* Applies a decorator to a class property.
|
|
69
|
+
* This is a utility function for applying decorators dynamically.
|
|
70
|
+
*
|
|
71
|
+
* @param decorator - The decorator function to apply
|
|
72
|
+
* @param targetClass - The class containing the property
|
|
73
|
+
* @param propertyName - The name of the property to decorate
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* import { IsOptional } from 'class-validator';
|
|
78
|
+
*
|
|
79
|
+
* applyPropertyDecorator(
|
|
80
|
+
* IsOptional(),
|
|
81
|
+
* MyClass,
|
|
82
|
+
* 'name'
|
|
83
|
+
* );
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export declare function applyPropertyDecorator(decorator: PropertyDecorator, targetClass: Type<any>, propertyName: string): void;
|
|
87
|
+
/**
|
|
88
|
+
* Applies multiple decorators to a class property.
|
|
89
|
+
*
|
|
90
|
+
* @param decorators - Array of decorators to apply
|
|
91
|
+
* @param targetClass - The class containing the property
|
|
92
|
+
* @param propertyName - The name of the property to decorate
|
|
93
|
+
*/
|
|
94
|
+
export declare function applyPropertyDecorators(decorators: PropertyDecorator[], targetClass: Type<any>, propertyName: string): void;
|
|
95
|
+
/**
|
|
96
|
+
* Applies a decorator to a class.
|
|
97
|
+
*
|
|
98
|
+
* @param decorator - The class decorator to apply
|
|
99
|
+
* @param targetClass - The class to decorate
|
|
100
|
+
*/
|
|
101
|
+
export declare function applyClassDecorator(decorator: ClassDecorator, targetClass: Type<any>): void;
|
|
102
|
+
/**
|
|
103
|
+
* Applies multiple decorators to a class.
|
|
104
|
+
*
|
|
105
|
+
* @param decorators - Array of class decorators to apply
|
|
106
|
+
* @param targetClass - The class to decorate
|
|
107
|
+
*/
|
|
108
|
+
export declare function applyMultipleClassDecorators(decorators: ClassDecorator[], targetClass: Type<any>): void;
|
|
109
|
+
/**
|
|
110
|
+
* Gets metadata for a property from a class.
|
|
111
|
+
*
|
|
112
|
+
* @param targetClass - The class to get metadata from
|
|
113
|
+
* @param propertyName - The property name
|
|
114
|
+
* @param metadataKey - The metadata key to retrieve
|
|
115
|
+
* @returns The metadata value or undefined
|
|
116
|
+
*/
|
|
117
|
+
export declare function getPropertyMetadata(targetClass: Type<any>, propertyName: string, metadataKey: string): any;
|
|
118
|
+
/**
|
|
119
|
+
* Sets metadata for a property on a class.
|
|
120
|
+
*
|
|
121
|
+
* @param targetClass - The class to set metadata on
|
|
122
|
+
* @param propertyName - The property name
|
|
123
|
+
* @param metadataKey - The metadata key
|
|
124
|
+
* @param metadataValue - The metadata value
|
|
125
|
+
*/
|
|
126
|
+
export declare function setPropertyMetadata(targetClass: Type<any>, propertyName: string, metadataKey: string, metadataValue: any): void;
|
|
127
|
+
/**
|
|
128
|
+
* Gets all property names that have been defined on a class.
|
|
129
|
+
*
|
|
130
|
+
* @param targetClass - The class to inspect
|
|
131
|
+
* @returns Array of property names
|
|
132
|
+
*/
|
|
133
|
+
export declare function getDefinedProperties(targetClass: Type<any>): string[];
|
|
134
|
+
/**
|
|
135
|
+
* Clones a class constructor, creating a new class with the same properties.
|
|
136
|
+
* This is useful for creating variations of existing classes.
|
|
137
|
+
*
|
|
138
|
+
* @param sourceClass - The class to clone
|
|
139
|
+
* @param newClassName - Name for the new class
|
|
140
|
+
* @returns A new class constructor
|
|
141
|
+
*/
|
|
142
|
+
export declare function cloneClass(sourceClass: Type<any>, newClassName: string): Type<any>;
|
|
143
|
+
//# sourceMappingURL=class-generator.helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"class-generator.helper.d.ts","sourceRoot":"","sources":["../../../src/helpers/args-helpers/class-generator.helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,kBAAkB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,UAAU,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAChB,UAAU,CAAC,E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