@amodx/schemas 0.0.1

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.
Files changed (37) hide show
  1. package/Inputs/DefaultInputs.d.ts +201 -0
  2. package/Inputs/DefaultInputs.js +376 -0
  3. package/Inputs/PropertyInput.d.ts +46 -0
  4. package/Inputs/PropertyInput.js +35 -0
  5. package/Inputs/PropertyInputRegister.d.ts +7 -0
  6. package/Inputs/PropertyInputRegister.js +13 -0
  7. package/Properties/ObjectPath.d.ts +17 -0
  8. package/Properties/ObjectPath.js +33 -0
  9. package/Properties/Property.d.ts +24 -0
  10. package/Properties/Property.js +38 -0
  11. package/Properties/PropertyCondition.d.ts +11 -0
  12. package/Properties/PropertyCondition.js +37 -0
  13. package/Properties/PropertyConditionAction.d.ts +11 -0
  14. package/Properties/PropertyConditionAction.js +38 -0
  15. package/Properties.d.ts +44 -0
  16. package/Properties.js +239 -0
  17. package/Schema.d.ts +22 -0
  18. package/Schema.js +99 -0
  19. package/Schemas/BinaryObjectSchema.d.ts +3 -0
  20. package/Schemas/BinaryObjectSchema.js +3 -0
  21. package/Schemas/ObjectSchema.d.ts +17 -0
  22. package/Schemas/ObjectSchema.js +103 -0
  23. package/Schemas/ObjectSchemaInstance.d.ts +10 -0
  24. package/Schemas/ObjectSchemaInstance.js +14 -0
  25. package/Schemas/SchemaNode.d.ts +62 -0
  26. package/Schemas/SchemaNode.js +172 -0
  27. package/Validation/ObjectPropertyValidator.d.ts +7 -0
  28. package/Validation/ObjectPropertyValidator.js +9 -0
  29. package/Validation/ObjectPropertyValidatorRegister.d.ts +7 -0
  30. package/Validation/ObjectPropertyValidatorRegister.js +13 -0
  31. package/Validation/ObjectValidation.types.d.ts +13 -0
  32. package/Validation/ObjectValidation.types.js +1 -0
  33. package/Validation/index.d.ts +3 -0
  34. package/Validation/index.js +3 -0
  35. package/index.d.ts +8 -0
  36. package/index.js +8 -0
  37. package/package.json +27 -0
