(
multiDocument: MultiDocument,
options?: { readonly reviver?: Reviver<Code> | undefined }
): CodeDocumentGenerates TypeScript code strings from a MultiDocument.
When to use
Use when you need to produce source code for Effect Schema definitions from a
schema representation MultiDocument.
Details
options.reviver can customize code generation for Declaration
nodes. Return undefined to fall back to the default logic, which uses
generation annotations or the encoded schema. References are
topologically sorted so non-recursive definitions are emitted before their
dependents. $ref keys are converted to sanitized JavaScript identifiers.
Example (Generating TypeScript code)
import { Schema, SchemaRepresentation } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Int
})
const multi = SchemaRepresentation.toMultiDocument(
SchemaRepresentation.fromAST(Person.ast)
)
const codeDoc = SchemaRepresentation.toCodeDocument(multi)
console.log(codeDoc.codes[0].runtime)
// Schema.Struct({ ... })export function function toCodeDocument(
multiDocument: MultiDocument,
options?: {
readonly reviver?: Reviver<Code> | undefined
}
): CodeDocument
Generates TypeScript code strings from a
MultiDocument
.
When to use
Use when you need to produce source code for Effect Schema definitions from a
schema representation MultiDocument.
Details
options.reviver can customize code generation for
Declaration
nodes. Return undefined to fall back to the default logic, which uses
generation annotations or the encoded schema. References are
topologically sorted so non-recursive definitions are emitted before their
dependents. $ref keys are converted to sanitized JavaScript identifiers.
Example (Generating TypeScript code)
import { Schema, SchemaRepresentation } from "effect"
const Person = Schema.Struct({
name: Schema.String,
age: Schema.Int
})
const multi = SchemaRepresentation.toMultiDocument(
SchemaRepresentation.fromAST(Person.ast)
)
const codeDoc = SchemaRepresentation.toCodeDocument(multi)
console.log(codeDoc.codes[0].runtime)
// Schema.Struct({ ... })
toCodeDocument(multiDocument: MultiDocument(parameter) multiDocument: {
representations: readonly [Representation, ...Array<Representation>];
references: References;
}
multiDocument: type MultiDocument = {
readonly representations: readonly [
Representation,
...Array<Representation>
]
readonly references: References
}
One or more
Representation
s sharing a common
References
map.
When to use
Use when you use
fromASTs
to create this from multiple Schema ASTs,
toCodeDocument
to generate TypeScript code, and
toJsonSchemaMultiDocument
to convert to JSON Schema.
MultiDocument, options: {
readonly reviver?: Reviver<Code> | undefined
}
options?: {
/**
* The reviver can return `undefined` to indicate that the generation should be generated by the default logic
*/
readonly reviver?: Reviver<Code> | undefinedThe reviver can return undefined to indicate that the generation should be generated by the default logic
reviver?: type Reviver<T> = (
declaration: Declaration,
recur: (representation: Representation) => T
) => T | undefined
A callback that handles
Declaration
nodes during reconstruction
(
toSchema
) or code generation (
toCodeDocument
).
Details
Return a value to handle the declaration. Return undefined to fall back to
default behavior, which uses encodedSchema for toSchema or the
generation annotation for toCodeDocument. recur processes child
representations recursively.
Reviver<type Code = {
readonly runtime: string
readonly Type: string
}
A pair of TypeScript source strings for a schema: runtime is the
executable Schema expression, Type is the corresponding TypeScript type.
Code> | undefined
}): type CodeDocument = {
readonly codes: ReadonlyArray<Code>
readonly references: {
readonly nonRecursives: ReadonlyArray<{
readonly $ref: string
readonly code: Code
}>
readonly recursives: {
readonly [$ref: string]: Code
}
}
readonly artifacts: ReadonlyArray<Artifact>
}
The output of
toCodeDocument
: generated TypeScript code for one or
more schemas plus their shared references and auxiliary artifacts.
Details
codes contains one
Code
per input representation.
references.nonRecursives contains topologically sorted non-recursive
definitions. references.recursives contains definitions involved in cycles.
artifacts contains symbols, enums, and import statements needed by the
code.
CodeDocument {
const const artifacts: Array<Artifact>artifacts: interface Array<T>Array<type Artifact =
| {
readonly _tag: "Symbol"
readonly identifier: string
readonly generation: Code
}
| {
readonly _tag: "Enum"
readonly identifier: string
readonly generation: Code
}
| {
readonly _tag: "Import"
readonly importDeclaration: string
}
An auxiliary code artifact produced during code generation — a symbol
declaration, an enum declaration, or an import statement.
Artifact> = []
const const ts: TopologicalSortconst ts: {
nonRecursives: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>;
recursives: { readonly [$ref: string]: Representation };
}
ts = function topologicalSort(
references: References
): TopologicalSort
topologicalSort(multiDocument: MultiDocument(parameter) multiDocument: {
representations: readonly [Representation, ...Array<Representation>];
references: References;
}
multiDocument.references: Referencesreferences)
// Phase 1: Build sanitization map with collision handling
const const sanitizedReferenceMap: Map<
string,
string
>
sanitizedReferenceMap = new var Map: MapConstructor
new <string, string>(iterable?: Iterable<readonly [string, string]> | null | undefined) => Map<string, string> (+3 overloads)
Map<string, string>()
const const uniqueSanitizedReferences: Set<string>uniqueSanitizedReferences = new var Set: SetConstructor
new <string>(iterable?: Iterable<string> | null | undefined) => Set<string> (+1 overload)
Set<string>()
const const referenceCount: Map<string, number>referenceCount = new var Map: MapConstructor
new <string, number>(iterable?: Iterable<readonly [string, number]> | null | undefined) => Map<string, number> (+3 overloads)
Map<string, number>()
// Process all references first to build the map
const const allRefs: string[]allRefs = [
...const ts: TopologicalSortconst ts: {
nonRecursives: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>;
recursives: { readonly [$ref: string]: Representation };
}
ts.nonRecursives: ReadonlyArray<{
readonly $ref: string
readonly representation: Representation
}>
The definitions that are not recursive.
The definitions that depends on other definitions are placed after the definitions they depend on
nonRecursives.function ReadonlyArray(callbackfn: (value: { readonly $ref: string; readonly representation: Representation }, index: number, array: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>) => U, thisArg?: any): Array<U>Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(({ $ref: string$ref }) => $ref: string$ref),
...var Object: ObjectConstructorProvides functionality common to all JavaScript objects.
Object.ObjectConstructor.keys(o: {}): string[] (+1 overload)Returns the names of the enumerable string properties and methods of an object.
keys(const ts: TopologicalSortconst ts: {
nonRecursives: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>;
recursives: { readonly [$ref: string]: Representation };
}
ts.recursives: {
readonly [$ref: string]: Representation
}
The recursive definitions (with no particular order).
recursives)
]
for (const const ref: stringref of const allRefs: string[]allRefs) {
function (local function) ensureUniqueSanitized(originalRef: string): stringensureUniqueSanitized(const ref: stringref)
}
// Phase 2: Use the map when processing references
const const nonRecursives: {
$ref: string
code: Code
}[]
nonRecursives = const ts: TopologicalSortconst ts: {
nonRecursives: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>;
recursives: { readonly [$ref: string]: Representation };
}
ts.nonRecursives: ReadonlyArray<{
readonly $ref: string
readonly representation: Representation
}>
The definitions that are not recursive.
The definitions that depends on other definitions are placed after the definitions they depend on
nonRecursives.function ReadonlyArray(callbackfn: (value: { readonly $ref: string; readonly representation: Representation }, index: number, array: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>) => U, thisArg?: any): Array<U>Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(({ $ref: string$ref, representation: Representationrepresentation }) => ({
$ref: string$ref: const sanitizedReferenceMap: Map<
string,
string
>
sanitizedReferenceMap.Map<string, string>.get(key: string): string | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get($ref: string$ref)!,
code: Code(property) code: {
runtime: string;
Type: string;
}
code: function (local function) recur(s: Representation): Coderecur(representation: Representationrepresentation)
}))
const const recursives: Record<string, Code>recursives = import RecRec.mapEntries(const ts: TopologicalSortconst ts: {
nonRecursives: ReadonlyArray<{ readonly $ref: string; readonly representation: Representation }>;
recursives: { readonly [$ref: string]: Representation };
}
ts.recursives: {
readonly [$ref: string]: Representation
}
The recursive definitions (with no particular order).
recursives, (representation: Representationrepresentation, $ref: any$ref) => [
const sanitizedReferenceMap: Map<
string,
string
>
sanitizedReferenceMap.Map<string, string>.get(key: string): string | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get($ref: any$ref)!,
function (local function) recur(s: Representation): Coderecur(representation: Representationrepresentation)
])
const const codes: Array<Code>codes = multiDocument: MultiDocument(parameter) multiDocument: {
representations: readonly [Representation, ...Array<Representation>];
references: References;
}
multiDocument.representations: readonly [
Representation,
...Array<Representation>
]
(property) representations: {
0: Representation;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<Representation>>): Array<Representation>; (...items: Array<Representation | ConcatArray<Representation>>): Array<Representation> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<Representation>;
indexOf: (searchElement: Representation, fromIndex?: number) => number;
lastIndexOf: (searchElement: Representation, fromIndex?: number) => number;
every: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unk…;
some: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Representation, index: number, array: ReadonlyArray<Representation>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisAr…;
reduce: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
reduceRight: { (callbackfn: (previousValue: Representation, currentValue: Representation, currentIndex: number, array: ReadonlyArray<Representation>) => Representation): Representation; (callbackfn: (previousValue: Representation, currentValue: Represe…;
find: { (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisA…;
findIndex: (predicate: (value: Representation, index: number, obj: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, Representation]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Representation>;
includes: (searchElement: Representation, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Representation, index: number, array: Array<Representation>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Representation | undefined;
findLast: { (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, t…;
findLastIndex: (predicate: (value: Representation, index: number, array: ReadonlyArray<Representation>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Representation>;
toSorted: (compareFn?: ((a: Representation, b: Representation) => number) | undefined) => Array<Representation>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Representation>): Array<Representation>; (start: number, deleteCount?: number): Array<Representation> };
with: (index: number, value: Representation) => Array<Representation>;
}
representations.ReadonlyArray<Representation>.map<Code>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(function (local function) recur(s: Representation): Coderecur)
return {
codes: Array<Code>codes,
references: {
readonly nonRecursives: ReadonlyArray<{
readonly $ref: string
readonly code: Code
}>
readonly recursives: {
readonly [$ref: string]: Code
}
}
references: {
nonRecursives: readonly {
readonly $ref: string
readonly code: Code
}[]
nonRecursives: const nonRecursives: {
$ref: string
code: Code
}[]
nonRecursives.Array<{ $ref: string; code: Code; }>.filter(predicate: (value: {
$ref: string;
code: Code;
}, index: number, array: {
$ref: string;
code: Code;
}[]) => unknown, thisArg?: any): {
$ref: string;
code: Code;
}[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
filter(({ $ref: string$ref }) => (const referenceCount: Map<string, number>referenceCount.Map<string, number>.get(key: string): number | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get($ref: string$ref) ?? 0) > 0),
recursives: Record<string, Code>recursives: import RecRec.filter(const recursives: Record<string, Code>recursives, (_: Code(parameter) _: {
runtime: string;
Type: string;
}
_, $ref: any$ref) => (const referenceCount: Map<string, number>referenceCount.Map<string, number>.get(key: string): number | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get($ref: any$ref) ?? 0) > 0)
},
artifacts: Array<Artifact>artifacts
}
function function (local function) ensureUniqueSanitized(originalRef: string): stringensureUniqueSanitized(originalRef: stringoriginalRef: string): string {
// Check if already mapped (consistency)
const const sanitized: string | undefinedsanitized = const sanitizedReferenceMap: Map<
string,
string
>
sanitizedReferenceMap.Map<string, string>.get(key: string): string | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get(originalRef: stringoriginalRef)
if (const sanitized: string | undefinedsanitized !== var undefinedundefined) {
return const sanitized: stringsanitized
}
// Find unique sanitized name
const const seed: stringseed = function sanitizeJavaScriptIdentifier(
s: string
): string
Converts an arbitrary string into a valid (ASCII) JavaScript identifier
starting with an uppercase letter, $, or _.
- Replaces invalid identifier characters with
_
- Uppercases a leading ASCII letter
- If the first character is a digit, prefixes
_
- Empty input becomes
_
sanitizeJavaScriptIdentifier(originalRef: stringoriginalRef)
let let candidate: stringcandidate = const seed: stringseed
let let suffix: numbersuffix = 0
while (const uniqueSanitizedReferences: Set<string>uniqueSanitizedReferences.Set<string>.has(value: string): booleanhas(let candidate: stringcandidate)) {
let candidate: stringcandidate = `${const seed: stringseed}${++let suffix: numbersuffix}`
}
const uniqueSanitizedReferences: Set<string>uniqueSanitizedReferences.Set<string>.add(value: string): Set<string>Appends a new element with a specified value to the end of the Set.
add(let candidate: stringcandidate)
const sanitizedReferenceMap: Map<
string,
string
>
sanitizedReferenceMap.Map<string, string>.set(key: string, value: string): Map<string, string>Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
set(originalRef: stringoriginalRef, let candidate: stringcandidate)
return let candidate: stringcandidate
}
function function (local function) addSymbol(s: symbol): stringaddSymbol(s: symbols: symbol): string {
const const identifier: stringidentifier = function (local function) ensureUniqueSanitized(originalRef: string): stringensureUniqueSanitized("_symbol")
const const key: string | undefinedkey = module globalThisglobalThis.var Symbol: SymbolConstructorSymbol.SymbolConstructor.keyFor(sym: symbol): string | undefinedReturns a key from the global symbol registry matching the given Symbol if found.
Otherwise, returns a undefined.
keyFor(s: symbols)
const const description: string | undefineddescription = s: symbols.Symbol.description: string | undefinedExpose the [[Description]] internal slot of a symbol directly.
description
const const generation: Codeconst generation: {
runtime: string;
Type: string;
}
generation = const key: string | undefinedkey === var undefinedundefined
? function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Symbol(${const description: string | undefineddescription === var undefinedundefined ? "" : import formatformat(const description: stringdescription)})`, `typeof ${const identifier: stringidentifier}`)
: function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Symbol.for(${import formatformat(const key: stringkey)})`, `typeof ${const identifier: stringidentifier}`)
const artifacts: Array<Artifact>artifacts.Array<Artifact>.push(...items: Artifact[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push({ _tag: "Symbol"_tag: "Symbol", identifier: stringidentifier, generation: Code(property) generation: {
runtime: string;
Type: string;
}
generation })
return const identifier: stringidentifier
}
function function (local function) addEnum(s: Enum): stringaddEnum(s: Enum(parameter) s: {
_tag: "Enum";
annotations: Schema.Annotations.Annotations | undefined;
enums: ReadonlyArray<readonly [string, string | number]>;
}
s: Enum): string {
const const identifier: stringidentifier = function (local function) ensureUniqueSanitized(originalRef: string): stringensureUniqueSanitized("_Enum")
const artifacts: Array<Artifact>artifacts.Array<Artifact>.push(...items: Artifact[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push({
_tag: "Enum"_tag: "Enum",
identifier: stringidentifier,
generation: Code(property) generation: {
runtime: string;
Type: string;
}
generation: function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`enum ${const identifier: stringidentifier} { ${s: Enum(parameter) s: {
_tag: "Enum";
annotations: Schema.Annotations.Annotations | undefined;
enums: ReadonlyArray<readonly [string, string | number]>;
}
s.Enum.enums: readonly (readonly [string, string | number])[]enums.ReadonlyArray<readonly [string, string | number]>.map<string>(callbackfn: (value: readonly [string, string | number], index: number, array: readonly (readonly [string, string | number])[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(([name: stringname, value: string | numbervalue]) => `${import formatformat(name: stringname)}: ${import formatformat(value: string | numbervalue)}`).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")} }`,
`typeof ${const identifier: stringidentifier}`
)
})
return const identifier: stringidentifier
}
function function (local function) addImport(importDeclaration: string): voidaddImport(importDeclaration: stringimportDeclaration: string) {
if (!const artifacts: Array<Artifact>artifacts.Array<Artifact>.some(predicate: (value: Artifact, index: number, array: Artifact[]) => unknown, thisArg?: any): booleanDetermines whether the specified callback function returns true for any element of an array.
some((a: Artifacta) => a: Artifacta._tag: "Symbol" | "Enum" | "Import"_tag === "Import" && a: {
readonly _tag: "Import"
readonly importDeclaration: string
}
a.importDeclaration: stringimportDeclaration === importDeclaration: stringimportDeclaration)) {
const artifacts: Array<Artifact>artifacts.Array<Artifact>.push(...items: Artifact[]): numberAppends new elements to the end of an array, and returns the new length of the array.
push({ _tag: "Import"_tag: "Import", importDeclaration: stringimportDeclaration })
}
}
function function (local function) recur(s: Representation): Coderecur(s: Representations: type Representation =
| Declaration
| Reference
| Suspend
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union
The core tagged union of all supported schema shapes.
Details
Each variant has a _tag discriminator. Switch on _tag to handle each
shape. Most variants carry optional annotations and some carry checks
for validation constraints.
Representation): type Code = {
readonly runtime: string
readonly Type: string
}
A pair of TypeScript source strings for a schema: runtime is the
executable Schema expression, Type is the corresponding TypeScript type.
Code {
const const g: Codeconst g: {
runtime: string;
Type: string;
}
g = function (local function) on(s: Representation): Codeon(s: Representations)
switch (s: Representations._tag: | "Declaration"
| "Suspend"
| "Reference"
| "Null"
| "Undefined"
| "Void"
| "Never"
| "Unknown"
| "Any"
| "String"
| "Number"
| "Boolean"
| "BigInt"
| "Symbol"
| "Literal"
| "UniqueSymbol"
| "ObjectKeyword"
| "Enum"
| "TemplateLiteral"
| "Arrays"
| "Objects"
| "Union"
_tag) {
default:
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
const g: Codeconst g: {
runtime: string;
Type: string;
}
g.runtime: stringruntime + function toRuntimeAnnotate(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotate(s: Representations.annotations?: anyannotations) + function toRuntimeBrand(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeBrand(s: Representations.annotations?: anyannotations),
const g: Codeconst g: {
runtime: string;
Type: string;
}
g.type Type: stringType + function (local function) toTypeBrand(annotations: Schema.Annotations.Annotations | undefined): stringtoTypeBrand(s: Representations.annotations?: anyannotations)
)
case "Reference":
return const g: Codeconst g: {
runtime: string;
Type: string;
}
g
case "Declaration":
case "String":
case "Number":
case "BigInt":
case "Arrays":
case "Objects":
case "Suspend":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
const g: Codeconst g: {
runtime: string;
Type: string;
}
g.runtime: stringruntime + function toRuntimeAnnotate(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotate(s: Representations.annotations?: anyannotations) + function toRuntimeBrand(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeBrand(s: Representations.annotations?: anyannotations) + function (local function) toRuntimeChecks(checks: ReadonlyArray<Check<Meta>>): stringtoRuntimeChecks(s: Representations.checks: readonly Check<any>[] | readonly []checks),
const g: Codeconst g: {
runtime: string;
Type: string;
}
g.type Type: stringType + function (local function) toTypeBrand(annotations: Schema.Annotations.Annotations | undefined): stringtoTypeBrand(s: Representations.annotations?: anyannotations) + function (local function) toTypeChecks(checks: ReadonlyArray<Check<Meta>>): stringtoTypeChecks(s: Representations.checks: readonly Check<any>[] | readonly []checks)
)
}
}
function function (local function) on(s: Representation): Codeon(s: Representations: type Representation =
| Declaration
| Reference
| Suspend
| Null
| Undefined
| Void
| Never
| Unknown
| Any
| String
| Number
| Boolean
| BigInt
| Symbol
| Literal
| UniqueSymbol
| ObjectKeyword
| Enum
| TemplateLiteral
| Arrays
| Objects
| Union
The core tagged union of all supported schema shapes.
Details
Each variant has a _tag discriminator. Switch on _tag to handle each
shape. Most variants carry optional annotations and some carry checks
for validation constraints.
Representation): type Code = {
readonly runtime: string
readonly Type: string
}
A pair of TypeScript source strings for a schema: runtime is the
executable Schema expression, Type is the corresponding TypeScript type.
Code {
switch (s: Representations._tag: | "Declaration"
| "Suspend"
| "Reference"
| "Null"
| "Undefined"
| "Void"
| "Never"
| "Unknown"
| "Any"
| "String"
| "Number"
| "Boolean"
| "BigInt"
| "Symbol"
| "Literal"
| "UniqueSymbol"
| "ObjectKeyword"
| "Enum"
| "TemplateLiteral"
| "Arrays"
| "Objects"
| "Union"
_tag) {
case "Declaration": {
// if there is a reviver, use it to generate the generation
if (options: {
readonly reviver?: Reviver<Code> | undefined
}
options?.reviver?: Reviver<Code> | undefinedThe reviver can return undefined to indicate that the generation should be generated by the default logic
reviver !== var undefinedundefined) {
// the reviver can return `undefined` to indicate that the generation should be generated by the default logic
const const out: Code | undefinedout = options: {
readonly reviver?: Reviver<Code> | undefined
}
options.reviver?: Reviver<Code> | undefinedThe reviver can return undefined to indicate that the generation should be generated by the default logic
reviver(s: Representation(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s, function (local function) recur(s: Representation): Coderecur)
if (const out: Code | undefinedout !== var undefinedundefined) {
return const out: Codeconst out: {
runtime: string;
Type: string;
}
out
}
}
// otherwise, use the generation from the annotations
const const generation: anygeneration = s: Representation(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s.Declaration.annotations?: anyannotations?.generation
if (
import PredicatePredicate.isObject(const generation: anygeneration) && typeof const generation: anygeneration.runtime === "string" &&
typeof const generation: anygeneration.Type === "string"
) {
const const typeParameters: Array<Code>typeParameters = s: Representation(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s.Declaration.typeParameters: ReadonlyArray<Representation>typeParameters.ReadonlyArray<Representation>.map<Code>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(function (local function) recur(s: Representation): Coderecur)
if (typeof const generation: anygeneration.importDeclaration === "string") {
function (local function) addImport(importDeclaration: string): voidaddImport(const generation: anygeneration.importDeclaration)
}
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
function replacePlaceholders(
template: string,
items: ReadonlyArray<string>
): string
replacePlaceholders(const generation: anygeneration.runtime, const typeParameters: Array<Code>typeParameters.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.runtime: stringruntime)),
function replacePlaceholders(
template: string,
items: ReadonlyArray<string>
): string
replacePlaceholders(const generation: anygeneration.Type, const typeParameters: Array<Code>typeParameters.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.type Type: stringType))
)
}
// otherwise, use the generation from the encoded schema
return function (local function) recur(s: Representation): Coderecur(s: Representation(parameter) s: {
_tag: "Declaration";
annotations: Schema.Annotations.Annotations | undefined;
typeParameters: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<DeclarationMeta>>;
encodedSchema: Representation;
}
s.Declaration.encodedSchema: RepresentationencodedSchema)
}
case "Reference": {
const const sanitized: stringsanitized = function (local function) ensureUniqueSanitized(originalRef: string): stringensureUniqueSanitized(s: Representation(parameter) s: {
_tag: "Reference";
$ref: string;
}
s.Reference.$ref: string$ref)
const referenceCount: Map<string, number>referenceCount.Map<string, number>.set(key: string, value: number): Map<string, number>Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.
set(const sanitized: stringsanitized, (const referenceCount: Map<string, number>referenceCount.Map<string, number>.get(key: string): number | undefinedReturns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
get(const sanitized: stringsanitized) ?? 0) + 1)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(const sanitized: stringsanitized, const sanitized: stringsanitized)
}
case "Suspend": {
const const thunk: Codeconst thunk: {
runtime: string;
Type: string;
}
thunk = function (local function) recur(s: Representation): Coderecur(s: Representation(parameter) s: {
_tag: "Suspend";
annotations: Schema.Annotations.Annotations | undefined;
checks: readonly [];
thunk: Representation;
}
s.Suspend.thunk: Representationthunk)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.suspend((): Schema.Codec<${const thunk: Codeconst thunk: {
runtime: string;
Type: string;
}
thunk.type Type: stringType}> => ${const thunk: Codeconst thunk: {
runtime: string;
Type: string;
}
thunk.runtime: stringruntime})`,
const thunk: Codeconst thunk: {
runtime: string;
Type: string;
}
thunk.type Type: stringType
)
}
case "Null":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Null`, "null")
case "Undefined":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Undefined`, "undefined")
case "Void":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Void`, "void")
case "Never":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Never`, "never")
case "Unknown":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Unknown`, "unknown")
case "Any":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Any`, "any")
case "Number":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Number`, "number")
case "Boolean":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Boolean`, "boolean")
case "BigInt":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.BigInt`, "bigint")
case "Symbol":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Symbol`, "symbol")
case "String": {
const const contentMediaType: string | undefinedcontentMediaType = s: Representation(parameter) s: {
_tag: "String";
annotations: Schema.Annotations.Annotations | undefined;
checks: ReadonlyArray<Check<StringMeta>>;
contentMediaType: string | undefined;
contentSchema: Representation | undefined;
}
s.String.contentMediaType?: string | undefinedcontentMediaType
const const contentSchema:
| Representation
| undefined
contentSchema = s: Representation(parameter) s: {
_tag: "String";
annotations: Schema.Annotations.Annotations | undefined;
checks: ReadonlyArray<Check<StringMeta>>;
contentMediaType: string | undefined;
contentSchema: Representation | undefined;
}
s.String.contentSchema?: Representation | undefinedcontentSchema
if (const contentMediaType: string | undefinedcontentMediaType === "application/json" && const contentSchema:
| Representation
| undefined
contentSchema !== var undefinedundefined) {
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.fromJsonString(${function (local function) recur(s: Representation): Coderecur(const contentSchema: RepresentationcontentSchema)})`, "string")
} else {
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.String`, "string")
}
}
case "Literal": {
const const literal: anyliteral = import formatformat(s: Representation(parameter) s: {
_tag: "Literal";
annotations: Schema.Annotations.Annotations | undefined;
literal: string | number | boolean | bigint;
}
s.Literal.literal: string | number | bigint | booleanliteral)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Literal(${const literal: anyliteral})`, const literal: anyliteral)
}
case "UniqueSymbol": {
const const identifier: stringidentifier = function (local function) addSymbol(s: symbol): stringaddSymbol(s: Representation(parameter) s: {
_tag: "UniqueSymbol";
annotations: Schema.Annotations.Annotations | undefined;
symbol: symbol;
}
s.UniqueSymbol.symbol: symbolsymbol)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.UniqueSymbol(${const identifier: stringidentifier})`, `typeof ${const identifier: stringidentifier}`)
}
case "ObjectKeyword":
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.ObjectKeyword`, "object")
case "Enum": {
const const identifier: stringidentifier = function (local function) addEnum(s: Enum): stringaddEnum(s: Representation(parameter) s: {
_tag: "Enum";
annotations: Schema.Annotations.Annotations | undefined;
enums: ReadonlyArray<readonly [string, string | number]>;
}
s)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Enum(${const identifier: stringidentifier})`, `typeof ${const identifier: stringidentifier}`)
}
case "TemplateLiteral": {
const const parts: Array<Code>parts = s: Representation(parameter) s: {
_tag: "TemplateLiteral";
annotations: Schema.Annotations.Annotations | undefined;
parts: ReadonlyArray<Representation>;
}
s.TemplateLiteral.parts: ReadonlyArray<Representation>parts.ReadonlyArray<Representation>.map<Code>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(function (local function) recur(s: Representation): Coderecur)
const const type: stringtype = function toTypeParts(
parts: ReadonlyArray<Representation>
): ReadonlyArray<string>
toTypeParts(s: Representation(parameter) s: {
_tag: "TemplateLiteral";
annotations: Schema.Annotations.Annotations | undefined;
parts: ReadonlyArray<Representation>;
}
s.TemplateLiteral.parts: ReadonlyArray<Representation>parts).ReadonlyArray<string>.map<string>(callbackfn: (value: string, index: number, array: readonly string[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: stringp) => "`" + p: stringp + "`").Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(" | ")
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.TemplateLiteral([${const parts: Array<Code>parts.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.runtime: stringruntime).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}])`, const type: stringtype)
}
case "Arrays": {
const const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements = s: Representation(parameter) s: {
_tag: "Arrays";
annotations: Schema.Annotations.Annotations | undefined;
elements: ReadonlyArray<Element>;
rest: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<ArraysMeta>>;
}
s.Arrays.elements: ReadonlyArray<Element>elements.ReadonlyArray<Element>.map<{
isOptional: boolean;
type: Code;
annotations: any;
}>(callbackfn: (value: Element, index: number, array: readonly Element[]) => {
isOptional: boolean;
type: Code;
annotations: any;
}, thisArg?: any): {
isOptional: boolean;
type: Code;
annotations: any;
}[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((e: Element(parameter) e: {
isOptional: boolean;
type: Representation;
annotations: Schema.Annotations.Annotations | undefined;
}
e) => {
return {
isOptional: booleanisOptional: e: Element(parameter) e: {
isOptional: boolean;
type: Representation;
annotations: Schema.Annotations.Annotations | undefined;
}
e.Element.isOptional: booleanisOptional,
type: Code(property) type: {
runtime: string;
Type: string;
}
type: function (local function) recur(s: Representation): Coderecur(e: Element(parameter) e: {
isOptional: boolean;
type: Representation;
annotations: Schema.Annotations.Annotations | undefined;
}
e.Element.type: Representationtype),
annotations: anyannotations: e: Element(parameter) e: {
isOptional: boolean;
type: Representation;
annotations: Schema.Annotations.Annotations | undefined;
}
e.Element.annotations?: anyannotations
}
})
const const rest: Array<Code>rest = s: Representation(parameter) s: {
_tag: "Arrays";
annotations: Schema.Annotations.Annotations | undefined;
elements: ReadonlyArray<Element>;
rest: ReadonlyArray<Representation>;
checks: ReadonlyArray<Check<ArraysMeta>>;
}
s.Arrays.rest: ReadonlyArray<Representation>rest.ReadonlyArray<Representation>.map<Code>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map(function (local function) recur(s: Representation): Coderecur)
if (import ArrArr.isArrayNonEmpty(const rest: Array<Code>rest)) {
const const item: Codeconst item: {
runtime: string;
Type: string;
}
item = const rest: Code[]const rest: {
0: Code;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => Code | undefined;
push: (...items: Array<Code>) => number;
concat: { (...items: Array<ConcatArray<Code>>): Array<Code>; (...items: Array<Code | ConcatArray<Code>>): Array<Code> };
join: (separator?: string) => string;
reverse: () => Array<Code>;
shift: () => Code | undefined;
slice: (start?: number, end?: number) => Array<Code>;
sort: (compareFn?: ((a: Code, b: Code) => number) | undefined) => [Code, ...Code[]];
splice: { (start: number, deleteCount?: number): Array<Code>; (start: number, deleteCount: number, ...items: Array<Code>): Array<Code> };
unshift: (...items: Array<Code>) => number;
indexOf: (searchElement: Code, fromIndex?: number) => number;
lastIndexOf: (searchElement: Code, fromIndex?: number) => number;
every: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): this is S[]; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Code, index: number, array: Array<Code>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Code, index: number, array: Array<Code>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Array<Code> };
reduce: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
reduceRight: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
find: { (predicate: (value: Code, index: number, obj: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findIndex: (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any) => number;
fill: (value: Code, start?: number, end?: number) => [Code, ...Code[]];
copyWithin: (target: number, start: number, end?: number) => [Code, ...Code[]];
entries: () => ArrayIterator<[number, Code]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Code>;
includes: (searchElement: Code, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Code, index: number, array: Array<Code>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Code | undefined;
findLast: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findLastIndex: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Code>;
toSorted: (compareFn?: ((a: Code, b: Code) => number) | undefined) => Array<Code>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Code>): Array<Code>; (start: number, deleteCount?: number): Array<Code> };
with: (index: number, value: Code) => Array<Code>;
}
rest[0]
if (const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 0 && const rest: Code[]const rest: {
0: Code;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => Code | undefined;
push: (...items: Array<Code>) => number;
concat: { (...items: Array<ConcatArray<Code>>): Array<Code>; (...items: Array<Code | ConcatArray<Code>>): Array<Code> };
join: (separator?: string) => string;
reverse: () => Array<Code>;
shift: () => Code | undefined;
slice: (start?: number, end?: number) => Array<Code>;
sort: (compareFn?: ((a: Code, b: Code) => number) | undefined) => [Code, ...Code[]];
splice: { (start: number, deleteCount?: number): Array<Code>; (start: number, deleteCount: number, ...items: Array<Code>): Array<Code> };
unshift: (...items: Array<Code>) => number;
indexOf: (searchElement: Code, fromIndex?: number) => number;
lastIndexOf: (searchElement: Code, fromIndex?: number) => number;
every: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): this is S[]; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Code, index: number, array: Array<Code>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Code, index: number, array: Array<Code>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Array<Code> };
reduce: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
reduceRight: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
find: { (predicate: (value: Code, index: number, obj: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findIndex: (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any) => number;
fill: (value: Code, start?: number, end?: number) => [Code, ...Code[]];
copyWithin: (target: number, start: number, end?: number) => [Code, ...Code[]];
entries: () => ArrayIterator<[number, Code]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Code>;
includes: (searchElement: Code, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Code, index: number, array: Array<Code>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Code | undefined;
findLast: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findLastIndex: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Code>;
toSorted: (compareFn?: ((a: Code, b: Code) => number) | undefined) => Array<Code>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Code>): Array<Code>; (start: number, deleteCount?: number): Array<Code> };
with: (index: number, value: Code) => Array<Code>;
}
rest.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 1) {
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.Array(${const item: Codeconst item: {
runtime: string;
Type: string;
}
item.runtime: stringruntime})`,
`ReadonlyArray<${const item: Codeconst item: {
runtime: string;
Type: string;
}
item.type Type: stringType}>`
)
}
const const post: Array<Code>post = const rest: Code[]const rest: {
0: Code;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => Code | undefined;
push: (...items: Array<Code>) => number;
concat: { (...items: Array<ConcatArray<Code>>): Array<Code>; (...items: Array<Code | ConcatArray<Code>>): Array<Code> };
join: (separator?: string) => string;
reverse: () => Array<Code>;
shift: () => Code | undefined;
slice: (start?: number, end?: number) => Array<Code>;
sort: (compareFn?: ((a: Code, b: Code) => number) | undefined) => [Code, ...Code[]];
splice: { (start: number, deleteCount?: number): Array<Code>; (start: number, deleteCount: number, ...items: Array<Code>): Array<Code> };
unshift: (...items: Array<Code>) => number;
indexOf: (searchElement: Code, fromIndex?: number) => number;
lastIndexOf: (searchElement: Code, fromIndex?: number) => number;
every: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): this is S[]; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Code, index: number, array: Array<Code>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Code, index: number, array: Array<Code>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Array<Code> };
reduce: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
reduceRight: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
find: { (predicate: (value: Code, index: number, obj: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findIndex: (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any) => number;
fill: (value: Code, start?: number, end?: number) => [Code, ...Code[]];
copyWithin: (target: number, start: number, end?: number) => [Code, ...Code[]];
entries: () => ArrayIterator<[number, Code]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Code>;
includes: (searchElement: Code, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Code, index: number, array: Array<Code>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Code | undefined;
findLast: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findLastIndex: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Code>;
toSorted: (compareFn?: ((a: Code, b: Code) => number) | undefined) => Array<Code>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Code>): Array<Code>; (start: number, deleteCount?: number): Array<Code> };
with: (index: number, value: Code) => Array<Code>;
}
rest.Array<Code>.slice(start?: number, end?: number): Code[]Returns a copy of a section of an array.
For both start and end, a negative index can be used to indicate an offset from the end of the array.
For example, -2 refers to the second to last element of the array.
slice(1)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.TupleWithRest(Schema.Tuple([${
const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements.Array<{ isOptional: boolean; type: Code; annotations: any; }>.map<string>(callbackfn: (value: {
isOptional: boolean;
type: Code;
annotations: any;
}, index: number, array: {
isOptional: boolean;
type: Code;
annotations: any;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((e: {
isOptional: boolean
type: Code
annotations: any
}
e) =>
function toRuntimeIsOptional(
isOptional: boolean,
runtime: string
): string
toRuntimeIsOptional(e: {
isOptional: boolean
type: Code
annotations: any
}
e.isOptional: booleanisOptional, e: {
isOptional: boolean
type: Code
annotations: any
}
e.type: Code(property) type: {
runtime: string;
Type: string;
}
type.runtime: stringruntime) + function toRuntimeAnnotateKey(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotateKey(e: {
isOptional: boolean
type: Code
annotations: any
}
e.annotations: anyannotations)
).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")
}]), [${const rest: Code[]const rest: {
0: Code;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
pop: () => Code | undefined;
push: (...items: Array<Code>) => number;
concat: { (...items: Array<ConcatArray<Code>>): Array<Code>; (...items: Array<Code | ConcatArray<Code>>): Array<Code> };
join: (separator?: string) => string;
reverse: () => Array<Code>;
shift: () => Code | undefined;
slice: (start?: number, end?: number) => Array<Code>;
sort: (compareFn?: ((a: Code, b: Code) => number) | undefined) => [Code, ...Code[]];
splice: { (start: number, deleteCount?: number): Array<Code>; (start: number, deleteCount: number, ...items: Array<Code>): Array<Code> };
unshift: (...items: Array<Code>) => number;
indexOf: (searchElement: Code, fromIndex?: number) => number;
lastIndexOf: (searchElement: Code, fromIndex?: number) => number;
every: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): this is S[]; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): boolean };
some: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Code, index: number, array: Array<Code>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Code, index: number, array: Array<Code>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Array<Code> };
reduce: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
reduceRight: { (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code): Code; (callbackfn: (previousValue: Code, currentValue: Code, currentIndex: number, array: Array<Code>) => Code, initialValue: Code…;
find: { (predicate: (value: Code, index: number, obj: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findIndex: (predicate: (value: Code, index: number, obj: Array<Code>) => unknown, thisArg?: any) => number;
fill: (value: Code, start?: number, end?: number) => [Code, ...Code[]];
copyWithin: (target: number, start: number, end?: number) => [Code, ...Code[]];
entries: () => ArrayIterator<[number, Code]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Code>;
includes: (searchElement: Code, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Code, index: number, array: Array<Code>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Code | undefined;
findLast: { (predicate: (value: Code, index: number, array: Array<Code>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any): Code | undefined };
findLastIndex: (predicate: (value: Code, index: number, array: Array<Code>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Code>;
toSorted: (compareFn?: ((a: Code, b: Code) => number) | undefined) => Array<Code>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Code>): Array<Code>; (start: number, deleteCount?: number): Array<Code> };
with: (index: number, value: Code) => Array<Code>;
}
rest.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((r: Code(parameter) r: {
runtime: string;
Type: string;
}
r) => r: Code(parameter) r: {
runtime: string;
Type: string;
}
r.runtime: stringruntime).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}])`,
`readonly [${
const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements.Array<{ isOptional: boolean; type: Code; annotations: any; }>.map<string>(callbackfn: (value: {
isOptional: boolean;
type: Code;
annotations: any;
}, index: number, array: {
isOptional: boolean;
type: Code;
annotations: any;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((e: {
isOptional: boolean
type: Code
annotations: any
}
e) => function toTypeIsOptional(
isOptional: boolean,
type: string
): string
toTypeIsOptional(e: {
isOptional: boolean
type: Code
annotations: any
}
e.isOptional: booleanisOptional, e: {
isOptional: boolean
type: Code
annotations: any
}
e.type: Code(property) type: {
runtime: string;
Type: string;
}
type.type Type: stringType)).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")
}, ...Array<${const item: Codeconst item: {
runtime: string;
Type: string;
}
item.type Type: stringType}>${const post: Array<Code>post.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length > 0 ? `, ${const post: Array<Code>post.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.type Type: stringType).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}` : ""}]`
)
}
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.Tuple([${
const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements.Array<{ isOptional: boolean; type: Code; annotations: any; }>.map<string>(callbackfn: (value: {
isOptional: boolean;
type: Code;
annotations: any;
}, index: number, array: {
isOptional: boolean;
type: Code;
annotations: any;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((e: {
isOptional: boolean
type: Code
annotations: any
}
e) => function toRuntimeIsOptional(
isOptional: boolean,
runtime: string
): string
toRuntimeIsOptional(e: {
isOptional: boolean
type: Code
annotations: any
}
e.isOptional: booleanisOptional, e: {
isOptional: boolean
type: Code
annotations: any
}
e.type: Code(property) type: {
runtime: string;
Type: string;
}
type.runtime: stringruntime) + function toRuntimeAnnotateKey(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotateKey(e: {
isOptional: boolean
type: Code
annotations: any
}
e.annotations: anyannotations))
.Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")
}])`,
`readonly [${const elements: {
isOptional: boolean
type: Code
annotations: any
}[]
elements.Array<{ isOptional: boolean; type: Code; annotations: any; }>.map<string>(callbackfn: (value: {
isOptional: boolean;
type: Code;
annotations: any;
}, index: number, array: {
isOptional: boolean;
type: Code;
annotations: any;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((e: {
isOptional: boolean
type: Code
annotations: any
}
e) => function toTypeIsOptional(
isOptional: boolean,
type: string
): string
toTypeIsOptional(e: {
isOptional: boolean
type: Code
annotations: any
}
e.isOptional: booleanisOptional, e: {
isOptional: boolean
type: Code
annotations: any
}
e.type: Code(property) type: {
runtime: string;
Type: string;
}
type.type Type: stringType)).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}]`
)
}
case "Objects": {
const const pss: Array<Code>pss = s: Representation(parameter) s: {
_tag: "Objects";
annotations: Schema.Annotations.Annotations | undefined;
propertySignatures: ReadonlyArray<PropertySignature>;
indexSignatures: ReadonlyArray<IndexSignature>;
checks: ReadonlyArray<Check<ObjectsMeta>>;
}
s.Objects.propertySignatures: ReadonlyArray<PropertySignature>propertySignatures.ReadonlyArray<PropertySignature>.map<Code>(callbackfn: (value: PropertySignature, index: number, array: readonly PropertySignature[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p) => {
const const isSymbol: booleanisSymbol = typeof p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.name: PropertyKeyname === "symbol"
const const name: anyname = const isSymbol: booleanisSymbol ? function (local function) addSymbol(s: symbol): stringaddSymbol(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.name: symbolname) : import formatPropertyKeyformatPropertyKey(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.name: string | numbername)
const const nameType: stringnameType = function toTypeIsOptional(
isOptional: boolean,
type: string
): string
toTypeIsOptional(
p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.isOptional: booleanisOptional,
function toTypeIsMutable(
isMutable: boolean,
type: string
): string
toTypeIsMutable(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.isMutable: booleanisMutable, const isSymbol: booleanisSymbol ? `[typeof ${const name: anyname}]` : const name: anyname)
)
const const type: Codeconst type: {
runtime: string;
Type: string;
}
type = function (local function) recur(s: Representation): Coderecur(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.type: Representationtype)
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`${const isSymbol: booleanisSymbol ? `[${const name: anyname}]` : const name: anyname}: ${
function toRuntimeIsOptional(
isOptional: boolean,
runtime: string
): string
toRuntimeIsOptional(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.isOptional: booleanisOptional, function toRuntimeIsMutable(
isMutable: boolean,
runtime: string
): string
toRuntimeIsMutable(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.isMutable: booleanisMutable, const type: Codeconst type: {
runtime: string;
Type: string;
}
type.runtime: stringruntime))
}` +
function toRuntimeAnnotateKey(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotateKey(p: PropertySignature(parameter) p: {
name: PropertyKey;
type: Representation;
isOptional: boolean;
isMutable: boolean;
annotations: Schema.Annotations.Annotations | undefined;
}
p.PropertySignature.annotations?: anyannotations),
`${const nameType: stringnameType}: ${const type: Codeconst type: {
runtime: string;
Type: string;
}
type.type Type: stringType}`
)
})
const const iss: {
parameter: Code
type: Code
}[]
iss = s: Representation(parameter) s: {
_tag: "Objects";
annotations: Schema.Annotations.Annotations | undefined;
propertySignatures: ReadonlyArray<PropertySignature>;
indexSignatures: ReadonlyArray<IndexSignature>;
checks: ReadonlyArray<Check<ObjectsMeta>>;
}
s.Objects.indexSignatures: ReadonlyArray<IndexSignature>indexSignatures.ReadonlyArray<IndexSignature>.map<{
parameter: Code;
type: Code;
}>(callbackfn: (value: IndexSignature, index: number, array: readonly IndexSignature[]) => {
parameter: Code;
type: Code;
}, thisArg?: any): {
parameter: Code;
type: Code;
}[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((is: IndexSignature(parameter) is: {
parameter: Representation;
type: Representation;
}
is) => {
return {
parameter: Code(property) parameter: {
runtime: string;
Type: string;
}
parameter: function (local function) recur(s: Representation): Coderecur(is: IndexSignature(parameter) is: {
parameter: Representation;
type: Representation;
}
is.IndexSignature.parameter: Representationparameter),
type: Code(property) type: {
runtime: string;
Type: string;
}
type: function (local function) recur(s: Representation): Coderecur(is: IndexSignature(parameter) is: {
parameter: Representation;
type: Representation;
}
is.IndexSignature.type: Representationtype)
}
})
if (const iss: {
parameter: Code
type: Code
}[]
iss.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 0) {
// 1) Only properties -> Struct
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.Struct({ ${const pss: Array<Code>pss.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.runtime: stringruntime).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")} })`,
`{ ${const pss: Array<Code>pss.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.type Type: stringType).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")} }`
)
} else if (const pss: Array<Code>pss.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 0 && const iss: {
parameter: Code
type: Code
}[]
iss.Array<T>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 1) {
// 2) Only one index signature and no properties -> Record
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.Record(${const iss: {
parameter: Code
type: Code
}[]
iss[0].parameter: Code(property) parameter: {
runtime: string;
Type: string;
}
parameter.runtime: stringruntime}, ${const iss: {
parameter: Code
type: Code
}[]
iss[0].type: Code(property) type: {
runtime: string;
Type: string;
}
type.runtime: stringruntime})`,
`{ readonly [x: ${const iss: {
parameter: Code
type: Code
}[]
iss[0].parameter: Code(property) parameter: {
runtime: string;
Type: string;
}
parameter.type Type: stringType}]: ${const iss: {
parameter: Code
type: Code
}[]
iss[0].type: Code(property) type: {
runtime: string;
Type: string;
}
type.type Type: stringType} }`
)
} else {
// 3) Properties + index signatures -> StructWithRest
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.StructWithRest(Schema.Struct({ ${const pss: Array<Code>pss.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.runtime: stringruntime).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")} }), [${
const iss: {
parameter: Code
type: Code
}[]
iss.Array<{ parameter: Code; type: Code; }>.map<string>(callbackfn: (value: {
parameter: Code;
type: Code;
}, index: number, array: {
parameter: Code;
type: Code;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((is: {
parameter: Code
type: Code
}
is) => `Schema.Record(${is: {
parameter: Code
type: Code
}
is.parameter: Code(property) parameter: {
runtime: string;
Type: string;
}
parameter.runtime: stringruntime}, ${is: {
parameter: Code
type: Code
}
is.type: Code(property) type: {
runtime: string;
Type: string;
}
type.runtime: stringruntime})`).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")
}])`,
`{ ${const pss: Array<Code>pss.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((p: Code(parameter) p: {
runtime: string;
Type: string;
}
p) => p: Code(parameter) p: {
runtime: string;
Type: string;
}
p.type Type: stringType).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}, ${
const iss: {
parameter: Code
type: Code
}[]
iss.Array<{ parameter: Code; type: Code; }>.map<string>(callbackfn: (value: {
parameter: Code;
type: Code;
}, index: number, array: {
parameter: Code;
type: Code;
}[]) => string, thisArg?: any): string[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((is: {
parameter: Code
type: Code
}
is) => `readonly [x: ${is: {
parameter: Code
type: Code
}
is.parameter: Code(property) parameter: {
runtime: string;
Type: string;
}
parameter.type Type: stringType}]: ${is: {
parameter: Code
type: Code
}
is.type: Code(property) type: {
runtime: string;
Type: string;
}
type.type Type: stringType}`).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")
} }`
)
}
}
case "Union": {
if (s: Representation(parameter) s: {
_tag: "Union";
annotations: Schema.Annotations.Annotations | undefined;
types: ReadonlyArray<Representation>;
mode: "anyOf" | "oneOf";
}
s.Union.types: ReadonlyArray<Representation>types.ReadonlyArray<Representation>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0) {
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode("Schema.Never", "never")
}
if (s: Representation(parameter) s: {
_tag: "Union";
annotations: Schema.Annotations.Annotations | undefined;
types: ReadonlyArray<Representation>;
mode: "anyOf" | "oneOf";
}
s.Union.types: ReadonlyArray<Representation>types.ReadonlyArray<Representation>.every<Literal>(predicate: (value: Representation, index: number, array: readonly Representation[]) => value is Literal, thisArg?: any): this is readonly S[] (+1 overload)Determines whether all the members of an array satisfy the specified test.
every((t: Representationt) => t: Representationt._tag: | "Declaration"
| "Suspend"
| "Reference"
| "Null"
| "Undefined"
| "Void"
| "Never"
| "Unknown"
| "Any"
| "String"
| "Number"
| "Boolean"
| "BigInt"
| "Symbol"
| "Literal"
| "UniqueSymbol"
| "ObjectKeyword"
| "Enum"
| "TemplateLiteral"
| "Arrays"
| "Objects"
| "Union"
_tag === "Literal")) {
const const literals: any[]literals = s: Representation(parameter) s: {
_tag: "Union";
annotations: Schema.Annotations.Annotations | undefined;
types: ReadonlyArray<Representation>;
mode: "anyOf" | "oneOf";
}
s.Union.types: ReadonlyArray<Representation>types.ReadonlyArray<Literal>.map<any>(callbackfn: (value: Literal, index: number, array: readonly Literal[]) => any, thisArg?: any): any[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((l: Literal(parameter) l: {
_tag: "Literal";
annotations: Schema.Annotations.Annotations | undefined;
literal: string | number | boolean | bigint;
}
l) => import formatformat(l: Literal(parameter) l: {
_tag: "Literal";
annotations: Schema.Annotations.Annotations | undefined;
literal: string | number | boolean | bigint;
}
l.Literal.literal: string | number | bigint | booleanliteral))
if (const literals: any[]literals.Array<any>.length: numberGets or sets the length of the array. This is a number one higher than the highest index in the array.
length === 1) {
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Literal(${const literals: any[]literals[0]})`, const literals: any[]literals[0])
}
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(`Schema.Literals([${const literals: any[]literals.Array<any>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}])`, const literals: any[]literals.Array<any>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(" | "))
}
const const mode: "" | ', { mode: "oneOf" }'mode = s: Representation(parameter) s: {
_tag: "Union";
annotations: Schema.Annotations.Annotations | undefined;
types: ReadonlyArray<Representation>;
mode: "anyOf" | "oneOf";
}
s.Union.mode: "anyOf" | "oneOf"mode === "anyOf" ? "" : `, { mode: "oneOf" }`
const const types: Array<Code>types = s: Representation(parameter) s: {
_tag: "Union";
annotations: Schema.Annotations.Annotations | undefined;
types: ReadonlyArray<Representation>;
mode: "anyOf" | "oneOf";
}
s.Union.types: ReadonlyArray<Representation>types.ReadonlyArray<Representation>.map<Code>(callbackfn: (value: Representation, index: number, array: readonly Representation[]) => Code, thisArg?: any): Code[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((t: Representationt) => function (local function) recur(s: Representation): Coderecur(t: Representationt))
return function makeCode(
runtime: string,
Type: string
): Code
Constructs a
Code
value from a runtime expression string and a
TypeScript type string.
makeCode(
`Schema.Union([${const types: Array<Code>types.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((t: Code(parameter) t: {
runtime: string;
Type: string;
}
t) => t: Code(parameter) t: {
runtime: string;
Type: string;
}
t.runtime: stringruntime).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}]${const mode: "" | ', { mode: "oneOf" }'mode})`,
const types: Array<Code>types.Array<Code>.map<string>(callbackfn: (value: Code, index: number, array: Code[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((t: Code(parameter) t: {
runtime: string;
Type: string;
}
t) => t: Code(parameter) t: {
runtime: string;
Type: string;
}
t.type Type: stringType).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(" | ")
)
}
}
}
function function (local function) toTypeBrand(annotations: Schema.Annotations.Annotations | undefined): stringtoTypeBrand(annotations: anyannotations: import SchemaSchema.declareAnnotations.type Schema.Annotations.Annotations = /*unresolved*/ anyAnnotations | undefined): string {
const const brands: readonly string[]brands = function collectBrands(annotations: Schema.Annotations.Annotations | undefined): ReadonlyArray<string>collectBrands(annotations: anyannotations)
if (const brands: readonly string[]brands.ReadonlyArray<T>.length: numberGets the length of the array. This is a number one higher than the highest element defined in an array.
length === 0) return ""
function (local function) addImport(importDeclaration: string): voidaddImport(`import type * as Brand from "effect/Brand"`)
return const brands: readonly string[]brands.ReadonlyArray<string>.map<string>(callbackfn: (value: string, index: number, array: readonly string[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((b: stringb) => ` & Brand.Brand<${import formatformat(b: stringb)}>`).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join("")
}
function function (local function) toTypeChecks(checks: ReadonlyArray<Check<Meta>>): stringtoTypeChecks(checks: ReadonlyArray<Check<Meta>>checks: interface ReadonlyArray<T>ReadonlyArray<type Check<M> = Filter<M> | FilterGroup<M>A validation constraint attached to a type. Either a single
Filter
or a
FilterGroup
combining multiple checks.
Check<type Meta = anyMeta>>): string {
return checks: ReadonlyArray<Check<Meta>>checks.ReadonlyArray<Check<any>>.map<string>(callbackfn: (value: Check<any>, index: number, array: readonly Check<any>[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((c: Check<Meta>c) => function (local function) toTypeCheck(check: Check<Meta>): stringtoTypeCheck(c: Check<Meta>c)).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join("")
}
function function (local function) toTypeCheck(check: Check<Meta>): stringtoTypeCheck(check: Check<Meta>check: type Check<M> = Filter<M> | FilterGroup<M>A validation constraint attached to a type. Either a single
Filter
or a
FilterGroup
combining multiple checks.
Check<type Meta = anyMeta>): string {
switch (check: Check<Meta>check._tag: "Filter" | "FilterGroup"_tag) {
case "Filter":
return function (local function) toTypeBrand(annotations: Schema.Annotations.Annotations | undefined): stringtoTypeBrand(check: Check<Meta>(parameter) check: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
check.Filter<M>.annotations?: anyannotations)
case "FilterGroup": {
return function (local function) toTypeChecks(checks: ReadonlyArray<Check<Meta>>): stringtoTypeChecks(check: Check<Meta>(parameter) check: {
_tag: "FilterGroup";
annotations: Schema.Annotations.Filter | undefined;
checks: readonly [Check<M>, ...Array<Check<M>>];
}
check.FilterGroup<any>.checks: readonly [Check<M>, ...Array<Check<M>>](property) FilterGroup<any>.checks: {
0: Check<Meta>;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<Check<Meta>>>): Array<Check<Meta>>; (...items: Array<Check<Meta> | ConcatArray<Check<Meta>>>): Array<Check<Meta>> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<Check<Meta>>;
indexOf: (searchElement: Check<Meta>, fromIndex?: number) => number;
lastIndexOf: (searchElement: Check<Meta>, fromIndex?: number) => number;
every: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisAr…;
some: (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any): Ar…;
reduce: { (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex: number, array: ReadonlyArray<Check<Meta>>) => Check<Meta>): Check<Meta>; (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex…;
reduceRight: { (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex: number, array: ReadonlyArray<Check<Meta>>) => Check<Meta>): Check<Meta>; (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex…;
find: { (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any): C…;
findIndex: (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, Check<Meta>]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Check<Meta>>;
includes: (searchElement: Check<Meta>, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Check<Meta>, index: number, array: Array<Check<Meta>>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Check<Meta> | undefined;
findLast: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any…;
findLastIndex: (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Check<Meta>>;
toSorted: (compareFn?: ((a: Check<Meta>, b: Check<Meta>) => number) | undefined) => Array<Check<Meta>>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Check<Meta>>): Array<Check<Meta>>; (start: number, deleteCount?: number): Array<Check<Meta>> };
with: (index: number, value: Check<Meta>) => Array<Check<Meta>>;
}
checks)
}
}
}
function function (local function) toRuntimeChecks(checks: ReadonlyArray<Check<Meta>>): stringtoRuntimeChecks(checks: ReadonlyArray<Check<Meta>>checks: interface ReadonlyArray<T>ReadonlyArray<type Check<M> = Filter<M> | FilterGroup<M>A validation constraint attached to a type. Either a single
Filter
or a
FilterGroup
combining multiple checks.
Check<type Meta = anyMeta>>): string {
return checks: ReadonlyArray<Check<Meta>>checks.ReadonlyArray<Check<any>>.map<string>(callbackfn: (value: Check<any>, index: number, array: readonly Check<any>[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((c: Check<Meta>c) => `.check(${function (local function) toRuntimeCheck(check: Check<Meta>): stringtoRuntimeCheck(c: Check<Meta>c)})` + function toRuntimeBrand(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeBrand(c: Check<Meta>c.annotations?: anyannotations)).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join("")
}
function function (local function) toRuntimeCheck(check: Check<Meta>): stringtoRuntimeCheck(check: Check<Meta>check: type Check<M> = Filter<M> | FilterGroup<M>A validation constraint attached to a type. Either a single
Filter
or a
FilterGroup
combining multiple checks.
Check<type Meta = anyMeta>): string {
switch (check: Check<Meta>check._tag: "Filter" | "FilterGroup"_tag) {
case "Filter":
return function (local function) toRuntimeFilter(filter: Filter<Meta>): stringtoRuntimeFilter(check: Check<Meta>(parameter) check: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
check)
case "FilterGroup": {
const const a: stringa = function toRuntimeAnnotations(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotations(check: Check<Meta>(parameter) check: {
_tag: "FilterGroup";
annotations: Schema.Annotations.Filter | undefined;
checks: readonly [Check<M>, ...Array<Check<M>>];
}
check.FilterGroup<M>.annotations?: anyannotations)
const const ca: stringca = const a: stringa === "" ? "" : `, ${const a: stringa}`
return `Schema.makeFilterGroup([${check: Check<Meta>(parameter) check: {
_tag: "FilterGroup";
annotations: Schema.Annotations.Filter | undefined;
checks: readonly [Check<M>, ...Array<Check<M>>];
}
check.FilterGroup<any>.checks: readonly [Check<M>, ...Array<Check<M>>](property) FilterGroup<any>.checks: {
0: Check<Meta>;
length: number;
toString: () => string;
toLocaleString: { (): string; (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string };
concat: { (...items: Array<ConcatArray<Check<Meta>>>): Array<Check<Meta>>; (...items: Array<Check<Meta> | ConcatArray<Check<Meta>>>): Array<Check<Meta>> };
join: (separator?: string) => string;
slice: (start?: number, end?: number) => Array<Check<Meta>>;
indexOf: (searchElement: Check<Meta>, fromIndex?: number) => number;
lastIndexOf: (searchElement: Check<Meta>, fromIndex?: number) => number;
every: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): this is readonly S[]; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisAr…;
some: (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => boolean;
forEach: (callbackfn: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => void, thisArg?: any) => void;
map: (callbackfn: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => U, thisArg?: any) => Array<U>;
filter: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): Array<S>; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any): Ar…;
reduce: { (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex: number, array: ReadonlyArray<Check<Meta>>) => Check<Meta>): Check<Meta>; (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex…;
reduceRight: { (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex: number, array: ReadonlyArray<Check<Meta>>) => Check<Meta>): Check<Meta>; (callbackfn: (previousValue: Check<Meta>, currentValue: Check<Meta>, currentIndex…;
find: { (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any): C…;
findIndex: (predicate: (value: Check<Meta>, index: number, obj: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => number;
entries: () => ArrayIterator<[number, Check<Meta>]>;
keys: () => ArrayIterator<number>;
values: () => ArrayIterator<Check<Meta>>;
includes: (searchElement: Check<Meta>, fromIndex?: number) => boolean;
flatMap: (callback: (this: This, value: Check<Meta>, index: number, array: Array<Check<Meta>>) => U | ReadonlyArray<U>, thisArg?: This | undefined) => Array<U>;
flat: (this: A, depth?: D | undefined) => Array<FlatArray<A, D>>;
at: (index: number) => Check<Meta> | undefined;
findLast: { (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => value is S, thisArg?: any): S | undefined; (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any…;
findLastIndex: (predicate: (value: Check<Meta>, index: number, array: ReadonlyArray<Check<Meta>>) => unknown, thisArg?: any) => number;
toReversed: () => Array<Check<Meta>>;
toSorted: (compareFn?: ((a: Check<Meta>, b: Check<Meta>) => number) | undefined) => Array<Check<Meta>>;
toSpliced: { (start: number, deleteCount: number, ...items: Array<Check<Meta>>): Array<Check<Meta>>; (start: number, deleteCount?: number): Array<Check<Meta>> };
with: (index: number, value: Check<Meta>) => Array<Check<Meta>>;
}
checks.ReadonlyArray<Check<any>>.map<string>(callbackfn: (value: Check<any>, index: number, array: readonly Check<any>[]) => string, thisArg?: any): string[]Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((c: Check<Meta>c) => function (local function) toRuntimeCheck(check: Check<Meta>): stringtoRuntimeCheck(c: Check<Meta>c)).Array<string>.join(separator?: string): stringAdds all the elements of an array into a string, separated by the specified separator string.
join(", ")}]${const ca: stringca})`
}
}
}
function function (local function) toRuntimeFilter(filter: Filter<Meta>): stringtoRuntimeFilter(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter: interface Filter<M>A single validation constraint with typed metadata describing the check
(e.g. { _tag: "isMinLength", minLength: 3 }).
Filter<type Meta = anyMeta>): string {
const const a: stringa = function toRuntimeAnnotations(
annotations:
| Schema.Annotations.Annotations
| undefined
): string
toRuntimeAnnotations(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<M>.annotations?: anyannotations)
const const ca: stringca = const a: stringa === "" ? "" : `, ${const a: stringa}`
switch (filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag) {
case "isTrimmed":
case "isGUID":
case "isULID":
case "isBase64":
case "isBase64Url":
case "isUppercased":
case "isLowercased":
case "isCapitalized":
case "isUncapitalized":
case "isFinite":
case "isInt":
case "isUnique":
case "isDateValid":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${const a: stringa})`
case "isStringFinite":
case "isStringBigInt":
case "isStringSymbol":
case "isPattern":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${function toRuntimeRegExp(
regExp: RegExp
): string
toRuntimeRegExp(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.regExp)}${const ca: stringca})`
case "isMinLength":
return `Schema.isMinLength(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMinLength";
minLength: number;
}
meta.minLength}${const ca: stringca})`
case "isMaxLength":
return `Schema.isMaxLength(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMaxLength";
maxLength: number;
}
meta.maxLength}${const ca: stringca})`
case "isLengthBetween":
return `Schema.isLengthBetween(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isLengthBetween";
minimum: number;
maximum: number;
}
meta.minimum}, ${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isLengthBetween";
minimum: number;
maximum: number;
}
meta.maximum}${const ca: stringca})`
case "isUUID":
return `Schema.isUUID(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isUUID";
regExp: globalThis.RegExp;
version: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | undefined;
}
meta.version}${const ca: stringca})`
case "isStartsWith":
return `Schema.isStartsWith(${import formatformat(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isStartsWith";
startsWith: string;
regExp: globalThis.RegExp;
}
meta.startsWith)}${const ca: stringca})`
case "isEndsWith":
return `Schema.isEndsWith(${import formatformat(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isEndsWith";
endsWith: string;
regExp: globalThis.RegExp;
}
meta.endsWith)}${const ca: stringca})`
case "isIncludes":
return `Schema.isIncludes(${import formatformat(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isIncludes";
includes: string;
regExp: globalThis.RegExp;
}
meta.includes)}${const ca: stringca})`
case "isGreaterThan":
case "isGreaterThanBigInt":
case "isGreaterThanDate":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.exclusiveMinimum)}${const ca: stringca})`
case "isGreaterThanOrEqualTo":
case "isGreaterThanOrEqualToBigInt":
case "isGreaterThanOrEqualToDate":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.minimum)}${const ca: stringca})`
case "isLessThan":
case "isLessThanBigInt":
case "isLessThanDate":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.exclusiveMaximum)}${const ca: stringca})`
case "isLessThanOrEqualTo":
case "isLessThanOrEqualToBigInt":
case "isLessThanOrEqualToDate":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}(${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.maximum)}${const ca: stringca})`
case "isBetween":
case "isBetweenBigInt":
case "isBetweenDate":
return `Schema.${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta._tag}({ minimum: ${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.minimum)}, maximum: ${
function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.maximum)
}, exclusiveMinimum: ${function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.exclusiveMinimum)}, exclusiveMaximum: ${
function toRuntimeValue(
value:
| undefined
| number
| boolean
| bigint
| Date
): string
toRuntimeValue(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: anymeta.exclusiveMaximum)
}${const ca: stringca})`
case "isMultipleOf":
return `Schema.isMultipleOf(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMultipleOf";
divisor: number;
}
meta.divisor}${const ca: stringca})`
case "isMinProperties":
return `Schema.isMinProperties(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMinProperties";
minProperties: number;
}
meta.minProperties}${const ca: stringca})`
case "isMaxProperties":
return `Schema.isMaxProperties(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMaxProperties";
maxProperties: number;
}
meta.maxProperties}${const ca: stringca})`
case "isPropertiesLengthBetween":
return `Schema.isPropertiesLengthBetween(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isPropertiesLengthBetween";
minimum: number;
maximum: number;
}
meta.minimum}, ${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isPropertiesLengthBetween";
minimum: number;
maximum: number;
}
meta.maximum}${const ca: stringca})`
case "isPropertyNames":
return `Schema.isPropertyNames(${function (local function) recur(s: Representation): Coderecur(filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isPropertyNames";
propertyNames: Representation;
}
meta.propertyNames).runtime: stringruntime}${const ca: stringca})`
case "isMinSize":
return `Schema.isMinSize(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMinSize";
minSize: number;
}
meta.minSize}${const ca: stringca})`
case "isMaxSize":
return `Schema.isMaxSize(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isMaxSize";
maxSize: number;
}
meta.maxSize}${const ca: stringca})`
case "isSizeBetween":
return `Schema.isSizeBetween(${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isSizeBetween";
minimum: number;
maximum: number;
}
meta.minimum}, ${filter: Filter<Meta>(parameter) filter: {
_tag: "Filter";
annotations: Schema.Annotations.Filter | undefined;
meta: M;
}
filter.Filter<any>.meta: any(property) Filter<any>.meta: {
_tag: "isSizeBetween";
minimum: number;
maximum: number;
}
meta.maximum}${const ca: stringca})`
}
}
}