import type { InvokeFunction, InvokeMethod } from "../client"; /** * @public * * This type is intended as a type helper for generated clients. * When initializing client, cast it to this type by passing * the client constructor type as the type parameter. * * It will then recursively remove "undefined" as a union type from all * input and output shapes' members. Note, this does not affect * any member that is optional (?) such as outputs with no required members. * * @example * ```ts * const client = new Client({}) as AssertiveClient; * ``` */ export type AssertiveClient = NarrowClientIOTypes; /** * @public * * This is similar to AssertiveClient but additionally changes all * output types to (recursive) Required so as to bypass all output nullability guards. */ export type UncheckedClient = UncheckedClientOutputTypes; /** * @internal * * Excludes undefined recursively. */ export type NoUndefined = T extends Function ? T : [T] extends [object] ? { [key in keyof T]: NoUndefined; } : Exclude; /** * @internal * * Excludes undefined and optional recursively. */ export type RecursiveRequired = T extends Function ? T : [T] extends [object] ? { [key in keyof T]-?: RecursiveRequired; } : Exclude; /** * @internal * * Removes undefined from unions. */ type NarrowClientIOTypes = { [key in keyof ClientType]: [ClientType[key]] extends [ InvokeFunction ] ? InvokeFunction, NoUndefined, ConfigType> : [ClientType[key]] extends [InvokeMethod] ? InvokeMethod, NoUndefined> : ClientType[key]; }; /** * @internal * * Removes undefined from unions and adds yolo output types. */ type UncheckedClientOutputTypes = { [key in keyof ClientType]: [ClientType[key]] extends [ InvokeFunction ] ? InvokeFunction, RecursiveRequired, ConfigType> : [ClientType[key]] extends [InvokeMethod] ? InvokeMethod, RecursiveRequired> : ClientType[key]; }; export {};