/** * @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 = { [K in keyof A]: A[K]; } & {}; /** * @since 3.10.0 */ export type SimplifyMutable = { -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 extends Schema.Variance, 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): Schema; } /** * @category annotations * @since 3.10.0 */ export interface Annotable, A, I = A, R = never> extends Schema { annotations(annotations: Annotations.GenericSchema): Self; } /** * @category annotations * @since 3.10.0 */ export interface AnnotableClass, A, I = A, R = never> extends Annotable { new (_: never): Schema.Variance; } /** * @category model * @since 3.10.0 */ export interface SchemaClass extends AnnotableClass, A, I, R> { } /** * @category constructors * @since 3.10.0 */ export declare function make(ast: AST.AST): SchemaClass; /** * 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: (schema: Schema, overrideOptions?: AST.ParseOptions) => StandardSchemaV1 & SchemaClass; /** * @category annotations * @since 3.10.0 */ export declare namespace Annotable { /** * @since 3.10.0 */ type Self = ReturnType; /** * @since 3.10.0 */ type Any = Annotable; /** * @since 3.10.0 */ type All = Any | Annotable | Annotable | Annotable; } /** * @since 3.10.0 */ export declare function asSchema(schema: S): Schema, Schema.Encoded, Schema.Context>; /** * @category formatting * @since 3.10.0 */ export declare const format: (schema: S) => string; /** * @since 3.10.0 */ export declare namespace Schema { /** * @since 3.10.0 */ interface Variance { readonly [TypeId]: { readonly _A: Types.Invariant; readonly _I: Types.Invariant; readonly _R: Types.Covariant; }; } /** * @since 3.10.0 */ type Type = S extends Schema.Variance ? A : never; /** * @since 3.10.0 */ type Encoded = S extends Schema.Variance ? I : never; /** * @since 3.10.0 */ type Context = S extends Schema.Variance ? R : never; /** * @since 3.10.0 */ type ToAsserts = (input: unknown, options?: AST.ParseOptions) => asserts input is Schema.Type; /** * Any schema, except for `never`. * * @since 3.10.0 */ type Any = Schema; /** * Any schema with `Context = never`, except for `never`. * * @since 3.10.0 */ type AnyNoContext = Schema; /** * Any schema, including `never`. * * @since 3.10.0 */ type All = Any | Schema | Schema | Schema; /** * Type-level counterpart of `Schema.asSchema` function. * * @since 3.10.0 */ type AsSchema = Schema, Encoded, Context>; } /** * 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: (schema: Schema) => SchemaClass; /** * 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: (schema: Schema) => SchemaClass; /** * 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: (schema: Schema) => SchemaClass; 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: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect; /** * @category encoding * @since 3.10.0 */ export declare const encodeUnknownEither: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either; /** * @category encoding * @since 3.10.0 */ export declare const encodeUnknownPromise: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise; /** * @category encoding * @since 3.10.0 */ export declare const encode: (schema: Schema, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Effect.Effect; /** * @category encoding * @since 3.10.0 */ export declare const encodeEither: (schema: Schema, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => either_.Either; /** * @category encoding * @since 3.10.0 */ export declare const encodePromise: (schema: Schema, options?: ParseOptions) => (a: A, overrideOptions?: ParseOptions) => Promise; /** * @category decoding * @since 3.10.0 */ export declare const decodeUnknown: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect; /** * @category decoding * @since 3.10.0 */ export declare const decodeUnknownEither: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either; /** * @category decoding * @since 3.10.0 */ export declare const decodeUnknownPromise: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise; /** * @category decoding * @since 3.10.0 */ export declare const decode: (schema: Schema, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Effect.Effect; /** * @category decoding * @since 3.10.0 */ export declare const decodeEither: (schema: Schema, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => either_.Either; /** * @category decoding * @since 3.10.0 */ export declare const decodePromise: (schema: Schema, options?: ParseOptions) => (i: I, overrideOptions?: ParseOptions) => Promise; /** * @category validation * @since 3.10.0 */ export declare const validate: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Effect.Effect; /** * @category validation * @since 3.10.0 */ export declare const validateEither: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => either_.Either; /** * @category validation * @since 3.10.0 */ export declare const validatePromise: (schema: Schema, options?: ParseOptions) => (u: unknown, overrideOptions?: ParseOptions) => Promise; /** * 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> extends AnnotableClass, Literals[number]> { readonly literals: Readonly; } /** * @category constructors * @since 3.10.0 */ export declare function Literal>(...literals: Literals): Literal; export declare function Literal(): Never; export declare function Literal>(...literals: Literals): SchemaClass; /** * Creates a new `Schema` from a literal schema. * * @example * ```ts * import * as assert from "node:assert" * import { Either, Schema } 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: >(...literals: L) => (_schema: Schema) => Literal<[...L]>; /** * @category constructors * @since 3.10.0 */ export declare const UniqueSymbolFromSelf: (symbol: S) => SchemaClass; /** * @category api interface * @since 3.10.0 */ export interface Enums extends AnnotableClass, 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: (enums: A) => Enums; type AppendType