@@ -0,0 +1,201 @@
1
+ import { PropertyInputBase, PropertyInputMetaData } from "./PropertyInput";
2
+ declare class StringInput extends PropertyInputBase<string, {
3
+ min: number;
4
+ max: number;
5
+ }> {
6
+ static Meta: {
7
+ id: string;
8
+ name: string;
9
+ };
10
+ static Create(data: Partial<StringInput["data"]>): StringInput["data"];
11
+ compare(value1: string, value2: string): boolean;
12
+ getClass(): typeof StringInput;
13
+ getMeta(): PropertyInputMetaData;
14
+ }
15
+ declare class ColorInput extends PropertyInputBase<string, {}> {
16
+ static Meta: {
17
+ id: string;
18
+ name: string;
19
+ };
20
+ static Create(data: Partial<ColorInput["data"]>): ColorInput["data"];
21
+ compare(value1: string, value2: string): boolean;
22
+ getClass(): typeof ColorInput;
23
+ getMeta(): PropertyInputMetaData;
24
+ }
25
+ declare class RangeInput extends PropertyInputBase<number, {
26
+ min: number;
27
+ max: number;
28
+ step: number;
29
+ }> {
30
+ static Meta: {
31
+ id: string;
32
+ name: string;
33
+ };
34
+ static Create(data: Partial<RangeInput["data"]>): RangeInput["data"];
35
+ compare(value1: number, value2: number): boolean;
36
+ getClass(): typeof RangeInput;
37
+ getMeta(): PropertyInputMetaData;
38
+ }
39
+ declare class FloatInput extends PropertyInputBase<number, {
40
+ min: number;
41
+ max: number;
42
+ }> {
43
+ static Meta: {
44
+ id: string;
45
+ name: string;
46
+ };
47
+ static Create(data: Partial<FloatInput["data"]>): FloatInput["data"];
48
+ compare(value1: number, value2: number): boolean;
49
+ getClass(): typeof FloatInput;
50
+ getMeta(): PropertyInputMetaData;
51
+ }
52
+ declare class Vec2Input extends PropertyInputBase<{
53
+ x: number;
54
+ y: number;
55
+ }, {
56
+ valueType: "position" | "dimension";
57
+ }> {
58
+ static Meta: {
59
+ id: string;
60
+ name: string;
61
+ };
62
+ static Create(data: Partial<Vec2Input["data"]>): Vec2Input["data"];
63
+ compare(value1: {
64
+ x: number;
65
+ y: number;
66
+ }, value2: {
67
+ x: number;
68
+ y: number;
69
+ }): boolean;
70
+ getClass(): typeof Vec2Input;
71
+ getMeta(): PropertyInputMetaData;
72
+ }
73
+ declare class Vec3Input extends PropertyInputBase<{
74
+ x: number;
75
+ y: number;
76
+ z: number;
77
+ }, {
78
+ valueType: "position" | "dimension";
79
+ }> {
80
+ static Meta: {
81
+ id: string;
82
+ name: string;
83
+ };
84
+ static Create(data: Partial<Vec3Input["data"]>): Vec3Input["data"];
85
+ compare(value1: {
86
+ x: number;
87
+ y: number;
88
+ z: number;
89
+ }, value2: {
90
+ x: number;
91
+ y: number;
92
+ z: number;
93
+ }): boolean;
94
+ getClass(): typeof Vec3Input;
95
+ getMeta(): PropertyInputMetaData;
96
+ }
97
+ declare class IntInput extends PropertyInputBase<number, {
98
+ min: number;
99
+ max: number;
100
+ }> {
101
+ static Meta: {
102
+ id: string;
103
+ name: string;
104
+ };
105
+ static Create(data: Partial<IntInput["data"]>): IntInput["data"];
106
+ compare(value1: number, value2: number): boolean;
107
+ getClass(): typeof IntInput;
108
+ getMeta(): PropertyInputMetaData;
109
+ }
110
+ declare class SelectInput extends PropertyInputBase<string | number, {
111
+ options: string[] | [display: string, value: string | number][];
112
+ mode?: string;
113
+ }> {
114
+ static Meta: {
115
+ id: string;
116
+ name: string;
117
+ };
118
+ static Create(data: Partial<SelectInput["data"]>): SelectInput["data"];
119
+ compare(value1: string | number, value2: string | number): boolean;
120
+ getClass(): typeof SelectInput;
121
+ getMeta(): PropertyInputMetaData;
122
+ }
123
+ declare class FilePathInput extends PropertyInputBase<string, {
124
+ acceptedFileExtensions: string[];
125
+ }> {
126
+ static Meta: {
127
+ id: string;
128
+ name: string;
129
+ };
130
+ static Create(data: Partial<FilePathInput["data"]>): FilePathInput["data"];
131
+ compare(value1: string, value2: string): boolean;
132
+ getClass(): typeof FilePathInput;
133
+ getMeta(): PropertyInputMetaData;
134
+ }
135
+ declare class PasswordInput extends PropertyInputBase<string, {
136
+ min: number;
137
+ max: number;
138
+ }> {
139
+ static Meta: {
140
+ id: string;
141
+ name: string;
142
+ };
143
+ static Create(data: Partial<PasswordInput["data"]>): PasswordInput["data"];
144
+ compare(value1: string, value2: string): boolean;
145
+ getClass(): typeof PasswordInput;
146
+ getMeta(): PropertyInputMetaData;
147
+ }
148
+ declare class CheckboxInput extends PropertyInputBase<boolean, {}> {
149
+ static Meta: {
150
+ id: string;
151
+ name: string;
152
+ };
153
+ static Create(data: Partial<CheckboxInput["data"]>): CheckboxInput["data"];
154
+ compare(value1: boolean, value2: boolean): boolean;
155
+ getClass(): typeof CheckboxInput;
156
+ getMeta(): PropertyInputMetaData;
157
+ }
158
+ declare class DateInput extends PropertyInputBase<string, {}> {
159
+ static Meta: {
160
+ id: string;
161
+ name: string;
162
+ };
163
+ static Create(data: Partial<DateInput["data"]>): DateInput["data"];
164
+ compare(value1: string, value2: string): boolean;
165
+ getClass(): typeof DateInput;
166
+ getMeta(): PropertyInputMetaData;
167
+ }
168
+ declare class TextareaInput extends PropertyInputBase<string, {
169
+ rows: number;
170
+ cols: number;
171
+ }> {
172
+ static Meta: {
173
+ id: string;
174
+ name: string;
175
+ };
176
+ static Create(data: Partial<TextareaInput["data"]>): TextareaInput["data"];
177
+ compare(value1: string, value2: string): boolean;
178
+ getClass(): typeof TextareaInput;
179
+ getMeta(): PropertyInputMetaData;
180
+ }
181
+ declare class EmailInput extends PropertyInputBase<string, {}> {
182
+ static Meta: {
183
+ id: string;
184
+ name: string;
185
+ };
186
+ static Create(data: Partial<EmailInput["data"]>): EmailInput["data"];
187
+ compare(value1: string, value2: string): boolean;
188
+ getClass(): typeof EmailInput;
189
+ getMeta(): PropertyInputMetaData;
190
+ }
191
+ declare class UrlInput extends PropertyInputBase<string, {}> {
192
+ static Meta: {
193
+ id: string;
194
+ name: string;
195
+ };
196
+ static Create(data: Partial<UrlInput["data"]>): UrlInput["data"];
197
+ compare(value1: string, value2: string): boolean;
198
+ getClass(): typeof UrlInput;
199
+ getMeta(): PropertyInputMetaData;
200
+ }
201
+ export { ColorInput as ColorPropertyInput, RangeInput as RangePropertyInput, FloatInput as FloatPropertyInput, Vec2Input as Vec2PropertyInput, Vec3Input as Vec3PropertyInput, IntInput as IntPropertyInput, StringInput as StringPropertyInput, SelectInput as SelectPropertyInput, FilePathInput as FilePathPropertyInput, PasswordInput as PasswordPropertyInput, CheckboxInput as CheckboxPropertyInput, DateInput as DatePropertyInput, TextareaInput as TextareaPropertyInput, EmailInput as EmailPropertyInput, UrlInput as UrlPropertyInput, };
@@ -0,0 +1,376 @@
1
+ import { PropertyInputBase } from "./PropertyInput";
2
+ import { PropertyInputRegister } from "./PropertyInputRegister";
3
+ class StringInput extends PropertyInputBase {
4
+ static Meta = {
5
+ id: "string",
6
+ name: "string",
7
+ };
8
+ static Create(data) {
9
+ return {
10
+ ...PropertyInputBase.CreateBase({}),
11
+ type: StringInput.Meta.id,
12
+ properties: {
13
+ min: 0,
14
+ max: Number.MAX_SAFE_INTEGER,
15
+ },
16
+ ...data,
17
+ };
18
+ }
19
+ compare(value1, value2) {
20
+ return value1 == value2;
21
+ }
22
+ getClass() {
23
+ return StringInput;
24
+ }
25
+ getMeta() {
26
+ return StringInput.Meta;
27
+ }
28
+ }
29
+ class ColorInput extends PropertyInputBase {
30
+ static Meta = {
31
+ id: "color",
32
+ name: "Color",
33
+ };
34
+ static Create(data) {
35
+ return {
36
+ ...PropertyInputBase.CreateBase({}),
37
+ type: ColorInput.Meta.id,
38
+ properties: {},
39
+ ...data,
40
+ };
41
+ }
42
+ compare(value1, value2) {
43
+ return value1 == value2;
44
+ }
45
+ getClass() {
46
+ return ColorInput;
47
+ }
48
+ getMeta() {
49
+ return ColorInput.Meta;
50
+ }
51
+ }
52
+ class RangeInput extends PropertyInputBase {
53
+ static Meta = {
54
+ id: "range",
55
+ name: "Range",
56
+ };
57
+ static Create(data) {
58
+ return {
59
+ ...PropertyInputBase.CreateBase({}),
60
+ type: RangeInput.Meta.id,
61
+ properties: {
62
+ min: 0,
63
+ max: Number.MAX_SAFE_INTEGER,
64
+ step: 1,
65
+ },
66
+ ...data,
67
+ };
68
+ }
69
+ compare(value1, value2) {
70
+ return value1 == value2;
71
+ }
72
+ getClass() {
73
+ return RangeInput;
74
+ }
75
+ getMeta() {
76
+ return RangeInput.Meta;
77
+ }
78
+ }
79
+ class FloatInput extends PropertyInputBase {
80
+ static Meta = {
81
+ id: "float",
82
+ name: "Float",
83
+ };
84
+ static Create(data) {
85
+ return {
86
+ ...PropertyInputBase.CreateBase({}),
87
+ type: FloatInput.Meta.id,
88
+ properties: {
89
+ min: 0,
90
+ max: Number.MAX_SAFE_INTEGER,
91
+ },
92
+ ...data,
93
+ };
94
+ }
95
+ compare(value1, value2) {
96
+ return value1 == value2;
97
+ }
98
+ getClass() {
99
+ return FloatInput;
100
+ }
101
+ getMeta() {
102
+ return FloatInput.Meta;
103
+ }
104
+ }
105
+ class Vec2Input extends PropertyInputBase {
106
+ static Meta = {
107
+ id: "vec2",
108
+ name: "Vec2",
109
+ };
110
+ static Create(data) {
111
+ return {
112
+ ...PropertyInputBase.CreateBase({}),
113
+ type: Vec2Input.Meta.id,
114
+ properties: {
115
+ valueType: "position",
116
+ },
117
+ ...data,
118
+ };
119
+ }
120
+ compare(value1, value2) {
121
+ return value1.x == value2.x && value1.y == value2.y;
122
+ }
123
+ getClass() {
124
+ return Vec2Input;
125
+ }
126
+ getMeta() {
127
+ return Vec2Input.Meta;
128
+ }
129
+ }
130
+ class Vec3Input extends PropertyInputBase {
131
+ static Meta = {
132
+ id: "vec3",
133
+ name: "Vec3",
134
+ };
135
+ static Create(data) {
136
+ return {
137
+ ...PropertyInputBase.CreateBase({}),
138
+ type: Vec3Input.Meta.id,
139
+ properties: {
140
+ valueType: "position",
141
+ },
142
+ ...data,
143
+ };
144
+ }
145
+ compare(value1, value2) {
146
+ return value1.x == value2.x && value1.y == value2.y && value1.z == value2.z;
147
+ }
148
+ getClass() {
149
+ return Vec3Input;
150
+ }
151
+ getMeta() {
152
+ return Vec3Input.Meta;
153
+ }
154
+ }
155
+ class IntInput extends PropertyInputBase {
156
+ static Meta = {
157
+ id: "int",
158
+ name: "Int",
159
+ };
160
+ static Create(data) {
161
+ return {
162
+ ...PropertyInputBase.CreateBase({}),
163
+ type: IntInput.Meta.id,
164
+ properties: {
165
+ min: 0,
166
+ max: Number.MAX_SAFE_INTEGER,
167
+ },
168
+ ...data,
169
+ };
170
+ }
171
+ compare(value1, value2) {
172
+ return value1 == value2;
173
+ }
174
+ getClass() {
175
+ return IntInput;
176
+ }
177
+ getMeta() {
178
+ return IntInput.Meta;
179
+ }
180
+ }
181
+ class SelectInput extends PropertyInputBase {
182
+ static Meta = {
183
+ id: "select",
184
+ name: "Select",
185
+ };
186
+ static Create(data) {
187
+ return {
188
+ ...PropertyInputBase.CreateBase({}),
189
+ type: SelectInput.Meta.id,
190
+ properties: {
191
+ options: [],
192
+ },
193
+ ...data,
194
+ };
195
+ }
196
+ compare(value1, value2) {
197
+ return value1 == value2;
198
+ }
199
+ getClass() {
200
+ return SelectInput;
201
+ }
202
+ getMeta() {
203
+ return SelectInput.Meta;
204
+ }
205
+ }
206
+ class FilePathInput extends PropertyInputBase {
207
+ static Meta = {
208
+ id: "file-path",
209
+ name: "File Path",
210
+ };
211
+ static Create(data) {
212
+ return {
213
+ ...PropertyInputBase.CreateBase({}),
214
+ type: FilePathInput.Meta.id,
215
+ properties: {
216
+ acceptedFileExtensions: [],
217
+ },
218
+ ...data,
219
+ };
220
+ }
221
+ compare(value1, value2) {
222
+ return value1 == value2;
223
+ }
224
+ getClass() {
225
+ return FilePathInput;
226
+ }
227
+ getMeta() {
228
+ return FilePathInput.Meta;
229
+ }
230
+ }
231
+ class PasswordInput extends PropertyInputBase {
232
+ static Meta = {
233
+ id: "password",
234
+ name: "Password",
235
+ };
236
+ static Create(data) {
237
+ return {
238
+ ...PropertyInputBase.CreateBase({}),
239
+ type: PasswordInput.Meta.id,
240
+ properties: {
241
+ min: 0,
242
+ max: Number.MAX_SAFE_INTEGER,
243
+ },
244
+ ...data,
245
+ };
246
+ }
247
+ compare(value1, value2) {
248
+ return value1 == value2;
249
+ }
250
+ getClass() {
251
+ return PasswordInput;
252
+ }
253
+ getMeta() {
254
+ return PasswordInput.Meta;
255
+ }
256
+ }
257
+ class CheckboxInput extends PropertyInputBase {
258
+ static Meta = {
259
+ id: "checkbox",
260
+ name: "Checkbox",
261
+ };
262
+ static Create(data) {
263
+ return {
264
+ ...PropertyInputBase.CreateBase({}),
265
+ type: CheckboxInput.Meta.id,
266
+ properties: {},
267
+ ...data,
268
+ };
269
+ }
270
+ compare(value1, value2) {
271
+ return value1 == value2;
272
+ }
273
+ getClass() {
274
+ return CheckboxInput;
275
+ }
276
+ getMeta() {
277
+ return CheckboxInput.Meta;
278
+ }
279
+ }
280
+ class DateInput extends PropertyInputBase {
281
+ static Meta = {
282
+ id: "date",
283
+ name: "Date",
284
+ };
285
+ static Create(data) {
286
+ return {
287
+ ...PropertyInputBase.CreateBase({}),
288
+ type: DateInput.Meta.id,
289
+ properties: {},
290
+ ...data,
291
+ };
292
+ }
293
+ compare(value1, value2) {
294
+ return value1 == value2;
295
+ }
296
+ getClass() {
297
+ return DateInput;
298
+ }
299
+ getMeta() {
300
+ return DateInput.Meta;
301
+ }
302
+ }
303
+ class TextareaInput extends PropertyInputBase {
304
+ static Meta = {
305
+ id: "textarea",
306
+ name: "Textarea",
307
+ };
308
+ static Create(data) {
309
+ return {
310
+ ...PropertyInputBase.CreateBase({}),
311
+ type: TextareaInput.Meta.id,
312
+ properties: {
313
+ rows: 4,
314
+ cols: 50,
315
+ },
316
+ ...data,
317
+ };
318
+ }
319
+ compare(value1, value2) {
320
+ return value1 == value2;
321
+ }
322
+ getClass() {
323
+ return TextareaInput;
324
+ }
325
+ getMeta() {
326
+ return TextareaInput.Meta;
327
+ }
328
+ }
329
+ class EmailInput extends PropertyInputBase {
330
+ static Meta = {
331
+ id: "email",
332
+ name: "Email",
333
+ };
334
+ static Create(data) {
335
+ return {
336
+ ...PropertyInputBase.CreateBase({}),
337
+ type: EmailInput.Meta.id,
338
+ properties: {},
339
+ ...data,
340
+ };
341
+ }
342
+ compare(value1, value2) {
343
+ return value1 == value2;
344
+ }
345
+ getClass() {
346
+ return EmailInput;
347
+ }
348
+ getMeta() {
349
+ return EmailInput.Meta;
350
+ }
351
+ }
352
+ class UrlInput extends PropertyInputBase {
353
+ static Meta = {
354
+ id: "url",
355
+ name: "URL",
356
+ };
357
+ static Create(data) {
358
+ return {
359
+ ...PropertyInputBase.CreateBase({}),
360
+ type: UrlInput.Meta.id,
361
+ properties: {},
362
+ ...data,
363
+ };
364
+ }
365
+ compare(value1, value2) {
366
+ return value1 == value2;
367
+ }
368
+ getClass() {
369
+ return UrlInput;
370
+ }
371
+ getMeta() {
372
+ return UrlInput.Meta;
373
+ }
374
+ }
375
+ PropertyInputRegister.regsiterProperty(ColorInput, RangeInput, FloatInput, Vec2Input, Vec3Input, IntInput, StringInput, SelectInput, FilePathInput, PasswordInput, CheckboxInput, DateInput, TextareaInput, EmailInput, UrlInput);
376
+ export { ColorInput as ColorPropertyInput, RangeInput as RangePropertyInput, FloatInput as FloatPropertyInput, Vec2Input as Vec2PropertyInput, Vec3Input as Vec3PropertyInput, IntInput as IntPropertyInput, StringInput as StringPropertyInput, SelectInput as SelectPropertyInput, FilePathInput as FilePathPropertyInput, PasswordInput as PasswordPropertyInput, CheckboxInput as CheckboxPropertyInput, DateInput as DatePropertyInput, TextareaInput as TextareaPropertyInput, EmailInput as EmailPropertyInput, UrlInput as UrlPropertyInput, };
@@ -0,0 +1,46 @@
1
+ import { Pipeline } from "@amodx/core/Pipelines";
2
+ import { SchemaNode } from "../Schemas/SchemaNode";
3
+ declare class PropertyInputPipelines<Value = any> {
4
+ onGet: Pipeline<{
5
+ value: Value;
6
+ input: PropertyInputBase;
7
+ }>;
8
+ onSet: Pipeline<{
9
+ newValue: any;
10
+ input: PropertyInputBase;
11
+ }>;
12
+ }
13
+ export interface PropertyInputData<Value = any, Properties extends object = any> {
14
+ type: string;
15
+ properties: Properties;
16
+ disabled?: boolean;
17
+ mode?: string;
18
+ required?: boolean;
19
+ validator?: string;
20
+ }
21
+ export interface PropertyInputMetaData {
22
+ id: string;
23
+ name: string;
24
+ [key: string]: any;
25
+ }
26
+ export interface PropertyInputConstructor<Value = any, Properties extends object = any> {
27
+ Meta: PropertyInputMetaData;
28
+ Create(overrides: Partial<PropertyInputData<Value, Properties>>): PropertyInputData<Value, Properties>;
29
+ new (data: PropertyInputData<Value, Properties>, node: SchemaNode): PropertyInputBase<Value, Properties>;
30
+ }
31
+ export interface PropertyInputBase {
32
+ init?(): void;
33
+ }
34
+ export declare abstract class PropertyInputBase<Value = any, Properties extends object = any> {
35
+ data: PropertyInputData<Value, Properties>;
36
+ node: SchemaNode;
37
+ static CreateBase<Value = any, Properties extends object = any>(data: Partial<PropertyInputConstructor<Value, Properties>>): PropertyInputData<Value, Properties>;
38
+ pipelines: PropertyInputPipelines<any>;
39
+ constructor(data: PropertyInputData<Value, Properties>, node: SchemaNode);
40
+ abstract compare(value1: Value, value2: Value): boolean;
41
+ get(): any;
42
+ set(newValue: Value): void;
43
+ abstract getClass(): PropertyInputConstructor<Value, Properties>;
44
+ abstract getMeta(): PropertyInputMetaData;
45
+ }
46
+ export {};
@@ -0,0 +1,35 @@
1
+ import { Pipeline } from "@amodx/core/Pipelines";
2
+ class PropertyInputPipelines {
3
+ onGet = new Pipeline();
4
+ onSet = new Pipeline();
5
+ }
6
+ export class PropertyInputBase {
7
+ data;
8
+ node;
9
+ static CreateBase(data) {
10
+ return {
11
+ type: "",
12
+ properties: {},
13
+ ...data,
14
+ };
15
+ }
16
+ pipelines = new PropertyInputPipelines();
17
+ constructor(data, node) {
18
+ this.data = data;
19
+ this.node = node;
20
+ if (this.init)
21
+ this.init();
22
+ }
23
+ get() {
24
+ return this.pipelines.onGet.pipe({
25
+ input: this,
26
+ value: this.node.get(),
27
+ }).value;
28
+ }
29
+ set(newValue) {
30
+ this.node.update(this.pipelines.onSet.pipe({
31
+ input: this,
32
+ newValue,
33
+ }).newValue);
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ import { ArrayMap } from "@amodx/core/DataStructures/ArrayMap";
2
+ import { PropertyInputConstructor } from "./PropertyInput";
3
+ export declare class PropertyInputRegister {
4
+ static properties: ArrayMap<string, PropertyInputConstructor<any, any>>;
5
+ static regsiterProperty(...data: PropertyInputConstructor[]): void;
6
+ static getProperty(id: string): PropertyInputConstructor<any, any>;
7
+ }
@@ -0,0 +1,13 @@
1
+ import { ArrayMap } from "@amodx/core/DataStructures/ArrayMap";
2
+ export class PropertyInputRegister {
3
+ static properties = new ArrayMap();
4
+ static regsiterProperty(...data) {
5
+ this.properties.add(data.map((_) => [_.Meta.id, _]));
6
+ }
7
+ static getProperty(id) {
8
+ const property = this.properties.get(id);
9
+ if (!property)
10
+ throw new Error(`Property with id ${id} does not exist`);
11
+ return property;
12
+ }
13
+ }
@@ -0,0 +1,17 @@
1
+ type QueryPathTree<T> = {
2
+ [P in keyof T]-?: T[P] extends (infer U)[] ? [P] | [P, number] | [P, number, ...QueryPath<U>] : T[P] extends object ? [P] | [P, ...QueryPath<T[P]>] : [P];
3
+ };
4
+ export type QueryPath<T> = QueryPathTree<T>[keyof T];
5
+ type QueryPathValue<T, P extends any[]> = P extends [infer K, ...infer Rest] ? K extends keyof T ? Rest extends [] ? T[K] : Rest extends [number, ...infer R] ? T[K] extends (infer U)[] ? R extends [] ? U : QueryPathValue<U, R> : never : QueryPathValue<T[K], Rest> : never : never;
6
+ export declare class ObjectPath<Data extends object, Path extends QueryPath<Data>> {
7
+ path: Path;
8
+ static Create<Data extends object, Path extends QueryPath<Data> = any>(path: Path): ObjectPath<Data, typeof path>;
9
+ static Generator<Data extends object>(): <Path extends QueryPath<Data>>(path: Path) => ObjectPath<Data, Path>;
10
+ private propertyPath;
11
+ private constructor();
12
+ private resolvePath;
13
+ private resolveParentPath;
14
+ get(obj: Data): QueryPathValue<Data, Path>;
15
+ set(obj: Data, value: QueryPathValue<Data, Path>): void;
16
+ }
17
+ export {};