import type { OperationObject, ReferenceObject, SchemaObject } from "openapi3-ts/oas31"; import type { SchemaObject as SchemaObject3 } from "openapi3-ts/oas30"; import type { RefResolver } from "./ref-resolver.ts"; import { Box } from "./box.ts"; import type { Method } from "./map-openapi-endpoints.ts"; export type LibSchemaObject = SchemaObject & SchemaObject3; export type BoxDefinition = { type: string; params: unknown; value: string; }; export type BoxParams = string | BoxDefinition; export type WithSchema = { schema: LibSchemaObject | ReferenceObject | undefined; ctx: OpenapiSchemaConvertContext; }; export type BoxUnion = WithSchema & { type: "union"; params: { types: Array; }; value: string; }; export type BoxIntersection = WithSchema & { type: "intersection"; params: { types: Array; }; value: string; }; export type BoxArray = WithSchema & { type: "array"; params: { type: BoxParams; }; value: string; }; export type BoxOptional = WithSchema & { type: "optional"; params: { type: BoxParams; }; value: string; }; export type BoxRef = WithSchema & { type: "ref"; params: { name: string; generics?: BoxParams[] | undefined }; value: string; }; export type BoxLiteral = WithSchema & { type: "literal"; params: {}; value: string; }; export type BoxKeyword = WithSchema & { type: "keyword"; params: { name: string }; value: string; }; export type BoxObject = WithSchema & { type: "object"; params: { props: Record }; value: string; }; export type AnyBoxDef = | BoxUnion | BoxIntersection | BoxArray | BoxOptional | BoxRef | BoxLiteral | BoxKeyword | BoxObject; export type AnyBox = Box; export type OpenapiSchemaConvertArgs = { schema: SchemaObject | ReferenceObject; ctx: OpenapiSchemaConvertContext; meta?: {} | undefined; }; export type FactoryCreator = ( schema: SchemaObject | ReferenceObject, ctx: OpenapiSchemaConvertContext, ) => GenericFactory; export type NameTransformOptions = { transformSchemaName?: (name: string) => string; transformEndpointName?: (endpoint: { alias: string; operation: OperationObject; method: Method; path: string; }) => string; }; export type OpenapiSchemaConvertContext = { factory: FactoryCreator | GenericFactory; refs: RefResolver; onBox?: (box: Box) => Box; nameTransform?: NameTransformOptions; }; export type StringOrBox = string | Box; export type BoxFactory = { union: (types: Array) => Box; intersection: (types: Array) => Box; array: (type: StringOrBox) => Box; object: (props: Record) => Box; optional: (type: StringOrBox) => Box; reference: (name: string, generics?: Array | undefined) => Box; literal: (value: StringOrBox) => Box; string: () => Box; number: () => Box; boolean: () => Box; unknown: () => Box; any: () => Box; never: () => Box; }; export type GenericFactory = { callback?: OpenapiSchemaConvertContext["onBox"]; union: (types: Array) => string; intersection: (types: Array) => string; array: (type: StringOrBox) => string; object: (props: Record) => string; optional: (type: StringOrBox) => string; reference: (name: string, generics?: Array | undefined) => string; literal: (value: StringOrBox) => string; string: () => string; number: () => string; boolean: () => string; unknown: () => string; any: () => string; never: () => string; };