Schema.Struct<{
readonly id: Schema.String
readonly version: Schema.String
readonly encoding: Schema.Literal<"json">
readonly jsonSchema: Schema.Unknown
}>Runtime schema for a queue item's codec descriptor (id / version / encoding / jsonSchema).
export const const QueueItemCodecDescriptorSchema: Schema.Struct<{
readonly id: Schema.String
readonly version: Schema.String
readonly encoding: Schema.Literal<"json">
readonly jsonSchema: Schema.Unknown
}>
const QueueItemCodecDescriptorSchema: {
Type: Struct.Type<Fields>;
Encoded: Struct.Encoded<Fields>;
DecodingServices: Struct.DecodingServices<Fields>;
EncodingServices: Struct.EncodingServices<Fields>;
Iso: Struct.Iso<Fields>;
fields: Fields;
mapFields: (f: (fields: { readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }) => To, options?: { readonly unsafePreserveChecks?: boolean | undefined } | undefi…;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<Schema.Struct.ReadonlySide<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown; }, 'Type'>, readonly []>) => …;
annotateKey: (annotations: Schema.Annotations.Key<Schema.Struct.ReadonlySide<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }, 'Type'>>) => Schema.Struct<{ r…;
check: (checks_0: Check<Schema.Struct.ReadonlySide<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }, 'Type'>>, ...checks: Array<Check<Schema.Struct.Rea…;
rebuild: (ast: Objects) => Schema.Struct<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }>;
make: (input: Schema.Struct.ReadonlyMakeIn<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }>, options?: Schema.MakeOptions) => Schema.Struct.ReadonlyS…;
makeOption: (input: Schema.Struct.ReadonlyMakeIn<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }>, options?: Schema.MakeOptions) => Option<Schema.Struct.Re…;
makeEffect: (input: Schema.Struct.ReadonlyMakeIn<{ readonly id: Schema.String; readonly version: Schema.String; readonly encoding: Schema.Literal<'json'>; readonly jsonSchema: Schema.Unknown }>, options?: Schema.MakeOptions) => Effect<Schema.Struct.Re…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Runtime schema for a queue item's codec descriptor (id / version / encoding / jsonSchema).
QueueItemCodecDescriptorSchema = import SchemaSchema.function Struct<{
readonly id: Schema.String;
readonly version: Schema.String;
readonly encoding: Schema.Literal<"json">;
readonly jsonSchema: Schema.Unknown;
}>(fields: {
readonly id: Schema.String;
readonly version: Schema.String;
readonly encoding: Schema.Literal<"json">;
readonly jsonSchema: Schema.Unknown;
}): Schema.Struct<{
readonly id: Schema.String;
readonly version: Schema.String;
readonly encoding: Schema.Literal<"json">;
readonly jsonSchema: Schema.Unknown;
}>
Defines a struct schema from a map of field schemas.
Details
Each field value is a schema. Use
optionalKey
or
optional
to
mark fields as optional, and
mutableKey
to mark them as mutable.
The resulting schema's Type is a readonly object type with the fields'
decoded types. The Encoded form mirrors the field schemas' encoded types.
Example (Defining a basic struct)
import { Schema } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Number,
email: Schema.optionalKey(Schema.String)
})
// { readonly name: string; readonly age: number; readonly email?: string }
type Person = typeof Person.Type
const alice = Schema.decodeUnknownSync(Person)({ name: "Alice", age: 30 })
console.log(alice)
// { name: 'Alice', age: 30 }
Struct({
id: Schema.String(property) id: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
id: import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String,
version: Schema.String(property) version: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
version: import SchemaSchema.const String: Schema.Stringconst String: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<string, readonly []>) => Schema.String;
annotateKey: (annotations: Schema.Annotations.Key<string>) => Schema.String;
check: (checks_0: Check<string>, ...checks: Array<Check<string>>) => Schema.String;
rebuild: (ast: String) => Schema.String;
make: (input: string, options?: Schema.MakeOptions) => string;
makeOption: (input: string, options?: Schema.MakeOptions) => Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect<string, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
String
.
Schema for string values. Validates that the input is typeof "string".
String,
encoding: Schema.Literal<"json">(property) encoding: {
literal: L;
transform: (to: L2) => Schema.decodeTo<Schema.Literal<L2>, Schema.Literal<'json'>, never, never>;
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<'json', readonly []>) => Schema.Literal<'json'>;
annotateKey: (annotations: Schema.Annotations.Key<'json'>) => Schema.Literal<'json'>;
check: (checks_0: Check<'json'>, ...checks: Array<Check<'json'>>) => Schema.Literal<'json'>;
rebuild: (ast: Literal) => Schema.Literal<'json'>;
make: (input: 'json', options?: Schema.MakeOptions) => 'json';
makeOption: (input: 'json', options?: Schema.MakeOptions) => Option<'json'>;
makeEffect: (input: 'json', options?: Schema.MakeOptions) => Effect<'json', Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
encoding: import SchemaSchema.function Literal<"json">(literal: "json"): Schema.Literal<"json">Creates a schema for a single literal value (string, number, bigint, boolean, or null).
Example (Defining a string literal)
import { Schema } from "effect"
const schema = Schema.Literal("hello")
// Type: Schema.Literal<"hello">
Literal("json"),
jsonSchema: Schema.Unknown(property) jsonSchema: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<unknown, readonly []>) => Schema.Unknown;
annotateKey: (annotations: Schema.Annotations.Key<unknown>) => Schema.Unknown;
check: (checks_0: Check<unknown>, ...checks: Array<Check<unknown>>) => Schema.Unknown;
rebuild: (ast: Unknown) => Schema.Unknown;
make: (input: unknown, options?: Schema.MakeOptions) => unknown;
makeOption: (input: unknown, options?: Schema.MakeOptions) => Option<unknown>;
makeEffect: (input: unknown, options?: Schema.MakeOptions) => Effect<unknown, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
jsonSchema: import SchemaSchema.const Unknown: Schema.Unknownconst Unknown: {
Rebuild: Rebuild;
Iso: Iso;
ast: Ast;
Type: T;
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
annotate: (annotations: Schema.Annotations.Bottom<unknown, readonly []>) => Schema.Unknown;
annotateKey: (annotations: Schema.Annotations.Key<unknown>) => Schema.Unknown;
check: (checks_0: Check<unknown>, ...checks: Array<Check<unknown>>) => Schema.Unknown;
rebuild: (ast: Unknown) => Schema.Unknown;
make: (input: unknown, options?: Schema.MakeOptions) => unknown;
makeOption: (input: unknown, options?: Schema.MakeOptions) => Option<unknown>;
makeEffect: (input: unknown, options?: Schema.MakeOptions) => Effect<unknown, Schema.SchemaError, never>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
Type-level representation of
Unknown
.
Schema for the unknown type. Accepts any value without validation.
When to use
Use as a top schema when you need to accept any input while preserving
TypeScript's unknown safety at use sites.
Unknown,
});