@servicenow/sdk - v4.14.3
    Preparing search index...
    interface ToJSONSchemaContext {
        counter: number;
        cycles: "throw" | "ref";
        deferred: (() => void)[];
        external?: {
            defs: Record<string, BaseSchema>;
            registry: $ZodRegistry<{ id?: string }>;
            uri?: (id: string) => string;
        };
        intersections: JSONSchema[][];
        io: "output"
        | "input";
        metadataRegistry: $ZodRegistry<Record<string, any>>;
        override: (
            ctx: {
                jsonSchema: JSONSchema;
                path: (string | number)[];
                zodSchema: $ZodType;
            },
        ) => void;
        processors: Record<string, Processor>;
        reused: "inline" | "ref";
        seen: Map<
            $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
            Seen,
        >;
        sharedDefsExtractedFor?: {
            defs: Record<string, BaseSchema>;
            registry: $ZodRegistry<{ id?: string }>;
            uri?: (id: string) => string;
        };
        sharedEmitDoneFor?: {
            defs: Record<string, BaseSchema>;
            registry: $ZodRegistry<{ id?: string }>;
            uri?: (id: string) => string;
        };
        target: | "draft-04"
        | "draft-07"
        | "draft-2020-12"
        | "openapi-3.0"
        | {} & string;
        unrepresentable: | "any"
        | "throw"
        | UnrepresentableHandler<
            $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
        >;
    }
    Index

    Properties

    counter: number
    cycles: "throw" | "ref"
    deferred: (() => void)[]

    Rewrites a processor deferred to finalize, where the flatten has resolved every ref and the union branches are in place.

    external?: {
        defs: Record<string, BaseSchema>;
        registry: $ZodRegistry<{ id?: string }>;
        uri?: (id: string) => string;
    }
    intersections: JSONSchema[][]

    The allOf array of each intersection encountered during traversal, innermost first. finalize folds every emitted object holding one; see foldIntersection.

    io: "output" | "input"
    metadataRegistry: $ZodRegistry<Record<string, any>>
    override: (
        ctx: {
            jsonSchema: JSONSchema;
            path: (string | number)[];
            zodSchema: $ZodType;
        },
    ) => void
    processors: Record<string, Processor>
    reused: "inline" | "ref"
    seen: Map<$ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>, Seen>
    sharedDefsExtractedFor?: {
        defs: Record<string, BaseSchema>;
        registry: $ZodRegistry<{ id?: string }>;
        uri?: (id: string) => string;
    }

    Registry conversions share one seen map across every emitted schema. These hold the external the whole-map passes below last ran for, so the passes are not repeated once per schema — and still re-run if the map grows or external is swapped. sharedEmitDoneFor covers both passes in finalize: the ref flattening and the $defs build.

    The passes are valid only while nothing they read has changed, so both are cleared in processSchema() when the map grows, and in JSONSchemaGenerator.emit(), which can also change the cycles and reused they branch on.

    One case is deliberately not covered: an override callback that writes to metadataRegistry mid-conversion. It runs inside finalize, so a registry conversion has nowhere left to clear the guards, and later schemas keep the ids the first pass saw. That output was never coherent — before this, whether a shared subschema was inlined or extracted depended on which registry entry happened to be emitted when the callback fired.

    sharedEmitDoneFor?: {
        defs: Record<string, BaseSchema>;
        registry: $ZodRegistry<{ id?: string }>;
        uri?: (id: string) => string;
    }
    target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | {} & string
    unrepresentable:
        | "any"
        | "throw"
        | UnrepresentableHandler<
            $ZodType<unknown, unknown, $ZodTypeInternals<unknown, unknown>>,
        >