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AC,MAAM,CAAC,EAAE;YAC/B,MAAM,CAAC,gBAAgB,EAAE,CAAC;SAC7B;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAED;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,MAAkB,EAAE,QAAa;IACnD,IAAI,iEAA0B,CAAC,QAAQ,CAAC,EAAE;QACtC,OAAO;YACH,UAAU,EAAE,IAAI;YAChB,KAAK,EAAE,QAAQ,CAAC,eAAe,CAAC,MAAM,CAAC;SAC1C,CAAC;KACL;SAAM;QACH,OAAO;YACH,UAAU,EAAE,KAAK;SACpB,CAAC;KACL;AACL,CAAC;;;;;;SC/LD;SACA;;SAEA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;SACA;;SAEA;SACA;;SAEA;SACA;SACA;;;;;UCtBA;UACA;UACA;UACA;UACA,yCAAyC,wCAAwC;UACjF;UACA;UACA;;;;;UCPA;;;;;UCAA;UACA;UACA;UACA,uDAAuD,iBAAiB;UACxE;UACA,gDAAgD,aAAa;UAC7D;;;;;;;;;;;;;;;;;;;ACN6B","sources":["webpack://@mdcc/at-json/./lib/public_api.ts","webpack://@mdcc/at-json/./lib/decorators/index.ts","webpack://@mdcc/at-json/./lib/decorators/array.ts","webpack://@mdcc/at-json/./lib/decorators/common.ts","webpack://@mdcc/at-json/./lib/interfaces.ts","webpack://@mdcc/at-json/./lib/reflection.ts","webpack://@mdcc/at-json/./lib/decorators/array-of-complex-property.ts","webpack://@mdcc/at-json/./lib/decorators/class.ts","webpack://@mdcc/at-json/./lib/decorators/complex-property.ts","webpack://@mdcc/at-json/./lib/decorators/map.ts","webpack://@mdcc/at-json/./lib/decorators/property.ts","webpack://@mdcc/at-json/./lib/mapper.ts","webpack://@mdcc/at-json/webpack/bootstrap","webpack://@mdcc/at-json/webpack/runtime/define property getters","webpack://@mdcc/at-json/webpack/runtime/hasOwnProperty shorthand","webpack://@mdcc/at-json/webpack/runtime/make namespace object","webpack://@mdcc/at-json/./lib/index.ts"],"sourcesContent":["export {\n IJsonClassOptions,\n JsonArray,\n JsonArrayOfComplexProperty,\n JsonClass,\n JsonComplexProperty,\n JsonMap,\n JsonProperty,\n MapDecoratorInput,\n makeCustomDecorator,\n} from './decorators';\nexport {\n AfterDeserialize,\n Constructable,\n CustomSerialize,\n DecoratorInputWithCustomFunctions,\n DecoratorInputWithoutCustomFunctions,\n IMappingFunctions,\n IMappingOptions,\n IMappingOptionsExtra,\n Mapping,\n} from './interfaces';\nexport { JsonMapper } from './mapper';\n","export { JsonArray } from './array';\nexport { JsonArrayOfComplexProperty } from './array-of-complex-property';\nexport { IJsonClassOptions, JsonClass } from './class';\nexport { makeCustomDecorator } from './common';\nexport { JsonComplexProperty } from './complex-property';\nexport { JsonMap, MapDecoratorInput } from './map';\nexport { JsonProperty } from './property';\n","import { DecoratorInputWithCustomFunctions } from '../interfaces';\nimport { JsonMapper } from '../mapper';\nimport { mapArray, transformDecorator } from './common';\n\n/**\n * The basic decorator for array of simple properties.\n *\n * `params` has the same meaning that the one in {@link JsonProperty}.\n *\n * Usage examples:\n * ```typescript\n * import { JsonClass, JsonMapper, JsonArray } from '@mdcc/at-json';\n *\n * @JsonClass()\n * class MyClass\n * {\n * @JsonArray()\n * basicProperty: string[];\n *\n * @JsonArray('extName')\n * renamedProperty: number[];\n *\n * @JsonArray({\n * name: 'custom',\n * serialize: (mapper, n) => n.toString(),\n * deserialize: (mapper, n) => parseInt(n, 10)\n * }, true)\n * customProperty: number[];\n * }\n *\n * const backendObject = {\n * basicProperty: ['value', 'value2'],\n * extName: [123, 456],\n * customProperty: ['456', '789']\n * };\n * const mapper = new JsonMapper();\n * const deserialized = mapper.deserialize<MyClass>(MyClass, backendObject);\n *\n * // basicProperty keeps the same name\n * assert.equal(deserialized.basicProperty, ['value', 'value2']);\n * // extName became renamedProperty\n * assert.equal(deserialized.renamedProperty, [123, 456]);\n * // customProperty became custom, and the string was converted to number\n * assert.equal(deserialized.custom, [456, 789]);\n *\n * const backendObjectSerialized = mapper.serialize(deserialized);\n * // reverse conversion was performed\n * assert.deepEqual(backendObjectSerialized, backendObject);\n *\n * const errorObject = { basicProperty: {} };\n * const deserializedErrorObject = mapper.deserialize<MyClass>(MyClass, errorObject);\n * // basicProperty is null\n * assert.isNull(deserializedErrorObject.basicProperty);\n *\n * const errorObject2 = { basicProperty: [], renamedProperty: [], customProperty: {} };\n * // this throws because customProperty was decorated with `@JsonArray(..., true)`\n * const deserializedErrorObject2 = mapper.deserialize<MyClass>(MyClass, errorObject2);\n\n * ```\n *\n * @export\n * @param {DecoratorInputWithCustomFunctions<T>} [params] the params\n * @param {NoCustomFunctionsDecoratorInput} params params\n * @param {boolean} throwIfNotArray if true, throws an error if the property is not an array.\n * @returns the decorator for the property.\n */\nexport function JsonArray(params?: DecoratorInputWithCustomFunctions, throwIfNotArray?: boolean): PropertyDecorator {\n return transformDecorator(opt => ({\n serialize: (mapper: JsonMapper, array) => mapArray(mapper, array, opt.serialize, throwIfNotArray),\n deserialize: (mapper: JsonMapper, array) => mapArray(mapper, array, opt.deserialize, throwIfNotArray),\n }))(params);\n}\n","import { IMappingFunctions, IMappingOptions, IMappingOptionsExtra, Mapping, Symbols } from '../interfaces';\nimport { JsonMapper } from '../mapper';\nimport { defineMetadata, getMetadata } from '../reflection';\n\nfunction normalizeParams(params?: string | IMappingOptionsExtra | undefined): IMappingOptions {\n let resolvedParams: IMappingOptions;\n\n if (typeof params === 'string') {\n resolvedParams = { name: params };\n } else {\n resolvedParams = params || {};\n }\n\n return resolvedParams;\n}\n\n/**\n * A custom decorator factory function, in order to allow defining custom reusable decorators.\n *\n * @param serializeFn the function used for serializing the value.\n * @param deserializeFn the function used for deserializing the value.\n */\nexport function makeCustomDecorator<S = any, D = any>(\n fn: () => IMappingFunctions<S, D>\n): (params?: string | IMappingOptionsExtra | undefined) => PropertyDecorator {\n return params => {\n const actualParams: IMappingOptions = {\n ...normalizeParams(params),\n ...fn(),\n };\n return _createPropertyDecorator(actualParams);\n };\n}\n\n/**\n * A decorator transforming function, used internally.\n */\nexport function transformDecorator<S = any, D = any>(\n fn: (opt: IMappingFunctions<S, D>) => IMappingFunctions<S, D>\n): (params?: string | IMappingOptionsExtra | undefined) => PropertyDecorator {\n return params => {\n const normalizedParams = normalizeParams(params);\n const { serialize, deserialize } = fn(normalizedParams);\n\n const actualParams: IMappingOptions = {\n ...normalizedParams,\n serialize,\n deserialize,\n };\n return _createPropertyDecorator(actualParams);\n };\n}\n\nfunction _createPropertyDecorator(actualParams: IMappingOptions): PropertyDecorator {\n return function (target: object, propertyKey: string | symbol) {\n const constructor = target.constructor;\n const objMetadata = getMetadata(Symbols.fieldsMetadata, constructor) || [];\n defineMetadata(Symbols.fieldsMetadata, [...objMetadata, propertyKey], constructor);\n defineMetadata(Symbols.mappingMetadata, actualParams, constructor, propertyKey);\n };\n}\n\nexport function mapArray<D, S = any>(\n mapper: JsonMapper,\n propertyValue: S,\n deserializeItem?: Mapping<S, D>,\n throwIfNotArray?: boolean\n): D[] | null {\n if (Array.isArray(propertyValue)) {\n if (deserializeItem) {\n // map deserialize on the array\n return propertyValue.map(item => deserializeItem(mapper, item));\n } else {\n return propertyValue;\n }\n } else {\n if (throwIfNotArray) {\n throw new Error(`Expected array, got ${typeof propertyValue}`);\n }\n\n // if marked as array, but not an array, set the value to null\n return null;\n }\n}\n","import { JsonMapper } from './mapper';\n\nexport const Symbols = {\n mappingMetadata: Symbol('[[mapping]]'),\n mappingOptions: Symbol('[[mappingOptions]]'),\n fieldsMetadata: Symbol('[[fields]]'),\n metadataRoot: Symbol('[[AtJsonMetadata]]'),\n};\nObject.freeze(Symbols);\n\n/**\n * Type alias for a mapping function.\n */\nexport type Mapping<T = any, R = any> = (mapper: JsonMapper, val: T) => R;\n\n/**\n * Interface for constructor class.\n *\n * @export\n * @interface Constructable\n * @template T the constructed type\n */\nexport type Constructable<T, Args extends any[] = any[]> = new (...args: Args) => T;\n\n/**\n * Interface for classes that want to apply a custom serialization logic.\n * If a class implements this interface, its {@link customSerialize}\n * method will be called instead of the default serialization logic.\n * It is the responsibility of the implementation to recursively serialize\n * nested objects.\n */\nexport interface CustomSerialize {\n /**\n * Custom serialization logic.\n */\n customSerialize(mapper: JsonMapper): any;\n}\n\n/**\n * Interface for classes that want to apply an additional deserialization logic\n * after default deserialization.\n * If a class implements this interface, its {@link afterDeserialize}\n * method will be called after the deserialization.\n */\nexport interface AfterDeserialize {\n /**\n * Additional deserialization logic.\n */\n afterDeserialize(): void;\n}\n\n/**\n * Type guard for {@link CustomSerialize} interface.\n *\n * @param mapValue value to check\n * @returns if the parameter is a CustomSerialize interface\n */\nexport function hasCustomSerializeExport(mapValue: any): mapValue is CustomSerialize {\n const fn = mapValue[nameOf<CustomSerialize>('customSerialize')];\n return typeof fn === 'function';\n}\n\n/**\n * Type guard for {@link AfterDeserialize} interface.\n *\n * @param mapValue value to check\n * @returns if the parameter is a AfterDeserialize interface\n */\nexport function hasAfterDeserialize(mapValue: any): mapValue is AfterDeserialize {\n const fn = mapValue[nameOf<AfterDeserialize>('afterDeserialize')];\n return typeof fn === 'function';\n}\n\n/**\n * Mapping functions.\n *\n * @export\n * @interface IMappingFunctions\n * @template S the type of the deserialized property\n * @template D the type of the serialized property\n */\nexport interface IMappingFunctions<S = any, D = any> {\n /**\n * Custom deserialization function.\n *\n * @type {Mapping}\n * @memberof IMappingOptions\n */\n deserialize?: Mapping<S, D>;\n\n /**\n * Custom serialization function.\n *\n * @type {Mapping}\n * @memberof IMappingOptions\n */\n serialize?: Mapping<D, S>;\n}\n\n/**\n * Mapping extra options.\n *\n * @export\n * @interface IMappingOptionsExtra\n */\nexport interface IMappingOptionsExtra {\n /**\n * Property name.\n * If specified, the serialize process will convert the class property name to this value, and\n * the deserialize process will convert the other way.\n *\n * @type {string}\n * @memberof IMappingOptions\n */\n name?: string;\n}\n\nexport type IMappingOptions<S = any, D = any> = IMappingFunctions<S, D> & IMappingOptionsExtra;\n\n/**\n * Decorator input for decorators that support custom serialize/deserialize functions.\n */\nexport type DecoratorInputWithCustomFunctions<S = any, D = any> = string | IMappingOptions<S, D> | undefined;\n/**\n * Decorator input for decorators that don't support custom serialize/deserialize functions.\n */\nexport type DecoratorInputWithoutCustomFunctions = string | IMappingOptionsExtra | undefined;\n\n/** helper */\nfunction nameOf<T>(k: keyof T): string {\n return k as string;\n}\n","import { Symbols } from './interfaces';\n\n/**\n * Defines a metadata on the target object.\n *\n * Replaces `Reflect.defineMetadata`.\n *\n * @param {string | symbol} key the key of the metadata\n * @param {any} value the value to be set in the metadata\n * @param {object} target the target on which the metadata should be set\n * @param {string | symbol} propertyName optional property name to add to the path on where value is set\n */\nexport function defineMetadata(key: string | symbol, value: any, target: object, propertyName?: string | symbol): void {\n // define metadata map on object to avoid overwriting the parent\n if (!has(target, Symbols.metadataRoot)) {\n target[Symbols.metadataRoot] = {};\n }\n\n const v = target[Symbols.metadataRoot];\n if (typeof v[propertyName] === 'undefined') {\n v[propertyName] = {};\n }\n v[propertyName][key] = value;\n}\n\n/**\n * Retrieves the metadata associated to `target` and `propertyName`.\n *\n * If not found, follows the prototype chain.\n *\n * Replaces `Reflect.getMedadata`.\n *\n * @param {string | symbol} key the key of the metadata\n * @param {object} target the target from which the metadata should be retrieved\n * @param {string | symbol} propertyName optional property name to add to the path on where value is retrieved\n * @returns {any} the value found, or `undefined` if not found\n */\nexport function getMetadata(key: string | symbol, target: object, propertyName?: string | symbol): any {\n const propName = propertyName as any;\n while (target) {\n const map = target?.[Symbols.metadataRoot];\n if (map && has(map, propName) && has(map[propName], key)) {\n return map[propName][key];\n }\n target = Object.getPrototypeOf(target);\n }\n return undefined;\n}\n\nfunction has(object: any, key: string | symbol): any {\n return Object.prototype.hasOwnProperty.call(object, key);\n}\n","import { Constructable, DecoratorInputWithoutCustomFunctions } from '../interfaces';\nimport { JsonMapper } from '../mapper';\nimport { makeCustomDecorator, mapArray } from './common';\n\n/**\n * Decorator for complex-type array properties to be (de)serialized correctly.\n * Use this if the property is an array of a type that needs recursive (de)serialization.\n *\n * Usage examples:\n * ```typescript\n * import {\n * JsonClass,\n * JsonMapper,\n * JsonProperty,\n * JsonArrayOfComplexProperty\n * } from '@mdcc/at-json';\n *\n * @JsonClass()\n * class SubClass\n * {\n * @JsonProperty()\n * foo: string;\n * }\n *\n * @JsonClass()\n * class MyClass\n * {\n * @JsonArrayOfComplexProperty(SubClass)\n * sub1: SubClass[];\n *\n * @JsonArrayOfComplexProperty(SubClass, 'extSub2', true)\n * sub2: SubClass[];\n * }\n *\n * const backendObject = {\n * sub1: [{ foo: 'bar' }],\n * extSub2: [{ foo: 'baz' }]\n * };\n * const mapper = new JsonMapper();\n * const deserialized = mapper.deserialize<MyClass>(MyClass, backendObject);\n *\n * // sub1 keeps the same name\n * assert.isInstanceOf(deserialized.sub1, Array);\n * assert.isInstanceOf(deserialized.sub1[0], SubClass);\n * assert.equal(deserialized.sub1[0].foo, 'bar');\n *\n * // extSub2 became sub2\n * assert.isInstanceOf(deserialized.sub2, Array);\n * assert.isInstanceOf(deserialized.sub2[0], SubClass);\n * assert.equal(deserialized.sub2[0].foo, 'baz');\n *\n * const backendObjectSerialized = mapper.serialize(deserialized);\n * // reverse conversion was performed\n * assert.deepEqual(backendObjectSerialized, backendObject);\n *\n * const errorObject = { sub1: {} };\n * const deserializedErrorObject = mapper.deserialize<MyClass>(MyClass, errorObject);\n * // sub1 is null\n * assert.isNull(deserializedErrorObject.sub1);\n *\n * const errorObject2 = { sub1: [], sub2: {} };\n * // this throws because sub2 was decorated with `@JsonArrayOfComplexProperty(..., true)`\n * const deserializedErrorObject2 = mapper.deserialize<MyClass>(MyClass, errorObject2);\n * ```\n *\n * @export\n * @param {Constructable<any>} constructor the constructor type of the array items.\n * @param {DecoratorInputWithoutCustomFunctions} params params\n * @param {boolean} throwIfNotArray if true, throws an error if the property is not an array.\n * @returns the decorator for the property.\n */\nexport function JsonArrayOfComplexProperty<T>(\n constructor: Constructable<T>,\n params?: DecoratorInputWithoutCustomFunctions,\n throwIfNotArray?: boolean\n): PropertyDecorator {\n function serialize(m: JsonMapper, item: any): any {\n return m.serialize(item);\n }\n\n function deserialize(m: JsonMapper, item: any): any {\n return item === null || item === undefined ? item : m.deserialize(constructor, item);\n }\n\n return makeCustomDecorator(() => ({\n serialize: (mapper: JsonMapper, array: any) => mapArray<T>(mapper, array, serialize, throwIfNotArray),\n deserialize: (mapper: JsonMapper, array: any) => mapArray<T>(mapper, array, deserialize, throwIfNotArray),\n }))(params);\n}\n","import { Symbols } from '../interfaces';\nimport { defineMetadata } from '../reflection';\n\nexport interface IJsonClassOptions {\n /**\n * If `true` (the default), undecorated properties are ignored by the serialization/deserialization process.\n * If `false`, they are treated as if they were decorated with the {@link JsonProperty} decorator.\n */\n ignoreUndecoratedProperties?: boolean;\n}\n\n/**\n * Decorator for mapped classes.\n *\n * @export\n * @template T\n * @returns\n * @param ignoreMissingFields\n */\nexport function JsonClass(options?: IJsonClassOptions): ClassDecorator {\n const actualOptions: Required<IJsonClassOptions> = Object.assign(\n { ignoreUndecoratedProperties: true } as Required<IJsonClassOptions>,\n options\n );\n\n return ctor => {\n defineMetadata(Symbols.mappingOptions, actualOptions, ctor);\n return ctor;\n };\n}\n","import { Constructable, DecoratorInputWithoutCustomFunctions } from '../interfaces';\nimport { JsonMapper } from '../mapper';\nimport { makeCustomDecorator } from './common';\n\n/**\n * Decorator for complex-type properties to be (de)serialized correctly.\n * Use this if the property is of a non-array type that needs recursive (de)serialization.\n *\n * Uses only the `name` property of the params.\n *\n * Usage examples:\n * ```typescript\n * import { JsonClass, JsonMapper, JsonProperty, JsonComplexProperty } from '@mdcc/at-json';\n *\n * @JsonClass()\n * class SubClass\n * {\n * @JsonProperty()\n * foo: string;\n * }\n *\n * @JsonClass()\n * class MyClass\n * {\n * @JsonComplexProperty(SubClass)\n * sub1: SubClass;\n *\n * @JsonComplexProperty(SubClass, 'extSub2')\n * sub2: SubClass;\n * }\n *\n * const backendObject = {\n * sub1: { foo: 'bar' },\n * extSub2: { foo: 'baz' }\n * };\n * const mapper = new JsonMapper();\n * const deserialized = mapper.deserialize<MyClass>(MyClass, backendObject);\n *\n * // sub1 keeps the same name\n * assert.isInstanceOf(deserialized.sub1, SubClass);\n * assert.equal(deserialized.sub1.foo, 'bar');\n *\n * // extSub2 became sub2\n * assert.isInstanceOf(deserialized.sub2, SubClass);\n * assert.equal(deserialized.sub2.foo, 'baz');\n *\n * const backendObjectSerialized = mapper.serialize(deserialized);\n * // reverse conversion was performed\n * assert.deepEqual(backendObjectSerialized, backendObject);\n * ```\n *\n * @export\n * @param {Constructable<any>} constructor the constructor type of the property.\n * @param name the name of the property\n * @returns the decorator for the property.\n */\nexport function JsonComplexProperty<T>(\n constructor: Constructable<T>,\n params?: DecoratorInputWithoutCustomFunctions\n): PropertyDecorator {\n return makeCustomDecorator(() => ({\n serialize: (mapper: JsonMapper, value: T) => mapper.serialize(value),\n deserialize: (mapper: JsonMapper, value: string | object) => mapper.deserialize<T>(constructor, value),\n }))(params);\n}\n","import { Constructable, DecoratorInputWithoutCustomFunctions } from '../interfaces';\nimport { JsonMapper } from '../mapper';\nimport { makeCustomDecorator } from './common';\n\nexport type MapDecoratorInput = DecoratorInputWithoutCustomFunctions & {\n complexType?: Constructable<any>;\n};\n\n/**\n * A custom decorator for handling objects as maps.\n *\n * @param params the mapping options to apply to the values of the map.\n */\nexport function JsonMap(params?: MapDecoratorInput): PropertyDecorator {\n return makeCustomDecorator(() => ({\n serialize: (mapper: JsonMapper, map: Map<any, any>) => {\n const ret = {};\n\n if (params?.complexType) {\n for (const [k, v] of map.entries()) {\n ret[k] = mapper.serialize(v);\n }\n } else {\n for (const [k, v] of map.entries()) {\n ret[k] = v;\n }\n }\n\n return ret;\n },\n deserialize: (mapper: JsonMapper, obj) => {\n const map = new Map();\n\n if (params?.complexType) {\n for (const key in obj) {\n map.set(key, mapper.deserialize(params.complexType!, obj[key]));\n }\n } else {\n for (const key in obj) {\n map.set(key, obj[key]);\n }\n }\n\n return map;\n },\n }))(params);\n}\n","import { DecoratorInputWithCustomFunctions } from '../interfaces';\nimport { transformDecorator } from './common';\n\n/**\n * The basic decorator for simple properties.\n *\n * It basically takes the incoming property value, applies eventual custom serialization or deserialization,\n * and then sets the property value to the result.\n *\n * `params` can be:\n * - a string, if only the name of source property is provided (`name` property of {@link IMappingOptions}).\n * - an object compliant to {@link IMappingOptions} interface.\n *\n * Usage examples:\n * ```typescript\n * import { JsonClass, JsonMapper, JsonProperty } from '@mdcc/at-json';\n *\n * @JsonClass()\n * class MyClass\n * {\n * @JsonProperty()\n * basicProperty: string;\n *\n * @JsonProperty('extName')\n * renamedProperty: number;\n *\n * @JsonProperty({\n * name: 'custom',\n * serialize: (mapper, n) => n.toString(),\n * deserialize: (mapper, n) => parseInt(n, 10)\n * })\n * customProperty: number;\n * }\n *\n * const mapper = new JsonMapper();\n * const backendObject = { basicProperty: 'value', extName: 123, customProperty: '456' };\n * const deserialized = mapper.deserialize<MyClass>(MyClass, backendObject);\n *\n * // basicProperty keeps the same name\n * assert.equal(deserialized.basicProperty, 'value');\n * // extName became renamedProperty\n * assert.equal(deserialized.renamedProperty, 123);\n * // customProperty became custom, and the string was converted to number\n * assert.equal(deserialized.custom, 456);\n *\n * const backendObjectSerialized = mapper.serialize(deserialized);\n * // reverse conversion was performed\n * assert.deepEqual(backendObjectSerialized, backendObject);\n * ```\n *\n * @export\n * @param {DecoratorInputWithCustomFunctions} [params] the params\n * @returns the decorator for the property.\n */\nexport function JsonProperty(params?: DecoratorInputWithCustomFunctions): PropertyDecorator {\n return transformDecorator(opt => ({\n serialize: opt.serialize,\n deserialize: opt.deserialize,\n }))(params);\n}\n","import { IJsonClassOptions } from './decorators/class';\nimport * as I from './interfaces';\nimport { getMetadata } from './reflection';\n\n/**\n * Class for JSON Mapping.\n *\n * @export\n * @class JsonMapper\n */\nexport class JsonMapper {\n /**\n * Serialization method.\n * Transforms `source` into a new JSON value by applying the \"serialization\" step for each property decorator.\n *\n * Annotated properties are serialized into a property using the `name` value as the destination name (defaults to the property name).\n *\n * @param {*} source the value to be serialized.\n * @returns {string} the transformed JSON value.\n * @throws An error if a class encountered while serializing has no {@link JsonClass} decorator.\n * @memberof JsonMapper\n */\n serialize(source: any): any {\n // if val is nil no need to do anything\n if (source === null || source === undefined) {\n return source;\n }\n\n // retrieve the object constructor in order to load the class decorator metadata\n const ctor: I.Constructable<any> = Object.getPrototypeOf(source).constructor;\n const ctorOptions: IJsonClassOptions = getMetadata(I.Symbols.mappingOptions, ctor);\n if (!ctorOptions) {\n throw new Error(`Class ${ctor.name} is not decorated with @JsonClass`);\n }\n\n // let's try to call an eventual custom export before the standard one\n const customExport = exportCustom(this, source);\n if (customExport.serialized) {\n return customExport.value;\n }\n\n // should missing properties be ignored\n const { ignoreUndecoratedProperties } = ctorOptions;\n // destination object for the mapping\n const target = {};\n\n Object.keys(source).forEach(propName => {\n // retrieve the serialization options in the decorator of the property\n const options: I.IMappingOptions = getMetadata(I.Symbols.mappingMetadata, ctor, propName);\n const propValue = source[propName];\n\n // if no decorator is provided, map the property by copy if \"ignoreUndecoratedProperties\" is false\n // maybe here a clone should be used instead of a shallow copy\n if (options === undefined) {\n if (!ignoreUndecoratedProperties) {\n target[propName] = propValue;\n }\n\n return;\n }\n\n // destination property name, by default the property name in the source object, but it can be\n // overridden in the decorator\n const name = options.name || propName;\n\n if (options.serialize) {\n target[name] = options.serialize(this, propValue);\n } else {\n target[name] = propValue;\n }\n });\n\n return target;\n }\n\n /**\n * Deserializes an array by applying {@link deserialize} to each element.\n * @template T the type of output object\n * @param {I.Constructable<T>} ctor the destination constructor\n * @param jsonArray the array to be deserialized\n * @returns {T} the deserialized object\n * @memberof JsonMapper\n */\n deserializeArray<T>(ctor: I.Constructable<T>, jsonArray: any[]): T[] {\n return jsonArray.map(v => this.deserialize(ctor, v));\n }\n\n /**\n * Deserialization method.\n * Deserializes `source` into an object built using `ctor`.\n *\n * Annotated properties are deserialized into a property using the `name` value as the source name (defaults to the property name).\n *\n * @template T the type of output object\n * @param {I.Constructable<T>} ctor the destination constructor\n * @param {*} source the value to be deserialized\n * @param {(s: string) => any} stringParser the string parser to deserialize strings into JSON objects. Defaults to `JSON.parse`.\n * @returns {T} the deserialized object\n * @throws An error if a class encountered while deserializing has no {@link JsonClass} decorator.\n * @memberof JsonMapper\n */\n deserialize<T>(\n ctor: I.Constructable<T>,\n source: string | object,\n stringParser: (s: string) => any = JSON.parse\n ): T {\n const ctorOptions: IJsonClassOptions = getMetadata(I.Symbols.mappingOptions, ctor);\n if (!ctorOptions) {\n throw new Error(`Class ${ctor.name} is not decorated with @JsonClass`);\n }\n\n // automatic parse of strings\n if (typeof source === 'string') {\n source = stringParser(source);\n }\n\n const target = new ctor();\n const has = Object.prototype.hasOwnProperty;\n\n const { ignoreUndecoratedProperties } = ctorOptions;\n\n // keep track of mapped properties, so we can copy not mapped ones if \"ignoreUndecoratedProperties\" is false\n const mapped = new Set<string>();\n\n // extract the property names array from the metadata stored in the constructor\n // be careful: undecorated properties are NOT stored in this array\n const propNames = (getMetadata(I.Symbols.fieldsMetadata, ctor) as string[]) ?? [];\n\n propNames.forEach(propName => {\n const options: I.IMappingOptions = getMetadata(I.Symbols.mappingMetadata, ctor, propName);\n\n /* istanbul ignore next */\n if (options === undefined) {\n return;\n }\n\n const name = options.name || propName;\n\n if (!has.call(source, name)) {\n return;\n }\n\n if (options.deserialize) {\n target[propName] = options.deserialize(this, source[name]);\n } else {\n target[propName] = source[name];\n }\n\n mapped.add(name);\n });\n\n if (!ignoreUndecoratedProperties) {\n // iterate ALL object keys (even undecorated ones, since we are using Object.keys)\n Object.keys(source).forEach(propName => {\n // copy over not mapped properties\n // maybe here a clone should be performed?\n if (!mapped.has(propName)) {\n target[propName] = source[propName];\n }\n });\n }\n\n // call eventual after deserialize callback to post-process values\n if (I.hasAfterDeserialize(target)) {\n target.afterDeserialize();\n }\n\n return target;\n }\n}\n\n/**\n * This method checks if the input value is a {@link CustomSerialize} implementation.\n * If it is so, it calls the custom export function and returns its output in the `value` field\n * of the response.\n *\n * @param {JsonMapper} mapper the mapper\n * @param mapValue the value to export\n * @returns the exported value decorated with a boolean\n */\nfunction exportCustom(mapper: JsonMapper, mapValue: any): { serialized: true; value: any } | { serialized: false } {\n if (I.hasCustomSerializeExport(mapValue)) {\n return {\n serialized: true,\n value: mapValue.customSerialize(mapper),\n };\n } else {\n return {\n serialized: false,\n };\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './public_api';\n"],"names":[],"sourceRoot":""}