<T>(
key: string,
itemSchema: Schema.Codec<T, unknown, never, never>,
options?: { readonly version?: string }
): QueueItemCodecDescriptorBuild a QueueItemCodecDescriptor from a live Effect Schema value. The descriptor's
id (…/item@vN) and version are taken from the schema's withSchemaVersion stamp
(default 1), so the descriptor self-describes the schema version for handoff / drift checks.
export const const makeQueueItemCodecDescriptor: <T>(
key: string,
itemSchema: Schema.Codec<
T,
unknown,
never,
never
>,
options?: { readonly version?: string }
) => QueueItemCodecDescriptor
Build a
QueueItemCodecDescriptor
from a live Effect Schema value. The descriptor's
id (…/item@vN) and version are taken from the schema's
withSchemaVersion
stamp
(default 1), so the descriptor self-describes the schema version for handoff / drift checks.
makeQueueItemCodecDescriptor = <function (type parameter) T in <T>(key: string, itemSchema: Schema.Codec<T, unknown, never, never>, options?: {
readonly version?: string;
}): QueueItemCodecDescriptor
T>(
key: stringkey: string,
itemSchema: Schema.Codec<T, unknown, never, never>(parameter) itemSchema: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<T, any>) => Schema.Codec<T, unknown, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<T>) => Schema.Codec<T, unknown, never, never>;
check: (checks_0: Check<T>, ...checks: Array<Check<T>>) => Schema.Codec<T, unknown, never, never>;
rebuild: (ast: AST) => Schema.Codec<T, unknown, never, never>;
make: (input: unknown, options?: Schema.MakeOptions) => T;
makeOption: (input: unknown, options?: Schema.MakeOptions) => Option.Option<T>;
makeEffect: (input: unknown, options?: Schema.MakeOptions) => Effect.Effect<T, 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; <…;
}
itemSchema: import SchemaSchema.interface Codec<out T, out E = T, out RD = never, out RE = never>Namespace of type-level helpers for
Codec
.
A schema that tracks the decoded type T, the encoded type E, and the
Effect services required during decoding (RD) and encoding (RE).
Details
Use Codec<T, E, RD, RE> when you need to preserve full type information
about a schema — both what it decodes to and what it serializes from/to.
Most concrete schemas produced by this module implement Codec.
For APIs that only need one direction, prefer the narrower views:
Decoder
<T, RD> — decode-only
Encoder
<E, RE> — encode-only
Schema
<T> — type-only (no encoded representation)
Example (Accepting a codec that decodes to number from string)
import { Schema } from "effect"
declare function serialize<T>(codec: Schema.Codec<T, string>): string
serialize(Schema.NumberFromString) // ok — decodes number, encoded as string
Codec<function (type parameter) T in <T>(key: string, itemSchema: Schema.Codec<T, unknown, never, never>, options?: {
readonly version?: string;
}): QueueItemCodecDescriptor
T, unknown, never, never>,
options: | {
readonly version?: string
}
| undefined
options?: { readonly version?: string | undefinedversion?: string },
): QueueItemCodecDescriptor => {
const const version: numberversion = const schemaVersionOf: (
schema: Schema.Top
) => number
Read an item schema's
withSchemaVersion
; defaults to 1 when unannotated.
schemaVersionOf(itemSchema: Schema.Codec<T, unknown, never, never>(parameter) itemSchema: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<T, any>) => Schema.Codec<T, unknown, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<T>) => Schema.Codec<T, unknown, never, never>;
check: (checks_0: Check<T>, ...checks: Array<Check<T>>) => Schema.Codec<T, unknown, never, never>;
rebuild: (ast: AST) => Schema.Codec<T, unknown, never, never>;
make: (input: unknown, options?: Schema.MakeOptions) => T;
makeOption: (input: unknown, options?: Schema.MakeOptions) => Option.Option<T>;
makeEffect: (input: unknown, options?: Schema.MakeOptions) => Effect.Effect<T, 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; <…;
}
itemSchema);
const const wrapped: StandardJSONSchemaV1<
unknown,
T
> &
Schema.Codec<T, unknown, never, never>
wrapped = import SchemaSchema.function toStandardJSONSchemaV1<Schema.Codec<T, unknown, never, never>>(self: Schema.Codec<T, unknown, never, never>): StandardJSONSchemaV1<unknown, T> & Schema.Codec<T, unknown, never, never>Converts a schema to an experimental Standard JSON Schema V1 representation.
Details
https://github.com/standard-schema/standard-schema/pull/134
toStandardJSONSchemaV1(itemSchema: Schema.Codec<T, unknown, never, never>(parameter) itemSchema: {
Encoded: E;
DecodingServices: RD;
EncodingServices: RE;
Rebuild: Codec<T, E, RD, RE>;
Type: T;
Iso: Iso;
ast: Ast;
annotate: (annotations: Schema.Annotations.Bottom<T, any>) => Schema.Codec<T, unknown, never, never>;
annotateKey: (annotations: Schema.Annotations.Key<T>) => Schema.Codec<T, unknown, never, never>;
check: (checks_0: Check<T>, ...checks: Array<Check<T>>) => Schema.Codec<T, unknown, never, never>;
rebuild: (ast: AST) => Schema.Codec<T, unknown, never, never>;
make: (input: unknown, options?: Schema.MakeOptions) => T;
makeOption: (input: unknown, options?: Schema.MakeOptions) => Option.Option<T>;
makeEffect: (input: unknown, options?: Schema.MakeOptions) => Effect.Effect<T, 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; <…;
}
itemSchema);
const const jsonSchema: Record<string, unknown>jsonSchema = const wrapped: StandardJSONSchemaV1<
unknown,
T
> &
Schema.Codec<T, unknown, never, never>
wrapped["~standard"].StandardJSONSchemaV1<Input = unknown, Output = Input>.Props<unknown, T>.jsonSchema: StandardJSONSchemaV1.ConverterMethods for generating the input/output JSON Schema.
jsonSchema.StandardJSONSchemaV1<Input = unknown, Output = Input>.Converter.input: (options: StandardJSONSchemaV1<Input = unknown, Output = Input>.Options) => Record<string, unknown>Converts the input type to JSON Schema. May throw if conversion is not supported.
input({ StandardJSONSchemaV1<Input = unknown, Output = Input>.Options.target: StandardJSONSchemaV1.TargetSpecifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw.
target: "draft-07" });
return {
QueueItemCodecDescriptor.id: stringStable codec id, e.g. "@app/EmailQueue/item@v1".
id: `${key: stringkey}/item@v${var String: StringConstructor
;(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(const version: numberversion)}`,
QueueItemCodecDescriptor.version: stringVersion string for drift checks (bump when encoded shape breaks).
version: options: | {
readonly version?: string
}
| undefined
options?.version?: string | undefinedversion ?? var String: StringConstructor
;(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(const version: numberversion),
QueueItemCodecDescriptor.encoding: "json"Wire encoding; "json" is the only supported value today.
encoding: "json",
QueueItemCodecDescriptor.jsonSchema: JsonSchema.JsonSchemaDraft-07 JSON Schema for the encoded item payload.
jsonSchema,
};
};