@cratis/fundamentals 4.3.0 → 5.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.
- package/DerivedType.ts +14 -0
- package/Field.ts +12 -0
- package/Fields.ts +32 -0
- package/JsonSerializer.ts +110 -0
- package/README.md +63 -6
- package/d.yarnist/cjs/Constructor.d.ts +2 -0
- package/d.yarnist/cjs/DerivedType.d.ts +6 -0
- package/d.yarnist/cjs/Field.d.ts +9 -0
- package/d.yarnist/cjs/Fields.d.ts +8 -0
- package/d.yarnist/cjs/JsonSerializer.d.ts +9 -0
- package/d.yarnist/cjs/PropertyAccessor.d.ts +2 -0
- package/d.yarnist/cjs/derivedTypeDecorator.d.ts +3 -0
- package/d.yarnist/cjs/fieldDecorator.d.ts +3 -0
- package/d.yarnist/cjs/index.d.ts +13 -0
- package/d.yarnist/cjs/index.js +24 -0
- package/derivedTypeDecorator.ts +11 -0
- package/dist/esm/Constructor.d.ts +2 -0
- package/dist/esm/Constructor.d.ts.map +1 -0
- package/dist/esm/DerivedType.d.ts +6 -0
- package/dist/esm/DerivedType.d.ts.map +1 -0
- package/dist/esm/DerivedType.js +11 -0
- package/dist/esm/DerivedType.js.map +1 -0
- package/dist/esm/Field.d.ts +9 -0
- package/dist/esm/Field.d.ts.map +1 -0
- package/dist/esm/Field.js +11 -0
- package/dist/esm/Field.js.map +1 -0
- package/dist/esm/Fields.d.ts +8 -0
- package/dist/esm/Fields.d.ts.map +1 -0
- package/dist/esm/Fields.js +26 -0
- package/dist/esm/Fields.js.map +1 -0
- package/dist/esm/Guid.d.ts +13 -0
- package/dist/esm/Guid.d.ts.map +1 -0
- package/dist/{Guid.js → esm/Guid.js} +3 -5
- package/dist/esm/Guid.js.map +1 -0
- package/dist/esm/IEquatable.d.ts +4 -0
- package/dist/esm/IEquatable.d.ts.map +1 -0
- package/dist/esm/JsonSerializer.d.ts +9 -0
- package/dist/esm/JsonSerializer.d.ts.map +1 -0
- package/dist/esm/JsonSerializer.js +68 -0
- package/dist/esm/JsonSerializer.js.map +1 -0
- package/dist/esm/PropertyAccessor.d.ts +2 -0
- package/dist/esm/PropertyAccessor.d.ts.map +1 -0
- package/dist/esm/PropertyAccessorDescriptor.d.ts +10 -0
- package/dist/esm/PropertyAccessorDescriptor.d.ts.map +1 -0
- package/dist/{PropertyAccessorDescriptor.js → esm/PropertyAccessorDescriptor.js} +3 -5
- package/dist/esm/PropertyAccessorDescriptor.js.map +1 -0
- package/dist/esm/PropertyPathResolverProxyHandler.d.ts +12 -0
- package/dist/esm/PropertyPathResolverProxyHandler.d.ts.map +1 -0
- package/dist/{PropertyPathResolverProxyHandler.js → esm/PropertyPathResolverProxyHandler.js} +3 -5
- package/dist/esm/PropertyPathResolverProxyHandler.js.map +1 -0
- package/dist/esm/derivedTypeDecorator.d.ts +3 -0
- package/dist/esm/derivedTypeDecorator.d.ts.map +1 -0
- package/dist/esm/derivedTypeDecorator.js +11 -0
- package/dist/esm/derivedTypeDecorator.js.map +1 -0
- package/dist/esm/fieldDecorator.d.ts +3 -0
- package/dist/esm/fieldDecorator.d.ts.map +1 -0
- package/dist/esm/fieldDecorator.js +10 -0
- package/dist/esm/fieldDecorator.js.map +1 -0
- package/dist/esm/index.d.ts +13 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/fieldDecorator.ts +11 -0
- package/for_Fields/when_adding_fiields_to_type.ts +42 -0
- package/for_JsonSerializer/when_deserializing_complex_nested_object_with_multiple_wellknown_types.ts +116 -0
- package/for_JsonSerializer/when_deserializing_json_array.ts +44 -0
- package/for_JsonSerializer/when_deserializing_object_with_any_object_on_it.ts +30 -0
- package/index.ts +6 -0
- package/package.json +25 -15
- package/dist/Constructor.d.ts +0 -2
- package/dist/Constructor.d.ts.map +0 -1
- package/dist/Constructor.js +0 -3
- package/dist/Constructor.js.map +0 -1
- package/dist/Guid.d.ts.map +0 -1
- package/dist/Guid.js.map +0 -1
- package/dist/IEquatable.d.ts.map +0 -1
- package/dist/IEquatable.js +0 -3
- package/dist/IEquatable.js.map +0 -1
- package/dist/PropertyAccessor.d.ts +0 -2
- package/dist/PropertyAccessor.d.ts.map +0 -1
- package/dist/PropertyAccessor.js +0 -3
- package/dist/PropertyAccessor.js.map +0 -1
- package/dist/PropertyAccessorDescriptor.d.ts.map +0 -1
- package/dist/PropertyAccessorDescriptor.js.map +0 -1
- package/dist/PropertyPathResolverProxyHandler.d.ts.map +0 -1
- package/dist/PropertyPathResolverProxyHandler.js.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_a_guid_and_a_number.d.ts +0 -2
- package/dist/for_Guid/when_checking_equality/of_a_guid_and_a_number.d.ts.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_a_guid_and_a_number.js +0 -9
- package/dist/for_Guid/when_checking_equality/of_a_guid_and_a_number.js.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_different_guids.d.ts +0 -2
- package/dist/for_Guid/when_checking_equality/of_two_different_guids.d.ts.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_different_guids.js +0 -9
- package/dist/for_Guid/when_checking_equality/of_two_different_guids.js.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_different_guids_when_one_is_a_string.d.ts +0 -2
- package/dist/for_Guid/when_checking_equality/of_two_different_guids_when_one_is_a_string.d.ts.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_different_guids_when_one_is_a_string.js +0 -9
- package/dist/for_Guid/when_checking_equality/of_two_different_guids_when_one_is_a_string.js.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids.d.ts +0 -2
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids.d.ts.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids.js +0 -9
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids.js.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids_when_one_is_a_string.d.ts +0 -2
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids_when_one_is_a_string.d.ts.map +0 -1
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids_when_one_is_a_string.js +0 -9
- package/dist/for_Guid/when_checking_equality/of_two_equal_guids_when_one_is_a_string.js.map +0 -1
- package/dist/for_Guid/when_constructing_using_uint8array.d.ts +0 -2
- package/dist/for_Guid/when_constructing_using_uint8array.d.ts.map +0 -1
- package/dist/for_Guid/when_constructing_using_uint8array.js +0 -10
- package/dist/for_Guid/when_constructing_using_uint8array.js.map +0 -1
- package/dist/for_Guid/when_converting_to_string.d.ts +0 -2
- package/dist/for_Guid/when_converting_to_string.d.ts.map +0 -1
- package/dist/for_Guid/when_converting_to_string.js +0 -11
- package/dist/for_Guid/when_converting_to_string.js.map +0 -1
- package/dist/for_Guid/when_creating.d.ts +0 -2
- package/dist/for_Guid/when_creating.d.ts.map +0 -1
- package/dist/for_Guid/when_creating.js +0 -8
- package/dist/for_Guid/when_creating.js.map +0 -1
- package/dist/for_Guid/when_getting_as/and_input_is_specific_type.d.ts +0 -2
- package/dist/for_Guid/when_getting_as/and_input_is_specific_type.d.ts.map +0 -1
- package/dist/for_Guid/when_getting_as/and_input_is_specific_type.js +0 -12
- package/dist/for_Guid/when_getting_as/and_input_is_specific_type.js.map +0 -1
- package/dist/for_Guid/when_getting_as/and_input_is_string.d.ts +0 -2
- package/dist/for_Guid/when_getting_as/and_input_is_string.d.ts.map +0 -1
- package/dist/for_Guid/when_getting_as/and_input_is_string.js +0 -11
- package/dist/for_Guid/when_getting_as/and_input_is_string.js.map +0 -1
- package/dist/for_Guid/when_getting_empty.d.ts +0 -2
- package/dist/for_Guid/when_getting_empty.d.ts.map +0 -1
- package/dist/for_Guid/when_getting_empty.js +0 -11
- package/dist/for_Guid/when_getting_empty.js.map +0 -1
- package/dist/for_Guid/when_parsing.d.ts +0 -2
- package/dist/for_Guid/when_parsing.d.ts.map +0 -1
- package/dist/for_Guid/when_parsing.js +0 -10
- package/dist/for_Guid/when_parsing.js.map +0 -1
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_on_object.d.ts +0 -2
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_on_object.d.ts.map +0 -1
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_on_object.js +0 -19
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_on_object.js.map +0 -1
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_three_levels_down.d.ts +0 -2
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_three_levels_down.d.ts.map +0 -1
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_three_levels_down.js +0 -31
- package/dist/for_PropertyPathResolverProxyHandler/when_accessing_property_three_levels_down.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -10
- package/dist/index.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/{dist → d.yarnist/cjs}/Guid.d.ts +0 -0
- /package/{dist → d.yarnist/cjs}/IEquatable.d.ts +0 -0
- /package/{dist → d.yarnist/cjs}/PropertyAccessorDescriptor.d.ts +0 -0
- /package/{dist → d.yarnist/cjs}/PropertyPathResolverProxyHandler.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSerializer.js","sources":["../../JsonSerializer.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from './Constructor';\nimport { Field } from './Field';\nimport { Fields } from './Fields';\nimport { DerivedType } from './DerivedType';\n\ntype typeSerializer = (value: any) => any;\n\nconst typeSerializers: Map<Constructor, typeSerializer> = new Map<Constructor, typeSerializer>([\n [Number, (value: any) => value],\n [String, (value: any) => value],\n [Boolean, (value: any) => value],\n [Date, (value: any) => new Date(value)]\n]);\n\nconst deserializeValue = (field: Field, value: any) => {\n if (typeSerializers.has(field.type)) {\n return typeSerializers.get(field.type)!(value);\n } else {\n let type = field.type;\n if (field.derivatives.length > 0 && value[JsonSerializer.DerivedTypeIdProperty]) {\n const derivedTypeId = value[JsonSerializer.DerivedTypeIdProperty];\n type = field.derivatives.find(_ => DerivedType.get(_) == derivedTypeId) || type;\n }\n\n return JsonSerializer.deserialize(type, JSON.stringify(value));\n }\n};\n\n/**\n * Represents a serializer for JSON.\n */\nexport class JsonSerializer {\n static readonly DerivedTypeIdProperty: string = \"_derivedTypeId\";\n\n /**\n * Deserialize a JSON string to the specific type.\n * @param {Constructor} targetType Type to deserialize to.\n * @param {string} json Actual JSON to deserialize.\n * @returns An instance of the target type.\n */\n static deserialize<TResult extends {}>(targetType: Constructor<TResult>, json: string): TResult {\n const parsed = JSON.parse(json);\n return this.deserializeFromInstance<TResult>(targetType, parsed);\n }\n\n /**\n * Deserialize a array JSON string to an array of the specific instance type.\n * @param {Constructor} targetType Type to deserialize to.\n * @param {string} json Actual JSON to deserialize.\n * @returns An array of instances of the target type.\n */\n static deserializeArray<TResult extends {}>(targetType: Constructor<TResult>, json: string): TResult[] {\n const parsed = JSON.parse(json);\n return this.deserializeArrayFromInstance(targetType, parsed);\n }\n\n /**\n * Deserialize an any instance to a specific instance type.\n * @param {Constructor} targetType Type to deserialize to.\n * @param {*} instance Actual instance to deserialize.\n * @returns An instance of the target type.\n */\n static deserializeFromInstance<TResult extends {}>(targetType: Constructor<TResult>, instance: any): TResult {\n const fields = Fields.getFieldsForType(targetType as Constructor);\n const deserialized = new targetType();\n for (const field of fields) {\n let value = instance[field.name];\n if (value) {\n if (field.enumerable) {\n value = value.map(_ => deserializeValue(field, _));\n } else {\n value = deserializeValue(field, value);\n }\n }\n\n deserialized[field.name] = value;\n }\n\n if ((targetType as Constructor) == Object) {\n const objectFields = Object.keys(instance).filter((value, index, arr) => {\n return !fields.some(_ => _.name == value);\n });\n\n for (const field of objectFields) {\n deserialized[field] = instance[field];\n }\n }\n\n return deserialized;\n }\n\n /**\n * Deserialize an array of any instances to an array of specific instance types.\n * @param {Constructor} targetType Type to deserialize to.\n * @param {instances} instances Actual instances to deserialize.\n * @returns An array of instances of the target type.\n */\n static deserializeArrayFromInstance<TResult extends {}>(targetType: Constructor<TResult>, instances: any): TResult[] {\n const deserialized: TResult[] = [];\n\n for (const instance of instances) {\n deserialized.push(this.deserializeFromInstance<TResult>(targetType, instance));\n }\n\n return deserialized;\n }\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,eAAe,GAAqC,IAAI,GAAG,CAA8B;IAC3F,CAAC,MAAM,EAAE,CAAC,KAAU,KAAK,KAAK,CAAC;IAC/B,CAAC,MAAM,EAAE,CAAC,KAAU,KAAK,KAAK,CAAC;IAC/B,CAAC,OAAO,EAAE,CAAC,KAAU,KAAK,KAAK,CAAC;AAChC,IAAA,CAAC,IAAI,EAAE,CAAC,KAAU,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAA,CAAC,CAAC;AAEH,MAAM,gBAAgB,GAAG,CAAC,KAAY,EAAE,KAAU,KAAI;IAClD,IAAI,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;QACjC,OAAO,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC,KAAK,CAAC,CAAC;AAClD,KAAA;AAAM,SAAA;AACH,QAAA,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;AACtB,QAAA,IAAI,KAAK,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,EAAE;YAC7E,MAAM,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;YAClE,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,IAAI,IAAI,CAAC;AACnF,SAAA;AAED,QAAA,OAAO,cAAc,C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;AACvC,YAAA,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,KAAI;AACpE,gBAAA,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC;AAC9C,aAAC,CAAC,CAAC;AAEH,YAAA,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;gBAC9B,YAAY,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AACzC,aAAA;AACJ,SAAA;AAED,QAAA,OAAO,YAAY,CAAC;KACvB;AAQD,IAAA,OAAO,4BAA4B,CAAqB,UAAgC,EAAE,SAAc,EAAA;QACpG,MAAM,YAAY,GAAc,EAAE,CAAC;AAEnC,QAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;AAC9B,YAAA,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAU,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;AAClF,SAAA;AAED,QAAA,OAAO,YAAY,CAAC;KACvB;;AAzEe,cAAqB,CAAA,qBAAA,GAAW,gBAAgB;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyAccessor.d.ts","sourceRoot":"","sources":["../../PropertyAccessor.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,gBAAgB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,GAAG,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PropertyAccessor } from './PropertyAccessor';
|
|
2
|
+
export declare class PropertyAccessorDescriptor {
|
|
3
|
+
private readonly _accessor;
|
|
4
|
+
private readonly _segments;
|
|
5
|
+
constructor(_accessor: PropertyAccessor, _segments: string[]);
|
|
6
|
+
get accessor(): PropertyAccessor;
|
|
7
|
+
get segments(): readonly string[];
|
|
8
|
+
get path(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=PropertyAccessorDescriptor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyAccessorDescriptor.d.ts","sourceRoot":"","sources":["../../PropertyAccessorDescriptor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,qBAAa,0BAA0B;IAOvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAoB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAvD,SAAS,EAAE,gBAAgB,EAAmB,SAAS,EAAE,MAAM,EAAE;IAO9F,IAAI,QAAQ,IAAI,gBAAgB,CAE/B;IAMD,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAMD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACJ"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PropertyAccessorDescriptor = void 0;
|
|
4
1
|
class PropertyAccessorDescriptor {
|
|
5
2
|
constructor(_accessor, _segments) {
|
|
6
3
|
this._accessor = _accessor;
|
|
@@ -16,5 +13,6 @@ class PropertyAccessorDescriptor {
|
|
|
16
13
|
return this._segments.join('.');
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
|
|
17
|
+
export { PropertyAccessorDescriptor };
|
|
18
|
+
//# sourceMappingURL=PropertyAccessorDescriptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyAccessorDescriptor.js","sources":["../../PropertyAccessorDescriptor.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { PropertyAccessor } from './PropertyAccessor';\n\n/**\n * Represents the descriptor of a specific property accessor\n */\nexport class PropertyAccessorDescriptor {\n\n /**\n * Creates an instance of {PropertyAccessorDescriptor}.\n * @param {PropertyAccessor} _accessor - The actual accessor for accessing the property.\n * @param {Array<string>} _segments - The segments representing the path of the property accessor within an instance.\n */\n constructor(private readonly _accessor: PropertyAccessor, private readonly _segments: string[]) {\n }\n\n /**\n * Gets the actual accessor.\n * @returns {PropertyAccessor}\n */\n get accessor(): PropertyAccessor {\n return this._accessor;\n }\n\n /**\n * Gets the segments that constitute the deep path within the object instance for accessing the underlying property.\n * @returns {ReadonlyArray<string>}\n */\n get segments(): readonly string[] {\n return this._segments;\n }\n\n /**\n * Gets the full path to the property\n * @returns {string}\n */\n get path(): string {\n return this._segments.join('.');\n }\n}\n"],"names":[],"mappings":"MAQa,0BAA0B,CAAA;IAOnC,WAA6B,CAAA,SAA2B,EAAmB,SAAmB,EAAA;QAAjE,IAAS,CAAA,SAAA,GAAT,SAAS,CAAkB;QAAmB,IAAS,CAAA,SAAA,GAAT,SAAS,CAAU;KAC7F;AAMD,IAAA,IAAI,QAAQ,GAAA;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;AAMD,IAAA,IAAI,QAAQ,GAAA;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;AAMD,IAAA,IAAI,IAAI,GAAA;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnC;AACJ;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class PropertyPathResolverProxyHandler implements ProxyHandler<any> {
|
|
2
|
+
private readonly _root?;
|
|
3
|
+
_property: string;
|
|
4
|
+
_segments: string[];
|
|
5
|
+
constructor(_root?: PropertyPathResolverProxyHandler | undefined);
|
|
6
|
+
get property(): string;
|
|
7
|
+
get segments(): readonly string[];
|
|
8
|
+
get path(): string;
|
|
9
|
+
private addSegment;
|
|
10
|
+
get(target: any, p: PropertyKey, receiver: any): any;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=PropertyPathResolverProxyHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyPathResolverProxyHandler.d.ts","sourceRoot":"","sources":["../../PropertyPathResolverProxyHandler.ts"],"names":[],"mappings":"AAOA,qBAAa,gCAAiC,YAAW,YAAY,CAAC,GAAG,CAAC;IAI1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,SAAS,SAAM;IACf,SAAS,EAAE,MAAM,EAAE,CAAM;gBAEI,KAAK,CAAC,8CAAkC;IAGrE,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,UAAU;IAKlB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG;CASvD"}
|
package/dist/{PropertyPathResolverProxyHandler.js → esm/PropertyPathResolverProxyHandler.js}
RENAMED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PropertyPathResolverProxyHandler = void 0;
|
|
4
1
|
class PropertyPathResolverProxyHandler {
|
|
5
2
|
constructor(_root) {
|
|
6
3
|
this._root = _root;
|
|
@@ -27,5 +24,6 @@ class PropertyPathResolverProxyHandler {
|
|
|
27
24
|
return childProperty;
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
|
|
28
|
+
export { PropertyPathResolverProxyHandler };
|
|
29
|
+
//# sourceMappingURL=PropertyPathResolverProxyHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PropertyPathResolverProxyHandler.js","sources":["../../PropertyPathResolverProxyHandler.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\n/**\n * Object proxy handler\n * @template TObject\n */\nexport class PropertyPathResolverProxyHandler implements ProxyHandler<any> {\n _property = '';\n _segments: string[] = [];\n\n constructor(private readonly _root?: PropertyPathResolverProxyHandler) {\n }\n\n get property(): string {\n return this._property;\n }\n\n get segments(): readonly string[] {\n return this._segments;\n }\n\n get path(): string {\n return this._segments.join('.');\n }\n\n private addSegment(segment: string) {\n this._segments.push(segment);\n }\n\n /** @inheritdoc */\n get(target: any, p: PropertyKey, receiver: any): any {\n const root = this._root || this;\n\n const childProperty = new Proxy({}, new PropertyPathResolverProxyHandler(root));\n this._property = p.toString();\n root.addSegment(this._property);\n\n return childProperty;\n }\n}\n"],"names":[],"mappings":"MAOa,gCAAgC,CAAA;AAIzC,IAAA,WAAA,CAA6B,KAAwC,EAAA;QAAxC,IAAK,CAAA,KAAA,GAAL,KAAK,CAAmC;QAHrE,IAAS,CAAA,SAAA,GAAG,EAAE,CAAC;QACf,IAAS,CAAA,SAAA,GAAa,EAAE,CAAC;KAGxB;AAED,IAAA,IAAI,QAAQ,GAAA;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;AAED,IAAA,IAAI,QAAQ,GAAA;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;KACzB;AAED,IAAA,IAAI,IAAI,GAAA;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnC;AAEO,IAAA,UAAU,CAAC,OAAe,EAAA;AAC9B,QAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;KAChC;AAGD,IAAA,GAAG,CAAC,MAAW,EAAE,CAAc,EAAE,QAAa,EAAA;AAC1C,QAAA,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;AAEhC,QAAA,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,IAAI,gCAAgC,CAAC,IAAI,CAAC,CAAC,CAAC;AAChF,QAAA,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9B,QAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAEhC,QAAA,OAAO,aAAa,CAAC;KACxB;AACJ;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivedTypeDecorator.d.ts","sourceRoot":"","sources":["../../derivedTypeDecorator.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAG1B,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,YACjB,GAAG,UAG/B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { DerivedType } from './DerivedType.js';
|
|
3
|
+
|
|
4
|
+
function derivedType(identifier) {
|
|
5
|
+
return function (target) {
|
|
6
|
+
DerivedType.set(target, identifier);
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { derivedType };
|
|
11
|
+
//# sourceMappingURL=derivedTypeDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivedTypeDecorator.js","sources":["../../derivedTypeDecorator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport 'reflect-metadata';\nimport { DerivedType } from './DerivedType';\n\nexport function derivedType(identifier: string) {\n return function (target: any) {\n DerivedType.set(target, identifier);\n };\n}\n"],"names":[],"mappings":";;;AAMM,SAAU,WAAW,CAAC,UAAkB,EAAA;AAC1C,IAAA,OAAO,UAAU,MAAW,EAAA;AACxB,QAAA,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;AACxC,KAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldDecorator.d.ts","sourceRoot":"","sources":["../../fieldDecorator.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,wBAAgB,KAAK,CAAC,UAAU,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,OAAO,EAAE,WAAW,CAAC,EAAE,WAAW,EAAE,YACnE,GAAG,eAAe,MAAM,UAGpD"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Fields } from './Fields.js';
|
|
2
|
+
|
|
3
|
+
function field(targetType, enumerable, derivatives) {
|
|
4
|
+
return function (target, propertyKey) {
|
|
5
|
+
Fields.addFieldToType(target.constructor, propertyKey, targetType, enumerable || false, derivatives || []);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { field };
|
|
10
|
+
//# sourceMappingURL=fieldDecorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldDecorator.js","sources":["../../fieldDecorator.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Constructor } from './Constructor';\nimport { Fields } from './Fields';\n\nexport function field(targetType: Constructor, enumerable?: boolean, derivatives?: Constructor[]) {\n return function (target: any, propertyKey: string) {\n Fields.addFieldToType(target.constructor, propertyKey, targetType, enumerable || false, derivatives || []);\n };\n}\n"],"names":[],"mappings":";;SAMgB,KAAK,CAAC,UAAuB,EAAE,UAAoB,EAAE,WAA2B,EAAA;IAC5F,OAAO,UAAU,MAAW,EAAE,WAAmB,EAAA;AAC7C,QAAA,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,IAAI,KAAK,EAAE,WAAW,IAAI,EAAE,CAAC,CAAC;AAC/G,KAAC,CAAC;AACN;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './Constructor';
|
|
2
|
+
export * from './Field';
|
|
3
|
+
export * from './Fields';
|
|
4
|
+
export * from './Guid';
|
|
5
|
+
export * from './IEquatable';
|
|
6
|
+
export * from './PropertyAccessor';
|
|
7
|
+
export * from './PropertyAccessorDescriptor';
|
|
8
|
+
export * from './PropertyPathResolverProxyHandler';
|
|
9
|
+
export * from './fieldDecorator';
|
|
10
|
+
export * from './derivedTypeDecorator';
|
|
11
|
+
export * from './JsonSerializer';
|
|
12
|
+
export * from './DerivedType';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAGA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC;AACnD,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { Field } from './Field.js';
|
|
2
|
+
export { Fields } from './Fields.js';
|
|
3
|
+
export { Guid } from './Guid.js';
|
|
4
|
+
export { PropertyAccessorDescriptor } from './PropertyAccessorDescriptor.js';
|
|
5
|
+
export { PropertyPathResolverProxyHandler } from './PropertyPathResolverProxyHandler.js';
|
|
6
|
+
export { field } from './fieldDecorator.js';
|
|
7
|
+
export { derivedType } from './derivedTypeDecorator.js';
|
|
8
|
+
export { JsonSerializer } from './JsonSerializer.js';
|
|
9
|
+
export { DerivedType } from './DerivedType.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Constructor } from './Constructor';
|
|
5
|
+
import { Fields } from './Fields';
|
|
6
|
+
|
|
7
|
+
export function field(targetType: Constructor, enumerable?: boolean, derivatives?: Constructor[]) {
|
|
8
|
+
return function (target: any, propertyKey: string) {
|
|
9
|
+
Fields.addFieldToType(target.constructor, propertyKey, targetType, enumerable || false, derivatives || []);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { Fields } from '../Fields';
|
|
5
|
+
|
|
6
|
+
class MyType {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
class MyOtherType {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
class MyThirdType {
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
describe('when adding fields to type', () => {
|
|
16
|
+
const firstField = "firstField";
|
|
17
|
+
const secondField = "secondField";
|
|
18
|
+
const thirdField = "thirdField";
|
|
19
|
+
|
|
20
|
+
const firstFieldType = String;
|
|
21
|
+
const secondFieldType = Number;
|
|
22
|
+
const thirdFieldType = MyOtherType;
|
|
23
|
+
|
|
24
|
+
Fields.addFieldToType(MyType, firstField, firstFieldType, false, []);
|
|
25
|
+
Fields.addFieldToType(MyType, secondField, secondFieldType, false, [MyOtherType, MyThirdType]);
|
|
26
|
+
Fields.addFieldToType(MyType, thirdField, thirdFieldType, true, []);
|
|
27
|
+
|
|
28
|
+
const fields = Fields.getFieldsForType(MyType);
|
|
29
|
+
|
|
30
|
+
it('should hold first field', () => fields[0].name.should.equal(firstField));
|
|
31
|
+
it('should have correct type for first field', () => fields[0].type.should.equal(firstFieldType));
|
|
32
|
+
it('should not consider first field as enumerable', () => fields[0].enumerable.should.be.false);
|
|
33
|
+
it('should not have any derivatives for first field', () => fields[0].derivatives.should.be.empty);
|
|
34
|
+
it('should hold second field', () => fields[1].name.should.equal(secondField));
|
|
35
|
+
it('should have correct type for second field', () => fields[1].type.should.equal(secondFieldType));
|
|
36
|
+
it('should not consider second field as enumerable', () => fields[1].enumerable.should.be.false);
|
|
37
|
+
it('should have 2 derivatives for second field', () => fields[1].derivatives.length.should.equal(2));
|
|
38
|
+
it('should hold third field', () => fields[2].name.should.equal(thirdField));
|
|
39
|
+
it('should have correct type for third field', () => fields[2].type.should.equal(thirdFieldType));
|
|
40
|
+
it('should consider third field as enumerable', () => fields[2].enumerable.should.be.true);
|
|
41
|
+
it('should not have any derivatives for third field', () => fields[2].derivatives.should.be.empty);
|
|
42
|
+
});
|
package/for_JsonSerializer/when_deserializing_complex_nested_object_with_multiple_wellknown_types.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { field } from '../fieldDecorator';
|
|
5
|
+
import { JsonSerializer } from '../JsonSerializer';
|
|
6
|
+
import { derivedType } from '../derivedTypeDecorator';
|
|
7
|
+
import { Constructor } from '../Constructor';
|
|
8
|
+
|
|
9
|
+
class OtherType {
|
|
10
|
+
@field(Number)
|
|
11
|
+
someNumber!: number;
|
|
12
|
+
|
|
13
|
+
@field(String)
|
|
14
|
+
someString!: string;
|
|
15
|
+
|
|
16
|
+
@field(Date)
|
|
17
|
+
someDate!: Date;
|
|
18
|
+
|
|
19
|
+
@field(Date)
|
|
20
|
+
collectionOfDates!: Date[];
|
|
21
|
+
|
|
22
|
+
@field(Number)
|
|
23
|
+
collectionOfNumbers!: number[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
27
|
+
interface ITargetType { }
|
|
28
|
+
|
|
29
|
+
@derivedType('ad7593d1-71be-4e26-9026-aedb32fc43d3')
|
|
30
|
+
class FirstDerivative implements ITargetType {
|
|
31
|
+
@field(Number)
|
|
32
|
+
firstDerivativeProperty!: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@derivedType('a038ca48-360e-46a7-8cb2-882ff21bb623')
|
|
36
|
+
class SecondDerivative implements ITargetType {
|
|
37
|
+
@field(Number)
|
|
38
|
+
secondDerivativeProperty!: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
class TopLevel {
|
|
42
|
+
@field(Number)
|
|
43
|
+
someNumber!: number;
|
|
44
|
+
|
|
45
|
+
@field(String)
|
|
46
|
+
someString!: string;
|
|
47
|
+
|
|
48
|
+
@field(Date)
|
|
49
|
+
someDate!: Date;
|
|
50
|
+
|
|
51
|
+
@field(Boolean)
|
|
52
|
+
someBoolean!: boolean;
|
|
53
|
+
|
|
54
|
+
@field(OtherType)
|
|
55
|
+
otherType!: OtherType;
|
|
56
|
+
|
|
57
|
+
@field(OtherType, true)
|
|
58
|
+
collectionOfOtherType!: OtherType[];
|
|
59
|
+
|
|
60
|
+
@field(Object, true, [FirstDerivative, SecondDerivative])
|
|
61
|
+
collectionOfDerivedTypes!: ITargetType[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const json = '{' +
|
|
65
|
+
' "someNumber": 42,' +
|
|
66
|
+
' "someString": "forty two",' +
|
|
67
|
+
' "someDate": "2022-10-07 15:51",' +
|
|
68
|
+
' "someBoolean": true,' +
|
|
69
|
+
' "otherType": {' +
|
|
70
|
+
' "someNumber": 43,' +
|
|
71
|
+
' "someString": "forty three",' +
|
|
72
|
+
' "someDate": "2022-11-07 15:51"' +
|
|
73
|
+
' },' +
|
|
74
|
+
' "collectionOfOtherType": [' +
|
|
75
|
+
' {' +
|
|
76
|
+
' "someNumber": 44,' +
|
|
77
|
+
' "someString": "forty four",' +
|
|
78
|
+
' "someDate": "2022-12-07 15:51"' +
|
|
79
|
+
' },' +
|
|
80
|
+
' {' +
|
|
81
|
+
' "someNumber": 45,' +
|
|
82
|
+
' "someString": "forty five",' +
|
|
83
|
+
' "someDate": "2022-13-07 15:51"' +
|
|
84
|
+
' }' +
|
|
85
|
+
' ],' +
|
|
86
|
+
' "collectionOfDerivedTypes": [' +
|
|
87
|
+
' {"firstDerivativeProperty" : 46, "_derivedTypeId": "ad7593d1-71be-4e26-9026-aedb32fc43d3" },' +
|
|
88
|
+
' {"secondDerivativeProperty" : 47, "_derivedTypeId": "a038ca48-360e-46a7-8cb2-882ff21bb623" }' +
|
|
89
|
+
' ]' +
|
|
90
|
+
'}';
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
describe('when deserializing complex nested object with multiple wellknown types', () => {
|
|
95
|
+
const result = JsonSerializer.deserialize(TopLevel, json);
|
|
96
|
+
|
|
97
|
+
it('should hold correct number for first level number', () => result.someNumber.should.equal(42));
|
|
98
|
+
it('should hold correct string for first level string', () => result.someString.should.equal('forty two'));
|
|
99
|
+
it('should hold correct bool fvalue for first level boolean', () => result.someBoolean.should.be.true);
|
|
100
|
+
it('should hold correct type for first level date', () => result.someDate.constructor.should.equal(Date));
|
|
101
|
+
it('should hold correct value for first level date', () => result.someDate.toString().should.equal(new Date('2022-10-07 15:51').toString()));
|
|
102
|
+
|
|
103
|
+
it('should hold correct number for second level number', () => result.otherType.someNumber.should.equal(43));
|
|
104
|
+
it('should hold correct string for second level string', () => result.otherType.someString.should.equal('forty three'));
|
|
105
|
+
it('should hold correct type for second level date', () => result.otherType.someDate.constructor.should.equal(Date));
|
|
106
|
+
it('should hold correct value for second level date', () => result.otherType.someDate.toString().should.equal(new Date('2022-11-07 15:51').toString()));
|
|
107
|
+
|
|
108
|
+
it('should have 2 items in the children', () => result.collectionOfOtherType.length.should.equal(2));
|
|
109
|
+
|
|
110
|
+
it('should have 2 items in the derived types collection', () => result.collectionOfDerivedTypes.length.should.equal(2));
|
|
111
|
+
it('should have correct type for first derivative', () => result.collectionOfDerivedTypes[0].constructor.should.equal(FirstDerivative));
|
|
112
|
+
it('should have correct value on first derivative', () => (result.collectionOfDerivedTypes[0] as FirstDerivative).firstDerivativeProperty.should.equal(46));
|
|
113
|
+
|
|
114
|
+
it('should have correct type for second derivative', () => result.collectionOfDerivedTypes[1].constructor.should.equal(SecondDerivative));
|
|
115
|
+
it('should have correct value on second derivative', () => (result.collectionOfDerivedTypes[1] as SecondDerivative).secondDerivativeProperty.should.equal(47));
|
|
116
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { field } from '../fieldDecorator';
|
|
5
|
+
import { JsonSerializer } from '../JsonSerializer';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class TheType {
|
|
9
|
+
@field(Number)
|
|
10
|
+
someNumber!: number;
|
|
11
|
+
|
|
12
|
+
@field(String)
|
|
13
|
+
someString!: string;
|
|
14
|
+
|
|
15
|
+
@field(Date)
|
|
16
|
+
someDate!: Date;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const json = '[{' +
|
|
20
|
+
' "someNumber": 42,' +
|
|
21
|
+
' "someString": "forty two",' +
|
|
22
|
+
' "someDate": "2022-10-07 15:51"' +
|
|
23
|
+
'}, {' +
|
|
24
|
+
' "someNumber": 43,' +
|
|
25
|
+
' "someString": "forty three",' +
|
|
26
|
+
' "someDate": "2022-10-07 14:42"' +
|
|
27
|
+
'}]';
|
|
28
|
+
|
|
29
|
+
describe('when deserializing json array', () => {
|
|
30
|
+
const result = JsonSerializer.deserializeArray(TheType, json);
|
|
31
|
+
|
|
32
|
+
it('should return an array with 2 items', () => result.length.should.equal(2));
|
|
33
|
+
|
|
34
|
+
it('should hold correct number for first instance', () => result[0].someNumber.should.equal(42));
|
|
35
|
+
it('should hold correct string for first instance', () => result[0].someString.should.equal('forty two'));
|
|
36
|
+
it('should hold correct type for first instance', () => result[0].someDate.constructor.should.equal(Date));
|
|
37
|
+
it('should hold correct value for first instance', () => result[0].someDate.toString().should.equal(new Date('2022-10-07 15:51').toString()));
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
it('should hold correct number for first instance', () => result[1].someNumber.should.equal(43));
|
|
41
|
+
it('should hold correct string for first instance', () => result[1].someString.should.equal('forty three'));
|
|
42
|
+
it('should hold correct type for first instance', () => result[1].someDate.constructor.should.equal(Date));
|
|
43
|
+
it('should hold correct value for first instance', () => result[1].someDate.toString().should.equal(new Date('2022-10-07 14:42').toString()));
|
|
44
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
5
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
6
|
+
|
|
7
|
+
import { field } from '../fieldDecorator';
|
|
8
|
+
import { JsonSerializer } from '../JsonSerializer';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class TheType {
|
|
12
|
+
@field(Object)
|
|
13
|
+
anyObject!: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const json = '{' +
|
|
17
|
+
' "anyObject": {' +
|
|
18
|
+
' "someNumber": 42,' +
|
|
19
|
+
' "someString": "forty two",' +
|
|
20
|
+
' "someBoolean": true' +
|
|
21
|
+
' }' +
|
|
22
|
+
'}';
|
|
23
|
+
|
|
24
|
+
describe('when deserializing object with any object on it', () => {
|
|
25
|
+
const result = JsonSerializer.deserialize(TheType, json);
|
|
26
|
+
|
|
27
|
+
it('should hold correct number for first instance', () => result.anyObject.someNumber.should.equal(42));
|
|
28
|
+
it('should hold correct string for first instance', () => result.anyObject.someString.should.equal('forty two'));
|
|
29
|
+
it('should hold correct type for first instance', () => result.anyObject.someBoolean.should.equal(true));
|
|
30
|
+
});
|
package/index.ts
CHANGED
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
4
|
export * from './Constructor';
|
|
5
|
+
export * from './Field';
|
|
6
|
+
export * from './Fields';
|
|
5
7
|
export * from './Guid';
|
|
6
8
|
export * from './IEquatable';
|
|
7
9
|
export * from './PropertyAccessor';
|
|
8
10
|
export * from './PropertyAccessorDescriptor';
|
|
9
11
|
export * from './PropertyPathResolverProxyHandler';
|
|
12
|
+
export * from './fieldDecorator';
|
|
13
|
+
export * from './derivedTypeDecorator';
|
|
14
|
+
export * from './JsonSerializer';
|
|
15
|
+
export * from './DerivedType';
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/fundamentals",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Cratis",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"repository": "github:cratis/fundamentals",
|
|
7
8
|
"publishConfig": {
|
|
8
9
|
"access": "public"
|
|
9
10
|
},
|
|
@@ -11,20 +12,29 @@
|
|
|
11
12
|
"dist",
|
|
12
13
|
"**/*.ts"
|
|
13
14
|
],
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "d.yarnist/cjs/index.js",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"types": "dist/esm/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
"./package.json": "./package.json",
|
|
21
|
+
".": {
|
|
22
|
+
"import": "./dist/esm/index.js",
|
|
23
|
+
"require": "./dist/cjs/index.js",
|
|
24
|
+
"types": "./dist/esm/index.d.ts"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
17
27
|
"scripts": {
|
|
18
|
-
"
|
|
19
|
-
"clean": "
|
|
20
|
-
"build": "
|
|
21
|
-
"lint": "
|
|
22
|
-
"lint:ci": "
|
|
23
|
-
"test": "
|
|
24
|
-
"ci": "yarn
|
|
28
|
+
"prepare": "yarn g:build",
|
|
29
|
+
"clean": "yarn g:clean",
|
|
30
|
+
"build": "yarn g:build",
|
|
31
|
+
"lint": "yarn g:lint",
|
|
32
|
+
"lint:ci": "yarn g:lint:ci",
|
|
33
|
+
"test": "yarn g:test",
|
|
34
|
+
"ci": "yarn g:ci",
|
|
35
|
+
"up": "yarn g:up"
|
|
25
36
|
},
|
|
26
37
|
"dependencies": {
|
|
27
|
-
"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
}
|
|
38
|
+
"reflect-metadata": "0.1.13"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/dist/Constructor.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Constructor.d.ts","sourceRoot":"","sources":["../Constructor.ts"],"names":[],"mappings":"AAGA,oBAAY,WAAW,CAAC,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC"}
|
package/dist/Constructor.js
DELETED
package/dist/Constructor.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Constructor.js","sourceRoot":"","sources":["../Constructor.ts"],"names":[],"mappings":""}
|
package/dist/Guid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Guid.d.ts","sourceRoot":"","sources":["../Guid.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAmB1C,qBAAa,IAAK,YAAW,UAAU;IAcvB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU;IATjD,MAAM,CAAC,QAAQ,CAAC,KAAK,OAA8D;IAEnF,OAAO,CAAC,cAAc,CAAM;gBAOP,KAAK,EAAE,MAAM,EAAE,GAAG,UAAU;IAiBjD,MAA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GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpE,CAAC,CAAC,CAAC;QAEH,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAQD,MAAM,CAAC,EAAE,CAAwB,KAAiB;QAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAM,CAAC;SACjC;QACD,OAAO,KAAU,CAAC;IACtB,CAAC;IAKD,MAAM,CAAC,KAAU;QACb,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,KAAK,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzD,CAAC;IAMD,QAAQ;QACJ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;;AAnGL,oBAoGC;AA/FmB,UAAK,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/IEquatable.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IEquatable.d.ts","sourceRoot":"","sources":["../IEquatable.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,UAAU;IAOvB,MAAM,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAAA;CAC9B"}
|
package/dist/IEquatable.js
DELETED
package/dist/IEquatable.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IEquatable.js","sourceRoot":"","sources":["../IEquatable.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyAccessor.d.ts","sourceRoot":"","sources":["../PropertyAccessor.ts"],"names":[],"mappings":"AAMA,oBAAY,gBAAgB,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,GAAG,CAAC"}
|
package/dist/PropertyAccessor.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyAccessor.js","sourceRoot":"","sources":["../PropertyAccessor.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyAccessorDescriptor.d.ts","sourceRoot":"","sources":["../PropertyAccessorDescriptor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAKtD,qBAAa,0BAA0B;IAOvB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAoB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAAvD,SAAS,EAAE,gBAAgB,EAAmB,SAAS,EAAE,MAAM,EAAE;IAO9F,IAAI,QAAQ,IAAI,gBAAgB,CAE/B;IAMD,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAMD,IAAI,IAAI,IAAI,MAAM,CAEjB;CACJ"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyAccessorDescriptor.js","sourceRoot":"","sources":["../PropertyAccessorDescriptor.ts"],"names":[],"mappings":";;;AAQA,MAAa,0BAA0B;IAOnC,YAA6B,SAA2B,EAAmB,SAAmB;QAAjE,cAAS,GAAT,SAAS,CAAkB;QAAmB,cAAS,GAAT,SAAS,CAAU;IAC9F,CAAC;IAMD,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAMD,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAMD,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACJ;AAjCD,gEAiCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyPathResolverProxyHandler.d.ts","sourceRoot":"","sources":["../PropertyPathResolverProxyHandler.ts"],"names":[],"mappings":"AAOA,qBAAa,gCAAiC,YAAW,YAAY,CAAC,GAAG,CAAC;IAI1D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC;IAHnC,SAAS,SAAM;IACf,SAAS,EAAE,MAAM,EAAE,CAAM;gBAEI,KAAK,CAAC,8CAAkC;IAGrE,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,IAAI,SAAS,MAAM,EAAE,CAEhC;IAED,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,UAAU;IAKlB,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG;CASvD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyPathResolverProxyHandler.js","sourceRoot":"","sources":["../PropertyPathResolverProxyHandler.ts"],"names":[],"mappings":";;;AAOA,MAAa,gCAAgC;IAIzC,YAA6B,KAAwC;QAAxC,UAAK,GAAL,KAAK,CAAmC;QAHrE,cAAS,GAAG,EAAE,CAAC;QACf,cAAS,GAAa,EAAE,CAAC;IAGzB,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IAED,IAAI,IAAI;QACJ,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAEO,UAAU,CAAC,OAAe;QAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAGD,GAAG,CAAC,MAAW,EAAE,CAAc,EAAE,QAAa;QAC1C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC;QAEhC,MAAM,aAAa,GAAG,IAAI,KAAK,CAAC,EAAE,EAAE,IAAI,gCAAgC,CAAC,IAAI,CAAC,CAAC,CAAC;QAChF,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAEhC,OAAO,aAAa,CAAC;IACzB,CAAC;CACJ;AAjCD,4EAiCC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"of_a_guid_and_a_number.d.ts","sourceRoot":"","sources":["../../../for_Guid/when_checking_equality/of_a_guid_and_a_number.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Guid_1 = require("../../Guid");
|
|
4
|
-
describe('when checking equality a guid and a number', () => {
|
|
5
|
-
const guid = Guid_1.Guid.parse('1a0a061b-3533-4d91-990a-524b7e6ae6a9');
|
|
6
|
-
const num = 2;
|
|
7
|
-
it('should not be the same', () => guid.equals(num).should.be.false);
|
|
8
|
-
});
|
|
9
|
-
//# sourceMappingURL=of_a_guid_and_a_number.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"of_a_guid_and_a_number.js","sourceRoot":"","sources":["../../../for_Guid/when_checking_equality/of_a_guid_and_a_number.ts"],"names":[],"mappings":";;AAGA,qCAAkC;AAElC,QAAQ,CAAC,4CAA4C,EAAE,GAAG,EAAE;IACxD,MAAM,IAAI,GAAG,WAAI,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAChE,MAAM,GAAG,GAAG,CAAC,CAAC;IAEd,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;AACzE,CAAC,CAAC,CAAC"}
|