Schema.Struct<{
readonly reason: Schema.String
readonly attributes: Schema.optionalKey<
Schema.$Record<
Schema.String,
Schema.Codec<JsonValue, JsonValue, never, never>
>
>
}>Options for deadLetter / drop (wire form of QueueRouteOptions).
export const const queueRouteOptions: Schema.Struct<{
readonly reason: Schema.String
readonly attributes: Schema.optionalKey<
Schema.$Record<
Schema.String,
Schema.Codec<
JsonValue,
JsonValue,
never,
never
>
>
>
}>
const queueRouteOptions: {
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 reason: Schema.String; readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>> }) => To, options?: { readonly unsafePreserveChecks?: boolean | undefin…;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue; } | undefined; }, readonly []>) => Schema.Struct<{ readonly reason: Schema.String; readonly attributes: Schema.opti…;
annotateKey: (annotations: Schema.Annotations.Key<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } | undefined }>) => Schema.Struct<{ readonly reason: Schema.String; readonly attributes: Schema.optionalKey<Schema.$Re…;
check: (checks_0: Check<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } | undefined }>, ...checks: Array<Check<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } | undefined }…;
rebuild: (ast: Objects) => Schema.Struct<{ readonly reason: Schema.String; readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>> }>;
make: (input: { readonly reason: string; readonly attributes?: { readonly [x: string]: unknown } | undefined }, options?: Schema.MakeOptions) => { readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } | undefined };
makeOption: (input: { readonly reason: string; readonly attributes?: { readonly [x: string]: unknown } | undefined }, options?: Schema.MakeOptions) => Option.Option<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } |…;
makeEffect: (input: { readonly reason: string; readonly attributes?: { readonly [x: string]: unknown } | undefined }, options?: Schema.MakeOptions) => Effect.Effect<{ readonly reason: string; readonly attributes?: { readonly [x: string]: JsonValue } |…;
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; <…;
}
Options for deadLetter / drop (wire form of QueueRouteOptions).
queueRouteOptions = import SchemaSchema.function Struct<{
readonly reason: Schema.String;
readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
}>(fields: {
readonly reason: Schema.String;
readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
}): Schema.Struct<{
readonly reason: Schema.String;
readonly attributes: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
}>
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({
reason: Schema.String(property) reason: {
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.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.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; <…;
}
reason: 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.Option<string>;
makeEffect: (input: string, options?: Schema.MakeOptions) => Effect.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,
attributes: Schema.optionalKey<
Schema.$Record<
Schema.String,
Schema.Codec<
JsonValue,
JsonValue,
never,
never
>
>
>
(property) attributes: {
Type: S["Type"];
Encoded: S["Encoded"];
DecodingServices: S["DecodingServices"];
EncodingServices: S["EncodingServices"];
Iso: S["Iso"];
schema: S;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<{ readonly [x: string]: JsonValue; }, readonly []>) => Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
annotateKey: (annotations: Schema.Annotations.Key<{ readonly [x: string]: JsonValue }>) => Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
check: (checks_0: Check<{ readonly [x: string]: JsonValue }>, ...checks: Array<Check<{ readonly [x: string]: JsonValue }>>) => Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
rebuild: (ast: Objects) => Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>;
make: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => { readonly [x: string]: JsonValue };
makeOption: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => Option.Option<{ readonly [x: string]: JsonValue }>;
makeEffect: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => Effect.Effect<{ readonly [x: string]: JsonValue }, 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; <…;
}
attributes: import SchemaSchema.const optionalKey: optionalKeyLambda
<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>(self: Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>) => Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>>
Type-level representation returned by
optionalKey
.
Creates an exact optional key schema for struct fields. Unlike optional,
this creates exact optional properties (not | undefined) that can be
completely omitted from the object.
Example (Creating a struct with optional key)
import { Schema } from "effect"
const schema = Schema.Struct({
name: Schema.String,
age: Schema.optionalKey(Schema.Number)
})
// Type: { readonly name: string; readonly age?: number }
type Person = typeof schema["Type"]
optionalKey(const queueJsonAttributes: Schema.$Record<
Schema.String,
Schema.Codec<JsonValue, JsonValue, never, never>
>
const queueJsonAttributes: {
Type: Record.Type<Key, Value>;
Encoded: Record.Encoded<Key, Value>;
DecodingServices: Record.DecodingServices<Key, Value>;
EncodingServices: Record.EncodingServices<Key, Value>;
Iso: Record.Iso<Key, Value>;
key: Key;
value: Value;
Rebuild: Rebuild;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<{ readonly [x: string]: JsonValue; }, readonly []>) => Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>;
annotateKey: (annotations: Schema.Annotations.Key<{ readonly [x: string]: JsonValue }>) => Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>;
check: (checks_0: Check<{ readonly [x: string]: JsonValue }>, ...checks: Array<Check<{ readonly [x: string]: JsonValue }>>) => Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>;
rebuild: (ast: Objects) => Schema.$Record<Schema.String, Schema.Codec<JsonValue, JsonValue, never, never>>;
make: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => { readonly [x: string]: JsonValue };
makeOption: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => Option.Option<{ readonly [x: string]: JsonValue }>;
makeEffect: (input: { readonly [x: string]: unknown }, options?: Schema.MakeOptions) => Effect.Effect<{ readonly [x: string]: JsonValue }, 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; <…;
}
Option attributes — a readonly record of
JsonValue
, matching the engine's
{ readonly [key: string]: JsonValue } on QueueReleaseOptions / QueueRouteOptions.
queueJsonAttributes),
});