import { ClazzOrModelSchema } from "../api/types"; type Primitive = string | number | boolean | null | undefined | symbol | bigint; type FunctionKeys = { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T]; type SerializeObjectProperties = { [P in keyof Omit>]: Serialized; }; /** * Recursively defines a type that represents the serialized form of T. * - Primitive types remain unchanged. * - Functions are omitted. * - Array elements are recursively serialized. * - Object properties are recursively serialized (excluding functions). */ export type Serialized = T extends Primitive ? T : T extends Array ? Array> : T extends object ? SerializeObjectProperties : T; /** * Serializes an object (graph) into json using the provided model schema. * The model schema can be omitted if the object type has a default model schema associated with it. * If a list of objects is provided, they should have an uniform type. * * @param arg1 class or modelschema to use. Optional * @param arg2 object(s) to serialize * @returns serialized representation of the object */ export default function serialize(modelSchema: ClazzOrModelSchema, instance: T): Serialized; export default function serialize(instance: T): Serialized; export default function serialize(modelSchema: ClazzOrModelSchema, instance: T[]): Serialized[]; export default function serialize(instance: T[]): Serialized[]; export {};