effect
Version:
The missing standard library for TypeScript, for writing production-grade software.
1,339 lines • 182 kB
TypeScript
/**
* @since 3.10.0
*/
import type { StandardSchemaV1 } from "@standard-schema/spec";
import type { ArbitraryAnnotation, LazyArbitrary } from "./Arbitrary.js";
import * as array_ from "./Array.js";
import * as bigDecimal_ from "./BigDecimal.js";
import type { Brand } from "./Brand.js";
import * as cause_ from "./Cause.js";
import * as chunk_ from "./Chunk.js";
import * as config_ from "./Config.js";
import * as dateTime from "./DateTime.js";
import * as duration_ from "./Duration.js";
import * as Effect from "./Effect.js";
import * as either_ from "./Either.js";
import * as Equivalence from "./Equivalence.js";
import * as exit_ from "./Exit.js";
import * as fiberId_ from "./FiberId.js";
import type { LazyArg } from "./Function.js";
import * as hashMap_ from "./HashMap.js";
import * as hashSet_ from "./HashSet.js";
import * as list_ from "./List.js";
import * as option_ from "./Option.js";
import type * as Order from "./Order.js";
import * as ParseResult from "./ParseResult.js";
import type { Pipeable } from "./Pipeable.js";
import type * as pretty_ from "./Pretty.js";
import * as redacted_ from "./Redacted.js";
import * as Request from "./Request.js";
import type { ParseOptions } from "./SchemaAST.js";
import * as AST from "./SchemaAST.js";
import * as sortedSet_ from "./SortedSet.js";
import type * as Types from "./Types.js";
/**
* @since 3.10.0
*/
export type Simplify<A> = {
[K in keyof A]: A[K];
} & {};
/**
* @since 3.10.0
*/
export type SimplifyMutable<A> = {
-readonly [K in keyof A]: A[K];
} extends infer B ? B : never;
/**
* @since 3.10.0
* @category symbol
*/
export declare const TypeId: unique symbol;
/**
* @since 3.10.0
* @category symbol
*/
export type TypeId = typeof TypeId;
/**
* @category model
* @since 3.10.0
*/
export interface Schema<in out A, in out I = A, out R = never> extends Schema.Variance<A, I, R>, Pipeable {
readonly Type: A;
readonly Encoded: I;
readonly Context: R;
readonly ast: AST.AST;
/**
* Merges a set of new annotations with existing ones, potentially overwriting
* any duplicates.
*/
annotations(annotations: Annotations.GenericSchema<A>): Schema<A, I, R>;
}
/**
* @category annotations
* @since 3.10.0
*/
export interface Annotable<Self extends Schema<A, I, R>, A, I = A, R = never> extends Schema<A, I, R> {
annotations(annotations: Annotations.GenericSchema<A>): Self;
}
/**
* @category annotations
* @since 3.10.0
*/
export interface AnnotableClass<Self extends Schema<A, I, R>, A, I = A, R = never> extends Annotable<Self, A, I, R> {
new (_: never): Schema.Variance<A, I, R>;
}
/**
* @category model
* @since 3.10.0
*/
export interface SchemaClass<A, I = A, R = never> extends AnnotableClass<SchemaClass<A, I, R>, A, I, R> {
}
/**
* @category constructors
* @since 3.10.0
*/
export declare function make<A, I = A, R = never>(ast: AST.AST): SchemaClass<A, I, R>;
/**
* Returns a "Standard Schema" object conforming to the [Standard Schema
* v1](https://standardschema.dev/) specification.
*
* This function creates a schema whose `validate` method attempts to decode and
* validate the provided input synchronously. If the underlying `Schema`
* includes any asynchronous components (e.g., asynchronous message resolutions
* or checks), then validation will necessarily return a `Promise` instead.
*
* Any detected defects will be reported via a single issue containing no
* `path`.
*
* @example
* ```ts
* import { Schema } from "effect"
*
* const schema = Schema.Struct({
* name: Schema.String
* })
*
* // ┌─── StandardSchemaV1<{ readonly name: string; }>
* // ▼
* const standardSchema = Schema.standardSchemaV1(schema)
* ```
*
* @category Standard Schema
* @since 3.13.0
*/
export declare const standardSchemaV1: <A, I>(schema: Schema<A, I, never>) => StandardSchemaV1<I, A>;
/**
* @category annotations
* @since 3.10.0
*/
export declare namespace Annotable {
/**
* @since 3.10.0
*/
type Self<S extends All> = ReturnType<S["annotations"]>;
/**
* @since 3.10.0
*/
type Any = Annotable<any, any, any, unknown>;
/**
* @since 3.10.0
*/
type All = Any | Annotable<any, any, never, unknown> | Annotable<any, never, any, unknown> | Annotable<any, never, never, unknown>;
}
/**
* @since 3.10.0
*/
export declare function asSchema<S extends Schema.All>(schema: S): Schema<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>>;
/**
* @category formatting
* @since 3.10.0
*/
export declare const format: <S extends Schema.All>(schema: S) => string;
/**
* @since 3.10.0
*/
export declare namespace Schema {
/**
* @since 3.10.0
*/
interface Variance<A, I, R> {
readonly [TypeId]: {
readonly _A: Types.Invariant<A>;
readonly _I: Types.Invariant<I>;
readonly _R: Types.Covariant<R>;
};
}
/**
* @since 3.10.0
*/
type Type<S> = S extends Schema.Variance<infer A, infer _I, infer _R> ? A : never;
/**
* @since 3.10.0
*/
type Encoded<S> = S extends Schema.Variance<infer _A, infer I, infer _R> ? I : never;
/**
* @since 3.10.0
*/
type Context<S> = S extends Schema.Variance<infer _A, infer _I, infer R> ? R : never;
/**
* @since 3.10.0
*/
type ToAsserts<S extends AnyNoContext> = (input: unknown, options?: AST.ParseOptions) => asserts input is Schema.Type<S>;
/**
* Any schema, except for `never`.
*
* @since 3.10.0
*/
type Any = Schema<any, any, unknown>;
/**
* Any schema with `Context = never`, except for `never`.
*
* @since 3.10.0
*/
type AnyNoContext = Schema<any, any, never>;
/**
* Any schema, including `never`.
*
* @since 3.10.0
*/
type All = Any | Schema<any, never, unknown> | Schema<never, any, unknown> | Schema<never, never, unknown>;
/**
* Type-level counterpart of `Schema.asSchema` function.
*
* @since 3.10.0
*/
type AsSchema<S extends All> = Schema<Type<S>, Encoded<S>, Context<S>>;
}
/**
* The `encodedSchema` function allows you to extract the `Encoded` portion of a
* schema, creating a new schema that conforms to the properties defined in the
* original schema without retaining any refinements or transformations that
* were applied previously.
*
* @since 3.10.0
*/
export declare const encodedSchema: <A, I, R>(schema: Schema<A, I, R>) => SchemaClass<I>;
/**
* The `encodedBoundSchema` function is similar to `encodedSchema` but preserves
* the refinements up to the first transformation point in the original schema.
*
* @since 3.10.0
*/
export declare const encodedBoundSchema: <A, I, R>(schema: Schema<A, I, R>) => SchemaClass<I>;
/**
* The `typeSchema` function allows you to extract the `Type` portion of a
* schema, creating a new schema that conforms to the properties defined in the
* original schema without considering the initial encoding or transformation
* processes.
*
* @since 3.10.0
*/
export declare const typeSchema: <A, I, R>(schema: Schema<A, I, R>) => SchemaClass<A>;
export {
/**
* By default the option `exact` is set to `true`.
*
* @throws `ParseError`
* @category validation
* @since 3.10.0
*/
asserts,
/**
* @category decoding
* @since 3.10.0
*/
decodeOption,
/**
* @throws `ParseError`
* @category decoding
* @since 3.10.0
*/
decodeSync,
/**
* @category decoding
* @since 3.10.0
*/
decodeUnknownOption,
/**
* @throws `ParseError`
* @category decoding
* @since 3.10.0
*/
decodeUnknownSync,
/**
* @category encoding
* @since 3.10.0
*/
encodeOption,
/**
* @throws `ParseError`
* @category encoding
* @since 3.10.0
*/
encodeSync,
/**
* @category encoding
* @since 3.10.0
*/
encodeUnknownOption,
/**
* @throws `ParseError`
* @category encoding
* @since 3.10.0
*/
encodeUnknownSync,
/**
* By default the option `exact` is set to `true`.
*
* @category validation
* @since 3.10.0
*/
is,
/**
* @category validation
* @since 3.10.0
*/
validateOption,
/**
* @throws `ParseError`
* @category validation
* @since 3.10.0
*/
validateSync } from "./ParseResult.js";
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknown: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<I, ParseResult.ParseError, R>;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either<I, ParseResult.ParseError>;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeUnknownPromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise<I>;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encode: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Effect.Effect<I, ParseResult.ParseError, R>;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodeEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => either_.Either<I, ParseResult.ParseError>;
/**
* @category encoding
* @since 3.10.0
*/
export declare const encodePromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Promise<I>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknown: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<A, ParseResult.ParseError, R>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either<A, ParseResult.ParseError>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeUnknownPromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise<A>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decode: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Effect.Effect<A, ParseResult.ParseError, R>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodeEither: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => either_.Either<A, ParseResult.ParseError>;
/**
* @category decoding
* @since 3.10.0
*/
export declare const decodePromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Promise<A>;
/**
* @category validation
* @since 3.10.0
*/
export declare const validate: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect<A, ParseResult.ParseError, R>;
/**
* @category validation
* @since 3.10.0
*/
export declare const validateEither: <A, I, R>(schema: Schema<A, I, R>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either<A, ParseResult.ParseError>;
/**
* @category validation
* @since 3.10.0
*/
export declare const validatePromise: <A, I>(schema: Schema<A, I, never>, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise<A>;
/**
* Tests if a value is a `Schema`.
*
* @category guards
* @since 3.10.0
*/
export declare const isSchema: (u: unknown) => u is Schema.Any;
/**
* @category api interface
* @since 3.10.0
*/
export interface Literal<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>> extends AnnotableClass<Literal<Literals>, Literals[number]> {
readonly literals: Readonly<Literals>;
}
/**
* @category constructors
* @since 3.10.0
*/
export declare function Literal<Literals extends array_.NonEmptyReadonlyArray<AST.LiteralValue>>(...literals: Literals): Literal<Literals>;
export declare function Literal(): Never;
export declare function Literal<Literals extends ReadonlyArray<AST.LiteralValue>>(...literals: Literals): SchemaClass<Literals[number]>;
/**
* Creates a new `Schema` from a literal schema.
*
* @example
* ```ts
* import * as Schema from "effect/Schema"
* import { Either } from "effect"
*
* const schema = Schema.Literal("a", "b", "c").pipe(Schema.pickLiteral("a", "b"))
*
* assert.deepStrictEqual(Schema.decodeSync(schema)("a"), "a")
* assert.deepStrictEqual(Schema.decodeSync(schema)("b"), "b")
* assert.strictEqual(Either.isLeft(Schema.decodeUnknownEither(schema)("c")), true)
* ```
*
* @category constructors
* @since 3.10.0
*/
export declare const pickLiteral: <A extends AST.LiteralValue, L extends array_.NonEmptyReadonlyArray<A>>(...literals: L) => <I, R>(_schema: Schema<A, I, R>) => Literal<[...L]>;
/**
* @category constructors
* @since 3.10.0
*/
export declare const UniqueSymbolFromSelf: <S extends symbol>(symbol: S) => SchemaClass<S>;
/**
* @category api interface
* @since 3.10.0
*/
export interface Enums<A extends EnumsDefinition> extends AnnotableClass<Enums<A>, A[keyof A]> {
readonly enums: A;
}
/**
* @since 3.10.0
*/
export type EnumsDefinition = {
[x: string]: string | number;
};
/**
* @category constructors
* @since 3.10.0
*/
export declare const Enums: <A extends EnumsDefinition>(enums: A) => Enums<A>;
type AppendType<Template extends string, Next> = Next extends AST.LiteralValue ? `${Template}${Next}` : Next extends Schema<infer A extends AST.LiteralValue, infer _I, infer _R> ? `${Template}${A}` : never;
type GetTemplateLiteralType<Params> = Params extends [...infer Init, infer Last] ? AppendType<GetTemplateLiteralType<Init>, Last> : ``;
/**
* @category API interface
* @since 3.10.0
*/
export interface TemplateLiteral<A> extends SchemaClass<A> {
}
type TemplateLiteralParameter = Schema.AnyNoContext | AST.LiteralValue;
/**
* @category template literal
* @since 3.10.0
*/
export declare const TemplateLiteral: <Params extends array_.NonEmptyReadonlyArray<TemplateLiteralParameter>>(...[head, ...tail]: Params) => TemplateLiteral<GetTemplateLiteralType<Params>>;
type TemplateLiteralParserParameters = Schema.Any | AST.LiteralValue;
type GetTemplateLiteralParserType<Params> = Params extends [infer Head, ...infer Tail] ? readonly [
Head extends Schema<infer A, infer _I, infer _R> ? A : Head,
...GetTemplateLiteralParserType<Tail>
] : [];
type AppendEncoded<Template extends string, Next> = Next extends AST.LiteralValue ? `${Template}${Next}` : Next extends Schema<infer _A, infer I extends AST.LiteralValue, infer _R> ? `${Template}${I}` : never;
type GetTemplateLiteralParserEncoded<Params> = Params extends [...infer Init, infer Last] ? AppendEncoded<GetTemplateLiteralParserEncoded<Init>, Last> : ``;
/**
* @category API interface
* @since 3.10.0
*/
export interface TemplateLiteralParser<Params extends array_.NonEmptyReadonlyArray<TemplateLiteralParserParameters>> extends Schema<GetTemplateLiteralParserType<Params>, GetTemplateLiteralParserEncoded<Params>, Schema.Context<Params[number]>> {
readonly params: Params;
}
/**
* @category template literal
* @since 3.10.0
*/
export declare const TemplateLiteralParser: <Params extends array_.NonEmptyReadonlyArray<TemplateLiteralParserParameters>>(...params: Params) => TemplateLiteralParser<Params>;
/**
* @category api interface
* @since 3.13.3
*/
export interface declare<A, I = A, P extends ReadonlyArray<Schema.All> = readonly [], R = Schema.Context<P[number]>> extends AnnotableClass<declare<A, I, P, R>, A, I, R> {
readonly typeParameters: Readonly<P>;
}
/**
* @category api interface
* @since 3.13.3
*/
export interface AnnotableDeclare<Self extends declare<A, I, P, R>, A, I = A, P extends ReadonlyArray<Schema.All> = readonly [], R = Schema.Context<P[number]>> extends declare<A, I, P, R> {
annotations(annotations: Annotations.Schema<A>): Self;
}
/**
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
*
* @category constructors
* @since 3.10.0
*/
export declare const declare: {
/**
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
*
* @category constructors
* @since 3.10.0
*/
<A>(is: (input: unknown) => input is A, annotations?: Annotations.Schema<A>): declare<A>;
/**
* The constraint `R extends Schema.Context<P[number]>` enforces dependencies solely from `typeParameters`.
* This ensures that when you call `Schema.to` or `Schema.from`, you receive a schema with a `never` context.
*
* @category constructors
* @since 3.10.0
*/
<A, I, const P extends ReadonlyArray<Schema.All>>(typeParameters: P, options: {
readonly decode: (...typeParameters: {
readonly [K in keyof P]: Schema<Schema.Type<P[K]>, Schema.Encoded<P[K]>, never>;
}) => (input: unknown, options: ParseOptions, ast: AST.Declaration) => Effect.Effect<A, ParseResult.ParseIssue, never>;
readonly encode: (...typeParameters: {
readonly [K in keyof P]: Schema<Schema.Type<P[K]>, Schema.Encoded<P[K]>, never>;
}) => (input: unknown, options: ParseOptions, ast: AST.Declaration) => Effect.Effect<I, ParseResult.ParseIssue, never>;
}, annotations?: Annotations.Schema<A, {
readonly [K in keyof P]: Schema.Type<P[K]>;
}>): declare<A, I, P>;
};
/**
* @category schema id
* @since 3.10.0
*/
export declare const BrandSchemaId: unique symbol;
/**
* @category constructors
* @since 3.10.0
*/
export declare const fromBrand: <C extends Brand<string | symbol>, A extends Brand.Unbranded<C>>(constructor: Brand.Constructor<C>, annotations?: Annotations.Filter<C, A>) => <I, R>(self: Schema<A, I, R>) => BrandSchema<A & C, I, R>;
/**
* @category schema id
* @since 3.10.0
*/
export declare const InstanceOfSchemaId: unique symbol;
/**
* @category api interface
* @since 3.10.0
*/
export interface instanceOf<A> extends AnnotableDeclare<instanceOf<A>, A> {
}
/**
* @category constructors
* @since 3.10.0
*/
export declare const instanceOf: <A extends abstract new (...args: any) => any>(constructor: A, annotations?: Annotations.Schema<InstanceType<A>>) => instanceOf<InstanceType<A>>;
declare const Undefined_base: SchemaClass<undefined, undefined, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Undefined extends Undefined_base {
}
declare const Void_base: SchemaClass<void, void, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Void extends Void_base {
}
declare const Null_base: SchemaClass<null, null, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Null extends Null_base {
}
declare const Never_base: SchemaClass<never, never, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Never extends Never_base {
}
declare const Unknown_base: SchemaClass<unknown, unknown, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Unknown extends Unknown_base {
}
declare const Any_base: SchemaClass<any, any, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class Any extends Any_base {
}
declare const BigIntFromSelf_base: SchemaClass<bigint, bigint, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class BigIntFromSelf extends BigIntFromSelf_base {
}
declare const SymbolFromSelf_base: SchemaClass<symbol, symbol, never>;
/**
* @category primitives
* @since 3.10.0
*/
export declare class SymbolFromSelf extends SymbolFromSelf_base {
}
declare const String$_base: SchemaClass<string, string, never>;
/** @ignore */
declare class String$ extends String$_base {
}
declare const Number$_base: SchemaClass<number, number, never>;
/** @ignore */
declare class Number$ extends Number$_base {
}
declare const Boolean$_base: SchemaClass<boolean, boolean, never>;
/** @ignore */
declare class Boolean$ extends Boolean$_base {
}
declare const Object$_base: SchemaClass<object, object, never>;
/** @ignore */
declare class Object$ extends Object$_base {
}
export {
/**
* @category primitives
* @since 3.10.0
*/
Boolean$ as Boolean,
/**
* @category primitives
* @since 3.10.0
*/
Number$ as Number,
/**
* @category primitives
* @since 3.10.0
*/
Object$ as Object,
/**
* @category primitives
* @since 3.10.0
*/
String$ as String };
/**
* @category api interface
* @since 3.10.0
*/
export interface Union<Members extends ReadonlyArray<Schema.All>> extends AnnotableClass<Union<Members>, Schema.Type<Members[number]>, Schema.Encoded<Members[number]>, Schema.Context<Members[number]>> {
readonly members: Readonly<Members>;
}
/**
* @category combinators
* @since 3.10.0
*/
export declare function Union<Members extends AST.Members<Schema.All>>(...members: Members): Union<Members>;
export declare function Union<Member extends Schema.All>(member: Member): Member;
export declare function Union(): typeof Never;
export declare function Union<Members extends ReadonlyArray<Schema.All>>(...members: Members): Schema<Schema.Type<Members[number]>, Schema.Encoded<Members[number]>, Schema.Context<Members[number]>>;
/**
* @category api interface
* @since 3.10.0
*/
export interface NullOr<S extends Schema.All> extends Union<[S, typeof Null]> {
annotations(annotations: Annotations.Schema<Schema.Type<S> | null>): NullOr<S>;
}
/**
* @category combinators
* @since 3.10.0
*/
export declare const NullOr: <S extends Schema.All>(self: S) => NullOr<S>;
/**
* @category api interface
* @since 3.10.0
*/
export interface UndefinedOr<S extends Schema.All> extends Union<[S, typeof Undefined]> {
annotations(annotations: Annotations.Schema<Schema.Type<S> | undefined>): UndefinedOr<S>;
}
/**
* @category combinators
* @since 3.10.0
*/
export declare const UndefinedOr: <S extends Schema.All>(self: S) => UndefinedOr<S>;
/**
* @category api interface
* @since 3.10.0
*/
export interface NullishOr<S extends Schema.All> extends Union<[S, typeof Null, typeof Undefined]> {
annotations(annotations: Annotations.Schema<Schema.Type<S> | null | undefined>): NullishOr<S>;
}
/**
* @category combinators
* @since 3.10.0
*/
export declare const NullishOr: <S extends Schema.All>(self: S) => NullishOr<S>;
/**
* @category combinators
* @since 3.10.0
*/
export declare const keyof: <A, I, R>(self: Schema<A, I, R>) => SchemaClass<keyof A>;
/**
* @since 3.10.0
*/
export declare namespace Element {
/**
* @since 3.10.0
*/
interface Annotations<A> extends Annotations.Doc<A> {
readonly missingMessage?: AST.MissingMessageAnnotation;
}
/**
* @since 3.10.0
*/
type Token = "" | "?";
}
/**
* @category API interface
* @since 3.10.0
*/
export interface Element<S extends Schema.Any, Token extends Element.Token> extends Schema.Variance<Schema.Type<S>, Schema.Encoded<S>, Schema.Context<S>> {
readonly _Token: Token;
readonly ast: AST.OptionalType;
readonly from: S;
annotations(annotations: Element.Annotations<Schema.Type<S>>): Element<S, Token>;
}
/**
* @since 3.10.0
*/
export declare const element: <S extends Schema.Any>(self: S) => Element<S, "">;
/**
* @since 3.10.0
*/
export declare const optionalElement: <S extends Schema.Any>(self: S) => Element<S, "?">;
/**
* @since 3.10.0
*/
export declare namespace TupleType {
type ElementsType<Elements, Out extends ReadonlyArray<any> = readonly []> = Elements extends readonly [infer Head, ...infer Tail] ? Head extends Element<infer T, "?"> ? ElementsType<Tail, readonly [...Out, Schema.Type<T>?]> : ElementsType<Tail, readonly [...Out, Schema.Type<Head>]> : Out;
type ElementsEncoded<Elements, Out extends ReadonlyArray<any> = readonly []> = Elements extends readonly [infer Head, ...infer Tail] ? Head extends Element<infer T, "?"> ? ElementsEncoded<Tail, readonly [...Out, Schema.Encoded<T>?]> : ElementsEncoded<Tail, readonly [...Out, Schema.Encoded<Head>]> : Out;
/**
* @since 3.10.0
*/
type Elements = ReadonlyArray<Schema.Any | Element<Schema.Any, Element.Token>>;
/**
* @since 3.10.0
*/
type Rest = ReadonlyArray<Schema.Any | Element<Schema.Any, "">>;
/**
* @since 3.10.0
*/
type Type<Elements extends TupleType.Elements, Rest extends TupleType.Rest> = Rest extends [
infer Head,
...infer Tail
] ? Readonly<[
...ElementsType<Elements>,
...ReadonlyArray<Schema.Type<Head>>,
...{
readonly [K in keyof Tail]: Schema.Type<Tail[K]>;
}
]> : ElementsType<Elements>;
/**
* @since 3.10.0
*/
type Encoded<Elements extends TupleType.Elements, Rest extends TupleType.Rest> = Rest extends [
infer Head,
...infer Tail
] ? Readonly<[
...ElementsEncoded<Elements>,
...ReadonlyArray<Schema.Encoded<Head>>,
...{
readonly [K in keyof Tail]: Schema.Encoded<Tail[K]>;
}
]> : ElementsEncoded<Elements>;
}
/**
* @category api interface
* @since 3.10.0
*/
export interface TupleType<Elements extends TupleType.Elements, Rest extends TupleType.Rest> extends AnnotableClass<TupleType<Elements, Rest>, TupleType.Type<Elements, Rest>, TupleType.Encoded<Elements, Rest>, Schema.Context<Elements[number]> | Schema.Context<Rest[number]>> {
readonly elements: Readonly<Elements>;
readonly rest: Readonly<Rest>;
}
/**
* @category api interface
* @since 3.10.0
*/
export interface Tuple<Elements extends TupleType.Elements> extends TupleType<Elements, []> {
annotations(annotations: Annotations.Schema<TupleType.Type<Elements, []>>): Tuple<Elements>;
}
/**
* @category api interface
* @since 3.13.3
*/
export interface Tuple2<Fst extends Schema.Any, Snd extends Schema.Any> extends AnnotableClass<Tuple2<Fst, Snd>, readonly [Schema.Type<Fst>, Schema.Type<Snd>], readonly [Schema.Encoded<Fst>, Schema.Encoded<Snd>], Schema.Context<Fst> | Schema.Context<Snd>> {
readonly elements: readonly [Fst, Snd];
readonly rest: readonly [];
}
/**
* @category constructors
* @since 3.10.0
*/
export declare function Tuple<const Elements extends TupleType.Elements, Rest extends array_.NonEmptyReadonlyArray<TupleType.Rest[number]>>(elements: Elements, ...rest: Rest): TupleType<Elements, Rest>;
export declare function Tuple<Fst extends Schema.Any, Snd extends Schema.Any>(fst: Fst, snd: Snd): Tuple2<Fst, Snd>;
export declare function Tuple<Elements extends TupleType.Elements>(...elements: Elements): Tuple<Elements>;
/**
* @category api interface
* @since 3.10.0
*/
export interface Array$<Value extends Schema.Any> extends TupleType<[], [Value]> {
readonly value: Value;
annotations(annotations: Annotations.Schema<TupleType.Type<[], [Value]>>): Array$<Value>;
}
declare const Array$: <Value extends Schema.Any>(value: Value) => Array$<Value>;
export {
/**
* @category constructors
* @since 3.10.0
*/
Array$ as Array };
/**
* @category api interface
* @since 3.10.0
*/
export interface NonEmptyArray<Value extends Schema.Any> extends AnnotableClass<NonEmptyArray<Value>, array_.NonEmptyReadonlyArray<Schema.Type<Value>>, array_.NonEmptyReadonlyArray<Schema.Encoded<Value>>, Schema.Context<Value>> {
readonly elements: readonly [Value];
readonly rest: readonly [Value];
readonly value: Value;
}
/**
* @category constructors
* @since 3.10.0
*/
export declare const NonEmptyArray: <Value extends Schema.Any>(value: Value) => NonEmptyArray<Value>;
/**
* @category api interface
* @since 3.10.0
*/
export interface ArrayEnsure<Value extends Schema.Any> extends transform<Union<[Value, Array$<Value>]>, Array$<SchemaClass<Schema.Type<Value>>>> {
}
/**
* @category constructors
* @since 3.10.0
*/
export declare function ArrayEnsure<Value extends Schema.Any>(value: Value): ArrayEnsure<Value>;
/**
* @category api interface
* @since 3.10.0
*/
export interface NonEmptyArrayEnsure<Value extends Schema.Any> extends transform<Union<[Value, NonEmptyArray<Value>]>, NonEmptyArray<SchemaClass<Schema.Type<Value>>>> {
}
/**
* @category constructors
* @since 3.10.0
*/
export declare function NonEmptyArrayEnsure<Value extends Schema.Any>(value: Value): NonEmptyArrayEnsure<Value>;
/**
* @since 3.10.0
*/
export declare namespace PropertySignature {
/**
* @since 3.10.0
*/
type Token = "?:" | ":";
/**
* @since 3.10.0
*/
type Any<Key extends PropertyKey = PropertyKey> = PropertySignature<Token, any, Key, Token, any, boolean, unknown>;
/**
* @since 3.10.0
*/
type All<Key extends PropertyKey = PropertyKey> = Any<Key> | PropertySignature<Token, never, Key, Token, any, boolean, unknown> | PropertySignature<Token, any, Key, Token, never, boolean, unknown> | PropertySignature<Token, never, Key, Token, never, boolean, unknown>;
/**
* @since 3.10.0
*/
type AST = PropertySignatureDeclaration | PropertySignatureTransformation;
/**
* @since 3.10.0
*/
interface Annotations<A> extends Annotations.Doc<A> {
readonly missingMessage?: AST.MissingMessageAnnotation;
}
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare class PropertySignatureDeclaration extends AST.OptionalType {
readonly isReadonly: boolean;
readonly defaultValue: (() => unknown) | undefined;
/**
* @since 3.10.0
*/
readonly _tag = "PropertySignatureDeclaration";
constructor(type: AST.AST, isOptional: boolean, isReadonly: boolean, annotations: AST.Annotations, defaultValue: (() => unknown) | undefined);
/**
* @since 3.10.0
*/
toString(): string;
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare class FromPropertySignature extends AST.OptionalType {
readonly isReadonly: boolean;
readonly fromKey?: PropertyKey | undefined;
constructor(type: AST.AST, isOptional: boolean, isReadonly: boolean, annotations: AST.Annotations, fromKey?: PropertyKey | undefined);
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare class ToPropertySignature extends AST.OptionalType {
readonly isReadonly: boolean;
readonly defaultValue: (() => unknown) | undefined;
constructor(type: AST.AST, isOptional: boolean, isReadonly: boolean, annotations: AST.Annotations, defaultValue: (() => unknown) | undefined);
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare class PropertySignatureTransformation {
readonly from: FromPropertySignature;
readonly to: ToPropertySignature;
readonly decode: AST.PropertySignatureTransformation["decode"];
readonly encode: AST.PropertySignatureTransformation["encode"];
/**
* @since 3.10.0
*/
readonly _tag = "PropertySignatureTransformation";
constructor(from: FromPropertySignature, to: ToPropertySignature, decode: AST.PropertySignatureTransformation["decode"], encode: AST.PropertySignatureTransformation["encode"]);
/**
* @since 3.10.0
*/
toString(): string;
}
/**
* @since 3.10.0
* @category symbol
*/
export declare const PropertySignatureTypeId: unique symbol;
/**
* @since 3.10.0
* @category symbol
*/
export type PropertySignatureTypeId = typeof PropertySignatureTypeId;
/**
* @since 3.10.0
* @category guards
*/
export declare const isPropertySignature: (u: unknown) => u is PropertySignature.All;
/**
* @category PropertySignature
* @since 3.10.0
*/
export interface PropertySignature<TypeToken extends PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never> extends Schema.Variance<Type, Encoded, R>, Pipeable {
readonly [PropertySignatureTypeId]: null;
readonly _TypeToken: TypeToken;
readonly _EncodedToken: EncodedToken;
readonly _HasDefault: HasDefault;
readonly _Key: Key;
readonly ast: PropertySignature.AST;
annotations(annotations: PropertySignature.Annotations<Type>): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;
}
declare class PropertySignatureImpl<TypeToken extends PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never> implements PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R> {
readonly ast: PropertySignature.AST;
readonly [TypeId]: Schema.Variance<Type, Encoded, R>[TypeId];
readonly [PropertySignatureTypeId]: null;
readonly _TypeToken: TypeToken;
readonly _Key: Key;
readonly _EncodedToken: EncodedToken;
readonly _HasDefault: HasDefault;
constructor(ast: PropertySignature.AST);
pipe(): unknown;
annotations(annotations: PropertySignature.Annotations<Type>): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;
toString(): string;
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare const makePropertySignature: <TypeToken extends PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, HasDefault extends boolean = false, R = never>(ast: PropertySignature.AST) => PropertySignatureImpl<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;
/**
* @category API interface
* @since 1.0.0
*/
export interface propertySignature<S extends Schema.All> extends PropertySignature<":", Schema.Type<S>, never, ":", Schema.Encoded<S>, false, Schema.Context<S>> {
readonly from: S;
annotations(annotations: PropertySignature.Annotations<Schema.Type<S>>): propertySignature<S>;
}
/**
* Lifts a `Schema` into a `PropertySignature`.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const propertySignature: <S extends Schema.All>(self: S) => propertySignature<S>;
/**
* Enhances a property signature with a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const withConstructorDefault: {
/**
* Enhances a property signature with a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type>(defaultValue: () => Types.NoInfer<Type>): <TypeToken extends PropertySignature.Token, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, R>(self: PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, boolean, R>) => PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, true, R>;
/**
* Enhances a property signature with a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
<TypeToken extends PropertySignature.Token, Type, Key extends PropertyKey, EncodedToken extends PropertySignature.Token, Encoded, R>(self: PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, boolean, R>, defaultValue: () => Types.NoInfer<Type>): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, true, R>;
};
/**
* Enhances a property signature with a default decoding value.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const withDecodingDefault: {
/**
* Enhances a property signature with a default decoding value.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type>(defaultValue: () => Types.NoInfer<Exclude<Type, undefined>>): <Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, false, R>) => PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, false, R>;
/**
* Enhances a property signature with a default decoding value.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type, Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, false, R>, defaultValue: () => Types.NoInfer<Exclude<Type, undefined>>): PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, false, R>;
};
/**
* Enhances a property signature with a default decoding value and a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const withDefaults: {
/**
* Enhances a property signature with a default decoding value and a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type>(defaults: {
constructor: () => Types.NoInfer<Exclude<Type, undefined>>;
decoding: () => Types.NoInfer<Exclude<Type, undefined>>;
}): <Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, boolean, R>) => PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, true, R>;
/**
* Enhances a property signature with a default decoding value and a default constructor value.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type, Key extends PropertyKey, Encoded, R>(self: PropertySignature<"?:", Type, Key, "?:", Encoded, boolean, R>, defaults: {
constructor: () => Types.NoInfer<Exclude<Type, undefined>>;
decoding: () => Types.NoInfer<Exclude<Type, undefined>>;
}): PropertySignature<":", Exclude<Type, undefined>, Key, "?:", Encoded, true, R>;
};
/**
* Enhances a property signature by specifying a different key for it in the Encoded type.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const fromKey: {
/**
* Enhances a property signature by specifying a different key for it in the Encoded type.
*
* @category PropertySignature
* @since 3.10.0
*/
<Key extends PropertyKey>(key: Key): <TypeToken extends PropertySignature.Token, Type, EncodedToken extends PropertySignature.Token, Encoded, HasDefault extends boolean, R>(self: PropertySignature<TypeToken, Type, PropertyKey, EncodedToken, Encoded, HasDefault, R>) => PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;
/**
* Enhances a property signature by specifying a different key for it in the Encoded type.
*
* @category PropertySignature
* @since 3.10.0
*/
<Type, TypeToken extends PropertySignature.Token, Encoded, EncodedToken extends PropertySignature.Token, HasDefault extends boolean, R, Key extends PropertyKey>(self: PropertySignature<TypeToken, Type, PropertyKey, EncodedToken, Encoded, HasDefault, R>, key: Key): PropertySignature<TypeToken, Type, Key, EncodedToken, Encoded, HasDefault, R>;
};
/**
* Converts an optional property to a required one through a transformation `Option -> Type`.
*
* - `decode`: `none` as argument means the value is missing in the input.
* - `encode`: `none` as return value means the value will be missing in the output.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const optionalToRequired: <FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: {
readonly decode: (o: option_.Option<FA>) => TI;
readonly encode: (ti: TI) => option_.Option<FA>;
}) => PropertySignature<":", TA, never, "?:", FI, false, FR | TR>;
/**
* Converts an optional property to a required one through a transformation `Type -> Option`.
*
* - `decode`: `none` as return value means the value will be missing in the output.
* - `encode`: `none` as argument means the value is missing in the input.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const requiredToOptional: <FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: {
readonly decode: (fa: FA) => option_.Option<TI>;
readonly encode: (o: option_.Option<TI>) => FA;
}) => PropertySignature<"?:", TA, never, ":", FI, false, FR | TR>;
/**
* Converts an optional property to another optional property through a transformation `Option -> Option`.
*
* - `decode`:
* - `none` as argument means the value is missing in the input.
* - `none` as return value means the value will be missing in the output.
* - `encode`:
* - `none` as argument means the value is missing in the input.
* - `none` as return value means the value will be missing in the output.
*
* @category PropertySignature
* @since 3.10.0
*/
export declare const optionalToOptional: <FA, FI, FR, TA, TI, TR>(from: Schema<FA, FI, FR>, to: Schema<TA, TI, TR>, options: {
readonly decode: (o: option_.Option<FA>) => option_.Option<TI>;
readonly encode: (o: option_.Option<TI>) => option_.Option<FA>;
}) => PropertySignature<"?:", TA, never, "?:", FI, false, FR | TR>;
/**
* @since 3.10.0
*/
export type OptionalOptions<A> = {
readonly default?: never;
readonly as?: never;
readonly exact?: true;
readonly nullable?: true;
} | {
readonly default: LazyArg<A>;
readonly as?: never;
readonly exact?: true;
readonly nullable?: true;
} | {
readonly as: "Option";
readonly default?: never;
readonly exact?: never;
readonly nullable?: never;
readonly onNoneEncoding?: LazyArg<option_.Option<undefined>>;
} | {
readonly as: "Option";
readonly default?: never;
readonly exact?: never;
readonly nullable: true;
readonly onNoneEncoding?: LazyArg<option_.Option<null | undefined>>;
} | {
readonly as: "Option";
readonly default?: never;
readonly exact: true;
readonly nullable?: never;
readonly onNoneEncoding?: never;
} | {
readonly as: "Option";
readonly default?: never;
readonly exact: true;
readonly nullable: true;
readonly onNoneEncoding?: LazyArg<option_.Option<null>>;
} | undefined;
/**
* @category api interface
* @since 3.10.0
*/
export interface optional<S extends Schema.All> extends PropertySignature<"?:", Schema.Type<S> | undefined, never, "?:", Schema.Encoded<S> | undefined, false, Schema.Context<S>> {
readonly from: S;
annotations(annotations: PropertySignature.Annotations<Schema.Type<S> | undefined>): optional<S>;
}
/**
* @category api interface
* @since 3.10.0
*/
export interface optionalWith<S extends Schema.All, Options> extends PropertySignature<Types.Has<Options, "as" | "default"> extends true ? ":" : "?:", (Types.Has<Options, "as"> extends true ? option_.Option<Schema.Type<S>> : Schema.Type<S>) | (Types.Has<Options, "as" | "default" | "exact"> extends true ? never : undefined), never, "?:", Schema.Encoded<S> | (Types.Has<Options, "nullable"> extends true ? null : never) | (Types.Has<Options, "exact"> extends true ? never : undefined), Types.Has<Options, "default">, Schema.Context<S>> {
readonly from: S;
annotations(annotations: PropertySignature.Annotations<(Types.Has<Options, "as"> extends true ? option_.Option<Schema.Type<S>> : Schema.Type<S>) | (Types.Has<Options, "as" | "default" | "exact"> extends true ? never : undefined)>): optionalWith<S, Options>;
}
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare const optional: <S extends Schema.All>(self: S) => optional<S>;
/**
* @category PropertySignature
* @since 3.10.0
*/
export declare const optionalWith: {
/**
* @category PropertySignature
* @since 3.10.0
*/
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(options: Options): (self: S) => optionalWith<S, Options>;
/**
* @category PropertySignature
* @since 3.10.0
*/
<S extends Schema.All, Options extends OptionalOptions<Schema.Type<S>>>(self: S, options: Options): optionalWith<S, Options>;
};
/**
* @since 3.10.0
*/
export declare namespace Struct {
/**
* @since 3.10.0
*/
type Fields = {
readonly [x: PropertyKey]: Schema.All | PropertySignature.All;
};
type OptionalEncodedPropertySignature = PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", any, boolean, unknown> | PropertySignature<PropertySignature.Token, any, PropertyKey, "?:", never, boolean, unknown> | PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", any, boolean, unknown> | PropertySignature<PropertySignature.Token, never, PropertyKey, "?:", never, boolean, unknown>;
type EncodedOptionalKeys<Fields extends Struct.Fields> = {
[K in keyof Fields]: Fields[K] extends OptionalEncodedPropertySignature ? K : never;
}[keyof Fields];
type OptionalTypePropertySignature = PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, any, boolean, unknown> | PropertySignature<"?:", any, PropertyKey, PropertySignature.Token, never, boolean, unknown> | PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, any, boolean, unknown> | PropertySignature<"?:", never, PropertyKey, PropertySignature.Token, never, boolean, unknown>;
/**
* @since 3.10.0
*/
type Type<F extends Fields> = Types.UnionToIntersection<{
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? {
readonly [H in K]?: Schema.Type<F[H]>;
} : {
readonly [h in K]: Schema.Type<F[h]>;
};
}[keyof F]> extends infer Q ? Q : never;
type Key<F extends Fields, K extends keyof F> = [K] extends [never] ? never : F[K] extends PropertySignature.All<infer Key> ? [Key] extends [never] ? K : Key : K;
/**
* @since 3.10.0
*/
type Encoded<F extends Fields> = {
readonly [K in Exclude<keyof F, EncodedOptionalKeys<F>> as Key<F, K>]: Schema.Encoded<F[K]>;
} & {
readonly [K in EncodedOptionalKeys<F> as Key<F, K>]?: Schema.Encoded<F[K]>;
};
/**
* @since 3.10.0
*/
type Context<F extends Fields> = Schema.Context<F[keyof F]>;
type PropertySignatureWithDefault = PropertySignature<PropertySignature.Token, any, PropertyKey, PropertySignature.Token, any, true, unknown> | PropertySignature<PropertySignature.Token, any, PropertyKey, PropertySignature.Token, never, true, unknown> | PropertySignature<PropertySignature.Token, never, PropertyKey, PropertySignature.Token, any, true, unknown> | PropertySignature<PropertySignature.Token, never, PropertyKey, PropertySignature.Token, never, true, unknown>;
/**
* @since 3.10.0
*/
type Constructor<F extends Fields> = Types.UnionToIntersection<{
[K in keyof F]: F[K] extends OptionalTypePropertySignature ? {
readonly [H in K]?: Schema.Type<F[H]>;
} : F[K] extends PropertySignatureWithDefault ? {
readonly [H in K]?: Schema.Type<F[H]>;
} : {
readonly [h in K]: Schema.Type<F[h]>;
};
}[keyof F]> extends infer Q ? Q : never;
}
/**
* @since 3.10.0
*/
export declare namespace IndexSignature {
/**
* @since 3.10.0
*/
type Record = {
readonly key: Schema.All;
readonly value: Schema.All;
};
/**
* @since 3.10.0
*/
type Records = ReadonlyArray<Record>;
/**
* @since 3.10.0
*/
type NonEmptyRecords = array_.NonEmptyReadonlyArray<Record>;
/**
* @since 3.10.0
*/
type Type<Records extends IndexSignature.Records> = Types.UnionToIntersection<{
[K in keyof Records]: {
readonly [P in Schema.Type<Records[K]["key"]>]: Schema.Type<Records[K]["value"]>;
};
}[number]>;
/**
* @since 3.10.0
*/
type Encoded<Records extends IndexSignature.Records> = Types.UnionToIntersection<{
[K in keyof Records]: {
readonly [P in Schema.Encoded<Records[K]["key"]>]: Schema.Encoded<Records[K]["value"]>;
};
}[number]>;
/**
* @since 3.10.0
*/
type Context<Records extends IndexSignature.Records> = {
[K in keyof Records]: Schema.Context<Records[K]["key"]> | Schema.Context<Records[K]["value"]>;
}[number];
}
/**
* @since 3.10.0
*/
export declare namespace TypeLiteral {
/**
* @since 3.10.0
*/
type Type<Fields extends Struct.Fields, Records extends IndexSignature.Records> = Struct.Type<Fields> & IndexSignature.Type<Records>;
/**
* @since 3.10.0
*/
type Encoded<Fields extends Struct.Fields, Records extends IndexSignature.Records> = Struct.Encoded<Fields> & IndexSignature.Encoded<Records>;
/**
* @since 3.10.0
*/
type Constructor<Fields extends Struct.Fields, Records extends IndexSignature.Records> = Struct.Constructor<Fields> & IndexSignature.Type<Records>;
}
/**
* @category api interface
* @since 3.10.0
*/
export interface TypeLiteral<Fields extends Struct.Fields, Records extends IndexSignature.Records> extends AnnotableClass<TypeLiteral<Fields, Records>, Simplify<TypeLiteral.Type<Fields, Records>>, Simplify<TypeLiteral.Encoded<Fields, Records>>, Struct.Context<Fields> | IndexSignature.Context<Records>> {
readonly fields: {
readonly [K in keyof Fields]: Fields[K];
};
readonly records: Readonly<Records>;
annotations(annotations: Annotations.Schema<Simplify<TypeLiteral.Type<Fields, Records>>>): TypeLiteral<Fields, Records>;
make(props: RequiredKeys<TypeLiteral.Constructor<Fields, Records>> extends never ? void | Simplify<TypeLiteral.Constructor<Fields, Records>> : Simplify<TypeLiteral.Constructor<Fields, Records>>, options?: MakeOptions): Simplify<TypeLiteral.Type<Fields, Records>>;
}
/**
* @category api interface
* @since 3.10.0
*/
export interface Struct<Fields extends Struct.Fields> extends TypeLiteral<Fields, []> {
annotations(annotations: Annotations.Schema<Simplify<Struct.Type<Fields>>>): Struct<Fields>;
pick<Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys): Struct<Simplify<Pick<Fields, Keys[number]>>>;
omit<Keys extends ReadonlyArray<keyof Fields>>(...keys: Keys): Struct<Simplify<Omit<Fields, Keys[number]>>>;
}
/**
* @category construct