import type { ArbitrarySize, ConstExpr } from '@skyleague/axioms'; import type { Simplify } from '@skyleague/axioms/types'; import type { Shape } from '../../../../examples/runtypes/shapes.type.js'; import type { GenericOutput, ThereforeExpr, TypescriptOutput } from '../../cst/cst.js'; import { NodeTrait } from '../../cst/mixin.js'; import type { Node } from '../../cst/node.js'; import type { SchemaOptions } from '../base.js'; import { EnumType } from '../enum/enum.js'; import { OptionalType } from '../optional/optional.js'; export type ObjectShape = Record> = { [K in keyof Shape]: ConstExpr; }; type UndefinedToOptional = { [K in keyof T as undefined extends T[K] ? K : never]?: T[K]; }; type _ShapeToInferred = Simplify> & UndefinedToOptional>; export type ShapeToInfer> = _ShapeToInferred<{ [K in keyof Shape]: Shape[K]['infer']; }>; export type ShapeToInput> = _ShapeToInferred<{ [K in keyof Shape]: Shape[K]['input']; }>; export type ShapeToPartial, Keys extends [...(keyof Shape)[]]> = Keys extends { length: 0; } ? { [K in keyof Shape]: OptionalType; } : { [K in keyof Shape]: [K] extends Keys ? OptionalType : Shape[K]; }; export type ShapeToRequired, Keys extends [...(keyof Shape)[]]> = Keys extends { length: 0; } ? { [K in keyof Shape]: Shape[K] extends OptionalType ? T : Shape[K]; } : { [K in keyof Shape]: [K] extends Keys ? (Shape[K] extends OptionalType ? T : Shape[K]) : Shape[K]; }; export interface ObjectOptions { /** * Throw an error if the object has unknown additional properties. * * @default false */ strict?: boolean | undefined; arbitrary?: { size?: ArbitrarySize; } | undefined; } export declare class ObjectType = Record> extends NodeTrait { _type: "object"; _children: Node[]; _options: ObjectOptions; shape: { [K in keyof Shape]: Shape[K]; }; protected element?: Node | undefined; protected key?: Node | undefined; protected patternProperties?: Record | undefined; protected _omitted?: { mask: (keyof Shape)[]; origin: ObjectType; }; protected _picked?: { mask: (keyof Shape)[]; origin: ObjectType; }; protected _extended?: { origin: ObjectType; extends: Shape; }; _isCommutative: boolean; infer: ShapeToInfer; input: ShapeToInput; constructor(shape: ObjectShape, options: SchemaOptions>); strict(strict?: boolean): this; keyof(): EnumType<(keyof Shape)[]>; extend>(extra: ObjectShape): ObjectType>; merge(other: Other): ObjectType>; pick(...properties: Key[]): ObjectType>>; omit(...properties: Key[]): ObjectType>>; partial(...properties: Keys): ObjectType>; required(...properties: Keys): ObjectType>; get _output(): (TypescriptOutput | GenericOutput)[]; _from({ shape, recordType, patternProperties, }: { shape?: ObjectShape; recordType?: ThereforeExpr | undefined; patternProperties?: Record | undefined; }): void; } export declare class _OmitType extends ObjectType { _omitted?: { mask: string[]; origin: ObjectType; }; } export declare class _PickType extends ObjectType { _picked: { mask: (keyof Shape)[]; origin: ObjectType; }; } export declare class _ExtendType extends ObjectType { _extended?: { extends: ObjectType['shape']; origin: ObjectType; }; } /** * Create a new `ObjectType` instance with the given options. * * ### Example * ```ts * $object({ * foo: $string * bar: $integer * }) * ``` * * @param properties - Key value pairs that define the object. * @param options - Additional options to pass to the number. * * @group Primitives */ export declare function $object>(properties: ObjectShape, options?: SchemaOptions>>): ObjectType; export {};