MCPcopy Create free account
hub / github.com/arktypeio/arktype / bakedJsonSchema

Function bakedJsonSchema

ark/type/runtime.ts:650–660  ·  view source on GitHub ↗
(
	write: () => JsonSchema,
	byTarget: readonly ((() => JsonSchema) | 0)[],
	// no fallback wrote it, so a call's changes nothing
	ignoresFallback?: 1
)

Source from the content-addressed store, hash-verified

648
649// a target's is 0 where the validator doesn't bake its schema
650export const bakedJsonSchema = (
651 write: () => JsonSchema,
652 byTarget: readonly ((() => JsonSchema) | 0)[],
653 // no fallback wrote it, so a call's changes nothing
654 ignoresFallback?: 1
655): ((opts?: JsonSchemaOptions) => JsonSchema) =>
656 freeze((opts?: JsonSchemaOptions) => {
657 const target = bakedTargetOf(opts, !!ignoresFallback)
658 const written = target === undefined ? write : byTarget[target]
659 return written ? written() : throwError(bakedJsonSchemaOptionsMessage)
660 })
661
662// a baked schema written again with the fallback a call passes, as the build
663// recorded arktype writing it; a target's replay is 0 where it has none

Callers 1

fallbacks.test.tsFile · 0.90

Calls 3

throwErrorFunction · 0.90
bakedTargetOfFunction · 0.85
writtenFunction · 0.70

Tested by

no test coverage detected