This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Retrieves the default values for a given Zod schema. | |
| * @param schema The Zod schema for which to retrieve the default values. | |
| * @param defaults A partial object containing default values for the schema. | |
| * @param discriminant The discriminant value for discriminated unions. | |
| * @returns An object containing the default values for the schema, or `undefined` if no defaults are found. | |
| */ | |
| export function getZodDefaults<T extends z.ZodType>(schema: T, defaults?: Partial<T['_output']>, discriminant?: string): T['_output'] | undefined { | |
| if (schema instanceof z.ZodDefault) { | |
| const def = schema.def.defaultValue |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Catches errors from a promise. | |
| * @param promise The promise to handle. | |
| * @param options Additional options for handling the promise. | |
| * @returns A tuple with either the error or the result of the promise. | |
| * @throws Will rethrow the error if it is not in the `errorsToCatch` array. | |
| */ | |
| export async function tryCatch<T = any, E extends new (...args: any[]) => Error = ErrorConstructor>( | |
| promise: Promise<T>, | |
| options?: { |