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

Method toCodecStringTree

packages/effect/src/SchemaAST.ts:1427–1441  ·  view source on GitHub ↗

@internal

()

Source from the content-addressed store, hash-verified

1425 }
1426 /** @internal */
1427 toCodecStringTree(): AST {
1428 if (this.enums.some(([_, v]) => typeof v === "number")) {
1429 const coercions = Object.fromEntries(this.enums.map(([_, v]) => [globalThis.String(v), v]))
1430 return replaceEncoding(this, [
1431 new Link(
1432 new Union(Object.keys(coercions).map((k) => new Literal(k))),
1433 new SchemaTransformation.Transformation(
1434 SchemaGetter.transform((s) => coercions[s]),
1435 SchemaGetter.String()
1436 )
1437 )
1438 ])
1439 }
1440 return this
1441 }
1442 /** @internal */
1443 getExpected(): string {
1444 return this.enums.map(([_, value]) => JSON.stringify(value)).join(" | ")

Callers

nothing calls this directly

Calls 7

replaceEncodingFunction · 0.85
literalToStringFunction · 0.85
someMethod · 0.80
keysMethod · 0.80
transformMethod · 0.65
toCodecJsonMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected