@amodx/schemas 0.0.1 → 0.0.2
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/Inputs/DefaultInputs.d.ts +20 -184
- package/Inputs/DefaultInputs.js +94 -348
- package/Inputs/PropertyInput.d.ts +27 -29
- package/Inputs/PropertyInput.js +22 -18
- package/Inputs/PropertyInputRegister.d.ts +4 -4
- package/Inputs/PropertyInputRegister.js +2 -2
- package/Inputs/index.d.ts +2 -0
- package/Inputs/index.js +2 -0
- package/Inputs/registerInput.d.ts +18 -0
- package/Inputs/registerInput.js +32 -0
- package/Properties/Property.d.ts +1 -1
- package/Properties.d.ts +37 -26
- package/Properties.js +14 -211
- package/Property.types.d.ts +13 -0
- package/Property.types.js +1 -0
- package/Schema/Node.d.ts +0 -0
- package/Schema/Node.js +1 -0
- package/Schema/Object.d.ts +0 -0
- package/Schema/Object.js +1 -0
- package/Schema/Property.d.ts +0 -0
- package/Schema/Property.js +1 -0
- package/Schema/Schema.d.ts +2 -0
- package/Schema/Schema.js +2 -0
- package/Schemas/SchemaNode.d.ts +13 -8
- package/Schemas/SchemaNode.js +24 -15
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
package/Schemas/SchemaNode.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Property } from "../Properties/Property";
|
|
2
|
+
import { PropertyInputBase } from "../Inputs/PropertyInput";
|
|
2
3
|
import { PropertyInputRegister } from "../Inputs/PropertyInputRegister";
|
|
3
4
|
import { Observable } from "@amodx/core/Observers/index";
|
|
4
5
|
import { Pipeline } from "@amodx/core/Pipelines";
|
|
@@ -13,6 +14,7 @@ export class TemplateNode {
|
|
|
13
14
|
class SchemaNodeObservers {
|
|
14
15
|
stateUpdated = new Observable();
|
|
15
16
|
updated = new Observable();
|
|
17
|
+
set = new Observable();
|
|
16
18
|
loadedIn = new Observable();
|
|
17
19
|
updatedOrLoadedIn = new Observable();
|
|
18
20
|
evaluate = new Observable();
|
|
@@ -34,6 +36,8 @@ class SchemaNodeProxy {
|
|
|
34
36
|
export class SchemaNode {
|
|
35
37
|
property;
|
|
36
38
|
root;
|
|
39
|
+
_updateData;
|
|
40
|
+
_loadInData;
|
|
37
41
|
children = null;
|
|
38
42
|
conditions = [];
|
|
39
43
|
input;
|
|
@@ -43,9 +47,17 @@ export class SchemaNode {
|
|
|
43
47
|
constructor(property, root) {
|
|
44
48
|
this.property = property;
|
|
45
49
|
this.root = root;
|
|
50
|
+
this._updateData = {
|
|
51
|
+
node: this,
|
|
52
|
+
newValue: this.getValue(),
|
|
53
|
+
};
|
|
54
|
+
this._loadInData = {
|
|
55
|
+
node: this,
|
|
56
|
+
value: this.getValue(),
|
|
57
|
+
};
|
|
46
58
|
if (property.input) {
|
|
47
|
-
const
|
|
48
|
-
this.input = new
|
|
59
|
+
const abstractInput = PropertyInputRegister.getProperty(property.input.type);
|
|
60
|
+
this.input = new PropertyInputBase(abstractInput, property.input, this);
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
63
|
proxy = null;
|
|
@@ -81,8 +93,8 @@ export class SchemaNode {
|
|
|
81
93
|
this.conditions.push(action);
|
|
82
94
|
}
|
|
83
95
|
}
|
|
84
|
-
if (property.input?.validator) {
|
|
85
|
-
const validator = ObjectPropertyValidatorRegister.getValidator(property.input.validator);
|
|
96
|
+
if (property.input?.properties.validator) {
|
|
97
|
+
const validator = ObjectPropertyValidatorRegister.getValidator(property.input.properties.validator);
|
|
86
98
|
this.observers.updatedOrLoadedIn.subscribe(this, () => {
|
|
87
99
|
const response = validator.validate(this.get(), this);
|
|
88
100
|
this.validatorResponse = response;
|
|
@@ -128,10 +140,8 @@ export class SchemaNode {
|
|
|
128
140
|
return this.pipelines.onStore.pipe(Property.Create(this.property)).value;
|
|
129
141
|
}
|
|
130
142
|
loadIn(value) {
|
|
131
|
-
this.
|
|
132
|
-
|
|
133
|
-
value,
|
|
134
|
-
}).value);
|
|
143
|
+
this._loadInData.value = value;
|
|
144
|
+
this.setValue(this.pipelines.loadedIn.pipe(this._loadInData).value);
|
|
135
145
|
this.observers.loadedIn.notify(this);
|
|
136
146
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
137
147
|
}
|
|
@@ -140,19 +150,18 @@ export class SchemaNode {
|
|
|
140
150
|
}
|
|
141
151
|
update(newValue) {
|
|
142
152
|
const oldValue = this.getValue();
|
|
143
|
-
this.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
const newFinalValue = this.getValue();
|
|
153
|
+
this._updateData.newValue = newValue;
|
|
154
|
+
const finalNewValue = this.pipelines.updated.pipe(this._updateData).newValue;
|
|
155
|
+
this.setValue(finalNewValue);
|
|
156
|
+
this.observers.set.notify(this);
|
|
148
157
|
if (this.input) {
|
|
149
|
-
if (!this.input.compare(oldValue,
|
|
158
|
+
if (!this.input.compare(oldValue, finalNewValue)) {
|
|
150
159
|
this.observers.updated.notify(this);
|
|
151
160
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
152
161
|
}
|
|
153
162
|
return;
|
|
154
163
|
}
|
|
155
|
-
if (oldValue !=
|
|
164
|
+
if (oldValue != finalNewValue) {
|
|
156
165
|
this.observers.updated.notify(this);
|
|
157
166
|
this.observers.updatedOrLoadedIn.notify(this);
|
|
158
167
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED