/** * @since 1.0.0 */ import type { Brand } from 'effect/Brand'; import type * as Effect from 'effect/Effect'; import * as Option from 'effect/Option'; import * as ParseResult from 'effect/ParseResult'; import { type Pipeable } from 'effect/Pipeable'; import * as Schema from 'effect/Schema'; import type * as AST from 'effect/SchemaAST'; /** * @since 1.0.0 * @category type ids */ export declare const TypeId: unique symbol; /** * @since 1.0.0 * @category type ids */ export type TypeId = typeof TypeId; /** * @since 1.0.0 * @category models */ export interface Struct extends Pipeable { readonly [TypeId]: A; } /** * @since 1.0.0 * @category guards */ export declare const isStruct: (u: unknown) => u is Struct; /** * @since 1.0.0 * @category models */ export declare namespace Struct { /** * @since 1.0.0 * @category models */ type Any = { readonly [TypeId]: any; }; /** * @since 1.0.0 * @category models */ type Fields = { readonly [key: string]: Schema.Schema.All | Schema.PropertySignature.All | Field | Struct | undefined; }; /** * @since 1.0.0 * @category models */ type Validate = { readonly [K in keyof A]: A[K] extends { readonly [TypeId]: infer _; } ? Validate : A[K] extends Field ? [keyof Config] extends [Variant] ? {} : 'field must have valid variants' : {}; }; } /** * @since 1.0.0 * @category type ids */ export declare const FieldTypeId: unique symbol; /** * @since 1.0.0 * @category type ids */ export type FieldTypeId = typeof FieldTypeId; /** * @since 1.0.0 * @category models */ export interface Field extends Pipeable { readonly [FieldTypeId]: FieldTypeId; readonly schemas: A; } /** * @since 1.0.0 * @category guards */ export declare const isField: (u: unknown) => u is Field; /** * @since 1.0.0 * @category models */ export declare namespace Field { /** * @since 1.0.0 * @category models */ type Any = { readonly [FieldTypeId]: FieldTypeId; }; /** * @since 1.0.0 * @category models */ type ValueAny = Schema.Schema.All | Schema.PropertySignature.All; /** * @since 1.0.0 * @category models */ type Config = { readonly [key: string]: Schema.Schema.All | Schema.PropertySignature.All | undefined; }; /** * @since 1.0.0 * @category models */ type ConfigWithKeys = { readonly [P in K]?: Schema.Schema.All | Schema.PropertySignature.All; }; /** * @since 1.0.0 * @category models */ type Fields = { readonly [key: string]: Schema.Schema.All | Schema.PropertySignature.All | Field | Struct | undefined; }; } /** * @since 1.0.0 * @category extractors */ export type ExtractFields = { readonly [K in keyof Fields as [Fields[K]] extends [Field] ? V extends keyof Config ? K : never : K]: [Fields[K]] extends [Struct] ? Extract : [Fields[K]] extends [Field] ? [Config[V]] extends [Schema.Schema.All | Schema.PropertySignature.All] ? Config[V] : never : [Fields[K]] extends [Schema.Schema.All | Schema.PropertySignature.All] ? Fields[K] : never; }; /** * @since 1.0.0 * @category extractors */ export type Extract, IsDefault = false> = [A] extends [Struct] ? IsDefault extends true ? [A] extends [Schema.Schema.Any] ? A : Schema.Struct>> : Schema.Struct>> : never; /** * @category accessors * @since 1.0.0 */ export declare const fields: >(self: A) => A[TypeId]; type RequiredKeys = { [K in keyof T]-?: {} extends Pick ? never : K; }[keyof T]; /** * @since 1.0.0 * @category models */ export interface Class extends Schema.Schema, R>, Struct { new (props: RequiredKeys extends never ? void | Schema.Simplify : Schema.Simplify, options?: { readonly disableValidation?: boolean; }): A; readonly ast: AST.Transformation; make, X>(this: { new (...args: Args): X; }, ...args: Args): X; annotations(annotations: Schema.Annotations.Schema): Schema.SchemaClass, R>; readonly identifier: string; readonly fields: SchemaFields; } type ClassFromFields = Class, Schema.Struct.Encoded, Schema.Struct.Context, Schema.Struct.Constructor>; type MissingSelfGeneric = `Missing \`Self\` generic - use \`class Self extends Class()(${Params}{ ... })\``; /** * @since 1.0.0 * @category models */ export interface Union>> extends Schema.Union<{ readonly [K in keyof Members]: [Members[K]] extends [Schema.Schema.All] ? Members[K] : never; }> { } /** * @since 1.0.0 * @category models */ export declare namespace Union { /** * @since 1.0.0 * @category models */ type Variants>, Variants extends string> = { readonly [Variant in Variants]: Schema.Union<{ [K in keyof Members]: Extract; }>; }; } /** * @since 1.0.0 * @category models */ export interface fromKey extends Schema.PropertySignature<':', Schema.Schema.Type, Key, ':', Schema.Schema.Encoded, false, Schema.Schema.Context> { } /** * @since 1.0.0 * @category models */ export declare namespace fromKey { /** * @since 1.0.0 */ type Rename = S extends Schema.PropertySignature ? Schema.PropertySignature<_TypeToken, _Type, Key, _EncodedToken, _Encoded, _HasDefault, _R> : S extends Schema.Schema.All ? fromKey : never; } /** * @since 1.0.0 * @category constructors */ export declare const make: , const Default extends Variants[number]>(options: { readonly variants: Variants; readonly defaultVariant: Default; }) => { readonly Struct: (fields: A & Struct.Validate) => Struct; readonly Field: >(config: A & { readonly [K in Exclude]: never; }) => Field; readonly FieldOnly: >(...keys: Keys) => (schema: S) => Field<{ readonly [K in Keys[number]]: S; }>; readonly FieldExcept: >(...keys: Keys) => (schema: S) => Field<{ readonly [K in Exclude]: S; }>; readonly fieldEvolve: { | Field.ValueAny, const Mapping extends Self extends Field ? { readonly [K in keyof S]?: (variant: S[K]) => Field.ValueAny; } : { readonly [K in Variants[number]]?: (variant: Self) => Field.ValueAny; }>(f: Mapping): (self: Self) => Field ? { readonly [K in keyof S]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType : S[K] : S[K]; } : { readonly [K in Variants[number]]: K extends keyof Mapping ? Mapping[K] extends (arg: any) => any ? ReturnType : Self : Self; }>; | Field.ValueAny, const Mapping_1 extends Self extends Field ? { readonly [K in keyof S]?: (variant: S[K]) => Field.ValueAny; } : { readonly [K in Variants[number]]?: (variant: Self) => Field.ValueAny; }>(self: Self, f: Mapping_1): Field ? { readonly [K in keyof S]: K extends keyof Mapping_1 ? Mapping_1[K] extends (arg: any) => any ? ReturnType : S[K] : S[K]; } : { readonly [K in Variants[number]]: K extends keyof Mapping_1 ? Mapping_1[K] extends (arg: any) => any ? ReturnType : Self : Self; }>; }; readonly fieldFromKey: { | Field.ValueAny, const Mapping_2 extends Self extends Field ? { readonly [K in keyof S]?: string; } : { readonly [K in Variants[number]]?: string; }>(mapping: Mapping_2): (self: Self) => Field ? { readonly [K in keyof S]: K extends keyof Mapping_2 ? Mapping_2[K] extends string ? fromKey.Rename : S[K] : S[K]; } : { readonly [K in Variants[number]]: K extends keyof Mapping_2 ? Mapping_2[K] extends string ? fromKey.Rename : Self : Self; }>; | Field.ValueAny, const Mapping_3 extends Self extends Field ? { readonly [K in keyof S]?: string; } : { readonly [K in Variants[number]]?: string; }>(self: Self, mapping: Mapping_3): Field ? { readonly [K in keyof S]: K extends keyof Mapping_3 ? Mapping_3[K] extends string ? fromKey.Rename : S[K] : S[K]; } : { readonly [K in Variants[number]]: K extends keyof Mapping_3 ? Mapping_3[K] extends string ? fromKey.Rename : Self : Self; }>; }; readonly Class: (identifier: string) => (fields: Fields & Struct.Validate, annotations?: Schema.Annotations.Schema) => [Self] extends [never] ? MissingSelfGeneric : ClassFromFields>> & { readonly [V in Variants[number]]: Extract>; }; readonly Union: >>(...members: Members) => Union & Union.Variants; readonly extract: { (variant: V): >(self: A) => Extract; >(self: A, variant: V): Extract; }; }; /** * @since 1.0.0 * @category overrideable */ export declare const Override: (value: A) => A & Brand<"Override">; /** * @since 1.0.0 * @category overrideable */ export interface Overrideable extends Schema.PropertySignature<':', (To & Brand<'Override'>) | undefined, never, ':', From, true, R> { } /** * @since 1.0.0 * @category overrideable */ export declare const Overrideable: (from: Schema.Schema, to: Schema.Schema, options: { readonly generate: (_: Option.Option) => Effect.Effect; }) => Overrideable; export {}; //# sourceMappingURL=variant-schema.d.ts.map