/** * These types are used by the AsyncObjectMapper. Here's the magic which makes * object mapper schemas type safe and complete. You generally won't need to * make use of these types within your own code; just `ObjectMapper` should be * enough. * * @module */ import { AllowInputKeyIfInputCanExtendOutput, AllowOmitIfOptional, ExactReturn, OptionalArgIfUndefined } from "./types.js"; /** * A function that takes some input object, and an optional context object, and returns a * promise of an output. This is used as part of an {@linkcode AsyncObjectMapperSchema}. * @param input The input object. * @param context The context object. If the `TContext` type parameter is `undefined`, you can omit this argument. * @returns The output value, OR the special symbol {@linkcode OmitProperty}`, indicating that the property should be omitted * completely. */ export interface AsyncMapperFunction { (input: TInputSubset, context: OptionalArgIfUndefined): Promise | AllowOmitIfOptional>; } /** * A mapper function, or input property name, used in an {@linkcode AsyncObjectMapperSchema}. * * In an {@linkcode AsyncObjectMapperSchema}, each property value can be either: * - An {@linkcode AsyncMapperFunction} * - A property name from the input object. The property value must be compatible * with the output property. */ export type AsyncMapperSchemaValue = AsyncMapperFunction | AllowInputKeyIfInputCanExtendOutput; /** * An object, where every property name must match a property name in the desired output type. * Every property value must be a {@linkcode AsyncMapperSchemaValue}. * ``` */ export type AsyncObjectMapperSchema = { [TOutputKey in keyof TOutput]-?: AsyncMapperSchemaValue; }; /** * A callable function, equivalent to calling {@linkcode AsyncObjectMapper#map}. * It also exposes {@linkcode AsyncObjectMapperFunction#schema} as a readonly property. */ export interface AsyncObjectMapperFunction { (value: TInput, context: OptionalArgIfUndefined): Promise>; readonly schema: AsyncObjectMapperSchema; } //# sourceMappingURL=async-types.d.ts.map