import type { Refinement } from "@effect-ts/core/Function"; import type * as fc from "fast-check"; import type { Parser, ParserEnv } from "../Parser.js"; import type * as Th from "../These.js"; import type { Annotation } from "./annotation.js"; import type { AnyError } from "./error.js"; export declare const SchemaSym: unique symbol; export type SchemaSym = typeof SchemaSym; /** * A `Schema` is a functional representation of a data model of type `ParsedShape` * that can be: * * 1) parsed from a `ParsedShape` starting from an input of type `ParserInput` * maybe failing for a reason `ParserError` * * 2) constructed smartly starting from an input of type `ConstructorInput` * * 3) encoded into an `Encoded` value * * 4) interacted with via `Api` */ /** * @tsplus type ets/Schema/Schema * @tsplus companion ets/Schema/SchemaOps */ export declare abstract class Schema { readonly [SchemaSym]: SchemaSym; readonly _ParserInput: (_: ParserInput, env?: ParserEnv) => void; readonly _ParserError: () => any; readonly _ParsedShape: () => ParsedShape; readonly _ConstructorInput: (_: ConstructorInput) => void; readonly _ConstructorError: () => any; readonly _Encoded: () => Encoded; abstract readonly Api: Api; readonly [">>>"]: (that: Schema) => Schema; readonly annotate: (identifier: Annotation, meta: Meta) => Schema; } export type SchemaAny = Schema; export type SchemaUPI = Schema; export type Standard = Schema; export interface ApiSelfType { _AS: AS; } export type GetApiSelfType, D> = unknown extends T["_AS"] ? D : T["_AS"]; export declare const SchemaContinuationSymbol: unique symbol; export type SchemaContinuationSymbol = typeof SchemaContinuationSymbol; export interface HasContinuation { readonly [SchemaContinuationSymbol]: Schema; } export declare function hasContinuation(schema: Schema): schema is Schema & HasContinuation; export type ParserInputOf> = [X] extends [ Schema ] ? Y : never; export type ParserErrorOf> = [X] extends [ Schema ] ? any : never; export type ConstructorInputOf> = [ X ] extends [Schema] ? Y : never; export type ConstructorErrorOf> = [ X ] extends [Schema] ? any : never; export type EncodedOf> = [X] extends [ Schema ] ? Y : never; export type ParsedShapeOf> = [X] extends [ Schema ] ? Y : never; export type ApiOf> = [X] extends [ Schema ] ? Y : never; export declare class SchemaIdentity extends Schema { readonly guard: (_: unknown) => _ is A; readonly Api: {}; constructor(guard: (_: unknown) => _ is A); } export declare class SchemaConstructor extends Schema implements HasContinuation { readonly self: Schema; readonly of: (i: NewConstructorInput) => Th.These; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, of: (i: NewConstructorInput) => Th.These); } export declare class SchemaParser extends Schema implements HasContinuation { readonly self: Schema; readonly parser: Parser; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, parser: Parser); } export declare class SchemaArbitrary extends Schema implements HasContinuation { readonly self: Schema; readonly arbitrary: (_: typeof fc) => fc.Arbitrary; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, arbitrary: (_: typeof fc) => fc.Arbitrary); } export declare class SchemaEncoder extends Schema implements HasContinuation { readonly self: Schema; readonly encoder: (_: ParsedShape) => Encoded2; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, encoder: (_: ParsedShape) => Encoded2); } export declare class SchemaRefinement extends Schema { readonly self: Schema; readonly refinement: Refinement; readonly error: (value: ParsedShape) => E; get Api(): Api; constructor(self: Schema, refinement: Refinement, error: (value: ParsedShape) => E); } export declare class SchemaPipe extends Schema implements HasContinuation { readonly self: Schema; readonly that: Schema; get Api(): ThatApi; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, that: Schema); } export declare class SchemaMapParserError extends Schema implements HasContinuation { readonly self: Schema; readonly mapError: (_: any) => any; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, mapError: (_: any) => any); } export declare class SchemaMapConstructorError extends Schema implements HasContinuation { readonly self: Schema; readonly mapError: (_: any) => any; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, mapError: (_: any) => any); } export declare class SchemaMapApi extends Schema implements HasContinuation { readonly self: Schema; readonly mapApi: (_: Api) => Api2; get Api(): Api2; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, mapApi: (_: Api) => Api2); } export declare class SchemaNamed extends Schema implements HasContinuation { readonly self: Schema; readonly name: Name; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, name: Name); } export declare const Identifiable: unique symbol; export declare function isAnnotated(self: Self, annotation: Annotation): self is Self & { readonly self: Self extends { self: infer X; } ? X : SchemaAny; readonly annotation: Annotation; readonly meta: A; }; export declare function isAnnotatedSchema(self: Self): self is Self & { readonly self: Self extends { self: infer X; } ? X : SchemaAny; readonly annotation: Annotation; readonly meta: any; }; export declare class SchemaAnnotated extends Schema implements HasContinuation { readonly self: Schema; readonly annotation: Annotation; readonly meta: Meta; get Api(): Api; readonly [Identifiable]: symbol; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, annotation: Annotation, meta: Meta); } export declare class SchemaGuard extends Schema implements HasContinuation { readonly self: Schema; readonly guard: (u: unknown) => u is ParsedShape; get Api(): Api; readonly [SchemaContinuationSymbol]: SchemaAny; constructor(self: Schema, guard: (u: unknown) => u is ParsedShape); } export declare class SchemaLazy extends Schema implements HasContinuation { readonly self: () => Schema; readonly Api: {}; get [SchemaContinuationSymbol](): SchemaAny; get lazy(): Schema; constructor(self: () => Schema); } //# sourceMappingURL=schema.d.ts.map