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

Function foreignFallback

ark/sets/toJsonSchema.ts:787–806  ·  view source on GitHub ↗
(
	ctx: JsonSchemaContext,
	reason?: string,
	sides: Pick<ToJsonSchema.MorphContext, "base" | "out"> = {
		base: {},
		out: null
	}
)

Source from the content-addressed store, hash-verified

785}
786
787const foreignFallback = (
788 ctx: JsonSchemaContext,
789 reason?: string,
790 sides: Pick<ToJsonSchema.MorphContext, "base" | "out"> = {
791 base: {},
792 out: null
793 }
794): JsonSchema => {
795 try {
796 return ctx.fallback.morph({ code: "morph", ...sides })
797 } catch (e) {
798 if (!(e instanceof ToJsonSchema.Error) || !e.hasCode("morph")) throw e
799 return ToJsonSchema.throw(
800 "morph",
801 e.context,
802 ctx.path,
803 `Can't convert the Type${ctx.path && ` at ${ctx.path}`} to ${ctx.target} JSON Schema${reason ? `, since ${reason}` : ""}. ${writeForeignArkMessage("It")}`
804 )
805 }
806}
807
808const reduceObjectJsonSchema = (
809 node: Structure.Node,

Callers 1

foreignToJsonSchemaFunction · 0.85

Calls 3

writeForeignArkMessageFunction · 0.90
throwMethod · 0.65
hasCodeMethod · 0.45

Tested by

no test coverage detected