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

Function recur

packages/effect/src/internal/schema/toCodeDocument.ts:374–396  ·  view source on GitHub ↗
(
    representation: SchemaRepresentation.Representation,
    path: Path,
    includeTypeBrands: boolean = true
  )

Source from the content-addressed store, hash-verified

372 }
373
374 function recur(
375 representation: SchemaRepresentation.Representation,
376 path: Path,
377 includeTypeBrands: boolean = true
378 ): SchemaRepresentation.Code {
379 if (representation._tag === "Reference") {
380 if (!Object.hasOwn(document.references, representation.$ref)) {
381 throw errorWithPath(`Invalid reference ${representation.$ref}`, [...path, "$ref"])
382 }
383 const identifier = ensureUniqueIdentifier(representation.$ref)
384 if (
385 compilingRecursiveDefinition && explicitSuspendDepth === 0 &&
386 Object.hasOwn(sorted.recursives, representation.$ref)
387 ) {
388 return makeCode(`Schema.suspend((): Schema.Codec<${identifier}> => ${identifier})`, identifier)
389 }
390 const Type = includeTypeBrands
391 ? identifier
392 : recur(document.references[representation.$ref], ["references", representation.$ref], false).Type
393 return makeCode(identifier, Type)
394 }
395 return applyNode(on(representation, path, includeTypeBrands), representation, path, includeTypeBrands)
396 }
397
398 function on(
399 representation: Exclude<SchemaRepresentation.Representation, SchemaRepresentation.Reference>,

Callers 3

toCodeDocumentFunction · 0.70
annotationSchemasFunction · 0.70
onFunction · 0.70

Calls 5

errorWithPathFunction · 0.90
ensureUniqueIdentifierFunction · 0.85
makeCodeFunction · 0.85
applyNodeFunction · 0.85
onFunction · 0.70

Tested by

no test coverage detected