MCPcopy
hub / github.com/arktypeio/arktype / parseDefinition

Function parseDefinition

ark/schema/scope.ts:692–710  ·  view source on GitHub ↗
(def: unknown, opts: BaseParseOptions = {})

Source from the content-addressed store, hash-verified

690 this.finalize(this.parseDefinition(def, opts))
691
692 parseDefinition(def: unknown, opts: BaseParseOptions = {}): BaseRoot {
693 if (hasArkKind(def, "root")) return this.bindReference(def)
694
695 const ctxInputOrNode = this.preparseOwnDefinitionFormat(def, opts)
696 if (hasArkKind(ctxInputOrNode, "root"))
697 return this.bindReference(ctxInputOrNode)
698
699 const ctx = this.createParseContext(ctxInputOrNode)
700 nodesByRegisteredId[ctx.id] = ctx
701 let node = this.bindReference(this.parseOwnDefinitionFormat(def, ctx))
702
703 // if the node is recursive e.g. { box: "this" }, we need to make sure it
704 // has the original id from context so that its references compile correctly
705 if (node.isCyclic) node = withId(node, ctx.id)
706
707 nodesByRegisteredId[ctx.id] = node
708
709 return node
710 }
711
712 finalize<node extends BaseRoot>(node: node): node {
713 bootstrapAliasReferences(node)

Callers

nothing calls this directly

Calls 4

hasArkKindFunction · 0.90
withIdFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…