/** biome-ignore-all lint/suspicious/noExplicitAny: Serialization/Deserialization involves a lot of `any` */ import * as duperFfi from "./generated/duper"; /** * Duper-specific errors. */ export type DuperError = duperFfi.DuperError; declare const duperSymbol: unique symbol; /** * A valid Duper value. */ export type DuperValue = { [duperSymbol]: "$__duper"; type: "Object"; value: Record; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Array"; value: (DuperValue | NonDuper)[]; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Tuple"; value: (DuperValue | NonDuper)[]; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "String"; value: string; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Bytes"; value: Uint8Array; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Integer"; value: bigint; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Float"; value: number; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Boolean"; value: boolean; identifier?: string; toJSON(): any; } | { [duperSymbol]: "$__duper"; type: "Null"; value: null; identifier?: string; toJSON(): any; }; type NonDuper = null | undefined | string | boolean | number | bigint | symbol | { [duperSymbol]?: never; [key: string]: unknown; }; /** * The possible types that a Duper value may have. */ export type DuperType = DuperValue extends { type: infer T; } ? T : never; export declare const DuperValue: { /** * Creates a Duper object. * * @param value The key/value mapping. * @param identifier The identifier. */ Object: (value: Record, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Object"; value: Record; identifier: string | undefined; toJSON: () => { [k: string]: any; }; }; /** * Creates a Duper array. * * @param value The value list. * @param identifier The identifier. */ Array: (value: (DuperValue | NonDuper)[], identifier?: string) => { [duperSymbol]: "$__duper"; type: "Array"; value: (DuperValue | NonDuper)[]; identifier: string | undefined; toJSON: () => any[]; }; /** * Creates a Duper tuple. * * @param value The value list. * @param identifier The identifier. */ Tuple: (value: (DuperValue | NonDuper)[], identifier?: string) => { [duperSymbol]: "$__duper"; type: "Tuple"; value: (DuperValue | NonDuper)[]; identifier: string | undefined; toJSON: () => any[]; }; /** * Creates a Duper string. * * @param value The value. * @param identifier The identifier. */ String: (value: string, identifier?: string) => { [duperSymbol]: "$__duper"; type: "String"; value: string; identifier: string | undefined; toJSON: () => string; }; /** * Creates a Duper byte string. * * @param value The value. * @param identifier The identifier. */ Bytes: (value: Uint8Array | string | number[], identifier?: string) => { [duperSymbol]: "$__duper"; type: "Bytes"; value: Uint8Array; identifier: string | undefined; toJSON: () => number[]; }; /** * Creates a Duper Temporal value. * * @param value The value. * @param identifier The identifier. */ Temporal: (value: any, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "Instant"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "ZonedDateTime"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "PlainDate"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "PlainTime"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "PlainDateTime"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "PlainYearMonth"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "PlainMonthDay"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: any; identifier: "Duration"; toJSON: () => any; } | { [duperSymbol]: "$__duper"; type: "Temporal"; value: string; identifier: string | undefined; toJSON: () => string; }; /** * Creates a Duper integer. * * @param value The value. * @param identifier The identifier. */ Integer: (value: bigint | number | string, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Integer"; value: bigint; identifier: string | undefined; toJSON: () => string | number; }; /** * Creates a Duper float. * * @param value The value. * @param identifier The identifier. */ Float: (value: bigint | number, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Float"; value: number; identifier: string | undefined; toJSON: () => number | bigint; }; /** * Creates a Duper boolean. * * @param value The value. * @param identifier The identifier. */ Boolean: (value: boolean, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Boolean"; value: boolean; identifier: string | undefined; toJSON: () => boolean; }; /** * Creates a Duper null value. * * @param _value The value. * @param identifier The identifier. */ Null: (_value?: null, identifier?: string) => { [duperSymbol]: "$__duper"; type: "Null"; value: null; identifier: string | undefined; toJSON: () => null; }; }; /** * Options available to the `stringify` function. * * @property {string | number} [indent] - Optional whitespace string to use as * indentation, or the number of spaces to use as indentation. * @property {boolean} [stripIdentifiers] - Whether Duper identifiers should be * removed from the stringified value. * @property {boolean} [minify] - Whether stringify should minify the value. Not * compatible with `indent`. */ type StringifyOptions = { indent?: string | number; stripIdentifiers?: boolean; minify?: false; } | { indent?: never; stripIdentifiers?: boolean; minify: true; }; /** * Converts the provided value into a Duper string. * * @param value The value to stringify. * @param options Options for stringification. * @returns The Duper string. */ export declare function stringify(value: any, options?: StringifyOptions): string; /** * Parses the provided Duper string into a Duper value, or a JSON-safe alternative if specified. * * @param value The Duper string to parse. * @param jsonSafe Whether to emit a JSON-safe alternative instead of a `DuperValue`. * @returns The parsed value. */ export declare function parse(value: string, jsonSafe?: false): DuperValue; export declare function parse(value: string, jsonSafe: true): any; export {};