@itrocks/framework 0.3.4 → 0.3.6
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/cjs/dependencies.js +5 -4
- package/cjs/reflect-class.d.ts +4 -8
- package/cjs/reflect-class.js +17 -11
- package/cjs/reflect-property.d.ts +3 -2
- package/cjs/reflect-property.js +3 -1
- package/package.json +1 -1
package/cjs/dependencies.js
CHANGED
|
@@ -15,6 +15,7 @@ const composition_1 = require("@itrocks/composition");
|
|
|
15
15
|
const config_1 = require("@itrocks/config");
|
|
16
16
|
const core_transformers_1 = require("@itrocks/core-transformers");
|
|
17
17
|
const core_transformers_2 = require("@itrocks/core-transformers");
|
|
18
|
+
const property_1 = require("@itrocks/decorator/property");
|
|
18
19
|
const file_1 = require("@itrocks/file");
|
|
19
20
|
const lazy_loading_2 = require("@itrocks/lazy-loading");
|
|
20
21
|
const list_properties_1 = require("@itrocks/list-properties");
|
|
@@ -69,14 +70,14 @@ function bind() {
|
|
|
69
70
|
(0, property_view_2.initOrderedProperties)();
|
|
70
71
|
(0, mysql_1.mysqlDependsOn)({
|
|
71
72
|
applyReadTransformer: async function (data, property, object) {
|
|
72
|
-
const value = await (0, transformer_1.applyTransformer)(data[property], object, property, transformer_3.SQL, transformer_3.READ, data);
|
|
73
|
-
if ((value !== transformer_2.IGNORE) && Reflect.getOwnMetadata(lazy_loading_2.PROTECT_GET, object, property)) {
|
|
74
|
-
Reflect.deleteMetadata(lazy_loading_2.PROTECT_GET, object, property);
|
|
73
|
+
const value = await (0, transformer_1.applyTransformer)(data[(0, rename_1.toColumn)(property)], object, property, transformer_3.SQL, transformer_3.READ, data);
|
|
74
|
+
if ((value !== transformer_2.IGNORE) && Reflect.getOwnMetadata(lazy_loading_2.PROTECT_GET, object, (0, property_1.metadataNameOf)(property))) {
|
|
75
|
+
Reflect.deleteMetadata(lazy_loading_2.PROTECT_GET, object, (0, property_1.metadataNameOf)(property));
|
|
75
76
|
}
|
|
76
77
|
return value;
|
|
77
78
|
},
|
|
78
79
|
applySaveTransformer: async function (object, property, data) {
|
|
79
|
-
const value = Reflect.getMetadata(lazy_loading_2.PROTECT_GET, object, property)
|
|
80
|
+
const value = Reflect.getMetadata(lazy_loading_2.PROTECT_GET, object, (0, property_1.metadataNameOf)(property))
|
|
80
81
|
? (Object.hasOwn(object, property) ? object[property] : undefined)
|
|
81
82
|
: await object[property];
|
|
82
83
|
return (0, transformer_1.applyTransformer)(value, object, property, transformer_3.SQL, transformer_3.SAVE, data);
|
package/cjs/reflect-class.d.ts
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { KeyOf } from '@itrocks/class-type';
|
|
2
1
|
import { PropertyTypes } from '@itrocks/property-type';
|
|
3
2
|
import { ReflectClass as RC } from '@itrocks/reflect';
|
|
4
3
|
import { ReflectProperty } from './reflect-property';
|
|
5
4
|
export declare class ReflectClass<T extends object = object> extends RC<T> {
|
|
6
|
-
|
|
7
|
-
get parent():
|
|
8
|
-
get properties():
|
|
9
|
-
|
|
10
|
-
[Symbol.iterator](): ArrayIterator<import("@itrocks/reflect").ReflectProperty<T>>;
|
|
11
|
-
};
|
|
12
|
-
property(name: KeyOf<T>): ReflectProperty<T>;
|
|
5
|
+
inheritPropertyTypes(propertyTypes: PropertyTypes<T>): void;
|
|
6
|
+
get parent(): ReflectClass | null;
|
|
7
|
+
get properties(): ReflectProperty<T, keyof T>[];
|
|
8
|
+
get property(): { [K in keyof T]: ReflectProperty<T, K>; };
|
|
13
9
|
get uses(): import("@itrocks/class-type").Type[];
|
|
14
10
|
}
|
package/cjs/reflect-class.js
CHANGED
|
@@ -5,27 +5,33 @@ const reflect_1 = require("@itrocks/reflect");
|
|
|
5
5
|
const uses_1 = require("@itrocks/uses");
|
|
6
6
|
const reflect_property_1 = require("./reflect-property");
|
|
7
7
|
class ReflectClass extends reflect_1.ReflectClass {
|
|
8
|
-
|
|
9
|
-
super.
|
|
8
|
+
inheritPropertyTypes(propertyTypes) {
|
|
9
|
+
super.inheritPropertyTypes(propertyTypes);
|
|
10
10
|
for (const uses of this.uses) {
|
|
11
11
|
Object.assign(propertyTypes, new ReflectClass(uses).propertyTypes);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
get parent() {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
const parentType = Object.getPrototypeOf(this.type);
|
|
16
|
+
const parent = (parentType === Function.prototype) ? null : new ReflectClass(parentType);
|
|
17
|
+
Object.defineProperty(this, 'parent', { configurable: true, enumerable: false, value: parent, writable: true });
|
|
18
|
+
return parent;
|
|
19
19
|
}
|
|
20
20
|
get properties() {
|
|
21
|
-
const properties =
|
|
22
|
-
for (const
|
|
23
|
-
|
|
21
|
+
const properties = new Array;
|
|
22
|
+
for (const name of this.propertyNames) {
|
|
23
|
+
properties.push(new reflect_property_1.ReflectProperty(this, name));
|
|
24
24
|
}
|
|
25
|
+
Object.defineProperty(this, 'properties', { configurable: true, enumerable: false, value: properties, writable: true });
|
|
25
26
|
return properties;
|
|
26
27
|
}
|
|
27
|
-
property(
|
|
28
|
-
|
|
28
|
+
get property() {
|
|
29
|
+
const properties = {};
|
|
30
|
+
for (const property of this.properties) {
|
|
31
|
+
properties[property.name] = property;
|
|
32
|
+
}
|
|
33
|
+
Object.defineProperty(this, 'property', { configurable: true, enumerable: false, value: properties, writable: true });
|
|
34
|
+
return properties;
|
|
29
35
|
}
|
|
30
36
|
get uses() {
|
|
31
37
|
const value = (0, uses_1.usesOf)(this.type);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { HtmlContainer } from '@itrocks/core-transformers';
|
|
2
2
|
import { ReflectProperty as RP } from '@itrocks/reflect';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import { ReflectClass } from './reflect-class';
|
|
4
|
+
export declare class ReflectProperty<T extends object, K extends keyof T = keyof T> extends RP<T, K> {
|
|
5
|
+
get class(): ReflectClass<T>;
|
|
5
6
|
edit(format?: string): Promise<any>;
|
|
6
7
|
output(format?: string, askFor?: HtmlContainer): Promise<any>;
|
|
7
8
|
outputMandatoryContainer(format?: string): Promise<any>;
|
package/cjs/reflect-property.js
CHANGED
|
@@ -8,7 +8,9 @@ const transformer_2 = require("@itrocks/transformer");
|
|
|
8
8
|
const reflect_class_1 = require("./reflect-class");
|
|
9
9
|
class ReflectProperty extends reflect_1.ReflectProperty {
|
|
10
10
|
get class() {
|
|
11
|
-
|
|
11
|
+
const value = super.class;
|
|
12
|
+
Object.defineProperty(this, 'class', { configurable: true, enumerable: false, value, writable: true });
|
|
13
|
+
return value ? new reflect_class_1.ReflectClass(value.object ?? value.type) : value;
|
|
12
14
|
}
|
|
13
15
|
async edit(format = transformer_2.HTML) {
|
|
14
16
|
const object = this.object ?? this.class.type;
|
package/package.json
CHANGED