import { type AnyFunction, type AnyObject, type IsAny, type IsUnknown } from '@augment-vir/common'; import { type Static, type TArray, type TBigInt, type TBoolean, type TNull, type TNumber, type TObject, type TSchema, type TString, type TSymbol, type TUndefined, type TUnsafe } from '@sinclair/typebox'; import { type TypeCheck } from '@sinclair/typebox/compiler'; /** * Output of {@link defineShape}. * * @category Internal */ export type Shape = { default: ShapeInitDefault; $_schema: ShapeInitSchema; $_schemaNoExtraKeys: ShapeInitSchema; $_schemaExtraKeys: ShapeInitSchema; $_compiledSchema: TypeCheck; $_compiledSchemaNoExtraKeys: TypeCheck; $_compiledSchemaExtraKeys: TypeCheck; runtimeType: ShapeInitType; }; /** * A special key string which is used to tag {@link Shape} instances so that we know they're shapes * instead of part of the shape itself. * * We don't use `instanceof` with a Class constructor for this because that breaks when you have * multiple versions of object-shape-tester defining and consuming shapes. * * @category Internal */ export declare const shapeIdentifier: unique symbol; /** * A type for defining a shape definition with a direct type definition. * * @category Internal */ export type UnsafeShape = Shape>; /** * A helper for defining a shape while also immediately providing the type for that shape's values. * * @category Internal */ export declare function unsafeShape(init: any): UnsafeShape; /** * Defines a shape from the given init. * * @category Define */ export declare function defineShape(init: Init): Shape; /** * Checks if `input` is a Shape. * * @category Internal */ export declare function isShape(input: unknown): input is Shape; /** * Checks if `input` is a TSchema. * * @category Internal */ export declare function isSchema(input: unknown): input is TSchema; /** * Converts the shape init to a TSchema. * * @category Internal */ export declare function shapeInitToSchema(init: unknown): TSchema; /** * Converts a shape init into its runtime type. * * @category Internal */ export type ShapeInitType = IsAny extends true ? any : IsUnknown extends true ? any : Init extends Shape ? Init['runtimeType'] : Static>; /** * Converts a shape init into its default value type. * * @category Internal */ export type ShapeInitDefault = IsAny extends true ? any : IsUnknown extends true ? any : Readonly>>; /** * Converts a shape init into its schema type. * * @category Internal */ export type ShapeInitSchema = IsAny extends true ? any : IsUnknown extends true ? any : Init extends TSchema ? Init : Init extends { $_schema: infer InnerSchema extends TSchema; } ? InnerSchema : Init extends AnyFunction ? TUnsafe : Init extends string ? TString : Init extends number ? TNumber : Init extends boolean ? TBoolean : Init extends symbol ? TSymbol : Init extends null ? TNull : Init extends undefined ? TUndefined : Init extends bigint ? TBigInt : Init extends ReadonlyArray ? TArray> : Init extends AnyObject ? TObject<{ [Key in keyof Init]: ShapeInitSchema; }> : never;