/** * @license * Copyright 2025 Steven Roussey * SPDX-License-Identifier: Apache-2.0 */ import type { FromExtendedSchema, FromExtendedSchemaOptions, FromSchemaOptions } from "@sroussey/json-schema-to-ts"; import type { JsonSchema, JsonSchemaCustomProps } from "./JsonSchema"; export { FromSchemaOptions }; /** * Removes the [$JSONSchema] symbol property from a type * This is needed because json-schema-to-ts adds this property which cannot be serialized */ export type StripJSONSchema = T extends object ? { [K in keyof T as K extends symbol ? never : K]: T[K]; } : T; export declare const FromSchemaDefaultOptions: { readonly parseNotKeyword: true; readonly parseIfThenElseKeywords: true; readonly keepDefaultedPropertiesOptional: true; readonly references: false; readonly deserialize: false; }; export type FromSchema, OPTIONS extends FromExtendedSchemaOptions = typeof FromSchemaDefaultOptions, EXTENSION extends JsonSchemaCustomProps = JsonSchemaCustomProps> = StripJSONSchema>; /** * IncludeProps - Returns a new schema with only the specified properties * * This is a schema transformer that returns a new schema object. * Use with FromSchema like: FromSchema> * * @template Schema - The JSON schema object (with 'as const') * @template Keys - Readonly array type of property keys to include (use typeof ["key1", "key2"] as const) * * @example * const schema = { * type: "object", * properties: { * name: { type: "string" }, * age: { type: "number" }, * email: { type: "string" } * }, * required: ["name"], * additionalProperties: false * } as const; * * type Filtered = FromSchema>; * // => { name: string, age?: number } */ export type IncludeProps; }, Keys extends readonly (keyof Schema["properties"])[]> = Omit & { readonly properties: { readonly [K in Extract]: Schema["properties"][K]; }; } & (Schema extends { readonly required: readonly (infer R extends string)[]; } ? { readonly required: readonly Extract[]; } : object); /** * ExcludeProps - Returns a new schema without the specified properties * * This is a schema transformer that returns a new schema object. * Use with FromSchema like: FromSchema> * * @template Schema - The JSON schema object (with 'as const') * @template Keys - Readonly array type of property keys to exclude (use typeof ["key1", "key2"] as const) * * @example * const schema = { * type: "object", * properties: { * name: { type: "string" }, * age: { type: "number" }, * email: { type: "string" } * }, * required: ["name"], * additionalProperties: false * } as const; * * type Filtered = FromSchema>; * // => { name: string, age?: number } */ export type ExcludeProps; }, Keys extends readonly (keyof Schema["properties"])[]> = Omit & { readonly properties: { readonly [K in Exclude]: Schema["properties"][K]; }; } & (Schema extends { readonly required: readonly (infer R extends string)[]; } ? { readonly required: readonly Exclude[]; } : object); //# sourceMappingURL=FromSchema.d.ts.map