@axi-engine/fields 0.3.5 → 0.3.7
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/index.d.mts +50 -3
- package/dist/index.d.ts +1044 -18
- package/dist/index.js +1271 -18
- package/dist/index.mjs +42 -2
- package/package.json +3 -3
- package/dist/core-field-tree-factory.d.ts +0 -13
- package/dist/core-field-tree-factory.d.ts.map +0 -1
- package/dist/core-field-tree-factory.js +0 -14
- package/dist/core-field-tree-factory.js.map +0 -1
- package/dist/core-field-tree.d.ts +0 -5
- package/dist/core-field-tree.d.ts.map +0 -1
- package/dist/core-field-tree.js +0 -4
- package/dist/core-field-tree.js.map +0 -1
- package/dist/core-fields-factory.d.ts +0 -10
- package/dist/core-fields-factory.d.ts.map +0 -1
- package/dist/core-fields-factory.js +0 -14
- package/dist/core-fields-factory.js.map +0 -1
- package/dist/core-fields.d.ts +0 -47
- package/dist/core-fields.d.ts.map +0 -1
- package/dist/core-fields.js +0 -8
- package/dist/core-fields.js.map +0 -1
- package/dist/data-store-field-resolver.d.ts +0 -26
- package/dist/data-store-field-resolver.d.ts.map +0 -1
- package/dist/data-store-field-resolver.js +0 -21
- package/dist/data-store-field-resolver.js.map +0 -1
- package/dist/data-store.d.ts +0 -38
- package/dist/data-store.d.ts.map +0 -1
- package/dist/data-store.js +0 -141
- package/dist/data-store.js.map +0 -1
- package/dist/field-definitions/core-boolean-field.d.ts +0 -11
- package/dist/field-definitions/core-boolean-field.d.ts.map +0 -1
- package/dist/field-definitions/core-boolean-field.js +0 -13
- package/dist/field-definitions/core-boolean-field.js.map +0 -1
- package/dist/field-definitions/core-field.d.ts +0 -51
- package/dist/field-definitions/core-field.d.ts.map +0 -1
- package/dist/field-definitions/core-field.js +0 -74
- package/dist/field-definitions/core-field.js.map +0 -1
- package/dist/field-definitions/core-numeric-field.d.ts +0 -18
- package/dist/field-definitions/core-numeric-field.d.ts.map +0 -1
- package/dist/field-definitions/core-numeric-field.js +0 -45
- package/dist/field-definitions/core-numeric-field.js.map +0 -1
- package/dist/field-definitions/core-string-field.d.ts +0 -15
- package/dist/field-definitions/core-string-field.d.ts.map +0 -1
- package/dist/field-definitions/core-string-field.js +0 -27
- package/dist/field-definitions/core-string-field.js.map +0 -1
- package/dist/field-definitions/index.d.ts +0 -5
- package/dist/field-definitions/index.d.ts.map +0 -1
- package/dist/field-definitions/index.js +0 -5
- package/dist/field-definitions/index.js.map +0 -1
- package/dist/field-registry.d.ts +0 -5
- package/dist/field-registry.d.ts.map +0 -1
- package/dist/field-registry.js +0 -4
- package/dist/field-registry.js.map +0 -1
- package/dist/field-tree-factory.d.ts +0 -12
- package/dist/field-tree-factory.d.ts.map +0 -1
- package/dist/field-tree-factory.js +0 -2
- package/dist/field-tree-factory.js.map +0 -1
- package/dist/field-tree.d.ts +0 -171
- package/dist/field-tree.d.ts.map +0 -1
- package/dist/field-tree.js +0 -248
- package/dist/field-tree.js.map +0 -1
- package/dist/field.d.ts +0 -34
- package/dist/field.d.ts.map +0 -1
- package/dist/field.js +0 -2
- package/dist/field.js.map +0 -1
- package/dist/fields-factory.d.ts +0 -5
- package/dist/fields-factory.d.ts.map +0 -1
- package/dist/fields-factory.js +0 -2
- package/dist/fields-factory.js.map +0 -1
- package/dist/fields.d.ts +0 -101
- package/dist/fields.d.ts.map +0 -1
- package/dist/fields.js +0 -143
- package/dist/fields.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/mixins/mixin-factory.d.ts +0 -29
- package/dist/mixins/mixin-factory.d.ts.map +0 -1
- package/dist/mixins/mixin-factory.js +0 -32
- package/dist/mixins/mixin-factory.js.map +0 -1
- package/dist/mixins/with-boolean-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-boolean-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-boolean-fields.mixin.js +0 -4
- package/dist/mixins/with-boolean-fields.mixin.js.map +0 -1
- package/dist/mixins/with-default-generic-fields.mixin.d.ts +0 -31
- package/dist/mixins/with-default-generic-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-default-generic-fields.mixin.js +0 -15
- package/dist/mixins/with-default-generic-fields.mixin.js.map +0 -1
- package/dist/mixins/with-numeric-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-numeric-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-numeric-fields.mixin.js +0 -4
- package/dist/mixins/with-numeric-fields.mixin.js.map +0 -1
- package/dist/mixins/with-string-fields.mixin.d.ts +0 -9
- package/dist/mixins/with-string-fields.mixin.d.ts.map +0 -1
- package/dist/mixins/with-string-fields.mixin.js +0 -4
- package/dist/mixins/with-string-fields.mixin.js.map +0 -1
- package/dist/policies/clamp-max-policy.d.ts +0 -11
- package/dist/policies/clamp-max-policy.d.ts.map +0 -1
- package/dist/policies/clamp-max-policy.js +0 -18
- package/dist/policies/clamp-max-policy.js.map +0 -1
- package/dist/policies/clamp-min-policy.d.ts +0 -11
- package/dist/policies/clamp-min-policy.d.ts.map +0 -1
- package/dist/policies/clamp-min-policy.js +0 -18
- package/dist/policies/clamp-min-policy.js.map +0 -1
- package/dist/policies/clamp-policy.d.ts +0 -12
- package/dist/policies/clamp-policy.d.ts.map +0 -1
- package/dist/policies/clamp-policy.js +0 -21
- package/dist/policies/clamp-policy.js.map +0 -1
- package/dist/policies/index.d.ts +0 -6
- package/dist/policies/index.d.ts.map +0 -1
- package/dist/policies/index.js +0 -6
- package/dist/policies/index.js.map +0 -1
- package/dist/policies/policies.d.ts +0 -38
- package/dist/policies/policies.d.ts.map +0 -1
- package/dist/policies/policies.js +0 -62
- package/dist/policies/policies.js.map +0 -1
- package/dist/policies/policy.d.ts +0 -6
- package/dist/policies/policy.d.ts.map +0 -1
- package/dist/policies/policy.js +0 -2
- package/dist/policies/policy.js.map +0 -1
- package/dist/serializer/field-serializer.d.ts +0 -52
- package/dist/serializer/field-serializer.d.ts.map +0 -1
- package/dist/serializer/field-serializer.js +0 -66
- package/dist/serializer/field-serializer.js.map +0 -1
- package/dist/serializer/field-tree-serializer.d.ts +0 -50
- package/dist/serializer/field-tree-serializer.d.ts.map +0 -1
- package/dist/serializer/field-tree-serializer.js +0 -68
- package/dist/serializer/field-tree-serializer.js.map +0 -1
- package/dist/serializer/fields-serializer.d.ts +0 -49
- package/dist/serializer/fields-serializer.d.ts.map +0 -1
- package/dist/serializer/fields-serializer.js +0 -57
- package/dist/serializer/fields-serializer.js.map +0 -1
- package/dist/serializer/index.d.ts +0 -8
- package/dist/serializer/index.d.ts.map +0 -1
- package/dist/serializer/index.js +0 -8
- package/dist/serializer/index.js.map +0 -1
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.d.ts +0 -13
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-max-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.d.ts +0 -13
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-min-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policies/clamp-policy-serializer-handler.d.ts +0 -16
- package/dist/serializer/policies/clamp-policy-serializer-handler.d.ts.map +0 -1
- package/dist/serializer/policies/clamp-policy-serializer-handler.js +0 -10
- package/dist/serializer/policies/clamp-policy-serializer-handler.js.map +0 -1
- package/dist/serializer/policy-serializer.d.ts +0 -41
- package/dist/serializer/policy-serializer.d.ts.map +0 -1
- package/dist/serializer/policy-serializer.js +0 -43
- package/dist/serializer/policy-serializer.js.map +0 -1
- package/dist/setup.d.ts +0 -41
- package/dist/setup.d.ts.map +0 -1
- package/dist/setup.js +0 -57
- package/dist/setup.js.map +0 -1
- package/dist/store.d.ts +0 -137
- package/dist/store.d.ts.map +0 -1
- package/dist/store.js +0 -2
- package/dist/store.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mixin-factory.js","sourceRoot":"","sources":["../../src/mixins/mixin-factory.ts"],"names":[],"mappings":"AAwBA;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAIrC,QAAgB,EAChB,cAAyB;IAEzB,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,SAAS,cAAc,EAAE;QACjC,KAAK,EAAE,QAAQ,cAAc,EAAE;QAC/B,GAAG,EAAE,MAAM,cAAc,EAAE;KAC5B,CAAC;IAEF,OAAO,UAA6C,IAAW;QAG7D,OAAO,MAAM,UAAW,SAAQ,IAAI;YAClC,sCAAsC;YACtC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,YAAiB,EAAE,OAAyC;gBAC7F,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAwB,CAAC;YACnF,CAAC;YAED,oCAAoC;YACpC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAY,EAAE,KAAU,EAAE,OAAyC;gBACrF,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAwB,CAAC;YAC3E,CAAC;YAED,gCAAgC;YAChC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAY;gBAC5B,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACxB,CAAC;SACK,CAAC;IACX,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CoreBooleanField } from '../field-definitions';
|
|
2
|
-
export declare const WithBooleanFields: <TBase extends import("@axi-engine/utils").Constructor<import("..").Fields>>(Base: TBase) => import("@axi-engine/utils").Constructor<InstanceType<TBase> & {
|
|
3
|
-
createBoolean: (name: string, initialValue: boolean, options?: import("../field-definitions").CoreBooleanFieldOptions | undefined) => CoreBooleanField;
|
|
4
|
-
} & {
|
|
5
|
-
upsetBoolean: (name: string, value: boolean, options?: import("../field-definitions").CoreBooleanFieldOptions | undefined) => CoreBooleanField;
|
|
6
|
-
} & {
|
|
7
|
-
getBoolean: (name: string) => CoreBooleanField;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=with-boolean-fields.mixin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-boolean-fields.mixin.d.ts","sourceRoot":"","sources":["../../src/mixins/with-boolean-fields.mixin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAEtD,eAAO,MAAM,iBAAiB;;;;;;EAGS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-boolean-fields.mixin.js","sourceRoot":"","sources":["../../src/mixins/with-boolean-fields.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAGtD,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Constructor } from '@axi-engine/utils';
|
|
2
|
-
import { Fields } from '../fields';
|
|
3
|
-
import { CoreField } from '../field-definitions';
|
|
4
|
-
import { FieldOptions } from '../field';
|
|
5
|
-
export declare function WithDefaultGenericFields<TBase extends Constructor<Fields>>(Base: TBase): {
|
|
6
|
-
new (...args: any[]): {
|
|
7
|
-
createGeneric<T>(name: string, initialValue: T, options?: FieldOptions<T>): CoreField<T>;
|
|
8
|
-
upsetGeneric<T>(name: string, value: T, options?: FieldOptions<T>): CoreField<T>;
|
|
9
|
-
getGeneric<T>(name: string): CoreField<T>;
|
|
10
|
-
readonly typeName: "fields";
|
|
11
|
-
readonly _fields: Map<string, import("../field").Field<any>>;
|
|
12
|
-
readonly _fieldRegistry: import("..").FieldRegistry;
|
|
13
|
-
onAdd: import("@axi-engine/utils").Emitter<[event: {
|
|
14
|
-
name: string;
|
|
15
|
-
field: import("../field").Field<any>;
|
|
16
|
-
}]>;
|
|
17
|
-
onRemove: import("@axi-engine/utils").Emitter<[event: {
|
|
18
|
-
names: string[];
|
|
19
|
-
}]>;
|
|
20
|
-
get fields(): Map<string, import("../field").Field<any>>;
|
|
21
|
-
has(name: string): boolean;
|
|
22
|
-
add<T extends import("../field").Field<any>>(field: import("../field").Field<any>): T;
|
|
23
|
-
create<T extends import("../field").Field<any>>(typeName: string, name: string, initialValue: any, options?: any): T;
|
|
24
|
-
upset<T extends import("../field").Field<any>>(typeName: string, name: string, value: any, options?: any): T;
|
|
25
|
-
get<TField extends import("../field").Field<any>>(name: string): TField;
|
|
26
|
-
remove(names: string | string[]): void;
|
|
27
|
-
clear(): void;
|
|
28
|
-
destroy(): void;
|
|
29
|
-
};
|
|
30
|
-
} & TBase;
|
|
31
|
-
//# sourceMappingURL=with-default-generic-fields.mixin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-default-generic-fields.mixin.d.ts","sourceRoot":"","sources":["../../src/mixins/with-default-generic-fields.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AAGtC,wBAAgB,wBAAwB,CAAC,KAAK,SAAS,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK;;sBAGrE,CAAC,QAAQ,MAAM,gBAAgB,CAAC,YAAY,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;qBAI3E,CAAC,QAAQ,MAAM,SAAS,CAAC,YAAY,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC;mBAIrE,CAAC,QAAQ,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;UAI5C"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CoreField } from '../field-definitions';
|
|
2
|
-
export function WithDefaultGenericFields(Base) {
|
|
3
|
-
return class FieldsWithDefaultGeneric extends Base {
|
|
4
|
-
createGeneric(name, initialValue, options) {
|
|
5
|
-
return this.create(CoreField.typeName, name, initialValue, options);
|
|
6
|
-
}
|
|
7
|
-
upsetGeneric(name, value, options) {
|
|
8
|
-
return this.upset(CoreField.typeName, name, value, options);
|
|
9
|
-
}
|
|
10
|
-
getGeneric(name) {
|
|
11
|
-
return this.get(name);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=with-default-generic-fields.mixin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-default-generic-fields.mixin.js","sourceRoot":"","sources":["../../src/mixins/with-default-generic-fields.mixin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAI/C,MAAM,UAAU,wBAAwB,CAAoC,IAAW;IAErF,OAAO,MAAM,wBAAyB,SAAQ,IAAI;QAChD,aAAa,CAAI,IAAY,EAAE,YAAe,EAAE,OAAyB;YACvE,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;QACtE,CAAC;QAED,YAAY,CAAI,IAAY,EAAE,KAAQ,EAAE,OAAyB;YAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC9D,CAAC;QAED,UAAU,CAAI,IAAY;YACxB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CoreNumericField } from '../field-definitions';
|
|
2
|
-
export declare const WithNumericFields: <TBase extends import("@axi-engine/utils").Constructor<import("..").Fields>>(Base: TBase) => import("@axi-engine/utils").Constructor<InstanceType<TBase> & {
|
|
3
|
-
createNumeric: (name: string, initialValue: number, options?: import("../field-definitions").CoreNumericFieldOptions | undefined) => CoreNumericField;
|
|
4
|
-
} & {
|
|
5
|
-
upsetNumeric: (name: string, value: number, options?: import("../field-definitions").CoreNumericFieldOptions | undefined) => CoreNumericField;
|
|
6
|
-
} & {
|
|
7
|
-
getNumeric: (name: string) => CoreNumericField;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=with-numeric-fields.mixin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-numeric-fields.mixin.d.ts","sourceRoot":"","sources":["../../src/mixins/with-numeric-fields.mixin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAGtD,eAAO,MAAM,iBAAiB;;;;;;EAGS,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-numeric-fields.mixin.js","sourceRoot":"","sources":["../../src/mixins/with-numeric-fields.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AAGtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAGtD,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { CoreStringField } from '../field-definitions';
|
|
2
|
-
export declare const WithStringFields: <TBase extends import("@axi-engine/utils").Constructor<import("..").Fields>>(Base: TBase) => import("@axi-engine/utils").Constructor<InstanceType<TBase> & {
|
|
3
|
-
createString: (name: string, initialValue: string, options?: import("../field-definitions").CoreStringFieldOptions | undefined) => CoreStringField;
|
|
4
|
-
} & {
|
|
5
|
-
upsetString: (name: string, value: string, options?: import("../field-definitions").CoreStringFieldOptions | undefined) => CoreStringField;
|
|
6
|
-
} & {
|
|
7
|
-
getString: (name: string) => CoreStringField;
|
|
8
|
-
}>;
|
|
9
|
-
//# sourceMappingURL=with-string-fields.mixin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-string-fields.mixin.d.ts","sourceRoot":"","sources":["../../src/mixins/with-string-fields.mixin.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,eAAO,MAAM,gBAAgB;;;;;;EAGQ,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"with-string-fields.mixin.js","sourceRoot":"","sources":["../../src/mixins/with-string-fields.mixin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CAGrD,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Policy } from './policy';
|
|
2
|
-
export declare class ClampMaxPolicy implements Policy<number> {
|
|
3
|
-
max: number;
|
|
4
|
-
static readonly id = "clampMax";
|
|
5
|
-
readonly id = "clampMax";
|
|
6
|
-
constructor(max: number);
|
|
7
|
-
apply(val: number): number;
|
|
8
|
-
updateBounds(max: number): void;
|
|
9
|
-
}
|
|
10
|
-
export declare function clampMaxPolicy(max: number): ClampMaxPolicy;
|
|
11
|
-
//# sourceMappingURL=clamp-max-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-max-policy.d.ts","sourceRoot":"","sources":["../../src/policies/clamp-max-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,qBAAa,cAAe,YAAW,MAAM,CAAC,MAAM,CAAC;IAIhC,GAAG,EAAE,MAAM;IAH9B,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc;IAChC,QAAQ,CAAC,EAAE,cAAqB;gBAEb,GAAG,EAAE,MAAM;IAG9B,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB,YAAY,CAAC,GAAG,EAAE,MAAM;CAGzB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,kBAEzC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class ClampMaxPolicy {
|
|
2
|
-
max;
|
|
3
|
-
static id = 'clampMax';
|
|
4
|
-
id = ClampMaxPolicy.id;
|
|
5
|
-
constructor(max) {
|
|
6
|
-
this.max = max;
|
|
7
|
-
}
|
|
8
|
-
apply(val) {
|
|
9
|
-
return Math.min(this.max, val);
|
|
10
|
-
}
|
|
11
|
-
updateBounds(max) {
|
|
12
|
-
this.max = max;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function clampMaxPolicy(max) {
|
|
16
|
-
return new ClampMaxPolicy(max);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=clamp-max-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-max-policy.js","sourceRoot":"","sources":["../../src/policies/clamp-max-policy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IAIN;IAHnB,MAAM,CAAU,EAAE,GAAG,UAAU,CAAC;IACvB,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC;IAEhC,YAAmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAC9B,CAAC;IAED,KAAK,CAAC,GAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;;AAGH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Policy } from './policy';
|
|
2
|
-
export declare class ClampMinPolicy implements Policy<number> {
|
|
3
|
-
min: number;
|
|
4
|
-
static readonly id = "clampMin";
|
|
5
|
-
readonly id = "clampMin";
|
|
6
|
-
constructor(min: number);
|
|
7
|
-
apply(val: number): number;
|
|
8
|
-
updateBounds(min: number): void;
|
|
9
|
-
}
|
|
10
|
-
export declare function clampMinPolicy(min: number): ClampMinPolicy;
|
|
11
|
-
//# sourceMappingURL=clamp-min-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-min-policy.d.ts","sourceRoot":"","sources":["../../src/policies/clamp-min-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,qBAAa,cAAe,YAAW,MAAM,CAAC,MAAM,CAAC;IAIhC,GAAG,EAAE,MAAM;IAH9B,MAAM,CAAC,QAAQ,CAAC,EAAE,cAAc;IAChC,QAAQ,CAAC,EAAE,cAAqB;gBAEb,GAAG,EAAE,MAAM;IAG9B,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB,YAAY,CAAC,GAAG,EAAE,MAAM;CAGzB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,kBAEzC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export class ClampMinPolicy {
|
|
2
|
-
min;
|
|
3
|
-
static id = 'clampMin';
|
|
4
|
-
id = ClampMinPolicy.id;
|
|
5
|
-
constructor(min) {
|
|
6
|
-
this.min = min;
|
|
7
|
-
}
|
|
8
|
-
apply(val) {
|
|
9
|
-
return Math.max(this.min, val);
|
|
10
|
-
}
|
|
11
|
-
updateBounds(min) {
|
|
12
|
-
this.min = min;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function clampMinPolicy(min) {
|
|
16
|
-
return new ClampMinPolicy(min);
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=clamp-min-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-min-policy.js","sourceRoot":"","sources":["../../src/policies/clamp-min-policy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IAIN;IAHnB,MAAM,CAAU,EAAE,GAAG,UAAU,CAAC;IACvB,EAAE,GAAG,cAAc,CAAC,EAAE,CAAC;IAEhC,YAAmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAC9B,CAAC;IAED,KAAK,CAAC,GAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,YAAY,CAAC,GAAW;QACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;;AAGH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,OAAO,IAAI,cAAc,CAAC,GAAG,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Policy } from './policy';
|
|
2
|
-
export declare class ClampPolicy implements Policy<number> {
|
|
3
|
-
min: number;
|
|
4
|
-
max: number;
|
|
5
|
-
static readonly id = "clamp";
|
|
6
|
-
readonly id = "clamp";
|
|
7
|
-
constructor(min: number, max: number);
|
|
8
|
-
apply(val: number): number;
|
|
9
|
-
updateBounds(min: number, max: number): void;
|
|
10
|
-
}
|
|
11
|
-
export declare function clampPolicy(min: number, max: number): ClampPolicy;
|
|
12
|
-
//# sourceMappingURL=clamp-policy.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-policy.d.ts","sourceRoot":"","sources":["../../src/policies/clamp-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAEhC,qBAAa,WAAY,YAAW,MAAM,CAAC,MAAM,CAAC;IAI7B,GAAG,EAAE,MAAM;IAAS,GAAG,EAAE,MAAM;IAHlD,MAAM,CAAC,QAAQ,CAAC,EAAE,WAAW;IAC7B,QAAQ,CAAC,EAAE,WAAkB;gBAEV,GAAG,EAAE,MAAM,EAAS,GAAG,EAAE,MAAM;IAGlD,KAAK,CAAC,GAAG,EAAE,MAAM;IAIjB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAItC;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,eAEnD"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export class ClampPolicy {
|
|
2
|
-
min;
|
|
3
|
-
max;
|
|
4
|
-
static id = 'clamp';
|
|
5
|
-
id = ClampPolicy.id;
|
|
6
|
-
constructor(min, max) {
|
|
7
|
-
this.min = min;
|
|
8
|
-
this.max = max;
|
|
9
|
-
}
|
|
10
|
-
apply(val) {
|
|
11
|
-
return Math.max(this.min, Math.min(this.max, val));
|
|
12
|
-
}
|
|
13
|
-
updateBounds(min, max) {
|
|
14
|
-
this.min = min;
|
|
15
|
-
this.max = max;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export function clampPolicy(min, max) {
|
|
19
|
-
return new ClampPolicy(min, max);
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=clamp-policy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"clamp-policy.js","sourceRoot":"","sources":["../../src/policies/clamp-policy.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,WAAW;IAIH;IAAoB;IAHvC,MAAM,CAAU,EAAE,GAAG,OAAO,CAAC;IACpB,EAAE,GAAG,WAAW,CAAC,EAAE,CAAC;IAE7B,YAAmB,GAAW,EAAS,GAAW;QAA/B,QAAG,GAAH,GAAG,CAAQ;QAAS,QAAG,GAAH,GAAG,CAAQ;IAClD,CAAC;IAED,KAAK,CAAC,GAAW;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,YAAY,CAAC,GAAW,EAAE,GAAW;QACnC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;;AAGH,MAAM,UAAU,WAAW,CAAC,GAAW,EAAE,GAAW;IAClD,OAAO,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AAClC,CAAC"}
|
package/dist/policies/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,YAAY,CAAC"}
|
package/dist/policies/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/policies/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,YAAY,CAAC"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { Policy } from './policy';
|
|
2
|
-
export declare class Policies<T> {
|
|
3
|
-
private readonly policies;
|
|
4
|
-
get items(): Map<string, Policy<T>>;
|
|
5
|
-
/**
|
|
6
|
-
* Retrieves a specific policy instance by its ID.
|
|
7
|
-
* Useful for accessing a policy's internal state or methods.
|
|
8
|
-
* @template P The expected type of the policy.
|
|
9
|
-
* @param id The unique ID of the policy to retrieve.
|
|
10
|
-
* @returns The policy instance, or `undefined` if not found.
|
|
11
|
-
*/
|
|
12
|
-
get<P extends Policy<T>>(id: string): P | undefined;
|
|
13
|
-
/**
|
|
14
|
-
* Adds a new policy to the field or replaces an existing one with the same ID.
|
|
15
|
-
* The new policy will be applied on the next `set()` operation.
|
|
16
|
-
* If a policy with the same ID already exists, its `destroy` method will be called before it is replaced.
|
|
17
|
-
* @param policy The policy instance to add.
|
|
18
|
-
*/
|
|
19
|
-
add(policy: Policy<T>): this;
|
|
20
|
-
/**
|
|
21
|
-
* Removes a policy from the field by its ID and call `destroy` method.
|
|
22
|
-
* @param policyId The unique ID of the policy to remove.
|
|
23
|
-
* @returns `true` if the policy was found and removed, otherwise `false`.
|
|
24
|
-
*/
|
|
25
|
-
remove(policyId: string): boolean;
|
|
26
|
-
isEmpty(): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Removes all policies from the field.
|
|
29
|
-
* After this, `set()` will no longer apply any transformations to the value until new policies are added.
|
|
30
|
-
*/
|
|
31
|
-
clear(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Forces the current value to be re-processed by all policies.
|
|
34
|
-
* Useful if a policy's logic has changed and you need to re-evaluate the current state.
|
|
35
|
-
*/
|
|
36
|
-
apply(val: T): T;
|
|
37
|
-
}
|
|
38
|
-
//# sourceMappingURL=policies.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policies.d.ts","sourceRoot":"","sources":["../../src/policies/policies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAC;AAGhC,qBAAa,QAAQ,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IAEzD,IAAI,KAAK,2BAER;IAED;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAInD;;;;;OAKG;IACH,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAQrB;;;;OAIG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IASjC,OAAO;IAIP;;;OAGG;IACH,KAAK,IAAI,IAAI;IAKb;;;OAGG;IACH,KAAK,CAAC,GAAG,EAAE,CAAC;CAKb"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export class Policies {
|
|
2
|
-
policies = new Map();
|
|
3
|
-
get items() {
|
|
4
|
-
return this.policies;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Retrieves a specific policy instance by its ID.
|
|
8
|
-
* Useful for accessing a policy's internal state or methods.
|
|
9
|
-
* @template P The expected type of the policy.
|
|
10
|
-
* @param id The unique ID of the policy to retrieve.
|
|
11
|
-
* @returns The policy instance, or `undefined` if not found.
|
|
12
|
-
*/
|
|
13
|
-
get(id) {
|
|
14
|
-
return this.policies.get(id);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Adds a new policy to the field or replaces an existing one with the same ID.
|
|
18
|
-
* The new policy will be applied on the next `set()` operation.
|
|
19
|
-
* If a policy with the same ID already exists, its `destroy` method will be called before it is replaced.
|
|
20
|
-
* @param policy The policy instance to add.
|
|
21
|
-
*/
|
|
22
|
-
add(policy) {
|
|
23
|
-
const existed = this.policies.get(policy.id);
|
|
24
|
-
existed?.destroy?.();
|
|
25
|
-
this.policies.set(policy.id, policy);
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Removes a policy from the field by its ID and call `destroy` method.
|
|
30
|
-
* @param policyId The unique ID of the policy to remove.
|
|
31
|
-
* @returns `true` if the policy was found and removed, otherwise `false`.
|
|
32
|
-
*/
|
|
33
|
-
remove(policyId) {
|
|
34
|
-
const policyToRemove = this.policies.get(policyId);
|
|
35
|
-
if (!policyToRemove) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
policyToRemove.destroy?.();
|
|
39
|
-
return this.policies.delete(policyId);
|
|
40
|
-
}
|
|
41
|
-
isEmpty() {
|
|
42
|
-
return this.policies.size === 0;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Removes all policies from the field.
|
|
46
|
-
* After this, `set()` will no longer apply any transformations to the value until new policies are added.
|
|
47
|
-
*/
|
|
48
|
-
clear() {
|
|
49
|
-
this.policies.forEach(policy => policy.destroy?.());
|
|
50
|
-
this.policies.clear();
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Forces the current value to be re-processed by all policies.
|
|
54
|
-
* Useful if a policy's logic has changed and you need to re-evaluate the current state.
|
|
55
|
-
*/
|
|
56
|
-
apply(val) {
|
|
57
|
-
let finalVal = val;
|
|
58
|
-
this.policies.forEach(policy => finalVal = policy.apply(finalVal));
|
|
59
|
-
return finalVal;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=policies.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policies.js","sourceRoot":"","sources":["../../src/policies/policies.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,QAAQ;IACF,QAAQ,GAAG,IAAI,GAAG,EAAqB,CAAC;IAEzD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAsB,EAAU;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAM,CAAC;IACpC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,MAAiB;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC7C,OAAO,EAAE,OAAO,EAAE,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAErC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,QAAgB;QACrB,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,cAAc,CAAC,OAAO,EAAE,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;OAGG;IACH,KAAK;QACH,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,GAAM;QACV,IAAI,QAAQ,GAAG,GAAG,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QACnE,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/policies/policy.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB"}
|
package/dist/policies/policy.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"policy.js","sourceRoot":"","sources":["../../src/policies/policy.ts"],"names":[],"mappings":""}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { PolicySerializer } from './policy-serializer';
|
|
2
|
-
import { FieldRegistry } from '../field-registry';
|
|
3
|
-
import { Field } from '../field';
|
|
4
|
-
/**
|
|
5
|
-
* A plain object representation of a Field's state for serialization.
|
|
6
|
-
*/
|
|
7
|
-
export interface FieldSnapshot {
|
|
8
|
-
__type: string;
|
|
9
|
-
name: string;
|
|
10
|
-
value: any;
|
|
11
|
-
policies?: object[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Orchestrates the serialization and deserialization of Field instances.
|
|
15
|
-
*
|
|
16
|
-
* This class acts as a central point for converting complex Field objects into
|
|
17
|
-
* plain, storable data (snapshots) and vice-versa. It uses a `FieldRegistry`
|
|
18
|
-
* to resolve class constructors and a `PolicySerializer` to handle the state
|
|
19
|
-
* of any attached policies.
|
|
20
|
-
*
|
|
21
|
-
* @todo Implement a `patch(field, snapshot)` method.
|
|
22
|
-
* Unlike `hydrate`, which creates a new
|
|
23
|
-
* instance, `patch` should update the state of an *existing* field instance
|
|
24
|
-
* without breaking external references to it.
|
|
25
|
-
*/
|
|
26
|
-
export declare class FieldSerializer {
|
|
27
|
-
private readonly fieldRegistry;
|
|
28
|
-
private readonly policySerializer;
|
|
29
|
-
/**
|
|
30
|
-
* Creates an instance of FieldSerializer.
|
|
31
|
-
* @param {FieldRegistry} fieldRegistry - A registry that maps string type names to Field constructors.
|
|
32
|
-
* @param {PolicySerializer} policySerializer - A serializer dedicated to handling Policy instances.
|
|
33
|
-
*/
|
|
34
|
-
constructor(fieldRegistry: FieldRegistry, policySerializer: PolicySerializer);
|
|
35
|
-
/**
|
|
36
|
-
* Creates a serializable snapshot of a Field instance.
|
|
37
|
-
* The snapshot includes the field's type, name, current value, and the state of all its policies.
|
|
38
|
-
* @param {Field<any>} field - The Field instance to serialize.
|
|
39
|
-
* @returns {FieldSnapshot} A plain object ready for JSON serialization.
|
|
40
|
-
*/
|
|
41
|
-
snapshot(field: Field<any>): FieldSnapshot;
|
|
42
|
-
/**
|
|
43
|
-
* Restores a Field instance from its snapshot representation.
|
|
44
|
-
* It uses the `__type` property to find the correct constructor and hydrates
|
|
45
|
-
* the field with its value and all its policies.
|
|
46
|
-
* @param {FieldSnapshot} snapshot - The plain object snapshot to deserialize.
|
|
47
|
-
* @returns {Field<any>} A new, fully functional Field instance.
|
|
48
|
-
* @throws If the snapshot is invalid, missing a `__type`, or if the type is not registered.
|
|
49
|
-
*/
|
|
50
|
-
hydrate(snapshot: FieldSnapshot): Field<any>;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=field-serializer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-serializer.d.ts","sourceRoot":"","sources":["../../src/serializer/field-serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAC,KAAK,EAAC,MAAM,UAAU,CAAC;AAI/B;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,eAAe;IAQxB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAPnC;;;;OAIG;gBAEgB,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,gBAAgB;IAIrD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,aAAa;IAgB1C;;;;;;;OAOG;IACH,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,KAAK,CAAC,GAAG,CAAC;CAa7C"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { isNullOrUndefined, throwIfEmpty } from '@axi-engine/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Orchestrates the serialization and deserialization of Field instances.
|
|
4
|
-
*
|
|
5
|
-
* This class acts as a central point for converting complex Field objects into
|
|
6
|
-
* plain, storable data (snapshots) and vice-versa. It uses a `FieldRegistry`
|
|
7
|
-
* to resolve class constructors and a `PolicySerializer` to handle the state
|
|
8
|
-
* of any attached policies.
|
|
9
|
-
*
|
|
10
|
-
* @todo Implement a `patch(field, snapshot)` method.
|
|
11
|
-
* Unlike `hydrate`, which creates a new
|
|
12
|
-
* instance, `patch` should update the state of an *existing* field instance
|
|
13
|
-
* without breaking external references to it.
|
|
14
|
-
*/
|
|
15
|
-
export class FieldSerializer {
|
|
16
|
-
fieldRegistry;
|
|
17
|
-
policySerializer;
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of FieldSerializer.
|
|
20
|
-
* @param {FieldRegistry} fieldRegistry - A registry that maps string type names to Field constructors.
|
|
21
|
-
* @param {PolicySerializer} policySerializer - A serializer dedicated to handling Policy instances.
|
|
22
|
-
*/
|
|
23
|
-
constructor(fieldRegistry, policySerializer) {
|
|
24
|
-
this.fieldRegistry = fieldRegistry;
|
|
25
|
-
this.policySerializer = policySerializer;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates a serializable snapshot of a Field instance.
|
|
29
|
-
* The snapshot includes the field's type, name, current value, and the state of all its policies.
|
|
30
|
-
* @param {Field<any>} field - The Field instance to serialize.
|
|
31
|
-
* @returns {FieldSnapshot} A plain object ready for JSON serialization.
|
|
32
|
-
*/
|
|
33
|
-
snapshot(field) {
|
|
34
|
-
let snapshot = {
|
|
35
|
-
__type: field.typeName,
|
|
36
|
-
name: field.name,
|
|
37
|
-
value: field.value,
|
|
38
|
-
};
|
|
39
|
-
if (!field.policies.isEmpty()) {
|
|
40
|
-
const serializedPolicies = [];
|
|
41
|
-
field.policies.items.forEach(policy => serializedPolicies.push(this.policySerializer.snapshot(policy)));
|
|
42
|
-
snapshot.policies = serializedPolicies;
|
|
43
|
-
}
|
|
44
|
-
return snapshot;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Restores a Field instance from its snapshot representation.
|
|
48
|
-
* It uses the `__type` property to find the correct constructor and hydrates
|
|
49
|
-
* the field with its value and all its policies.
|
|
50
|
-
* @param {FieldSnapshot} snapshot - The plain object snapshot to deserialize.
|
|
51
|
-
* @returns {Field<any>} A new, fully functional Field instance.
|
|
52
|
-
* @throws If the snapshot is invalid, missing a `__type`, or if the type is not registered.
|
|
53
|
-
*/
|
|
54
|
-
hydrate(snapshot) {
|
|
55
|
-
const fieldType = snapshot.__type;
|
|
56
|
-
throwIfEmpty(fieldType, 'Invalid field snapshot: missing "__type" identifier.');
|
|
57
|
-
const Ctor = this.fieldRegistry.get(fieldType);
|
|
58
|
-
let policies;
|
|
59
|
-
if (!isNullOrUndefined(snapshot.policies)) {
|
|
60
|
-
policies = [];
|
|
61
|
-
snapshot.policies.forEach((p) => policies.push(this.policySerializer.hydrate(p)));
|
|
62
|
-
}
|
|
63
|
-
return new Ctor(snapshot.name, snapshot.value, { policies });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=field-serializer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-serializer.js","sourceRoot":"","sources":["../../src/serializer/field-serializer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAE,YAAY,EAAC,MAAM,mBAAmB,CAAC;AAgBlE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,eAAe;IAQP;IACA;IAPnB;;;;OAIG;IACH,YACmB,aAA4B,EAC5B,gBAAkC;QADlC,kBAAa,GAAb,aAAa,CAAe;QAC5B,qBAAgB,GAAhB,gBAAgB,CAAkB;IAErD,CAAC;IAED;;;;;OAKG;IACH,QAAQ,CAAC,KAAiB;QACxB,IAAI,QAAQ,GAAQ;YAClB,MAAM,EAAE,KAAK,CAAC,QAAQ;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAA;QAED,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;YAC9B,MAAM,kBAAkB,GAAa,EAAE,CAAC;YACxC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YACxG,QAAQ,CAAC,QAAQ,GAAG,kBAAkB,CAAC;QACzC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,OAAO,CAAC,QAAuB;QAC7B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC;QAClC,YAAY,CAAC,SAAS,EAAE,sDAAsD,CAAC,CAAC;QAChF,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAE/C,IAAI,QAAmC,CAAC;QACxC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC1C,QAAQ,GAAG,EAAE,CAAC;YACd,QAAQ,CAAC,QAAS,CAAC,OAAO,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,QAAS,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3F,CAAC;QAED,OAAO,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,EAAE,EAAC,QAAQ,EAAC,CAAe,CAAC;IAC3E,CAAC;CACF"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { FieldsSerializer, FieldsSnapshot } from './fields-serializer';
|
|
2
|
-
import { Fields } from '../fields';
|
|
3
|
-
import { FieldTreeFactory } from '../field-tree-factory';
|
|
4
|
-
import { FieldTree } from '../field-tree';
|
|
5
|
-
/**
|
|
6
|
-
* Represents the serializable state of a `FieldTree` container.
|
|
7
|
-
*
|
|
8
|
-
* This type describes a plain object that has:
|
|
9
|
-
* 1. A required `__type` property to identify the tree's class.
|
|
10
|
-
* 2. An arbitrary number of other properties, where each key is the `name`
|
|
11
|
-
* of a child node, and the value is the snapshot of that child node.
|
|
12
|
-
* The `| string` is included to ensure compatibility with the `__type` property.
|
|
13
|
-
*/
|
|
14
|
-
export interface FieldTreeSnapshot {
|
|
15
|
-
__type: string;
|
|
16
|
-
[fieldName: string]: FieldsSnapshot | FieldTreeSnapshot | string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Orchestrates the recursive serialization and deserialization of `FieldTree` instances.
|
|
20
|
-
*
|
|
21
|
-
* This class handles the conversion of an entire `FieldTree` object graph into a
|
|
22
|
-
* plain, storable snapshot and vice-versa. It delegates the processing of `Fields`
|
|
23
|
-
* leaf nodes to a dedicated `FieldsSerializer`.
|
|
24
|
-
* @todo Refactoring: The current implementation uses `if/else` logic in `snapshot` and `hydrate`
|
|
25
|
-
* to process different node types. A more extensible approach would be to use a
|
|
26
|
-
* registry of dedicated handlers for each node type.
|
|
27
|
-
* This would allow new node types to be supported without
|
|
28
|
-
* modifying this class, adhering to the Open/Closed Principle.
|
|
29
|
-
*
|
|
30
|
-
* @todo Implement a `patch(tree, snapshot)` method for recursive, non-destructive
|
|
31
|
-
* updates. This method should traverse the existing tree and the snapshot,
|
|
32
|
-
* patching nodes in place to maintain object references.
|
|
33
|
-
*/
|
|
34
|
-
export declare class FieldTreeSerializer<TFields extends Fields> {
|
|
35
|
-
private readonly fieldTreeNodeFactory;
|
|
36
|
-
private readonly fieldsSerializer;
|
|
37
|
-
constructor(fieldTreeNodeFactory: FieldTreeFactory<TFields>, fieldsSerializer: FieldsSerializer<TFields>);
|
|
38
|
-
/**
|
|
39
|
-
* Creates a serializable snapshot of the entire tree and its contained fields.
|
|
40
|
-
* @returns A plain JavaScript object representing the complete state managed by this tree.
|
|
41
|
-
*/
|
|
42
|
-
snapshot(tree: FieldTree<TFields>): FieldTreeSnapshot;
|
|
43
|
-
/**
|
|
44
|
-
* Restores the state of the tree from a snapshot.
|
|
45
|
-
* It intelligently creates missing nodes based on `__type` metadata and delegates hydration to child nodes.
|
|
46
|
-
* @param snapshot The snapshot object to load.
|
|
47
|
-
*/
|
|
48
|
-
hydrate(snapshot: FieldTreeSnapshot): FieldTree<TFields>;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=field-tree-serializer.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"field-tree-serializer.d.ts","sourceRoot":"","sources":["../../src/serializer/field-tree-serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAE,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAAC,MAAM,EAAC,MAAM,WAAW,CAAC;AACjC,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,SAAS,EAAW,MAAM,eAAe,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,iBAAiB,GAAG,MAAM,CAAC;CAClE;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,mBAAmB,CAAC,OAAO,SAAS,MAAM;IAGnD,OAAO,CAAC,QAAQ,CAAC,oBAAoB;IACrC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBADhB,oBAAoB,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAC/C,gBAAgB,EAAE,gBAAgB,CAAC,OAAO,CAAC;IAI9D;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,iBAAiB;IAerD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC,OAAO,CAAC;CAkBzD"}
|