import { AnyDoEntity, BaseDoEntity, Constructor, DataObjectDeserializerModel, DoEntity, DoNodeSerializer, DoTypeResolver, ObjectType } from '../index';
/**
 * Helper functions to deal with data objects.
 */
export declare const dataObjects: {
    /**
     * Editable array of {@link DoNodeSerializer} instances.
     * May be modified to add custom (de)serialization logic for custom types.
     */
    serializers: DoNodeSerializer<any>[];
    /**
     * Editable array of {@link DoTypeResolver} instances.
     *
     * The resolvers are called when an object is being deserialized by {@link DataObjectDeserializer} according to the order of this list.
     * If a resolver returns a value, the next resolvers won't be called.
     *
     * By default, the list only contains an instance of {@link DefaultDoTypeResolver}.
     *
     * The list may be modified to add a custom resolver. This may be useful for example in the following scenario:
     * Normally, a {@link BaseDoEntity} is created if the data object class cannot be resolved, unless {@link DataObjectDeserializerModel.createPojoIfDoIsUnknown} is set to true.
     * To use a specific {@link BaseDoEntity} class for unknown {@link DoEntity._type} values, a custom resolver can be added.
     */
    doTypeResolvers: DoTypeResolver[];
    /**
     * Serializes the given value and converts it to a JSON string using {@link JSON.stringify}.
     *
     * See {@link serialize} for details.
     *
     * Note: Like {@link JSON.stringify}, this method will convert `null` to the string `'null'`. If this is not desired, check the input before calling this method.
     *
     * @param dataObject The value to serialize. Can be primitives, arrays or objects/classes. Typically, a pojo or data object class extending {@link BaseDoEntity}.
     * @returns the JSON string.
     */
    stringify(dataObject: any): string;
    /**
     * Serializes the given value.
     *
     * Note:
     * * {@link Map} is converted to a pojo. This means the Map key must be able to be serialized to an object key (string, number or symbol) and must be unique.
     * * {@link Set} is converted to array.
     * * {@link Date} instances are converted to a string according to {@link dates.toJsonDate}.
     * * Properties with value 'undefined' are not part of the result (skipped).
     *
     * @param dataObject The value to serialize. Can be primitives, arrays or objects/classes. Typically, a pojo or data object class extending {@link BaseDoEntity}.
     * @returns the input serialized. Typically, a pojo. Returns the unaltered input if the input is falsy.
     */
    serialize(dataObject: any): any;
    /**
     * Parses the given JSON string into a pojo and deserializes it to the data object classes if possible.
     *
     * See {@link deserialize} for details.
     *
     * @param json The JSON string to parse.
     * @param objectType The expected resulting data object.
     * @param deserializerModel Optional configuration object for the DataObjectDeserializer.
     * @returns The deserialized data object instance, if json is defined. Returns undefined if json is undefined. Returns null if json is null or the empty string.
     */
    parse: DoDeserializeFunction<string>;
    /**
     * Deserializes the given object to data object classes if possible.
     *
     * If the data object class cannot be computed for an object (e.g. because the _type value is unknown), a generic {@link BaseDoEntity} instance is created holding all the attributes.
     * If a pojo should be created instead, use {@link DataObjectDeserializerModel.createPojoIfDoIsUnknown}
     *
     * @param obj The pojo to deserialize.
     * @param objectType The expected resulting data object.
     * @param deserializerModel Optional configuration object for the DataObjectDeserializer.
     * @returns The deserialized data object instance. Returns undefined if obj is undefined. Returns null if obj is null or falsy.
     */
    deserialize: DoDeserializeFunction<any>;
    /**
     * @returns the DO entity contribution for the given contribution class or type.
     */
    getContribution<TContributionDo extends DoEntity>(contributionClassOrType: DoContributionClassOrType<TContributionDo>, doEntity: DoEntityWithContributions): TContributionDo;
    /**
     * @returns all DO entity contributions as array.
     */
    getContributions<TContributionDo extends DoEntity>(doEntity: DoEntityWithContributions): TContributionDo[];
    /**
     * Adds a new DO entity contribution to the given DO entity.
     * Existing contributions for the same contribution class are replaced. If the contribution is a plain object, existing contributions with the same _type are replaced.
     */
    addContribution(contribution: AnyDoEntity, doEntity: DoEntityWithContributions): void;
    /**
     * Removes the DO entity contributions whose class or type matches the given contribution class.
     * @returns true if a contribution was removed.
     */
    removeContribution<TContributionDo extends DoEntity>(contributionClassOrType: DoContributionClassOrType<TContributionDo>, doEntity: DoEntityWithContributions): boolean;
};
export type DoEntityWithContributions = DoEntity & {
    _contributions?: DoEntity[];
};
export type DoContributionClassOrType<TContributionDo extends DoEntity> = string | Constructor<TContributionDo>;
export interface DoDeserializeFunction<TInput> {
    (obj: TInput): BaseDoEntity;
    <TResultDo extends BaseDoEntity | BaseDoEntity[] = BaseDoEntity>(obj: TInput, objectType: ObjectType<TResultDo>): TResultDo;
    <TConfig extends DataObjectDeserializerModel = DataObjectDeserializerModel>(obj: TInput, objectType: null | undefined, deserializerModel: TConfig): TConfig['createPojoIfDoIsUnknown'] extends true ? any : BaseDoEntity;
    <TResultDo extends BaseDoEntity | BaseDoEntity[] = BaseDoEntity, TConfig extends DataObjectDeserializerModel = DataObjectDeserializerModel>(obj: TInput, objectType: ObjectType<TResultDo>, deserializerModel: TConfig): TResultDo;
}
//# sourceMappingURL=dataObjects.d.ts.map