import type { DataDocument } from "../interfaces/json-api.interface"; import type { SerializerOptions } from "../interfaces/serializer.interface"; import Resource from "../models/resource.model"; import ResourceIdentifier from "../models/resource-identifier.model"; import type { Dictionary, nullish, SingleOrArray } from "../types/global.types"; import { Helpers } from "../utils/serializer.utils"; import Cache from "./cache"; import type Relator from "./relator"; /** * The {@link Serializer} class is the main class used to serializer data * (you can use the {@link ErrorSerializer} class to serialize errors). * * Example: * ```typescript * [[include:serializer.example.ts]] * ``` */ export default class Serializer = any> { /** * Default options. Can be edited to change default options globally. */ static defaultOptions: { idKey: string; version: string; onlyIdentifier: boolean; nullData: boolean; asIncluded: boolean; onlyRelationship: boolean; cache: boolean; depth: number; include: number; projection: null; linkers: {}; metaizers: {}; }; /** * The name to use for the type. */ collectionName: string; /** * The set of options for the serializer. */ private options; /** * The set of helper functions for the serializer */ helpers: Helpers; /** * Caching */ cache: Cache; /** * Creates a {@link Serializer}. * * @param collectionName - The name of the collection of objects. * @param options - Options for the serializer. */ constructor(collectionName: string, options?: Partial>); /** * Gets the idKey (ie. name of the id field for the given model) */ getIdKeyFieldName(): keyof PrimaryType; /** * Gets the {@link Relator}s associated with this serializer */ getRelators(): Record> | undefined; /** * Sets the {@link Relator}s associated with this serializer */ setRelators(relators: SerializerOptions["relators"]): void; /** @internal Generates a `ResourceIdentifier`. */ createIdentifier(data: PrimaryType, options?: SerializerOptions): ResourceIdentifier; /** @internal Generates a `Resource`. */ createResource(data: PrimaryType, options?: Partial>, helpers?: Helpers, relatorDataCache?: Map, Dictionary[]>): Promise>; /** * The actual serialization function. * * @param data - Data to serialize. * @param options - Options to use at runtime. */ serialize(data: SingleOrArray | nullish, options?: Partial>): Promise>>; } //# sourceMappingURL=serializer.d.ts.map