MCPcopy Create free account
hub / github.com/Effect-TS/effect / toCodecStringTree

Method toCodecStringTree

packages/effect/src/SchemaAST.ts:1077–1091  ·  view source on GitHub ↗

@internal

()

Source from the content-addressed store, hash-verified

1075 }
1076 /** @internal */
1077 toCodecStringTree(): AST {
1078 if (this.enums.some(([_, v]) => typeof v === "number")) {
1079 const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]))
1080 return replaceEncoding(this, [
1081 new Link(
1082 new Union(Object.keys(coercions).map((k) => new Literal(k)), "anyOf"),
1083 new SchemaTransformation.Transformation(
1084 SchemaGetter.transform((s) => coercions[s]),
1085 SchemaGetter.String()
1086 )
1087 )
1088 ])
1089 }
1090 return this
1091 }
1092 /** @internal */
1093 getExpected(): string {
1094 return this.enums.map(([_, value]) => JSON.stringify(value)).join(" | ")

Callers 15

Schema.tst.tsFile · 0.45
toCodec.test.tsFile · 0.45
assertXmlFunction · 0.45
assertXmlFailureFunction · 0.45
assertRoundtripsFunction · 0.45
SchemaAST.tsFile · 0.45
schemaFunction · 0.45
RecordFunction · 0.45
ArrayConfigFunction · 0.45
Schema.tsFile · 0.45
transformResponseSchemaFunction · 0.45
transformResponseFunction · 0.45

Calls 4

replaceEncodingFunction · 0.85
someMethod · 0.80
transformMethod · 0.65
mapMethod · 0.45

Tested by 3

assertXmlFunction · 0.36
assertXmlFailureFunction · 0.36
assertRoundtripsFunction · 0.36