From fb970501cd5ed7e1a64bbcf2e52a2fe9e96aa607 Mon Sep 17 00:00:00 2001 From: "maxholman[bot]" <321308195+maxholman[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:44:32 +0800 Subject: [PATCH 1/5] fix: key additionalProperties records by string JSON object keys are always strings, so Record made Object.entries-style helpers type keys as string | number. Co-Authored-By: LLM --- .../types.ts | 5 + .../valibot.ts | 6 + .../types.ts | 2 +- __tests__/codegen-regressions.test.ts | 4 +- .../docker/.openapi-codegen-manifest.json | 4 +- __tests__/fixtures/docker/types.ts | 751 +++++++++--------- .../openai/.openapi-codegen-manifest.json | 4 +- __tests__/fixtures/openai/types.ts | 62 +- .../petstore/.openapi-codegen-manifest.json | 2 +- .../test1/.openapi-codegen-manifest.json | 4 +- __tests__/fixtures/test1/types.ts | 2 +- lib/process-schema.ts | 6 +- 12 files changed, 421 insertions(+), 431 deletions(-) create mode 100644 __tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts create mode 100644 __tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts new file mode 100644 index 0000000..8eb1824 --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts @@ -0,0 +1,5 @@ +import type { UndefinedOnPartialDeep } from "type-fest"; + +export type Labels = Record; +export type GetThingCommandInput = never; +export type InputGetThingCommandResponse = UndefinedOnPartialDeep; diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts new file mode 100644 index 0000000..984fbbd --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts @@ -0,0 +1,6 @@ +import * as v from "valibot"; + +export const inputLabelsSchema = v.record(v.string(), v.string()); +export const labelsSchema = inputLabelsSchema; +export const inputGetThingCommandResponseSchema = inputLabelsSchema; +export const getThingCommandResponseSchema = labelsSchema; diff --git a/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts b/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts index 21cf87b..5e51d00 100644 --- a/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts +++ b/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts @@ -1,5 +1,5 @@ import type { Jsonifiable, UndefinedOnPartialDeep } from "type-fest"; -export type Empty = Record; +export type Empty = Record; export type GetThingCommandInput = never; export type InputGetThingCommandResponse = UndefinedOnPartialDeep; diff --git a/__tests__/codegen-regressions.test.ts b/__tests__/codegen-regressions.test.ts index d090143..c96731c 100644 --- a/__tests__/codegen-regressions.test.ts +++ b/__tests__/codegen-regressions.test.ts @@ -1,5 +1,5 @@ import type { oas31 } from "openapi3-ts"; -import { test } from "vitest"; +import { expect, test } from "vitest"; import { processOpenApiDocument } from "../lib/process-document.ts"; import { expectGenerated } from "./generated-snapshot.ts"; @@ -190,7 +190,7 @@ function docWithSchema(name: string, schema: oas31.SchemaObject) { }; } -test("additionalProperties types the record value instead of widening to unknown", async () => { +test("additionalProperties is a string-keyed record of the value type", async () => { const result = await processOpenApiDocument( "/tmp/whatever", docWithSchema("Labels", { diff --git a/__tests__/fixtures/docker/.openapi-codegen-manifest.json b/__tests__/fixtures/docker/.openapi-codegen-manifest.json index 5bb2570..bc3c892 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "3d94c5af1601bec3282ab4664df01eee", "commands.ts": "137aa1b06856ca44a0c780958480af81", - "types.ts": "6b85d6261f52a556a0dc6a584b3da2db", + "types.ts": "3e03e759f7637110c12ddea24009796c", "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", "valibot.ts": "2c62b6192664e3a42e1b44700d430df7", "hono.ts": "4dee43760e6f999bf0da89d4c063bcd4", diff --git a/__tests__/fixtures/docker/types.ts b/__tests__/fixtures/docker/types.ts index 180b553..416cd4a 100644 --- a/__tests__/fixtures/docker/types.ts +++ b/__tests__/fixtures/docker/types.ts @@ -97,7 +97,7 @@ export type DeviceRequest = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }; export type ThrottleDevice = { Path?: string; @@ -141,10 +141,10 @@ export type Mount = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -223,7 +223,7 @@ export type Resources = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -408,7 +408,7 @@ export type HostConfig = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -441,7 +441,7 @@ export type HostConfig = { | "splunk" | "etwlogs" | "none"; - Config?: Record; + Config?: Record; }; NetworkMode?: string; /** @@ -455,7 +455,7 @@ export type HostConfig = { * @example [object Object] */ PortBindings?: Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -523,10 +523,10 @@ export type HostConfig = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -535,7 +535,7 @@ export type HostConfig = { }; }[]; ConsoleSize?: readonly number[]; - Annotations?: Record; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -569,12 +569,12 @@ export type HostConfig = { PublishAllPorts?: boolean; ReadonlyRootfs?: boolean; SecurityOpt?: readonly string[]; - StorageOpt?: Record; - Tmpfs?: Record; + StorageOpt?: Record; + Tmpfs?: Record; UTSMode?: string; UsernsMode?: string; ShmSize?: bigint; - Sysctls?: Record; + Sysctls?: Record; Runtime?: string; /** * Isolation technology of the container. (Windows only) @@ -619,7 +619,7 @@ export type ContainerConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -653,7 +653,7 @@ export type ContainerConfig = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -679,7 +679,7 @@ export type ContainerConfig = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -753,7 +753,7 @@ export type ImageConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record>; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -820,7 +820,7 @@ export type ImageConfig = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -862,7 +862,7 @@ export type ImageConfig = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -883,7 +883,7 @@ export type ImageConfig = { */ export type NetworkingConfig = { EndpointsConfig?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -942,7 +942,7 @@ export type NetworkingConfig = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -984,7 +984,7 @@ export type NetworkSettings = { * @example [object Object] */ Ports?: Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -1116,7 +1116,7 @@ export type NetworkSettings = { */ MacAddress?: string; Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -1175,7 +1175,7 @@ export type NetworkSettings = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -1194,7 +1194,7 @@ export type Address = { * are added to the mapping table. */ export type PortMap = Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -1241,7 +1241,7 @@ export type GraphDriverData = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; /** Change in the container's filesystem. */ export type FilesystemChange = { @@ -1355,10 +1355,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -1392,7 +1389,7 @@ export type ImageInspect = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1418,7 +1415,7 @@ export type ImageInspect = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -1506,10 +1503,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record>; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -1576,7 +1570,7 @@ export type ImageInspect = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1618,7 +1612,7 @@ export type ImageInspect = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -1683,7 +1677,7 @@ export type ImageInspect = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; RootFS?: { Type: string; @@ -1781,7 +1775,7 @@ export type ImageSummary = { * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * Number of containers using this image. Includes both stopped and running * containers. @@ -1835,12 +1829,12 @@ export type Volume = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -1881,14 +1875,14 @@ export type Volume = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -1909,9 +1903,9 @@ export type Volume = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -1934,14 +1928,14 @@ export type Volume = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -1977,12 +1971,12 @@ export type VolumeCreateOptions = { * passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; ClusterVolumeSpec?: { Group?: string; AccessMode?: { @@ -2008,14 +2002,14 @@ export type VolumeCreateOptions = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -2067,12 +2061,12 @@ export type VolumeListResponse = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -2113,14 +2107,14 @@ export type VolumeListResponse = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -2141,9 +2135,9 @@ export type VolumeListResponse = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -2166,14 +2160,14 @@ export type VolumeListResponse = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -2242,13 +2236,13 @@ export type Network = { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }[]; /** * Driver-specific options, specified as a map. * @example [object Object] */ - Options?: Record; + Options?: Record; }; /** * Whether the network is created to only allow internal networking @@ -2282,7 +2276,7 @@ export type Network = { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -2295,12 +2289,12 @@ export type Network = { * Network-specific options uses when creating the network. * @example [object Object] */ - Options?: Record; + Options?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Peers?: readonly { /** * ID of the peer-node in the Swarm cluster. @@ -2338,19 +2332,19 @@ export type Ipam = { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }[]; /** * Driver-specific options, specified as a map. * @example [object Object] */ - Options?: Record; + Options?: Record; }; export type IpamConfig = { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }; export type NetworkContainer = { Name?: string; @@ -2561,7 +2555,7 @@ export type EndpointSettings = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; }; /** EndpointIPAMConfig represents an endpoint's IPAM configuration. */ export type EndpointIpamConfig = { @@ -2730,7 +2724,7 @@ export type NodeSpec = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -2767,7 +2761,7 @@ export type Node = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -2817,7 +2811,7 @@ export type Node = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -2903,7 +2897,7 @@ export type NodeDescription = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -2937,7 +2931,7 @@ export type Platform = { /** EngineDescription provides information about an engine. */ export type EngineDescription = { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -3006,7 +3000,7 @@ export type SwarmSpec = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -3070,7 +3064,7 @@ export type SwarmSpec = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -3097,7 +3091,7 @@ export type SwarmSpec = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3136,7 +3130,7 @@ export type ClusterInfo = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -3200,7 +3194,7 @@ export type ClusterInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -3227,7 +3221,7 @@ export type ClusterInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3305,7 +3299,7 @@ export type Swarm = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -3369,7 +3363,7 @@ export type Swarm = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -3396,7 +3390,7 @@ export type Swarm = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3457,7 +3451,7 @@ export type TaskSpec = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -3547,10 +3541,10 @@ export type TaskSpec = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -3590,7 +3584,7 @@ export type TaskSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -3601,7 +3595,7 @@ export type TaskSpec = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -3725,11 +3719,11 @@ export type TaskSpec = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; export type TaskState = @@ -3756,7 +3750,7 @@ export type Task = { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -3770,7 +3764,7 @@ export type Task = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -3860,10 +3854,10 @@ export type Task = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -3903,7 +3897,7 @@ export type Task = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -3914,7 +3908,7 @@ export type Task = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -4038,11 +4032,11 @@ export type Task = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; ServiceID?: string; @@ -4112,7 +4106,7 @@ export type Task = { /** User modifiable configuration for a service. */ export type ServiceSpec = { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -4126,7 +4120,7 @@ export type ServiceSpec = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -4216,10 +4210,10 @@ export type ServiceSpec = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -4259,7 +4253,7 @@ export type ServiceSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4270,7 +4264,7 @@ export type ServiceSpec = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -4394,18 +4388,18 @@ export type ServiceSpec = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -4414,7 +4408,7 @@ export type ServiceSpec = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -4457,7 +4451,7 @@ export type ServiceSpec = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -4558,7 +4552,7 @@ export type Service = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -4572,7 +4566,7 @@ export type Service = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -4662,10 +4656,10 @@ export type Service = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -4705,7 +4699,7 @@ export type Service = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4716,7 +4710,7 @@ export type Service = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -4840,18 +4834,18 @@ export type Service = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -4860,7 +4854,7 @@ export type Service = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -4903,7 +4897,7 @@ export type Service = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -5052,7 +5046,7 @@ export type ContainerSummary = { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -5060,7 +5054,7 @@ export type ContainerSummary = { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -5119,7 +5113,7 @@ export type ContainerSummary = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -5197,7 +5191,7 @@ export type Driver = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; export type SecretSpec = { Name?: string; @@ -5205,7 +5199,7 @@ export type SecretSpec = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -5226,7 +5220,7 @@ export type SecretSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -5238,7 +5232,7 @@ export type SecretSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type Secret = { @@ -5254,7 +5248,7 @@ export type Secret = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -5275,7 +5269,7 @@ export type Secret = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -5287,13 +5281,13 @@ export type Secret = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; export type ConfigSpec = { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -5305,7 +5299,7 @@ export type ConfigSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type Config = { @@ -5317,7 +5311,7 @@ export type Config = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -5329,7 +5323,7 @@ export type Config = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -5492,7 +5486,7 @@ export type SystemVersion = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record; }[]; /** * The version of the daemon @@ -5897,7 +5891,7 @@ export type SystemInfo = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -6033,7 +6027,7 @@ export type SystemInfo = { * @example [object Object] */ Runtimes?: Record< - string | number, + string, { /** * Name and, optional, path, of the OCI executable binary. @@ -6133,7 +6127,7 @@ export type SystemInfo = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -6197,7 +6191,7 @@ export type SystemInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -6224,7 +6218,7 @@ export type SystemInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -6473,7 +6467,7 @@ export type RegistryServiceConfig = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -6662,7 +6656,7 @@ export type SwarmInfo = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -6726,7 +6720,7 @@ export type SwarmInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -6753,7 +6747,7 @@ export type SwarmInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -6805,7 +6799,7 @@ export type PeerNode = { export type NetworkAttachmentConfig = { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }; /** * Actor describes something that generates events, like a container, network, @@ -6821,7 +6815,7 @@ export type EventActor = { * Various key/value attributes of the object, depending on its type. * @example [object Object] */ - Attributes?: Record; + Attributes?: Record; }; /** EventMessage represents the information an event contains. */ export type EventMessage = { @@ -6857,7 +6851,7 @@ export type EventMessage = { * Various key/value attributes of the object, depending on its type. * @example [object Object] */ - Attributes?: Record; + Attributes?: Record; }; /** * Scope of the event. Engine events are `local` scope. Cluster (Swarm) @@ -7022,14 +7016,14 @@ export type ClusterVolume = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -7050,9 +7044,9 @@ export type ClusterVolume = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -7075,7 +7069,7 @@ export type ClusterVolume = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** Cluster-specific options used to create the volume. */ @@ -7104,14 +7098,14 @@ export type ClusterVolumeSpec = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -7135,7 +7129,7 @@ export type ClusterVolumeSpec = { * details, see documentation for the Topology object in the CSI * specification. */ -export type Topology = Record; +export type Topology = Record; export type ContainerListCommandQuery = { all?: "true" | "false"; limit?: `${number}`; @@ -7158,7 +7152,7 @@ export type ContainerListCommandOutput = readonly { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -7166,7 +7160,7 @@ export type ContainerListCommandOutput = readonly { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -7225,7 +7219,7 @@ export type ContainerListCommandOutput = readonly { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -7323,7 +7317,7 @@ type ContainerCreateJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -7357,7 +7351,7 @@ type ContainerCreateJsonBody = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -7383,7 +7377,7 @@ type ContainerCreateJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -7446,7 +7440,7 @@ type ContainerCreateJsonBody = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -7479,7 +7473,7 @@ type ContainerCreateJsonBody = { | "splunk" | "etwlogs" | "none"; - Config?: Record; + Config?: Record; }; NetworkMode?: string; /** @@ -7493,7 +7487,7 @@ type ContainerCreateJsonBody = { * @example [object Object] */ PortBindings?: Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -7561,10 +7555,10 @@ type ContainerCreateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -7573,7 +7567,7 @@ type ContainerCreateJsonBody = { }; }[]; ConsoleSize?: readonly number[]; - Annotations?: Record; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -7607,12 +7601,12 @@ type ContainerCreateJsonBody = { PublishAllPorts?: boolean; ReadonlyRootfs?: boolean; SecurityOpt?: readonly string[]; - StorageOpt?: Record; - Tmpfs?: Record; + StorageOpt?: Record; + Tmpfs?: Record; UTSMode?: string; UsernsMode?: string; ShmSize?: bigint; - Sysctls?: Record; + Sysctls?: Record; Runtime?: string; /** * Isolation technology of the container. (Windows only) @@ -7631,7 +7625,7 @@ type ContainerCreateJsonBody = { */ NetworkingConfig?: { EndpointsConfig?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -7690,7 +7684,7 @@ type ContainerCreateJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -7902,7 +7896,7 @@ export type ContainerInspectCommandOutput = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -7935,7 +7929,7 @@ export type ContainerInspectCommandOutput = { | "splunk" | "etwlogs" | "none"; - Config?: Record; + Config?: Record; }; NetworkMode?: string; /** @@ -7949,7 +7943,7 @@ export type ContainerInspectCommandOutput = { * @example [object Object] */ PortBindings?: Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -8017,10 +8011,10 @@ export type ContainerInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -8029,7 +8023,7 @@ export type ContainerInspectCommandOutput = { }; }[]; ConsoleSize?: readonly number[]; - Annotations?: Record; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -8063,12 +8057,12 @@ export type ContainerInspectCommandOutput = { PublishAllPorts?: boolean; ReadonlyRootfs?: boolean; SecurityOpt?: readonly string[]; - StorageOpt?: Record; - Tmpfs?: Record; + StorageOpt?: Record; + Tmpfs?: Record; UTSMode?: string; UsernsMode?: string; ShmSize?: bigint; - Sysctls?: Record; + Sysctls?: Record; Runtime?: string; /** * Isolation technology of the container. (Windows only) @@ -8091,7 +8085,7 @@ export type ContainerInspectCommandOutput = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; SizeRw?: bigint; SizeRootFs?: bigint; @@ -8182,10 +8176,7 @@ export type ContainerInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -8219,7 +8210,7 @@ export type ContainerInspectCommandOutput = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -8245,7 +8236,7 @@ export type ContainerInspectCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -8295,7 +8286,7 @@ export type ContainerInspectCommandOutput = { * @example [object Object] */ Ports?: Record< - string | number, + string, readonly { /** * Host IP address that the container's port is mapped to. @@ -8427,7 +8418,7 @@ export type ContainerInspectCommandOutput = { */ MacAddress?: string; Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -8486,7 +8477,7 @@ export type ContainerInspectCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -8555,7 +8546,7 @@ export type ContainerStatsCommandParams = { export type ContainerStatsCommandInput = ContainerStatsCommandParams & ContainerStatsCommandQuery; export type ContainerStatsCommandOutput = - | Record + | Record | undefined; export type InputContainerStatsCommandResponse = UndefinedOnPartialDeep; @@ -8652,7 +8643,7 @@ type ContainerUpdateJsonBody = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -8901,7 +8892,7 @@ export type ImageListCommandOutput = readonly { * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * Number of containers using this image. Includes both stopped and running * containers. @@ -9078,10 +9069,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -9115,7 +9103,7 @@ export type ImageInspectCommandOutput = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -9141,7 +9129,7 @@ export type ImageInspectCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -9229,10 +9217,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record>; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -9299,7 +9284,7 @@ export type ImageInspectCommandOutput = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -9341,7 +9326,7 @@ export type ImageInspectCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -9406,7 +9391,7 @@ export type ImageInspectCommandOutput = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; RootFS?: { Type: string; @@ -9864,7 +9849,7 @@ export type SystemInfoCommandOutput = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -10000,7 +9985,7 @@ export type SystemInfoCommandOutput = { * @example [object Object] */ Runtimes?: Record< - string | number, + string, { /** * Name and, optional, path, of the OCI executable binary. @@ -10100,7 +10085,7 @@ export type SystemInfoCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -10164,7 +10149,7 @@ export type SystemInfoCommandOutput = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -10191,7 +10176,7 @@ export type SystemInfoCommandOutput = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -10348,7 +10333,7 @@ export type SystemVersionCommandOutput = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record; }[]; /** * The version of the daemon @@ -10444,7 +10429,7 @@ type ImageCommitJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record>; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -10478,7 +10463,7 @@ type ImageCommitJsonBody = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -10504,7 +10489,7 @@ type ImageCommitJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Signal to stop a container as a string or unsigned integer. * @example SIGTERM @@ -10564,7 +10549,7 @@ export type SystemEventsCommandOutput = { * Various key/value attributes of the object, depending on its type. * @example [object Object] */ - Attributes?: Record; + Attributes?: Record; }; /** * Scope of the event. Engine events are `local` scope. Cluster (Swarm) @@ -10671,7 +10656,7 @@ export type SystemDataUsageCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * Number of containers using this image. Includes both stopped and running * containers. @@ -10697,7 +10682,7 @@ export type SystemDataUsageCommandOutput = { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -10705,7 +10690,7 @@ export type SystemDataUsageCommandOutput = { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; @@ -10764,7 +10749,7 @@ export type SystemDataUsageCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; } >; }; @@ -10861,12 +10846,12 @@ export type SystemDataUsageCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -10907,14 +10892,14 @@ export type SystemDataUsageCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -10935,9 +10920,9 @@ export type SystemDataUsageCommandOutput = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -10960,14 +10945,14 @@ export type SystemDataUsageCommandOutput = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -11172,12 +11157,12 @@ export type VolumeListCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -11218,14 +11203,14 @@ export type VolumeListCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -11246,9 +11231,9 @@ export type VolumeListCommandOutput = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -11271,14 +11256,14 @@ export type VolumeListCommandOutput = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -11321,12 +11306,12 @@ type VolumeCreateJsonBody = { * passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; ClusterVolumeSpec?: { Group?: string; AccessMode?: { @@ -11352,14 +11337,14 @@ type VolumeCreateJsonBody = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -11411,12 +11396,12 @@ export type VolumeCreateCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -11457,14 +11442,14 @@ export type VolumeCreateCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -11485,9 +11470,9 @@ export type VolumeCreateCommandOutput = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -11510,14 +11495,14 @@ export type VolumeCreateCommandOutput = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -11571,12 +11556,12 @@ export type VolumeInspectCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] */ - Labels: Record; + Labels: Record; /** * The level at which the volume exists. Either `global` for cluster-wide, * or `local` for machine level. @@ -11617,14 +11602,14 @@ export type VolumeInspectCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -11645,9 +11630,9 @@ export type VolumeInspectCommandOutput = { }; Info?: { CapacityBytes?: bigint; - VolumeContext?: Record; + VolumeContext?: Record; VolumeID?: string; - AccessibleTopology?: readonly Record[]; + AccessibleTopology?: readonly Record[]; }; PublishStatus?: readonly { NodeID?: string; @@ -11670,14 +11655,14 @@ export type VolumeInspectCommandOutput = { | "published" | "pending-node-unpublish" | "pending-controller-unpublish"; - PublishContext?: Record; + PublishContext?: Record; }[]; }; /** * The driver specific options used when creating the volume. * @example [object Object] */ - Options: Record; + Options: Record; UsageData?: { /** * Amount of disk space used by the volume (in bytes). This information @@ -11726,14 +11711,14 @@ type VolumeUpdateJsonBody = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; }[]; AccessibilityRequirements?: { - Requisite?: readonly Record[]; - Preferred?: readonly Record[]; + Requisite?: readonly Record[]; + Preferred?: readonly Record[]; }; CapacityRange?: { RequiredBytes?: bigint; @@ -11827,13 +11812,13 @@ export type NetworkListCommandOutput = readonly { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }[]; /** * Driver-specific options, specified as a map. * @example [object Object] */ - Options?: Record; + Options?: Record; }; /** * Whether the network is created to only allow internal networking @@ -11867,7 +11852,7 @@ export type NetworkListCommandOutput = readonly { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -11880,12 +11865,12 @@ export type NetworkListCommandOutput = readonly { * Network-specific options uses when creating the network. * @example [object Object] */ - Options?: Record; + Options?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Peers?: readonly { /** * ID of the peer-node in the Swarm cluster. @@ -11955,13 +11940,13 @@ export type NetworkInspectCommandOutput = { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }[]; /** * Driver-specific options, specified as a map. * @example [object Object] */ - Options?: Record; + Options?: Record; }; /** * Whether the network is created to only allow internal networking @@ -11995,7 +11980,7 @@ export type NetworkInspectCommandOutput = { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -12008,12 +11993,12 @@ export type NetworkInspectCommandOutput = { * Network-specific options uses when creating the network. * @example [object Object] */ - Options?: Record; + Options?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Peers?: readonly { /** * ID of the peer-node in the Swarm cluster. @@ -12098,13 +12083,13 @@ type NetworkCreateJsonBody = { Subnet?: string; IPRange?: string; Gateway?: string; - AuxiliaryAddresses?: Record; + AuxiliaryAddresses?: Record; }[]; /** * Driver-specific options, specified as a map. * @example [object Object] */ - Options?: Record; + Options?: Record; }; /** * Enable IPv6 on the network. @@ -12115,12 +12100,12 @@ type NetworkCreateJsonBody = { * Network specific options to be used by the drivers. * @example [object Object] */ - Options?: Record; + Options?: Record; /** * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; }; export type NetworkCreateCommandBody = NetworkCreateJsonBody; export type NetworkCreateCommandInput = NetworkCreateJsonBody; @@ -12190,7 +12175,7 @@ type NetworkConnectJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record; }; }; export type NetworkConnectCommandParams = { @@ -12668,7 +12653,7 @@ export type NodeListCommandOutput = readonly { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12718,7 +12703,7 @@ export type NodeListCommandOutput = readonly { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -12793,7 +12778,7 @@ export type NodeInspectCommandOutput = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12843,7 +12828,7 @@ export type NodeInspectCommandOutput = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -12908,7 +12893,7 @@ type NodeUpdateJsonBody = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12961,7 +12946,7 @@ export type SwarmInspectCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -13025,7 +13010,7 @@ export type SwarmInspectCommandOutput = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -13052,7 +13037,7 @@ export type SwarmInspectCommandOutput = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13119,7 +13104,7 @@ type SwarmInitJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -13183,7 +13168,7 @@ type SwarmInitJsonBody = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -13210,7 +13195,7 @@ type SwarmInitJsonBody = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13249,7 +13234,7 @@ type SwarmUpdateJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; Orchestration?: { /** * The number of historic tasks to keep per instance or node. If @@ -13313,7 +13298,7 @@ type SwarmUpdateJsonBody = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; @@ -13340,7 +13325,7 @@ type SwarmUpdateJsonBody = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13372,7 +13357,7 @@ export type ServiceListCommandOutput = readonly { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -13386,7 +13371,7 @@ export type ServiceListCommandOutput = readonly { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -13476,10 +13461,10 @@ export type ServiceListCommandOutput = readonly { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -13519,7 +13504,7 @@ export type ServiceListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -13530,7 +13515,7 @@ export type ServiceListCommandOutput = readonly { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -13654,18 +13639,18 @@ export type ServiceListCommandOutput = readonly { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -13674,7 +13659,7 @@ export type ServiceListCommandOutput = readonly { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -13717,7 +13702,7 @@ export type ServiceListCommandOutput = readonly { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -13851,7 +13836,7 @@ export type ServiceCreateCommandHeader = { }; type ServiceCreateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -13865,7 +13850,7 @@ type ServiceCreateJsonBody = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -13955,10 +13940,10 @@ type ServiceCreateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -13998,7 +13983,7 @@ type ServiceCreateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14009,7 +13994,7 @@ type ServiceCreateJsonBody = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -14133,18 +14118,18 @@ type ServiceCreateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -14153,7 +14138,7 @@ type ServiceCreateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14196,7 +14181,7 @@ type ServiceCreateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -14230,7 +14215,7 @@ type ServiceCreateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceCreateCommandBody = ServiceCreateJsonBody; export type ServiceCreateCommandInput = ServiceCreateJsonBody; export type ServiceCreateCommandOutput = { @@ -14256,7 +14241,7 @@ export type ServiceInspectCommandOutput = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -14270,7 +14255,7 @@ export type ServiceInspectCommandOutput = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -14360,10 +14345,10 @@ export type ServiceInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -14403,7 +14388,7 @@ export type ServiceInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14414,7 +14399,7 @@ export type ServiceInspectCommandOutput = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -14538,18 +14523,18 @@ export type ServiceInspectCommandOutput = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -14558,7 +14543,7 @@ export type ServiceInspectCommandOutput = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14601,7 +14586,7 @@ export type ServiceInspectCommandOutput = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -14744,7 +14729,7 @@ export type ServiceUpdateCommandHeader = { }; type ServiceUpdateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -14758,7 +14743,7 @@ type ServiceUpdateJsonBody = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -14848,10 +14833,10 @@ type ServiceUpdateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -14891,7 +14876,7 @@ type ServiceUpdateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14902,7 +14887,7 @@ type ServiceUpdateJsonBody = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -15026,18 +15011,18 @@ type ServiceUpdateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; Mode?: { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -15046,7 +15031,7 @@ type ServiceUpdateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -15089,7 +15074,7 @@ type ServiceUpdateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -15123,7 +15108,7 @@ type ServiceUpdateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceUpdateCommandParams = { id: string; }; @@ -15162,7 +15147,7 @@ export type TaskListCommandOutput = readonly { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -15176,7 +15161,7 @@ export type TaskListCommandOutput = readonly { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -15266,10 +15251,10 @@ export type TaskListCommandOutput = readonly { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -15309,7 +15294,7 @@ export type TaskListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15320,7 +15305,7 @@ export type TaskListCommandOutput = readonly { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -15444,11 +15429,11 @@ export type TaskListCommandOutput = readonly { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; ServiceID?: string; @@ -15529,7 +15514,7 @@ export type TaskInspectCommandOutput = { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -15543,7 +15528,7 @@ export type TaskInspectCommandOutput = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -15633,10 +15618,10 @@ export type TaskInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -15676,7 +15661,7 @@ export type TaskInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15687,7 +15672,7 @@ export type TaskInspectCommandOutput = { */ Isolation?: "default" | "process" | "hyperv" | ""; Init?: boolean | null; - Sysctls?: Record; + Sysctls?: Record; /** * A list of kernel capabilities to add to the default set * for the container. @@ -15811,11 +15796,11 @@ export type TaskInspectCommandOutput = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; LogDriver?: { Name?: string; - Options?: Record; + Options?: Record; }; }; ServiceID?: string; @@ -15914,7 +15899,7 @@ export type SecretListCommandOutput = readonly { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -15935,7 +15920,7 @@ export type SecretListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -15947,7 +15932,7 @@ export type SecretListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }[]; @@ -15959,7 +15944,7 @@ type SecretCreateJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -15980,7 +15965,7 @@ type SecretCreateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -15992,9 +15977,9 @@ type SecretCreateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; -} & Record; +} & Record; export type SecretCreateCommandBody = SecretCreateJsonBody; export type SecretCreateCommandInput = SecretCreateJsonBody; export type SecretCreateCommandOutput = { @@ -16019,7 +16004,7 @@ export type SecretInspectCommandOutput = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -16040,7 +16025,7 @@ export type SecretInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -16052,7 +16037,7 @@ export type SecretInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -16071,7 +16056,7 @@ type SecretUpdateJsonBody = { * User-defined key/value metadata. * @example [object Object] */ - Labels?: Record; + Labels?: Record; /** * Base64-url-safe-encoded ([RFC * 4648](https://tools.ietf.org/html/rfc4648#section-5)) @@ -16092,7 +16077,7 @@ type SecretUpdateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -16104,7 +16089,7 @@ type SecretUpdateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type SecretUpdateCommandParams = { @@ -16127,7 +16112,7 @@ export type ConfigListCommandOutput = readonly { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16139,7 +16124,7 @@ export type ConfigListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }[]; @@ -16147,7 +16132,7 @@ export type InputConfigListCommandResponse = UndefinedOnPartialDeep; type ConfigCreateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16159,9 +16144,9 @@ type ConfigCreateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; -} & Record; +} & Record; export type ConfigCreateCommandBody = ConfigCreateJsonBody; export type ConfigCreateCommandInput = ConfigCreateJsonBody; export type ConfigCreateCommandOutput = { @@ -16182,7 +16167,7 @@ export type ConfigInspectCommandOutput = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16194,7 +16179,7 @@ export type ConfigInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -16209,7 +16194,7 @@ export type ConfigUpdateCommandQuery = { }; type ConfigUpdateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16221,7 +16206,7 @@ type ConfigUpdateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type ConfigUpdateCommandParams = { diff --git a/__tests__/fixtures/openai/.openapi-codegen-manifest.json b/__tests__/fixtures/openai/.openapi-codegen-manifest.json index a2bb01a..8828ef8 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "3d94c5af1601bec3282ab4664df01eee", "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", - "types.ts": "605fb801d1203d2e523cbcb63cb8d0e6", + "types.ts": "9d72866ddaef5efdae76ea47d90ff3e7", "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", "valibot.ts": "9d670c8ddc0f9bb81a5dd1a80efd5eee", "hono.ts": "54130437a23164b228769eb3ec967e4e", diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index 46ea6fa..56afc6c 100644 --- a/__tests__/fixtures/openai/types.ts +++ b/__tests__/fixtures/openai/types.ts @@ -91,10 +91,7 @@ export type CreateChatCompletionStreamResponse = { * Represents a streamed chunk of a chat completion response returned by * model, based on the provided input. */ -export type CreateChatCompletionImageResponse = Record< - string | number, - Jsonifiable ->; +export type CreateChatCompletionImageResponse = Record; export type CreateImageRequest = { /** * A text description of the desired image(s). The maximum length is 1000 @@ -386,7 +383,7 @@ export type CompleteUploadRequest = { part_ids: readonly string[]; md5?: string; }; -export type CancelUploadRequest = Record; +export type CancelUploadRequest = Record; export type CreateFineTuningJobRequest = { /** * The name of the model to fine-tune. You can select one of the @@ -613,7 +610,7 @@ export type AssistantToolsFileSearchTypeOnly = { type: "file_search"; }; export type ModifyRunRequest = { - metadata?: Record; + metadata?: Record; }; export type SubmitToolOutputsRunRequest = { tool_outputs: readonly { @@ -637,7 +634,7 @@ export type ModifyThreadRequest = { vector_store_ids?: readonly string[]; }; }; - metadata?: Record; + metadata?: Record; }; export type DeleteThreadResponse = { id: string; @@ -645,7 +642,7 @@ export type DeleteThreadResponse = { object: "thread.deleted"; }; export type ModifyMessageRequest = { - metadata?: Record; + metadata?: Record; }; export type DeleteMessageResponse = { id: string; @@ -936,7 +933,7 @@ export type RunStepDeltaStepDetailsToolCallsFileSearchObject = { * @enum file_search */ type: "file_search"; - file_search: Record; + file_search: Record; }; export type RunStepDetailsToolCallsFunctionObject = { id: string; @@ -1019,7 +1016,7 @@ export type BatchRequestOutput = { response?: { status_code?: number; request_id?: string; - body?: Record; + body?: Record; }; error?: { code?: string; @@ -1511,7 +1508,7 @@ export type Batch = { completed: number; failed: number; }; - metadata?: Record; + metadata?: Record; }; export type ListBatchesResponse = { data: readonly Batch[]; @@ -1611,7 +1608,7 @@ export type MessageObject = { file_id?: string; tools?: readonly (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; }[]; - metadata: Record; + metadata: Record; }; export type MessageStreamEvent = | { @@ -1754,7 +1751,7 @@ export type RunStepObject = { cancelled_at: number | null; failed_at: number | null; completed_at: number | null; - metadata: Record; + metadata: Record; /** * Usage statistics related to the run step. This value will be `null` while * the run step's status is `in_progress`. @@ -1801,10 +1798,7 @@ export type RunStepStreamEvent = data: RunStepObject; }; /** The schema for the response format, described as a JSON Schema object. */ -export type ResponseFormatJsonSchemaSchema = Record< - string | number, - Jsonifiable ->; +export type ResponseFormatJsonSchemaSchema = Record; export type ResponseFormatJsonSchema = { /** * The type of response format being defined: `json_schema` @@ -2002,7 +1996,7 @@ export type RunObject = { * @default */ tools: readonly AssistantToolsCode[]; - metadata: Record; + metadata: Record; /** * Usage statistics related to the run. This value will be `null` if the run * is not in a terminal state (i.e. `in_progress`, `queued`, etc.). @@ -2134,7 +2128,7 @@ export type ThreadObject = { vector_store_ids?: readonly string[]; }; }; - metadata: Record; + metadata: Record; }; export type ThreadStreamEvent = { event: "thread.created"; @@ -2322,7 +2316,7 @@ export type VectorStoreObject = { expires_after?: VectorStoreExpirationAfter; expires_at?: number | null; last_active_at: number | null; - metadata: Record; + metadata: Record; }; export type ListVectorStoresResponse = { object: string; @@ -2335,7 +2329,7 @@ export type UpdateVectorStoreRequest = { name?: string; /** The expiration policy for a vector store. */ expires_after?: VectorStoreExpirationAfter; - metadata?: Record; + metadata?: Record; }; export type CreateVectorStoreRequest = { file_ids?: readonly string[]; @@ -2345,7 +2339,7 @@ export type CreateVectorStoreRequest = { chunking_strategy?: | AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - metadata?: Record; + metadata?: Record; }; /** A result instance of the file search. */ export type RunStepDetailsToolCallsFileSearchResultObject = { @@ -2427,7 +2421,7 @@ export type CreateMessageRequest = { file_id?: string; tools?: readonly (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; }[]; - metadata?: Record; + metadata?: Record; }; export type CreateThreadRequest = { messages?: readonly CreateMessageRequest[]; @@ -2443,7 +2437,7 @@ export type CreateThreadRequest = { }; file_search?: unknown; }; - metadata?: Record; + metadata?: Record; }; export type CreateThreadAndRunRequest = { assistant_id: string; @@ -2497,7 +2491,7 @@ export type CreateThreadAndRunRequest = { vector_store_ids?: readonly string[]; }; }; - metadata?: Record; + metadata?: Record; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2614,7 +2608,7 @@ export type CreateRunRequest = { additional_instructions?: string; additional_messages?: readonly CreateMessageRequest[]; tools?: readonly AssistantToolsCode[]; - metadata?: Record; + metadata?: Record; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2693,7 +2687,7 @@ export type CreateRunRequest = { * * Omitting `parameters` defines a function with an empty parameter list. */ -export type FunctionParameters = Record; +export type FunctionParameters = Record; export type FunctionObject = { description?: string; name: string; @@ -2790,7 +2784,7 @@ export type AssistantObject = { vector_store_ids?: readonly string[]; }; }; - metadata: Record; + metadata: Record; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2871,7 +2865,7 @@ export type ModifyAssistantRequest = { vector_store_ids?: readonly string[]; }; }; - metadata?: Record; + metadata?: Record; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2975,7 +2969,7 @@ export type CreateAssistantRequest = { }; file_search?: unknown; }; - metadata?: Record; + metadata?: Record; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -3638,7 +3632,7 @@ export type CreateChatCompletionRequest = { string >; frequency_penalty?: number | null; - logit_bias?: Record; + logit_bias?: Record; logprobs?: boolean | null; top_logprobs?: number | null; /** @@ -3850,7 +3844,7 @@ export type CreateCompletionResponse = { text_offset?: readonly number[]; token_logprobs?: readonly number[]; tokens?: readonly string[]; - top_logprobs?: readonly Record[]; + top_logprobs?: readonly Record[]; }; text: string; }[]; @@ -3900,7 +3894,7 @@ export type CreateCompletionRequest = { best_of?: number | null; echo?: boolean | null; frequency_penalty?: number | null; - logit_bias?: Record; + logit_bias?: Record; logprobs?: number | null; /** * The maximum number of [tokens](/tokenizer) that can be generated in the @@ -4482,7 +4476,7 @@ type CreateBatchJsonBody = { * @enum 24h */ completion_window: "24h"; - metadata?: Record; + metadata?: Record; }; export type CreateBatchCommandBody = CreateBatchJsonBody; export type CreateBatchCommandInput = CreateBatchJsonBody; diff --git a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json index 2717dd8..16e77bd 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "3d94c5af1601bec3282ab4664df01eee", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", diff --git a/__tests__/fixtures/test1/.openapi-codegen-manifest.json b/__tests__/fixtures/test1/.openapi-codegen-manifest.json index b1d5c83..5ce122a 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "3d94c5af1601bec3282ab4664df01eee", "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", - "types.ts": "2fa39af3c41c92051312d9ba51ee2a5a", + "types.ts": "e19f646f79d970daa0bb6a21140a2f94", "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", "valibot.ts": "d7e166b84040d92d2eefc8b2f986e5a1", "hono.ts": "26885b9a53e8c0343a2fdb21f4eb8a37", diff --git a/__tests__/fixtures/test1/types.ts b/__tests__/fixtures/test1/types.ts index fab8006..f848fd1 100644 --- a/__tests__/fixtures/test1/types.ts +++ b/__tests__/fixtures/test1/types.ts @@ -213,7 +213,7 @@ export type LongRunningOperationSuccess = { operationId: Uuid; done: boolean; result: { - response: Record; + response: Record; }; }; export type LongRunningOperation = diff --git a/lib/process-schema.ts b/lib/process-schema.ts index 62e738a..13d3101 100644 --- a/lib/process-schema.ts +++ b/lib/process-schema.ts @@ -107,7 +107,7 @@ function maybeUnion(...types: (string | WriterFunction)[]) { function recordType(value: string | WriterFunction) { return (writer: CodeBlockWriter) => { - writer.write("Record", + type: "Record", }; } @@ -855,7 +855,7 @@ export function registerTypesFromSchema( // in TypeScript, since JSON Schema names such as `integer` differ register( schemaToType(typesAndInterfaces, {}, schemaName, schemaObject).type ?? - "Record", + "Record", schemaObject.description, ); } From 05852613547341892c8d13aa446f2154a51a058a Mon Sep 17 00:00:00 2001 From: "maxholman[bot]" <321308195+maxholman[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:44:32 +0800 Subject: [PATCH 2/5] fix: admit null in nullable object, array and string types valibot wraps every nullable schema in v.nullable, but the TS type for an object, an array, or a non-temporal string returned before the null union was applied. A validated response could then hold null where its type said a value was always there, as docker's IPAMConfig does. Co-Authored-By: LLM --- .../types.ts | 15 + .../valibot.ts | 62 ++ .../docker/.openapi-codegen-manifest.json | 4 +- __tests__/fixtures/docker/types.ts | 592 +++++++++--------- .../openai/.openapi-codegen-manifest.json | 4 +- __tests__/fixtures/openai/types.ts | 259 ++++---- .../petstore/.openapi-codegen-manifest.json | 2 +- .../test1/.openapi-codegen-manifest.json | 2 +- __tests__/nullables.test.ts | 58 ++ lib/process-schema.ts | 55 +- 10 files changed, 628 insertions(+), 425 deletions(-) create mode 100644 __tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/types.ts create mode 100644 __tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts diff --git a/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/types.ts b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/types.ts new file mode 100644 index 0000000..ec2f3bb --- /dev/null +++ b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/types.ts @@ -0,0 +1,15 @@ +export type Base = { + "id"?: string; + }; +export type Nullables = { + "object": { + "id"?: string; + } | null; + "array": readonly (string)[] | null; + "string": string | null; + "stringEnum": "a" | "b" | null; + "unionMember": string | readonly (string)[] | null; + "intersectionMember": Base & { + "name"?: string; + }; + }; diff --git a/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts new file mode 100644 index 0000000..c099bcb --- /dev/null +++ b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts @@ -0,0 +1,62 @@ +import * as v from "valibot"; + +export const inputBaseSchema = v.looseObject( + { + "id": v.optional(v.string()) + , + }); +export const baseSchema = v.looseObject( + { + "id": v.exactOptional(v.pipe(v.string(), v.trim())) + , + }); +export const inputNullablesSchema = v.looseObject( + { + "object": v.nullable(v.looseObject( + { + "id": v.optional(v.string()) + , + })) + , + "array": v.nullable(v.array(v.string())) + , + "string": v.nullable(v.string()) + , + "stringEnum": v.nullable(v.picklist(["a", "b"])) + , + "unionMember": v.nullable(v.union([v.nullable(v.string()), v.array(v.string())])) + , + "intersectionMember": v.looseObject( + { + ...inputBaseSchema + .entries, + "name": v.optional(v.string()) + , + }) + , + }); +export const nullablesSchema = v.looseObject( + { + "object": v.nullable(v.looseObject( + { + "id": v.exactOptional(v.pipe(v.string(), v.trim())) + , + })) + , + "array": v.nullable(v.array(v.pipe(v.string(), v.trim()))) + , + "string": v.nullable(v.pipe(v.string(), v.trim())) + , + "stringEnum": v.nullable(v.picklist(["a", "b"])) + , + "unionMember": v.nullable(v.union([v.nullable(v.pipe(v.string(), v.trim())), v.array(v.pipe(v.string(), v.trim()))])) + , + "intersectionMember": v.looseObject( + { + ...baseSchema + .entries, + "name": v.exactOptional(v.pipe(v.string(), v.trim())) + , + }) + , + }); diff --git a/__tests__/fixtures/docker/.openapi-codegen-manifest.json b/__tests__/fixtures/docker/.openapi-codegen-manifest.json index bc3c892..74870e3 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "3d94c5af1601bec3282ab4664df01eee", + "#generator": "d6135fb004b0f7131657ef7774c6d9dc", "commands.ts": "137aa1b06856ca44a0c780958480af81", - "types.ts": "3e03e759f7637110c12ddea24009796c", + "types.ts": "8663cb3f2737a93a01cf1b396e2fad63", "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", "valibot.ts": "2c62b6192664e3a42e1b44700d430df7", "hono.ts": "4dee43760e6f999bf0da89d4c063bcd4", diff --git a/__tests__/fixtures/docker/types.ts b/__tests__/fixtures/docker/types.ts index 416cd4a..cc0ad51 100644 --- a/__tests__/fixtures/docker/types.ts +++ b/__tests__/fixtures/docker/types.ts @@ -302,7 +302,7 @@ export type Health = { * @example 0 */ FailingStreak?: number; - Log?: readonly { + Log?: readonly ({ /** * Date and time at which this check started in * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. @@ -326,8 +326,8 @@ export type Health = { */ ExitCode?: number; Output?: string; - }[]; -}; + } | null)[]; +} | null; /** * HealthcheckResult stores information about a single run of a healthcheck * probe @@ -356,7 +356,7 @@ export type HealthcheckResult = { */ ExitCode?: number; Output?: string; -}; +} | null; /** Container configuration that depends on the host we are running on */ export type HostConfig = { CpuShares?: number; @@ -456,18 +456,19 @@ export type HostConfig = { */ PortBindings?: Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; RestartPolicy?: { /** @@ -534,7 +535,7 @@ export type HostConfig = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; @@ -619,7 +620,7 @@ export type ContainerConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -669,12 +670,12 @@ export type ContainerConfig = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -684,13 +685,13 @@ export type ContainerConfig = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * Configuration of the image. These fields are used as defaults @@ -753,7 +754,7 @@ export type ImageConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -852,12 +853,12 @@ export type ImageConfig = { * > **Note**: this field is always omitted and must not be used. * @example */ - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -867,13 +868,13 @@ export type ImageConfig = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * NetworkingConfig represents the container's networking configuration for @@ -889,7 +890,7 @@ export type NetworkingConfig = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -942,7 +943,7 @@ export type NetworkingConfig = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -985,32 +986,37 @@ export type NetworkSettings = { */ Ports?: Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; /** * SandboxKey identifies the sandbox * @example /var/run/docker/netns/8ab54b426c38 */ SandboxKey?: string; - SecondaryIPAddresses?: readonly { - Addr?: string; - PrefixLen?: number; - }[]; - SecondaryIPv6Addresses?: readonly { - Addr?: string; - PrefixLen?: number; - }[]; + SecondaryIPAddresses?: + | readonly { + Addr?: string; + PrefixLen?: number; + }[] + | null; + SecondaryIPv6Addresses?: + | readonly { + Addr?: string; + PrefixLen?: number; + }[] + | null; /** * EndpointID uniquely represents a service endpoint in a Sandbox. * @@ -1122,7 +1128,7 @@ export type NetworkSettings = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -1175,7 +1181,7 @@ export type NetworkSettings = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -1195,18 +1201,19 @@ export type Address = { */ export type PortMap = Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; /** * PortBinding represents a binding between a host IP address and a host @@ -1355,7 +1362,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -1405,12 +1412,12 @@ export type ImageInspect = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -1420,13 +1427,13 @@ export type ImageInspect = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * The version of Docker that was used to build the image. @@ -1503,7 +1510,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -1602,12 +1609,12 @@ export type ImageInspect = { * > **Note**: this field is always omitted and must not be used. * @example */ - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -1617,13 +1624,13 @@ export type ImageInspect = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * Hardware CPU architecture that the image runs on. @@ -1634,7 +1641,7 @@ export type ImageInspect = { * CPU architecture variant (presently ARM-only). * @example v7 */ - Variant?: string; + Variant?: string | null; /** * Operating System the image is built to run on. * @example linux @@ -1645,7 +1652,7 @@ export type ImageInspect = { * for Windows). * @example */ - OsVersion?: string; + OsVersion?: string | null; /** * Total size of the image including all layers it is composed of. * @example 1239828 @@ -1692,7 +1699,7 @@ export type ImageInspect = { * and omitted otherwise. * @example 2022-02-28T14:40:02.623929178Z */ - LastTagTime?: string; + LastTagTime?: string | null; }; }; export type ImageSummary = { @@ -1951,7 +1958,7 @@ export type Volume = { * @default -1 */ RefCount: bigint; - }; + } | null; }; /** Volume configuration */ export type VolumeCreateOptions = { @@ -2183,7 +2190,7 @@ export type VolumeListResponse = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; /** * Warnings that occurred when fetching the list of volumes. @@ -2295,18 +2302,20 @@ export type Network = { * @example [object Object] */ Labels?: Record; - Peers?: readonly { - /** - * ID of the peer-node in the Swarm cluster. - * @example 6869d7c1732b - */ - Name?: string; - /** - * IP-address of the peer-node in the Swarm cluster. - * @example 10.133.77.91 - */ - IP?: string; - }[]; + Peers?: + | readonly { + /** + * ID of the peer-node in the Swarm cluster. + * @example 6869d7c1732b + */ + Name?: string; + /** + * IP-address of the peer-node in the Swarm cluster. + * @example 10.133.77.91 + */ + IP?: string; + }[] + | null; }; /** * The config-only network source to provide the configuration for @@ -2401,12 +2410,12 @@ export type BuildCache = { * > **Deprecated**: This field is deprecated, and omitted if empty. * @example */ - Parent?: string; + Parent?: string | null; /** * List of parent build cache record IDs. * @example hw53o5aio51xtltp5xjp8v7fx */ - Parents?: readonly string[]; + Parents?: readonly string[] | null; /** * Cache record type. * @enum internal,frontend,source.local,source.git.checkout,exec.cachemount,regular @@ -2450,7 +2459,7 @@ export type BuildCache = { * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. * @example 2017-08-09T07:09:37.632105588Z */ - LastUsedAt?: string; + LastUsedAt?: string | null; UsageCount?: number; }; /** Image ID or Digest */ @@ -2502,7 +2511,7 @@ export type EndpointSettings = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -2555,14 +2564,14 @@ export type EndpointSettings = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; }; /** EndpointIPAMConfig represents an endpoint's IPAM configuration. */ export type EndpointIpamConfig = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; -}; +} | null; export type PluginMount = { Name: string; Description: string; @@ -2855,7 +2864,7 @@ export type Node = { * @example 10.0.0.46:2377 */ Addr?: string; - }; + } | null; }; /** * NodeDescription encapsulates the properties of the Node as reported by the @@ -2986,7 +2995,7 @@ export type ManagerStatus = { * @example 10.0.0.46:2377 */ Addr?: string; -}; +} | null; /** Reachability represents the reachability of a node. */ export type Reachability = "unknown" | "unreachable" | "reachable"; /** User modifiable swarm configuration. */ @@ -3008,7 +3017,7 @@ export type SwarmSpec = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3048,7 +3057,7 @@ export type SwarmSpec = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3070,7 +3079,7 @@ export type SwarmSpec = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -3138,7 +3147,7 @@ export type ClusterInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3178,7 +3187,7 @@ export type ClusterInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3200,7 +3209,7 @@ export type ClusterInfo = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -3254,7 +3263,7 @@ export type ClusterInfo = { * @example 24 */ SubnetSize?: number; -}; +} | null; /** JoinTokens contains the tokens workers and managers need to join the swarm. */ export type JoinTokens = { /** @@ -3307,7 +3316,7 @@ export type Swarm = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3347,7 +3356,7 @@ export type Swarm = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3369,7 +3378,7 @@ export type Swarm = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -5060,7 +5069,7 @@ export type ContainerSummary = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -5113,7 +5122,7 @@ export type ContainerSummary = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -5419,7 +5428,7 @@ export type ContainerState = { * @example 0 */ FailingStreak?: number; - Log?: readonly { + Log?: readonly ({ /** * Date and time at which this check started in * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. @@ -5443,9 +5452,9 @@ export type ContainerState = { */ ExitCode?: number; Output?: string; - }[]; - }; -}; + } | null)[]; + } | null; +} | null; /** OK response to ContainerCreate operation */ export type ContainerCreateResponse = { /** @@ -5486,7 +5495,7 @@ export type SystemVersion = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record | null; }[]; /** * The version of the daemon @@ -5925,7 +5934,7 @@ export type SystemInfo = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -5933,7 +5942,7 @@ export type SystemInfo = { * @example https://hub-mirror.corp.example.com:5000/,https://[2001:db8:a0b:12f0::1]/ */ Mirrors?: readonly string[]; - }; + } | null; /** * User-defined resources can be either Integer resources (e.g, `SSD=3`) or * String resources (e.g, `GPU=UUID1`). @@ -6041,7 +6050,7 @@ export type SystemInfo = { * List of command-line arguments to pass to the runtime when invoked. * @example --debug,--systemd-cgroup=false */ - runtimeArgs?: readonly string[]; + runtimeArgs?: readonly string[] | null; } >; /** @@ -6082,10 +6091,12 @@ export type SystemInfo = { * List of ID's and addresses of other managers in the swarm. * @example [object Object],[object Object],[object Object] */ - RemoteManagers?: readonly { - NodeID?: string; - Addr?: string; - }[]; + RemoteManagers?: + | readonly { + NodeID?: string; + Addr?: string; + }[] + | null; /** * Total number of nodes in the swarm. * @example 4 @@ -6135,7 +6146,7 @@ export type SystemInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -6175,7 +6186,7 @@ export type SystemInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -6197,7 +6208,7 @@ export type SystemInfo = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -6251,7 +6262,7 @@ export type SystemInfo = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** * Indicates if live restore is enabled. @@ -6501,7 +6512,7 @@ export type RegistryServiceConfig = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -6509,7 +6520,7 @@ export type RegistryServiceConfig = { * @example https://hub-mirror.corp.example.com:5000/,https://[2001:db8:a0b:12f0::1]/ */ Mirrors?: readonly string[]; -}; +} | null; /** IndexInfo contains information about a registry. */ export type IndexInfo = { /** @@ -6544,7 +6555,7 @@ export type IndexInfo = { * @example true */ Official?: boolean; -}; +} | null; /** * Runtime describes an [OCI * compliant](https://github.com/opencontainers/runtime-spec) @@ -6567,7 +6578,7 @@ export type Runtime = { * List of command-line arguments to pass to the runtime when invoked. * @example --debug,--systemd-cgroup=false */ - runtimeArgs?: readonly string[]; + runtimeArgs?: readonly string[] | null; }; /** * Commit holds the Git-commit (SHA1) that a binary was built from, as @@ -6611,10 +6622,12 @@ export type SwarmInfo = { * List of ID's and addresses of other managers in the swarm. * @example [object Object],[object Object],[object Object] */ - RemoteManagers?: readonly { - NodeID?: string; - Addr?: string; - }[]; + RemoteManagers?: + | readonly { + NodeID?: string; + Addr?: string; + }[] + | null; /** * Total number of nodes in the swarm. * @example 4 @@ -6664,7 +6677,7 @@ export type SwarmInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -6704,7 +6717,7 @@ export type SwarmInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -6726,7 +6739,7 @@ export type SwarmInfo = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -6780,7 +6793,7 @@ export type SwarmInfo = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** Current local status of this node. */ export type LocalNodeState = @@ -7166,7 +7179,7 @@ export type ContainerListCommandOutput = readonly { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -7219,7 +7232,7 @@ export type ContainerListCommandOutput = readonly { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -7317,7 +7330,7 @@ type ContainerCreateJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -7367,12 +7380,12 @@ type ContainerCreateJsonBody = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -7382,13 +7395,13 @@ type ContainerCreateJsonBody = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; } & { HostConfig?: { CpuShares?: number; @@ -7488,18 +7501,19 @@ type ContainerCreateJsonBody = { */ PortBindings?: Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; RestartPolicy?: { /** @@ -7566,7 +7580,7 @@ type ContainerCreateJsonBody = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; @@ -7631,7 +7645,7 @@ type ContainerCreateJsonBody = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -7684,7 +7698,7 @@ type ContainerCreateJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -7806,7 +7820,7 @@ export type ContainerInspectCommandOutput = { * @example 0 */ FailingStreak?: number; - Log?: readonly { + Log?: readonly ({ /** * Date and time at which this check started in * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. @@ -7830,9 +7844,9 @@ export type ContainerInspectCommandOutput = { */ ExitCode?: number; Output?: string; - }[]; - }; - }; + } | null)[]; + } | null; + } | null; Image?: string; ResolvConfPath?: string; HostnamePath?: string; @@ -7845,7 +7859,7 @@ export type ContainerInspectCommandOutput = { MountLabel?: string; ProcessLabel?: string; AppArmorProfile?: string; - ExecIDs?: readonly string[]; + ExecIDs?: readonly string[] | null; HostConfig?: { CpuShares?: number; Memory?: bigint; @@ -7944,18 +7958,19 @@ export type ContainerInspectCommandOutput = { */ PortBindings?: Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; RestartPolicy?: { /** @@ -8022,7 +8037,7 @@ export type ContainerInspectCommandOutput = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; @@ -8176,7 +8191,7 @@ export type ContainerInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -8226,12 +8241,12 @@ export type ContainerInspectCommandOutput = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -8241,13 +8256,13 @@ export type ContainerInspectCommandOutput = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; NetworkSettings?: { /** @@ -8287,32 +8302,37 @@ export type ContainerInspectCommandOutput = { */ Ports?: Record< string, - readonly { - /** - * Host IP address that the container's port is mapped to. - * @example 127.0.0.1 - */ - HostIp?: string; - /** - * Host port number that the container's port is mapped to. - * @example 4443 - */ - HostPort?: string; - }[] + | readonly { + /** + * Host IP address that the container's port is mapped to. + * @example 127.0.0.1 + */ + HostIp?: string; + /** + * Host port number that the container's port is mapped to. + * @example 4443 + */ + HostPort?: string; + }[] + | null >; /** * SandboxKey identifies the sandbox * @example /var/run/docker/netns/8ab54b426c38 */ SandboxKey?: string; - SecondaryIPAddresses?: readonly { - Addr?: string; - PrefixLen?: number; - }[]; - SecondaryIPv6Addresses?: readonly { - Addr?: string; - PrefixLen?: number; - }[]; + SecondaryIPAddresses?: + | readonly { + Addr?: string; + PrefixLen?: number; + }[] + | null; + SecondaryIPv6Addresses?: + | readonly { + Addr?: string; + PrefixLen?: number; + }[] + | null; /** * EndpointID uniquely represents a service endpoint in a Sandbox. * @@ -8424,7 +8444,7 @@ export type ContainerInspectCommandOutput = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -8477,7 +8497,7 @@ export type ContainerInspectCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -9069,7 +9089,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -9119,12 +9139,12 @@ export type ImageInspectCommandOutput = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -9134,13 +9154,13 @@ export type ImageInspectCommandOutput = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * The version of Docker that was used to build the image. @@ -9217,7 +9237,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -9316,12 +9336,12 @@ export type ImageInspectCommandOutput = { * > **Note**: this field is always omitted and must not be used. * @example */ - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -9331,13 +9351,13 @@ export type ImageInspectCommandOutput = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; /** * Hardware CPU architecture that the image runs on. @@ -9348,7 +9368,7 @@ export type ImageInspectCommandOutput = { * CPU architecture variant (presently ARM-only). * @example v7 */ - Variant?: string; + Variant?: string | null; /** * Operating System the image is built to run on. * @example linux @@ -9359,7 +9379,7 @@ export type ImageInspectCommandOutput = { * for Windows). * @example */ - OsVersion?: string; + OsVersion?: string | null; /** * Total size of the image including all layers it is composed of. * @example 1239828 @@ -9406,7 +9426,7 @@ export type ImageInspectCommandOutput = { * and omitted otherwise. * @example 2022-02-28T14:40:02.623929178Z */ - LastTagTime?: string; + LastTagTime?: string | null; }; }; export type InputImageInspectCommandResponse = @@ -9883,7 +9903,7 @@ export type SystemInfoCommandOutput = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -9891,7 +9911,7 @@ export type SystemInfoCommandOutput = { * @example https://hub-mirror.corp.example.com:5000/,https://[2001:db8:a0b:12f0::1]/ */ Mirrors?: readonly string[]; - }; + } | null; /** * User-defined resources can be either Integer resources (e.g, `SSD=3`) or * String resources (e.g, `GPU=UUID1`). @@ -9999,7 +10019,7 @@ export type SystemInfoCommandOutput = { * List of command-line arguments to pass to the runtime when invoked. * @example --debug,--systemd-cgroup=false */ - runtimeArgs?: readonly string[]; + runtimeArgs?: readonly string[] | null; } >; /** @@ -10040,10 +10060,12 @@ export type SystemInfoCommandOutput = { * List of ID's and addresses of other managers in the swarm. * @example [object Object],[object Object],[object Object] */ - RemoteManagers?: readonly { - NodeID?: string; - Addr?: string; - }[]; + RemoteManagers?: + | readonly { + NodeID?: string; + Addr?: string; + }[] + | null; /** * Total number of nodes in the swarm. * @example 4 @@ -10093,7 +10115,7 @@ export type SystemInfoCommandOutput = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -10133,7 +10155,7 @@ export type SystemInfoCommandOutput = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -10155,7 +10177,7 @@ export type SystemInfoCommandOutput = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -10209,7 +10231,7 @@ export type SystemInfoCommandOutput = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** * Indicates if live restore is enabled. @@ -10333,7 +10355,7 @@ export type SystemVersionCommandOutput = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record | null; }[]; /** * The version of the daemon @@ -10429,7 +10451,7 @@ type ImageCommitJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -10479,12 +10501,12 @@ type ImageCommitJsonBody = { */ Entrypoint?: readonly string[]; NetworkDisabled?: boolean | null; - MacAddress?: string; + MacAddress?: string | null; /** * `ONBUILD` metadata that were defined in the image's `Dockerfile`. * @example */ - OnBuild?: readonly string[]; + OnBuild?: readonly string[] | null; /** * User-defined key/value metadata. * @example [object Object] @@ -10494,13 +10516,13 @@ type ImageCommitJsonBody = { * Signal to stop a container as a string or unsigned integer. * @example SIGTERM */ - StopSignal?: string; + StopSignal?: string | null; StopTimeout?: number | null; /** * Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell. * @example /bin/sh,-c */ - Shell?: readonly string[]; + Shell?: readonly string[] | null; }; export type ImageCommitCommandBody = ImageCommitJsonBody; export type ImageCommitCommandInput = ImageCommitJsonBody & @@ -10696,7 +10718,7 @@ export type SystemDataUsageCommandOutput = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -10749,7 +10771,7 @@ export type SystemDataUsageCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -10968,7 +10990,7 @@ export type SystemDataUsageCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; BuildCache?: readonly { /** @@ -10982,12 +11004,12 @@ export type SystemDataUsageCommandOutput = { * > **Deprecated**: This field is deprecated, and omitted if empty. * @example */ - Parent?: string; + Parent?: string | null; /** * List of parent build cache record IDs. * @example hw53o5aio51xtltp5xjp8v7fx */ - Parents?: readonly string[]; + Parents?: readonly string[] | null; /** * Cache record type. * @enum internal,frontend,source.local,source.git.checkout,exec.cachemount,regular @@ -11031,7 +11053,7 @@ export type SystemDataUsageCommandOutput = { * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format with nano-seconds. * @example 2017-08-09T07:09:37.632105588Z */ - LastUsedAt?: string; + LastUsedAt?: string | null; UsageCount?: number; }[]; }; @@ -11058,7 +11080,7 @@ type ContainerExecJsonBody = { AttachStdin?: boolean; AttachStdout?: boolean; AttachStderr?: boolean; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; DetachKeys?: string; Tty?: boolean; Env?: readonly string[]; @@ -11081,7 +11103,7 @@ export type InputContainerExecCommandResponse = type ExecStartJsonBody = { Detach?: boolean; Tty?: boolean; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; }; export type ExecStartCommandParams = { id: string; @@ -11279,7 +11301,7 @@ export type VolumeListCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; /** * Warnings that occurred when fetching the list of volumes. @@ -11518,7 +11540,7 @@ export type VolumeCreateCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }; export type InputVolumeCreateCommandResponse = UndefinedOnPartialDeep; @@ -11678,7 +11700,7 @@ export type VolumeInspectCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }; export type InputVolumeInspectCommandResponse = UndefinedOnPartialDeep; @@ -11871,18 +11893,20 @@ export type NetworkListCommandOutput = readonly { * @example [object Object] */ Labels?: Record; - Peers?: readonly { - /** - * ID of the peer-node in the Swarm cluster. - * @example 6869d7c1732b - */ - Name?: string; - /** - * IP-address of the peer-node in the Swarm cluster. - * @example 10.133.77.91 - */ - IP?: string; - }[]; + Peers?: + | readonly { + /** + * ID of the peer-node in the Swarm cluster. + * @example 6869d7c1732b + */ + Name?: string; + /** + * IP-address of the peer-node in the Swarm cluster. + * @example 10.133.77.91 + */ + IP?: string; + }[] + | null; }[]; export type InputNetworkListCommandResponse = UndefinedOnPartialDeep; @@ -11999,18 +12023,20 @@ export type NetworkInspectCommandOutput = { * @example [object Object] */ Labels?: Record; - Peers?: readonly { - /** - * ID of the peer-node in the Swarm cluster. - * @example 6869d7c1732b - */ - Name?: string; - /** - * IP-address of the peer-node in the Swarm cluster. - * @example 10.133.77.91 - */ - IP?: string; - }[]; + Peers?: + | readonly { + /** + * ID of the peer-node in the Swarm cluster. + * @example 6869d7c1732b + */ + Name?: string; + /** + * IP-address of the peer-node in the Swarm cluster. + * @example 10.133.77.91 + */ + IP?: string; + }[] + | null; }; export type InputNetworkInspectCommandResponse = UndefinedOnPartialDeep; @@ -12122,7 +12148,7 @@ type NetworkConnectJsonBody = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -12175,7 +12201,7 @@ type NetworkConnectJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; }; }; export type NetworkConnectCommandParams = { @@ -12747,7 +12773,7 @@ export type NodeListCommandOutput = readonly { * @example 10.0.0.46:2377 */ Addr?: string; - }; + } | null; }[]; export type InputNodeListCommandResponse = UndefinedOnPartialDeep; @@ -12872,7 +12898,7 @@ export type NodeInspectCommandOutput = { * @example 10.0.0.46:2377 */ Addr?: string; - }; + } | null; }; export type InputNodeInspectCommandResponse = UndefinedOnPartialDeep; @@ -12954,7 +12980,7 @@ export type SwarmInspectCommandOutput = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -12994,7 +13020,7 @@ export type SwarmInspectCommandOutput = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13016,7 +13042,7 @@ export type SwarmInspectCommandOutput = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -13112,7 +13138,7 @@ type SwarmInitJsonBody = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -13152,7 +13178,7 @@ type SwarmInitJsonBody = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13174,7 +13200,7 @@ type SwarmInitJsonBody = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -13242,7 +13268,7 @@ type SwarmUpdateJsonBody = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -13282,7 +13308,7 @@ type SwarmUpdateJsonBody = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13304,7 +13330,7 @@ type SwarmUpdateJsonBody = { SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the diff --git a/__tests__/fixtures/openai/.openapi-codegen-manifest.json b/__tests__/fixtures/openai/.openapi-codegen-manifest.json index 8828ef8..a46dbe2 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "3d94c5af1601bec3282ab4664df01eee", + "#generator": "d6135fb004b0f7131657ef7774c6d9dc", "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", - "types.ts": "9d72866ddaef5efdae76ea47d90ff3e7", + "types.ts": "96f39fe18139b75d58cd2987ec07877c", "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", "valibot.ts": "9d670c8ddc0f9bb81a5dd1a80efd5eee", "hono.ts": "54130437a23164b228769eb3ec967e4e", diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index 56afc6c..9b51c4a 100644 --- a/__tests__/fixtures/openai/types.ts +++ b/__tests__/fixtures/openai/types.ts @@ -27,11 +27,11 @@ export type ChatCompletionRole = export type ChatCompletionTokenLogprob = { token: string; logprob: number; - bytes: readonly number[]; + bytes: readonly number[] | null; top_logprobs: readonly { token: string; logprob: number; - bytes: readonly number[]; + bytes: readonly number[] | null; }[]; }; /** @@ -44,9 +44,9 @@ export type CreateChatCompletionStreamResponse = { /** WARN: $ref used before available - schema={"$ref":"#/components/schemas/ChatCompletionStreamResponseDelta"} */ delta: never; logprobs?: { - content: readonly ChatCompletionTokenLogprob[]; - refusal: readonly ChatCompletionTokenLogprob[]; - }; + content: readonly ChatCompletionTokenLogprob[] | null; + refusal: readonly ChatCompletionTokenLogprob[] | null; + } | null; /** * The reason the model stopped generating tokens. This will be `stop` if the * model hit a natural stop point or a provided stop sequence, @@ -63,7 +63,8 @@ export type CreateChatCompletionStreamResponse = { | "length" | "tool_calls" | "content_filter" - | "function_call"; + | "function_call" + | null; index: number; }[]; created: number; @@ -74,7 +75,7 @@ export type CreateChatCompletionStreamResponse = { * @enum scale,default * @example scale */ - service_tier?: "scale" | "default"; + service_tier?: "scale" | "default" | null; system_fingerprint?: string; /** * The object type, which is always `chat.completion.chunk`. @@ -129,7 +130,7 @@ export type CreateImageRequest = { * @enum url,b64_json * @example url */ - response_format?: "url" | "b64_json"; + response_format?: "url" | "b64_json" | null; /** * The size of the generated images. Must be one of `256x256`, `512x512`, or * `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or @@ -138,7 +139,7 @@ export type CreateImageRequest = { * @enum 256x256,512x512,1024x1024,1792x1024,1024x1792 * @example 1024x1024 */ - size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792"; + size?: "256x256" | "512x512" | "1024x1024" | "1792x1024" | "1024x1792" | null; /** * The style of the generated images. Must be one of `vivid` or `natural`. * Vivid causes the model to lean towards generating hyper-real and dramatic @@ -148,7 +149,7 @@ export type CreateImageRequest = { * @enum vivid,natural * @example vivid */ - style?: "vivid" | "natural"; + style?: "vivid" | "natural" | null; /** * A unique identifier representing your end-user, which can help OpenAI to * monitor and detect abuse. [Learn @@ -186,7 +187,7 @@ export type CreateImageEditRequest = { * @enum 256x256,512x512,1024x1024 * @example 1024x1024 */ - size?: "256x256" | "512x512" | "1024x1024"; + size?: "256x256" | "512x512" | "1024x1024" | null; /** * The format in which the generated images are returned. Must be one of `url` * or `b64_json`. URLs are only valid for 60 minutes after the image has been @@ -195,7 +196,7 @@ export type CreateImageEditRequest = { * @enum url,b64_json * @example url */ - response_format?: "url" | "b64_json"; + response_format?: "url" | "b64_json" | null; /** * A unique identifier representing your end-user, which can help OpenAI to * monitor and detect abuse. [Learn @@ -228,7 +229,7 @@ export type CreateImageVariationRequest = { * @enum url,b64_json * @example url */ - response_format?: "url" | "b64_json"; + response_format?: "url" | "b64_json" | null; /** * The size of the generated images. Must be one of `256x256`, `512x512`, or * `1024x1024`. @@ -236,7 +237,7 @@ export type CreateImageVariationRequest = { * @enum 256x256,512x512,1024x1024 * @example 1024x1024 */ - size?: "256x256" | "512x512" | "1024x1024"; + size?: "256x256" | "512x512" | "1024x1024" | null; /** * A unique identifier representing your end-user, which can help OpenAI to * monitor and detect abuse. [Learn @@ -435,7 +436,7 @@ export type CreateFineTuningJobRequest = { */ n_epochs?: "auto" | number; }; - suffix?: string; + suffix?: string | null; /** * The ID of an uploaded file that contains validation data. * @@ -450,20 +451,22 @@ export type CreateFineTuningJobRequest = { * See the [fine-tuning guide](/docs/guides/fine-tuning) for more details. * @example file-abc123 */ - validation_file?: string; - integrations?: readonly { - type: "wandb"; - wandb: { - /** - * The name of the project that the new run will be created under. - * @example my-wandb-project - */ - project: string; - name?: string; - entity?: string; - tags?: readonly string[]; - }; - }[]; + validation_file?: string | null; + integrations?: + | readonly { + type: "wandb"; + wandb: { + /** + * The name of the project that the new run will be created under. + * @example my-wandb-project + */ + project: string; + name?: string | null; + entity?: string | null; + tags?: readonly string[]; + }; + }[] + | null; /** * The seed controls the reproducibility of the job. Passing in the same seed * and job parameters should produce the same results, but may differ in rare @@ -577,8 +580,8 @@ export type FineTuningIntegration = { * @example my-wandb-project */ project: string; - name?: string; - entity?: string; + name?: string | null; + entity?: string | null; tags?: readonly string[]; }; }; @@ -610,7 +613,7 @@ export type AssistantToolsFileSearchTypeOnly = { type: "file_search"; }; export type ModifyRunRequest = { - metadata?: Record; + metadata?: Record | null; }; export type SubmitToolOutputsRunRequest = { tool_outputs: readonly { @@ -633,8 +636,8 @@ export type ModifyThreadRequest = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata?: Record; + } | null; + metadata?: Record | null; }; export type DeleteThreadResponse = { id: string; @@ -642,7 +645,7 @@ export type DeleteThreadResponse = { object: "thread.deleted"; }; export type ModifyMessageRequest = { - metadata?: Record; + metadata?: Record | null; }; export type DeleteMessageResponse = { id: string; @@ -946,7 +949,7 @@ export type RunStepDetailsToolCallsFunctionObject = { function: { name: string; arguments: string; - output: string; + output: string | null; }; }; export type RunStepDeltaStepDetailsToolCallsFunctionObject = { @@ -961,7 +964,7 @@ export type RunStepDeltaStepDetailsToolCallsFunctionObject = { function?: { name?: string; arguments?: string; - output?: string; + output?: string | null; }; }; export type DeleteVectorStoreResponse = { @@ -1017,11 +1020,11 @@ export type BatchRequestOutput = { status_code?: number; request_id?: string; body?: Record; - }; + } | null; error?: { code?: string; message?: string; - }; + } | null; }; export type InviteRequest = { email: string; @@ -1473,7 +1476,7 @@ export type Batch = { data?: readonly { code?: string; message?: string; - param?: string; + param?: string | null; line?: number | null; }[]; }; @@ -1508,7 +1511,7 @@ export type Batch = { completed: number; failed: number; }; - metadata?: Record; + metadata?: Record | null; }; export type ListBatchesResponse = { data: readonly Batch[]; @@ -1548,9 +1551,9 @@ export type DoneEvent = { data: "[DONE]"; }; export type Error = { - code: string; + code: string | null; message: string; - param: string; + param: string | null; type: string; }; /** @@ -1588,7 +1591,7 @@ export type MessageObject = { | "run_cancelled" | "run_expired" | "run_failed"; - }; + } | null; completed_at: number | null; incomplete_at: number | null; /** @@ -1602,13 +1605,18 @@ export type MessageObject = { | MessageContentTextObject | MessageContentRefusalObject )[]; - assistant_id: string; - run_id: string; - attachments: readonly { - file_id?: string; - tools?: readonly (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; - metadata: Record; + assistant_id: string | null; + run_id: string | null; + attachments: + | readonly { + file_id?: string; + tools?: readonly ( + | AssistantToolsCode + | AssistantToolsFileSearchTypeOnly + )[]; + }[] + | null; + metadata: Record | null; }; export type MessageStreamEvent = | { @@ -1688,7 +1696,7 @@ export type RunStepCompletionUsage = { completion_tokens: number; prompt_tokens: number; total_tokens: number; -}; +} | null; /** Details of the tool call. */ export type RunStepDetailsToolCallsObject = { /** @@ -1746,12 +1754,12 @@ export type RunStepObject = { */ code: "server_error" | "rate_limit_exceeded"; message: string; - }; + } | null; expired_at: number | null; cancelled_at: number | null; failed_at: number | null; completed_at: number | null; - metadata: Record; + metadata: Record | null; /** * Usage statistics related to the run step. This value will be `null` while * the run step's status is `in_progress`. @@ -1915,7 +1923,7 @@ export type RunCompletionUsage = { completion_tokens: number; prompt_tokens: number; total_tokens: number; -}; +} | null; /** Tool call objects */ export type RunToolCallObject = { id: string; @@ -1966,7 +1974,7 @@ export type RunObject = { submit_tool_outputs: { tool_calls: readonly RunToolCallObject[]; }; - }; + } | null; last_error: { /** * One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. @@ -1974,7 +1982,7 @@ export type RunObject = { */ code: "server_error" | "rate_limit_exceeded" | "invalid_prompt"; message: string; - }; + } | null; expires_at: number | null; started_at: number | null; cancelled_at: number | null; @@ -1987,7 +1995,7 @@ export type RunObject = { * @enum max_completion_tokens,max_prompt_tokens */ reason?: "max_completion_tokens" | "max_prompt_tokens"; - }; + } | null; model: string; instructions: string; /** @@ -1996,7 +2004,7 @@ export type RunObject = { * @default */ tools: readonly AssistantToolsCode[]; - metadata: Record; + metadata: Record | null; /** * Usage statistics related to the run. This value will be `null` if the run * is not in a terminal state (i.e. `in_progress`, `queued`, etc.). @@ -2127,8 +2135,8 @@ export type ThreadObject = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata: Record; + } | null; + metadata: Record | null; }; export type ThreadStreamEvent = { event: "thread.created"; @@ -2254,7 +2262,7 @@ export type VectorStoreFileObject = { */ code: "server_error" | "unsupported_file" | "invalid_file"; message: string; - }; + } | null; chunking_strategy?: | StaticChunkingStrategyResponseParam | OtherChunkingStrategyResponseParam; @@ -2316,7 +2324,7 @@ export type VectorStoreObject = { expires_after?: VectorStoreExpirationAfter; expires_at?: number | null; last_active_at: number | null; - metadata: Record; + metadata: Record | null; }; export type ListVectorStoresResponse = { object: string; @@ -2326,10 +2334,10 @@ export type ListVectorStoresResponse = { has_more: boolean; }; export type UpdateVectorStoreRequest = { - name?: string; + name?: string | null; /** The expiration policy for a vector store. */ expires_after?: VectorStoreExpirationAfter; - metadata?: Record; + metadata?: Record | null; }; export type CreateVectorStoreRequest = { file_ids?: readonly string[]; @@ -2339,7 +2347,7 @@ export type CreateVectorStoreRequest = { chunking_strategy?: | AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - metadata?: Record; + metadata?: Record | null; }; /** A result instance of the file search. */ export type RunStepDetailsToolCallsFileSearchResultObject = { @@ -2417,11 +2425,16 @@ export type CreateMessageRequest = { | MessageContentImageUrlObject | MessageRequestContentTextObject )[]; - attachments?: readonly { - file_id?: string; - tools?: readonly (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; - metadata?: Record; + attachments?: + | readonly { + file_id?: string; + tools?: readonly ( + | AssistantToolsCode + | AssistantToolsFileSearchTypeOnly + )[]; + }[] + | null; + metadata?: Record | null; }; export type CreateThreadRequest = { messages?: readonly CreateMessageRequest[]; @@ -2436,8 +2449,8 @@ export type CreateThreadRequest = { file_ids?: readonly string[]; }; file_search?: unknown; - }; - metadata?: Record; + } | null; + metadata?: Record | null; }; export type CreateThreadAndRunRequest = { assistant_id: string; @@ -2475,8 +2488,8 @@ export type CreateThreadAndRunRequest = { | "gpt-3.5-turbo-16k-0613", string > | null; - instructions?: string; - tools?: readonly AssistantToolsCode[]; + instructions?: string | null; + tools?: readonly AssistantToolsCode[] | null; tool_resources?: { code_interpreter?: { /** @@ -2490,8 +2503,8 @@ export type CreateThreadAndRunRequest = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata?: Record; + } | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2604,11 +2617,11 @@ export type CreateRunRequest = { | "gpt-3.5-turbo-16k-0613", string > | null; - instructions?: string; - additional_instructions?: string; - additional_messages?: readonly CreateMessageRequest[]; - tools?: readonly AssistantToolsCode[]; - metadata?: Record; + instructions?: string | null; + additional_instructions?: string | null; + additional_messages?: readonly CreateMessageRequest[] | null; + tools?: readonly AssistantToolsCode[] | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2755,10 +2768,10 @@ export type AssistantObject = { */ object: "assistant"; created_at: number; - name: string; - description: string; + name: string | null; + description: string | null; model: string; - instructions: string; + instructions: string | null; /** * A list of tool enabled on the assistant. There can be a maximum of 128 * tools per assistant. Tools can be of types `code_interpreter`, @@ -2783,8 +2796,8 @@ export type AssistantObject = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata: Record; + } | null; + metadata: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2837,9 +2850,9 @@ export type ListAssistantsResponse = { }; export type ModifyAssistantRequest = { model?: string; - name?: string; - description?: string; - instructions?: string; + name?: string | null; + description?: string | null; + instructions?: string | null; /** * A list of tool enabled on the assistant. There can be a maximum of 128 * tools per assistant. Tools can be of types `code_interpreter`, @@ -2864,8 +2877,8 @@ export type ModifyAssistantRequest = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata?: Record; + } | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2943,9 +2956,9 @@ export type CreateAssistantRequest = { | "gpt-3.5-turbo-16k-0613", string >; - name?: string; - description?: string; - instructions?: string; + name?: string | null; + description?: string | null; + instructions?: string | null; /** * A list of tool enabled on the assistant. There can be a maximum of 128 * tools per assistant. Tools can be of types `code_interpreter`, @@ -2968,8 +2981,8 @@ export type CreateAssistantRequest = { file_ids?: readonly string[]; }; file_search?: unknown; - }; - metadata?: Record; + } | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -3247,8 +3260,8 @@ export type FineTuningJobCheckpoint = { export type ListFineTuningJobCheckpointsResponse = { data: readonly FineTuningJobCheckpoint[]; object: "list"; - first_id?: string; - last_id?: string; + first_id?: string | null; + last_id?: string | null; has_more: boolean; }; /** Fine-tuning job event object */ @@ -3287,9 +3300,9 @@ export type FineTuningJob = { error: { code: string; message: string; - param: string; - }; - fine_tuned_model: string; + param: string | null; + } | null; + fine_tuned_model: string | null; finished_at: number | null; hyperparameters: { /** @@ -3325,8 +3338,8 @@ export type FineTuningJob = { | "cancelled"; trained_tokens: number | null; training_file: string; - validation_file: string; - integrations?: readonly FineTuningIntegration[]; + validation_file: string | null; + integrations?: readonly FineTuningIntegration[] | null; seed: number; estimated_finish?: number | null; }; @@ -3403,9 +3416,9 @@ export type CreateChatCompletionResponse = { /** WARN: $ref used before available - schema={"$ref":"#/components/schemas/ChatCompletionResponseMessage"} */ message: never; logprobs: { - content: readonly ChatCompletionTokenLogprob[]; - refusal: readonly ChatCompletionTokenLogprob[]; - }; + content: readonly ChatCompletionTokenLogprob[] | null; + refusal: readonly ChatCompletionTokenLogprob[] | null; + } | null; }[]; created: number; model: string; @@ -3415,7 +3428,7 @@ export type CreateChatCompletionResponse = { * @enum scale,default * @example scale */ - service_tier?: "scale" | "default"; + service_tier?: "scale" | "default" | null; system_fingerprint?: string; /** * The object type, which is always `chat.completion`. @@ -3467,14 +3480,14 @@ export type ChatCompletionToolChoiceOption = /** Options for streaming response. Only set this when you set `stream: true`. */ export type ChatCompletionStreamOptions = { include_usage?: boolean; -}; +} | null; export type ChatCompletionRequestFunctionMessage = { /** * The role of the messages author, in this case `function`. * @enum function */ role: "function"; - content: string; + content: string | null; name: string; }; export type ChatCompletionRequestMessageContentPartText = { @@ -3526,7 +3539,7 @@ export type ChatCompletionRequestAssistantMessage = { | string | readonly ChatCompletionRequestAssistantMessageContentPart[] | null; - refusal?: string; + refusal?: string | null; /** * The role of the messages author, in this case `assistant`. * @enum assistant @@ -3543,7 +3556,7 @@ export type ChatCompletionRequestAssistantMessage = { function_call?: { arguments: string; name: string; - }; + } | null; }; export type ChatCompletionRequestMessageContentPartImage = { /** @@ -3632,7 +3645,7 @@ export type CreateChatCompletionRequest = { string >; frequency_penalty?: number | null; - logit_bias?: Record; + logit_bias?: Record | null; logprobs?: boolean | null; top_logprobs?: number | null; /** @@ -3681,8 +3694,8 @@ export type CreateChatCompletionRequest = { * `service_tier` utilized. * @enum auto,default */ - service_tier?: "auto" | "default"; - stop?: string | readonly string[]; + service_tier?: "auto" | "default" | null; + stop?: string | readonly string[] | null; stream?: boolean | null; /** Options for streaming response. Only set this when you set `stream: true`. */ stream_options?: ChatCompletionStreamOptions; @@ -3774,7 +3787,7 @@ export type ChatCompletionMessageToolCallChunk = { }; /** A chat completion delta generated by streamed model responses. */ export type ChatCompletionStreamResponseDelta = { - content?: string; + content?: string | null; /** * Deprecated and replaced by `tool_calls`. The name and arguments of a * function that should be called, as generated by the model. @@ -3790,12 +3803,12 @@ export type ChatCompletionStreamResponseDelta = { * @enum system,user,assistant,tool */ role?: "system" | "user" | "assistant" | "tool"; - refusal?: string; + refusal?: string | null; }; /** A chat completion message generated by the model. */ export type ChatCompletionResponseMessage = { - content: string; - refusal: string; + content: string | null; + refusal: string | null; /** The tool calls generated by the model, such as function calls. */ tool_calls?: ChatCompletionMessageToolCalls; /** @@ -3845,7 +3858,7 @@ export type CreateCompletionResponse = { token_logprobs?: readonly number[]; tokens?: readonly string[]; top_logprobs?: readonly Record[]; - }; + } | null; text: string; }[]; created: number; @@ -3894,7 +3907,7 @@ export type CreateCompletionRequest = { best_of?: number | null; echo?: boolean | null; frequency_penalty?: number | null; - logit_bias?: Record; + logit_bias?: Record | null; logprobs?: number | null; /** * The maximum number of [tokens](/tokenizer) that can be generated in the @@ -3930,7 +3943,7 @@ export type CreateCompletionRequest = { * This parameter is only supported for `gpt-3.5-turbo-instruct`. * @example test. */ - suffix?: string; + suffix?: string | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -4476,7 +4489,7 @@ type CreateBatchJsonBody = { * @enum 24h */ completion_window: "24h"; - metadata?: Record; + metadata?: Record | null; }; export type CreateBatchCommandBody = CreateBatchJsonBody; export type CreateBatchCommandInput = CreateBatchJsonBody; diff --git a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json index 16e77bd..9463b51 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "3d94c5af1601bec3282ab4664df01eee", + "#generator": "d6135fb004b0f7131657ef7774c6d9dc", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", diff --git a/__tests__/fixtures/test1/.openapi-codegen-manifest.json b/__tests__/fixtures/test1/.openapi-codegen-manifest.json index 5ce122a..64a814b 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "3d94c5af1601bec3282ab4664df01eee", + "#generator": "d6135fb004b0f7131657ef7774c6d9dc", "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", "types.ts": "e19f646f79d970daa0bb6a21140a2f94", "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", diff --git a/__tests__/nullables.test.ts b/__tests__/nullables.test.ts index 9fff29f..ad25b42 100644 --- a/__tests__/nullables.test.ts +++ b/__tests__/nullables.test.ts @@ -70,6 +70,64 @@ test("top-level type array with null", async () => { ]); }); +test("3.0 nullable objects, arrays, strings and combinator members admit null", async () => { + const result = await processOpenApiDocument("/tmp/like-you-know-whatever", { + openapi: "3.0.3", + info: { title: "Test", version: "1.0.0" }, + paths: {}, + components: { + schemas: { + Base: { + type: "object", + properties: { id: { type: "string" } }, + }, + Nullables: { + type: "object", + required: [ + "object", + "array", + "string", + "stringEnum", + "unionMember", + "intersectionMember", + ], + properties: { + object: { + type: "object", + properties: { id: { type: "string" } }, + nullable: true, + }, + array: { type: "array", items: { type: "string" }, nullable: true }, + string: { type: "string", nullable: true }, + stringEnum: { type: "string", enum: ["a", "b"], nullable: true }, + // one nullable member makes the union nullable, once + unionMember: { + nullable: true, + oneOf: [ + { type: "string", nullable: true }, + { type: "array", items: { type: "string" } }, + ], + }, + // an intersection needs every member nullable to admit null + intersectionMember: { + allOf: [ + { $ref: "#/components/schemas/Base" }, + { + type: "object", + properties: { name: { type: "string" } }, + nullable: true, + }, + ], + }, + }, + }, + }, + }, + } as oas31.OpenAPIObject); + + await expectGenerated([result.typesFile, result.valibotFile]); +}); + test("const values", async () => { const result = await processOpenApiDocument( "/tmp/like-you-know-whatever", diff --git a/lib/process-schema.ts b/lib/process-schema.ts index 13d3101..51ed3e0 100644 --- a/lib/process-schema.ts +++ b/lib/process-schema.ts @@ -67,6 +67,17 @@ function schemaTypeIsNull(schema: oas30.SchemaObject | oas31.SchemaObject) { ); } +// valibot wraps every nullable schema in v.nullable, so the type admits null +function withNullable( + schema: oas30.SchemaObject | oas31.SchemaObject, + result: T, +) { + return { + ...result, + type: maybeWithNullUnion(result.type, schemaTypeIsNull(schema)), + }; +} + // Drops `unknown`, `never` and duplicate string members from a union function collapseUnion(types: (string | WriterFunction)[]) { const seen = new Set(); @@ -401,30 +412,46 @@ function combinatorType( } } + // a member's `nullable` joins the combinator's own null below, so the + // member types stay free of it + const nullableMembers = schemaItems.filter( + (schema) => + !isReferenceObject(schema) && "nullable" in schema && schema.nullable, + ); + const types = schemaItems .map((schema) => schemaToType( typesAndInterfaces, parentSchema, propertyName, - schema, + nullableMembers.includes(schema) + ? { ...schema, nullable: false } + : schema, options, ), ) .map((t) => t.type); const [onlyType] = types; + const intersect = "allOf" in schemaObject; + + // an intersection admits null when every member does + const membersNullable = intersect + ? nullableMembers.length === schemaItems.length + : nullableMembers.length > 0; // only one type, so just return that type if (types.length === 1 && onlyType !== undefined) { - return onlyType; + return maybeWithNullUnion( + onlyType, + membersNullable || schemaTypeIsNull(schemaObject), + ); } - const intersect = "allOf" in schemaObject; - const filteredTypes = types.filter((value) => isNotNullOrUndefined(value)); const hasNullType = types.some((t) => t === "null"); - const isNullable = schemaTypeIsNull(schemaObject); + const isNullable = membersNullable || schemaTypeIsNull(schemaObject); if (intersect) { // For allOf, intersect the non-null types and add null when nullable @@ -527,11 +554,7 @@ function stringType(schemaObject: oas31.SchemaObject | oas30.SchemaObject) { const temporal = temporalStringType(schemaObject.format); - if (temporal) { - return maybeWithNullUnion(temporal, schemaTypeIsNull(schemaObject)); - } - - return "string"; + return temporal ?? "string"; } function schemaObjectType( @@ -562,7 +585,10 @@ function schemaObjectType( } if (schemaObject.type === "array") { - return arrayType(typesAndInterfaces, propertyName, schemaObject, options); + return withNullable( + schemaObject, + arrayType(typesAndInterfaces, propertyName, schemaObject, options), + ); } if ( @@ -582,7 +608,10 @@ function schemaObjectType( } if (isObjectSchema(schemaObject)) { - return objectType(typesAndInterfaces, propertyName, schemaObject, options); + return withNullable( + schemaObject, + objectType(typesAndInterfaces, propertyName, schemaObject, options), + ); } if (schemaObject.type === "integer" || schemaObject.type === "number") { @@ -606,7 +635,7 @@ function schemaObjectType( } if (schemaObject.type === "string") { - return { type: stringType(schemaObject) }; + return withNullable(schemaObject, { type: stringType(schemaObject) }); } // empty schemaObject From ff9c9b65218e965824237230ad3c5c56206abe30 Mon Sep 17 00:00:00 2001 From: "maxholman[bot]" <321308195+maxholman[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:44:32 +0800 Subject: [PATCH 3/5] fix: honour required on object schemas that omit type A property was optional only when its parent declared `type: "object"`, so a schema with properties and no type made every property required, while valibot made the unlisted ones optional. The parent is now judged by isObjectSchema, as the type dispatch already is. Co-Authored-By: LLM --- .../types.ts | 4 ++++ __tests__/codegen-regressions.test.ts | 18 ++++++++++++++++++ .../docker/.openapi-codegen-manifest.json | 2 +- .../openai/.openapi-codegen-manifest.json | 4 ++-- __tests__/fixtures/openai/types.ts | 2 +- .../petstore/.openapi-codegen-manifest.json | 2 +- .../test1/.openapi-codegen-manifest.json | 2 +- lib/process-schema.ts | 2 +- 8 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 __tests__/__snapshots__/codegen-regressions/an-object-schema-that-omits-type-still-honours-required/types.ts diff --git a/__tests__/__snapshots__/codegen-regressions/an-object-schema-that-omits-type-still-honours-required/types.ts b/__tests__/__snapshots__/codegen-regressions/an-object-schema-that-omits-type-still-honours-required/types.ts new file mode 100644 index 0000000..83425c3 --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/an-object-schema-that-omits-type-still-honours-required/types.ts @@ -0,0 +1,4 @@ +export type Untyped = { + "id": string; + "note"?: string; + }; diff --git a/__tests__/codegen-regressions.test.ts b/__tests__/codegen-regressions.test.ts index c96731c..45ef54a 100644 --- a/__tests__/codegen-regressions.test.ts +++ b/__tests__/codegen-regressions.test.ts @@ -470,3 +470,21 @@ test("a oneOf query param keeps the stringish wire types in every branch", async await expectGenerated([result.typesFile]); }); + +test("an object schema that omits `type` still honours `required`", async () => { + const result = await processOpenApiDocument("/tmp/whatever", { + openapi: "3.1.0", + info: { title: "Test", version: "1.0.0" }, + paths: {}, + components: { + schemas: { + Untyped: { + required: ["id"], + properties: { id: { type: "string" }, note: { type: "string" } }, + }, + }, + }, + }); + + await expectGenerated([result.typesFile]); +}); diff --git a/__tests__/fixtures/docker/.openapi-codegen-manifest.json b/__tests__/fixtures/docker/.openapi-codegen-manifest.json index 74870e3..dbffb25 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "d6135fb004b0f7131657ef7774c6d9dc", + "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", "commands.ts": "137aa1b06856ca44a0c780958480af81", "types.ts": "8663cb3f2737a93a01cf1b396e2fad63", "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", diff --git a/__tests__/fixtures/openai/.openapi-codegen-manifest.json b/__tests__/fixtures/openai/.openapi-codegen-manifest.json index a46dbe2..3077747 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,7 +1,7 @@ { - "#generator": "d6135fb004b0f7131657ef7774c6d9dc", + "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", - "types.ts": "96f39fe18139b75d58cd2987ec07877c", + "types.ts": "f0e8be3c50578dfebfd60d365c51b59a", "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", "valibot.ts": "9d670c8ddc0f9bb81a5dd1a80efd5eee", "hono.ts": "54130437a23164b228769eb3ec967e4e", diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index 9b51c4a..ee43e8c 100644 --- a/__tests__/fixtures/openai/types.ts +++ b/__tests__/fixtures/openai/types.ts @@ -3100,7 +3100,7 @@ export type OpenAiFile = { * validation, see the `error` field on `fine_tuning.job`. * @deprecated */ - status_details: string; + status_details?: string; }; /** The Upload object can accept byte chunks in the form of Parts. */ export type Upload = { diff --git a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json index 9463b51..8542d63 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "d6135fb004b0f7131657ef7774c6d9dc", + "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", diff --git a/__tests__/fixtures/test1/.openapi-codegen-manifest.json b/__tests__/fixtures/test1/.openapi-codegen-manifest.json index 64a814b..c9524be 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,5 +1,5 @@ { - "#generator": "d6135fb004b0f7131657ef7774c6d9dc", + "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", "types.ts": "e19f646f79d970daa0bb6a21140a2f94", "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", diff --git a/lib/process-schema.ts b/lib/process-schema.ts index 51ed3e0..56aa98d 100644 --- a/lib/process-schema.ts +++ b/lib/process-schema.ts @@ -680,7 +680,7 @@ export function schemaToType( ): OptionalKind { const name = `"${propertyName}"`; const hasQuestionToken = - parentSchema.type === "object" && + isObjectSchema(parentSchema) && !parentSchema.required?.includes(propertyName); if (isReferenceObject(schemaObject)) { From 675f5ade8e206a14b8e532cff3fa2b6f117bb16b Mon Sep 17 00:00:00 2001 From: "maxholman[bot]" <321308195+maxholman[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:44:32 +0800 Subject: [PATCH 4/5] fix: order component schemas by every nested $ref getDependents followed a $ref only at a few top-level positions, so a ref under an items object, an additionalProperties value, or combinators beside properties was left out of the sort. Its schema could register before its target, and the TS side then emitted `never` while valibot emitted v.unknown(), which dropped out of unions (openai's RunObject.tools). It now walks the whole schema, and an unresolved ref throws on both sides rather than emitting a placeholder. Co-Authored-By: LLM --- .../types.ts | 5 + .../valibot.ts | 34 + __tests__/codegen-regressions.test.ts | 36 + .../docker/.openapi-codegen-manifest.json | 8 +- .../openai/.openapi-codegen-manifest.json | 12 +- __tests__/fixtures/openai/types.ts | 1703 +-- __tests__/fixtures/openai/valibot.ts | 9750 +++++++++-------- .../petstore/.openapi-codegen-manifest.json | 4 +- .../test1/.openapi-codegen-manifest.json | 14 +- lib/process-schema.ts | 17 +- lib/utils.ts | 50 +- lib/valibot.ts | 5 +- 12 files changed, 5892 insertions(+), 5746 deletions(-) create mode 100644 __tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/types.ts create mode 100644 __tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts diff --git a/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/types.ts b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/types.ts new file mode 100644 index 0000000..63f1128 --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/types.ts @@ -0,0 +1,5 @@ +export type Leaf = { + "name"?: string; + }; +export type InUnionBesideProperties = Leaf; +export type InRecord = Record; diff --git a/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts new file mode 100644 index 0000000..6769bad --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts @@ -0,0 +1,34 @@ +import * as v from "valibot"; + +export const inputLeafSchema = v.strictObject( + { + "name": v.optional(v.string()) + , + }); +export const leafSchema = v.strictObject( + { + "name": v.exactOptional(v.pipe(v.string(), v.trim())) + , + }); +export const inputInUnionBesidePropertiesSchema = v.looseObject( + { + ...inputLeafSchema + .entries, + }); +export const inUnionBesidePropertiesSchema = v.looseObject( + { + ...leafSchema + .entries, + }); +export const inputInRecordSchema = v.record(v.string(), inputLeafSchema); +export const inRecordSchema = inputInRecordSchema; +export const inputInArrayItemSchema = v.array(v.looseObject( + { + "leaf": v.optional(inputLeafSchema) + , + })); +export const inArrayItemSchema = v.array(v.looseObject( + { + "leaf": v.exactOptional(leafSchema) + , + })); diff --git a/__tests__/codegen-regressions.test.ts b/__tests__/codegen-regressions.test.ts index 45ef54a..cb52b09 100644 --- a/__tests__/codegen-regressions.test.ts +++ b/__tests__/codegen-regressions.test.ts @@ -488,3 +488,39 @@ test("an object schema that omits `type` still honours `required`", async () => await expectGenerated([result.typesFile]); }); + +test("a $ref nested past the top level registers after its target", async () => { + const result = await processOpenApiDocument("/tmp/whatever", { + openapi: "3.1.0", + info: { title: "Test", version: "1.0.0" }, + paths: {}, + components: { + schemas: { + // each refers to Leaf before it is declared + InArrayItem: { + type: "array", + items: { + type: "object", + properties: { leaf: { $ref: "#/components/schemas/Leaf" } }, + }, + }, + InRecord: { + type: "object", + additionalProperties: { $ref: "#/components/schemas/Leaf" }, + }, + InUnionBesideProperties: { + type: "object", + properties: { id: { type: "string" } }, + allOf: [{ $ref: "#/components/schemas/Leaf" }], + }, + Leaf: { + type: "object", + properties: { name: { type: "string" } }, + additionalProperties: false, + }, + }, + }, + }); + + await expectGenerated([result.typesFile, result.valibotFile]); +}); diff --git a/__tests__/fixtures/docker/.openapi-codegen-manifest.json b/__tests__/fixtures/docker/.openapi-codegen-manifest.json index dbffb25..9ef0dd3 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", - "commands.ts": "137aa1b06856ca44a0c780958480af81", + "#generator": "dfa29fcb516184c923352b589d0a33f8", + "commands.ts": "0971e86b831d9a354c1e219ecf7e8b7f", "types.ts": "8663cb3f2737a93a01cf1b396e2fad63", - "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", + "main.ts": "38065305823906f3aa1c7f968e278002", "valibot.ts": "2c62b6192664e3a42e1b44700d430df7", "hono.ts": "4dee43760e6f999bf0da89d4c063bcd4", - "commands-validated.ts": "c6066f3a4ead3dadfad70443e923a265", + "commands-validated.ts": "633c805329787be3de004224eeb86e5c", "enums.ts": "6d2420ab590db68349e2e8463a1b026d" } diff --git a/__tests__/fixtures/openai/.openapi-codegen-manifest.json b/__tests__/fixtures/openai/.openapi-codegen-manifest.json index 3077747..0d8a91c 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", - "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", - "types.ts": "f0e8be3c50578dfebfd60d365c51b59a", - "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", - "valibot.ts": "9d670c8ddc0f9bb81a5dd1a80efd5eee", + "#generator": "dfa29fcb516184c923352b589d0a33f8", + "commands.ts": "99ac148005b23e09a53adb6b62620dc0", + "types.ts": "09755ea8c2e057904e6e57c6ad14d7ed", + "main.ts": "8147604a37254400a015b78650466094", + "valibot.ts": "0d298d838136dd6e76996d9ebfe4af82", "hono.ts": "54130437a23164b228769eb3ec967e4e", - "commands-validated.ts": "e4929484f6a64b784ff7b03327f58a3a", + "commands-validated.ts": "9725b4bdcac4632927d011b9a54886d9", "enums.ts": "87a5ccd7e57cc937104b2d256e8d67b1" } diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index ee43e8c..d274f5f 100644 --- a/__tests__/fixtures/openai/types.ts +++ b/__tests__/fixtures/openai/types.ts @@ -24,70 +24,6 @@ export type ChatCompletionRole = | "assistant" | "tool" | "function"; -export type ChatCompletionTokenLogprob = { - token: string; - logprob: number; - bytes: readonly number[] | null; - top_logprobs: readonly { - token: string; - logprob: number; - bytes: readonly number[] | null; - }[]; -}; -/** - * Represents a streamed chunk of a chat completion response returned by - * model, based on the provided input. - */ -export type CreateChatCompletionStreamResponse = { - id: string; - choices: readonly { - /** WARN: $ref used before available - schema={"$ref":"#/components/schemas/ChatCompletionStreamResponseDelta"} */ - delta: never; - logprobs?: { - content: readonly ChatCompletionTokenLogprob[] | null; - refusal: readonly ChatCompletionTokenLogprob[] | null; - } | null; - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was - * reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if - * the model called a function. - * @enum stop,length,tool_calls,content_filter,function_call - */ - finish_reason: - | "stop" - | "length" - | "tool_calls" - | "content_filter" - | "function_call" - | null; - index: number; - }[]; - created: number; - model: string; - /** - * The service tier used for processing the request. This field is only - * included if the `service_tier` parameter is specified in the request. - * @enum scale,default - * @example scale - */ - service_tier?: "scale" | "default" | null; - system_fingerprint?: string; - /** - * The object type, which is always `chat.completion.chunk`. - * @enum chat.completion.chunk - */ - object: "chat.completion.chunk"; - usage?: { - completion_tokens: number; - prompt_tokens: number; - total_tokens: number; - }; -}; /** * Represents a streamed chunk of a chat completion response returned by * model, based on the provided input. @@ -568,23 +504,6 @@ export type UploadPart = { */ object: "upload.part"; }; -export type FineTuningIntegration = { - /** - * The type of the integration being enabled for the fine-tuning job - * @enum wandb - */ - type: "wandb"; - wandb: { - /** - * The name of the project that the new run will be created under. - * @example my-wandb-project - */ - project: string; - name?: string | null; - entity?: string | null; - tags?: readonly string[]; - }; -}; /** * The per-line training example of a fine-tuning input file for completions * models @@ -598,20 +517,6 @@ export type DeleteAssistantResponse = { deleted: boolean; object: "assistant.deleted"; }; -export type AssistantToolsCode = { - /** - * The type of tool being defined: `code_interpreter` - * @enum code_interpreter - */ - type: "code_interpreter"; -}; -export type AssistantToolsFileSearchTypeOnly = { - /** - * The type of tool being defined: `file_search` - * @enum file_search - */ - type: "file_search"; -}; export type ModifyRunRequest = { metadata?: Record | null; }; @@ -652,401 +557,86 @@ export type DeleteMessageResponse = { deleted: boolean; object: "thread.message.deleted"; }; -/** - * References an image [File](/docs/api-reference/files) in the content of a - * message. - */ -export type MessageContentImageFileObject = { - /** - * Always `image_file`. - * @enum image_file - */ - type: "image_file"; - image_file: { - file_id: string; - /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. - * @default auto - * @enum auto,low,high - */ - detail?: "auto" | "low" | "high"; - }; +export type DeleteVectorStoreResponse = { + id: string; + deleted: boolean; + object: "vector_store.deleted"; }; -/** - * References an image [File](/docs/api-reference/files) in the content of a - * message. - */ -export type MessageDeltaContentImageFileObject = { - index: number; - /** - * Always `image_file`. - * @enum image_file - */ - type: "image_file"; - image_file?: { - file_id?: string; - /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. - * @default auto - * @enum auto,low,high - */ - detail?: "auto" | "low" | "high"; - }; +export type DeleteVectorStoreFileResponse = { + id: string; + deleted: boolean; + object: "vector_store.file.deleted"; }; -/** References an image URL in the content of a message. */ -export type MessageContentImageUrlObject = { +/** A batch of files attached to a vector store. */ +export type VectorStoreFileBatchObject = { + id: string; /** - * The type of the content part. - * @enum image_url + * The object type, which is always `vector_store.file_batch`. + * @enum vector_store.files_batch */ - type: "image_url"; - image_url: { - url: string; - /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. Default value is `auto` - * @default auto - * @enum auto,low,high - */ - detail?: "auto" | "low" | "high"; - }; -}; -/** References an image URL in the content of a message. */ -export type MessageDeltaContentImageUrlObject = { - index: number; + object: "vector_store.files_batch"; + created_at: number; + vector_store_id: string; /** - * Always `image_url`. - * @enum image_url + * The status of the vector store files batch, which can be either + * `in_progress`, `completed`, `cancelled` or `failed`. + * @enum in_progress,completed,cancelled,failed */ - type: "image_url"; - image_url?: { - url?: string; - /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. - * @default auto - * @enum auto,low,high - */ - detail?: "auto" | "low" | "high"; + status: "in_progress" | "completed" | "cancelled" | "failed"; + file_counts: { + in_progress: number; + completed: number; + failed: number; + cancelled: number; + total: number; }; }; -/** The text content that is part of a message. */ -export type MessageContentTextObject = { +/** The per-line object of the batch input file */ +export type BatchRequestInput = { + custom_id?: string; /** - * Always `text`. - * @enum text + * The HTTP method to be used for the request. Currently only `POST` is + * supported. + * @enum POST */ - type: "text"; - text: { - value: string; - annotations: readonly never[]; - }; + method?: "POST"; + url?: string; }; -/** The refusal content generated by the assistant. */ -export type MessageContentRefusalObject = { +/** The per-line object of the batch output and error files */ +export type BatchRequestOutput = { + id?: string; + custom_id?: string; + response?: { + status_code?: number; + request_id?: string; + body?: Record; + } | null; + error?: { + code?: string; + message?: string; + } | null; +}; +export type InviteRequest = { + email: string; /** - * Always `refusal`. - * @enum refusal + * `owner` or `reader` + * @enum reader,owner */ - type: "refusal"; - refusal: string; + role: "reader" | "owner"; }; -/** The text content that is part of a message. */ -export type MessageRequestContentTextObject = { +export type InviteDeleteResponse = { /** - * Always `text`. - * @enum text + * The object type, which is always `organization.invite.deleted` + * @enum organization.invite.deleted */ - type: "text"; - text: string; + object: "organization.invite.deleted"; + id: string; + deleted: boolean; }; -/** - * A citation within the message that points to a specific quote from a - * specific File associated with the assistant or the message. Generated when - * the assistant uses the "file_search" tool to search files. - */ -export type MessageContentTextAnnotationsFileCitationObject = { +export type UserRoleUpdateRequest = { /** - * Always `file_citation`. - * @enum file_citation - */ - type: "file_citation"; - text: string; - file_citation: { - file_id: string; - }; - start_index: number; - end_index: number; -}; -/** - * A URL for the file that's generated when the assistant used the - * `code_interpreter` tool to generate a file. - */ -export type MessageContentTextAnnotationsFilePathObject = { - /** - * Always `file_path`. - * @enum file_path - */ - type: "file_path"; - text: string; - file_path: { - file_id: string; - }; - start_index: number; - end_index: number; -}; -/** The text content that is part of a message. */ -export type MessageDeltaContentTextObject = { - index: number; - /** - * Always `text`. - * @enum text - */ - type: "text"; - text?: { - value?: string; - annotations?: readonly never[]; - }; -}; -/** The refusal content that is part of a message. */ -export type MessageDeltaContentRefusalObject = { - index: number; - /** - * Always `refusal`. - * @enum refusal - */ - type: "refusal"; - refusal?: string; -}; -/** - * A citation within the message that points to a specific quote from a - * specific File associated with the assistant or the message. Generated when - * the assistant uses the "file_search" tool to search files. - */ -export type MessageDeltaContentTextAnnotationsFileCitationObject = { - index: number; - /** - * Always `file_citation`. - * @enum file_citation - */ - type: "file_citation"; - text?: string; - file_citation?: { - file_id?: string; - quote?: string; - }; - start_index?: number; - end_index?: number; -}; -/** - * A URL for the file that's generated when the assistant used the - * `code_interpreter` tool to generate a file. - */ -export type MessageDeltaContentTextAnnotationsFilePathObject = { - index: number; - /** - * Always `file_path`. - * @enum file_path - */ - type: "file_path"; - text?: string; - file_path?: { - file_id?: string; - }; - start_index?: number; - end_index?: number; -}; -/** Details of the Code Interpreter tool call the run step was involved in. */ -export type RunStepDetailsToolCallsCodeObject = { - id: string; - /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. - * @enum code_interpreter - */ - type: "code_interpreter"; - code_interpreter: { - input: string; - outputs: readonly never[]; - }; -}; -/** Details of the Code Interpreter tool call the run step was involved in. */ -export type RunStepDeltaStepDetailsToolCallsCodeObject = { - index: number; - id?: string; - /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. - * @enum code_interpreter - */ - type: "code_interpreter"; - code_interpreter?: { - input?: string; - outputs?: readonly never[]; - }; -}; -/** Text output from the Code Interpreter tool call as part of a run step. */ -export type RunStepDetailsToolCallsCodeOutputLogsObject = { - /** - * Always `logs`. - * @enum logs - */ - type: "logs"; - logs: string; -}; -/** Text output from the Code Interpreter tool call as part of a run step. */ -export type RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject = { - index: number; - /** - * Always `logs`. - * @enum logs - */ - type: "logs"; - logs?: string; -}; -export type RunStepDetailsToolCallsCodeOutputImageObject = { - /** - * Always `image`. - * @enum image - */ - type: "image"; - image: { - file_id: string; - }; -}; -export type RunStepDeltaStepDetailsToolCallsCodeOutputImageObject = { - index: number; - /** - * Always `image`. - * @enum image - */ - type: "image"; - image?: { - file_id?: string; - }; -}; -export type RunStepDeltaStepDetailsToolCallsFileSearchObject = { - index: number; - id?: string; - /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. - * @enum file_search - */ - type: "file_search"; - file_search: Record; -}; -export type RunStepDetailsToolCallsFunctionObject = { - id: string; - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - * @enum function - */ - type: "function"; - function: { - name: string; - arguments: string; - output: string | null; - }; -}; -export type RunStepDeltaStepDetailsToolCallsFunctionObject = { - index: number; - id?: string; - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - * @enum function - */ - type: "function"; - function?: { - name?: string; - arguments?: string; - output?: string | null; - }; -}; -export type DeleteVectorStoreResponse = { - id: string; - deleted: boolean; - object: "vector_store.deleted"; -}; -export type DeleteVectorStoreFileResponse = { - id: string; - deleted: boolean; - object: "vector_store.file.deleted"; -}; -/** A batch of files attached to a vector store. */ -export type VectorStoreFileBatchObject = { - id: string; - /** - * The object type, which is always `vector_store.file_batch`. - * @enum vector_store.files_batch - */ - object: "vector_store.files_batch"; - created_at: number; - vector_store_id: string; - /** - * The status of the vector store files batch, which can be either - * `in_progress`, `completed`, `cancelled` or `failed`. - * @enum in_progress,completed,cancelled,failed - */ - status: "in_progress" | "completed" | "cancelled" | "failed"; - file_counts: { - in_progress: number; - completed: number; - failed: number; - cancelled: number; - total: number; - }; -}; -/** The per-line object of the batch input file */ -export type BatchRequestInput = { - custom_id?: string; - /** - * The HTTP method to be used for the request. Currently only `POST` is - * supported. - * @enum POST - */ - method?: "POST"; - url?: string; -}; -/** The per-line object of the batch output and error files */ -export type BatchRequestOutput = { - id?: string; - custom_id?: string; - response?: { - status_code?: number; - request_id?: string; - body?: Record; - } | null; - error?: { - code?: string; - message?: string; - } | null; -}; -export type InviteRequest = { - email: string; - /** - * `owner` or `reader` - * @enum reader,owner - */ - role: "reader" | "owner"; -}; -export type InviteDeleteResponse = { - /** - * The object type, which is always `organization.invite.deleted` - * @enum organization.invite.deleted - */ - object: "organization.invite.deleted"; - id: string; - deleted: boolean; -}; -export type UserRoleUpdateRequest = { - /** - * `owner` or `reader` - * @enum owner,reader + * `owner` or `reader` + * @enum owner,reader */ role: "owner" | "reader"; }; @@ -1511,14 +1101,138 @@ export type Batch = { completed: number; failed: number; }; - metadata?: Record | null; + metadata?: Record | null; +}; +export type ListBatchesResponse = { + data: readonly Batch[]; + first_id?: string; + last_id?: string; + has_more: boolean; + object: "list"; +}; +/** Occurs when a stream ends. */ +export type DoneEvent = { + event: "done"; + data: "[DONE]"; +}; +export type Error = { + code: string | null; + message: string; + param: string | null; + type: string; +}; +/** + * Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This + * can happen due to an internal server error or a timeout. + */ +export type ErrorEvent = { + event: "error"; + data: Error; +}; +/** References an image URL in the content of a message. */ +export type MessageDeltaContentImageUrlObject = { + index: number; + /** + * Always `image_url`. + * @enum image_url + */ + type: "image_url"; + image_url?: { + url?: string; + /** + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. + * @default auto + * @enum auto,low,high + */ + detail?: "auto" | "low" | "high"; + }; +}; +/** The refusal content that is part of a message. */ +export type MessageDeltaContentRefusalObject = { + index: number; + /** + * Always `refusal`. + * @enum refusal + */ + type: "refusal"; + refusal?: string; +}; +/** + * A URL for the file that's generated when the assistant used the + * `code_interpreter` tool to generate a file. + */ +export type MessageDeltaContentTextAnnotationsFilePathObject = { + index: number; + /** + * Always `file_path`. + * @enum file_path + */ + type: "file_path"; + text?: string; + file_path?: { + file_id?: string; + }; + start_index?: number; + end_index?: number; +}; +/** + * A citation within the message that points to a specific quote from a + * specific File associated with the assistant or the message. Generated when + * the assistant uses the "file_search" tool to search files. + */ +export type MessageDeltaContentTextAnnotationsFileCitationObject = { + index: number; + /** + * Always `file_citation`. + * @enum file_citation + */ + type: "file_citation"; + text?: string; + file_citation?: { + file_id?: string; + quote?: string; + }; + start_index?: number; + end_index?: number; +}; +/** The text content that is part of a message. */ +export type MessageDeltaContentTextObject = { + index: number; + /** + * Always `text`. + * @enum text + */ + type: "text"; + text?: { + value?: string; + annotations?: readonly ( + | MessageDeltaContentTextAnnotationsFileCitationObject + | MessageDeltaContentTextAnnotationsFilePathObject + )[]; + }; }; -export type ListBatchesResponse = { - data: readonly Batch[]; - first_id?: string; - last_id?: string; - has_more: boolean; - object: "list"; +/** + * References an image [File](/docs/api-reference/files) in the content of a + * message. + */ +export type MessageDeltaContentImageFileObject = { + index: number; + /** + * Always `image_file`. + * @enum image_file + */ + type: "image_file"; + image_file?: { + file_id?: string; + /** + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. + * @default auto + * @enum auto,low,high + */ + detail?: "auto" | "low" | "high"; + }; }; /** * Represents a message delta i.e. any changed fields on a message during @@ -1545,24 +1259,117 @@ export type MessageDeltaObject = { )[]; }; }; -/** Occurs when a stream ends. */ -export type DoneEvent = { - event: "done"; - data: "[DONE]"; +export type AssistantToolsFileSearchTypeOnly = { + /** + * The type of tool being defined: `file_search` + * @enum file_search + */ + type: "file_search"; }; -export type Error = { - code: string | null; - message: string; - param: string | null; - type: string; +export type AssistantToolsCode = { + /** + * The type of tool being defined: `code_interpreter` + * @enum code_interpreter + */ + type: "code_interpreter"; +}; +/** The refusal content generated by the assistant. */ +export type MessageContentRefusalObject = { + /** + * Always `refusal`. + * @enum refusal + */ + type: "refusal"; + refusal: string; }; /** - * Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This - * can happen due to an internal server error or a timeout. + * A URL for the file that's generated when the assistant used the + * `code_interpreter` tool to generate a file. */ -export type ErrorEvent = { - event: "error"; - data: Error; +export type MessageContentTextAnnotationsFilePathObject = { + /** + * Always `file_path`. + * @enum file_path + */ + type: "file_path"; + text: string; + file_path: { + file_id: string; + }; + start_index: number; + end_index: number; +}; +/** + * A citation within the message that points to a specific quote from a + * specific File associated with the assistant or the message. Generated when + * the assistant uses the "file_search" tool to search files. + */ +export type MessageContentTextAnnotationsFileCitationObject = { + /** + * Always `file_citation`. + * @enum file_citation + */ + type: "file_citation"; + text: string; + file_citation: { + file_id: string; + }; + start_index: number; + end_index: number; +}; +/** The text content that is part of a message. */ +export type MessageContentTextObject = { + /** + * Always `text`. + * @enum text + */ + type: "text"; + text: { + value: string; + annotations: readonly ( + | MessageContentTextAnnotationsFileCitationObject + | MessageContentTextAnnotationsFilePathObject + )[]; + }; +}; +/** References an image URL in the content of a message. */ +export type MessageContentImageUrlObject = { + /** + * The type of the content part. + * @enum image_url + */ + type: "image_url"; + image_url: { + url: string; + /** + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. Default value is `auto` + * @default auto + * @enum auto,low,high + */ + detail?: "auto" | "low" | "high"; + }; +}; +/** + * References an image [File](/docs/api-reference/files) in the content of a + * message. + */ +export type MessageContentImageFileObject = { + /** + * Always `image_file`. + * @enum image_file + */ + type: "image_file"; + image_file: { + file_id: string; + /** + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. + * @default auto + * @enum auto,low,high + */ + detail?: "auto" | "low" | "high"; + }; }; /** Represents a message within a [thread](/docs/api-reference/threads). */ export type MessageObject = { @@ -1598,55 +1405,120 @@ export type MessageObject = { * The entity that produced the message. One of `user` or `assistant`. * @enum user,assistant */ - role: "user" | "assistant"; - content: readonly ( - | MessageContentImageFileObject - | MessageContentImageUrlObject - | MessageContentTextObject - | MessageContentRefusalObject - )[]; - assistant_id: string | null; - run_id: string | null; - attachments: - | readonly { - file_id?: string; - tools?: readonly ( - | AssistantToolsCode - | AssistantToolsFileSearchTypeOnly - )[]; - }[] - | null; - metadata: Record | null; + role: "user" | "assistant"; + content: readonly ( + | MessageContentImageFileObject + | MessageContentImageUrlObject + | MessageContentTextObject + | MessageContentRefusalObject + )[]; + assistant_id: string | null; + run_id: string | null; + attachments: + | readonly { + file_id?: string; + tools?: readonly ( + | AssistantToolsCode + | AssistantToolsFileSearchTypeOnly + )[]; + }[] + | null; + metadata: Record | null; +}; +export type MessageStreamEvent = + | { + event: "thread.message.created"; + /** Represents a message within a [thread](/docs/api-reference/threads). */ + data: MessageObject; + } + | { + event: "thread.message.in_progress"; + /** Represents a message within a [thread](/docs/api-reference/threads). */ + data: MessageObject; + } + | { + event: "thread.message.delta"; + /** + * Represents a message delta i.e. any changed fields on a message during + * streaming. + */ + data: MessageDeltaObject; + } + | { + event: "thread.message.completed"; + /** Represents a message within a [thread](/docs/api-reference/threads). */ + data: MessageObject; + } + | { + event: "thread.message.incomplete"; + /** Represents a message within a [thread](/docs/api-reference/threads). */ + data: MessageObject; + }; +export type RunStepDeltaStepDetailsToolCallsFunctionObject = { + index: number; + id?: string; + /** + * The type of tool call. This is always going to be `function` for this type + * of tool call. + * @enum function + */ + type: "function"; + function?: { + name?: string; + arguments?: string; + output?: string | null; + }; +}; +export type RunStepDeltaStepDetailsToolCallsFileSearchObject = { + index: number; + id?: string; + /** + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. + * @enum file_search + */ + type: "file_search"; + file_search: Record; +}; +export type RunStepDeltaStepDetailsToolCallsCodeOutputImageObject = { + index: number; + /** + * Always `image`. + * @enum image + */ + type: "image"; + image?: { + file_id?: string; + }; +}; +/** Text output from the Code Interpreter tool call as part of a run step. */ +export type RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject = { + index: number; + /** + * Always `logs`. + * @enum logs + */ + type: "logs"; + logs?: string; +}; +/** Details of the Code Interpreter tool call the run step was involved in. */ +export type RunStepDeltaStepDetailsToolCallsCodeObject = { + index: number; + id?: string; + /** + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. + * @enum code_interpreter + */ + type: "code_interpreter"; + code_interpreter?: { + input?: string; + outputs?: readonly ( + | RunStepDeltaStepDetailsToolCallsCodeOutputLogsObject + | RunStepDeltaStepDetailsToolCallsCodeOutputImageObject + )[]; + }; }; -export type MessageStreamEvent = - | { - event: "thread.message.created"; - /** Represents a message within a [thread](/docs/api-reference/threads). */ - data: MessageObject; - } - | { - event: "thread.message.in_progress"; - /** Represents a message within a [thread](/docs/api-reference/threads). */ - data: MessageObject; - } - | { - event: "thread.message.delta"; - /** - * Represents a message delta i.e. any changed fields on a message during - * streaming. - */ - data: MessageDeltaObject; - } - | { - event: "thread.message.completed"; - /** Represents a message within a [thread](/docs/api-reference/threads). */ - data: MessageObject; - } - | { - event: "thread.message.incomplete"; - /** Represents a message within a [thread](/docs/api-reference/threads). */ - data: MessageObject; - }; /** Details of the tool call. */ export type RunStepDeltaStepDetailsToolCallsObject = { /** @@ -1697,6 +1569,93 @@ export type RunStepCompletionUsage = { prompt_tokens: number; total_tokens: number; } | null; +export type RunStepDetailsToolCallsFunctionObject = { + id: string; + /** + * The type of tool call. This is always going to be `function` for this type + * of tool call. + * @enum function + */ + type: "function"; + function: { + name: string; + arguments: string; + output: string | null; + }; +}; +/** A result instance of the file search. */ +export type RunStepDetailsToolCallsFileSearchResultObject = { + file_id: string; + file_name: string; + score: number; + content?: readonly { + /** + * The type of the content. + * @enum text + */ + type?: "text"; + text?: string; + }[]; +}; +/** The ranking options for the file search. */ +export type RunStepDetailsToolCallsFileSearchRankingOptionsObject = { + /** + * The ranker used for the file search. + * @enum default_2024_08_21 + */ + ranker: "default_2024_08_21"; + score_threshold: number; +}; +export type RunStepDetailsToolCallsFileSearchObject = { + id: string; + /** + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. + * @enum file_search + */ + type: "file_search"; + file_search: { + /** The ranking options for the file search. */ + ranking_options?: RunStepDetailsToolCallsFileSearchRankingOptionsObject; + results?: readonly RunStepDetailsToolCallsFileSearchResultObject[]; + }; +}; +export type RunStepDetailsToolCallsCodeOutputImageObject = { + /** + * Always `image`. + * @enum image + */ + type: "image"; + image: { + file_id: string; + }; +}; +/** Text output from the Code Interpreter tool call as part of a run step. */ +export type RunStepDetailsToolCallsCodeOutputLogsObject = { + /** + * Always `logs`. + * @enum logs + */ + type: "logs"; + logs: string; +}; +/** Details of the Code Interpreter tool call the run step was involved in. */ +export type RunStepDetailsToolCallsCodeObject = { + id: string; + /** + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. + * @enum code_interpreter + */ + type: "code_interpreter"; + code_interpreter: { + input: string; + outputs: readonly ( + | RunStepDetailsToolCallsCodeOutputLogsObject + | RunStepDetailsToolCallsCodeOutputImageObject + )[]; + }; +}; /** Details of the tool call. */ export type RunStepDetailsToolCallsObject = { /** @@ -1706,6 +1665,7 @@ export type RunStepDetailsToolCallsObject = { type: "tool_calls"; tool_calls: readonly ( | RunStepDetailsToolCallsCodeObject + | RunStepDetailsToolCallsFileSearchObject | RunStepDetailsToolCallsFunctionObject )[]; }; @@ -1924,6 +1884,73 @@ export type RunCompletionUsage = { prompt_tokens: number; total_tokens: number; } | null; +/** + * The parameters the functions accepts, described as a JSON Schema object. + * See the [guide](/docs/guides/function-calling) for examples, and the [JSON + * Schema reference](https://json-schema.org/understanding-json-schema/) for + * documentation about the format. + * + * Omitting `parameters` defines a function with an empty parameter list. + */ +export type FunctionParameters = Record; +export type FunctionObject = { + description?: string; + name: string; + /** + * The parameters the functions accepts, described as a JSON Schema object. + * See the [guide](/docs/guides/function-calling) for examples, and the [JSON + * Schema reference](https://json-schema.org/understanding-json-schema/) for + * documentation about the format. + * + * Omitting `parameters` defines a function with an empty parameter list. + */ + parameters?: FunctionParameters; + strict?: boolean | null; +}; +export type AssistantToolsFunction = { + /** + * The type of tool being defined: `function` + * @enum function + */ + type: "function"; + function: FunctionObject; +}; +/** + * The ranking options for the file search. If not specified, the file search + * tool will use the `auto` ranker and a score_threshold of 0. + * + * See the [file search tool + * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ +export type FileSearchRankingOptions = { + /** + * The ranker to use for the file search. If not specified will use the `auto` + * ranker. + * @enum auto,default_2024_08_21 + */ + ranker?: "auto" | "default_2024_08_21"; + score_threshold: number; +}; +export type AssistantToolsFileSearch = { + /** + * The type of tool being defined: `file_search` + * @enum file_search + */ + type: "file_search"; + file_search?: { + max_num_results?: number; + /** + * The ranking options for the file search. If not specified, the file search + * tool will use the `auto` ranker and a score_threshold of 0. + * + * See the [file search tool + * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + ranking_options?: FileSearchRankingOptions; + }; +}; /** Tool call objects */ export type RunToolCallObject = { id: string; @@ -2003,7 +2030,11 @@ export type RunObject = { * for this run. * @default */ - tools: readonly AssistantToolsCode[]; + tools: readonly ( + | AssistantToolsCode + | AssistantToolsFileSearch + | AssistantToolsFunction + )[]; metadata: Record | null; /** * Usage statistics related to the run. This value will be `null` if the run @@ -2349,43 +2380,6 @@ export type CreateVectorStoreRequest = { | StaticChunkingStrategyRequestParam; metadata?: Record | null; }; -/** A result instance of the file search. */ -export type RunStepDetailsToolCallsFileSearchResultObject = { - file_id: string; - file_name: string; - score: number; - content?: readonly { - /** - * The type of the content. - * @enum text - */ - type?: "text"; - text?: string; - }[]; -}; -/** The ranking options for the file search. */ -export type RunStepDetailsToolCallsFileSearchRankingOptionsObject = { - /** - * The ranker used for the file search. - * @enum default_2024_08_21 - */ - ranker: "default_2024_08_21"; - score_threshold: number; -}; -export type RunStepDetailsToolCallsFileSearchObject = { - id: string; - /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. - * @enum file_search - */ - type: "file_search"; - file_search: { - /** The ranking options for the file search. */ - ranking_options?: RunStepDetailsToolCallsFileSearchRankingOptionsObject; - results?: readonly RunStepDetailsToolCallsFileSearchResultObject[]; - }; -}; export type ListRunStepsResponse = { object: string; data: readonly RunStepObject[]; @@ -2400,6 +2394,15 @@ export type ListMessagesResponse = { last_id: string; has_more: boolean; }; +/** The text content that is part of a message. */ +export type MessageRequestContentTextObject = { + /** + * Always `text`. + * @enum text + */ + type: "text"; + text: string; +}; export type ListThreadsResponse = { object: string; data: readonly ThreadObject[]; @@ -2489,7 +2492,13 @@ export type CreateThreadAndRunRequest = { string > | null; instructions?: string | null; - tools?: readonly AssistantToolsCode[] | null; + tools?: + | readonly ( + | AssistantToolsCode + | AssistantToolsFileSearch + | AssistantToolsFunction + )[] + | null; tool_resources?: { code_interpreter?: { /** @@ -2620,7 +2629,13 @@ export type CreateRunRequest = { instructions?: string | null; additional_instructions?: string | null; additional_messages?: readonly CreateMessageRequest[] | null; - tools?: readonly AssistantToolsCode[] | null; + tools?: + | readonly ( + | AssistantToolsCode + | AssistantToolsFileSearch + | AssistantToolsFunction + )[] + | null; metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 @@ -2692,73 +2707,6 @@ export type CreateRunRequest = { */ response_format?: AssistantsApiResponseFormatOption; }; -/** - * The parameters the functions accepts, described as a JSON Schema object. - * See the [guide](/docs/guides/function-calling) for examples, and the [JSON - * Schema reference](https://json-schema.org/understanding-json-schema/) for - * documentation about the format. - * - * Omitting `parameters` defines a function with an empty parameter list. - */ -export type FunctionParameters = Record; -export type FunctionObject = { - description?: string; - name: string; - /** - * The parameters the functions accepts, described as a JSON Schema object. - * See the [guide](/docs/guides/function-calling) for examples, and the [JSON - * Schema reference](https://json-schema.org/understanding-json-schema/) for - * documentation about the format. - * - * Omitting `parameters` defines a function with an empty parameter list. - */ - parameters?: FunctionParameters; - strict?: boolean | null; -}; -export type AssistantToolsFunction = { - /** - * The type of tool being defined: `function` - * @enum function - */ - type: "function"; - function: FunctionObject; -}; -/** - * The ranking options for the file search. If not specified, the file search - * tool will use the `auto` ranker and a score_threshold of 0. - * - * See the [file search tool - * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ -export type FileSearchRankingOptions = { - /** - * The ranker to use for the file search. If not specified will use the `auto` - * ranker. - * @enum auto,default_2024_08_21 - */ - ranker?: "auto" | "default_2024_08_21"; - score_threshold: number; -}; -export type AssistantToolsFileSearch = { - /** - * The type of tool being defined: `file_search` - * @enum file_search - */ - type: "file_search"; - file_search?: { - max_num_results?: number; - /** - * The ranking options for the file search. If not specified, the file search - * tool will use the `auto` ranker and a score_threshold of 0. - * - * See the [file search tool - * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - ranking_options?: FileSearchRankingOptions; - }; -}; /** Represents an `assistant` that can call the model and use tools. */ export type AssistantObject = { id: string; @@ -3047,9 +2995,140 @@ export type ChatCompletionTool = { type: "function"; function: FunctionObject; }; +export type ChatCompletionRequestFunctionMessage = { + /** + * The role of the messages author, in this case `function`. + * @enum function + */ + role: "function"; + content: string | null; + name: string; +}; +export type ChatCompletionRequestMessageContentPartText = { + /** + * The type of the content part. + * @enum text + */ + type: "text"; + text: string; +}; +export type ChatCompletionRequestToolMessageContentPart = + ChatCompletionRequestMessageContentPartText; +export type ChatCompletionRequestToolMessage = { + /** + * The role of the messages author, in this case `tool`. + * @enum tool + */ + role: "tool"; + content: string | readonly ChatCompletionRequestToolMessageContentPart[]; + tool_call_id: string; +}; +export type ChatCompletionMessageToolCall = { + id: string; + /** + * The type of the tool. Currently, only `function` is supported. + * @enum function + */ + type: "function"; + function: { + name: string; + arguments: string; + }; +}; +/** The tool calls generated by the model, such as function calls. */ +export type ChatCompletionMessageToolCalls = ChatCompletionMessageToolCall[]; +export type ChatCompletionRequestMessageContentPartRefusal = { + /** + * The type of the content part. + * @enum refusal + */ + type: "refusal"; + refusal: string; +}; +export type ChatCompletionRequestAssistantMessageContentPart = + | ChatCompletionRequestMessageContentPartText + | ChatCompletionRequestMessageContentPartRefusal; +export type ChatCompletionRequestAssistantMessage = { + content?: + | string + | readonly ChatCompletionRequestAssistantMessageContentPart[] + | null; + refusal?: string | null; + /** + * The role of the messages author, in this case `assistant`. + * @enum assistant + */ + role: "assistant"; + name?: string; + /** The tool calls generated by the model, such as function calls. */ + tool_calls?: ChatCompletionMessageToolCalls; + /** + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. + * @deprecated + */ + function_call?: { + arguments: string; + name: string; + } | null; +}; +export type FineTuneChatCompletionRequestAssistantMessage = + ChatCompletionRequestAssistantMessage & { + /** + * Controls whether the assistant message is trained against (0 or 1) + * @enum 0,1 + */ + weight?: number; + }; +export type ChatCompletionRequestMessageContentPartImage = { + /** + * The type of the content part. + * @enum image_url + */ + type: "image_url"; + image_url: { + url: string; + /** + * Specifies the detail level of the image. Learn more in the [Vision + * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + * @default auto + * @enum auto,low,high + */ + detail?: "auto" | "low" | "high"; + }; +}; +export type ChatCompletionRequestUserMessageContentPart = + | ChatCompletionRequestMessageContentPartText + | ChatCompletionRequestMessageContentPartImage; +export type ChatCompletionRequestUserMessage = { + content: string | readonly ChatCompletionRequestUserMessageContentPart[]; + /** + * The role of the messages author, in this case `user`. + * @enum user + */ + role: "user"; + name?: string; +}; +export type ChatCompletionRequestSystemMessageContentPart = + ChatCompletionRequestMessageContentPartText; +export type ChatCompletionRequestSystemMessage = { + content: string | readonly ChatCompletionRequestSystemMessageContentPart[]; + /** + * The role of the messages author, in this case `system`. + * @enum system + */ + role: "system"; + name?: string; +}; /** The per-line training example of a fine-tuning input file for chat models */ export type FinetuneChatRequestInput = { - messages?: readonly never[]; + messages?: readonly ( + | ChatCompletionRequestSystemMessage + | ChatCompletionRequestUserMessage + | FineTuneChatCompletionRequestAssistantMessage + | ChatCompletionRequestToolMessage + | ChatCompletionRequestFunctionMessage + )[]; tools?: readonly ChatCompletionTool[]; /** * Whether to enable [parallel function @@ -3063,6 +3142,23 @@ export type FinetuneChatRequestInput = { */ functions?: readonly ChatCompletionFunctions[]; }; +export type FineTuningIntegration = { + /** + * The type of the integration being enabled for the fine-tuning job + * @enum wandb + */ + type: "wandb"; + wandb: { + /** + * The name of the project that the new run will be created under. + * @example my-wandb-project + */ + project: string; + name?: string | null; + entity?: string | null; + tags?: readonly string[]; + }; +}; /** The `File` object represents a document that has been uploaded to OpenAI. */ export type OpenAiFile = { id: string; @@ -3286,9 +3382,106 @@ export type Image = { url?: string; revised_prompt?: string; }; -export type ImagesResponse = { +export type ImagesResponse = { + created: number; + data: readonly Image[]; +}; +export type ChatCompletionTokenLogprob = { + token: string; + logprob: number; + bytes: readonly number[] | null; + top_logprobs: readonly { + token: string; + logprob: number; + bytes: readonly number[] | null; + }[]; +}; +export type ChatCompletionMessageToolCallChunk = { + index: number; + id?: string; + /** + * The type of the tool. Currently, only `function` is supported. + * @enum function + */ + type?: "function"; + function?: { + name?: string; + arguments?: string; + }; +}; +/** A chat completion delta generated by streamed model responses. */ +export type ChatCompletionStreamResponseDelta = { + content?: string | null; + /** + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. + * @deprecated + */ + function_call?: { + arguments?: string; + name?: string; + }; + tool_calls?: readonly ChatCompletionMessageToolCallChunk[]; + /** + * The role of the author of this message. + * @enum system,user,assistant,tool + */ + role?: "system" | "user" | "assistant" | "tool"; + refusal?: string | null; +}; +/** + * Represents a streamed chunk of a chat completion response returned by + * model, based on the provided input. + */ +export type CreateChatCompletionStreamResponse = { + id: string; + choices: readonly { + /** A chat completion delta generated by streamed model responses. */ + delta: ChatCompletionStreamResponseDelta; + logprobs?: { + content: readonly ChatCompletionTokenLogprob[] | null; + refusal: readonly ChatCompletionTokenLogprob[] | null; + } | null; + /** + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if + * the model called a function. + * @enum stop,length,tool_calls,content_filter,function_call + */ + finish_reason: + | "stop" + | "length" + | "tool_calls" + | "content_filter" + | "function_call" + | null; + index: number; + }[]; created: number; - data: readonly Image[]; + model: string; + /** + * The service tier used for processing the request. This field is only + * included if the `service_tier` parameter is specified in the request. + * @enum scale,default + * @example scale + */ + service_tier?: "scale" | "default" | null; + system_fingerprint?: string; + /** + * The object type, which is always `chat.completion.chunk`. + * @enum chat.completion.chunk + */ + object: "chat.completion.chunk"; + usage?: { + completion_tokens: number; + prompt_tokens: number; + total_tokens: number; + }; }; /** * The `fine_tuning.job` object represents a fine-tuning job that has been @@ -3357,6 +3550,27 @@ export type CompletionUsage = { reasoning_tokens?: number; }; }; +/** A chat completion message generated by the model. */ +export type ChatCompletionResponseMessage = { + content: string | null; + refusal: string | null; + /** The tool calls generated by the model, such as function calls. */ + tool_calls?: ChatCompletionMessageToolCalls; + /** + * The role of the author of this message. + * @enum assistant + */ + role: "assistant"; + /** + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. + * @deprecated + */ + function_call?: { + arguments: string; + name: string; + }; +}; /** * Represents a chat completion response returned by model, based on the * provided input. @@ -3374,8 +3588,8 @@ export type CreateChatCompletionFunctionResponse = { */ finish_reason: "stop" | "length" | "function_call" | "content_filter"; index: number; - /** WARN: $ref used before available - schema={"$ref":"#/components/schemas/ChatCompletionResponseMessage"} */ - message: never; + /** A chat completion message generated by the model. */ + message: ChatCompletionResponseMessage; }[]; created: number; model: string; @@ -3413,8 +3627,8 @@ export type CreateChatCompletionResponse = { | "content_filter" | "function_call"; index: number; - /** WARN: $ref used before available - schema={"$ref":"#/components/schemas/ChatCompletionResponseMessage"} */ - message: never; + /** A chat completion message generated by the model. */ + message: ChatCompletionResponseMessage; logprobs: { content: readonly ChatCompletionTokenLogprob[] | null; refusal: readonly ChatCompletionTokenLogprob[] | null; @@ -3481,123 +3695,6 @@ export type ChatCompletionToolChoiceOption = export type ChatCompletionStreamOptions = { include_usage?: boolean; } | null; -export type ChatCompletionRequestFunctionMessage = { - /** - * The role of the messages author, in this case `function`. - * @enum function - */ - role: "function"; - content: string | null; - name: string; -}; -export type ChatCompletionRequestMessageContentPartText = { - /** - * The type of the content part. - * @enum text - */ - type: "text"; - text: string; -}; -export type ChatCompletionRequestToolMessageContentPart = - ChatCompletionRequestMessageContentPartText; -export type ChatCompletionRequestToolMessage = { - /** - * The role of the messages author, in this case `tool`. - * @enum tool - */ - role: "tool"; - content: string | readonly ChatCompletionRequestToolMessageContentPart[]; - tool_call_id: string; -}; -export type ChatCompletionMessageToolCall = { - id: string; - /** - * The type of the tool. Currently, only `function` is supported. - * @enum function - */ - type: "function"; - function: { - name: string; - arguments: string; - }; -}; -/** The tool calls generated by the model, such as function calls. */ -export type ChatCompletionMessageToolCalls = ChatCompletionMessageToolCall[]; -export type ChatCompletionRequestMessageContentPartRefusal = { - /** - * The type of the content part. - * @enum refusal - */ - type: "refusal"; - refusal: string; -}; -export type ChatCompletionRequestAssistantMessageContentPart = - | ChatCompletionRequestMessageContentPartText - | ChatCompletionRequestMessageContentPartRefusal; -export type ChatCompletionRequestAssistantMessage = { - content?: - | string - | readonly ChatCompletionRequestAssistantMessageContentPart[] - | null; - refusal?: string | null; - /** - * The role of the messages author, in this case `assistant`. - * @enum assistant - */ - role: "assistant"; - name?: string; - /** The tool calls generated by the model, such as function calls. */ - tool_calls?: ChatCompletionMessageToolCalls; - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - * @deprecated - */ - function_call?: { - arguments: string; - name: string; - } | null; -}; -export type ChatCompletionRequestMessageContentPartImage = { - /** - * The type of the content part. - * @enum image_url - */ - type: "image_url"; - image_url: { - url: string; - /** - * Specifies the detail level of the image. Learn more in the [Vision - * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). - * @default auto - * @enum auto,low,high - */ - detail?: "auto" | "low" | "high"; - }; -}; -export type ChatCompletionRequestUserMessageContentPart = - | ChatCompletionRequestMessageContentPartText - | ChatCompletionRequestMessageContentPartImage; -export type ChatCompletionRequestUserMessage = { - content: string | readonly ChatCompletionRequestUserMessageContentPart[]; - /** - * The role of the messages author, in this case `user`. - * @enum user - */ - role: "user"; - name?: string; -}; -export type ChatCompletionRequestSystemMessageContentPart = - ChatCompletionRequestMessageContentPartText; -export type ChatCompletionRequestSystemMessage = { - content: string | readonly ChatCompletionRequestSystemMessageContentPart[]; - /** - * The role of the messages author, in this case `system`. - * @enum system - */ - role: "system"; - name?: string; -}; export type ChatCompletionRequestMessage = | ChatCompletionRequestSystemMessage | ChatCompletionRequestUserMessage @@ -3772,68 +3869,6 @@ export type CreateChatCompletionRequest = { */ functions?: readonly ChatCompletionFunctions[]; }; -export type ChatCompletionMessageToolCallChunk = { - index: number; - id?: string; - /** - * The type of the tool. Currently, only `function` is supported. - * @enum function - */ - type?: "function"; - function?: { - name?: string; - arguments?: string; - }; -}; -/** A chat completion delta generated by streamed model responses. */ -export type ChatCompletionStreamResponseDelta = { - content?: string | null; - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - * @deprecated - */ - function_call?: { - arguments?: string; - name?: string; - }; - tool_calls?: readonly ChatCompletionMessageToolCallChunk[]; - /** - * The role of the author of this message. - * @enum system,user,assistant,tool - */ - role?: "system" | "user" | "assistant" | "tool"; - refusal?: string | null; -}; -/** A chat completion message generated by the model. */ -export type ChatCompletionResponseMessage = { - content: string | null; - refusal: string | null; - /** The tool calls generated by the model, such as function calls. */ - tool_calls?: ChatCompletionMessageToolCalls; - /** - * The role of the author of this message. - * @enum assistant - */ - role: "assistant"; - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - * @deprecated - */ - function_call?: { - arguments: string; - name: string; - }; -}; -export type FineTuneChatCompletionRequestAssistantMessage = - ChatCompletionRequestAssistantMessage & { - /** - * Controls whether the assistant message is trained against (0 or 1) - * @enum 0,1 - */ - weight?: number; - }; /** * Represents a completion response from the API. Note: both the streamed and * non-streamed response objects share the same shape (unlike the chat diff --git a/__tests__/fixtures/openai/valibot.ts b/__tests__/fixtures/openai/valibot.ts index a68fffc..642c514 100644 --- a/__tests__/fixtures/openai/valibot.ts +++ b/__tests__/fixtures/openai/valibot.ts @@ -27,434 +27,130 @@ export const inputChatCompletionRoleSchema = v.picklist([ "function", ]); export const chatCompletionRoleSchema = inputChatCompletionRoleSchema; -export const inputChatCompletionTokenLogprobSchema = v.looseObject({ +/** + * Represents a streamed chunk of a chat completion response returned by + * model, based on the provided input. + */ +export const inputCreateChatCompletionImageResponseSchema = v.record( + v.string(), + v.unknown(), +); +export const createChatCompletionImageResponseSchema = + inputCreateChatCompletionImageResponseSchema; +export const inputCreateImageRequestSchema = v.looseObject({ /** - * The token. + * A text description of the desired image(s). The maximum length is 1000 + * characters for `dall-e-2` and 4000 characters for `dall-e-3`. */ - token: v.string(), + prompt: v.string(), /** - * The log probability of this token, if it is within the top 20 most likely - * tokens. Otherwise, the value `-9999.0` is used to signify that the token is - * very unlikely. + * The model to use for image generation. */ - logprob: v.number(), + model: v.optional( + v.nullable(v.union([v.string(), v.picklist(["dall-e-2", "dall-e-3"])])), + ), /** - * A list of integers representing the UTF-8 bytes representation of the - * token. Useful in instances where characters are represented by multiple - * tokens and their byte representations must be combined to generate the - * correct text representation. Can be `null` if there is no bytes - * representation for the token. + * The number of images to generate. Must be between 1 and 10. For `dall-e-3`, + * only `n=1` is supported. */ - bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + n: v.optional( + v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(10))), + ), /** - * List of the most likely tokens and their log probability, at this token - * position. In rare cases, there may be fewer than the number of requested - * `top_logprobs` returned. + * The quality of the image that will be generated. `hd` creates images with + * finer details and greater consistency across the image. This param is only + * supported for `dall-e-3`. */ - top_logprobs: v.array( - v.looseObject({ - /** - * The token. - */ - token: v.string(), - /** - * The log probability of this token, if it is within the top 20 most likely - * tokens. Otherwise, the value `-9999.0` is used to signify that the token is - * very unlikely. - */ - logprob: v.number(), - /** - * A list of integers representing the UTF-8 bytes representation of the - * token. Useful in instances where characters are represented by multiple - * tokens and their byte representations must be combined to generate the - * correct text representation. Can be `null` if there is no bytes - * representation for the token. - */ - bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), - }), - ), -}); -export const chatCompletionTokenLogprobSchema = v.looseObject({ + quality: v.optional(v.picklist(["standard", "hd"])), /** - * The token. + * The format in which the generated images are returned. Must be one of `url` + * or `b64_json`. URLs are only valid for 60 minutes after the image has been + * generated. */ - token: v.pipe(v.string(), v.trim()), + response_format: v.optional(v.nullable(v.picklist(["url", "b64_json"]))), /** - * The log probability of this token, if it is within the top 20 most likely - * tokens. Otherwise, the value `-9999.0` is used to signify that the token is - * very unlikely. + * The size of the generated images. Must be one of `256x256`, `512x512`, or + * `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or + * `1024x1792` for `dall-e-3` models. */ - logprob: v.number(), + size: v.optional( + v.nullable( + v.picklist(["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]), + ), + ), /** - * A list of integers representing the UTF-8 bytes representation of the - * token. Useful in instances where characters are represented by multiple - * tokens and their byte representations must be combined to generate the - * correct text representation. Can be `null` if there is no bytes - * representation for the token. + * The style of the generated images. Must be one of `vivid` or `natural`. + * Vivid causes the model to lean towards generating hyper-real and dramatic + * images. Natural causes the model to produce more natural, less hyper-real + * looking images. This param is only supported for `dall-e-3`. */ - bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + style: v.optional(v.nullable(v.picklist(["vivid", "natural"]))), /** - * List of the most likely tokens and their log probability, at this token - * position. In rare cases, there may be fewer than the number of requested - * `top_logprobs` returned. + * A unique identifier representing your end-user, which can help OpenAI to + * monitor and detect abuse. [Learn + * more](/docs/guides/safety-best-practices/end-user-ids). */ - top_logprobs: v.array( - v.looseObject({ - /** - * The token. - */ - token: v.pipe(v.string(), v.trim()), - /** - * The log probability of this token, if it is within the top 20 most likely - * tokens. Otherwise, the value `-9999.0` is used to signify that the token is - * very unlikely. - */ - logprob: v.number(), - /** - * A list of integers representing the UTF-8 bytes representation of the - * token. Useful in instances where characters are represented by multiple - * tokens and their byte representations must be combined to generate the - * correct text representation. Can be `null` if there is no bytes - * representation for the token. - */ - bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), - }), - ), + user: v.optional(v.string()), }); -/** - * Represents a streamed chunk of a chat completion response returned by - * model, based on the provided input. - */ -export const inputCreateChatCompletionStreamResponseSchema = v.looseObject({ +export const createImageRequestSchema = v.looseObject({ /** - * A unique identifier for the chat completion. Each chunk has the same ID. + * A text description of the desired image(s). The maximum length is 1000 + * characters for `dall-e-2` and 4000 characters for `dall-e-3`. */ - id: v.string(), + prompt: v.pipe(v.string(), v.trim()), /** - * A list of chat completion choices. Can contain more than one elements if - * `n` is greater than 1. Can also be empty for the - * last chunk if you set `stream_options: {"include_usage": true}`. + * The model to use for image generation. */ - choices: v.array( - v.looseObject({ - delta: v.unknown(), - /** - * Log probability information for the choice. - */ - logprobs: v.optional( - v.nullable( - v.looseObject({ - /** - * A list of message content tokens with log probability information. - */ - content: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), - /** - * A list of message refusal tokens with log probability information. - */ - refusal: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), - }), - ), - ), - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was - * reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if - * the model called a function. - */ - finish_reason: v.nullable( - v.picklist([ - "stop", - "length", - "tool_calls", - "content_filter", - "function_call", - ]), - ), - /** - * The index of the choice in the list of choices. - */ - index: v.pipe(v.number(), v.integer()), - }), + model: v.exactOptional( + v.nullable( + v.union([ + v.pipe(v.string(), v.trim()), + v.picklist(["dall-e-2", "dall-e-3"]), + ]), + ), ), /** - * The Unix timestamp (in seconds) of when the chat completion was created. - * Each chunk has the same timestamp. + * The number of images to generate. Must be between 1 and 10. For `dall-e-3`, + * only `n=1` is supported. */ - created: v.pipe(v.number(), v.integer()), + n: v.exactOptional( + v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(10))), + ), /** - * The model to generate the completion. + * The quality of the image that will be generated. `hd` creates images with + * finer details and greater consistency across the image. This param is only + * supported for `dall-e-3`. */ - model: v.string(), + quality: v.exactOptional(v.picklist(["standard", "hd"])), /** - * The service tier used for processing the request. This field is only - * included if the `service_tier` parameter is specified in the request. + * The format in which the generated images are returned. Must be one of `url` + * or `b64_json`. URLs are only valid for 60 minutes after the image has been + * generated. */ - service_tier: v.optional(v.nullable(v.picklist(["scale", "default"]))), + response_format: v.exactOptional(v.nullable(v.picklist(["url", "b64_json"]))), /** - * This fingerprint represents the backend configuration that the model runs - * with. - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. + * The size of the generated images. Must be one of `256x256`, `512x512`, or + * `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or + * `1024x1792` for `dall-e-3` models. */ - system_fingerprint: v.optional(v.string()), + size: v.exactOptional( + v.nullable( + v.picklist(["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]), + ), + ), /** - * The object type, which is always `chat.completion.chunk`. + * The style of the generated images. Must be one of `vivid` or `natural`. + * Vivid causes the model to lean towards generating hyper-real and dramatic + * images. Natural causes the model to produce more natural, less hyper-real + * looking images. This param is only supported for `dall-e-3`. */ - object: v.picklist(["chat.completion.chunk"]), + style: v.exactOptional(v.nullable(v.picklist(["vivid", "natural"]))), /** - * An optional field that will only be present when you set `stream_options: - * {"include_usage": true}` in your request. - * When present, it contains a null value except for the last chunk which - * contains the token usage statistics for the entire request. + * A unique identifier representing your end-user, which can help OpenAI to + * monitor and detect abuse. [Learn + * more](/docs/guides/safety-best-practices/end-user-ids). */ - usage: v.optional( - v.looseObject({ - /** - * Number of tokens in the generated completion. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of tokens in the prompt. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used in the request (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - }), - ), -}); -export const createChatCompletionStreamResponseSchema = v.looseObject({ - /** - * A unique identifier for the chat completion. Each chunk has the same ID. - */ - id: v.pipe(v.string(), v.trim()), - /** - * A list of chat completion choices. Can contain more than one elements if - * `n` is greater than 1. Can also be empty for the - * last chunk if you set `stream_options: {"include_usage": true}`. - */ - choices: v.array( - v.looseObject({ - delta: v.unknown(), - /** - * Log probability information for the choice. - */ - logprobs: v.exactOptional( - v.nullable( - v.looseObject({ - /** - * A list of message content tokens with log probability information. - */ - content: v.nullable(v.array(chatCompletionTokenLogprobSchema)), - /** - * A list of message refusal tokens with log probability information. - */ - refusal: v.nullable(v.array(chatCompletionTokenLogprobSchema)), - }), - ), - ), - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was - * reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if - * the model called a function. - */ - finish_reason: v.nullable( - v.picklist([ - "stop", - "length", - "tool_calls", - "content_filter", - "function_call", - ]), - ), - /** - * The index of the choice in the list of choices. - */ - index: v.pipe(v.number(), v.integer()), - }), - ), - /** - * The Unix timestamp (in seconds) of when the chat completion was created. - * Each chunk has the same timestamp. - */ - created: v.pipe(v.number(), v.integer()), - /** - * The model to generate the completion. - */ - model: v.pipe(v.string(), v.trim()), - /** - * The service tier used for processing the request. This field is only - * included if the `service_tier` parameter is specified in the request. - */ - service_tier: v.exactOptional(v.nullable(v.picklist(["scale", "default"]))), - /** - * This fingerprint represents the backend configuration that the model runs - * with. - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. - */ - system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The object type, which is always `chat.completion.chunk`. - */ - object: v.picklist(["chat.completion.chunk"]), - /** - * An optional field that will only be present when you set `stream_options: - * {"include_usage": true}` in your request. - * When present, it contains a null value except for the last chunk which - * contains the token usage statistics for the entire request. - */ - usage: v.exactOptional( - v.looseObject({ - /** - * Number of tokens in the generated completion. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of tokens in the prompt. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used in the request (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - }), - ), -}); -/** - * Represents a streamed chunk of a chat completion response returned by - * model, based on the provided input. - */ -export const inputCreateChatCompletionImageResponseSchema = v.record( - v.string(), - v.unknown(), -); -export const createChatCompletionImageResponseSchema = - inputCreateChatCompletionImageResponseSchema; -export const inputCreateImageRequestSchema = v.looseObject({ - /** - * A text description of the desired image(s). The maximum length is 1000 - * characters for `dall-e-2` and 4000 characters for `dall-e-3`. - */ - prompt: v.string(), - /** - * The model to use for image generation. - */ - model: v.optional( - v.nullable(v.union([v.string(), v.picklist(["dall-e-2", "dall-e-3"])])), - ), - /** - * The number of images to generate. Must be between 1 and 10. For `dall-e-3`, - * only `n=1` is supported. - */ - n: v.optional( - v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(10))), - ), - /** - * The quality of the image that will be generated. `hd` creates images with - * finer details and greater consistency across the image. This param is only - * supported for `dall-e-3`. - */ - quality: v.optional(v.picklist(["standard", "hd"])), - /** - * The format in which the generated images are returned. Must be one of `url` - * or `b64_json`. URLs are only valid for 60 minutes after the image has been - * generated. - */ - response_format: v.optional(v.nullable(v.picklist(["url", "b64_json"]))), - /** - * The size of the generated images. Must be one of `256x256`, `512x512`, or - * `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or - * `1024x1792` for `dall-e-3` models. - */ - size: v.optional( - v.nullable( - v.picklist(["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]), - ), - ), - /** - * The style of the generated images. Must be one of `vivid` or `natural`. - * Vivid causes the model to lean towards generating hyper-real and dramatic - * images. Natural causes the model to produce more natural, less hyper-real - * looking images. This param is only supported for `dall-e-3`. - */ - style: v.optional(v.nullable(v.picklist(["vivid", "natural"]))), - /** - * A unique identifier representing your end-user, which can help OpenAI to - * monitor and detect abuse. [Learn - * more](/docs/guides/safety-best-practices/end-user-ids). - */ - user: v.optional(v.string()), -}); -export const createImageRequestSchema = v.looseObject({ - /** - * A text description of the desired image(s). The maximum length is 1000 - * characters for `dall-e-2` and 4000 characters for `dall-e-3`. - */ - prompt: v.pipe(v.string(), v.trim()), - /** - * The model to use for image generation. - */ - model: v.exactOptional( - v.nullable( - v.union([ - v.pipe(v.string(), v.trim()), - v.picklist(["dall-e-2", "dall-e-3"]), - ]), - ), - ), - /** - * The number of images to generate. Must be between 1 and 10. For `dall-e-3`, - * only `n=1` is supported. - */ - n: v.exactOptional( - v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(10))), - ), - /** - * The quality of the image that will be generated. `hd` creates images with - * finer details and greater consistency across the image. This param is only - * supported for `dall-e-3`. - */ - quality: v.exactOptional(v.picklist(["standard", "hd"])), - /** - * The format in which the generated images are returned. Must be one of `url` - * or `b64_json`. URLs are only valid for 60 minutes after the image has been - * generated. - */ - response_format: v.exactOptional(v.nullable(v.picklist(["url", "b64_json"]))), - /** - * The size of the generated images. Must be one of `256x256`, `512x512`, or - * `1024x1024` for `dall-e-2`. Must be one of `1024x1024`, `1792x1024`, or - * `1024x1792` for `dall-e-3` models. - */ - size: v.exactOptional( - v.nullable( - v.picklist(["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]), - ), - ), - /** - * The style of the generated images. Must be one of `vivid` or `natural`. - * Vivid causes the model to lean towards generating hyper-real and dramatic - * images. Natural causes the model to produce more natural, less hyper-real - * looking images. This param is only supported for `dall-e-3`. - */ - style: v.exactOptional(v.nullable(v.picklist(["vivid", "natural"]))), - /** - * A unique identifier representing your end-user, which can help OpenAI to - * monitor and detect abuse. [Learn - * more](/docs/guides/safety-best-practices/end-user-ids). - */ - user: v.exactOptional(v.pipe(v.string(), v.trim())), + user: v.exactOptional(v.pipe(v.string(), v.trim())), }); export const inputCreateImageEditRequestSchema = v.looseObject({ /** @@ -1815,95 +1511,17 @@ export const uploadPartSchema = v.looseObject({ */ object: v.picklist(["upload.part"]), }); -export const inputFineTuningIntegrationSchema = v.looseObject({ +/** + * The per-line training example of a fine-tuning input file for completions + * models + */ +export const inputFinetuneCompletionRequestInputSchema = v.looseObject({ /** - * The type of the integration being enabled for the fine-tuning job + * The input prompt for this training example. */ - type: v.picklist(["wandb"]), + prompt: v.optional(v.string()), /** - * The settings for your integration with Weights and Biases. This payload - * specifies the project that - * metrics will be sent to. Optionally, you can set an explicit display name - * for your run, add tags - * to your run, and set a default entity (team, username, etc) to be - * associated with your run. - */ - wandb: v.looseObject({ - /** - * The name of the project that the new run will be created under. - */ - project: v.string(), - /** - * A display name to set for the run. If not set, we will use the Job ID as - * the name. - */ - name: v.optional(v.nullable(v.string())), - /** - * The entity to use for the run. This allows you to set the team or username - * of the WandB user that you would - * like associated with the run. If not set, the default entity for the - * registered WandB API key is used. - */ - entity: v.optional(v.nullable(v.string())), - /** - * A list of tags to be attached to the newly created run. These tags are - * passed through directly to WandB. Some - * default tags are generated by OpenAI: "openai/finetune", - * "openai/{base-model}", "openai/{ftjob-abcdef}". - */ - tags: v.optional(v.array(v.string())), - }), -}); -export const fineTuningIntegrationSchema = v.looseObject({ - /** - * The type of the integration being enabled for the fine-tuning job - */ - type: v.picklist(["wandb"]), - /** - * The settings for your integration with Weights and Biases. This payload - * specifies the project that - * metrics will be sent to. Optionally, you can set an explicit display name - * for your run, add tags - * to your run, and set a default entity (team, username, etc) to be - * associated with your run. - */ - wandb: v.looseObject({ - /** - * The name of the project that the new run will be created under. - */ - project: v.pipe(v.string(), v.trim()), - /** - * A display name to set for the run. If not set, we will use the Job ID as - * the name. - */ - name: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - /** - * The entity to use for the run. This allows you to set the team or username - * of the WandB user that you would - * like associated with the run. If not set, the default entity for the - * registered WandB API key is used. - */ - entity: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - /** - * A list of tags to be attached to the newly created run. These tags are - * passed through directly to WandB. Some - * default tags are generated by OpenAI: "openai/finetune", - * "openai/{base-model}", "openai/{ftjob-abcdef}". - */ - tags: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), - }), -}); -/** - * The per-line training example of a fine-tuning input file for completions - * models - */ -export const inputFinetuneCompletionRequestInputSchema = v.looseObject({ - /** - * The input prompt for this training example. - */ - prompt: v.optional(v.string()), - /** - * The desired completion for this training example. + * The desired completion for this training example. */ completion: v.optional(v.string()), }); @@ -1927,21 +1545,6 @@ export const deleteAssistantResponseSchema = v.looseObject({ deleted: v.boolean(), object: v.picklist(["assistant.deleted"]), }); -export const inputAssistantToolsCodeSchema = v.looseObject({ - /** - * The type of tool being defined: `code_interpreter` - */ - type: v.picklist(["code_interpreter"]), -}); -export const assistantToolsCodeSchema = inputAssistantToolsCodeSchema; -export const inputAssistantToolsFileSearchTypeOnlySchema = v.looseObject({ - /** - * The type of tool being defined: `file_search` - */ - type: v.picklist(["file_search"]), -}); -export const assistantToolsFileSearchTypeOnlySchema = - inputAssistantToolsFileSearchTypeOnlySchema; export const inputModifyRunRequestSchema = v.strictObject({ /** * Set of 16 key-value pairs that can be attached to an object. This can be @@ -2134,1464 +1737,504 @@ export const deleteMessageResponseSchema = v.looseObject({ deleted: v.boolean(), object: v.picklist(["thread.message.deleted"]), }); +export const inputDeleteVectorStoreResponseSchema = v.looseObject({ + id: v.string(), + deleted: v.boolean(), + object: v.picklist(["vector_store.deleted"]), +}); +export const deleteVectorStoreResponseSchema = v.looseObject({ + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), + object: v.picklist(["vector_store.deleted"]), +}); +export const inputDeleteVectorStoreFileResponseSchema = v.looseObject({ + id: v.string(), + deleted: v.boolean(), + object: v.picklist(["vector_store.file.deleted"]), +}); +export const deleteVectorStoreFileResponseSchema = v.looseObject({ + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), + object: v.picklist(["vector_store.file.deleted"]), +}); /** - * References an image [File](/docs/api-reference/files) in the content of a - * message. - * @title Image file + * A batch of files attached to a vector store. + * @title Vector store file batch */ -export const inputMessageContentImageFileObjectSchema = v.looseObject({ +export const inputVectorStoreFileBatchObjectSchema = v.looseObject({ /** - * Always `image_file`. + * The identifier, which can be referenced in API endpoints. */ - type: v.picklist(["image_file"]), - image_file: v.looseObject({ + id: v.string(), + /** + * The object type, which is always `vector_store.file_batch`. + */ + object: v.picklist(["vector_store.files_batch"]), + /** + * The Unix timestamp (in seconds) for when the vector store files batch was + * created. + */ + created_at: v.pipe(v.number(), v.integer()), + /** + * The ID of the [vector store](/docs/api-reference/vector-stores/object) that + * the [File](/docs/api-reference/files) is attached to. + */ + vector_store_id: v.string(), + /** + * The status of the vector store files batch, which can be either + * `in_progress`, `completed`, `cancelled` or `failed`. + */ + status: v.picklist(["in_progress", "completed", "cancelled", "failed"]), + file_counts: v.looseObject({ /** - * The [File](/docs/api-reference/files) ID of the image in the message - * content. Set `purpose="vision"` when uploading the File if you need to - * later display the file content. + * The number of files that are currently being processed. */ - file_id: v.string(), + in_progress: v.pipe(v.number(), v.integer()), /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. + * The number of files that have been processed. */ - detail: v.optional(v.picklist(["auto", "low", "high"])), - }), -}); -export const messageContentImageFileObjectSchema = v.looseObject({ - /** - * Always `image_file`. - */ - type: v.picklist(["image_file"]), - image_file: v.looseObject({ + completed: v.pipe(v.number(), v.integer()), /** - * The [File](/docs/api-reference/files) ID of the image in the message - * content. Set `purpose="vision"` when uploading the File if you need to - * later display the file content. + * The number of files that have failed to process. */ - file_id: v.pipe(v.string(), v.trim()), + failed: v.pipe(v.number(), v.integer()), /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. + * The number of files that where cancelled. */ - detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + cancelled: v.pipe(v.number(), v.integer()), + /** + * The total number of files. + */ + total: v.pipe(v.number(), v.integer()), }), }); -/** - * References an image [File](/docs/api-reference/files) in the content of a - * message. - * @title Image file - */ -export const inputMessageDeltaContentImageFileObjectSchema = v.looseObject({ +export const vectorStoreFileBatchObjectSchema = v.looseObject({ /** - * The index of the content part in the message. + * The identifier, which can be referenced in API endpoints. */ - index: v.pipe(v.number(), v.integer()), + id: v.pipe(v.string(), v.trim()), /** - * Always `image_file`. + * The object type, which is always `vector_store.file_batch`. */ - type: v.picklist(["image_file"]), - image_file: v.optional( - v.looseObject({ - /** - * The [File](/docs/api-reference/files) ID of the image in the message - * content. Set `purpose="vision"` when uploading the File if you need to - * later display the file content. - */ - file_id: v.optional(v.string()), - /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. - */ - detail: v.optional(v.picklist(["auto", "low", "high"])), - }), - ), -}); -export const messageDeltaContentImageFileObjectSchema = v.looseObject({ + object: v.picklist(["vector_store.files_batch"]), /** - * The index of the content part in the message. + * The Unix timestamp (in seconds) for when the vector store files batch was + * created. */ - index: v.pipe(v.number(), v.integer()), + created_at: v.pipe(v.number(), v.integer()), /** - * Always `image_file`. + * The ID of the [vector store](/docs/api-reference/vector-stores/object) that + * the [File](/docs/api-reference/files) is attached to. */ - type: v.picklist(["image_file"]), - image_file: v.exactOptional( - v.looseObject({ - /** - * The [File](/docs/api-reference/files) ID of the image in the message - * content. Set `purpose="vision"` when uploading the File if you need to - * later display the file content. - */ - file_id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * Specifies the detail level of the image if specified by the user. `low` - * uses fewer tokens, you can opt in to high resolution using `high`. - */ - detail: v.exactOptional(v.picklist(["auto", "low", "high"])), - }), - ), -}); -/** - * References an image URL in the content of a message. - * @title Image URL - */ -export const inputMessageContentImageUrlObjectSchema = v.looseObject({ + vector_store_id: v.pipe(v.string(), v.trim()), /** - * The type of the content part. + * The status of the vector store files batch, which can be either + * `in_progress`, `completed`, `cancelled` or `failed`. */ - type: v.picklist(["image_url"]), - image_url: v.looseObject({ + status: v.picklist(["in_progress", "completed", "cancelled", "failed"]), + file_counts: v.looseObject({ /** - * The external URL of the image, must be a supported image types: jpeg, jpg, - * png, gif, webp. + * The number of files that are currently being processed. */ - url: v.string(), + in_progress: v.pipe(v.number(), v.integer()), /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. Default value is `auto` + * The number of files that have been processed. */ - detail: v.optional(v.picklist(["auto", "low", "high"])), - }), -}); -export const messageContentImageUrlObjectSchema = v.looseObject({ - /** - * The type of the content part. - */ - type: v.picklist(["image_url"]), - image_url: v.looseObject({ + completed: v.pipe(v.number(), v.integer()), /** - * The external URL of the image, must be a supported image types: jpeg, jpg, - * png, gif, webp. + * The number of files that have failed to process. */ - url: v.pipe(v.string(), v.trim()), + failed: v.pipe(v.number(), v.integer()), /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. Default value is `auto` + * The number of files that where cancelled. */ - detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + cancelled: v.pipe(v.number(), v.integer()), + /** + * The total number of files. + */ + total: v.pipe(v.number(), v.integer()), }), }); -/** - * References an image URL in the content of a message. - * @title Image URL - */ -export const inputMessageDeltaContentImageUrlObjectSchema = v.looseObject({ +/** The per-line object of the batch input file */ +export const inputBatchRequestInputSchema = v.looseObject({ /** - * The index of the content part in the message. + * A developer-provided per-request id that will be used to match outputs to + * inputs. Must be unique for each request in a batch. */ - index: v.pipe(v.number(), v.integer()), + custom_id: v.optional(v.string()), /** - * Always `image_url`. + * The HTTP method to be used for the request. Currently only `POST` is + * supported. */ - type: v.picklist(["image_url"]), - image_url: v.optional( - v.looseObject({ - /** - * The URL of the image, must be a supported image types: jpeg, jpg, png, gif, - * webp. - */ - url: v.optional(v.string()), - /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. - */ - detail: v.optional(v.picklist(["auto", "low", "high"])), - }), - ), + method: v.optional(v.picklist(["POST"])), + /** + * The OpenAI API relative URL to be used for the request. Currently + * `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are + * supported. + */ + url: v.optional(v.string()), }); -export const messageDeltaContentImageUrlObjectSchema = v.looseObject({ +export const batchRequestInputSchema = v.looseObject({ /** - * The index of the content part in the message. + * A developer-provided per-request id that will be used to match outputs to + * inputs. Must be unique for each request in a batch. */ - index: v.pipe(v.number(), v.integer()), + custom_id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * Always `image_url`. + * The HTTP method to be used for the request. Currently only `POST` is + * supported. */ - type: v.picklist(["image_url"]), - image_url: v.exactOptional( - v.looseObject({ - /** - * The URL of the image, must be a supported image types: jpeg, jpg, png, gif, - * webp. - */ - url: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * Specifies the detail level of the image. `low` uses fewer tokens, you can - * opt in to high resolution using `high`. - */ - detail: v.exactOptional(v.picklist(["auto", "low", "high"])), - }), - ), -}); -/** - * The text content that is part of a message. - * @title Text - */ -export const inputMessageContentTextObjectSchema = v.looseObject({ + method: v.exactOptional(v.picklist(["POST"])), /** - * Always `text`. + * The OpenAI API relative URL to be used for the request. Currently + * `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are + * supported. */ - type: v.picklist(["text"]), - text: v.looseObject({ - /** - * The data that makes up the text. - */ - value: v.string(), - annotations: v.array(v.union([v.unknown(), v.unknown()])), - }), + url: v.exactOptional(v.pipe(v.string(), v.trim())), }); -export const messageContentTextObjectSchema = v.looseObject({ +/** The per-line object of the batch output and error files */ +export const inputBatchRequestOutputSchema = v.looseObject({ + id: v.optional(v.string()), /** - * Always `text`. + * A developer-provided per-request id that will be used to match outputs to + * inputs. */ - type: v.picklist(["text"]), - text: v.looseObject({ - /** - * The data that makes up the text. - */ - value: v.pipe(v.string(), v.trim()), - annotations: v.array(v.union([v.unknown(), v.unknown()])), - }), + custom_id: v.optional(v.string()), + response: v.optional( + v.nullable( + v.looseObject({ + /** + * The HTTP status code of the response + */ + status_code: v.optional(v.pipe(v.number(), v.integer())), + /** + * An unique identifier for the OpenAI API request. Please include this + * request ID when contacting support. + */ + request_id: v.optional(v.string()), + /** + * The JSON body of the response + */ + body: v.optional(v.record(v.string(), v.unknown())), + }), + ), + ), + /** + * For requests that failed with a non-HTTP error, this will contain more + * information on the cause of the failure. + */ + error: v.optional( + v.nullable( + v.looseObject({ + /** + * A machine-readable error code. + */ + code: v.optional(v.string()), + /** + * A human-readable error message. + */ + message: v.optional(v.string()), + }), + ), + ), }); -/** - * The refusal content generated by the assistant. - * @title Refusal - */ -export const inputMessageContentRefusalObjectSchema = v.looseObject({ +export const batchRequestOutputSchema = v.looseObject({ + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * Always `refusal`. + * A developer-provided per-request id that will be used to match outputs to + * inputs. */ - type: v.picklist(["refusal"]), - refusal: v.string(), + custom_id: v.exactOptional(v.pipe(v.string(), v.trim())), + response: v.exactOptional( + v.nullable( + v.looseObject({ + /** + * The HTTP status code of the response + */ + status_code: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * An unique identifier for the OpenAI API request. Please include this + * request ID when contacting support. + */ + request_id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The JSON body of the response + */ + body: v.exactOptional(v.record(v.string(), v.unknown())), + }), + ), + ), + /** + * For requests that failed with a non-HTTP error, this will contain more + * information on the cause of the failure. + */ + error: v.exactOptional( + v.nullable( + v.looseObject({ + /** + * A machine-readable error code. + */ + code: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * A human-readable error message. + */ + message: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + ), }); -export const messageContentRefusalObjectSchema = v.looseObject({ +export const inputInviteRequestSchema = v.looseObject({ /** - * Always `refusal`. + * Send an email to this address */ - type: v.picklist(["refusal"]), - refusal: v.pipe(v.string(), v.trim()), + email: v.string(), + /** + * `owner` or `reader` + */ + role: v.picklist(["reader", "owner"]), }); -/** - * The text content that is part of a message. - * @title Text - */ -export const inputMessageRequestContentTextObjectSchema = v.looseObject({ +export const inviteRequestSchema = v.looseObject({ /** - * Always `text`. + * Send an email to this address */ - type: v.picklist(["text"]), + email: v.pipe(v.string(), v.trim()), /** - * Text content to be sent to the model + * `owner` or `reader` */ - text: v.string(), + role: v.picklist(["reader", "owner"]), }); -export const messageRequestContentTextObjectSchema = v.looseObject({ +export const inputInviteDeleteResponseSchema = v.looseObject({ /** - * Always `text`. + * The object type, which is always `organization.invite.deleted` */ - type: v.picklist(["text"]), + object: v.picklist(["organization.invite.deleted"]), + id: v.string(), + deleted: v.boolean(), +}); +export const inviteDeleteResponseSchema = v.looseObject({ /** - * Text content to be sent to the model + * The object type, which is always `organization.invite.deleted` */ - text: v.pipe(v.string(), v.trim()), + object: v.picklist(["organization.invite.deleted"]), + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), }); -/** - * A citation within the message that points to a specific quote from a - * specific File associated with the assistant or the message. Generated when - * the assistant uses the "file_search" tool to search files. - * @title File citation - */ -export const inputMessageContentTextAnnotationsFileCitationObjectSchema = - v.looseObject({ - /** - * Always `file_citation`. - */ - type: v.picklist(["file_citation"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.string(), - file_citation: v.looseObject({ - /** - * The ID of the specific File the citation is from. - */ - file_id: v.string(), - }), - start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - }); -export const messageContentTextAnnotationsFileCitationObjectSchema = - v.looseObject({ - /** - * Always `file_citation`. - */ - type: v.picklist(["file_citation"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.pipe(v.string(), v.trim()), - file_citation: v.looseObject({ - /** - * The ID of the specific File the citation is from. - */ - file_id: v.pipe(v.string(), v.trim()), - }), - start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - }); -/** - * A URL for the file that's generated when the assistant used the - * `code_interpreter` tool to generate a file. - * @title File path - */ -export const inputMessageContentTextAnnotationsFilePathObjectSchema = - v.looseObject({ - /** - * Always `file_path`. - */ - type: v.picklist(["file_path"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.string(), - file_path: v.looseObject({ - /** - * The ID of the file that was generated. - */ - file_id: v.string(), - }), - start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - }); -export const messageContentTextAnnotationsFilePathObjectSchema = v.looseObject({ +export const inputUserRoleUpdateRequestSchema = v.looseObject({ /** - * Always `file_path`. + * `owner` or `reader` */ - type: v.picklist(["file_path"]), + role: v.picklist(["owner", "reader"]), +}); +export const userRoleUpdateRequestSchema = inputUserRoleUpdateRequestSchema; +export const inputUserDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.user.deleted"]), + id: v.string(), + deleted: v.boolean(), +}); +export const userDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.user.deleted"]), + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), +}); +export const inputProjectCreateRequestSchema = v.looseObject({ /** - * The text in the message content that needs to be replaced. + * The friendly name of the project, this name appears in reports. */ - text: v.pipe(v.string(), v.trim()), - file_path: v.looseObject({ - /** - * The ID of the file that was generated. - */ - file_id: v.pipe(v.string(), v.trim()), - }), - start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), - end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + name: v.string(), + /** + * A description of your business, project, or use case. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). + */ + app_use_case: v.optional(v.string()), + /** + * Your business URL, or if you don't have one yet, a URL to your LinkedIn or + * other social media. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). + */ + business_website: v.optional(v.string()), }); -/** - * The text content that is part of a message. - * @title Text - */ -export const inputMessageDeltaContentTextObjectSchema = v.looseObject({ +export const projectCreateRequestSchema = v.looseObject({ /** - * The index of the content part in the message. + * The friendly name of the project, this name appears in reports. */ - index: v.pipe(v.number(), v.integer()), + name: v.pipe(v.string(), v.trim()), /** - * Always `text`. + * A description of your business, project, or use case. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). */ - type: v.picklist(["text"]), - text: v.optional( - v.looseObject({ - /** - * The data that makes up the text. - */ - value: v.optional(v.string()), - annotations: v.optional(v.array(v.union([v.unknown(), v.unknown()]))), - }), - ), + app_use_case: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * Your business URL, or if you don't have one yet, a URL to your LinkedIn or + * other social media. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). + */ + business_website: v.exactOptional(v.pipe(v.string(), v.trim())), }); -export const messageDeltaContentTextObjectSchema = v.looseObject({ +export const inputProjectUpdateRequestSchema = v.looseObject({ /** - * The index of the content part in the message. + * The updated name of the project, this name appears in reports. */ - index: v.pipe(v.number(), v.integer()), + name: v.string(), /** - * Always `text`. + * A description of your business, project, or use case. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). */ - type: v.picklist(["text"]), - text: v.exactOptional( - v.looseObject({ - /** - * The data that makes up the text. - */ - value: v.exactOptional(v.pipe(v.string(), v.trim())), - annotations: v.exactOptional( - v.array(v.union([v.unknown(), v.unknown()])), - ), - }), - ), + app_use_case: v.optional(v.string()), + /** + * Your business URL, or if you don't have one yet, a URL to your LinkedIn or + * other social media. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). + */ + business_website: v.optional(v.string()), }); -/** - * The refusal content that is part of a message. - * @title Refusal - */ -export const inputMessageDeltaContentRefusalObjectSchema = v.looseObject({ +export const projectUpdateRequestSchema = v.looseObject({ /** - * The index of the refusal part in the message. + * The updated name of the project, this name appears in reports. */ - index: v.pipe(v.number(), v.integer()), + name: v.pipe(v.string(), v.trim()), /** - * Always `refusal`. + * A description of your business, project, or use case. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). */ - type: v.picklist(["refusal"]), - refusal: v.optional(v.string()), + app_use_case: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * Your business URL, or if you don't have one yet, a URL to your LinkedIn or + * other social media. [Why we need this + * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). + */ + business_website: v.exactOptional(v.pipe(v.string(), v.trim())), }); -export const messageDeltaContentRefusalObjectSchema = v.looseObject({ +export const inputDefaultProjectErrorResponseSchema = v.looseObject({ + code: v.pipe(v.number(), v.integer()), + message: v.string(), +}); +export const defaultProjectErrorResponseSchema = v.looseObject({ + code: v.pipe(v.number(), v.integer()), + message: v.pipe(v.string(), v.trim()), +}); +export const inputProjectUserCreateRequestSchema = v.looseObject({ /** - * The index of the refusal part in the message. + * The ID of the user. */ - index: v.pipe(v.number(), v.integer()), + user_id: v.string(), /** - * Always `refusal`. + * `owner` or `member` */ - type: v.picklist(["refusal"]), - refusal: v.exactOptional(v.pipe(v.string(), v.trim())), + role: v.picklist(["owner", "member"]), }); -/** - * A citation within the message that points to a specific quote from a - * specific File associated with the assistant or the message. Generated when - * the assistant uses the "file_search" tool to search files. - * @title File citation - */ -export const inputMessageDeltaContentTextAnnotationsFileCitationObjectSchema = - v.looseObject({ - /** - * The index of the annotation in the text content part. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `file_citation`. - */ - type: v.picklist(["file_citation"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.optional(v.string()), - file_citation: v.optional( - v.looseObject({ - /** - * The ID of the specific File the citation is from. - */ - file_id: v.optional(v.string()), - /** - * The specific quote in the file. - */ - quote: v.optional(v.string()), - }), - ), - start_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), - end_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), - }); -export const messageDeltaContentTextAnnotationsFileCitationObjectSchema = - v.looseObject({ - /** - * The index of the annotation in the text content part. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `file_citation`. - */ - type: v.picklist(["file_citation"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.exactOptional(v.pipe(v.string(), v.trim())), - file_citation: v.exactOptional( - v.looseObject({ - /** - * The ID of the specific File the citation is from. - */ - file_id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The specific quote in the file. - */ - quote: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - start_index: v.exactOptional( - v.pipe(v.number(), v.integer(), v.minValue(0)), - ), - end_index: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0))), - }); -/** - * A URL for the file that's generated when the assistant used the - * `code_interpreter` tool to generate a file. - * @title File path - */ -export const inputMessageDeltaContentTextAnnotationsFilePathObjectSchema = - v.looseObject({ - /** - * The index of the annotation in the text content part. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `file_path`. - */ - type: v.picklist(["file_path"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.optional(v.string()), - file_path: v.optional( - v.looseObject({ - /** - * The ID of the file that was generated. - */ - file_id: v.optional(v.string()), - }), - ), - start_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), - end_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), - }); -export const messageDeltaContentTextAnnotationsFilePathObjectSchema = - v.looseObject({ - /** - * The index of the annotation in the text content part. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `file_path`. - */ - type: v.picklist(["file_path"]), - /** - * The text in the message content that needs to be replaced. - */ - text: v.exactOptional(v.pipe(v.string(), v.trim())), - file_path: v.exactOptional( - v.looseObject({ - /** - * The ID of the file that was generated. - */ - file_id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - start_index: v.exactOptional( - v.pipe(v.number(), v.integer(), v.minValue(0)), - ), - end_index: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0))), - }); -/** - * Details of the Code Interpreter tool call the run step was involved in. - * @title Code Interpreter tool call - */ -export const inputRunStepDetailsToolCallsCodeObjectSchema = v.looseObject({ +export const projectUserCreateRequestSchema = v.looseObject({ /** - * The ID of the tool call. + * The ID of the user. */ - id: v.string(), + user_id: v.pipe(v.string(), v.trim()), /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. + * `owner` or `member` */ - type: v.picklist(["code_interpreter"]), + role: v.picklist(["owner", "member"]), +}); +export const inputProjectUserUpdateRequestSchema = v.looseObject({ /** - * The Code Interpreter tool call definition. + * `owner` or `member` */ - code_interpreter: v.looseObject({ - /** - * The input to the Code Interpreter tool call. - */ - input: v.string(), - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can - * output one or more items, including text (`logs`) or images (`image`). Each - * of these are represented by a different object type. - */ - outputs: v.array(v.union([v.unknown(), v.unknown()])), - }), + role: v.picklist(["owner", "member"]), }); -export const runStepDetailsToolCallsCodeObjectSchema = v.looseObject({ +export const projectUserUpdateRequestSchema = + inputProjectUserUpdateRequestSchema; +export const inputProjectUserDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.user.deleted"]), + id: v.string(), + deleted: v.boolean(), +}); +export const projectUserDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.user.deleted"]), + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), +}); +export const inputProjectServiceAccountCreateRequestSchema = v.looseObject({ /** - * The ID of the tool call. + * The name of the service account being created. + */ + name: v.string(), +}); +export const projectServiceAccountCreateRequestSchema = v.looseObject({ + /** + * The name of the service account being created. */ + name: v.pipe(v.string(), v.trim()), +}); +export const inputProjectServiceAccountDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.service_account.deleted"]), + id: v.string(), + deleted: v.boolean(), +}); +export const projectServiceAccountDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.service_account.deleted"]), + id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), +}); +export const inputProjectApiKeyDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.api_key.deleted"]), + id: v.string(), + deleted: v.boolean(), +}); +export const projectApiKeyDeleteResponseSchema = v.looseObject({ + object: v.picklist(["organization.project.api_key.deleted"]), id: v.pipe(v.string(), v.trim()), + deleted: v.boolean(), +}); +/** Represents an individual service account in a project. */ +export const inputProjectServiceAccountSchema = v.looseObject({ /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. + * The object type, which is always `organization.project.service_account` */ - type: v.picklist(["code_interpreter"]), + object: v.picklist(["organization.project.service_account"]), /** - * The Code Interpreter tool call definition. + * The identifier, which can be referenced in API endpoints */ - code_interpreter: v.looseObject({ - /** - * The input to the Code Interpreter tool call. - */ - input: v.pipe(v.string(), v.trim()), - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can - * output one or more items, including text (`logs`) or images (`image`). Each - * of these are represented by a different object type. - */ - outputs: v.array(v.union([v.unknown(), v.unknown()])), - }), + id: v.string(), + /** + * The name of the service account + */ + name: v.string(), + /** + * `owner` or `member` + */ + role: v.picklist(["owner", "member"]), + /** + * The Unix timestamp (in seconds) of when the service account was created + */ + created_at: v.pipe(v.number(), v.integer()), }); -/** - * Details of the Code Interpreter tool call the run step was involved in. - * @title Code interpreter tool call - */ -export const inputRunStepDeltaStepDetailsToolCallsCodeObjectSchema = - v.looseObject({ - /** - * The index of the tool call in the tool calls array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call. - */ - id: v.optional(v.string()), - /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. - */ - type: v.picklist(["code_interpreter"]), - /** - * The Code Interpreter tool call definition. - */ - code_interpreter: v.optional( - v.looseObject({ - /** - * The input to the Code Interpreter tool call. - */ - input: v.optional(v.string()), - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can - * output one or more items, including text (`logs`) or images (`image`). Each - * of these are represented by a different object type. - */ - outputs: v.optional(v.array(v.union([v.unknown(), v.unknown()]))), - }), - ), - }); -export const runStepDeltaStepDetailsToolCallsCodeObjectSchema = v.looseObject({ +export const projectServiceAccountSchema = v.looseObject({ /** - * The index of the tool call in the tool calls array. + * The object type, which is always `organization.project.service_account` */ - index: v.pipe(v.number(), v.integer()), + object: v.picklist(["organization.project.service_account"]), /** - * The ID of the tool call. + * The identifier, which can be referenced in API endpoints */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + id: v.pipe(v.string(), v.trim()), /** - * The type of tool call. This is always going to be `code_interpreter` for - * this type of tool call. + * The name of the service account */ - type: v.picklist(["code_interpreter"]), + name: v.pipe(v.string(), v.trim()), /** - * The Code Interpreter tool call definition. + * `owner` or `member` */ - code_interpreter: v.exactOptional( - v.looseObject({ - /** - * The input to the Code Interpreter tool call. - */ - input: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The outputs from the Code Interpreter tool call. Code Interpreter can - * output one or more items, including text (`logs`) or images (`image`). Each - * of these are represented by a different object type. - */ - outputs: v.exactOptional(v.array(v.union([v.unknown(), v.unknown()]))), - }), - ), + role: v.picklist(["owner", "member"]), + /** + * The Unix timestamp (in seconds) of when the service account was created + */ + created_at: v.pipe(v.number(), v.integer()), }); -/** - * Text output from the Code Interpreter tool call as part of a run step. - * @title Code Interpreter log output - */ -export const inputRunStepDetailsToolCallsCodeOutputLogsObjectSchema = - v.looseObject({ - /** - * Always `logs`. - */ - type: v.picklist(["logs"]), - /** - * The text output from the Code Interpreter tool call. - */ - logs: v.string(), - }); -export const runStepDetailsToolCallsCodeOutputLogsObjectSchema = v.looseObject({ +/** Represents an individual user in a project. */ +export const inputProjectUserSchema = v.looseObject({ /** - * Always `logs`. + * The object type, which is always `organization.project.user` */ - type: v.picklist(["logs"]), + object: v.picklist(["organization.project.user"]), /** - * The text output from the Code Interpreter tool call. - */ - logs: v.pipe(v.string(), v.trim()), -}); -/** - * Text output from the Code Interpreter tool call as part of a run step. - * @title Code interpreter log output - */ -export const inputRunStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema = - v.looseObject({ - /** - * The index of the output in the outputs array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `logs`. - */ - type: v.picklist(["logs"]), - /** - * The text output from the Code Interpreter tool call. - */ - logs: v.optional(v.string()), - }); -export const runStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema = - v.looseObject({ - /** - * The index of the output in the outputs array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `logs`. - */ - type: v.picklist(["logs"]), - /** - * The text output from the Code Interpreter tool call. - */ - logs: v.exactOptional(v.pipe(v.string(), v.trim())), - }); -export const inputRunStepDetailsToolCallsCodeOutputImageObjectSchema = - v.looseObject({ - /** - * Always `image`. - */ - type: v.picklist(["image"]), - image: v.looseObject({ - /** - * The [file](/docs/api-reference/files) ID of the image. - */ - file_id: v.string(), - }), - }); -export const runStepDetailsToolCallsCodeOutputImageObjectSchema = v.looseObject( - { - /** - * Always `image`. - */ - type: v.picklist(["image"]), - image: v.looseObject({ - /** - * The [file](/docs/api-reference/files) ID of the image. - */ - file_id: v.pipe(v.string(), v.trim()), - }), - }, -); -export const inputRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema = - v.looseObject({ - /** - * The index of the output in the outputs array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `image`. - */ - type: v.picklist(["image"]), - image: v.optional( - v.looseObject({ - /** - * The [file](/docs/api-reference/files) ID of the image. - */ - file_id: v.optional(v.string()), - }), - ), - }); -export const runStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema = - v.looseObject({ - /** - * The index of the output in the outputs array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * Always `image`. - */ - type: v.picklist(["image"]), - image: v.exactOptional( - v.looseObject({ - /** - * The [file](/docs/api-reference/files) ID of the image. - */ - file_id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - }); -export const inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema = - v.looseObject({ - /** - * The index of the tool call in the tool calls array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call object. - */ - id: v.optional(v.string()), - /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. - */ - type: v.picklist(["file_search"]), - /** - * For now, this is always going to be an empty object. - */ - file_search: v.record(v.string(), v.unknown()), - }); -export const runStepDeltaStepDetailsToolCallsFileSearchObjectSchema = - v.looseObject({ - /** - * The index of the tool call in the tool calls array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call object. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. - */ - type: v.picklist(["file_search"]), - /** - * For now, this is always going to be an empty object. - */ - file_search: v.record(v.string(), v.unknown()), - }); -export const inputRunStepDetailsToolCallsFunctionObjectSchema = v.looseObject({ - /** - * The ID of the tool call object. - */ - id: v.string(), - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - */ - type: v.picklist(["function"]), - /** - * The definition of the function that was called. - */ - function: v.looseObject({ - /** - * The name of the function. - */ - name: v.string(), - /** - * The arguments passed to the function. - */ - arguments: v.string(), - /** - * The output of the function. This will be `null` if the outputs have not - * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - */ - output: v.nullable(v.string()), - }), -}); -export const runStepDetailsToolCallsFunctionObjectSchema = v.looseObject({ - /** - * The ID of the tool call object. - */ - id: v.pipe(v.string(), v.trim()), - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - */ - type: v.picklist(["function"]), - /** - * The definition of the function that was called. - */ - function: v.looseObject({ - /** - * The name of the function. - */ - name: v.pipe(v.string(), v.trim()), - /** - * The arguments passed to the function. - */ - arguments: v.pipe(v.string(), v.trim()), - /** - * The output of the function. This will be `null` if the outputs have not - * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - */ - output: v.nullable(v.pipe(v.string(), v.trim())), - }), -}); -export const inputRunStepDeltaStepDetailsToolCallsFunctionObjectSchema = - v.looseObject({ - /** - * The index of the tool call in the tool calls array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call object. - */ - id: v.optional(v.string()), - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - */ - type: v.picklist(["function"]), - /** - * The definition of the function that was called. - */ - function: v.optional( - v.looseObject({ - /** - * The name of the function. - */ - name: v.optional(v.string()), - /** - * The arguments passed to the function. - */ - arguments: v.optional(v.string()), - /** - * The output of the function. This will be `null` if the outputs have not - * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - */ - output: v.optional(v.nullable(v.string())), - }), - ), - }); -export const runStepDeltaStepDetailsToolCallsFunctionObjectSchema = - v.looseObject({ - /** - * The index of the tool call in the tool calls array. - */ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call object. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The type of tool call. This is always going to be `function` for this type - * of tool call. - */ - type: v.picklist(["function"]), - /** - * The definition of the function that was called. - */ - function: v.exactOptional( - v.looseObject({ - /** - * The name of the function. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The arguments passed to the function. - */ - arguments: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The output of the function. This will be `null` if the outputs have not - * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. - */ - output: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - }), - ), - }); -export const inputDeleteVectorStoreResponseSchema = v.looseObject({ - id: v.string(), - deleted: v.boolean(), - object: v.picklist(["vector_store.deleted"]), -}); -export const deleteVectorStoreResponseSchema = v.looseObject({ - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), - object: v.picklist(["vector_store.deleted"]), -}); -export const inputDeleteVectorStoreFileResponseSchema = v.looseObject({ - id: v.string(), - deleted: v.boolean(), - object: v.picklist(["vector_store.file.deleted"]), -}); -export const deleteVectorStoreFileResponseSchema = v.looseObject({ - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), - object: v.picklist(["vector_store.file.deleted"]), -}); -/** - * A batch of files attached to a vector store. - * @title Vector store file batch - */ -export const inputVectorStoreFileBatchObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.string(), - /** - * The object type, which is always `vector_store.file_batch`. - */ - object: v.picklist(["vector_store.files_batch"]), - /** - * The Unix timestamp (in seconds) for when the vector store files batch was - * created. - */ - created_at: v.pipe(v.number(), v.integer()), - /** - * The ID of the [vector store](/docs/api-reference/vector-stores/object) that - * the [File](/docs/api-reference/files) is attached to. - */ - vector_store_id: v.string(), - /** - * The status of the vector store files batch, which can be either - * `in_progress`, `completed`, `cancelled` or `failed`. - */ - status: v.picklist(["in_progress", "completed", "cancelled", "failed"]), - file_counts: v.looseObject({ - /** - * The number of files that are currently being processed. - */ - in_progress: v.pipe(v.number(), v.integer()), - /** - * The number of files that have been processed. - */ - completed: v.pipe(v.number(), v.integer()), - /** - * The number of files that have failed to process. - */ - failed: v.pipe(v.number(), v.integer()), - /** - * The number of files that where cancelled. - */ - cancelled: v.pipe(v.number(), v.integer()), - /** - * The total number of files. - */ - total: v.pipe(v.number(), v.integer()), - }), -}); -export const vectorStoreFileBatchObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always `vector_store.file_batch`. - */ - object: v.picklist(["vector_store.files_batch"]), - /** - * The Unix timestamp (in seconds) for when the vector store files batch was - * created. - */ - created_at: v.pipe(v.number(), v.integer()), - /** - * The ID of the [vector store](/docs/api-reference/vector-stores/object) that - * the [File](/docs/api-reference/files) is attached to. - */ - vector_store_id: v.pipe(v.string(), v.trim()), - /** - * The status of the vector store files batch, which can be either - * `in_progress`, `completed`, `cancelled` or `failed`. - */ - status: v.picklist(["in_progress", "completed", "cancelled", "failed"]), - file_counts: v.looseObject({ - /** - * The number of files that are currently being processed. - */ - in_progress: v.pipe(v.number(), v.integer()), - /** - * The number of files that have been processed. - */ - completed: v.pipe(v.number(), v.integer()), - /** - * The number of files that have failed to process. - */ - failed: v.pipe(v.number(), v.integer()), - /** - * The number of files that where cancelled. - */ - cancelled: v.pipe(v.number(), v.integer()), - /** - * The total number of files. - */ - total: v.pipe(v.number(), v.integer()), - }), -}); -/** The per-line object of the batch input file */ -export const inputBatchRequestInputSchema = v.looseObject({ - /** - * A developer-provided per-request id that will be used to match outputs to - * inputs. Must be unique for each request in a batch. - */ - custom_id: v.optional(v.string()), - /** - * The HTTP method to be used for the request. Currently only `POST` is - * supported. - */ - method: v.optional(v.picklist(["POST"])), - /** - * The OpenAI API relative URL to be used for the request. Currently - * `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are - * supported. - */ - url: v.optional(v.string()), -}); -export const batchRequestInputSchema = v.looseObject({ - /** - * A developer-provided per-request id that will be used to match outputs to - * inputs. Must be unique for each request in a batch. - */ - custom_id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The HTTP method to be used for the request. Currently only `POST` is - * supported. - */ - method: v.exactOptional(v.picklist(["POST"])), - /** - * The OpenAI API relative URL to be used for the request. Currently - * `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are - * supported. - */ - url: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -/** The per-line object of the batch output and error files */ -export const inputBatchRequestOutputSchema = v.looseObject({ - id: v.optional(v.string()), - /** - * A developer-provided per-request id that will be used to match outputs to - * inputs. - */ - custom_id: v.optional(v.string()), - response: v.optional( - v.nullable( - v.looseObject({ - /** - * The HTTP status code of the response - */ - status_code: v.optional(v.pipe(v.number(), v.integer())), - /** - * An unique identifier for the OpenAI API request. Please include this - * request ID when contacting support. - */ - request_id: v.optional(v.string()), - /** - * The JSON body of the response - */ - body: v.optional(v.record(v.string(), v.unknown())), - }), - ), - ), - /** - * For requests that failed with a non-HTTP error, this will contain more - * information on the cause of the failure. - */ - error: v.optional( - v.nullable( - v.looseObject({ - /** - * A machine-readable error code. - */ - code: v.optional(v.string()), - /** - * A human-readable error message. - */ - message: v.optional(v.string()), - }), - ), - ), -}); -export const batchRequestOutputSchema = v.looseObject({ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * A developer-provided per-request id that will be used to match outputs to - * inputs. - */ - custom_id: v.exactOptional(v.pipe(v.string(), v.trim())), - response: v.exactOptional( - v.nullable( - v.looseObject({ - /** - * The HTTP status code of the response - */ - status_code: v.exactOptional(v.pipe(v.number(), v.integer())), - /** - * An unique identifier for the OpenAI API request. Please include this - * request ID when contacting support. - */ - request_id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The JSON body of the response - */ - body: v.exactOptional(v.record(v.string(), v.unknown())), - }), - ), - ), - /** - * For requests that failed with a non-HTTP error, this will contain more - * information on the cause of the failure. - */ - error: v.exactOptional( - v.nullable( - v.looseObject({ - /** - * A machine-readable error code. - */ - code: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * A human-readable error message. - */ - message: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - ), -}); -export const inputInviteRequestSchema = v.looseObject({ - /** - * Send an email to this address - */ - email: v.string(), - /** - * `owner` or `reader` - */ - role: v.picklist(["reader", "owner"]), -}); -export const inviteRequestSchema = v.looseObject({ - /** - * Send an email to this address - */ - email: v.pipe(v.string(), v.trim()), - /** - * `owner` or `reader` - */ - role: v.picklist(["reader", "owner"]), -}); -export const inputInviteDeleteResponseSchema = v.looseObject({ - /** - * The object type, which is always `organization.invite.deleted` - */ - object: v.picklist(["organization.invite.deleted"]), - id: v.string(), - deleted: v.boolean(), -}); -export const inviteDeleteResponseSchema = v.looseObject({ - /** - * The object type, which is always `organization.invite.deleted` - */ - object: v.picklist(["organization.invite.deleted"]), - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), -}); -export const inputUserRoleUpdateRequestSchema = v.looseObject({ - /** - * `owner` or `reader` - */ - role: v.picklist(["owner", "reader"]), -}); -export const userRoleUpdateRequestSchema = inputUserRoleUpdateRequestSchema; -export const inputUserDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.user.deleted"]), - id: v.string(), - deleted: v.boolean(), -}); -export const userDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.user.deleted"]), - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), -}); -export const inputProjectCreateRequestSchema = v.looseObject({ - /** - * The friendly name of the project, this name appears in reports. - */ - name: v.string(), - /** - * A description of your business, project, or use case. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - app_use_case: v.optional(v.string()), - /** - * Your business URL, or if you don't have one yet, a URL to your LinkedIn or - * other social media. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - business_website: v.optional(v.string()), -}); -export const projectCreateRequestSchema = v.looseObject({ - /** - * The friendly name of the project, this name appears in reports. - */ - name: v.pipe(v.string(), v.trim()), - /** - * A description of your business, project, or use case. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - app_use_case: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * Your business URL, or if you don't have one yet, a URL to your LinkedIn or - * other social media. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - business_website: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -export const inputProjectUpdateRequestSchema = v.looseObject({ - /** - * The updated name of the project, this name appears in reports. - */ - name: v.string(), - /** - * A description of your business, project, or use case. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - app_use_case: v.optional(v.string()), - /** - * Your business URL, or if you don't have one yet, a URL to your LinkedIn or - * other social media. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - business_website: v.optional(v.string()), -}); -export const projectUpdateRequestSchema = v.looseObject({ - /** - * The updated name of the project, this name appears in reports. - */ - name: v.pipe(v.string(), v.trim()), - /** - * A description of your business, project, or use case. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - app_use_case: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * Your business URL, or if you don't have one yet, a URL to your LinkedIn or - * other social media. [Why we need this - * information](https://help.openai.com/en/articles/9824607-api-platform-verifications). - */ - business_website: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -export const inputDefaultProjectErrorResponseSchema = v.looseObject({ - code: v.pipe(v.number(), v.integer()), - message: v.string(), -}); -export const defaultProjectErrorResponseSchema = v.looseObject({ - code: v.pipe(v.number(), v.integer()), - message: v.pipe(v.string(), v.trim()), -}); -export const inputProjectUserCreateRequestSchema = v.looseObject({ - /** - * The ID of the user. - */ - user_id: v.string(), - /** - * `owner` or `member` - */ - role: v.picklist(["owner", "member"]), -}); -export const projectUserCreateRequestSchema = v.looseObject({ - /** - * The ID of the user. - */ - user_id: v.pipe(v.string(), v.trim()), - /** - * `owner` or `member` - */ - role: v.picklist(["owner", "member"]), -}); -export const inputProjectUserUpdateRequestSchema = v.looseObject({ - /** - * `owner` or `member` - */ - role: v.picklist(["owner", "member"]), -}); -export const projectUserUpdateRequestSchema = - inputProjectUserUpdateRequestSchema; -export const inputProjectUserDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.user.deleted"]), - id: v.string(), - deleted: v.boolean(), -}); -export const projectUserDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.user.deleted"]), - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), -}); -export const inputProjectServiceAccountCreateRequestSchema = v.looseObject({ - /** - * The name of the service account being created. - */ - name: v.string(), -}); -export const projectServiceAccountCreateRequestSchema = v.looseObject({ - /** - * The name of the service account being created. - */ - name: v.pipe(v.string(), v.trim()), -}); -export const inputProjectServiceAccountDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.service_account.deleted"]), - id: v.string(), - deleted: v.boolean(), -}); -export const projectServiceAccountDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.service_account.deleted"]), - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), -}); -export const inputProjectApiKeyDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.api_key.deleted"]), - id: v.string(), - deleted: v.boolean(), -}); -export const projectApiKeyDeleteResponseSchema = v.looseObject({ - object: v.picklist(["organization.project.api_key.deleted"]), - id: v.pipe(v.string(), v.trim()), - deleted: v.boolean(), -}); -/** Represents an individual service account in a project. */ -export const inputProjectServiceAccountSchema = v.looseObject({ - /** - * The object type, which is always `organization.project.service_account` - */ - object: v.picklist(["organization.project.service_account"]), - /** - * The identifier, which can be referenced in API endpoints - */ - id: v.string(), - /** - * The name of the service account - */ - name: v.string(), - /** - * `owner` or `member` - */ - role: v.picklist(["owner", "member"]), - /** - * The Unix timestamp (in seconds) of when the service account was created - */ - created_at: v.pipe(v.number(), v.integer()), -}); -export const projectServiceAccountSchema = v.looseObject({ - /** - * The object type, which is always `organization.project.service_account` - */ - object: v.picklist(["organization.project.service_account"]), - /** - * The identifier, which can be referenced in API endpoints - */ - id: v.pipe(v.string(), v.trim()), - /** - * The name of the service account - */ - name: v.pipe(v.string(), v.trim()), - /** - * `owner` or `member` - */ - role: v.picklist(["owner", "member"]), - /** - * The Unix timestamp (in seconds) of when the service account was created - */ - created_at: v.pipe(v.number(), v.integer()), -}); -/** Represents an individual user in a project. */ -export const inputProjectUserSchema = v.looseObject({ - /** - * The object type, which is always `organization.project.user` - */ - object: v.picklist(["organization.project.user"]), - /** - * The identifier, which can be referenced in API endpoints + * The identifier, which can be referenced in API endpoints */ id: v.string(), /** @@ -4058,119 +2701,493 @@ export const inputAuditLogActorServiceAccountSchema = v.looseObject({ }); export const auditLogActorServiceAccountSchema = v.looseObject({ /** - * The service account id. + * The service account id. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +/** The user who performed the audit logged action. */ +export const inputAuditLogActorUserSchema = v.looseObject({ + /** + * The user id. + */ + id: v.optional(v.string()), + /** + * The user email. + */ + email: v.optional(v.string()), +}); +export const auditLogActorUserSchema = v.looseObject({ + /** + * The user id. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The user email. + */ + email: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +/** The API Key used to perform the audit logged action. */ +export const inputAuditLogActorApiKeySchema = v.looseObject({ + /** + * The tracking id of the API key. + */ + id: v.optional(v.string()), + /** + * The type of API key. Can be either `user` or `service_account`. + */ + type: v.optional(v.picklist(["user", "service_account"])), + user: v.optional(inputAuditLogActorUserSchema), + service_account: v.optional(inputAuditLogActorServiceAccountSchema), +}); +export const auditLogActorApiKeySchema = v.looseObject({ + /** + * The tracking id of the API key. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The type of API key. Can be either `user` or `service_account`. + */ + type: v.exactOptional(v.picklist(["user", "service_account"])), + user: v.exactOptional(auditLogActorUserSchema), + service_account: v.exactOptional(auditLogActorServiceAccountSchema), +}); +/** The session in which the audit logged action was performed. */ +export const inputAuditLogActorSessionSchema = v.looseObject({ + user: v.optional(inputAuditLogActorUserSchema), + /** + * The IP address from which the action was performed. + */ + ip_address: v.optional(v.string()), +}); +export const auditLogActorSessionSchema = v.looseObject({ + user: v.exactOptional(auditLogActorUserSchema), + /** + * The IP address from which the action was performed. + */ + ip_address: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +/** The actor who performed the audit logged action. */ +export const inputAuditLogActorSchema = v.looseObject({ + /** + * The type of actor. Is either `session` or `api_key`. + */ + type: v.optional(v.picklist(["session", "api_key"])), + session: v.optional(inputAuditLogActorSessionSchema), + api_key: v.optional(inputAuditLogActorApiKeySchema), +}); +export const auditLogActorSchema = v.looseObject({ + /** + * The type of actor. Is either `session` or `api_key`. + */ + type: v.exactOptional(v.picklist(["session", "api_key"])), + session: v.exactOptional(auditLogActorSessionSchema), + api_key: v.exactOptional(auditLogActorApiKeySchema), +}); +/** The event type. */ +export const inputAuditLogEventTypeSchema = v.picklist([ + "api_key.created", + "api_key.updated", + "api_key.deleted", + "invite.sent", + "invite.accepted", + "invite.deleted", + "login.succeeded", + "login.failed", + "logout.succeeded", + "logout.failed", + "organization.updated", + "project.created", + "project.updated", + "project.archived", + "service_account.created", + "service_account.updated", + "service_account.deleted", + "user.added", + "user.updated", + "user.deleted", +]); +export const auditLogEventTypeSchema = inputAuditLogEventTypeSchema; +/** A log of a user action or configuration change within this organization. */ +export const inputAuditLogSchema = v.looseObject({ + /** + * The ID of this log. + */ + id: v.string(), + type: inputAuditLogEventTypeSchema, + /** + * The Unix timestamp (in seconds) of the event. + */ + effective_at: v.pipe(v.number(), v.integer()), + /** + * The project that the action was scoped to. Absent for actions not scoped to + * projects. + */ + project: v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: v.optional(v.string()), + /** + * The project title. + */ + name: v.optional(v.string()), + }), + ), + actor: inputAuditLogActorSchema, + /** + * The details for events with this `type`. + */ + "api_key.created": v.optional( + v.looseObject({ + /** + * The tracking ID of the API key. + */ + id: v.optional(v.string()), + /** + * The payload used to create the API key. + */ + data: v.optional( + v.looseObject({ + /** + * A list of scopes allowed for the API key, e.g. `["api.model.request"]` + */ + scopes: v.optional(v.array(v.string())), + }), + ), + }), + ), + /** + * The details for events with this `type`. + */ + "api_key.updated": v.optional( + v.looseObject({ + /** + * The tracking ID of the API key. + */ + id: v.optional(v.string()), + /** + * The payload used to update the API key. + */ + changes_requested: v.optional( + v.looseObject({ + /** + * A list of scopes allowed for the API key, e.g. `["api.model.request"]` + */ + scopes: v.optional(v.array(v.string())), + }), + ), + }), + ), + /** + * The details for events with this `type`. + */ + "api_key.deleted": v.optional( + v.looseObject({ + /** + * The tracking ID of the API key. + */ + id: v.optional(v.string()), + }), + ), + /** + * The details for events with this `type`. + */ + "invite.sent": v.optional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.optional(v.string()), + /** + * The payload used to create the invite. + */ + data: v.optional( + v.looseObject({ + /** + * The email invited to the organization. + */ + email: v.optional(v.string()), + /** + * The role the email was invited to be. Is either `owner` or `member`. + */ + role: v.optional(v.string()), + }), + ), + }), + ), + /** + * The details for events with this `type`. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -/** The user who performed the audit logged action. */ -export const inputAuditLogActorUserSchema = v.looseObject({ + "invite.accepted": v.optional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.optional(v.string()), + }), + ), /** - * The user id. + * The details for events with this `type`. */ - id: v.optional(v.string()), + "invite.deleted": v.optional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.optional(v.string()), + }), + ), /** - * The user email. + * The details for events with this `type`. */ - email: v.optional(v.string()), -}); -export const auditLogActorUserSchema = v.looseObject({ + "login.failed": v.optional( + v.looseObject({ + /** + * The error code of the failure. + */ + error_code: v.optional(v.string()), + /** + * The error message of the failure. + */ + error_message: v.optional(v.string()), + }), + ), /** - * The user id. + * The details for events with this `type`. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + "logout.failed": v.optional( + v.looseObject({ + /** + * The error code of the failure. + */ + error_code: v.optional(v.string()), + /** + * The error message of the failure. + */ + error_message: v.optional(v.string()), + }), + ), /** - * The user email. + * The details for events with this `type`. */ - email: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -/** The API Key used to perform the audit logged action. */ -export const inputAuditLogActorApiKeySchema = v.looseObject({ + "organization.updated": v.optional( + v.looseObject({ + /** + * The organization ID. + */ + id: v.optional(v.string()), + /** + * The payload used to update the organization settings. + */ + changes_requested: v.optional( + v.looseObject({ + /** + * The organization title. + */ + title: v.optional(v.string()), + /** + * The organization description. + */ + description: v.optional(v.string()), + /** + * The organization name. + */ + name: v.optional(v.string()), + settings: v.optional( + v.looseObject({ + /** + * Visibility of the threads page which shows messages created with the + * Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. + */ + threads_ui_visibility: v.optional(v.string()), + /** + * Visibility of the usage dashboard which shows activity and costs for your + * organization. One of `ANY_ROLE` or `OWNERS`. + */ + usage_dashboard_visibility: v.optional(v.string()), + }), + ), + }), + ), + }), + ), /** - * The tracking id of the API key. + * The details for events with this `type`. */ - id: v.optional(v.string()), + "project.created": v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: v.optional(v.string()), + /** + * The payload used to create the project. + */ + data: v.optional( + v.looseObject({ + /** + * The project name. + */ + name: v.optional(v.string()), + /** + * The title of the project as seen on the dashboard. + */ + title: v.optional(v.string()), + }), + ), + }), + ), /** - * The type of API key. Can be either `user` or `service_account`. + * The details for events with this `type`. */ - type: v.optional(v.picklist(["user", "service_account"])), - user: v.optional(inputAuditLogActorUserSchema), - service_account: v.optional(inputAuditLogActorServiceAccountSchema), -}); -export const auditLogActorApiKeySchema = v.looseObject({ + "project.updated": v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: v.optional(v.string()), + /** + * The payload used to update the project. + */ + changes_requested: v.optional( + v.looseObject({ + /** + * The title of the project as seen on the dashboard. + */ + title: v.optional(v.string()), + }), + ), + }), + ), /** - * The tracking id of the API key. + * The details for events with this `type`. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + "project.archived": v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: v.optional(v.string()), + }), + ), /** - * The type of API key. Can be either `user` or `service_account`. + * The details for events with this `type`. */ - type: v.exactOptional(v.picklist(["user", "service_account"])), - user: v.exactOptional(auditLogActorUserSchema), - service_account: v.exactOptional(auditLogActorServiceAccountSchema), -}); -/** The session in which the audit logged action was performed. */ -export const inputAuditLogActorSessionSchema = v.looseObject({ - user: v.optional(inputAuditLogActorUserSchema), + "service_account.created": v.optional( + v.looseObject({ + /** + * The service account ID. + */ + id: v.optional(v.string()), + /** + * The payload used to create the service account. + */ + data: v.optional( + v.looseObject({ + /** + * The role of the service account. Is either `owner` or `member`. + */ + role: v.optional(v.string()), + }), + ), + }), + ), /** - * The IP address from which the action was performed. + * The details for events with this `type`. */ - ip_address: v.optional(v.string()), -}); -export const auditLogActorSessionSchema = v.looseObject({ - user: v.exactOptional(auditLogActorUserSchema), + "service_account.updated": v.optional( + v.looseObject({ + /** + * The service account ID. + */ + id: v.optional(v.string()), + /** + * The payload used to updated the service account. + */ + changes_requested: v.optional( + v.looseObject({ + /** + * The role of the service account. Is either `owner` or `member`. + */ + role: v.optional(v.string()), + }), + ), + }), + ), /** - * The IP address from which the action was performed. + * The details for events with this `type`. */ - ip_address: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -/** The actor who performed the audit logged action. */ -export const inputAuditLogActorSchema = v.looseObject({ + "service_account.deleted": v.optional( + v.looseObject({ + /** + * The service account ID. + */ + id: v.optional(v.string()), + }), + ), /** - * The type of actor. Is either `session` or `api_key`. + * The details for events with this `type`. */ - type: v.optional(v.picklist(["session", "api_key"])), - session: v.optional(inputAuditLogActorSessionSchema), - api_key: v.optional(inputAuditLogActorApiKeySchema), -}); -export const auditLogActorSchema = v.looseObject({ + "user.added": v.optional( + v.looseObject({ + /** + * The user ID. + */ + id: v.optional(v.string()), + /** + * The payload used to add the user to the project. + */ + data: v.optional( + v.looseObject({ + /** + * The role of the user. Is either `owner` or `member`. + */ + role: v.optional(v.string()), + }), + ), + }), + ), /** - * The type of actor. Is either `session` or `api_key`. + * The details for events with this `type`. */ - type: v.exactOptional(v.picklist(["session", "api_key"])), - session: v.exactOptional(auditLogActorSessionSchema), - api_key: v.exactOptional(auditLogActorApiKeySchema), + "user.updated": v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: v.optional(v.string()), + /** + * The payload used to update the user. + */ + changes_requested: v.optional( + v.looseObject({ + /** + * The role of the user. Is either `owner` or `member`. + */ + role: v.optional(v.string()), + }), + ), + }), + ), + /** + * The details for events with this `type`. + */ + "user.deleted": v.optional( + v.looseObject({ + /** + * The user ID. + */ + id: v.optional(v.string()), + }), + ), }); -/** The event type. */ -export const inputAuditLogEventTypeSchema = v.picklist([ - "api_key.created", - "api_key.updated", - "api_key.deleted", - "invite.sent", - "invite.accepted", - "invite.deleted", - "login.succeeded", - "login.failed", - "logout.succeeded", - "logout.failed", - "organization.updated", - "project.created", - "project.updated", - "project.archived", - "service_account.created", - "service_account.updated", - "service_account.deleted", - "user.added", - "user.updated", - "user.deleted", -]); -export const auditLogEventTypeSchema = inputAuditLogEventTypeSchema; -/** A log of a user action or configuration change within this organization. */ -export const inputAuditLogSchema = v.looseObject({ +export const auditLogSchema = v.looseObject({ /** * The ID of this log. */ - id: v.string(), - type: inputAuditLogEventTypeSchema, + id: v.pipe(v.string(), v.trim()), + type: auditLogEventTypeSchema, /** * The Unix timestamp (in seconds) of the event. */ @@ -4179,37 +3196,37 @@ export const inputAuditLogSchema = v.looseObject({ * The project that the action was scoped to. Absent for actions not scoped to * projects. */ - project: v.optional( + project: v.exactOptional( v.looseObject({ /** * The project ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The project title. */ - name: v.optional(v.string()), + name: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), - actor: inputAuditLogActorSchema, + actor: auditLogActorSchema, /** * The details for events with this `type`. */ - "api_key.created": v.optional( + "api_key.created": v.exactOptional( v.looseObject({ /** * The tracking ID of the API key. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The payload used to create the API key. */ - data: v.optional( + data: v.exactOptional( v.looseObject({ /** * A list of scopes allowed for the API key, e.g. `["api.model.request"]` */ - scopes: v.optional(v.array(v.string())), + scopes: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), }), ), }), @@ -4217,21 +3234,21 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "api_key.updated": v.optional( + "api_key.updated": v.exactOptional( v.looseObject({ /** * The tracking ID of the API key. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The payload used to update the API key. */ - changes_requested: v.optional( + changes_requested: v.exactOptional( v.looseObject({ /** * A list of scopes allowed for the API key, e.g. `["api.model.request"]` */ - scopes: v.optional(v.array(v.string())), + scopes: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), }), ), }), @@ -4239,36 +3256,162 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "api_key.deleted": v.optional( + "api_key.deleted": v.exactOptional( v.looseObject({ /** * The tracking ID of the API key. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), /** * The details for events with this `type`. */ - "invite.sent": v.optional( + "invite.sent": v.exactOptional( v.looseObject({ /** * The ID of the invite. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The payload used to create the invite. */ - data: v.optional( + data: v.exactOptional( v.looseObject({ /** * The email invited to the organization. */ - email: v.optional(v.string()), + email: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The role the email was invited to be. Is either `owner` or `member`. */ - role: v.optional(v.string()), + role: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + }), + ), + /** + * The details for events with this `type`. + */ + "invite.accepted": v.exactOptional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + /** + * The details for events with this `type`. + */ + "invite.deleted": v.exactOptional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + /** + * The details for events with this `type`. + */ + "login.failed": v.exactOptional( + v.looseObject({ + /** + * The error code of the failure. + */ + error_code: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The error message of the failure. + */ + error_message: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + /** + * The details for events with this `type`. + */ + "logout.failed": v.exactOptional( + v.looseObject({ + /** + * The error code of the failure. + */ + error_code: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The error message of the failure. + */ + error_message: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + /** + * The details for events with this `type`. + */ + "organization.updated": v.exactOptional( + v.looseObject({ + /** + * The organization ID. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The payload used to update the organization settings. + */ + changes_requested: v.exactOptional( + v.looseObject({ + /** + * The organization title. + */ + title: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The organization description. + */ + description: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The organization name. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + settings: v.exactOptional( + v.looseObject({ + /** + * Visibility of the threads page which shows messages created with the + * Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. + */ + threads_ui_visibility: v.exactOptional( + v.pipe(v.string(), v.trim()), + ), + /** + * Visibility of the usage dashboard which shows activity and costs for your + * organization. One of `ANY_ROLE` or `OWNERS`. + */ + usage_dashboard_visibility: v.exactOptional( + v.pipe(v.string(), v.trim()), + ), + }), + ), + }), + ), + }), + ), + /** + * The details for events with this `type`. + */ + "project.created": v.exactOptional( + v.looseObject({ + /** + * The project ID. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The payload used to create the project. + */ + data: v.exactOptional( + v.looseObject({ + /** + * The project name. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The title of the project as seen on the dashboard. + */ + title: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), }), @@ -4276,121 +3419,109 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "invite.accepted": v.optional( + "project.updated": v.exactOptional( v.looseObject({ /** - * The ID of the invite. + * The project ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The payload used to update the project. + */ + changes_requested: v.exactOptional( + v.looseObject({ + /** + * The title of the project as seen on the dashboard. + */ + title: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), }), ), /** * The details for events with this `type`. */ - "invite.deleted": v.optional( + "project.archived": v.exactOptional( v.looseObject({ /** - * The ID of the invite. + * The project ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), /** * The details for events with this `type`. */ - "login.failed": v.optional( + "service_account.created": v.exactOptional( v.looseObject({ /** - * The error code of the failure. + * The service account ID. */ - error_code: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The error message of the failure. + * The payload used to create the service account. */ - error_message: v.optional(v.string()), + data: v.exactOptional( + v.looseObject({ + /** + * The role of the service account. Is either `owner` or `member`. + */ + role: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), }), ), /** * The details for events with this `type`. */ - "logout.failed": v.optional( + "service_account.updated": v.exactOptional( v.looseObject({ /** - * The error code of the failure. + * The service account ID. */ - error_code: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The error message of the failure. + * The payload used to updated the service account. */ - error_message: v.optional(v.string()), + changes_requested: v.exactOptional( + v.looseObject({ + /** + * The role of the service account. Is either `owner` or `member`. + */ + role: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), }), ), /** * The details for events with this `type`. */ - "organization.updated": v.optional( + "service_account.deleted": v.exactOptional( v.looseObject({ /** - * The organization ID. - */ - id: v.optional(v.string()), - /** - * The payload used to update the organization settings. + * The service account ID. */ - changes_requested: v.optional( - v.looseObject({ - /** - * The organization title. - */ - title: v.optional(v.string()), - /** - * The organization description. - */ - description: v.optional(v.string()), - /** - * The organization name. - */ - name: v.optional(v.string()), - settings: v.optional( - v.looseObject({ - /** - * Visibility of the threads page which shows messages created with the - * Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. - */ - threads_ui_visibility: v.optional(v.string()), - /** - * Visibility of the usage dashboard which shows activity and costs for your - * organization. One of `ANY_ROLE` or `OWNERS`. - */ - usage_dashboard_visibility: v.optional(v.string()), - }), - ), - }), - ), + id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), /** * The details for events with this `type`. */ - "project.created": v.optional( + "user.added": v.exactOptional( v.looseObject({ /** - * The project ID. + * The user ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The payload used to create the project. + * The payload used to add the user to the project. */ - data: v.optional( + data: v.exactOptional( v.looseObject({ /** - * The project name. - */ - name: v.optional(v.string()), - /** - * The title of the project as seen on the dashboard. + * The role of the user. Is either `owner` or `member`. */ - title: v.optional(v.string()), + role: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), }), @@ -4398,21 +3529,21 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "project.updated": v.optional( + "user.updated": v.exactOptional( v.looseObject({ /** * The project ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The payload used to update the project. + * The payload used to update the user. */ - changes_requested: v.optional( + changes_requested: v.exactOptional( v.looseObject({ /** - * The title of the project as seen on the dashboard. + * The role of the user. Is either `owner` or `member`. */ - title: v.optional(v.string()), + role: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), }), @@ -4420,641 +3551,1060 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "project.archived": v.optional( + "user.deleted": v.exactOptional( v.looseObject({ /** - * The project ID. + * The user ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), +}); +export const inputListAuditLogsResponseSchema = v.looseObject({ + object: v.picklist(["list"]), + data: v.array(inputAuditLogSchema), + first_id: v.string(), + last_id: v.string(), + has_more: v.boolean(), +}); +export const listAuditLogsResponseSchema = v.looseObject({ + object: v.picklist(["list"]), + data: v.array(auditLogSchema), + first_id: v.pipe(v.string(), v.trim()), + last_id: v.pipe(v.string(), v.trim()), + has_more: v.boolean(), +}); +export const inputBatchSchema = v.looseObject({ + id: v.string(), /** - * The details for events with this `type`. + * The object type, which is always `batch`. */ - "service_account.created": v.optional( + object: v.picklist(["batch"]), + /** + * The OpenAI API endpoint used by the batch. + */ + endpoint: v.string(), + errors: v.optional( v.looseObject({ /** - * The service account ID. - */ - id: v.optional(v.string()), - /** - * The payload used to create the service account. + * The object type, which is always `list`. */ + object: v.optional(v.string()), data: v.optional( - v.looseObject({ - /** - * The role of the service account. Is either `owner` or `member`. - */ - role: v.optional(v.string()), - }), + v.array( + v.looseObject({ + /** + * An error code identifying the error type. + */ + code: v.optional(v.string()), + /** + * A human-readable message providing more details about the error. + */ + message: v.optional(v.string()), + /** + * The name of the parameter that caused the error, if applicable. + */ + param: v.optional(v.nullable(v.string())), + /** + * The line number of the input file where the error occurred, if applicable. + */ + line: v.optional(v.nullable(v.pipe(v.number(), v.integer()))), + }), + ), ), }), ), /** - * The details for events with this `type`. + * The ID of the input file for the batch. + */ + input_file_id: v.string(), + /** + * The time frame within which the batch should be processed. + */ + completion_window: v.string(), + /** + * The current status of the batch. + */ + status: v.picklist([ + "validating", + "failed", + "in_progress", + "finalizing", + "completed", + "expired", + "cancelling", + "cancelled", + ]), + /** + * The ID of the file containing the outputs of successfully executed + * requests. + */ + output_file_id: v.optional(v.string()), + /** + * The ID of the file containing the outputs of requests with errors. + */ + error_file_id: v.optional(v.string()), + /** + * The Unix timestamp (in seconds) for when the batch was created. + */ + created_at: v.pipe(v.number(), v.integer()), + /** + * The Unix timestamp (in seconds) for when the batch started processing. + */ + in_progress_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch will expire. + */ + expires_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch started finalizing. + */ + finalizing_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch was completed. + */ + completed_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch failed. + */ + failed_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch expired. + */ + expired_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch started cancelling. + */ + cancelling_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch was cancelled. + */ + cancelled_at: v.optional(v.pipe(v.number(), v.integer())), + /** + * The request counts for different statuses within the batch. */ - "service_account.updated": v.optional( + request_counts: v.optional( v.looseObject({ /** - * The service account ID. + * Total number of requests in the batch. */ - id: v.optional(v.string()), + total: v.pipe(v.number(), v.integer()), /** - * The payload used to updated the service account. + * Number of requests that have been completed successfully. */ - changes_requested: v.optional( - v.looseObject({ - /** - * The role of the service account. Is either `owner` or `member`. - */ - role: v.optional(v.string()), - }), - ), - }), - ), - /** - * The details for events with this `type`. - */ - "service_account.deleted": v.optional( - v.looseObject({ + completed: v.pipe(v.number(), v.integer()), /** - * The service account ID. + * Number of requests that have failed. */ - id: v.optional(v.string()), + failed: v.pipe(v.number(), v.integer()), }), ), /** - * The details for events with this `type`. + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. */ - "user.added": v.optional( - v.looseObject({ - /** - * The user ID. - */ - id: v.optional(v.string()), - /** - * The payload used to add the user to the project. - */ - data: v.optional( - v.looseObject({ - /** - * The role of the user. Is either `owner` or `member`. - */ - role: v.optional(v.string()), - }), - ), - }), - ), + metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), +}); +export const batchSchema = v.looseObject({ + id: v.pipe(v.string(), v.trim()), /** - * The details for events with this `type`. + * The object type, which is always `batch`. */ - "user.updated": v.optional( + object: v.picklist(["batch"]), + /** + * The OpenAI API endpoint used by the batch. + */ + endpoint: v.pipe(v.string(), v.trim()), + errors: v.exactOptional( v.looseObject({ /** - * The project ID. - */ - id: v.optional(v.string()), - /** - * The payload used to update the user. + * The object type, which is always `list`. */ - changes_requested: v.optional( - v.looseObject({ - /** - * The role of the user. Is either `owner` or `member`. - */ - role: v.optional(v.string()), - }), + object: v.exactOptional(v.pipe(v.string(), v.trim())), + data: v.exactOptional( + v.array( + v.looseObject({ + /** + * An error code identifying the error type. + */ + code: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * A human-readable message providing more details about the error. + */ + message: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The name of the parameter that caused the error, if applicable. + */ + param: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + /** + * The line number of the input file where the error occurred, if applicable. + */ + line: v.exactOptional(v.nullable(v.pipe(v.number(), v.integer()))), + }), + ), ), }), ), /** - * The details for events with this `type`. + * The ID of the input file for the batch. */ - "user.deleted": v.optional( - v.looseObject({ - /** - * The user ID. - */ - id: v.optional(v.string()), - }), - ), -}); -export const auditLogSchema = v.looseObject({ + input_file_id: v.pipe(v.string(), v.trim()), /** - * The ID of this log. + * The time frame within which the batch should be processed. */ - id: v.pipe(v.string(), v.trim()), - type: auditLogEventTypeSchema, + completion_window: v.pipe(v.string(), v.trim()), /** - * The Unix timestamp (in seconds) of the event. + * The current status of the batch. */ - effective_at: v.pipe(v.number(), v.integer()), + status: v.picklist([ + "validating", + "failed", + "in_progress", + "finalizing", + "completed", + "expired", + "cancelling", + "cancelled", + ]), /** - * The project that the action was scoped to. Absent for actions not scoped to - * projects. + * The ID of the file containing the outputs of successfully executed + * requests. */ - project: v.exactOptional( - v.looseObject({ - /** - * The project ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The project title. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - actor: auditLogActorSchema, + output_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The details for events with this `type`. + * The ID of the file containing the outputs of requests with errors. */ - "api_key.created": v.exactOptional( + error_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The Unix timestamp (in seconds) for when the batch was created. + */ + created_at: v.pipe(v.number(), v.integer()), + /** + * The Unix timestamp (in seconds) for when the batch started processing. + */ + in_progress_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch will expire. + */ + expires_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch started finalizing. + */ + finalizing_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch was completed. + */ + completed_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch failed. + */ + failed_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch expired. + */ + expired_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch started cancelling. + */ + cancelling_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The Unix timestamp (in seconds) for when the batch was cancelled. + */ + cancelled_at: v.exactOptional(v.pipe(v.number(), v.integer())), + /** + * The request counts for different statuses within the batch. + */ + request_counts: v.exactOptional( v.looseObject({ /** - * The tracking ID of the API key. + * Total number of requests in the batch. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + total: v.pipe(v.number(), v.integer()), /** - * The payload used to create the API key. + * Number of requests that have been completed successfully. */ - data: v.exactOptional( - v.looseObject({ - /** - * A list of scopes allowed for the API key, e.g. `["api.model.request"]` - */ - scopes: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), - }), - ), + completed: v.pipe(v.number(), v.integer()), + /** + * Number of requests that have failed. + */ + failed: v.pipe(v.number(), v.integer()), }), ), /** - * The details for events with this `type`. + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), +}); +export const inputListBatchesResponseSchema = v.looseObject({ + data: v.array(inputBatchSchema), + first_id: v.optional(v.string()), + last_id: v.optional(v.string()), + has_more: v.boolean(), + object: v.picklist(["list"]), +}); +export const listBatchesResponseSchema = v.looseObject({ + data: v.array(batchSchema), + first_id: v.exactOptional(v.pipe(v.string(), v.trim())), + last_id: v.exactOptional(v.pipe(v.string(), v.trim())), + has_more: v.boolean(), + object: v.picklist(["list"]), +}); +/** Occurs when a stream ends. */ +export const inputDoneEventSchema = v.looseObject({ + event: v.picklist(["done"]), + data: v.picklist(["[DONE]"]), +}); +export const doneEventSchema = inputDoneEventSchema; +export const inputErrorSchema = v.looseObject({ + code: v.nullable(v.string()), + message: v.string(), + param: v.nullable(v.string()), + type: v.string(), +}); +export const errorSchema = v.looseObject({ + code: v.nullable(v.pipe(v.string(), v.trim())), + message: v.pipe(v.string(), v.trim()), + param: v.nullable(v.pipe(v.string(), v.trim())), + type: v.pipe(v.string(), v.trim()), +}); +/** + * Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This + * can happen due to an internal server error or a timeout. + */ +export const inputErrorEventSchema = v.looseObject({ + event: v.picklist(["error"]), + data: inputErrorSchema, +}); +export const errorEventSchema = inputErrorEventSchema; +/** + * References an image URL in the content of a message. + * @title Image URL + */ +export const inputMessageDeltaContentImageUrlObjectSchema = v.looseObject({ + /** + * The index of the content part in the message. */ - "api_key.updated": v.exactOptional( + index: v.pipe(v.number(), v.integer()), + /** + * Always `image_url`. + */ + type: v.picklist(["image_url"]), + image_url: v.optional( v.looseObject({ /** - * The tracking ID of the API key. + * The URL of the image, must be a supported image types: jpeg, jpg, png, gif, + * webp. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + url: v.optional(v.string()), /** - * The payload used to update the API key. + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. */ - changes_requested: v.exactOptional( - v.looseObject({ - /** - * A list of scopes allowed for the API key, e.g. `["api.model.request"]` - */ - scopes: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), - }), - ), + detail: v.optional(v.picklist(["auto", "low", "high"])), }), ), +}); +export const messageDeltaContentImageUrlObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "api_key.deleted": v.exactOptional( - v.looseObject({ - /** - * The tracking ID of the API key. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `image_url`. */ - "invite.sent": v.exactOptional( + type: v.picklist(["image_url"]), + image_url: v.exactOptional( v.looseObject({ /** - * The ID of the invite. + * The URL of the image, must be a supported image types: jpeg, jpg, png, gif, + * webp. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + url: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The payload used to create the invite. + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. */ - data: v.exactOptional( - v.looseObject({ - /** - * The email invited to the organization. - */ - email: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The role the email was invited to be. Is either `owner` or `member`. - */ - role: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + detail: v.exactOptional(v.picklist(["auto", "low", "high"])), }), ), +}); +/** + * The refusal content that is part of a message. + * @title Refusal + */ +export const inputMessageDeltaContentRefusalObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the refusal part in the message. */ - "invite.accepted": v.exactOptional( - v.looseObject({ - /** - * The ID of the invite. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `refusal`. */ - "invite.deleted": v.exactOptional( - v.looseObject({ - /** - * The ID of the invite. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + type: v.picklist(["refusal"]), + refusal: v.optional(v.string()), +}); +export const messageDeltaContentRefusalObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the refusal part in the message. */ - "login.failed": v.exactOptional( - v.looseObject({ - /** - * The error code of the failure. - */ - error_code: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The error message of the failure. - */ - error_message: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + index: v.pipe(v.number(), v.integer()), + /** + * Always `refusal`. + */ + type: v.picklist(["refusal"]), + refusal: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +/** + * A URL for the file that's generated when the assistant used the + * `code_interpreter` tool to generate a file. + * @title File path + */ +export const inputMessageDeltaContentTextAnnotationsFilePathObjectSchema = + v.looseObject({ + /** + * The index of the annotation in the text content part. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `file_path`. + */ + type: v.picklist(["file_path"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.optional(v.string()), + file_path: v.optional( + v.looseObject({ + /** + * The ID of the file that was generated. + */ + file_id: v.optional(v.string()), + }), + ), + start_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), + end_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), + }); +export const messageDeltaContentTextAnnotationsFilePathObjectSchema = + v.looseObject({ + /** + * The index of the annotation in the text content part. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `file_path`. + */ + type: v.picklist(["file_path"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.exactOptional(v.pipe(v.string(), v.trim())), + file_path: v.exactOptional( + v.looseObject({ + /** + * The ID of the file that was generated. + */ + file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + start_index: v.exactOptional( + v.pipe(v.number(), v.integer(), v.minValue(0)), + ), + end_index: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0))), + }); +/** + * A citation within the message that points to a specific quote from a + * specific File associated with the assistant or the message. Generated when + * the assistant uses the "file_search" tool to search files. + * @title File citation + */ +export const inputMessageDeltaContentTextAnnotationsFileCitationObjectSchema = + v.looseObject({ + /** + * The index of the annotation in the text content part. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `file_citation`. + */ + type: v.picklist(["file_citation"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.optional(v.string()), + file_citation: v.optional( + v.looseObject({ + /** + * The ID of the specific File the citation is from. + */ + file_id: v.optional(v.string()), + /** + * The specific quote in the file. + */ + quote: v.optional(v.string()), + }), + ), + start_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), + end_index: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0))), + }); +export const messageDeltaContentTextAnnotationsFileCitationObjectSchema = + v.looseObject({ + /** + * The index of the annotation in the text content part. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `file_citation`. + */ + type: v.picklist(["file_citation"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.exactOptional(v.pipe(v.string(), v.trim())), + file_citation: v.exactOptional( + v.looseObject({ + /** + * The ID of the specific File the citation is from. + */ + file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The specific quote in the file. + */ + quote: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + start_index: v.exactOptional( + v.pipe(v.number(), v.integer(), v.minValue(0)), + ), + end_index: v.exactOptional(v.pipe(v.number(), v.integer(), v.minValue(0))), + }); +/** + * The text content that is part of a message. + * @title Text + */ +export const inputMessageDeltaContentTextObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "logout.failed": v.exactOptional( - v.looseObject({ - /** - * The error code of the failure. - */ - error_code: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The error message of the failure. - */ - error_message: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `text`. */ - "organization.updated": v.exactOptional( + type: v.picklist(["text"]), + text: v.optional( v.looseObject({ /** - * The organization ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to update the organization settings. + * The data that makes up the text. */ - changes_requested: v.exactOptional( - v.looseObject({ - /** - * The organization title. - */ - title: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The organization description. - */ - description: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The organization name. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - settings: v.exactOptional( - v.looseObject({ - /** - * Visibility of the threads page which shows messages created with the - * Assistants API and Playground. One of `ANY_ROLE`, `OWNERS`, or `NONE`. - */ - threads_ui_visibility: v.exactOptional( - v.pipe(v.string(), v.trim()), - ), - /** - * Visibility of the usage dashboard which shows activity and costs for your - * organization. One of `ANY_ROLE` or `OWNERS`. - */ - usage_dashboard_visibility: v.exactOptional( - v.pipe(v.string(), v.trim()), - ), - }), - ), - }), + value: v.optional(v.string()), + annotations: v.optional( + v.array( + v.union([ + inputMessageDeltaContentTextAnnotationsFileCitationObjectSchema, + inputMessageDeltaContentTextAnnotationsFilePathObjectSchema, + ]), + ), ), }), ), +}); +export const messageDeltaContentTextObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "project.created": v.exactOptional( + index: v.pipe(v.number(), v.integer()), + /** + * Always `text`. + */ + type: v.picklist(["text"]), + text: v.exactOptional( v.looseObject({ /** - * The project ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to create the project. + * The data that makes up the text. */ - data: v.exactOptional( - v.looseObject({ - /** - * The project name. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The title of the project as seen on the dashboard. - */ - title: v.exactOptional(v.pipe(v.string(), v.trim())), - }), + value: v.exactOptional(v.pipe(v.string(), v.trim())), + annotations: v.exactOptional( + v.array( + v.union([ + messageDeltaContentTextAnnotationsFileCitationObjectSchema, + messageDeltaContentTextAnnotationsFilePathObjectSchema, + ]), + ), ), }), ), +}); +/** + * References an image [File](/docs/api-reference/files) in the content of a + * message. + * @title Image file + */ +export const inputMessageDeltaContentImageFileObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "project.updated": v.exactOptional( + index: v.pipe(v.number(), v.integer()), + /** + * Always `image_file`. + */ + type: v.picklist(["image_file"]), + image_file: v.optional( v.looseObject({ /** - * The project ID. + * The [File](/docs/api-reference/files) ID of the image in the message + * content. Set `purpose="vision"` when uploading the File if you need to + * later display the file content. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + file_id: v.optional(v.string()), /** - * The payload used to update the project. + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. */ - changes_requested: v.exactOptional( - v.looseObject({ - /** - * The title of the project as seen on the dashboard. - */ - title: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + detail: v.optional(v.picklist(["auto", "low", "high"])), }), ), +}); +export const messageDeltaContentImageFileObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "project.archived": v.exactOptional( - v.looseObject({ - /** - * The project ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `image_file`. */ - "service_account.created": v.exactOptional( + type: v.picklist(["image_file"]), + image_file: v.exactOptional( v.looseObject({ /** - * The service account ID. + * The [File](/docs/api-reference/files) ID of the image in the message + * content. Set `purpose="vision"` when uploading the File if you need to + * later display the file content. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + file_id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The payload used to create the service account. + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. */ - data: v.exactOptional( - v.looseObject({ - /** - * The role of the service account. Is either `owner` or `member`. - */ - role: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + detail: v.exactOptional(v.picklist(["auto", "low", "high"])), }), ), +}); +/** + * Represents a message delta i.e. any changed fields on a message during + * streaming. + * @title Message delta object + */ +export const inputMessageDeltaObjectSchema = v.looseObject({ + /** + * The identifier of the message, which can be referenced in API endpoints. + */ + id: v.string(), + /** + * The object type, which is always `thread.message.delta`. + */ + object: v.picklist(["thread.message.delta"]), + /** + * The delta containing the fields that have changed on the Message. + */ + delta: v.looseObject({ + /** + * The entity that produced the message. One of `user` or `assistant`. + */ + role: v.optional(v.picklist(["user", "assistant"])), + /** + * The content of the message in array of text and/or images. + */ + content: v.optional( + v.array( + v.union([ + inputMessageDeltaContentImageFileObjectSchema, + inputMessageDeltaContentTextObjectSchema, + inputMessageDeltaContentRefusalObjectSchema, + inputMessageDeltaContentImageUrlObjectSchema, + ]), + ), + ), + }), +}); +export const messageDeltaObjectSchema = v.looseObject({ + /** + * The identifier of the message, which can be referenced in API endpoints. + */ + id: v.pipe(v.string(), v.trim()), + /** + * The object type, which is always `thread.message.delta`. + */ + object: v.picklist(["thread.message.delta"]), + /** + * The delta containing the fields that have changed on the Message. + */ + delta: v.looseObject({ + /** + * The entity that produced the message. One of `user` or `assistant`. + */ + role: v.exactOptional(v.picklist(["user", "assistant"])), + /** + * The content of the message in array of text and/or images. + */ + content: v.exactOptional( + v.array( + v.union([ + messageDeltaContentImageFileObjectSchema, + messageDeltaContentTextObjectSchema, + messageDeltaContentRefusalObjectSchema, + messageDeltaContentImageUrlObjectSchema, + ]), + ), + ), + }), +}); +export const inputAssistantToolsFileSearchTypeOnlySchema = v.looseObject({ + /** + * The type of tool being defined: `file_search` + */ + type: v.picklist(["file_search"]), +}); +export const assistantToolsFileSearchTypeOnlySchema = + inputAssistantToolsFileSearchTypeOnlySchema; +export const inputAssistantToolsCodeSchema = v.looseObject({ + /** + * The type of tool being defined: `code_interpreter` + */ + type: v.picklist(["code_interpreter"]), +}); +export const assistantToolsCodeSchema = inputAssistantToolsCodeSchema; +/** + * The refusal content generated by the assistant. + * @title Refusal + */ +export const inputMessageContentRefusalObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * Always `refusal`. */ - "service_account.updated": v.exactOptional( - v.looseObject({ - /** - * The service account ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to updated the service account. - */ - changes_requested: v.exactOptional( - v.looseObject({ - /** - * The role of the service account. Is either `owner` or `member`. - */ - role: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - }), - ), + type: v.picklist(["refusal"]), + refusal: v.string(), +}); +export const messageContentRefusalObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * Always `refusal`. */ - "service_account.deleted": v.exactOptional( - v.looseObject({ + type: v.picklist(["refusal"]), + refusal: v.pipe(v.string(), v.trim()), +}); +/** + * A URL for the file that's generated when the assistant used the + * `code_interpreter` tool to generate a file. + * @title File path + */ +export const inputMessageContentTextAnnotationsFilePathObjectSchema = + v.looseObject({ + /** + * Always `file_path`. + */ + type: v.picklist(["file_path"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.string(), + file_path: v.looseObject({ /** - * The service account ID. + * The ID of the file that was generated. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + file_id: v.string(), }), - ), + start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + }); +export const messageContentTextAnnotationsFilePathObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * Always `file_path`. */ - "user.added": v.exactOptional( - v.looseObject({ - /** - * The user ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to add the user to the project. - */ - data: v.exactOptional( - v.looseObject({ - /** - * The role of the user. Is either `owner` or `member`. - */ - role: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - }), - ), + type: v.picklist(["file_path"]), /** - * The details for events with this `type`. + * The text in the message content that needs to be replaced. */ - "user.updated": v.exactOptional( - v.looseObject({ + text: v.pipe(v.string(), v.trim()), + file_path: v.looseObject({ + /** + * The ID of the file that was generated. + */ + file_id: v.pipe(v.string(), v.trim()), + }), + start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), +}); +/** + * A citation within the message that points to a specific quote from a + * specific File associated with the assistant or the message. Generated when + * the assistant uses the "file_search" tool to search files. + * @title File citation + */ +export const inputMessageContentTextAnnotationsFileCitationObjectSchema = + v.looseObject({ + /** + * Always `file_citation`. + */ + type: v.picklist(["file_citation"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.string(), + file_citation: v.looseObject({ /** - * The project ID. + * The ID of the specific File the citation is from. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + file_id: v.string(), + }), + start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + }); +export const messageContentTextAnnotationsFileCitationObjectSchema = + v.looseObject({ + /** + * Always `file_citation`. + */ + type: v.picklist(["file_citation"]), + /** + * The text in the message content that needs to be replaced. + */ + text: v.pipe(v.string(), v.trim()), + file_citation: v.looseObject({ /** - * The payload used to update the user. + * The ID of the specific File the citation is from. */ - changes_requested: v.exactOptional( - v.looseObject({ - /** - * The role of the user. Is either `owner` or `member`. - */ - role: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + file_id: v.pipe(v.string(), v.trim()), }), - ), + start_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + end_index: v.pipe(v.number(), v.integer(), v.minValue(0)), + }); +/** + * The text content that is part of a message. + * @title Text + */ +export const inputMessageContentTextObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * Always `text`. */ - "user.deleted": v.exactOptional( - v.looseObject({ - /** - * The user ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), -}); -export const inputListAuditLogsResponseSchema = v.looseObject({ - object: v.picklist(["list"]), - data: v.array(inputAuditLogSchema), - first_id: v.string(), - last_id: v.string(), - has_more: v.boolean(), -}); -export const listAuditLogsResponseSchema = v.looseObject({ - object: v.picklist(["list"]), - data: v.array(auditLogSchema), - first_id: v.pipe(v.string(), v.trim()), - last_id: v.pipe(v.string(), v.trim()), - has_more: v.boolean(), + type: v.picklist(["text"]), + text: v.looseObject({ + /** + * The data that makes up the text. + */ + value: v.string(), + annotations: v.array( + v.union([ + inputMessageContentTextAnnotationsFileCitationObjectSchema, + inputMessageContentTextAnnotationsFilePathObjectSchema, + ]), + ), + }), }); -export const inputBatchSchema = v.looseObject({ - id: v.string(), +export const messageContentTextObjectSchema = v.looseObject({ /** - * The object type, which is always `batch`. + * Always `text`. */ - object: v.picklist(["batch"]), + type: v.picklist(["text"]), + text: v.looseObject({ + /** + * The data that makes up the text. + */ + value: v.pipe(v.string(), v.trim()), + annotations: v.array( + v.union([ + messageContentTextAnnotationsFileCitationObjectSchema, + messageContentTextAnnotationsFilePathObjectSchema, + ]), + ), + }), +}); +/** + * References an image URL in the content of a message. + * @title Image URL + */ +export const inputMessageContentImageUrlObjectSchema = v.looseObject({ /** - * The OpenAI API endpoint used by the batch. + * The type of the content part. */ - endpoint: v.string(), - errors: v.optional( - v.looseObject({ - /** - * The object type, which is always `list`. - */ - object: v.optional(v.string()), - data: v.optional( - v.array( - v.looseObject({ - /** - * An error code identifying the error type. - */ - code: v.optional(v.string()), - /** - * A human-readable message providing more details about the error. - */ - message: v.optional(v.string()), - /** - * The name of the parameter that caused the error, if applicable. - */ - param: v.optional(v.nullable(v.string())), - /** - * The line number of the input file where the error occurred, if applicable. - */ - line: v.optional(v.nullable(v.pipe(v.number(), v.integer()))), - }), - ), - ), - }), - ), + type: v.picklist(["image_url"]), + image_url: v.looseObject({ + /** + * The external URL of the image, must be a supported image types: jpeg, jpg, + * png, gif, webp. + */ + url: v.string(), + /** + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. Default value is `auto` + */ + detail: v.optional(v.picklist(["auto", "low", "high"])), + }), +}); +export const messageContentImageUrlObjectSchema = v.looseObject({ /** - * The ID of the input file for the batch. + * The type of the content part. */ - input_file_id: v.string(), + type: v.picklist(["image_url"]), + image_url: v.looseObject({ + /** + * The external URL of the image, must be a supported image types: jpeg, jpg, + * png, gif, webp. + */ + url: v.pipe(v.string(), v.trim()), + /** + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. Default value is `auto` + */ + detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + }), +}); +/** + * References an image [File](/docs/api-reference/files) in the content of a + * message. + * @title Image file + */ +export const inputMessageContentImageFileObjectSchema = v.looseObject({ /** - * The time frame within which the batch should be processed. + * Always `image_file`. */ - completion_window: v.string(), + type: v.picklist(["image_file"]), + image_file: v.looseObject({ + /** + * The [File](/docs/api-reference/files) ID of the image in the message + * content. Set `purpose="vision"` when uploading the File if you need to + * later display the file content. + */ + file_id: v.string(), + /** + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. + */ + detail: v.optional(v.picklist(["auto", "low", "high"])), + }), +}); +export const messageContentImageFileObjectSchema = v.looseObject({ /** - * The current status of the batch. + * Always `image_file`. */ - status: v.picklist([ - "validating", - "failed", - "in_progress", - "finalizing", - "completed", - "expired", - "cancelling", - "cancelled", - ]), + type: v.picklist(["image_file"]), + image_file: v.looseObject({ + /** + * The [File](/docs/api-reference/files) ID of the image in the message + * content. Set `purpose="vision"` when uploading the File if you need to + * later display the file content. + */ + file_id: v.pipe(v.string(), v.trim()), + /** + * Specifies the detail level of the image if specified by the user. `low` + * uses fewer tokens, you can opt in to high resolution using `high`. + */ + detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + }), +}); +/** + * Represents a message within a [thread](/docs/api-reference/threads). + * @title The message object + */ +export const inputMessageObjectSchema = v.looseObject({ /** - * The ID of the file containing the outputs of successfully executed - * requests. + * The identifier, which can be referenced in API endpoints. */ - output_file_id: v.optional(v.string()), + id: v.string(), /** - * The ID of the file containing the outputs of requests with errors. + * The object type, which is always `thread.message`. */ - error_file_id: v.optional(v.string()), + object: v.picklist(["thread.message"]), /** - * The Unix timestamp (in seconds) for when the batch was created. + * The Unix timestamp (in seconds) for when the message was created. */ created_at: v.pipe(v.number(), v.integer()), /** - * The Unix timestamp (in seconds) for when the batch started processing. + * The [thread](/docs/api-reference/threads) ID that this message belongs to. */ - in_progress_at: v.optional(v.pipe(v.number(), v.integer())), + thread_id: v.string(), /** - * The Unix timestamp (in seconds) for when the batch will expire. + * The status of the message, which can be either `in_progress`, `incomplete`, + * or `completed`. */ - expires_at: v.optional(v.pipe(v.number(), v.integer())), + status: v.picklist(["in_progress", "incomplete", "completed"]), /** - * The Unix timestamp (in seconds) for when the batch started finalizing. + * On an incomplete message, details about why the message is incomplete. */ - finalizing_at: v.optional(v.pipe(v.number(), v.integer())), + incomplete_details: v.nullable( + v.looseObject({ + /** + * The reason the message is incomplete. + */ + reason: v.picklist([ + "content_filter", + "max_tokens", + "run_cancelled", + "run_expired", + "run_failed", + ]), + }), + ), /** - * The Unix timestamp (in seconds) for when the batch was completed. + * The Unix timestamp (in seconds) for when the message was completed. */ - completed_at: v.optional(v.pipe(v.number(), v.integer())), + completed_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The Unix timestamp (in seconds) for when the batch failed. + * The Unix timestamp (in seconds) for when the message was marked as + * incomplete. */ - failed_at: v.optional(v.pipe(v.number(), v.integer())), + incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The Unix timestamp (in seconds) for when the batch expired. + * The entity that produced the message. One of `user` or `assistant`. */ - expired_at: v.optional(v.pipe(v.number(), v.integer())), + role: v.picklist(["user", "assistant"]), /** - * The Unix timestamp (in seconds) for when the batch started cancelling. + * The content of the message in array of text and/or images. */ - cancelling_at: v.optional(v.pipe(v.number(), v.integer())), + content: v.array( + v.union([ + inputMessageContentImageFileObjectSchema, + inputMessageContentImageUrlObjectSchema, + inputMessageContentTextObjectSchema, + inputMessageContentRefusalObjectSchema, + ]), + ), /** - * The Unix timestamp (in seconds) for when the batch was cancelled. + * If applicable, the ID of the [assistant](/docs/api-reference/assistants) + * that authored this message. */ - cancelled_at: v.optional(v.pipe(v.number(), v.integer())), + assistant_id: v.nullable(v.string()), /** - * The request counts for different statuses within the batch. + * The ID of the [run](/docs/api-reference/runs) associated with the creation + * of this message. Value is `null` when messages are created manually using + * the create message or create thread endpoints. */ - request_counts: v.optional( - v.looseObject({ - /** - * Total number of requests in the batch. - */ - total: v.pipe(v.number(), v.integer()), - /** - * Number of requests that have been completed successfully. - */ - completed: v.pipe(v.number(), v.integer()), - /** - * Number of requests that have failed. - */ - failed: v.pipe(v.number(), v.integer()), - }), + run_id: v.nullable(v.string()), + /** + * A list of files attached to the message, and the tools they were added to. + */ + attachments: v.nullable( + v.array( + v.looseObject({ + /** + * The ID of the file to attach to the message. + */ + file_id: v.optional(v.string()), + /** + * The tools to add this file to. + */ + tools: v.optional( + v.array( + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchTypeOnlySchema, + ]), + ), + ), + }), + ), ), /** * Set of 16 key-value pairs that can be attached to an object. This can be @@ -5062,132 +4612,105 @@ export const inputBatchSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.nullable(v.record(v.string(), v.unknown())), }); -export const batchSchema = v.looseObject({ - id: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always `batch`. - */ - object: v.picklist(["batch"]), - /** - * The OpenAI API endpoint used by the batch. - */ - endpoint: v.pipe(v.string(), v.trim()), - errors: v.exactOptional( - v.looseObject({ - /** - * The object type, which is always `list`. - */ - object: v.exactOptional(v.pipe(v.string(), v.trim())), - data: v.exactOptional( - v.array( - v.looseObject({ - /** - * An error code identifying the error type. - */ - code: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * A human-readable message providing more details about the error. - */ - message: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The name of the parameter that caused the error, if applicable. - */ - param: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - /** - * The line number of the input file where the error occurred, if applicable. - */ - line: v.exactOptional(v.nullable(v.pipe(v.number(), v.integer()))), - }), - ), - ), - }), - ), - /** - * The ID of the input file for the batch. - */ - input_file_id: v.pipe(v.string(), v.trim()), - /** - * The time frame within which the batch should be processed. - */ - completion_window: v.pipe(v.string(), v.trim()), - /** - * The current status of the batch. - */ - status: v.picklist([ - "validating", - "failed", - "in_progress", - "finalizing", - "completed", - "expired", - "cancelling", - "cancelled", - ]), +export const messageObjectSchema = v.looseObject({ /** - * The ID of the file containing the outputs of successfully executed - * requests. + * The identifier, which can be referenced in API endpoints. */ - output_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + id: v.pipe(v.string(), v.trim()), /** - * The ID of the file containing the outputs of requests with errors. + * The object type, which is always `thread.message`. */ - error_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + object: v.picklist(["thread.message"]), /** - * The Unix timestamp (in seconds) for when the batch was created. + * The Unix timestamp (in seconds) for when the message was created. */ created_at: v.pipe(v.number(), v.integer()), /** - * The Unix timestamp (in seconds) for when the batch started processing. + * The [thread](/docs/api-reference/threads) ID that this message belongs to. */ - in_progress_at: v.exactOptional(v.pipe(v.number(), v.integer())), + thread_id: v.pipe(v.string(), v.trim()), /** - * The Unix timestamp (in seconds) for when the batch will expire. + * The status of the message, which can be either `in_progress`, `incomplete`, + * or `completed`. */ - expires_at: v.exactOptional(v.pipe(v.number(), v.integer())), + status: v.picklist(["in_progress", "incomplete", "completed"]), /** - * The Unix timestamp (in seconds) for when the batch started finalizing. + * On an incomplete message, details about why the message is incomplete. */ - finalizing_at: v.exactOptional(v.pipe(v.number(), v.integer())), + incomplete_details: v.nullable( + v.looseObject({ + /** + * The reason the message is incomplete. + */ + reason: v.picklist([ + "content_filter", + "max_tokens", + "run_cancelled", + "run_expired", + "run_failed", + ]), + }), + ), /** - * The Unix timestamp (in seconds) for when the batch was completed. + * The Unix timestamp (in seconds) for when the message was completed. */ - completed_at: v.exactOptional(v.pipe(v.number(), v.integer())), + completed_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The Unix timestamp (in seconds) for when the batch failed. + * The Unix timestamp (in seconds) for when the message was marked as + * incomplete. */ - failed_at: v.exactOptional(v.pipe(v.number(), v.integer())), + incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The Unix timestamp (in seconds) for when the batch expired. + * The entity that produced the message. One of `user` or `assistant`. */ - expired_at: v.exactOptional(v.pipe(v.number(), v.integer())), + role: v.picklist(["user", "assistant"]), /** - * The Unix timestamp (in seconds) for when the batch started cancelling. + * The content of the message in array of text and/or images. */ - cancelling_at: v.exactOptional(v.pipe(v.number(), v.integer())), + content: v.array( + v.union([ + messageContentImageFileObjectSchema, + messageContentImageUrlObjectSchema, + messageContentTextObjectSchema, + messageContentRefusalObjectSchema, + ]), + ), /** - * The Unix timestamp (in seconds) for when the batch was cancelled. + * If applicable, the ID of the [assistant](/docs/api-reference/assistants) + * that authored this message. */ - cancelled_at: v.exactOptional(v.pipe(v.number(), v.integer())), + assistant_id: v.nullable(v.pipe(v.string(), v.trim())), /** - * The request counts for different statuses within the batch. + * The ID of the [run](/docs/api-reference/runs) associated with the creation + * of this message. Value is `null` when messages are created manually using + * the create message or create thread endpoints. */ - request_counts: v.exactOptional( - v.looseObject({ - /** - * Total number of requests in the batch. - */ - total: v.pipe(v.number(), v.integer()), - /** - * Number of requests that have been completed successfully. - */ - completed: v.pipe(v.number(), v.integer()), - /** - * Number of requests that have failed. - */ - failed: v.pipe(v.number(), v.integer()), - }), + run_id: v.nullable(v.pipe(v.string(), v.trim())), + /** + * A list of files attached to the message, and the tools they were added to. + */ + attachments: v.nullable( + v.array( + v.looseObject({ + /** + * The ID of the file to attach to the message. + */ + file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The tools to add this file to. + */ + tools: v.exactOptional( + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchTypeOnlySchema, + ]), + ), + ), + }), + ), ), /** * Set of 16 key-value pairs that can be attached to an object. This can be @@ -5195,510 +4718,769 @@ export const batchSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), -}); -export const inputListBatchesResponseSchema = v.looseObject({ - data: v.array(inputBatchSchema), - first_id: v.optional(v.string()), - last_id: v.optional(v.string()), - has_more: v.boolean(), - object: v.picklist(["list"]), -}); -export const listBatchesResponseSchema = v.looseObject({ - data: v.array(batchSchema), - first_id: v.exactOptional(v.pipe(v.string(), v.trim())), - last_id: v.exactOptional(v.pipe(v.string(), v.trim())), - has_more: v.boolean(), - object: v.picklist(["list"]), + metadata: v.nullable(v.record(v.string(), v.unknown())), }); -/** - * Represents a message delta i.e. any changed fields on a message during - * streaming. - * @title Message delta object - */ -export const inputMessageDeltaObjectSchema = v.looseObject({ - /** - * The identifier of the message, which can be referenced in API endpoints. - */ - id: v.string(), - /** - * The object type, which is always `thread.message.delta`. - */ - object: v.picklist(["thread.message.delta"]), - /** - * The delta containing the fields that have changed on the Message. - */ - delta: v.looseObject({ +export const inputMessageStreamEventSchema = v.union([ + v.looseObject({ + event: v.picklist(["thread.message.created"]), + data: inputMessageObjectSchema, + }), + v.looseObject({ + event: v.picklist(["thread.message.in_progress"]), + data: inputMessageObjectSchema, + }), + v.looseObject({ + event: v.picklist(["thread.message.delta"]), + data: inputMessageDeltaObjectSchema, + }), + v.looseObject({ + event: v.picklist(["thread.message.completed"]), + data: inputMessageObjectSchema, + }), + v.looseObject({ + event: v.picklist(["thread.message.incomplete"]), + data: inputMessageObjectSchema, + }), +]); +export const messageStreamEventSchema = inputMessageStreamEventSchema; +export const inputRunStepDeltaStepDetailsToolCallsFunctionObjectSchema = + v.looseObject({ + /** + * The index of the tool call in the tool calls array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call object. + */ + id: v.optional(v.string()), + /** + * The type of tool call. This is always going to be `function` for this type + * of tool call. + */ + type: v.picklist(["function"]), + /** + * The definition of the function that was called. + */ + function: v.optional( + v.looseObject({ + /** + * The name of the function. + */ + name: v.optional(v.string()), + /** + * The arguments passed to the function. + */ + arguments: v.optional(v.string()), + /** + * The output of the function. This will be `null` if the outputs have not + * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + */ + output: v.optional(v.nullable(v.string())), + }), + ), + }); +export const runStepDeltaStepDetailsToolCallsFunctionObjectSchema = + v.looseObject({ + /** + * The index of the tool call in the tool calls array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call object. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The type of tool call. This is always going to be `function` for this type + * of tool call. + */ + type: v.picklist(["function"]), + /** + * The definition of the function that was called. + */ + function: v.exactOptional( + v.looseObject({ + /** + * The name of the function. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The arguments passed to the function. + */ + arguments: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The output of the function. This will be `null` if the outputs have not + * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + */ + output: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + }), + ), + }); +export const inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema = + v.looseObject({ + /** + * The index of the tool call in the tool calls array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call object. + */ + id: v.optional(v.string()), + /** + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. + */ + type: v.picklist(["file_search"]), + /** + * For now, this is always going to be an empty object. + */ + file_search: v.record(v.string(), v.unknown()), + }); +export const runStepDeltaStepDetailsToolCallsFileSearchObjectSchema = + v.looseObject({ + /** + * The index of the tool call in the tool calls array. + */ + index: v.pipe(v.number(), v.integer()), /** - * The entity that produced the message. One of `user` or `assistant`. + * The ID of the tool call object. */ - role: v.optional(v.picklist(["user", "assistant"])), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The content of the message in array of text and/or images. + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. */ - content: v.optional( - v.array( - v.union([ - inputMessageDeltaContentImageFileObjectSchema, - inputMessageDeltaContentTextObjectSchema, - inputMessageDeltaContentRefusalObjectSchema, - inputMessageDeltaContentImageUrlObjectSchema, - ]), - ), + type: v.picklist(["file_search"]), + /** + * For now, this is always going to be an empty object. + */ + file_search: v.record(v.string(), v.unknown()), + }); +export const inputRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema = + v.looseObject({ + /** + * The index of the output in the outputs array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `image`. + */ + type: v.picklist(["image"]), + image: v.optional( + v.looseObject({ + /** + * The [file](/docs/api-reference/files) ID of the image. + */ + file_id: v.optional(v.string()), + }), ), - }), -}); -export const messageDeltaObjectSchema = v.looseObject({ - /** - * The identifier of the message, which can be referenced in API endpoints. - */ - id: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always `thread.message.delta`. - */ - object: v.picklist(["thread.message.delta"]), - /** - * The delta containing the fields that have changed on the Message. - */ - delta: v.looseObject({ + }); +export const runStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema = + v.looseObject({ /** - * The entity that produced the message. One of `user` or `assistant`. + * The index of the output in the outputs array. */ - role: v.exactOptional(v.picklist(["user", "assistant"])), + index: v.pipe(v.number(), v.integer()), /** - * The content of the message in array of text and/or images. + * Always `image`. */ - content: v.exactOptional( - v.array( - v.union([ - messageDeltaContentImageFileObjectSchema, - messageDeltaContentTextObjectSchema, - messageDeltaContentRefusalObjectSchema, - messageDeltaContentImageUrlObjectSchema, - ]), - ), + type: v.picklist(["image"]), + image: v.exactOptional( + v.looseObject({ + /** + * The [file](/docs/api-reference/files) ID of the image. + */ + file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + }), ), - }), -}); -/** Occurs when a stream ends. */ -export const inputDoneEventSchema = v.looseObject({ - event: v.picklist(["done"]), - data: v.picklist(["[DONE]"]), -}); -export const doneEventSchema = inputDoneEventSchema; -export const inputErrorSchema = v.looseObject({ - code: v.nullable(v.string()), - message: v.string(), - param: v.nullable(v.string()), - type: v.string(), -}); -export const errorSchema = v.looseObject({ - code: v.nullable(v.pipe(v.string(), v.trim())), - message: v.pipe(v.string(), v.trim()), - param: v.nullable(v.pipe(v.string(), v.trim())), - type: v.pipe(v.string(), v.trim()), -}); + }); /** - * Occurs when an [error](/docs/guides/error-codes/api-errors) occurs. This - * can happen due to an internal server error or a timeout. + * Text output from the Code Interpreter tool call as part of a run step. + * @title Code interpreter log output */ -export const inputErrorEventSchema = v.looseObject({ - event: v.picklist(["error"]), - data: inputErrorSchema, -}); -export const errorEventSchema = inputErrorEventSchema; +export const inputRunStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema = + v.looseObject({ + /** + * The index of the output in the outputs array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `logs`. + */ + type: v.picklist(["logs"]), + /** + * The text output from the Code Interpreter tool call. + */ + logs: v.optional(v.string()), + }); +export const runStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema = + v.looseObject({ + /** + * The index of the output in the outputs array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * Always `logs`. + */ + type: v.picklist(["logs"]), + /** + * The text output from the Code Interpreter tool call. + */ + logs: v.exactOptional(v.pipe(v.string(), v.trim())), + }); /** - * Represents a message within a [thread](/docs/api-reference/threads). - * @title The message object + * Details of the Code Interpreter tool call the run step was involved in. + * @title Code interpreter tool call */ -export const inputMessageObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.string(), - /** - * The object type, which is always `thread.message`. - */ - object: v.picklist(["thread.message"]), +export const inputRunStepDeltaStepDetailsToolCallsCodeObjectSchema = + v.looseObject({ + /** + * The index of the tool call in the tool calls array. + */ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call. + */ + id: v.optional(v.string()), + /** + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. + */ + type: v.picklist(["code_interpreter"]), + /** + * The Code Interpreter tool call definition. + */ + code_interpreter: v.optional( + v.looseObject({ + /** + * The input to the Code Interpreter tool call. + */ + input: v.optional(v.string()), + /** + * The outputs from the Code Interpreter tool call. Code Interpreter can + * output one or more items, including text (`logs`) or images (`image`). Each + * of these are represented by a different object type. + */ + outputs: v.optional( + v.array( + v.union([ + inputRunStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema, + inputRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema, + ]), + ), + ), + }), + ), + }); +export const runStepDeltaStepDetailsToolCallsCodeObjectSchema = v.looseObject({ /** - * The Unix timestamp (in seconds) for when the message was created. + * The index of the tool call in the tool calls array. */ - created_at: v.pipe(v.number(), v.integer()), + index: v.pipe(v.number(), v.integer()), /** - * The [thread](/docs/api-reference/threads) ID that this message belongs to. + * The ID of the tool call. */ - thread_id: v.string(), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The status of the message, which can be either `in_progress`, `incomplete`, - * or `completed`. + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. */ - status: v.picklist(["in_progress", "incomplete", "completed"]), + type: v.picklist(["code_interpreter"]), /** - * On an incomplete message, details about why the message is incomplete. + * The Code Interpreter tool call definition. */ - incomplete_details: v.nullable( + code_interpreter: v.exactOptional( v.looseObject({ /** - * The reason the message is incomplete. + * The input to the Code Interpreter tool call. */ - reason: v.picklist([ - "content_filter", - "max_tokens", - "run_cancelled", - "run_expired", - "run_failed", - ]), + input: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The outputs from the Code Interpreter tool call. Code Interpreter can + * output one or more items, including text (`logs`) or images (`image`). Each + * of these are represented by a different object type. + */ + outputs: v.exactOptional( + v.array( + v.union([ + runStepDeltaStepDetailsToolCallsCodeOutputLogsObjectSchema, + runStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema, + ]), + ), + ), }), ), +}); +/** + * Details of the tool call. + * @title Tool calls + */ +export const inputRunStepDeltaStepDetailsToolCallsObjectSchema = v.looseObject({ /** - * The Unix timestamp (in seconds) for when the message was completed. - */ - completed_at: v.nullable(v.pipe(v.number(), v.integer())), - /** - * The Unix timestamp (in seconds) for when the message was marked as - * incomplete. - */ - incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), - /** - * The entity that produced the message. One of `user` or `assistant`. - */ - role: v.picklist(["user", "assistant"]), - /** - * The content of the message in array of text and/or images. - */ - content: v.array( - v.union([ - inputMessageContentImageFileObjectSchema, - inputMessageContentImageUrlObjectSchema, - inputMessageContentTextObjectSchema, - inputMessageContentRefusalObjectSchema, - ]), - ), - /** - * If applicable, the ID of the [assistant](/docs/api-reference/assistants) - * that authored this message. + * Always `tool_calls`. */ - assistant_id: v.nullable(v.string()), + type: v.picklist(["tool_calls"]), /** - * The ID of the [run](/docs/api-reference/runs) associated with the creation - * of this message. Value is `null` when messages are created manually using - * the create message or create thread endpoints. + * An array of tool calls the run step was involved in. These can be + * associated with one of three types of tools: `code_interpreter`, + * `file_search`, or `function`. */ - run_id: v.nullable(v.string()), + tool_calls: v.optional( + v.array( + v.union([ + inputRunStepDeltaStepDetailsToolCallsCodeObjectSchema, + inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema, + inputRunStepDeltaStepDetailsToolCallsFunctionObjectSchema, + ]), + ), + ), +}); +export const runStepDeltaStepDetailsToolCallsObjectSchema = v.looseObject({ /** - * A list of files attached to the message, and the tools they were added to. + * Always `tool_calls`. */ - attachments: v.nullable( + type: v.picklist(["tool_calls"]), + /** + * An array of tool calls the run step was involved in. These can be + * associated with one of three types of tools: `code_interpreter`, + * `file_search`, or `function`. + */ + tool_calls: v.exactOptional( v.array( + v.union([ + runStepDeltaStepDetailsToolCallsCodeObjectSchema, + runStepDeltaStepDetailsToolCallsFileSearchObjectSchema, + runStepDeltaStepDetailsToolCallsFunctionObjectSchema, + ]), + ), + ), +}); +/** + * Details of the message creation by the run step. + * @title Message creation + */ +export const inputRunStepDeltaStepDetailsMessageCreationObjectSchema = + v.looseObject({ + /** + * Always `message_creation`. + */ + type: v.picklist(["message_creation"]), + message_creation: v.optional( v.looseObject({ /** - * The ID of the file to attach to the message. + * The ID of the message that was created by this run step. */ - file_id: v.optional(v.string()), + message_id: v.optional(v.string()), + }), + ), + }); +export const runStepDeltaStepDetailsMessageCreationObjectSchema = v.looseObject( + { + /** + * Always `message_creation`. + */ + type: v.picklist(["message_creation"]), + message_creation: v.exactOptional( + v.looseObject({ /** - * The tools to add this file to. + * The ID of the message that was created by this run step. */ - tools: v.optional( - v.array( - v.union([ - inputAssistantToolsCodeSchema, - inputAssistantToolsFileSearchTypeOnlySchema, - ]), - ), - ), + message_id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), - ), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.nullable(v.record(v.string(), v.unknown())), -}); -export const messageObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always `thread.message`. - */ - object: v.picklist(["thread.message"]), - /** - * The Unix timestamp (in seconds) for when the message was created. - */ - created_at: v.pipe(v.number(), v.integer()), + }, +); +/** + * Represents a run step delta i.e. any changed fields on a run step during + * streaming. + * @title Run step delta object + */ +export const inputRunStepDeltaObjectSchema = v.looseObject({ /** - * The [thread](/docs/api-reference/threads) ID that this message belongs to. + * The identifier of the run step, which can be referenced in API endpoints. */ - thread_id: v.pipe(v.string(), v.trim()), + id: v.string(), /** - * The status of the message, which can be either `in_progress`, `incomplete`, - * or `completed`. + * The object type, which is always `thread.run.step.delta`. */ - status: v.picklist(["in_progress", "incomplete", "completed"]), + object: v.picklist(["thread.run.step.delta"]), /** - * On an incomplete message, details about why the message is incomplete. + * The delta containing the fields that have changed on the run step. */ - incomplete_details: v.nullable( - v.looseObject({ - /** - * The reason the message is incomplete. - */ - reason: v.picklist([ - "content_filter", - "max_tokens", - "run_cancelled", - "run_expired", - "run_failed", + delta: v.looseObject({ + /** + * The details of the run step. + */ + step_details: v.optional( + v.union([ + inputRunStepDeltaStepDetailsMessageCreationObjectSchema, + inputRunStepDeltaStepDetailsToolCallsObjectSchema, ]), - }), - ), + ), + }), +}); +export const runStepDeltaObjectSchema = v.looseObject({ /** - * The Unix timestamp (in seconds) for when the message was completed. + * The identifier of the run step, which can be referenced in API endpoints. */ - completed_at: v.nullable(v.pipe(v.number(), v.integer())), + id: v.pipe(v.string(), v.trim()), /** - * The Unix timestamp (in seconds) for when the message was marked as - * incomplete. + * The object type, which is always `thread.run.step.delta`. */ - incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), + object: v.picklist(["thread.run.step.delta"]), /** - * The entity that produced the message. One of `user` or `assistant`. + * The delta containing the fields that have changed on the run step. */ - role: v.picklist(["user", "assistant"]), + delta: v.looseObject({ + /** + * The details of the run step. + */ + step_details: v.exactOptional( + v.union([ + runStepDeltaStepDetailsMessageCreationObjectSchema, + runStepDeltaStepDetailsToolCallsObjectSchema, + ]), + ), + }), +}); +/** + * Usage statistics related to the run step. This value will be `null` while + * the run step's status is `in_progress`. + */ +export const inputRunStepCompletionUsageSchema = v.nullable( + v.looseObject({ + /** + * Number of completion tokens used over the course of the run step. + */ + completion_tokens: v.pipe(v.number(), v.integer()), + /** + * Number of prompt tokens used over the course of the run step. + */ + prompt_tokens: v.pipe(v.number(), v.integer()), + /** + * Total number of tokens used (prompt + completion). + */ + total_tokens: v.pipe(v.number(), v.integer()), + }), +); +export const runStepCompletionUsageSchema = inputRunStepCompletionUsageSchema; +export const inputRunStepDetailsToolCallsFunctionObjectSchema = v.looseObject({ /** - * The content of the message in array of text and/or images. + * The ID of the tool call object. */ - content: v.array( - v.union([ - messageContentImageFileObjectSchema, - messageContentImageUrlObjectSchema, - messageContentTextObjectSchema, - messageContentRefusalObjectSchema, - ]), - ), + id: v.string(), /** - * If applicable, the ID of the [assistant](/docs/api-reference/assistants) - * that authored this message. + * The type of tool call. This is always going to be `function` for this type + * of tool call. */ - assistant_id: v.nullable(v.pipe(v.string(), v.trim())), + type: v.picklist(["function"]), /** - * The ID of the [run](/docs/api-reference/runs) associated with the creation - * of this message. Value is `null` when messages are created manually using - * the create message or create thread endpoints. + * The definition of the function that was called. */ - run_id: v.nullable(v.pipe(v.string(), v.trim())), + function: v.looseObject({ + /** + * The name of the function. + */ + name: v.string(), + /** + * The arguments passed to the function. + */ + arguments: v.string(), + /** + * The output of the function. This will be `null` if the outputs have not + * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + */ + output: v.nullable(v.string()), + }), +}); +export const runStepDetailsToolCallsFunctionObjectSchema = v.looseObject({ /** - * A list of files attached to the message, and the tools they were added to. - */ - attachments: v.nullable( - v.array( - v.looseObject({ - /** - * The ID of the file to attach to the message. - */ - file_id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The tools to add this file to. - */ - tools: v.exactOptional( - v.array( - v.union([ - assistantToolsCodeSchema, - assistantToolsFileSearchTypeOnlySchema, - ]), - ), - ), - }), - ), - ), + * The ID of the tool call object. + */ + id: v.pipe(v.string(), v.trim()), /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. + * The type of tool call. This is always going to be `function` for this type + * of tool call. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), -}); -export const inputMessageStreamEventSchema = v.union([ - v.looseObject({ - event: v.picklist(["thread.message.created"]), - data: inputMessageObjectSchema, - }), - v.looseObject({ - event: v.picklist(["thread.message.in_progress"]), - data: inputMessageObjectSchema, - }), - v.looseObject({ - event: v.picklist(["thread.message.delta"]), - data: inputMessageDeltaObjectSchema, + type: v.picklist(["function"]), + /** + * The definition of the function that was called. + */ + function: v.looseObject({ + /** + * The name of the function. + */ + name: v.pipe(v.string(), v.trim()), + /** + * The arguments passed to the function. + */ + arguments: v.pipe(v.string(), v.trim()), + /** + * The output of the function. This will be `null` if the outputs have not + * been [submitted](/docs/api-reference/runs/submitToolOutputs) yet. + */ + output: v.nullable(v.pipe(v.string(), v.trim())), }), +}); +/** + * A result instance of the file search. + * @title File search tool call result + */ +export const inputRunStepDetailsToolCallsFileSearchResultObjectSchema = v.looseObject({ - event: v.picklist(["thread.message.completed"]), - data: inputMessageObjectSchema, - }), + /** + * The ID of the file that result was found in. + */ + file_id: v.string(), + /** + * The name of the file that result was found in. + */ + file_name: v.string(), + /** + * The score of the result. All values must be a floating point number between + * 0 and 1. + */ + score: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), + /** + * The content of the result that was found. The content is only included if + * requested via the include query parameter. + */ + content: v.optional( + v.array( + v.looseObject({ + /** + * The type of the content. + */ + type: v.optional(v.picklist(["text"])), + /** + * The text content of the file. + */ + text: v.optional(v.string()), + }), + ), + ), + }); +export const runStepDetailsToolCallsFileSearchResultObjectSchema = v.looseObject({ - event: v.picklist(["thread.message.incomplete"]), - data: inputMessageObjectSchema, - }), -]); -export const messageStreamEventSchema = inputMessageStreamEventSchema; + /** + * The ID of the file that result was found in. + */ + file_id: v.pipe(v.string(), v.trim()), + /** + * The name of the file that result was found in. + */ + file_name: v.pipe(v.string(), v.trim()), + /** + * The score of the result. All values must be a floating point number between + * 0 and 1. + */ + score: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), + /** + * The content of the result that was found. The content is only included if + * requested via the include query parameter. + */ + content: v.exactOptional( + v.array( + v.looseObject({ + /** + * The type of the content. + */ + type: v.exactOptional(v.picklist(["text"])), + /** + * The text content of the file. + */ + text: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + ), + }); /** - * Details of the tool call. - * @title Tool calls + * The ranking options for the file search. + * @title File search tool call ranking options */ -export const inputRunStepDeltaStepDetailsToolCallsObjectSchema = v.looseObject({ - /** - * Always `tool_calls`. - */ - type: v.picklist(["tool_calls"]), +export const inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema = + v.looseObject({ + /** + * The ranker used for the file search. + */ + ranker: v.picklist(["default_2024_08_21"]), + /** + * The score threshold for the file search. All values must be a floating + * point number between 0 and 1. + */ + score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), + }); +export const runStepDetailsToolCallsFileSearchRankingOptionsObjectSchema = + inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema; +export const inputRunStepDetailsToolCallsFileSearchObjectSchema = v.looseObject( + { + /** + * The ID of the tool call object. + */ + id: v.string(), + /** + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. + */ + type: v.picklist(["file_search"]), + /** + * For now, this is always going to be an empty object. + */ + file_search: v.looseObject({ + ranking_options: v.optional( + inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema, + ), + /** + * The results of the file search. + */ + results: v.optional( + v.array(inputRunStepDetailsToolCallsFileSearchResultObjectSchema), + ), + }), + }, +); +export const runStepDetailsToolCallsFileSearchObjectSchema = v.looseObject({ /** - * An array of tool calls the run step was involved in. These can be - * associated with one of three types of tools: `code_interpreter`, - * `file_search`, or `function`. + * The ID of the tool call object. */ - tool_calls: v.optional( - v.array( - v.union([ - inputRunStepDeltaStepDetailsToolCallsCodeObjectSchema, - inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema, - inputRunStepDeltaStepDetailsToolCallsFunctionObjectSchema, - ]), - ), - ), -}); -export const runStepDeltaStepDetailsToolCallsObjectSchema = v.looseObject({ + id: v.pipe(v.string(), v.trim()), /** - * Always `tool_calls`. + * The type of tool call. This is always going to be `file_search` for this + * type of tool call. */ - type: v.picklist(["tool_calls"]), + type: v.picklist(["file_search"]), /** - * An array of tool calls the run step was involved in. These can be - * associated with one of three types of tools: `code_interpreter`, - * `file_search`, or `function`. + * For now, this is always going to be an empty object. */ - tool_calls: v.exactOptional( - v.array( - v.union([ - runStepDeltaStepDetailsToolCallsCodeObjectSchema, - runStepDeltaStepDetailsToolCallsFileSearchObjectSchema, - runStepDeltaStepDetailsToolCallsFunctionObjectSchema, - ]), + file_search: v.looseObject({ + ranking_options: v.exactOptional( + runStepDetailsToolCallsFileSearchRankingOptionsObjectSchema, ), - ), + /** + * The results of the file search. + */ + results: v.exactOptional( + v.array(runStepDetailsToolCallsFileSearchResultObjectSchema), + ), + }), }); -/** - * Details of the message creation by the run step. - * @title Message creation - */ -export const inputRunStepDeltaStepDetailsMessageCreationObjectSchema = +export const inputRunStepDetailsToolCallsCodeOutputImageObjectSchema = v.looseObject({ /** - * Always `message_creation`. + * Always `image`. */ - type: v.picklist(["message_creation"]), - message_creation: v.optional( - v.looseObject({ - /** - * The ID of the message that was created by this run step. - */ - message_id: v.optional(v.string()), - }), - ), + type: v.picklist(["image"]), + image: v.looseObject({ + /** + * The [file](/docs/api-reference/files) ID of the image. + */ + file_id: v.string(), + }), }); -export const runStepDeltaStepDetailsMessageCreationObjectSchema = v.looseObject( +export const runStepDetailsToolCallsCodeOutputImageObjectSchema = v.looseObject( { /** - * Always `message_creation`. + * Always `image`. */ - type: v.picklist(["message_creation"]), - message_creation: v.exactOptional( - v.looseObject({ - /** - * The ID of the message that was created by this run step. - */ - message_id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + type: v.picklist(["image"]), + image: v.looseObject({ + /** + * The [file](/docs/api-reference/files) ID of the image. + */ + file_id: v.pipe(v.string(), v.trim()), + }), }, ); /** - * Represents a run step delta i.e. any changed fields on a run step during - * streaming. - * @title Run step delta object + * Text output from the Code Interpreter tool call as part of a run step. + * @title Code Interpreter log output */ -export const inputRunStepDeltaObjectSchema = v.looseObject({ +export const inputRunStepDetailsToolCallsCodeOutputLogsObjectSchema = + v.looseObject({ + /** + * Always `logs`. + */ + type: v.picklist(["logs"]), + /** + * The text output from the Code Interpreter tool call. + */ + logs: v.string(), + }); +export const runStepDetailsToolCallsCodeOutputLogsObjectSchema = v.looseObject({ /** - * The identifier of the run step, which can be referenced in API endpoints. + * Always `logs`. + */ + type: v.picklist(["logs"]), + /** + * The text output from the Code Interpreter tool call. + */ + logs: v.pipe(v.string(), v.trim()), +}); +/** + * Details of the Code Interpreter tool call the run step was involved in. + * @title Code Interpreter tool call + */ +export const inputRunStepDetailsToolCallsCodeObjectSchema = v.looseObject({ + /** + * The ID of the tool call. */ id: v.string(), /** - * The object type, which is always `thread.run.step.delta`. + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. */ - object: v.picklist(["thread.run.step.delta"]), + type: v.picklist(["code_interpreter"]), /** - * The delta containing the fields that have changed on the run step. + * The Code Interpreter tool call definition. */ - delta: v.looseObject({ + code_interpreter: v.looseObject({ /** - * The details of the run step. + * The input to the Code Interpreter tool call. */ - step_details: v.optional( + input: v.string(), + /** + * The outputs from the Code Interpreter tool call. Code Interpreter can + * output one or more items, including text (`logs`) or images (`image`). Each + * of these are represented by a different object type. + */ + outputs: v.array( v.union([ - inputRunStepDeltaStepDetailsMessageCreationObjectSchema, - inputRunStepDeltaStepDetailsToolCallsObjectSchema, + inputRunStepDetailsToolCallsCodeOutputLogsObjectSchema, + inputRunStepDetailsToolCallsCodeOutputImageObjectSchema, ]), ), }), }); -export const runStepDeltaObjectSchema = v.looseObject({ +export const runStepDetailsToolCallsCodeObjectSchema = v.looseObject({ /** - * The identifier of the run step, which can be referenced in API endpoints. + * The ID of the tool call. */ id: v.pipe(v.string(), v.trim()), /** - * The object type, which is always `thread.run.step.delta`. + * The type of tool call. This is always going to be `code_interpreter` for + * this type of tool call. */ - object: v.picklist(["thread.run.step.delta"]), + type: v.picklist(["code_interpreter"]), /** - * The delta containing the fields that have changed on the run step. + * The Code Interpreter tool call definition. */ - delta: v.looseObject({ + code_interpreter: v.looseObject({ /** - * The details of the run step. + * The input to the Code Interpreter tool call. */ - step_details: v.exactOptional( + input: v.pipe(v.string(), v.trim()), + /** + * The outputs from the Code Interpreter tool call. Code Interpreter can + * output one or more items, including text (`logs`) or images (`image`). Each + * of these are represented by a different object type. + */ + outputs: v.array( v.union([ - runStepDeltaStepDetailsMessageCreationObjectSchema, - runStepDeltaStepDetailsToolCallsObjectSchema, + runStepDetailsToolCallsCodeOutputLogsObjectSchema, + runStepDetailsToolCallsCodeOutputImageObjectSchema, ]), ), }), }); -/** - * Usage statistics related to the run step. This value will be `null` while - * the run step's status is `in_progress`. - */ -export const inputRunStepCompletionUsageSchema = v.nullable( - v.looseObject({ - /** - * Number of completion tokens used over the course of the run step. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of prompt tokens used over the course of the run step. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - }), -); -export const runStepCompletionUsageSchema = inputRunStepCompletionUsageSchema; /** * Details of the tool call. * @title Tool calls @@ -5716,7 +5498,7 @@ export const inputRunStepDetailsToolCallsObjectSchema = v.looseObject({ tool_calls: v.array( v.union([ inputRunStepDetailsToolCallsCodeObjectSchema, - v.unknown(), + inputRunStepDetailsToolCallsFileSearchObjectSchema, inputRunStepDetailsToolCallsFunctionObjectSchema, ]), ), @@ -6172,27 +5954,174 @@ export const truncationObjectSchema = v.looseObject({ v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1))), ), }); -/** - * Usage statistics related to the run. This value will be `null` if the run - * is not in a terminal state (i.e. `in_progress`, `queued`, etc.). - */ -export const inputRunCompletionUsageSchema = v.nullable( - v.looseObject({ - /** - * Number of completion tokens used over the course of the run. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of prompt tokens used over the course of the run. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - }), -); -export const runCompletionUsageSchema = inputRunCompletionUsageSchema; +/** + * Usage statistics related to the run. This value will be `null` if the run + * is not in a terminal state (i.e. `in_progress`, `queued`, etc.). + */ +export const inputRunCompletionUsageSchema = v.nullable( + v.looseObject({ + /** + * Number of completion tokens used over the course of the run. + */ + completion_tokens: v.pipe(v.number(), v.integer()), + /** + * Number of prompt tokens used over the course of the run. + */ + prompt_tokens: v.pipe(v.number(), v.integer()), + /** + * Total number of tokens used (prompt + completion). + */ + total_tokens: v.pipe(v.number(), v.integer()), + }), +); +export const runCompletionUsageSchema = inputRunCompletionUsageSchema; +/** + * The parameters the functions accepts, described as a JSON Schema object. + * See the [guide](/docs/guides/function-calling) for examples, and the [JSON + * Schema reference](https://json-schema.org/understanding-json-schema/) for + * documentation about the format. + * + * Omitting `parameters` defines a function with an empty parameter list. + */ +export const inputFunctionParametersSchema = v.record(v.string(), v.unknown()); +export const functionParametersSchema = inputFunctionParametersSchema; +export const inputFunctionObjectSchema = v.looseObject({ + /** + * A description of what the function does, used by the model to choose when + * and how to call the function. + */ + description: v.optional(v.string()), + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + name: v.string(), + parameters: v.optional(inputFunctionParametersSchema), + /** + * Whether to enable strict schema adherence when generating the function + * call. If set to true, the model will follow the exact schema defined in the + * `parameters` field. Only a subset of JSON Schema is supported when `strict` + * is `true`. Learn more about Structured Outputs in the [function calling + * guide](docs/guides/function-calling). + */ + strict: v.optional(v.nullable(v.boolean())), +}); +export const functionObjectSchema = v.looseObject({ + /** + * A description of what the function does, used by the model to choose when + * and how to call the function. + */ + description: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + name: v.pipe(v.string(), v.trim()), + parameters: v.exactOptional(functionParametersSchema), + /** + * Whether to enable strict schema adherence when generating the function + * call. If set to true, the model will follow the exact schema defined in the + * `parameters` field. Only a subset of JSON Schema is supported when `strict` + * is `true`. Learn more about Structured Outputs in the [function calling + * guide](docs/guides/function-calling). + */ + strict: v.exactOptional(v.nullable(v.boolean())), +}); +export const inputAssistantToolsFunctionSchema = v.looseObject({ + /** + * The type of tool being defined: `function` + */ + type: v.picklist(["function"]), + function: inputFunctionObjectSchema, +}); +export const assistantToolsFunctionSchema = inputAssistantToolsFunctionSchema; +/** + * The ranking options for the file search. If not specified, the file search + * tool will use the `auto` ranker and a score_threshold of 0. + * + * See the [file search tool + * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + * @title File search tool call ranking options + */ +export const inputFileSearchRankingOptionsSchema = v.looseObject({ + /** + * The ranker to use for the file search. If not specified will use the `auto` + * ranker. + */ + ranker: v.optional(v.picklist(["auto", "default_2024_08_21"])), + /** + * The score threshold for the file search. All values must be a floating + * point number between 0 and 1. + */ + score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), +}); +export const fileSearchRankingOptionsSchema = v.looseObject({ + /** + * The ranker to use for the file search. If not specified will use the `auto` + * ranker. + */ + ranker: v.exactOptional(v.picklist(["auto", "default_2024_08_21"])), + /** + * The score threshold for the file search. All values must be a floating + * point number between 0 and 1. + */ + score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), +}); +export const inputAssistantToolsFileSearchSchema = v.looseObject({ + /** + * The type of tool being defined: `file_search` + */ + type: v.picklist(["file_search"]), + /** + * Overrides for the file search tool. + */ + file_search: v.optional( + v.looseObject({ + /** + * The maximum number of results the file search tool should output. The + * default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number + * should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` + * results. See the [file search tool + * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + max_num_results: v.optional( + v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), + ), + ranking_options: v.optional(inputFileSearchRankingOptionsSchema), + }), + ), +}); +export const assistantToolsFileSearchSchema = v.looseObject({ + /** + * The type of tool being defined: `file_search` + */ + type: v.picklist(["file_search"]), + /** + * Overrides for the file search tool. + */ + file_search: v.exactOptional( + v.looseObject({ + /** + * The maximum number of results the file search tool should output. The + * default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number + * should be between 1 and 50 inclusive. + * + * Note that the file search tool may output fewer than `max_num_results` + * results. See the [file search tool + * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) + * for more information. + */ + max_num_results: v.exactOptional( + v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), + ), + ranking_options: v.exactOptional(fileSearchRankingOptionsSchema), + }), + ), +}); /** Tool call objects */ export const inputRunToolCallObjectSchema = v.looseObject({ /** @@ -6380,7 +6309,13 @@ export const inputRunObjectSchema = v.looseObject({ * for this run. */ tools: v.pipe( - v.array(v.union([inputAssistantToolsCodeSchema, v.unknown(), v.unknown()])), + v.array( + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchSchema, + inputAssistantToolsFunctionSchema, + ]), + ), v.maxLength(20), ), /** @@ -6548,7 +6483,13 @@ export const runObjectSchema = v.looseObject({ * for this run. */ tools: v.pipe( - v.array(v.union([assistantToolsCodeSchema, v.unknown(), v.unknown()])), + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchSchema, + assistantToolsFunctionSchema, + ]), + ), v.maxLength(20), ), /** @@ -7188,238 +7129,96 @@ export const listVectorStoresResponseSchema = v.looseObject({ object: v.pipe(v.string(), v.trim()), data: v.array(vectorStoreObjectSchema), first_id: v.pipe(v.string(), v.trim()), - last_id: v.pipe(v.string(), v.trim()), - has_more: v.boolean(), -}); -export const inputUpdateVectorStoreRequestSchema = v.strictObject({ - /** - * The name of the vector store. - */ - name: v.optional(v.nullable(v.string())), - expires_after: v.optional(inputVectorStoreExpirationAfterSchema), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), -}); -export const updateVectorStoreRequestSchema = v.strictObject({ - /** - * The name of the vector store. - */ - name: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - expires_after: v.exactOptional(vectorStoreExpirationAfterSchema), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), -}); -export const inputCreateVectorStoreRequestSchema = v.strictObject({ - /** - * A list of [File](/docs/api-reference/files) IDs that the vector store - * should use. Useful for tools like `file_search` that can access files. - */ - file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(500))), - /** - * The name of the vector store. - */ - name: v.optional(v.string()), - expires_after: v.optional(inputVectorStoreExpirationAfterSchema), - /** - * The chunking strategy used to chunk the file(s). If not set, will use the - * `auto` strategy. Only applicable if `file_ids` is non-empty. - */ - chunking_strategy: v.optional( - v.union([ - inputAutoChunkingStrategyRequestParamSchema, - inputStaticChunkingStrategyRequestParamSchema, - ]), - ), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), -}); -export const createVectorStoreRequestSchema = v.strictObject({ - /** - * A list of [File](/docs/api-reference/files) IDs that the vector store - * should use. Useful for tools like `file_search` that can access files. - */ - file_ids: v.exactOptional( - v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(500)), - ), - /** - * The name of the vector store. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - expires_after: v.exactOptional(vectorStoreExpirationAfterSchema), - /** - * The chunking strategy used to chunk the file(s). If not set, will use the - * `auto` strategy. Only applicable if `file_ids` is non-empty. - */ - chunking_strategy: v.exactOptional( - v.union([ - autoChunkingStrategyRequestParamSchema, - staticChunkingStrategyRequestParamSchema, - ]), - ), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), -}); -/** - * A result instance of the file search. - * @title File search tool call result - */ -export const inputRunStepDetailsToolCallsFileSearchResultObjectSchema = - v.looseObject({ - /** - * The ID of the file that result was found in. - */ - file_id: v.string(), - /** - * The name of the file that result was found in. - */ - file_name: v.string(), - /** - * The score of the result. All values must be a floating point number between - * 0 and 1. - */ - score: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), - /** - * The content of the result that was found. The content is only included if - * requested via the include query parameter. - */ - content: v.optional( - v.array( - v.looseObject({ - /** - * The type of the content. - */ - type: v.optional(v.picklist(["text"])), - /** - * The text content of the file. - */ - text: v.optional(v.string()), - }), - ), - ), - }); -export const runStepDetailsToolCallsFileSearchResultObjectSchema = - v.looseObject({ - /** - * The ID of the file that result was found in. - */ - file_id: v.pipe(v.string(), v.trim()), - /** - * The name of the file that result was found in. - */ - file_name: v.pipe(v.string(), v.trim()), - /** - * The score of the result. All values must be a floating point number between - * 0 and 1. - */ - score: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), - /** - * The content of the result that was found. The content is only included if - * requested via the include query parameter. - */ - content: v.exactOptional( - v.array( - v.looseObject({ - /** - * The type of the content. - */ - type: v.exactOptional(v.picklist(["text"])), - /** - * The text content of the file. - */ - text: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - ), - }); -/** - * The ranking options for the file search. - * @title File search tool call ranking options - */ -export const inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema = - v.looseObject({ - /** - * The ranker used for the file search. - */ - ranker: v.picklist(["default_2024_08_21"]), - /** - * The score threshold for the file search. All values must be a floating - * point number between 0 and 1. - */ - score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), - }); -export const runStepDetailsToolCallsFileSearchRankingOptionsObjectSchema = - inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema; -export const inputRunStepDetailsToolCallsFileSearchObjectSchema = v.looseObject( - { - /** - * The ID of the tool call object. - */ - id: v.string(), - /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. - */ - type: v.picklist(["file_search"]), - /** - * For now, this is always going to be an empty object. - */ - file_search: v.looseObject({ - ranking_options: v.optional( - inputRunStepDetailsToolCallsFileSearchRankingOptionsObjectSchema, - ), - /** - * The results of the file search. - */ - results: v.optional( - v.array(inputRunStepDetailsToolCallsFileSearchResultObjectSchema), - ), - }), - }, -); -export const runStepDetailsToolCallsFileSearchObjectSchema = v.looseObject({ + last_id: v.pipe(v.string(), v.trim()), + has_more: v.boolean(), +}); +export const inputUpdateVectorStoreRequestSchema = v.strictObject({ /** - * The ID of the tool call object. + * The name of the vector store. */ - id: v.pipe(v.string(), v.trim()), + name: v.optional(v.nullable(v.string())), + expires_after: v.optional(inputVectorStoreExpirationAfterSchema), /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. */ - type: v.picklist(["file_search"]), + metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), +}); +export const updateVectorStoreRequestSchema = v.strictObject({ /** - * For now, this is always going to be an empty object. + * The name of the vector store. */ - file_search: v.looseObject({ - ranking_options: v.exactOptional( - runStepDetailsToolCallsFileSearchRankingOptionsObjectSchema, - ), - /** - * The results of the file search. - */ - results: v.exactOptional( - v.array(runStepDetailsToolCallsFileSearchResultObjectSchema), - ), - }), + name: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + expires_after: v.exactOptional(vectorStoreExpirationAfterSchema), + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), +}); +export const inputCreateVectorStoreRequestSchema = v.strictObject({ + /** + * A list of [File](/docs/api-reference/files) IDs that the vector store + * should use. Useful for tools like `file_search` that can access files. + */ + file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(500))), + /** + * The name of the vector store. + */ + name: v.optional(v.string()), + expires_after: v.optional(inputVectorStoreExpirationAfterSchema), + /** + * The chunking strategy used to chunk the file(s). If not set, will use the + * `auto` strategy. Only applicable if `file_ids` is non-empty. + */ + chunking_strategy: v.optional( + v.union([ + inputAutoChunkingStrategyRequestParamSchema, + inputStaticChunkingStrategyRequestParamSchema, + ]), + ), + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), +}); +export const createVectorStoreRequestSchema = v.strictObject({ + /** + * A list of [File](/docs/api-reference/files) IDs that the vector store + * should use. Useful for tools like `file_search` that can access files. + */ + file_ids: v.exactOptional( + v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(500)), + ), + /** + * The name of the vector store. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + expires_after: v.exactOptional(vectorStoreExpirationAfterSchema), + /** + * The chunking strategy used to chunk the file(s). If not set, will use the + * `auto` strategy. Only applicable if `file_ids` is non-empty. + */ + chunking_strategy: v.exactOptional( + v.union([ + autoChunkingStrategyRequestParamSchema, + staticChunkingStrategyRequestParamSchema, + ]), + ), + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), }); export const inputListRunStepsResponseSchema = v.looseObject({ object: v.string(), @@ -7449,6 +7248,30 @@ export const listMessagesResponseSchema = v.looseObject({ last_id: v.pipe(v.string(), v.trim()), has_more: v.boolean(), }); +/** + * The text content that is part of a message. + * @title Text + */ +export const inputMessageRequestContentTextObjectSchema = v.looseObject({ + /** + * Always `text`. + */ + type: v.picklist(["text"]), + /** + * Text content to be sent to the model + */ + text: v.string(), +}); +export const messageRequestContentTextObjectSchema = v.looseObject({ + /** + * Always `text`. + */ + type: v.picklist(["text"]), + /** + * Text content to be sent to the model + */ + text: v.pipe(v.string(), v.trim()), +}); export const inputListThreadsResponseSchema = v.looseObject({ object: v.string(), data: v.array(inputThreadObjectSchema), @@ -7724,7 +7547,11 @@ export const inputCreateThreadAndRunRequestSchema = v.strictObject({ v.nullable( v.pipe( v.array( - v.union([inputAssistantToolsCodeSchema, v.unknown(), v.unknown()]), + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchSchema, + inputAssistantToolsFunctionSchema, + ]), ), v.maxLength(20), ), @@ -7879,7 +7706,13 @@ export const createThreadAndRunRequestSchema = v.strictObject({ tools: v.exactOptional( v.nullable( v.pipe( - v.array(v.union([assistantToolsCodeSchema, v.unknown(), v.unknown()])), + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchSchema, + assistantToolsFunctionSchema, + ]), + ), v.maxLength(20), ), ), @@ -8062,7 +7895,11 @@ export const inputCreateRunRequestSchema = v.strictObject({ v.nullable( v.pipe( v.array( - v.union([inputAssistantToolsCodeSchema, v.unknown(), v.unknown()]), + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchSchema, + inputAssistantToolsFunctionSchema, + ]), ), v.maxLength(20), ), @@ -8197,7 +8034,13 @@ export const createRunRequestSchema = v.strictObject({ tools: v.exactOptional( v.nullable( v.pipe( - v.array(v.union([assistantToolsCodeSchema, v.unknown(), v.unknown()])), + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchSchema, + assistantToolsFunctionSchema, + ]), + ), v.maxLength(20), ), ), @@ -8208,13 +8051,156 @@ export const createRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it + * more focused and deterministic. + */ + temperature: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), + ), + /** + * An alternative to sampling with temperature, called nucleus sampling, where + * the model considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are + * considered. + * + * We generally recommend altering this or temperature but not both. + */ + top_p: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), + ), + /** + * If `true`, returns a stream of events that happen during the Run as + * server-sent events, terminating when the Run enters a terminal state with a + * `data: [DONE]` message. + */ + stream: v.exactOptional(v.nullable(v.boolean())), + /** + * The maximum number of prompt tokens that may be used over the course of the + * run. The run will make a best effort to use only the number of prompt + * tokens specified, across multiple turns of the run. If the run exceeds the + * number of prompt tokens specified, the run will end with status + * `incomplete`. See `incomplete_details` for more info. + */ + max_prompt_tokens: v.exactOptional( + v.nullable(v.pipe(v.number(), v.integer(), v.minValue(256))), + ), + /** + * The maximum number of completion tokens that may be used over the course of + * the run. The run will make a best effort to use only the number of + * completion tokens specified, across multiple turns of the run. If the run + * exceeds the number of completion tokens specified, the run will end with + * status `incomplete`. See `incomplete_details` for more info. + */ + max_completion_tokens: v.exactOptional( + v.nullable(v.pipe(v.number(), v.integer(), v.minValue(256))), + ), + truncation_strategy: v.exactOptional(truncationObjectSchema), + tool_choice: v.exactOptional(assistantsApiToolChoiceOptionSchema), + parallel_tool_calls: v.exactOptional(parallelToolCallsSchema), + response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), +}); +/** + * Represents an `assistant` that can call the model and use tools. + * @title Assistant + */ +export const inputAssistantObjectSchema = v.looseObject({ + /** + * The identifier, which can be referenced in API endpoints. + */ + id: v.string(), + /** + * The object type, which is always `assistant`. + */ + object: v.picklist(["assistant"]), + /** + * The Unix timestamp (in seconds) for when the assistant was created. + */ + created_at: v.pipe(v.number(), v.integer()), + /** + * The name of the assistant. The maximum length is 256 characters. + */ + name: v.nullable(v.pipe(v.string(), v.maxLength(256))), + /** + * The description of the assistant. The maximum length is 512 characters. + */ + description: v.nullable(v.pipe(v.string(), v.maxLength(512))), + /** + * ID of the model to use. You can use the [List + * models](/docs/api-reference/models/list) API to see all of your available + * models, or see our [Model overview](/docs/models/overview) for descriptions + * of them. + */ + model: v.string(), + /** + * The system instructions that the assistant uses. The maximum length is + * 256,000 characters. + */ + instructions: v.nullable(v.pipe(v.string(), v.maxLength(256_000))), + /** + * A list of tool enabled on the assistant. There can be a maximum of 128 + * tools per assistant. Tools can be of types `code_interpreter`, + * `file_search`, or `function`. + */ + tools: v.pipe( + v.array( + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchSchema, + inputAssistantToolsFunctionSchema, + ]), + ), + v.maxLength(128), + ), + /** + * A set of resources that are used by the assistant's tools. The resources + * are specific to the type of tool. For example, the `code_interpreter` tool + * requires a list of file IDs, while the `file_search` tool requires a list + * of vector store IDs. + */ + tool_resources: v.optional( + v.nullable( + v.looseObject({ + code_interpreter: v.optional( + v.looseObject({ + /** + * A list of [file](/docs/api-reference/files) IDs made available to the + * `code_interpreter`` tool. There can be a maximum of 20 files associated + * with the tool. + */ + file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(20))), + }), + ), + file_search: v.optional( + v.looseObject({ + /** + * The ID of the [vector store](/docs/api-reference/vector-stores/object) + * attached to this assistant. There can be a maximum of 1 vector store + * attached to the assistant. + */ + vector_store_ids: v.optional( + v.pipe(v.array(v.string()), v.maxLength(1)), + ), + }), + ), + }), + ), + ), + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.nullable(v.record(v.string(), v.unknown())), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it * more focused and deterministic. */ - temperature: v.exactOptional( + temperature: v.optional( v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), ), /** @@ -8225,238 +8211,176 @@ export const createRunRequestSchema = v.strictObject({ * * We generally recommend altering this or temperature but not both. */ - top_p: v.exactOptional( + top_p: v.optional( v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), ), - /** - * If `true`, returns a stream of events that happen during the Run as - * server-sent events, terminating when the Run enters a terminal state with a - * `data: [DONE]` message. - */ - stream: v.exactOptional(v.nullable(v.boolean())), - /** - * The maximum number of prompt tokens that may be used over the course of the - * run. The run will make a best effort to use only the number of prompt - * tokens specified, across multiple turns of the run. If the run exceeds the - * number of prompt tokens specified, the run will end with status - * `incomplete`. See `incomplete_details` for more info. - */ - max_prompt_tokens: v.exactOptional( - v.nullable(v.pipe(v.number(), v.integer(), v.minValue(256))), - ), - /** - * The maximum number of completion tokens that may be used over the course of - * the run. The run will make a best effort to use only the number of - * completion tokens specified, across multiple turns of the run. If the run - * exceeds the number of completion tokens specified, the run will end with - * status `incomplete`. See `incomplete_details` for more info. - */ - max_completion_tokens: v.exactOptional( - v.nullable(v.pipe(v.number(), v.integer(), v.minValue(256))), - ), - truncation_strategy: v.exactOptional(truncationObjectSchema), - tool_choice: v.exactOptional(assistantsApiToolChoiceOptionSchema), - parallel_tool_calls: v.exactOptional(parallelToolCallsSchema), - response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), -}); -/** - * The parameters the functions accepts, described as a JSON Schema object. - * See the [guide](/docs/guides/function-calling) for examples, and the [JSON - * Schema reference](https://json-schema.org/understanding-json-schema/) for - * documentation about the format. - * - * Omitting `parameters` defines a function with an empty parameter list. - */ -export const inputFunctionParametersSchema = v.record(v.string(), v.unknown()); -export const functionParametersSchema = inputFunctionParametersSchema; -export const inputFunctionObjectSchema = v.looseObject({ - /** - * A description of what the function does, used by the model to choose when - * and how to call the function. - */ - description: v.optional(v.string()), - /** - * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain - * underscores and dashes, with a maximum length of 64. - */ - name: v.string(), - parameters: v.optional(inputFunctionParametersSchema), - /** - * Whether to enable strict schema adherence when generating the function - * call. If set to true, the model will follow the exact schema defined in the - * `parameters` field. Only a subset of JSON Schema is supported when `strict` - * is `true`. Learn more about Structured Outputs in the [function calling - * guide](docs/guides/function-calling). - */ - strict: v.optional(v.nullable(v.boolean())), -}); -export const functionObjectSchema = v.looseObject({ - /** - * A description of what the function does, used by the model to choose when - * and how to call the function. - */ - description: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain - * underscores and dashes, with a maximum length of 64. - */ - name: v.pipe(v.string(), v.trim()), - parameters: v.exactOptional(functionParametersSchema), - /** - * Whether to enable strict schema adherence when generating the function - * call. If set to true, the model will follow the exact schema defined in the - * `parameters` field. Only a subset of JSON Schema is supported when `strict` - * is `true`. Learn more about Structured Outputs in the [function calling - * guide](docs/guides/function-calling). - */ - strict: v.exactOptional(v.nullable(v.boolean())), -}); -export const inputAssistantToolsFunctionSchema = v.looseObject({ - /** - * The type of tool being defined: `function` - */ - type: v.picklist(["function"]), - function: inputFunctionObjectSchema, + response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), }); -export const assistantToolsFunctionSchema = inputAssistantToolsFunctionSchema; -/** - * The ranking options for the file search. If not specified, the file search - * tool will use the `auto` ranker and a score_threshold of 0. - * - * See the [file search tool - * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - * @title File search tool call ranking options - */ -export const inputFileSearchRankingOptionsSchema = v.looseObject({ +export const assistantObjectSchema = v.looseObject({ /** - * The ranker to use for the file search. If not specified will use the `auto` - * ranker. + * The identifier, which can be referenced in API endpoints. */ - ranker: v.optional(v.picklist(["auto", "default_2024_08_21"])), + id: v.pipe(v.string(), v.trim()), /** - * The score threshold for the file search. All values must be a floating - * point number between 0 and 1. + * The object type, which is always `assistant`. */ - score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), -}); -export const fileSearchRankingOptionsSchema = v.looseObject({ + object: v.picklist(["assistant"]), /** - * The ranker to use for the file search. If not specified will use the `auto` - * ranker. + * The Unix timestamp (in seconds) for when the assistant was created. */ - ranker: v.exactOptional(v.picklist(["auto", "default_2024_08_21"])), + created_at: v.pipe(v.number(), v.integer()), /** - * The score threshold for the file search. All values must be a floating - * point number between 0 and 1. + * The name of the assistant. The maximum length is 256 characters. */ - score_threshold: v.pipe(v.number(), v.minValue(0), v.maxValue(1)), -}); -export const inputAssistantToolsFileSearchSchema = v.looseObject({ + name: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256))), /** - * The type of tool being defined: `file_search` + * The description of the assistant. The maximum length is 512 characters. */ - type: v.picklist(["file_search"]), + description: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(512))), /** - * Overrides for the file search tool. + * ID of the model to use. You can use the [List + * models](/docs/api-reference/models/list) API to see all of your available + * models, or see our [Model overview](/docs/models/overview) for descriptions + * of them. */ - file_search: v.optional( - v.looseObject({ - /** - * The maximum number of results the file search tool should output. The - * default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number - * should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `max_num_results` - * results. See the [file search tool - * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - max_num_results: v.optional( - v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), - ), - ranking_options: v.optional(inputFileSearchRankingOptionsSchema), - }), - ), -}); -export const assistantToolsFileSearchSchema = v.looseObject({ + model: v.pipe(v.string(), v.trim()), /** - * The type of tool being defined: `file_search` + * The system instructions that the assistant uses. The maximum length is + * 256,000 characters. */ - type: v.picklist(["file_search"]), + instructions: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256_000))), /** - * Overrides for the file search tool. + * A list of tool enabled on the assistant. There can be a maximum of 128 + * tools per assistant. Tools can be of types `code_interpreter`, + * `file_search`, or `function`. */ - file_search: v.exactOptional( - v.looseObject({ - /** - * The maximum number of results the file search tool should output. The - * default is 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number - * should be between 1 and 50 inclusive. - * - * Note that the file search tool may output fewer than `max_num_results` - * results. See the [file search tool - * documentation](/docs/assistants/tools/file-search/customizing-file-search-settings) - * for more information. - */ - max_num_results: v.exactOptional( - v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), - ), - ranking_options: v.exactOptional(fileSearchRankingOptionsSchema), - }), + tools: v.pipe( + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchSchema, + assistantToolsFunctionSchema, + ]), + ), + v.maxLength(128), ), -}); -/** - * Represents an `assistant` that can call the model and use tools. - * @title Assistant - */ -export const inputAssistantObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.string(), /** - * The object type, which is always `assistant`. + * A set of resources that are used by the assistant's tools. The resources + * are specific to the type of tool. For example, the `code_interpreter` tool + * requires a list of file IDs, while the `file_search` tool requires a list + * of vector store IDs. */ - object: v.picklist(["assistant"]), + tool_resources: v.exactOptional( + v.nullable( + v.looseObject({ + code_interpreter: v.exactOptional( + v.looseObject({ + /** + * A list of [file](/docs/api-reference/files) IDs made available to the + * `code_interpreter`` tool. There can be a maximum of 20 files associated + * with the tool. + */ + file_ids: v.exactOptional( + v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(20)), + ), + }), + ), + file_search: v.exactOptional( + v.looseObject({ + /** + * The ID of the [vector store](/docs/api-reference/vector-stores/object) + * attached to this assistant. There can be a maximum of 1 vector store + * attached to the assistant. + */ + vector_store_ids: v.exactOptional( + v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(1)), + ), + }), + ), + }), + ), + ), /** - * The Unix timestamp (in seconds) for when the assistant was created. + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. */ - created_at: v.pipe(v.number(), v.integer()), + metadata: v.nullable(v.record(v.string(), v.unknown())), /** - * The name of the assistant. The maximum length is 256 characters. + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it + * more focused and deterministic. */ - name: v.nullable(v.pipe(v.string(), v.maxLength(256))), + temperature: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), + ), /** - * The description of the assistant. The maximum length is 512 characters. + * An alternative to sampling with temperature, called nucleus sampling, where + * the model considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are + * considered. + * + * We generally recommend altering this or temperature but not both. */ - description: v.nullable(v.pipe(v.string(), v.maxLength(512))), + top_p: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), + ), + response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), +}); +export const inputListAssistantsResponseSchema = v.looseObject({ + object: v.string(), + data: v.array(inputAssistantObjectSchema), + first_id: v.string(), + last_id: v.string(), + has_more: v.boolean(), +}); +export const listAssistantsResponseSchema = v.looseObject({ + object: v.pipe(v.string(), v.trim()), + data: v.array(assistantObjectSchema), + first_id: v.pipe(v.string(), v.trim()), + last_id: v.pipe(v.string(), v.trim()), + has_more: v.boolean(), +}); +export const inputModifyAssistantRequestSchema = v.strictObject({ /** * ID of the model to use. You can use the [List * models](/docs/api-reference/models/list) API to see all of your available * models, or see our [Model overview](/docs/models/overview) for descriptions * of them. */ - model: v.string(), + model: v.optional(v.string()), + /** + * The name of the assistant. The maximum length is 256 characters. + */ + name: v.optional(v.nullable(v.pipe(v.string(), v.maxLength(256)))), + /** + * The description of the assistant. The maximum length is 512 characters. + */ + description: v.optional(v.nullable(v.pipe(v.string(), v.maxLength(512)))), /** * The system instructions that the assistant uses. The maximum length is * 256,000 characters. */ - instructions: v.nullable(v.pipe(v.string(), v.maxLength(256_000))), + instructions: v.optional( + v.nullable(v.pipe(v.string(), v.maxLength(256_000))), + ), /** * A list of tool enabled on the assistant. There can be a maximum of 128 * tools per assistant. Tools can be of types `code_interpreter`, * `file_search`, or `function`. */ - tools: v.pipe( - v.array( - v.union([ - inputAssistantToolsCodeSchema, - inputAssistantToolsFileSearchSchema, - inputAssistantToolsFunctionSchema, - ]), + tools: v.optional( + v.pipe( + v.array( + v.union([ + inputAssistantToolsCodeSchema, + inputAssistantToolsFileSearchSchema, + inputAssistantToolsFunctionSchema, + ]), + ), + v.maxLength(128), ), - v.maxLength(128), ), /** * A set of resources that are used by the assistant's tools. The resources @@ -8470,9 +8394,9 @@ export const inputAssistantObjectSchema = v.looseObject({ code_interpreter: v.optional( v.looseObject({ /** - * A list of [file](/docs/api-reference/files) IDs made available to the - * `code_interpreter`` tool. There can be a maximum of 20 files associated - * with the tool. + * Overrides the list of [file](/docs/api-reference/files) IDs made available + * to the `code_interpreter` tool. There can be a maximum of 20 files + * associated with the tool. */ file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(20))), }), @@ -8480,7 +8404,7 @@ export const inputAssistantObjectSchema = v.looseObject({ file_search: v.optional( v.looseObject({ /** - * The ID of the [vector store](/docs/api-reference/vector-stores/object) + * Overrides the [vector store](/docs/api-reference/vector-stores/object) * attached to this assistant. There can be a maximum of 1 vector store * attached to the assistant. */ @@ -8498,7 +8422,7 @@ export const inputAssistantObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8520,53 +8444,49 @@ export const inputAssistantObjectSchema = v.looseObject({ ), response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), }); -export const assistantObjectSchema = v.looseObject({ - /** - * The identifier, which can be referenced in API endpoints. - */ - id: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always `assistant`. - */ - object: v.picklist(["assistant"]), +export const modifyAssistantRequestSchema = v.strictObject({ /** - * The Unix timestamp (in seconds) for when the assistant was created. + * ID of the model to use. You can use the [List + * models](/docs/api-reference/models/list) API to see all of your available + * models, or see our [Model overview](/docs/models/overview) for descriptions + * of them. */ - created_at: v.pipe(v.number(), v.integer()), + model: v.exactOptional(v.pipe(v.string(), v.trim())), /** * The name of the assistant. The maximum length is 256 characters. */ - name: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256))), + name: v.exactOptional( + v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256))), + ), /** * The description of the assistant. The maximum length is 512 characters. */ - description: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(512))), - /** - * ID of the model to use. You can use the [List - * models](/docs/api-reference/models/list) API to see all of your available - * models, or see our [Model overview](/docs/models/overview) for descriptions - * of them. - */ - model: v.pipe(v.string(), v.trim()), + description: v.exactOptional( + v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(512))), + ), /** * The system instructions that the assistant uses. The maximum length is * 256,000 characters. */ - instructions: v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256_000))), + instructions: v.exactOptional( + v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256_000))), + ), /** * A list of tool enabled on the assistant. There can be a maximum of 128 * tools per assistant. Tools can be of types `code_interpreter`, * `file_search`, or `function`. */ - tools: v.pipe( - v.array( - v.union([ - assistantToolsCodeSchema, - assistantToolsFileSearchSchema, - assistantToolsFunctionSchema, - ]), + tools: v.exactOptional( + v.pipe( + v.array( + v.union([ + assistantToolsCodeSchema, + assistantToolsFileSearchSchema, + assistantToolsFunctionSchema, + ]), + ), + v.maxLength(128), ), - v.maxLength(128), ), /** * A set of resources that are used by the assistant's tools. The resources @@ -8580,9 +8500,9 @@ export const assistantObjectSchema = v.looseObject({ code_interpreter: v.exactOptional( v.looseObject({ /** - * A list of [file](/docs/api-reference/files) IDs made available to the - * `code_interpreter`` tool. There can be a maximum of 20 files associated - * with the tool. + * Overrides the list of [file](/docs/api-reference/files) IDs made available + * to the `code_interpreter` tool. There can be a maximum of 20 files + * associated with the tool. */ file_ids: v.exactOptional( v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(20)), @@ -8592,7 +8512,7 @@ export const assistantObjectSchema = v.looseObject({ file_search: v.exactOptional( v.looseObject({ /** - * The ID of the [vector store](/docs/api-reference/vector-stores/object) + * Overrides the [vector store](/docs/api-reference/vector-stores/object) * attached to this assistant. There can be a maximum of 1 vector store * attached to the assistant. */ @@ -8610,7 +8530,7 @@ export const assistantObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8632,28 +8552,42 @@ export const assistantObjectSchema = v.looseObject({ ), response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), }); -export const inputListAssistantsResponseSchema = v.looseObject({ - object: v.string(), - data: v.array(inputAssistantObjectSchema), - first_id: v.string(), - last_id: v.string(), - has_more: v.boolean(), -}); -export const listAssistantsResponseSchema = v.looseObject({ - object: v.pipe(v.string(), v.trim()), - data: v.array(assistantObjectSchema), - first_id: v.pipe(v.string(), v.trim()), - last_id: v.pipe(v.string(), v.trim()), - has_more: v.boolean(), -}); -export const inputModifyAssistantRequestSchema = v.strictObject({ +export const inputCreateAssistantRequestSchema = v.strictObject({ /** * ID of the model to use. You can use the [List * models](/docs/api-reference/models/list) API to see all of your available * models, or see our [Model overview](/docs/models/overview) for descriptions * of them. */ - model: v.optional(v.string()), + model: v.union([ + v.string(), + v.picklist([ + "gpt-4o", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-2024-08-06", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613", + ]), + ]), /** * The name of the assistant. The maximum length is 256 characters. */ @@ -8698,24 +8632,18 @@ export const inputModifyAssistantRequestSchema = v.strictObject({ code_interpreter: v.optional( v.looseObject({ /** - * Overrides the list of [file](/docs/api-reference/files) IDs made available - * to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. + * A list of [file](/docs/api-reference/files) IDs made available to the + * `code_interpreter` tool. There can be a maximum of 20 files associated with + * the tool. */ file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(20))), }), ), file_search: v.optional( - v.looseObject({ - /** - * Overrides the [vector store](/docs/api-reference/vector-stores/object) - * attached to this assistant. There can be a maximum of 1 vector store - * attached to the assistant. - */ - vector_store_ids: v.optional( - v.pipe(v.array(v.string()), v.maxLength(1)), - ), - }), + v.union([ + v.record(v.string(), v.unknown()), + v.record(v.string(), v.unknown()), + ]), ), }), ), @@ -8748,14 +8676,42 @@ export const inputModifyAssistantRequestSchema = v.strictObject({ ), response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), }); -export const modifyAssistantRequestSchema = v.strictObject({ +export const createAssistantRequestSchema = v.strictObject({ /** * ID of the model to use. You can use the [List * models](/docs/api-reference/models/list) API to see all of your available * models, or see our [Model overview](/docs/models/overview) for descriptions * of them. */ - model: v.exactOptional(v.pipe(v.string(), v.trim())), + model: v.union([ + v.pipe(v.string(), v.trim()), + v.picklist([ + "gpt-4o", + "gpt-4o-2024-08-06", + "gpt-4o-2024-05-13", + "gpt-4o-2024-08-06", + "gpt-4o-mini", + "gpt-4o-mini-2024-07-18", + "gpt-4-turbo", + "gpt-4-turbo-2024-04-09", + "gpt-4-0125-preview", + "gpt-4-turbo-preview", + "gpt-4-1106-preview", + "gpt-4-vision-preview", + "gpt-4", + "gpt-4-0314", + "gpt-4-0613", + "gpt-4-32k", + "gpt-4-32k-0314", + "gpt-4-32k-0613", + "gpt-3.5-turbo", + "gpt-3.5-turbo-16k", + "gpt-3.5-turbo-0613", + "gpt-3.5-turbo-1106", + "gpt-3.5-turbo-0125", + "gpt-3.5-turbo-16k-0613", + ]), + ]), /** * The name of the assistant. The maximum length is 256 characters. */ @@ -8804,9 +8760,9 @@ export const modifyAssistantRequestSchema = v.strictObject({ code_interpreter: v.exactOptional( v.looseObject({ /** - * Overrides the list of [file](/docs/api-reference/files) IDs made available - * to the `code_interpreter` tool. There can be a maximum of 20 files - * associated with the tool. + * A list of [file](/docs/api-reference/files) IDs made available to the + * `code_interpreter` tool. There can be a maximum of 20 files associated with + * the tool. */ file_ids: v.exactOptional( v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(20)), @@ -8814,347 +8770,518 @@ export const modifyAssistantRequestSchema = v.strictObject({ }), ), file_search: v.exactOptional( - v.looseObject({ - /** - * Overrides the [vector store](/docs/api-reference/vector-stores/object) - * attached to this assistant. There can be a maximum of 1 vector store - * attached to the assistant. - */ - vector_store_ids: v.exactOptional( - v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(1)), - ), - }), + v.union([ + v.record(v.string(), v.unknown()), + v.record(v.string(), v.unknown()), + ]), + ), + }), + ), + ), + /** + * Set of 16 key-value pairs that can be attached to an object. This can be + * useful for storing additional information about the object in a structured + * format. Keys can be a maximum of 64 characters long and values can be a + * maximum of 512 characters long. + */ + metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + /** + * What sampling temperature to use, between 0 and 2. Higher values like 0.8 + * will make the output more random, while lower values like 0.2 will make it + * more focused and deterministic. + */ + temperature: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), + ), + /** + * An alternative to sampling with temperature, called nucleus sampling, where + * the model considers the results of the tokens with top_p probability mass. + * So 0.1 means only the tokens comprising the top 10% probability mass are + * considered. + * + * We generally recommend altering this or temperature but not both. + */ + top_p: v.exactOptional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), + ), + response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), +}); +export const inputChatCompletionFunctionsSchema = v.looseObject({ + /** + * A description of what the function does, used by the model to choose when + * and how to call the function. + */ + description: v.optional(v.string()), + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + name: v.string(), + parameters: v.optional(inputFunctionParametersSchema), +}); +export const chatCompletionFunctionsSchema = v.looseObject({ + /** + * A description of what the function does, used by the model to choose when + * and how to call the function. + */ + description: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain + * underscores and dashes, with a maximum length of 64. + */ + name: v.pipe(v.string(), v.trim()), + parameters: v.exactOptional(functionParametersSchema), +}); +export const inputChatCompletionToolSchema = v.looseObject({ + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: v.picklist(["function"]), + function: inputFunctionObjectSchema, +}); +export const chatCompletionToolSchema = inputChatCompletionToolSchema; +export const inputChatCompletionRequestFunctionMessageSchema = v.looseObject({ + /** + * The role of the messages author, in this case `function`. + */ + role: v.picklist(["function"]), + /** + * The contents of the function message. + */ + content: v.nullable(v.string()), + /** + * The name of the function to call. + */ + name: v.string(), +}); +export const chatCompletionRequestFunctionMessageSchema = v.looseObject({ + /** + * The role of the messages author, in this case `function`. + */ + role: v.picklist(["function"]), + /** + * The contents of the function message. + */ + content: v.nullable(v.pipe(v.string(), v.trim())), + /** + * The name of the function to call. + */ + name: v.pipe(v.string(), v.trim()), +}); +export const inputChatCompletionRequestMessageContentPartTextSchema = + v.looseObject({ + /** + * The type of the content part. + */ + type: v.picklist(["text"]), + /** + * The text content. + */ + text: v.string(), + }); +export const chatCompletionRequestMessageContentPartTextSchema = v.looseObject({ + /** + * The type of the content part. + */ + type: v.picklist(["text"]), + /** + * The text content. + */ + text: v.pipe(v.string(), v.trim()), +}); +export const inputChatCompletionRequestToolMessageContentPartSchema = + inputChatCompletionRequestMessageContentPartTextSchema; +export const chatCompletionRequestToolMessageContentPartSchema = + inputChatCompletionRequestToolMessageContentPartSchema; +export const inputChatCompletionRequestToolMessageSchema = v.looseObject({ + /** + * The role of the messages author, in this case `tool`. + */ + role: v.picklist(["tool"]), + /** + * The contents of the tool message. + */ + content: v.union([ + v.string(), + v.pipe( + v.array(inputChatCompletionRequestToolMessageContentPartSchema), + v.minLength(1), + ), + ]), + /** + * Tool call that this message is responding to. + */ + tool_call_id: v.string(), +}); +export const chatCompletionRequestToolMessageSchema = v.looseObject({ + /** + * The role of the messages author, in this case `tool`. + */ + role: v.picklist(["tool"]), + /** + * The contents of the tool message. + */ + content: v.union([ + v.pipe(v.string(), v.trim()), + v.pipe( + v.array(chatCompletionRequestToolMessageContentPartSchema), + v.minLength(1), + ), + ]), + /** + * Tool call that this message is responding to. + */ + tool_call_id: v.pipe(v.string(), v.trim()), +}); +export const inputChatCompletionMessageToolCallSchema = v.looseObject({ + /** + * The ID of the tool call. + */ + id: v.string(), + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: v.picklist(["function"]), + /** + * The function that the model called. + */ + function: v.looseObject({ + /** + * The name of the function to call. + */ + name: v.string(), + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.string(), + }), +}); +export const chatCompletionMessageToolCallSchema = v.looseObject({ + /** + * The ID of the tool call. + */ + id: v.pipe(v.string(), v.trim()), + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: v.picklist(["function"]), + /** + * The function that the model called. + */ + function: v.looseObject({ + /** + * The name of the function to call. + */ + name: v.pipe(v.string(), v.trim()), + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.pipe(v.string(), v.trim()), + }), +}); +/** The tool calls generated by the model, such as function calls. */ +export const inputChatCompletionMessageToolCallsSchema = v.array( + inputChatCompletionMessageToolCallSchema, +); +export const chatCompletionMessageToolCallsSchema = + inputChatCompletionMessageToolCallsSchema; +export const inputChatCompletionRequestMessageContentPartRefusalSchema = + v.looseObject({ + /** + * The type of the content part. + */ + type: v.picklist(["refusal"]), + /** + * The refusal message generated by the model. + */ + refusal: v.string(), + }); +export const chatCompletionRequestMessageContentPartRefusalSchema = + v.looseObject({ + /** + * The type of the content part. + */ + type: v.picklist(["refusal"]), + /** + * The refusal message generated by the model. + */ + refusal: v.pipe(v.string(), v.trim()), + }); +export const inputChatCompletionRequestAssistantMessageContentPartSchema = + v.union([ + inputChatCompletionRequestMessageContentPartTextSchema, + inputChatCompletionRequestMessageContentPartRefusalSchema, + ]); +export const chatCompletionRequestAssistantMessageContentPartSchema = + inputChatCompletionRequestAssistantMessageContentPartSchema; +export const inputChatCompletionRequestAssistantMessageSchema = v.looseObject({ + /** + * The contents of the assistant message. Required unless `tool_calls` or + * `function_call` is specified. + */ + content: v.optional( + v.nullable( + v.union([ + v.string(), + v.pipe( + v.array(inputChatCompletionRequestAssistantMessageContentPartSchema), + v.minLength(1), ), - }), + ]), ), ), /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. + * The refusal message by the assistant. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + refusal: v.optional(v.nullable(v.string())), /** - * What sampling temperature to use, between 0 and 2. Higher values like 0.8 - * will make the output more random, while lower values like 0.2 will make it - * more focused and deterministic. + * The role of the messages author, in this case `assistant`. */ - temperature: v.exactOptional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), - ), + role: v.picklist(["assistant"]), /** - * An alternative to sampling with temperature, called nucleus sampling, where - * the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are - * considered. - * - * We generally recommend altering this or temperature but not both. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - top_p: v.exactOptional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), - ), - response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), -}); -export const inputCreateAssistantRequestSchema = v.strictObject({ + name: v.optional(v.string()), + tool_calls: v.optional(inputChatCompletionMessageToolCallsSchema), /** - * ID of the model to use. You can use the [List - * models](/docs/api-reference/models/list) API to see all of your available - * models, or see our [Model overview](/docs/models/overview) for descriptions - * of them. + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. */ - model: v.union([ - v.string(), - v.picklist([ - "gpt-4o", - "gpt-4o-2024-08-06", - "gpt-4o-2024-05-13", - "gpt-4o-2024-08-06", - "gpt-4o-mini", - "gpt-4o-mini-2024-07-18", - "gpt-4-turbo", - "gpt-4-turbo-2024-04-09", - "gpt-4-0125-preview", - "gpt-4-turbo-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", - "gpt-4", - "gpt-4-0314", - "gpt-4-0613", - "gpt-4-32k", - "gpt-4-32k-0314", - "gpt-4-32k-0613", - "gpt-3.5-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-0613", - "gpt-3.5-turbo-1106", - "gpt-3.5-turbo-0125", - "gpt-3.5-turbo-16k-0613", - ]), - ]), + function_call: v.optional( + v.nullable( + v.looseObject({ + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.string(), + /** + * The name of the function to call. + */ + name: v.string(), + }), + ), + ), +}); +export const chatCompletionRequestAssistantMessageSchema = v.looseObject({ /** - * The name of the assistant. The maximum length is 256 characters. + * The contents of the assistant message. Required unless `tool_calls` or + * `function_call` is specified. */ - name: v.optional(v.nullable(v.pipe(v.string(), v.maxLength(256)))), + content: v.exactOptional( + v.nullable( + v.union([ + v.pipe(v.string(), v.trim()), + v.pipe( + v.array(chatCompletionRequestAssistantMessageContentPartSchema), + v.minLength(1), + ), + ]), + ), + ), /** - * The description of the assistant. The maximum length is 512 characters. + * The refusal message by the assistant. */ - description: v.optional(v.nullable(v.pipe(v.string(), v.maxLength(512)))), + refusal: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), /** - * The system instructions that the assistant uses. The maximum length is - * 256,000 characters. + * The role of the messages author, in this case `assistant`. */ - instructions: v.optional( - v.nullable(v.pipe(v.string(), v.maxLength(256_000))), - ), + role: v.picklist(["assistant"]), /** - * A list of tool enabled on the assistant. There can be a maximum of 128 - * tools per assistant. Tools can be of types `code_interpreter`, - * `file_search`, or `function`. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - tools: v.optional( - v.pipe( - v.array( - v.union([ - inputAssistantToolsCodeSchema, - inputAssistantToolsFileSearchSchema, - inputAssistantToolsFunctionSchema, - ]), - ), - v.maxLength(128), - ), - ), + name: v.exactOptional(v.pipe(v.string(), v.trim())), + tool_calls: v.exactOptional(chatCompletionMessageToolCallsSchema), /** - * A set of resources that are used by the assistant's tools. The resources - * are specific to the type of tool. For example, the `code_interpreter` tool - * requires a list of file IDs, while the `file_search` tool requires a list - * of vector store IDs. + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. */ - tool_resources: v.optional( + function_call: v.exactOptional( v.nullable( v.looseObject({ - code_interpreter: v.optional( - v.looseObject({ - /** - * A list of [file](/docs/api-reference/files) IDs made available to the - * `code_interpreter` tool. There can be a maximum of 20 files associated with - * the tool. - */ - file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(20))), - }), - ), - file_search: v.optional( - v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), - ]), - ), + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.pipe(v.string(), v.trim()), + /** + * The name of the function to call. + */ + name: v.pipe(v.string(), v.trim()), }), ), ), +}); +export const inputFineTuneChatCompletionRequestAssistantMessageSchema = + v.looseObject({ + /** + * Controls whether the assistant message is trained against (0 or 1) + */ + weight: v.optional(v.picklist([0, 1])), + ...inputChatCompletionRequestAssistantMessageSchema.entries, + }); +export const fineTuneChatCompletionRequestAssistantMessageSchema = + v.looseObject({ + /** + * Controls whether the assistant message is trained against (0 or 1) + */ + weight: v.exactOptional(v.picklist([0, 1])), + ...chatCompletionRequestAssistantMessageSchema.entries, + }); +export const inputChatCompletionRequestMessageContentPartImageSchema = + v.looseObject({ + /** + * The type of the content part. + */ + type: v.picklist(["image_url"]), + image_url: v.looseObject({ + /** + * Either a URL of the image or the base64 encoded image data. + */ + url: v.string(), + /** + * Specifies the detail level of the image. Learn more in the [Vision + * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + */ + detail: v.optional(v.picklist(["auto", "low", "high"])), + }), + }); +export const chatCompletionRequestMessageContentPartImageSchema = v.looseObject( + { + /** + * The type of the content part. + */ + type: v.picklist(["image_url"]), + image_url: v.looseObject({ + /** + * Either a URL of the image or the base64 encoded image data. + */ + url: v.pipe(v.string(), v.trim()), + /** + * Specifies the detail level of the image. Learn more in the [Vision + * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + */ + detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + }), + }, +); +export const inputChatCompletionRequestUserMessageContentPartSchema = v.union([ + inputChatCompletionRequestMessageContentPartTextSchema, + inputChatCompletionRequestMessageContentPartImageSchema, +]); +export const chatCompletionRequestUserMessageContentPartSchema = + inputChatCompletionRequestUserMessageContentPartSchema; +export const inputChatCompletionRequestUserMessageSchema = v.looseObject({ /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. + * The contents of the user message. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + content: v.union([ + v.string(), + v.pipe( + v.array(inputChatCompletionRequestUserMessageContentPartSchema), + v.minLength(1), + ), + ]), /** - * What sampling temperature to use, between 0 and 2. Higher values like 0.8 - * will make the output more random, while lower values like 0.2 will make it - * more focused and deterministic. + * The role of the messages author, in this case `user`. */ - temperature: v.optional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), - ), + role: v.picklist(["user"]), /** - * An alternative to sampling with temperature, called nucleus sampling, where - * the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are - * considered. - * - * We generally recommend altering this or temperature but not both. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - top_p: v.optional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), - ), - response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), + name: v.optional(v.string()), }); -export const createAssistantRequestSchema = v.strictObject({ +export const chatCompletionRequestUserMessageSchema = v.looseObject({ /** - * ID of the model to use. You can use the [List - * models](/docs/api-reference/models/list) API to see all of your available - * models, or see our [Model overview](/docs/models/overview) for descriptions - * of them. + * The contents of the user message. */ - model: v.union([ + content: v.union([ v.pipe(v.string(), v.trim()), - v.picklist([ - "gpt-4o", - "gpt-4o-2024-08-06", - "gpt-4o-2024-05-13", - "gpt-4o-2024-08-06", - "gpt-4o-mini", - "gpt-4o-mini-2024-07-18", - "gpt-4-turbo", - "gpt-4-turbo-2024-04-09", - "gpt-4-0125-preview", - "gpt-4-turbo-preview", - "gpt-4-1106-preview", - "gpt-4-vision-preview", - "gpt-4", - "gpt-4-0314", - "gpt-4-0613", - "gpt-4-32k", - "gpt-4-32k-0314", - "gpt-4-32k-0613", - "gpt-3.5-turbo", - "gpt-3.5-turbo-16k", - "gpt-3.5-turbo-0613", - "gpt-3.5-turbo-1106", - "gpt-3.5-turbo-0125", - "gpt-3.5-turbo-16k-0613", - ]), + v.pipe( + v.array(chatCompletionRequestUserMessageContentPartSchema), + v.minLength(1), + ), ]), /** - * The name of the assistant. The maximum length is 256 characters. - */ - name: v.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256))), - ), - /** - * The description of the assistant. The maximum length is 512 characters. + * The role of the messages author, in this case `user`. */ - description: v.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(512))), - ), + role: v.picklist(["user"]), /** - * The system instructions that the assistant uses. The maximum length is - * 256,000 characters. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - instructions: v.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256_000))), - ), + name: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +export const inputChatCompletionRequestSystemMessageContentPartSchema = + inputChatCompletionRequestMessageContentPartTextSchema; +export const chatCompletionRequestSystemMessageContentPartSchema = + inputChatCompletionRequestSystemMessageContentPartSchema; +export const inputChatCompletionRequestSystemMessageSchema = v.looseObject({ /** - * A list of tool enabled on the assistant. There can be a maximum of 128 - * tools per assistant. Tools can be of types `code_interpreter`, - * `file_search`, or `function`. + * The contents of the system message. */ - tools: v.exactOptional( + content: v.union([ + v.string(), v.pipe( - v.array( - v.union([ - assistantToolsCodeSchema, - assistantToolsFileSearchSchema, - assistantToolsFunctionSchema, - ]), - ), - v.maxLength(128), - ), - ), - /** - * A set of resources that are used by the assistant's tools. The resources - * are specific to the type of tool. For example, the `code_interpreter` tool - * requires a list of file IDs, while the `file_search` tool requires a list - * of vector store IDs. - */ - tool_resources: v.exactOptional( - v.nullable( - v.looseObject({ - code_interpreter: v.exactOptional( - v.looseObject({ - /** - * A list of [file](/docs/api-reference/files) IDs made available to the - * `code_interpreter` tool. There can be a maximum of 20 files associated with - * the tool. - */ - file_ids: v.exactOptional( - v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(20)), - ), - }), - ), - file_search: v.exactOptional( - v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), - ]), - ), - }), + v.array(inputChatCompletionRequestSystemMessageContentPartSchema), + v.minLength(1), ), - ), - /** - * Set of 16 key-value pairs that can be attached to an object. This can be - * useful for storing additional information about the object in a structured - * format. Keys can be a maximum of 64 characters long and values can be a - * maximum of 512 characters long. - */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), - /** - * What sampling temperature to use, between 0 and 2. Higher values like 0.8 - * will make the output more random, while lower values like 0.2 will make it - * more focused and deterministic. - */ - temperature: v.exactOptional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), - ), - /** - * An alternative to sampling with temperature, called nucleus sampling, where - * the model considers the results of the tokens with top_p probability mass. - * So 0.1 means only the tokens comprising the top 10% probability mass are - * considered. - * - * We generally recommend altering this or temperature but not both. - */ - top_p: v.exactOptional( - v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), - ), - response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), -}); -export const inputChatCompletionFunctionsSchema = v.looseObject({ + ]), /** - * A description of what the function does, used by the model to choose when - * and how to call the function. + * The role of the messages author, in this case `system`. */ - description: v.optional(v.string()), + role: v.picklist(["system"]), /** - * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain - * underscores and dashes, with a maximum length of 64. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - name: v.string(), - parameters: v.optional(inputFunctionParametersSchema), + name: v.optional(v.string()), }); -export const chatCompletionFunctionsSchema = v.looseObject({ +export const chatCompletionRequestSystemMessageSchema = v.looseObject({ /** - * A description of what the function does, used by the model to choose when - * and how to call the function. + * The contents of the system message. */ - description: v.exactOptional(v.pipe(v.string(), v.trim())), + content: v.union([ + v.pipe(v.string(), v.trim()), + v.pipe( + v.array(chatCompletionRequestSystemMessageContentPartSchema), + v.minLength(1), + ), + ]), /** - * The name of the function to be called. Must be a-z, A-Z, 0-9, or contain - * underscores and dashes, with a maximum length of 64. + * The role of the messages author, in this case `system`. */ - name: v.pipe(v.string(), v.trim()), - parameters: v.exactOptional(functionParametersSchema), -}); -export const inputChatCompletionToolSchema = v.looseObject({ + role: v.picklist(["system"]), /** - * The type of the tool. Currently, only `function` is supported. + * An optional name for the participant. Provides the model information to + * differentiate between participants of the same role. */ - type: v.picklist(["function"]), - function: inputFunctionObjectSchema, + name: v.exactOptional(v.pipe(v.string(), v.trim())), }); -export const chatCompletionToolSchema = inputChatCompletionToolSchema; /** The per-line training example of a fine-tuning input file for chat models */ export const inputFinetuneChatRequestInputSchema = v.looseObject({ messages: v.optional( v.pipe( v.array( v.union([ - v.unknown(), - v.unknown(), - v.unknown(), - v.unknown(), - v.unknown(), + inputChatCompletionRequestSystemMessageSchema, + inputChatCompletionRequestUserMessageSchema, + inputFineTuneChatCompletionRequestAssistantMessageSchema, + inputChatCompletionRequestToolMessageSchema, + inputChatCompletionRequestFunctionMessageSchema, ]), ), v.minLength(1), @@ -9176,36 +9303,114 @@ export const inputFinetuneChatRequestInputSchema = v.looseObject({ ), ), }); -export const finetuneChatRequestInputSchema = v.looseObject({ - messages: v.exactOptional( - v.pipe( - v.array( - v.union([ - v.unknown(), - v.unknown(), - v.unknown(), - v.unknown(), - v.unknown(), - ]), - ), - v.minLength(1), - ), - ), +export const finetuneChatRequestInputSchema = v.looseObject({ + messages: v.exactOptional( + v.pipe( + v.array( + v.union([ + chatCompletionRequestSystemMessageSchema, + chatCompletionRequestUserMessageSchema, + fineTuneChatCompletionRequestAssistantMessageSchema, + chatCompletionRequestToolMessageSchema, + chatCompletionRequestFunctionMessageSchema, + ]), + ), + v.minLength(1), + ), + ), + /** + * A list of tools the model may generate JSON inputs for. + */ + tools: v.exactOptional(v.array(chatCompletionToolSchema)), + parallel_tool_calls: v.exactOptional(parallelToolCallsSchema), + /** + * A list of functions the model may generate JSON inputs for. + */ + functions: v.exactOptional( + v.pipe( + v.array(chatCompletionFunctionsSchema), + v.minLength(1), + v.maxLength(128), + ), + ), +}); +export const inputFineTuningIntegrationSchema = v.looseObject({ + /** + * The type of the integration being enabled for the fine-tuning job + */ + type: v.picklist(["wandb"]), + /** + * The settings for your integration with Weights and Biases. This payload + * specifies the project that + * metrics will be sent to. Optionally, you can set an explicit display name + * for your run, add tags + * to your run, and set a default entity (team, username, etc) to be + * associated with your run. + */ + wandb: v.looseObject({ + /** + * The name of the project that the new run will be created under. + */ + project: v.string(), + /** + * A display name to set for the run. If not set, we will use the Job ID as + * the name. + */ + name: v.optional(v.nullable(v.string())), + /** + * The entity to use for the run. This allows you to set the team or username + * of the WandB user that you would + * like associated with the run. If not set, the default entity for the + * registered WandB API key is used. + */ + entity: v.optional(v.nullable(v.string())), + /** + * A list of tags to be attached to the newly created run. These tags are + * passed through directly to WandB. Some + * default tags are generated by OpenAI: "openai/finetune", + * "openai/{base-model}", "openai/{ftjob-abcdef}". + */ + tags: v.optional(v.array(v.string())), + }), +}); +export const fineTuningIntegrationSchema = v.looseObject({ /** - * A list of tools the model may generate JSON inputs for. + * The type of the integration being enabled for the fine-tuning job */ - tools: v.exactOptional(v.array(chatCompletionToolSchema)), - parallel_tool_calls: v.exactOptional(parallelToolCallsSchema), + type: v.picklist(["wandb"]), /** - * A list of functions the model may generate JSON inputs for. + * The settings for your integration with Weights and Biases. This payload + * specifies the project that + * metrics will be sent to. Optionally, you can set an explicit display name + * for your run, add tags + * to your run, and set a default entity (team, username, etc) to be + * associated with your run. */ - functions: v.exactOptional( - v.pipe( - v.array(chatCompletionFunctionsSchema), - v.minLength(1), - v.maxLength(128), - ), - ), + wandb: v.looseObject({ + /** + * The name of the project that the new run will be created under. + */ + project: v.pipe(v.string(), v.trim()), + /** + * A display name to set for the run. If not set, we will use the Job ID as + * the name. + */ + name: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + /** + * The entity to use for the run. This allows you to set the team or username + * of the WandB user that you would + * like associated with the run. If not set, the default entity for the + * registered WandB API key is used. + */ + entity: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + /** + * A list of tags to be attached to the newly created run. These tags are + * passed through directly to WandB. Some + * default tags are generated by OpenAI: "openai/finetune", + * "openai/{base-model}", "openai/{ftjob-abcdef}". + */ + tags: v.exactOptional(v.array(v.pipe(v.string(), v.trim()))), + }), }); /** * The `File` object represents a document that has been uploaded to OpenAI. @@ -9927,177 +10132,484 @@ export const inputListFilesResponseSchema = v.looseObject({ data: v.array(inputOpenAiFileSchema), object: v.picklist(["list"]), }); -export const listFilesResponseSchema = inputListFilesResponseSchema; -/** Represents the url or the content of an image generated by the OpenAI API. */ -export const inputImageSchema = v.looseObject({ +export const listFilesResponseSchema = inputListFilesResponseSchema; +/** Represents the url or the content of an image generated by the OpenAI API. */ +export const inputImageSchema = v.looseObject({ + /** + * The base64-encoded JSON of the generated image, if `response_format` is + * `b64_json`. + */ + b64_json: v.optional(v.string()), + /** + * The URL of the generated image, if `response_format` is `url` (default). + */ + url: v.optional(v.string()), + /** + * The prompt that was used to generate the image, if there was any revision + * to the prompt. + */ + revised_prompt: v.optional(v.string()), +}); +export const imageSchema = v.looseObject({ + /** + * The base64-encoded JSON of the generated image, if `response_format` is + * `b64_json`. + */ + b64_json: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The URL of the generated image, if `response_format` is `url` (default). + */ + url: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The prompt that was used to generate the image, if there was any revision + * to the prompt. + */ + revised_prompt: v.exactOptional(v.pipe(v.string(), v.trim())), +}); +export const inputImagesResponseSchema = v.looseObject({ + created: v.pipe(v.number(), v.integer()), + data: v.array(inputImageSchema), +}); +export const imagesResponseSchema = inputImagesResponseSchema; +export const inputChatCompletionTokenLogprobSchema = v.looseObject({ + /** + * The token. + */ + token: v.string(), + /** + * The log probability of this token, if it is within the top 20 most likely + * tokens. Otherwise, the value `-9999.0` is used to signify that the token is + * very unlikely. + */ + logprob: v.number(), + /** + * A list of integers representing the UTF-8 bytes representation of the + * token. Useful in instances where characters are represented by multiple + * tokens and their byte representations must be combined to generate the + * correct text representation. Can be `null` if there is no bytes + * representation for the token. + */ + bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + /** + * List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs` returned. + */ + top_logprobs: v.array( + v.looseObject({ + /** + * The token. + */ + token: v.string(), + /** + * The log probability of this token, if it is within the top 20 most likely + * tokens. Otherwise, the value `-9999.0` is used to signify that the token is + * very unlikely. + */ + logprob: v.number(), + /** + * A list of integers representing the UTF-8 bytes representation of the + * token. Useful in instances where characters are represented by multiple + * tokens and their byte representations must be combined to generate the + * correct text representation. Can be `null` if there is no bytes + * representation for the token. + */ + bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + }), + ), +}); +export const chatCompletionTokenLogprobSchema = v.looseObject({ + /** + * The token. + */ + token: v.pipe(v.string(), v.trim()), + /** + * The log probability of this token, if it is within the top 20 most likely + * tokens. Otherwise, the value `-9999.0` is used to signify that the token is + * very unlikely. + */ + logprob: v.number(), + /** + * A list of integers representing the UTF-8 bytes representation of the + * token. Useful in instances where characters are represented by multiple + * tokens and their byte representations must be combined to generate the + * correct text representation. Can be `null` if there is no bytes + * representation for the token. + */ + bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + /** + * List of the most likely tokens and their log probability, at this token + * position. In rare cases, there may be fewer than the number of requested + * `top_logprobs` returned. + */ + top_logprobs: v.array( + v.looseObject({ + /** + * The token. + */ + token: v.pipe(v.string(), v.trim()), + /** + * The log probability of this token, if it is within the top 20 most likely + * tokens. Otherwise, the value `-9999.0` is used to signify that the token is + * very unlikely. + */ + logprob: v.number(), + /** + * A list of integers representing the UTF-8 bytes representation of the + * token. Useful in instances where characters are represented by multiple + * tokens and their byte representations must be combined to generate the + * correct text representation. Can be `null` if there is no bytes + * representation for the token. + */ + bytes: v.nullable(v.array(v.pipe(v.number(), v.integer()))), + }), + ), +}); +export const inputChatCompletionMessageToolCallChunkSchema = v.looseObject({ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call. + */ + id: v.optional(v.string()), + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: v.optional(v.picklist(["function"])), + function: v.optional( + v.looseObject({ + /** + * The name of the function to call. + */ + name: v.optional(v.string()), + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.optional(v.string()), + }), + ), +}); +export const chatCompletionMessageToolCallChunkSchema = v.looseObject({ + index: v.pipe(v.number(), v.integer()), + /** + * The ID of the tool call. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The type of the tool. Currently, only `function` is supported. + */ + type: v.exactOptional(v.picklist(["function"])), + function: v.exactOptional( + v.looseObject({ + /** + * The name of the function to call. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), +}); +/** A chat completion delta generated by streamed model responses. */ +export const inputChatCompletionStreamResponseDeltaSchema = v.looseObject({ /** - * The base64-encoded JSON of the generated image, if `response_format` is - * `b64_json`. + * The contents of the chunk message. */ - b64_json: v.optional(v.string()), + content: v.optional(v.nullable(v.string())), /** - * The URL of the generated image, if `response_format` is `url` (default). + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. */ - url: v.optional(v.string()), + function_call: v.optional( + v.looseObject({ + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.optional(v.string()), + /** + * The name of the function to call. + */ + name: v.optional(v.string()), + }), + ), + tool_calls: v.optional( + v.array(inputChatCompletionMessageToolCallChunkSchema), + ), /** - * The prompt that was used to generate the image, if there was any revision - * to the prompt. + * The role of the author of this message. */ - revised_prompt: v.optional(v.string()), + role: v.optional(v.picklist(["system", "user", "assistant", "tool"])), + /** + * The refusal message generated by the model. + */ + refusal: v.optional(v.nullable(v.string())), }); -export const imageSchema = v.looseObject({ +export const chatCompletionStreamResponseDeltaSchema = v.looseObject({ /** - * The base64-encoded JSON of the generated image, if `response_format` is - * `b64_json`. + * The contents of the chunk message. */ - b64_json: v.exactOptional(v.pipe(v.string(), v.trim())), + content: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), /** - * The URL of the generated image, if `response_format` is `url` (default). + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. */ - url: v.exactOptional(v.pipe(v.string(), v.trim())), + function_call: v.exactOptional( + v.looseObject({ + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The name of the function to call. + */ + name: v.exactOptional(v.pipe(v.string(), v.trim())), + }), + ), + tool_calls: v.exactOptional( + v.array(chatCompletionMessageToolCallChunkSchema), + ), /** - * The prompt that was used to generate the image, if there was any revision - * to the prompt. + * The role of the author of this message. */ - revised_prompt: v.exactOptional(v.pipe(v.string(), v.trim())), -}); -export const inputImagesResponseSchema = v.looseObject({ - created: v.pipe(v.number(), v.integer()), - data: v.array(inputImageSchema), + role: v.exactOptional(v.picklist(["system", "user", "assistant", "tool"])), + /** + * The refusal message generated by the model. + */ + refusal: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), }); -export const imagesResponseSchema = inputImagesResponseSchema; /** - * The `fine_tuning.job` object represents a fine-tuning job that has been - * created through the API. - * @title FineTuningJob + * Represents a streamed chunk of a chat completion response returned by + * model, based on the provided input. */ -export const inputFineTuningJobSchema = v.looseObject({ +export const inputCreateChatCompletionStreamResponseSchema = v.looseObject({ /** - * The object identifier, which can be referenced in the API endpoints. + * A unique identifier for the chat completion. Each chunk has the same ID. */ id: v.string(), /** - * The Unix timestamp (in seconds) for when the fine-tuning job was created. - */ - created_at: v.pipe(v.number(), v.integer()), - /** - * For fine-tuning jobs that have `failed`, this will contain more information - * on the cause of the failure. + * A list of chat completion choices. Can contain more than one elements if + * `n` is greater than 1. Can also be empty for the + * last chunk if you set `stream_options: {"include_usage": true}`. */ - error: v.nullable( + choices: v.array( v.looseObject({ + delta: inputChatCompletionStreamResponseDeltaSchema, /** - * A machine-readable error code. + * Log probability information for the choice. */ - code: v.string(), + logprobs: v.optional( + v.nullable( + v.looseObject({ + /** + * A list of message content tokens with log probability information. + */ + content: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), + /** + * A list of message refusal tokens with log probability information. + */ + refusal: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), + }), + ), + ), /** - * A human-readable error message. + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if + * the model called a function. */ - message: v.string(), + finish_reason: v.nullable( + v.picklist([ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ]), + ), /** - * The parameter that was invalid, usually `training_file` or - * `validation_file`. This field will be null if the failure was not - * parameter-specific. + * The index of the choice in the list of choices. */ - param: v.nullable(v.string()), + index: v.pipe(v.number(), v.integer()), }), ), /** - * The name of the fine-tuned model that is being created. The value will be - * null if the fine-tuning job is still running. + * The Unix timestamp (in seconds) of when the chat completion was created. + * Each chunk has the same timestamp. */ - fine_tuned_model: v.nullable(v.string()), + created: v.pipe(v.number(), v.integer()), /** - * The Unix timestamp (in seconds) for when the fine-tuning job was finished. - * The value will be null if the fine-tuning job is still running. + * The model to generate the completion. */ - finished_at: v.nullable(v.pipe(v.number(), v.integer())), + model: v.string(), /** - * The hyperparameters used for the fine-tuning job. See the [fine-tuning - * guide](/docs/guides/fine-tuning) for more details. + * The service tier used for processing the request. This field is only + * included if the `service_tier` parameter is specified in the request. */ - hyperparameters: v.looseObject({ - /** - * The number of epochs to train the model for. An epoch refers to one full - * cycle through the training dataset. - * "auto" decides the optimal number of epochs based on the size of the - * dataset. If setting the number manually, we support any number between 1 - * and 50 epochs. - */ - n_epochs: v.union([ - v.picklist(["auto"]), - v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), - ]), - }), + service_tier: v.optional(v.nullable(v.picklist(["scale", "default"]))), /** - * The base model that is being fine-tuned. + * This fingerprint represents the backend configuration that the model runs + * with. + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - model: v.string(), + system_fingerprint: v.optional(v.string()), /** - * The object type, which is always "fine_tuning.job". + * The object type, which is always `chat.completion.chunk`. */ - object: v.picklist(["fine_tuning.job"]), + object: v.picklist(["chat.completion.chunk"]), /** - * The organization that owns the fine-tuning job. + * An optional field that will only be present when you set `stream_options: + * {"include_usage": true}` in your request. + * When present, it contains a null value except for the last chunk which + * contains the token usage statistics for the entire request. */ - organization_id: v.string(), + usage: v.optional( + v.looseObject({ + /** + * Number of tokens in the generated completion. + */ + completion_tokens: v.pipe(v.number(), v.integer()), + /** + * Number of tokens in the prompt. + */ + prompt_tokens: v.pipe(v.number(), v.integer()), + /** + * Total number of tokens used in the request (prompt + completion). + */ + total_tokens: v.pipe(v.number(), v.integer()), + }), + ), +}); +export const createChatCompletionStreamResponseSchema = v.looseObject({ + /** + * A unique identifier for the chat completion. Each chunk has the same ID. + */ + id: v.pipe(v.string(), v.trim()), + /** + * A list of chat completion choices. Can contain more than one elements if + * `n` is greater than 1. Can also be empty for the + * last chunk if you set `stream_options: {"include_usage": true}`. + */ + choices: v.array( + v.looseObject({ + delta: chatCompletionStreamResponseDeltaSchema, + /** + * Log probability information for the choice. + */ + logprobs: v.exactOptional( + v.nullable( + v.looseObject({ + /** + * A list of message content tokens with log probability information. + */ + content: v.nullable(v.array(chatCompletionTokenLogprobSchema)), + /** + * A list of message refusal tokens with log probability information. + */ + refusal: v.nullable(v.array(chatCompletionTokenLogprobSchema)), + }), + ), + ), + /** + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if + * the model called a function. + */ + finish_reason: v.nullable( + v.picklist([ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ]), + ), + /** + * The index of the choice in the list of choices. + */ + index: v.pipe(v.number(), v.integer()), + }), + ), /** - * The compiled results file ID(s) for the fine-tuning job. You can retrieve - * the results with the [Files - * API](/docs/api-reference/files/retrieve-contents). + * The Unix timestamp (in seconds) of when the chat completion was created. + * Each chunk has the same timestamp. */ - result_files: v.array(v.string()), + created: v.pipe(v.number(), v.integer()), /** - * The current status of the fine-tuning job, which can be either - * `validating_files`, `queued`, `running`, `succeeded`, `failed`, or - * `cancelled`. + * The model to generate the completion. */ - status: v.picklist([ - "validating_files", - "queued", - "running", - "succeeded", - "failed", - "cancelled", - ]), + model: v.pipe(v.string(), v.trim()), /** - * The total number of billable tokens processed by this fine-tuning job. The - * value will be null if the fine-tuning job is still running. + * The service tier used for processing the request. This field is only + * included if the `service_tier` parameter is specified in the request. */ - trained_tokens: v.nullable(v.pipe(v.number(), v.integer())), + service_tier: v.exactOptional(v.nullable(v.picklist(["scale", "default"]))), /** - * The file ID used for training. You can retrieve the training data with the - * [Files API](/docs/api-reference/files/retrieve-contents). + * This fingerprint represents the backend configuration that the model runs + * with. + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - training_file: v.string(), + system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The file ID used for validation. You can retrieve the validation results - * with the [Files API](/docs/api-reference/files/retrieve-contents). + * The object type, which is always `chat.completion.chunk`. */ - validation_file: v.nullable(v.string()), + object: v.picklist(["chat.completion.chunk"]), /** - * A list of integrations to enable for this fine-tuning job. + * An optional field that will only be present when you set `stream_options: + * {"include_usage": true}` in your request. + * When present, it contains a null value except for the last chunk which + * contains the token usage statistics for the entire request. */ - integrations: v.optional( - v.nullable( - v.pipe(v.array(inputFineTuningIntegrationSchema), v.maxLength(5)), - ), + usage: v.exactOptional( + v.looseObject({ + /** + * Number of tokens in the generated completion. + */ + completion_tokens: v.pipe(v.number(), v.integer()), + /** + * Number of tokens in the prompt. + */ + prompt_tokens: v.pipe(v.number(), v.integer()), + /** + * Total number of tokens used in the request (prompt + completion). + */ + total_tokens: v.pipe(v.number(), v.integer()), + }), ), - /** - * The seed used for the fine-tuning job. - */ - seed: v.pipe(v.number(), v.integer()), - /** - * The Unix timestamp (in seconds) for when the fine-tuning job is estimated - * to finish. The value will be null if the fine-tuning job is not running. - */ - estimated_finish: v.optional(v.nullable(v.pipe(v.number(), v.integer()))), }); -export const fineTuningJobSchema = v.looseObject({ +/** + * The `fine_tuning.job` object represents a fine-tuning job that has been + * created through the API. + * @title FineTuningJob + */ +export const inputFineTuningJobSchema = v.looseObject({ /** * The object identifier, which can be referenced in the API endpoints. */ - id: v.pipe(v.string(), v.trim()), + id: v.string(), /** * The Unix timestamp (in seconds) for when the fine-tuning job was created. */ @@ -10111,24 +10623,24 @@ export const fineTuningJobSchema = v.looseObject({ /** * A machine-readable error code. */ - code: v.pipe(v.string(), v.trim()), + code: v.string(), /** * A human-readable error message. */ - message: v.pipe(v.string(), v.trim()), + message: v.string(), /** * The parameter that was invalid, usually `training_file` or * `validation_file`. This field will be null if the failure was not * parameter-specific. */ - param: v.nullable(v.pipe(v.string(), v.trim())), + param: v.nullable(v.string()), }), ), /** * The name of the fine-tuned model that is being created. The value will be * null if the fine-tuning job is still running. */ - fine_tuned_model: v.nullable(v.pipe(v.string(), v.trim())), + fine_tuned_model: v.nullable(v.string()), /** * The Unix timestamp (in seconds) for when the fine-tuning job was finished. * The value will be null if the fine-tuning job is still running. @@ -10154,896 +10666,672 @@ export const fineTuningJobSchema = v.looseObject({ /** * The base model that is being fine-tuned. */ - model: v.pipe(v.string(), v.trim()), - /** - * The object type, which is always "fine_tuning.job". - */ - object: v.picklist(["fine_tuning.job"]), - /** - * The organization that owns the fine-tuning job. - */ - organization_id: v.pipe(v.string(), v.trim()), - /** - * The compiled results file ID(s) for the fine-tuning job. You can retrieve - * the results with the [Files - * API](/docs/api-reference/files/retrieve-contents). - */ - result_files: v.array(v.pipe(v.string(), v.trim())), - /** - * The current status of the fine-tuning job, which can be either - * `validating_files`, `queued`, `running`, `succeeded`, `failed`, or - * `cancelled`. - */ - status: v.picklist([ - "validating_files", - "queued", - "running", - "succeeded", - "failed", - "cancelled", - ]), - /** - * The total number of billable tokens processed by this fine-tuning job. The - * value will be null if the fine-tuning job is still running. - */ - trained_tokens: v.nullable(v.pipe(v.number(), v.integer())), - /** - * The file ID used for training. You can retrieve the training data with the - * [Files API](/docs/api-reference/files/retrieve-contents). - */ - training_file: v.pipe(v.string(), v.trim()), - /** - * The file ID used for validation. You can retrieve the validation results - * with the [Files API](/docs/api-reference/files/retrieve-contents). - */ - validation_file: v.nullable(v.pipe(v.string(), v.trim())), - /** - * A list of integrations to enable for this fine-tuning job. - */ - integrations: v.exactOptional( - v.nullable(v.pipe(v.array(fineTuningIntegrationSchema), v.maxLength(5))), - ), - /** - * The seed used for the fine-tuning job. - */ - seed: v.pipe(v.number(), v.integer()), - /** - * The Unix timestamp (in seconds) for when the fine-tuning job is estimated - * to finish. The value will be null if the fine-tuning job is not running. - */ - estimated_finish: v.exactOptional( - v.nullable(v.pipe(v.number(), v.integer())), - ), -}); -export const inputListPaginatedFineTuningJobsResponseSchema = v.looseObject({ - data: v.array(inputFineTuningJobSchema), - has_more: v.boolean(), - object: v.picklist(["list"]), -}); -export const listPaginatedFineTuningJobsResponseSchema = - inputListPaginatedFineTuningJobsResponseSchema; -/** Usage statistics for the completion request. */ -export const inputCompletionUsageSchema = v.looseObject({ - /** - * Number of tokens in the generated completion. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of tokens in the prompt. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used in the request (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - /** - * Breakdown of tokens used in a completion. - */ - completion_tokens_details: v.optional( - v.looseObject({ - /** - * Tokens generated by the model for reasoning. - */ - reasoning_tokens: v.optional(v.pipe(v.number(), v.integer())), - }), - ), -}); -export const completionUsageSchema = v.looseObject({ - /** - * Number of tokens in the generated completion. - */ - completion_tokens: v.pipe(v.number(), v.integer()), - /** - * Number of tokens in the prompt. - */ - prompt_tokens: v.pipe(v.number(), v.integer()), - /** - * Total number of tokens used in the request (prompt + completion). - */ - total_tokens: v.pipe(v.number(), v.integer()), - /** - * Breakdown of tokens used in a completion. - */ - completion_tokens_details: v.exactOptional( - v.looseObject({ - /** - * Tokens generated by the model for reasoning. - */ - reasoning_tokens: v.exactOptional(v.pipe(v.number(), v.integer())), - }), - ), -}); -/** - * Represents a chat completion response returned by model, based on the - * provided input. - */ -export const inputCreateChatCompletionFunctionResponseSchema = v.looseObject({ - /** - * A unique identifier for the chat completion. - */ - id: v.string(), - /** - * A list of chat completion choices. Can be more than one if `n` is greater - * than 1. - */ - choices: v.array( - v.looseObject({ - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, `length` if the - * maximum number of tokens specified in the request was reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, or `function_call` if the model called a function. - */ - finish_reason: v.picklist([ - "stop", - "length", - "function_call", - "content_filter", - ]), - /** - * The index of the choice in the list of choices. - */ - index: v.pipe(v.number(), v.integer()), - message: v.unknown(), - }), - ), + model: v.string(), /** - * The Unix timestamp (in seconds) of when the chat completion was created. + * The object type, which is always "fine_tuning.job". */ - created: v.pipe(v.number(), v.integer()), + object: v.picklist(["fine_tuning.job"]), /** - * The model used for the chat completion. + * The organization that owns the fine-tuning job. */ - model: v.string(), + organization_id: v.string(), /** - * This fingerprint represents the backend configuration that the model runs - * with. - * - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. + * The compiled results file ID(s) for the fine-tuning job. You can retrieve + * the results with the [Files + * API](/docs/api-reference/files/retrieve-contents). */ - system_fingerprint: v.optional(v.string()), + result_files: v.array(v.string()), /** - * The object type, which is always `chat.completion`. + * The current status of the fine-tuning job, which can be either + * `validating_files`, `queued`, `running`, `succeeded`, `failed`, or + * `cancelled`. */ - object: v.picklist(["chat.completion"]), - usage: v.optional(inputCompletionUsageSchema), -}); -export const createChatCompletionFunctionResponseSchema = v.looseObject({ + status: v.picklist([ + "validating_files", + "queued", + "running", + "succeeded", + "failed", + "cancelled", + ]), /** - * A unique identifier for the chat completion. + * The total number of billable tokens processed by this fine-tuning job. The + * value will be null if the fine-tuning job is still running. */ - id: v.pipe(v.string(), v.trim()), + trained_tokens: v.nullable(v.pipe(v.number(), v.integer())), /** - * A list of chat completion choices. Can be more than one if `n` is greater - * than 1. + * The file ID used for training. You can retrieve the training data with the + * [Files API](/docs/api-reference/files/retrieve-contents). */ - choices: v.array( - v.looseObject({ - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, `length` if the - * maximum number of tokens specified in the request was reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, or `function_call` if the model called a function. - */ - finish_reason: v.picklist([ - "stop", - "length", - "function_call", - "content_filter", - ]), - /** - * The index of the choice in the list of choices. - */ - index: v.pipe(v.number(), v.integer()), - message: v.unknown(), - }), - ), + training_file: v.string(), /** - * The Unix timestamp (in seconds) of when the chat completion was created. + * The file ID used for validation. You can retrieve the validation results + * with the [Files API](/docs/api-reference/files/retrieve-contents). */ - created: v.pipe(v.number(), v.integer()), + validation_file: v.nullable(v.string()), /** - * The model used for the chat completion. + * A list of integrations to enable for this fine-tuning job. */ - model: v.pipe(v.string(), v.trim()), + integrations: v.optional( + v.nullable( + v.pipe(v.array(inputFineTuningIntegrationSchema), v.maxLength(5)), + ), + ), /** - * This fingerprint represents the backend configuration that the model runs - * with. - * - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. + * The seed used for the fine-tuning job. */ - system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), + seed: v.pipe(v.number(), v.integer()), /** - * The object type, which is always `chat.completion`. + * The Unix timestamp (in seconds) for when the fine-tuning job is estimated + * to finish. The value will be null if the fine-tuning job is not running. */ - object: v.picklist(["chat.completion"]), - usage: v.exactOptional(completionUsageSchema), + estimated_finish: v.optional(v.nullable(v.pipe(v.number(), v.integer()))), }); -/** - * Represents a chat completion response returned by model, based on the - * provided input. - */ -export const inputCreateChatCompletionResponseSchema = v.looseObject({ +export const fineTuningJobSchema = v.looseObject({ /** - * A unique identifier for the chat completion. + * The object identifier, which can be referenced in the API endpoints. */ - id: v.string(), + id: v.pipe(v.string(), v.trim()), /** - * A list of chat completion choices. Can be more than one if `n` is greater - * than 1. + * The Unix timestamp (in seconds) for when the fine-tuning job was created. */ - choices: v.array( + created_at: v.pipe(v.number(), v.integer()), + /** + * For fine-tuning jobs that have `failed`, this will contain more information + * on the cause of the failure. + */ + error: v.nullable( v.looseObject({ /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was - * reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if - * the model called a function. + * A machine-readable error code. */ - finish_reason: v.picklist([ - "stop", - "length", - "tool_calls", - "content_filter", - "function_call", - ]), + code: v.pipe(v.string(), v.trim()), /** - * The index of the choice in the list of choices. + * A human-readable error message. */ - index: v.pipe(v.number(), v.integer()), - message: v.unknown(), + message: v.pipe(v.string(), v.trim()), /** - * Log probability information for the choice. + * The parameter that was invalid, usually `training_file` or + * `validation_file`. This field will be null if the failure was not + * parameter-specific. */ - logprobs: v.nullable( - v.looseObject({ - /** - * A list of message content tokens with log probability information. - */ - content: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), - /** - * A list of message refusal tokens with log probability information. - */ - refusal: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), - }), - ), + param: v.nullable(v.pipe(v.string(), v.trim())), }), ), /** - * The Unix timestamp (in seconds) of when the chat completion was created. + * The name of the fine-tuned model that is being created. The value will be + * null if the fine-tuning job is still running. */ - created: v.pipe(v.number(), v.integer()), + fine_tuned_model: v.nullable(v.pipe(v.string(), v.trim())), /** - * The model used for the chat completion. + * The Unix timestamp (in seconds) for when the fine-tuning job was finished. + * The value will be null if the fine-tuning job is still running. */ - model: v.string(), + finished_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The service tier used for processing the request. This field is only - * included if the `service_tier` parameter is specified in the request. + * The hyperparameters used for the fine-tuning job. See the [fine-tuning + * guide](/docs/guides/fine-tuning) for more details. */ - service_tier: v.optional(v.nullable(v.picklist(["scale", "default"]))), + hyperparameters: v.looseObject({ + /** + * The number of epochs to train the model for. An epoch refers to one full + * cycle through the training dataset. + * "auto" decides the optimal number of epochs based on the size of the + * dataset. If setting the number manually, we support any number between 1 + * and 50 epochs. + */ + n_epochs: v.union([ + v.picklist(["auto"]), + v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(50)), + ]), + }), /** - * This fingerprint represents the backend configuration that the model runs - * with. - * - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. + * The base model that is being fine-tuned. */ - system_fingerprint: v.optional(v.string()), + model: v.pipe(v.string(), v.trim()), /** - * The object type, which is always `chat.completion`. + * The object type, which is always "fine_tuning.job". */ - object: v.picklist(["chat.completion"]), - usage: v.optional(inputCompletionUsageSchema), -}); -export const createChatCompletionResponseSchema = v.looseObject({ + object: v.picklist(["fine_tuning.job"]), /** - * A unique identifier for the chat completion. + * The organization that owns the fine-tuning job. */ - id: v.pipe(v.string(), v.trim()), + organization_id: v.pipe(v.string(), v.trim()), /** - * A list of chat completion choices. Can be more than one if `n` is greater - * than 1. + * The compiled results file ID(s) for the fine-tuning job. You can retrieve + * the results with the [Files + * API](/docs/api-reference/files/retrieve-contents). */ - choices: v.array( - v.looseObject({ - /** - * The reason the model stopped generating tokens. This will be `stop` if the - * model hit a natural stop point or a provided stop sequence, - * `length` if the maximum number of tokens specified in the request was - * reached, - * `content_filter` if content was omitted due to a flag from our content - * filters, - * `tool_calls` if the model called a tool, or `function_call` (deprecated) if - * the model called a function. - */ - finish_reason: v.picklist([ - "stop", - "length", - "tool_calls", - "content_filter", - "function_call", - ]), - /** - * The index of the choice in the list of choices. - */ - index: v.pipe(v.number(), v.integer()), - message: v.unknown(), - /** - * Log probability information for the choice. - */ - logprobs: v.nullable( - v.looseObject({ - /** - * A list of message content tokens with log probability information. - */ - content: v.nullable(v.array(chatCompletionTokenLogprobSchema)), - /** - * A list of message refusal tokens with log probability information. - */ - refusal: v.nullable(v.array(chatCompletionTokenLogprobSchema)), - }), - ), - }), - ), + result_files: v.array(v.pipe(v.string(), v.trim())), + /** + * The current status of the fine-tuning job, which can be either + * `validating_files`, `queued`, `running`, `succeeded`, `failed`, or + * `cancelled`. + */ + status: v.picklist([ + "validating_files", + "queued", + "running", + "succeeded", + "failed", + "cancelled", + ]), /** - * The Unix timestamp (in seconds) of when the chat completion was created. + * The total number of billable tokens processed by this fine-tuning job. The + * value will be null if the fine-tuning job is still running. */ - created: v.pipe(v.number(), v.integer()), + trained_tokens: v.nullable(v.pipe(v.number(), v.integer())), /** - * The model used for the chat completion. + * The file ID used for training. You can retrieve the training data with the + * [Files API](/docs/api-reference/files/retrieve-contents). */ - model: v.pipe(v.string(), v.trim()), + training_file: v.pipe(v.string(), v.trim()), /** - * The service tier used for processing the request. This field is only - * included if the `service_tier` parameter is specified in the request. + * The file ID used for validation. You can retrieve the validation results + * with the [Files API](/docs/api-reference/files/retrieve-contents). */ - service_tier: v.exactOptional(v.nullable(v.picklist(["scale", "default"]))), + validation_file: v.nullable(v.pipe(v.string(), v.trim())), /** - * This fingerprint represents the backend configuration that the model runs - * with. - * - * Can be used in conjunction with the `seed` request parameter to understand - * when backend changes have been made that might impact determinism. + * A list of integrations to enable for this fine-tuning job. */ - system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), + integrations: v.exactOptional( + v.nullable(v.pipe(v.array(fineTuningIntegrationSchema), v.maxLength(5))), + ), /** - * The object type, which is always `chat.completion`. + * The seed used for the fine-tuning job. */ - object: v.picklist(["chat.completion"]), - usage: v.exactOptional(completionUsageSchema), -}); -/** - * Specifying a particular function via `{"name": "my_function"}` forces the - * model to call that function. - */ -export const inputChatCompletionFunctionCallOptionSchema = v.looseObject({ + seed: v.pipe(v.number(), v.integer()), /** - * The name of the function to call. + * The Unix timestamp (in seconds) for when the fine-tuning job is estimated + * to finish. The value will be null if the fine-tuning job is not running. */ - name: v.string(), + estimated_finish: v.exactOptional( + v.nullable(v.pipe(v.number(), v.integer())), + ), }); -export const chatCompletionFunctionCallOptionSchema = v.looseObject({ +export const inputListPaginatedFineTuningJobsResponseSchema = v.looseObject({ + data: v.array(inputFineTuningJobSchema), + has_more: v.boolean(), + object: v.picklist(["list"]), +}); +export const listPaginatedFineTuningJobsResponseSchema = + inputListPaginatedFineTuningJobsResponseSchema; +/** Usage statistics for the completion request. */ +export const inputCompletionUsageSchema = v.looseObject({ /** - * The name of the function to call. + * Number of tokens in the generated completion. */ - name: v.pipe(v.string(), v.trim()), -}); -/** - * Specifies a tool the model should use. Use to force the model to call a - * specific function. - */ -export const inputChatCompletionNamedToolChoiceSchema = v.looseObject({ + completion_tokens: v.pipe(v.number(), v.integer()), /** - * The type of the tool. Currently, only `function` is supported. + * Number of tokens in the prompt. */ - type: v.picklist(["function"]), - function: v.looseObject({ - /** - * The name of the function to call. - */ - name: v.string(), - }), -}); -export const chatCompletionNamedToolChoiceSchema = v.looseObject({ + prompt_tokens: v.pipe(v.number(), v.integer()), /** - * The type of the tool. Currently, only `function` is supported. + * Total number of tokens used in the request (prompt + completion). */ - type: v.picklist(["function"]), - function: v.looseObject({ - /** - * The name of the function to call. - */ - name: v.pipe(v.string(), v.trim()), - }), + total_tokens: v.pipe(v.number(), v.integer()), + /** + * Breakdown of tokens used in a completion. + */ + completion_tokens_details: v.optional( + v.looseObject({ + /** + * Tokens generated by the model for reasoning. + */ + reasoning_tokens: v.optional(v.pipe(v.number(), v.integer())), + }), + ), }); -/** - * Controls which (if any) tool is called by the model. - * `none` means the model will not call any tool and instead generates a - * message. - * `auto` means the model can pick between generating a message or calling one - * or more tools. - * `required` means the model must call one or more tools. - * Specifying a particular tool via `{"type": "function", "function": {"name": - * "my_function"}}` forces the model to call that tool. - * - * `none` is the default when no tools are present. `auto` is the default if - * tools are present. - */ -export const inputChatCompletionToolChoiceOptionSchema = v.union([ - v.picklist(["none", "auto", "required"]), - inputChatCompletionNamedToolChoiceSchema, -]); -export const chatCompletionToolChoiceOptionSchema = - inputChatCompletionToolChoiceOptionSchema; -/** Options for streaming response. Only set this when you set `stream: true`. */ -export const inputChatCompletionStreamOptionsSchema = v.nullable( - v.looseObject({ - /** - * If set, an additional chunk will be streamed before the `data: [DONE]` - * message. The `usage` field on this chunk shows the token usage statistics - * for the entire request, and the `choices` field will always be an empty - * array. All other chunks will also include a `usage` field, but with a null - * value. - */ - include_usage: v.optional(v.boolean()), - }), -); -export const chatCompletionStreamOptionsSchema = v.nullable( - v.looseObject({ - /** - * If set, an additional chunk will be streamed before the `data: [DONE]` - * message. The `usage` field on this chunk shows the token usage statistics - * for the entire request, and the `choices` field will always be an empty - * array. All other chunks will also include a `usage` field, but with a null - * value. - */ - include_usage: v.exactOptional(v.boolean()), - }), -); -export const inputChatCompletionRequestFunctionMessageSchema = v.looseObject({ +export const completionUsageSchema = v.looseObject({ /** - * The role of the messages author, in this case `function`. + * Number of tokens in the generated completion. */ - role: v.picklist(["function"]), + completion_tokens: v.pipe(v.number(), v.integer()), /** - * The contents of the function message. + * Number of tokens in the prompt. */ - content: v.nullable(v.string()), + prompt_tokens: v.pipe(v.number(), v.integer()), /** - * The name of the function to call. + * Total number of tokens used in the request (prompt + completion). */ - name: v.string(), -}); -export const chatCompletionRequestFunctionMessageSchema = v.looseObject({ + total_tokens: v.pipe(v.number(), v.integer()), /** - * The role of the messages author, in this case `function`. + * Breakdown of tokens used in a completion. */ - role: v.picklist(["function"]), + completion_tokens_details: v.exactOptional( + v.looseObject({ + /** + * Tokens generated by the model for reasoning. + */ + reasoning_tokens: v.exactOptional(v.pipe(v.number(), v.integer())), + }), + ), +}); +/** A chat completion message generated by the model. */ +export const inputChatCompletionResponseMessageSchema = v.looseObject({ /** - * The contents of the function message. + * The contents of the message. */ - content: v.nullable(v.pipe(v.string(), v.trim())), + content: v.nullable(v.string()), /** - * The name of the function to call. + * The refusal message generated by the model. */ - name: v.pipe(v.string(), v.trim()), -}); -export const inputChatCompletionRequestMessageContentPartTextSchema = - v.looseObject({ - /** - * The type of the content part. - */ - type: v.picklist(["text"]), - /** - * The text content. - */ - text: v.string(), - }); -export const chatCompletionRequestMessageContentPartTextSchema = v.looseObject({ + refusal: v.nullable(v.string()), + tool_calls: v.optional(inputChatCompletionMessageToolCallsSchema), /** - * The type of the content part. + * The role of the author of this message. */ - type: v.picklist(["text"]), + role: v.picklist(["assistant"]), /** - * The text content. + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. */ - text: v.pipe(v.string(), v.trim()), + function_call: v.optional( + v.looseObject({ + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.string(), + /** + * The name of the function to call. + */ + name: v.string(), + }), + ), }); -export const inputChatCompletionRequestToolMessageContentPartSchema = - inputChatCompletionRequestMessageContentPartTextSchema; -export const chatCompletionRequestToolMessageContentPartSchema = - inputChatCompletionRequestToolMessageContentPartSchema; -export const inputChatCompletionRequestToolMessageSchema = v.looseObject({ +export const chatCompletionResponseMessageSchema = v.looseObject({ /** - * The role of the messages author, in this case `tool`. + * The contents of the message. */ - role: v.picklist(["tool"]), + content: v.nullable(v.pipe(v.string(), v.trim())), /** - * The contents of the tool message. + * The refusal message generated by the model. */ - content: v.union([ - v.string(), - v.pipe( - v.array(inputChatCompletionRequestToolMessageContentPartSchema), - v.minLength(1), - ), - ]), + refusal: v.nullable(v.pipe(v.string(), v.trim())), + tool_calls: v.exactOptional(chatCompletionMessageToolCallsSchema), /** - * Tool call that this message is responding to. + * The role of the author of this message. */ - tool_call_id: v.string(), + role: v.picklist(["assistant"]), + /** + * Deprecated and replaced by `tool_calls`. The name and arguments of a + * function that should be called, as generated by the model. + */ + function_call: v.exactOptional( + v.looseObject({ + /** + * The arguments to call the function with, as generated by the model in JSON + * format. Note that the model does not always generate valid JSON, and may + * hallucinate parameters not defined by your function schema. Validate the + * arguments in your code before calling your function. + */ + arguments: v.pipe(v.string(), v.trim()), + /** + * The name of the function to call. + */ + name: v.pipe(v.string(), v.trim()), + }), + ), }); -export const chatCompletionRequestToolMessageSchema = v.looseObject({ +/** + * Represents a chat completion response returned by model, based on the + * provided input. + */ +export const inputCreateChatCompletionFunctionResponseSchema = v.looseObject({ /** - * The role of the messages author, in this case `tool`. + * A unique identifier for the chat completion. */ - role: v.picklist(["tool"]), + id: v.string(), /** - * The contents of the tool message. + * A list of chat completion choices. Can be more than one if `n` is greater + * than 1. */ - content: v.union([ - v.pipe(v.string(), v.trim()), - v.pipe( - v.array(chatCompletionRequestToolMessageContentPartSchema), - v.minLength(1), - ), - ]), + choices: v.array( + v.looseObject({ + /** + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, `length` if the + * maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, or `function_call` if the model called a function. + */ + finish_reason: v.picklist([ + "stop", + "length", + "function_call", + "content_filter", + ]), + /** + * The index of the choice in the list of choices. + */ + index: v.pipe(v.number(), v.integer()), + message: inputChatCompletionResponseMessageSchema, + }), + ), /** - * Tool call that this message is responding to. + * The Unix timestamp (in seconds) of when the chat completion was created. */ - tool_call_id: v.pipe(v.string(), v.trim()), -}); -export const inputChatCompletionMessageToolCallSchema = v.looseObject({ + created: v.pipe(v.number(), v.integer()), /** - * The ID of the tool call. + * The model used for the chat completion. */ - id: v.string(), + model: v.string(), /** - * The type of the tool. Currently, only `function` is supported. + * This fingerprint represents the backend configuration that the model runs + * with. + * + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - type: v.picklist(["function"]), + system_fingerprint: v.optional(v.string()), /** - * The function that the model called. + * The object type, which is always `chat.completion`. */ - function: v.looseObject({ - /** - * The name of the function to call. - */ - name: v.string(), - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.string(), - }), + object: v.picklist(["chat.completion"]), + usage: v.optional(inputCompletionUsageSchema), }); -export const chatCompletionMessageToolCallSchema = v.looseObject({ +export const createChatCompletionFunctionResponseSchema = v.looseObject({ /** - * The ID of the tool call. + * A unique identifier for the chat completion. */ id: v.pipe(v.string(), v.trim()), /** - * The type of the tool. Currently, only `function` is supported. + * A list of chat completion choices. Can be more than one if `n` is greater + * than 1. */ - type: v.picklist(["function"]), + choices: v.array( + v.looseObject({ + /** + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, `length` if the + * maximum number of tokens specified in the request was reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, or `function_call` if the model called a function. + */ + finish_reason: v.picklist([ + "stop", + "length", + "function_call", + "content_filter", + ]), + /** + * The index of the choice in the list of choices. + */ + index: v.pipe(v.number(), v.integer()), + message: chatCompletionResponseMessageSchema, + }), + ), /** - * The function that the model called. + * The Unix timestamp (in seconds) of when the chat completion was created. */ - function: v.looseObject({ - /** - * The name of the function to call. - */ - name: v.pipe(v.string(), v.trim()), - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.pipe(v.string(), v.trim()), - }), -}); -/** The tool calls generated by the model, such as function calls. */ -export const inputChatCompletionMessageToolCallsSchema = v.array( - inputChatCompletionMessageToolCallSchema, -); -export const chatCompletionMessageToolCallsSchema = - inputChatCompletionMessageToolCallsSchema; -export const inputChatCompletionRequestMessageContentPartRefusalSchema = - v.looseObject({ - /** - * The type of the content part. - */ - type: v.picklist(["refusal"]), - /** - * The refusal message generated by the model. - */ - refusal: v.string(), - }); -export const chatCompletionRequestMessageContentPartRefusalSchema = - v.looseObject({ - /** - * The type of the content part. - */ - type: v.picklist(["refusal"]), - /** - * The refusal message generated by the model. - */ - refusal: v.pipe(v.string(), v.trim()), - }); -export const inputChatCompletionRequestAssistantMessageContentPartSchema = - v.union([ - inputChatCompletionRequestMessageContentPartTextSchema, - inputChatCompletionRequestMessageContentPartRefusalSchema, - ]); -export const chatCompletionRequestAssistantMessageContentPartSchema = - inputChatCompletionRequestAssistantMessageContentPartSchema; -export const inputChatCompletionRequestAssistantMessageSchema = v.looseObject({ + created: v.pipe(v.number(), v.integer()), /** - * The contents of the assistant message. Required unless `tool_calls` or - * `function_call` is specified. + * The model used for the chat completion. */ - content: v.optional( - v.nullable( - v.union([ - v.string(), - v.pipe( - v.array(inputChatCompletionRequestAssistantMessageContentPartSchema), - v.minLength(1), - ), - ]), - ), - ), + model: v.pipe(v.string(), v.trim()), /** - * The refusal message by the assistant. + * This fingerprint represents the backend configuration that the model runs + * with. + * + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - refusal: v.optional(v.nullable(v.string())), + system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The role of the messages author, in this case `assistant`. + * The object type, which is always `chat.completion`. */ - role: v.picklist(["assistant"]), + object: v.picklist(["chat.completion"]), + usage: v.exactOptional(completionUsageSchema), +}); +/** + * Represents a chat completion response returned by model, based on the + * provided input. + */ +export const inputCreateChatCompletionResponseSchema = v.looseObject({ /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * A unique identifier for the chat completion. */ - name: v.optional(v.string()), - tool_calls: v.optional(inputChatCompletionMessageToolCallsSchema), + id: v.string(), /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. + * A list of chat completion choices. Can be more than one if `n` is greater + * than 1. */ - function_call: v.optional( - v.nullable( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.string(), - /** - * The name of the function to call. - */ - name: v.string(), - }), - ), + choices: v.array( + v.looseObject({ + /** + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if + * the model called a function. + */ + finish_reason: v.picklist([ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ]), + /** + * The index of the choice in the list of choices. + */ + index: v.pipe(v.number(), v.integer()), + message: inputChatCompletionResponseMessageSchema, + /** + * Log probability information for the choice. + */ + logprobs: v.nullable( + v.looseObject({ + /** + * A list of message content tokens with log probability information. + */ + content: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), + /** + * A list of message refusal tokens with log probability information. + */ + refusal: v.nullable(v.array(inputChatCompletionTokenLogprobSchema)), + }), + ), + }), ), -}); -export const chatCompletionRequestAssistantMessageSchema = v.looseObject({ /** - * The contents of the assistant message. Required unless `tool_calls` or - * `function_call` is specified. + * The Unix timestamp (in seconds) of when the chat completion was created. */ - content: v.exactOptional( - v.nullable( - v.union([ - v.pipe(v.string(), v.trim()), - v.pipe( - v.array(chatCompletionRequestAssistantMessageContentPartSchema), - v.minLength(1), - ), - ]), - ), - ), + created: v.pipe(v.number(), v.integer()), /** - * The refusal message by the assistant. + * The model used for the chat completion. */ - refusal: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), + model: v.string(), /** - * The role of the messages author, in this case `assistant`. + * The service tier used for processing the request. This field is only + * included if the `service_tier` parameter is specified in the request. */ - role: v.picklist(["assistant"]), + service_tier: v.optional(v.nullable(v.picklist(["scale", "default"]))), /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * This fingerprint represents the backend configuration that the model runs + * with. + * + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - tool_calls: v.exactOptional(chatCompletionMessageToolCallsSchema), + system_fingerprint: v.optional(v.string()), /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. + * The object type, which is always `chat.completion`. */ - function_call: v.exactOptional( - v.nullable( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.pipe(v.string(), v.trim()), - /** - * The name of the function to call. - */ - name: v.pipe(v.string(), v.trim()), - }), - ), - ), + object: v.picklist(["chat.completion"]), + usage: v.optional(inputCompletionUsageSchema), }); -export const inputChatCompletionRequestMessageContentPartImageSchema = - v.looseObject({ - /** - * The type of the content part. - */ - type: v.picklist(["image_url"]), - image_url: v.looseObject({ - /** - * Either a URL of the image or the base64 encoded image data. - */ - url: v.string(), +export const createChatCompletionResponseSchema = v.looseObject({ + /** + * A unique identifier for the chat completion. + */ + id: v.pipe(v.string(), v.trim()), + /** + * A list of chat completion choices. Can be more than one if `n` is greater + * than 1. + */ + choices: v.array( + v.looseObject({ /** - * Specifies the detail level of the image. Learn more in the [Vision - * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + * The reason the model stopped generating tokens. This will be `stop` if the + * model hit a natural stop point or a provided stop sequence, + * `length` if the maximum number of tokens specified in the request was + * reached, + * `content_filter` if content was omitted due to a flag from our content + * filters, + * `tool_calls` if the model called a tool, or `function_call` (deprecated) if + * the model called a function. */ - detail: v.optional(v.picklist(["auto", "low", "high"])), - }), - }); -export const chatCompletionRequestMessageContentPartImageSchema = v.looseObject( - { - /** - * The type of the content part. - */ - type: v.picklist(["image_url"]), - image_url: v.looseObject({ + finish_reason: v.picklist([ + "stop", + "length", + "tool_calls", + "content_filter", + "function_call", + ]), /** - * Either a URL of the image or the base64 encoded image data. + * The index of the choice in the list of choices. */ - url: v.pipe(v.string(), v.trim()), + index: v.pipe(v.number(), v.integer()), + message: chatCompletionResponseMessageSchema, /** - * Specifies the detail level of the image. Learn more in the [Vision - * guide](/docs/guides/vision/low-or-high-fidelity-image-understanding). + * Log probability information for the choice. */ - detail: v.exactOptional(v.picklist(["auto", "low", "high"])), + logprobs: v.nullable( + v.looseObject({ + /** + * A list of message content tokens with log probability information. + */ + content: v.nullable(v.array(chatCompletionTokenLogprobSchema)), + /** + * A list of message refusal tokens with log probability information. + */ + refusal: v.nullable(v.array(chatCompletionTokenLogprobSchema)), + }), + ), }), - }, -); -export const inputChatCompletionRequestUserMessageContentPartSchema = v.union([ - inputChatCompletionRequestMessageContentPartTextSchema, - inputChatCompletionRequestMessageContentPartImageSchema, -]); -export const chatCompletionRequestUserMessageContentPartSchema = - inputChatCompletionRequestUserMessageContentPartSchema; -export const inputChatCompletionRequestUserMessageSchema = v.looseObject({ - /** - * The contents of the user message. - */ - content: v.union([ - v.string(), - v.pipe( - v.array(inputChatCompletionRequestUserMessageContentPartSchema), - v.minLength(1), - ), - ]), + ), /** - * The role of the messages author, in this case `user`. + * The Unix timestamp (in seconds) of when the chat completion was created. */ - role: v.picklist(["user"]), + created: v.pipe(v.number(), v.integer()), /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * The model used for the chat completion. */ - name: v.optional(v.string()), -}); -export const chatCompletionRequestUserMessageSchema = v.looseObject({ + model: v.pipe(v.string(), v.trim()), /** - * The contents of the user message. + * The service tier used for processing the request. This field is only + * included if the `service_tier` parameter is specified in the request. */ - content: v.union([ - v.pipe(v.string(), v.trim()), - v.pipe( - v.array(chatCompletionRequestUserMessageContentPartSchema), - v.minLength(1), - ), - ]), + service_tier: v.exactOptional(v.nullable(v.picklist(["scale", "default"]))), /** - * The role of the messages author, in this case `user`. + * This fingerprint represents the backend configuration that the model runs + * with. + * + * Can be used in conjunction with the `seed` request parameter to understand + * when backend changes have been made that might impact determinism. */ - role: v.picklist(["user"]), + system_fingerprint: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * The object type, which is always `chat.completion`. */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), + object: v.picklist(["chat.completion"]), + usage: v.exactOptional(completionUsageSchema), }); -export const inputChatCompletionRequestSystemMessageContentPartSchema = - inputChatCompletionRequestMessageContentPartTextSchema; -export const chatCompletionRequestSystemMessageContentPartSchema = - inputChatCompletionRequestSystemMessageContentPartSchema; -export const inputChatCompletionRequestSystemMessageSchema = v.looseObject({ - /** - * The contents of the system message. - */ - content: v.union([ - v.string(), - v.pipe( - v.array(inputChatCompletionRequestSystemMessageContentPartSchema), - v.minLength(1), - ), - ]), - /** - * The role of the messages author, in this case `system`. - */ - role: v.picklist(["system"]), +/** + * Specifying a particular function via `{"name": "my_function"}` forces the + * model to call that function. + */ +export const inputChatCompletionFunctionCallOptionSchema = v.looseObject({ /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * The name of the function to call. */ - name: v.optional(v.string()), + name: v.string(), }); -export const chatCompletionRequestSystemMessageSchema = v.looseObject({ +export const chatCompletionFunctionCallOptionSchema = v.looseObject({ /** - * The contents of the system message. + * The name of the function to call. */ - content: v.union([ - v.pipe(v.string(), v.trim()), - v.pipe( - v.array(chatCompletionRequestSystemMessageContentPartSchema), - v.minLength(1), - ), - ]), + name: v.pipe(v.string(), v.trim()), +}); +/** + * Specifies a tool the model should use. Use to force the model to call a + * specific function. + */ +export const inputChatCompletionNamedToolChoiceSchema = v.looseObject({ /** - * The role of the messages author, in this case `system`. + * The type of the tool. Currently, only `function` is supported. */ - role: v.picklist(["system"]), + type: v.picklist(["function"]), + function: v.looseObject({ + /** + * The name of the function to call. + */ + name: v.string(), + }), +}); +export const chatCompletionNamedToolChoiceSchema = v.looseObject({ /** - * An optional name for the participant. Provides the model information to - * differentiate between participants of the same role. + * The type of the tool. Currently, only `function` is supported. */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), + type: v.picklist(["function"]), + function: v.looseObject({ + /** + * The name of the function to call. + */ + name: v.pipe(v.string(), v.trim()), + }), }); +/** + * Controls which (if any) tool is called by the model. + * `none` means the model will not call any tool and instead generates a + * message. + * `auto` means the model can pick between generating a message or calling one + * or more tools. + * `required` means the model must call one or more tools. + * Specifying a particular tool via `{"type": "function", "function": {"name": + * "my_function"}}` forces the model to call that tool. + * + * `none` is the default when no tools are present. `auto` is the default if + * tools are present. + */ +export const inputChatCompletionToolChoiceOptionSchema = v.union([ + v.picklist(["none", "auto", "required"]), + inputChatCompletionNamedToolChoiceSchema, +]); +export const chatCompletionToolChoiceOptionSchema = + inputChatCompletionToolChoiceOptionSchema; +/** Options for streaming response. Only set this when you set `stream: true`. */ +export const inputChatCompletionStreamOptionsSchema = v.nullable( + v.looseObject({ + /** + * If set, an additional chunk will be streamed before the `data: [DONE]` + * message. The `usage` field on this chunk shows the token usage statistics + * for the entire request, and the `choices` field will always be an empty + * array. All other chunks will also include a `usage` field, but with a null + * value. + */ + include_usage: v.optional(v.boolean()), + }), +); +export const chatCompletionStreamOptionsSchema = v.nullable( + v.looseObject({ + /** + * If set, an additional chunk will be streamed before the `data: [DONE]` + * message. The `usage` field on this chunk shows the token usage statistics + * for the entire request, and the `choices` field will always be an empty + * array. All other chunks will also include a `usage` field, but with a null + * value. + */ + include_usage: v.exactOptional(v.boolean()), + }), +); export const inputChatCompletionRequestMessageSchema = v.union([ inputChatCompletionRequestSystemMessageSchema, inputChatCompletionRequestUserMessageSchema, @@ -11610,216 +11898,6 @@ export const createChatCompletionRequestSchema = v.looseObject({ ), ), }); -export const inputChatCompletionMessageToolCallChunkSchema = v.looseObject({ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call. - */ - id: v.optional(v.string()), - /** - * The type of the tool. Currently, only `function` is supported. - */ - type: v.optional(v.picklist(["function"])), - function: v.optional( - v.looseObject({ - /** - * The name of the function to call. - */ - name: v.optional(v.string()), - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.optional(v.string()), - }), - ), -}); -export const chatCompletionMessageToolCallChunkSchema = v.looseObject({ - index: v.pipe(v.number(), v.integer()), - /** - * The ID of the tool call. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The type of the tool. Currently, only `function` is supported. - */ - type: v.exactOptional(v.picklist(["function"])), - function: v.exactOptional( - v.looseObject({ - /** - * The name of the function to call. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), -}); -/** A chat completion delta generated by streamed model responses. */ -export const inputChatCompletionStreamResponseDeltaSchema = v.looseObject({ - /** - * The contents of the chunk message. - */ - content: v.optional(v.nullable(v.string())), - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - */ - function_call: v.optional( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.optional(v.string()), - /** - * The name of the function to call. - */ - name: v.optional(v.string()), - }), - ), - tool_calls: v.optional( - v.array(inputChatCompletionMessageToolCallChunkSchema), - ), - /** - * The role of the author of this message. - */ - role: v.optional(v.picklist(["system", "user", "assistant", "tool"])), - /** - * The refusal message generated by the model. - */ - refusal: v.optional(v.nullable(v.string())), -}); -export const chatCompletionStreamResponseDeltaSchema = v.looseObject({ - /** - * The contents of the chunk message. - */ - content: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - */ - function_call: v.exactOptional( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The name of the function to call. - */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), - tool_calls: v.exactOptional( - v.array(chatCompletionMessageToolCallChunkSchema), - ), - /** - * The role of the author of this message. - */ - role: v.exactOptional(v.picklist(["system", "user", "assistant", "tool"])), - /** - * The refusal message generated by the model. - */ - refusal: v.exactOptional(v.nullable(v.pipe(v.string(), v.trim()))), -}); -/** A chat completion message generated by the model. */ -export const inputChatCompletionResponseMessageSchema = v.looseObject({ - /** - * The contents of the message. - */ - content: v.nullable(v.string()), - /** - * The refusal message generated by the model. - */ - refusal: v.nullable(v.string()), - tool_calls: v.optional(inputChatCompletionMessageToolCallsSchema), - /** - * The role of the author of this message. - */ - role: v.picklist(["assistant"]), - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - */ - function_call: v.optional( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.string(), - /** - * The name of the function to call. - */ - name: v.string(), - }), - ), -}); -export const chatCompletionResponseMessageSchema = v.looseObject({ - /** - * The contents of the message. - */ - content: v.nullable(v.pipe(v.string(), v.trim())), - /** - * The refusal message generated by the model. - */ - refusal: v.nullable(v.pipe(v.string(), v.trim())), - tool_calls: v.exactOptional(chatCompletionMessageToolCallsSchema), - /** - * The role of the author of this message. - */ - role: v.picklist(["assistant"]), - /** - * Deprecated and replaced by `tool_calls`. The name and arguments of a - * function that should be called, as generated by the model. - */ - function_call: v.exactOptional( - v.looseObject({ - /** - * The arguments to call the function with, as generated by the model in JSON - * format. Note that the model does not always generate valid JSON, and may - * hallucinate parameters not defined by your function schema. Validate the - * arguments in your code before calling your function. - */ - arguments: v.pipe(v.string(), v.trim()), - /** - * The name of the function to call. - */ - name: v.pipe(v.string(), v.trim()), - }), - ), -}); -export const inputFineTuneChatCompletionRequestAssistantMessageSchema = - v.looseObject({ - /** - * Controls whether the assistant message is trained against (0 or 1) - */ - weight: v.optional(v.picklist([0, 1])), - ...inputChatCompletionRequestAssistantMessageSchema.entries, - }); -export const fineTuneChatCompletionRequestAssistantMessageSchema = - v.looseObject({ - /** - * Controls whether the assistant message is trained against (0 or 1) - */ - weight: v.exactOptional(v.picklist([0, 1])), - ...chatCompletionRequestAssistantMessageSchema.entries, - }); /** * Represents a completion response from the API. Note: both the streamed and * non-streamed response objects share the same shape (unlike the chat diff --git a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json index 8542d63..cedf0e0 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", + "#generator": "dfa29fcb516184c923352b589d0a33f8", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", "valibot.ts": "2383058357d21e704546455f4e073d67", "hono.ts": "be7061d9a002b7d6f42bbdfc53727ec7", - "commands-validated.ts": "90b52a2210f1b9cc0e123225210fe74a" + "commands-validated.ts": "21f5e9e15233b504d8509d93e00911fd" } diff --git a/__tests__/fixtures/test1/.openapi-codegen-manifest.json b/__tests__/fixtures/test1/.openapi-codegen-manifest.json index c9524be..9dad7b5 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "2ba32f14aac5a11cad017b3fa8f958f2", - "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", - "types.ts": "e19f646f79d970daa0bb6a21140a2f94", - "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", - "valibot.ts": "d7e166b84040d92d2eefc8b2f986e5a1", - "hono.ts": "26885b9a53e8c0343a2fdb21f4eb8a37", - "commands-validated.ts": "cc5f84090799e163e229aabd160311f8", + "#generator": "dfa29fcb516184c923352b589d0a33f8", + "commands.ts": "0e6777a5287ed2535587a0f5180bbbd5", + "types.ts": "ce23bfa944b6b2d51dfb0c97062dc8ad", + "main.ts": "5c768be2e48d0b06d7ed8da665653404", + "valibot.ts": "f150b977a0fcd30da6d15f4890bedb2f", + "hono.ts": "12cc7ef64bfc4acf632ba9d9011880d8", + "commands-validated.ts": "afd10b6462e83dbe33e5d42dd227cd97", "enums.ts": "26ade5ccad3bf30118ce8691b99b7c91" } diff --git a/lib/process-schema.ts b/lib/process-schema.ts index 56aa98d..3bd347c 100644 --- a/lib/process-schema.ts +++ b/lib/process-schema.ts @@ -230,22 +230,9 @@ function refType( ) { const existingSchema = typesAndInterfaces.get(schemaObject.$ref); + // components register in dependency order, so a miss is a codegen bug if (!existingSchema) { - console.warn("ref used before available: schema=%j", schemaObject); - - const property: Pick< - OptionalKind, - "type" | "docs" - > = { - type: "never", - docs: [ - { - description: `WARN: $ref used before available - schema=${JSON.stringify(schemaObject)}`, - }, - ], - }; - - return property; + throw new Error(`ref used before available: ${schemaObject.$ref}`); } const docs = refPropertyDocs(existingSchema); diff --git a/lib/utils.ts b/lib/utils.ts index 339f5dc..9adc0ed 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -6,10 +6,6 @@ export function isReferenceObject(obj: unknown): obj is oas31.ReferenceObject { return typeof obj === "object" && obj !== null && "$ref" in obj; } -function getDependency(obj: unknown) { - return isReferenceObject(obj) ? obj.$ref : undefined; -} - export function isNotReferenceObject( obj: T, ): obj is Exclude { @@ -20,48 +16,20 @@ export function isNotNullOrUndefined(obj: T | null | undefined): obj is T { return obj !== null && obj !== undefined; } -function isString(x: string | undefined): x is string { - return typeof x === "string"; -} - -export function getDependents( - obj: oas31.ReferenceObject | oas31.SchemaObject, -): string[] { +/** + * Every $ref anywhere under a schema. Items, additionalProperties and + * combinators nest them at any depth, and a schema registers after all of them + */ +export function getDependents(obj: unknown): string[] { if (isReferenceObject(obj)) { - return [getDependency(obj)].filter((value) => isString(value)); - } - - if ("properties" in obj) { - const properties = Object.values(obj.properties); - - return properties - .flatMap((value) => getDependents(value)) - .filter((value) => isString(value)); - } - - if ("items" in obj && isReferenceObject(obj.items)) { - return [getDependency(obj.items)].filter((value) => isString(value)); - } - - if ("anyOf" in obj) { - return obj.anyOf - .flatMap((value) => getDependents(value)) - .filter((value) => isString(value)); - } - - if ("allOf" in obj) { - return obj.allOf - .flatMap((value) => getDependents(value)) - .filter((value) => isString(value)); + return [obj.$ref]; } - if ("oneOf" in obj) { - return obj.oneOf - .flatMap((value) => getDependents(value)) - .filter((value) => isString(value)); + if (typeof obj !== "object" || obj === null) { + return []; } - return []; + return Object.values(obj).flatMap((value) => getDependents(value)); } export function camelCase(...str: string[]): string { diff --git a/lib/valibot.ts b/lib/valibot.ts index 7a4c53d..527b207 100644 --- a/lib/valibot.ts +++ b/lib/valibot.ts @@ -245,9 +245,12 @@ function resolveRef( mode: SchemaMode, ) { const entry = validators.get(ref); + + // components register in dependency order, so a miss is a codegen bug if (!entry) { - return vcall("unknown"); + throw new Error(`ref used before available: ${ref}`); } + return mode === "input" ? entry.input : entry.wire; } From 43a3a7d04db61763ed688588a5ee69ee705e81a0 Mon Sep 17 00:00:00 2001 From: "maxholman[bot]" <321308195+maxholman[bot]@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:44:32 +0800 Subject: [PATCH 5/5] fix: type values a schema leaves open as JsonValue on both sides An empty schema, an untyped record value, or an array without items was Jsonifiable in TS, which admits toJSON objects that JSON.parse never yields. valibot typed the same values as unknown, and an empty schema there required a record, rejecting other JSON values. Both sides now use type-fest's JsonValue: valibot checks the value recursively with a lazy union typed v.GenericSchema, emitted only in a module that uses it. Co-Authored-By: LLM --- .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../types.ts | 7 + .../valibot.ts | 14 + .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../types.ts | 5 - .../valibot.ts | 6 - .../types.ts | 4 +- .../valibot.ts | 1 - .../nullables/const-values/valibot.ts | 1 - .../valibot.ts | 1 - .../nullables/header-parameters/valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../valibot.ts | 1 - .../rfc-3339-temporal-formats/valibot.ts | 1 - .../top-level-type-array-with-null/valibot.ts | 1 - __tests__/codegen-regressions.test.ts | 26 +- .../docker/.openapi-codegen-manifest.json | 12 +- __tests__/fixtures/docker/types.ts | 132 ++++---- __tests__/fixtures/docker/valibot.ts | 289 ++++++++++-------- .../openai/.openapi-codegen-manifest.json | 12 +- __tests__/fixtures/openai/types.ts | 50 +-- __tests__/fixtures/openai/valibot.ts | 121 ++++---- .../petstore/.openapi-codegen-manifest.json | 6 +- __tests__/fixtures/petstore/valibot.ts | 1 - .../test1/.openapi-codegen-manifest.json | 14 +- __tests__/fixtures/test1/types.ts | 4 +- __tests__/fixtures/test1/valibot.ts | 13 +- lib/process-document.ts | 3 + lib/process-schema.ts | 8 +- lib/valibot.ts | 52 +++- 40 files changed, 469 insertions(+), 330 deletions(-) create mode 100644 __tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/types.ts create mode 100644 __tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/valibot.ts delete mode 100644 __tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts delete mode 100644 __tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/valibot.ts diff --git a/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts index 6769bad..10f338b 100644 --- a/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputLeafSchema = v.strictObject( { "name": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-anyof/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-anyof/valibot.ts index 999d3a4..940955c 100644 --- a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-anyof/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-anyof/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOnlySchema = v.string(); export const onlySchema = v.pipe(v.string(), v.trim()); export const inputGetThingCommandResponseSchema = inputOnlySchema; diff --git a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-oneof/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-oneof/valibot.ts index 999d3a4..940955c 100644 --- a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-oneof/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-oneof/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOnlySchema = v.string(); export const onlySchema = v.pipe(v.string(), v.trim()); export const inputGetThingCommandResponseSchema = inputOnlySchema; diff --git a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-two-member-oneof/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-two-member-oneof/valibot.ts index cc3c4da..8267dcf 100644 --- a/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-two-member-oneof/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/a-single-member-combinator-emits-the-member-alone-two-member-oneof/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOnlySchema = v.union([v.string(), v.number()]); export const onlySchema = v.union([v.pipe(v.string(), v.trim()), v.number()]); export const inputGetThingCommandResponseSchema = inputOnlySchema; diff --git a/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/types.ts b/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/types.ts new file mode 100644 index 0000000..1cbe9e9 --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/types.ts @@ -0,0 +1,7 @@ +import type { JsonValue } from "type-fest"; + +export type Open = { + "anything": JsonValue; + "record": Record; + "list": readonly (JsonValue)[]; + }; diff --git a/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/valibot.ts b/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/valibot.ts new file mode 100644 index 0000000..a665298 --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/a-value-the-schema-leaves-open-is-a-jsonvalue-on-both-sides/valibot.ts @@ -0,0 +1,14 @@ +import * as v from "valibot"; +import type { JsonValue } from "type-fest"; + +const jsonValueSchema: v.GenericSchema = v.lazy(() => v.union([v.string(), v.number(), v.boolean(), v.null(), v.record(v.string(), jsonValueSchema), v.array(jsonValueSchema)])); +export const inputOpenSchema = v.strictObject( + { + "anything": jsonValueSchema + , + "record": v.record(v.string(), jsonValueSchema) + , + "list": v.array(jsonValueSchema) + , + }); +export const openSchema = inputOpenSchema; diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-alongside-properties-keeps-the-extra-keys-valid/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-alongside-properties-keeps-the-extra-keys-valid/valibot.ts index 131918b..4d2ad55 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-alongside-properties-keeps-the-extra-keys-valid/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-alongside-properties-keeps-the-extra-keys-valid/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputConfigSchema = v.objectWithRest( { "name": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-empty-schema/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-empty-schema/valibot.ts index 5c53bc7..efdce05 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-empty-schema/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-empty-schema/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOpenSchema = v.looseObject( { "a": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-false/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-false/valibot.ts index 1c97502..30eb592 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-false/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-false/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOpenSchema = v.strictObject( { "a": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-string-schema/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-string-schema/valibot.ts index bb6c2da..134699b 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-string-schema/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-string-schema/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOpenSchema = v.objectWithRest( { "a": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-true/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-true/valibot.ts index 5c53bc7..efdce05 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-true/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-chooses-the-object-schema-true/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOpenSchema = v.looseObject( { "a": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts index 984fbbd..f258c90 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputLabelsSchema = v.record(v.string(), v.string()); export const labelsSchema = inputLabelsSchema; export const inputGetThingCommandResponseSchema = inputLabelsSchema; diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-true-accepts-any-key/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-true-accepts-any-key/valibot.ts index d13b4c4..a56b6be 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-true-accepts-any-key/valibot.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-true-accepts-any-key/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputOpenSchema = v.looseObject( { "name": v.optional(v.string()) diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts deleted file mode 100644 index 5bbfb1d..0000000 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts +++ /dev/null @@ -1,5 +0,0 @@ -import type { UndefinedOnPartialDeep } from "type-fest"; - -export type Labels = Record; -export type GetThingCommandInput = never; -export type InputGetThingCommandResponse = UndefinedOnPartialDeep; diff --git a/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/valibot.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/valibot.ts deleted file mode 100644 index 984fbbd..0000000 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/valibot.ts +++ /dev/null @@ -1,6 +0,0 @@ -import * as v from "valibot"; - -export const inputLabelsSchema = v.record(v.string(), v.string()); -export const labelsSchema = inputLabelsSchema; -export const inputGetThingCommandResponseSchema = inputLabelsSchema; -export const getThingCommandResponseSchema = labelsSchema; diff --git a/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts b/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts index 5e51d00..0c78c93 100644 --- a/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts +++ b/__tests__/__snapshots__/codegen-regressions/an-empty-properties-bag-is-a-record-not-an-empty-object-type/types.ts @@ -1,5 +1,5 @@ -import type { Jsonifiable, UndefinedOnPartialDeep } from "type-fest"; +import type { JsonValue, UndefinedOnPartialDeep } from "type-fest"; -export type Empty = Record; +export type Empty = Record; export type GetThingCommandInput = never; export type InputGetThingCommandResponse = UndefinedOnPartialDeep; diff --git a/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts index c099bcb..b8a1e89 100644 --- a/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts +++ b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputBaseSchema = v.looseObject( { "id": v.optional(v.string()) diff --git a/__tests__/__snapshots__/nullables/const-values/valibot.ts b/__tests__/__snapshots__/nullables/const-values/valibot.ts index d880cb4..a59e06a 100644 --- a/__tests__/__snapshots__/nullables/const-values/valibot.ts +++ b/__tests__/__snapshots__/nullables/const-values/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputStringConstSchema = v.literal("hello"); export const stringConstSchema = inputStringConstSchema; export const inputNumberConstSchema = v.literal(42); diff --git a/__tests__/__snapshots__/nullables/enums-short-circuit-type-constraints-picklist-only/valibot.ts b/__tests__/__snapshots__/nullables/enums-short-circuit-type-constraints-picklist-only/valibot.ts index 4b8cd8d..ee43703 100644 --- a/__tests__/__snapshots__/nullables/enums-short-circuit-type-constraints-picklist-only/valibot.ts +++ b/__tests__/__snapshots__/nullables/enums-short-circuit-type-constraints-picklist-only/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputIntegerEnumSchema = v.picklist([0, 1, 2]); export const integerEnumSchema = inputIntegerEnumSchema; export const inputStringEnumSchema = v.picklist(["a@example.com", "b@example.com"]); diff --git a/__tests__/__snapshots__/nullables/header-parameters/valibot.ts b/__tests__/__snapshots__/nullables/header-parameters/valibot.ts index 25ede4c..8a73cd0 100644 --- a/__tests__/__snapshots__/nullables/header-parameters/valibot.ts +++ b/__tests__/__snapshots__/nullables/header-parameters/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputUploadStatusSchema = v.picklist(["pending", "complete"]); export const uploadStatusSchema = inputUploadStatusSchema; export const inputUploadDataCommandResponseSchema = inputUploadStatusSchema; diff --git a/__tests__/__snapshots__/nullables/input-only-mode-omits-wire-schemas/valibot.ts b/__tests__/__snapshots__/nullables/input-only-mode-omits-wire-schemas/valibot.ts index 25a2198..92d4676 100644 --- a/__tests__/__snapshots__/nullables/input-only-mode-omits-wire-schemas/valibot.ts +++ b/__tests__/__snapshots__/nullables/input-only-mode-omits-wire-schemas/valibot.ts @@ -1,4 +1,3 @@ import * as v from "valibot"; - export const inputNameSchema = v.pipe(v.string(), v.minLength(1)); export const inputAmountSchema = v.pipe(v.bigint(), v.minValue(0n)); diff --git a/__tests__/__snapshots__/nullables/oneof-with-type-null-generates-v-null/valibot.ts b/__tests__/__snapshots__/nullables/oneof-with-type-null-generates-v-null/valibot.ts index 47d8bcb..a3deba3 100644 --- a/__tests__/__snapshots__/nullables/oneof-with-type-null-generates-v-null/valibot.ts +++ b/__tests__/__snapshots__/nullables/oneof-with-type-null-generates-v-null/valibot.ts @@ -1,4 +1,3 @@ import * as v from "valibot"; - export const inputNullableImageSchema = v.union([v.string(), v.null()]); export const nullableImageSchema = v.union([v.pipe(v.string(), v.trim()), v.null()]); diff --git a/__tests__/__snapshots__/nullables/query-and-header-integer-params-coerce-strings-to-numbers/valibot.ts b/__tests__/__snapshots__/nullables/query-and-header-integer-params-coerce-strings-to-numbers/valibot.ts index bd36c75..5a2fefd 100644 --- a/__tests__/__snapshots__/nullables/query-and-header-integer-params-coerce-strings-to-numbers/valibot.ts +++ b/__tests__/__snapshots__/nullables/query-and-header-integer-params-coerce-strings-to-numbers/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputDummySchema = v.string(); export const dummySchema = v.pipe(v.string(), v.trim()); export const inputExpireTimeSchema = v.pipe(v.bigint(), v.minValue(0n)); diff --git a/__tests__/__snapshots__/nullables/rfc-3339-temporal-formats/valibot.ts b/__tests__/__snapshots__/nullables/rfc-3339-temporal-formats/valibot.ts index 2a8123d..a91445d 100644 --- a/__tests__/__snapshots__/nullables/rfc-3339-temporal-formats/valibot.ts +++ b/__tests__/__snapshots__/nullables/rfc-3339-temporal-formats/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputMyDateSchema = v.pipe(v.string(), v.regex(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/u, "date"), v.custom<`${number}-${number}-${number}`>(() => true)); export const myDateSchema = v.pipe(v.string(), v.trim(), v.regex(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/u, "date"), v.custom<`${number}-${number}-${number}`>(() => true)); export const inputMyTimeSchema = v.pipe(v.string(), v.regex(/^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d+)?([Zz]|[+-]([01]\d|2[0-3]):[0-5]\d)$/u, "time"), v.custom<`${number}:${number}:${number}${string}`>(() => true)); diff --git a/__tests__/__snapshots__/nullables/top-level-type-array-with-null/valibot.ts b/__tests__/__snapshots__/nullables/top-level-type-array-with-null/valibot.ts index 42e7b9e..44fe2df 100644 --- a/__tests__/__snapshots__/nullables/top-level-type-array-with-null/valibot.ts +++ b/__tests__/__snapshots__/nullables/top-level-type-array-with-null/valibot.ts @@ -1,5 +1,4 @@ import * as v from "valibot"; - export const inputNullableStringSchema = v.nullable(v.string()); export const nullableStringSchema = inputNullableStringSchema; export const inputNullableStringEnumSchema = v.nullable(v.picklist(["active", "inactive"])); diff --git a/__tests__/codegen-regressions.test.ts b/__tests__/codegen-regressions.test.ts index cb52b09..cc74217 100644 --- a/__tests__/codegen-regressions.test.ts +++ b/__tests__/codegen-regressions.test.ts @@ -1,5 +1,5 @@ import type { oas31 } from "openapi3-ts"; -import { expect, test } from "vitest"; +import { test } from "vitest"; import { processOpenApiDocument } from "../lib/process-document.ts"; import { expectGenerated } from "./generated-snapshot.ts"; @@ -524,3 +524,27 @@ test("a $ref nested past the top level registers after its target", async () => await expectGenerated([result.typesFile, result.valibotFile]); }); + +test("a value the schema leaves open is a JsonValue on both sides", async () => { + const result = await processOpenApiDocument("/tmp/whatever", { + openapi: "3.1.0", + info: { title: "Test", version: "1.0.0" }, + paths: {}, + components: { + schemas: { + Open: { + type: "object", + required: ["anything", "record", "list"], + properties: { + anything: {}, + record: { type: "object", additionalProperties: true }, + list: { type: "array" }, + }, + additionalProperties: false, + }, + }, + }, + }); + + await expectGenerated([result.typesFile, result.valibotFile]); +}); diff --git a/__tests__/fixtures/docker/.openapi-codegen-manifest.json b/__tests__/fixtures/docker/.openapi-codegen-manifest.json index 9ef0dd3..24a8e04 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "dfa29fcb516184c923352b589d0a33f8", - "commands.ts": "0971e86b831d9a354c1e219ecf7e8b7f", - "types.ts": "8663cb3f2737a93a01cf1b396e2fad63", - "main.ts": "38065305823906f3aa1c7f968e278002", - "valibot.ts": "2c62b6192664e3a42e1b44700d430df7", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", + "commands.ts": "137aa1b06856ca44a0c780958480af81", + "types.ts": "f1e7d6c61bb9e15c5034a3cc3cc729b5", + "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", + "valibot.ts": "25d47efaf15282d72c20aed794bd32da", "hono.ts": "4dee43760e6f999bf0da89d4c063bcd4", - "commands-validated.ts": "633c805329787be3de004224eeb86e5c", + "commands-validated.ts": "c6066f3a4ead3dadfad70443e923a265", "enums.ts": "6d2420ab590db68349e2e8463a1b026d" } diff --git a/__tests__/fixtures/docker/types.ts b/__tests__/fixtures/docker/types.ts index cc0ad51..93c4736 100644 --- a/__tests__/fixtures/docker/types.ts +++ b/__tests__/fixtures/docker/types.ts @@ -6,7 +6,7 @@ // oxlint-disable block65/max-comment-lines, block65/no-absence-comment, block65/no-comment-history, block65/no-comment-list, block65/no-comment-overclaim, block65/no-comment-punctuation, block65/no-figurative-comment, block65/no-narrative-comment, block65/no-negated-comment, block65/no-padded-comment, block65/no-trailing-comment-punctuation, unicorn-unported/comment-content -import type { Jsonifiable, UndefinedOnPartialDeep } from "type-fest"; +import type { JsonValue, UndefinedOnPartialDeep } from "type-fest"; /** An open port on a container */ export type Port = { @@ -620,7 +620,7 @@ export type ContainerConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -654,7 +654,7 @@ export type ContainerConfig = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -754,7 +754,7 @@ export type ImageConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -821,7 +821,7 @@ export type ImageConfig = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1362,7 +1362,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -1396,7 +1396,7 @@ export type ImageInspect = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1510,7 +1510,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -1577,7 +1577,7 @@ export type ImageInspect = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1836,7 +1836,7 @@ export type Volume = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -1882,7 +1882,7 @@ export type Volume = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -2009,7 +2009,7 @@ export type VolumeCreateOptions = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -2068,7 +2068,7 @@ export type VolumeListResponse = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -2114,7 +2114,7 @@ export type VolumeListResponse = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -3593,7 +3593,7 @@ export type TaskSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -3906,7 +3906,7 @@ export type Task = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4262,7 +4262,7 @@ export type ServiceSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4408,7 +4408,7 @@ export type ServiceSpec = { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -4417,7 +4417,7 @@ export type ServiceSpec = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -4708,7 +4708,7 @@ export type Service = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4854,7 +4854,7 @@ export type Service = { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -4863,7 +4863,7 @@ export type Service = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -5495,7 +5495,7 @@ export type SystemVersion = { * @example 19.03.12 */ Version: string; - Details?: Record | null; + Details?: Record | null; }[]; /** * The version of the daemon @@ -7029,7 +7029,7 @@ export type ClusterVolume = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -7111,7 +7111,7 @@ export type ClusterVolumeSpec = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -7330,7 +7330,7 @@ type ContainerCreateJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -7364,7 +7364,7 @@ type ContainerCreateJsonBody = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -8191,7 +8191,7 @@ export type ContainerInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -8225,7 +8225,7 @@ export type ContainerInspectCommandOutput = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -8565,9 +8565,7 @@ export type ContainerStatsCommandParams = { }; export type ContainerStatsCommandInput = ContainerStatsCommandParams & ContainerStatsCommandQuery; -export type ContainerStatsCommandOutput = - | Record - | undefined; +export type ContainerStatsCommandOutput = Record | undefined; export type InputContainerStatsCommandResponse = UndefinedOnPartialDeep; export type ContainerResizeCommandQuery = { @@ -9089,7 +9087,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -9123,7 +9121,7 @@ export type ImageInspectCommandOutput = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -9237,7 +9235,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -9304,7 +9302,7 @@ export type ImageInspectCommandOutput = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -10355,7 +10353,7 @@ export type SystemVersionCommandOutput = { * @example 19.03.12 */ Version: string; - Details?: Record | null; + Details?: Record | null; }[]; /** * The version of the daemon @@ -10451,7 +10449,7 @@ type ImageCommitJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record> | null; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -10485,7 +10483,7 @@ type ImageCommitJsonBody = { * @example example-image:1.0 */ Image?: string; - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -10868,7 +10866,7 @@ export type SystemDataUsageCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -10914,7 +10912,7 @@ export type SystemDataUsageCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -11179,7 +11177,7 @@ export type VolumeListCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -11225,7 +11223,7 @@ export type VolumeListCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -11359,7 +11357,7 @@ type VolumeCreateJsonBody = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -11418,7 +11416,7 @@ export type VolumeCreateCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -11464,7 +11462,7 @@ export type VolumeCreateCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -11578,7 +11576,7 @@ export type VolumeInspectCommandOutput = { * does not support this feature. * @example [object Object] */ - Status?: Record>; + Status?: Record>; /** * User-defined key/value metadata. * @example [object Object] @@ -11624,7 +11622,7 @@ export type VolumeInspectCommandOutput = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -11733,7 +11731,7 @@ type VolumeUpdateJsonBody = { * @enum none,readonly,onewriter,all */ Sharing?: "none" | "readonly" | "onewriter" | "all"; - MountVolume?: Record; + MountVolume?: Record; Secrets?: readonly { Key?: string; Secret?: string; @@ -13530,7 +13528,7 @@ export type ServiceListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -13676,7 +13674,7 @@ export type ServiceListCommandOutput = readonly { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -13685,7 +13683,7 @@ export type ServiceListCommandOutput = readonly { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14009,7 +14007,7 @@ type ServiceCreateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14155,7 +14153,7 @@ type ServiceCreateJsonBody = { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -14164,7 +14162,7 @@ type ServiceCreateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14241,7 +14239,7 @@ type ServiceCreateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceCreateCommandBody = ServiceCreateJsonBody; export type ServiceCreateCommandInput = ServiceCreateJsonBody; export type ServiceCreateCommandOutput = { @@ -14414,7 +14412,7 @@ export type ServiceInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14560,7 +14558,7 @@ export type ServiceInspectCommandOutput = { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -14569,7 +14567,7 @@ export type ServiceInspectCommandOutput = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14902,7 +14900,7 @@ type ServiceUpdateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15048,7 +15046,7 @@ type ServiceUpdateJsonBody = { Replicated?: { Replicas?: bigint; }; - Global?: Record; + Global?: Record; ReplicatedJob?: { /** * The maximum number of replicas to run simultaneously. @@ -15057,7 +15055,7 @@ type ServiceUpdateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -15134,7 +15132,7 @@ type ServiceUpdateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceUpdateCommandParams = { id: string; }; @@ -15320,7 +15318,7 @@ export type TaskListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15687,7 +15685,7 @@ export type TaskInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -16005,7 +16003,7 @@ type SecretCreateJsonBody = { */ Options?: Record; }; -} & Record; +} & Record; export type SecretCreateCommandBody = SecretCreateJsonBody; export type SecretCreateCommandInput = SecretCreateJsonBody; export type SecretCreateCommandOutput = { @@ -16172,7 +16170,7 @@ type ConfigCreateJsonBody = { */ Options?: Record; }; -} & Record; +} & Record; export type ConfigCreateCommandBody = ConfigCreateJsonBody; export type ConfigCreateCommandInput = ConfigCreateJsonBody; export type ConfigCreateCommandOutput = { diff --git a/__tests__/fixtures/docker/valibot.ts b/__tests__/fixtures/docker/valibot.ts index 9d858aa..bb7fd22 100644 --- a/__tests__/fixtures/docker/valibot.ts +++ b/__tests__/fixtures/docker/valibot.ts @@ -6,8 +6,19 @@ // oxlint-disable block65/max-comment-lines, block65/no-absence-comment, block65/no-assumption-comment, block65/no-banned-comment-words, block65/no-comment-history, block65/no-comment-list, block65/no-comment-overclaim, block65/no-comment-punctuation, block65/no-figurative-comment, block65/no-narrative-comment, block65/no-negated-comment, block65/no-padded-comment, block65/no-trailing-comment-punctuation, block65/prefer-exact-optional, unicorn-unported/comment-content +import type { JsonValue } from "type-fest"; import * as v from "valibot"; +const jsonValueSchema: v.GenericSchema = v.lazy(() => + v.union([ + v.string(), + v.number(), + v.boolean(), + v.null(), + v.record(v.string(), jsonValueSchema), + v.array(jsonValueSchema), + ]), +); /** * An open port on a container * @example { @@ -3420,7 +3431,7 @@ export const inputContainerConfigSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -3494,7 +3505,9 @@ export const inputContainerConfigSchema = v.looseObject({ * An object mapping mount point paths inside the container to empty * objects. */ - Volumes: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Volumes: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * The working directory for commands to run in. */ @@ -3567,7 +3580,7 @@ export const containerConfigSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -3660,7 +3673,7 @@ export const containerConfigSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -3807,7 +3820,7 @@ export const inputImageConfigSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -3897,7 +3910,9 @@ export const inputImageConfigSchema = v.looseObject({ * An object mapping mount point paths inside the container to empty * objects. */ - Volumes: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Volumes: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * The working directory for commands to run in. */ @@ -4002,7 +4017,7 @@ export const imageConfigSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -4111,7 +4126,7 @@ export const imageConfigSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -5116,7 +5131,7 @@ export const inputImageInspectSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -5191,7 +5206,7 @@ export const inputImageInspectSchema = v.looseObject({ * objects. */ Volumes: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -5302,7 +5317,7 @@ export const inputImageInspectSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -5393,7 +5408,7 @@ export const inputImageInspectSchema = v.looseObject({ * objects. */ Volumes: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -5623,7 +5638,7 @@ export const imageInspectSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -5716,7 +5731,7 @@ export const imageInspectSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -5831,7 +5846,7 @@ export const imageInspectSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -5940,7 +5955,7 @@ export const imageInspectSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -6317,7 +6332,9 @@ export const inputVolumeSchema = v.looseObject({ * The `Status` field is optional, and is omitted if the volume driver * does not support this feature. */ - Status: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Status: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * User-defined key/value metadata. */ @@ -6438,7 +6455,7 @@ export const inputVolumeSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -6643,7 +6660,7 @@ export const volumeSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -6765,7 +6782,9 @@ export const volumeSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -7076,7 +7095,7 @@ export const inputVolumeCreateOptionsSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -7250,7 +7269,7 @@ export const volumeCreateOptionsSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -7378,7 +7397,7 @@ export const inputVolumeListResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -7500,7 +7519,9 @@ export const inputVolumeListResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -7718,7 +7739,7 @@ export const volumeListResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -7841,7 +7862,7 @@ export const volumeListResponseSchema = v.looseObject({ * Intentionally empty. */ MountVolume: v.exactOptional( - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), ), /** * Swarm Secrets that are passed to the CSI storage plugin when @@ -12012,7 +12033,7 @@ export const inputTaskSpecSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -12796,7 +12817,7 @@ export const taskSpecSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -13676,7 +13697,7 @@ export const inputTaskSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -14612,7 +14633,7 @@ export const taskSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -15564,7 +15585,7 @@ export const inputServiceSpecSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -15865,7 +15886,7 @@ export const inputServiceSpecSchema = v.looseObject({ Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -15887,7 +15908,7 @@ export const inputServiceSpecSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -16555,7 +16576,7 @@ export const serviceSpecSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -16942,7 +16963,7 @@ export const serviceSpecSchema = v.looseObject({ ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -16976,7 +16997,7 @@ export const serviceSpecSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -17806,7 +17827,7 @@ export const inputServiceSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -18107,7 +18128,7 @@ export const inputServiceSchema = v.looseObject({ Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -18129,7 +18150,7 @@ export const inputServiceSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -19002,7 +19023,9 @@ export const serviceSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -19397,7 +19420,7 @@ export const serviceSchema = v.looseObject({ ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -19431,7 +19454,7 @@ export const serviceSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -21080,7 +21103,7 @@ export const inputSystemVersionSchema = v.looseObject({ * * These messages can be printed by the client as information to the user. */ - Details: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + Details: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }), ), ), @@ -21158,7 +21181,9 @@ export const systemVersionSchema = v.looseObject({ * * These messages can be printed by the client as information to the user. */ - Details: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + Details: v.exactOptional( + v.nullable(v.record(v.string(), jsonValueSchema)), + ), }), ), ), @@ -24741,7 +24766,7 @@ export const inputClusterVolumeSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -24990,7 +25015,7 @@ export const clusterVolumeSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -25238,7 +25263,7 @@ export const inputClusterVolumeSpecSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -25386,7 +25411,7 @@ export const clusterVolumeSpecSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -25970,7 +25995,7 @@ export const inputContainerCreateCommandBodySchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -26044,7 +26069,9 @@ export const inputContainerCreateCommandBodySchema = v.looseObject({ * An object mapping mount point paths inside the container to empty * objects. */ - Volumes: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Volumes: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * The working directory for commands to run in. */ @@ -26937,7 +26964,7 @@ export const containerCreateCommandBodySchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -27030,7 +27057,7 @@ export const containerCreateCommandBodySchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -29191,7 +29218,7 @@ export const inputContainerInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -29266,7 +29293,7 @@ export const inputContainerInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -30838,7 +30865,7 @@ export const containerInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -30931,7 +30958,7 @@ export const containerInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -31382,11 +31409,11 @@ export const containerExportCommandParamsSchema = v.strictObject({ }); export const inputContainerStatsCommandResponseSchema = v.record( v.string(), - v.unknown(), + jsonValueSchema, ); export const containerStatsCommandResponseSchema = v.record( v.string(), - v.unknown(), + jsonValueSchema, ); export const inputContainerStatsCommandParamsSchema = v.strictObject({ id: v.string(), @@ -32974,7 +33001,7 @@ export const inputImageInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -33049,7 +33076,7 @@ export const inputImageInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -33160,7 +33187,7 @@ export const inputImageInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -33251,7 +33278,7 @@ export const inputImageInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -33481,7 +33508,7 @@ export const imageInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -33574,7 +33601,7 @@ export const imageInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -33689,7 +33716,7 @@ export const imageInspectCommandResponseSchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -33798,7 +33825,7 @@ export const imageInspectCommandResponseSchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -36153,7 +36180,7 @@ export const inputSystemVersionCommandResponseSchema = v.looseObject({ * * These messages can be printed by the client as information to the user. */ - Details: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + Details: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }), ), ), @@ -36231,7 +36258,9 @@ export const systemVersionCommandResponseSchema = v.looseObject({ * * These messages can be printed by the client as information to the user. */ - Details: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + Details: v.exactOptional( + v.nullable(v.record(v.string(), jsonValueSchema)), + ), }), ), ), @@ -36312,7 +36341,7 @@ export const inputImageCommitCommandBodySchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.optional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -36386,7 +36415,9 @@ export const inputImageCommitCommandBodySchema = v.looseObject({ * An object mapping mount point paths inside the container to empty * objects. */ - Volumes: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Volumes: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * The working directory for commands to run in. */ @@ -36459,7 +36490,7 @@ export const imageCommitCommandBodySchema = v.looseObject({ * `{"/": {}}` */ ExposedPorts: v.exactOptional( - v.nullable(v.record(v.string(), v.record(v.string(), v.unknown()))), + v.nullable(v.record(v.string(), v.record(v.string(), jsonValueSchema))), ), /** * Attach standard streams to a TTY, including `stdin` if it is not closed. @@ -36552,7 +36583,7 @@ export const imageCommitCommandBodySchema = v.looseObject({ * objects. */ Volumes: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * The working directory for commands to run in. @@ -37077,7 +37108,7 @@ export const inputSystemDataUsageCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -37199,7 +37230,9 @@ export const inputSystemDataUsageCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -37821,7 +37854,7 @@ export const systemDataUsageCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -37944,7 +37977,7 @@ export const systemDataUsageCommandResponseSchema = v.looseObject({ * Intentionally empty. */ MountVolume: v.exactOptional( - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), ), /** * Swarm Secrets that are passed to the CSI storage plugin when @@ -38571,7 +38604,7 @@ export const inputVolumeListCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.optional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -38693,7 +38726,9 @@ export const inputVolumeListCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -38911,7 +38946,7 @@ export const volumeListCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -39034,7 +39069,7 @@ export const volumeListCommandResponseSchema = v.looseObject({ * Intentionally empty. */ MountVolume: v.exactOptional( - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), ), /** * Swarm Secrets that are passed to the CSI storage plugin when @@ -39379,7 +39414,7 @@ export const inputVolumeCreateCommandBodySchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -39553,7 +39588,7 @@ export const volumeCreateCommandBodySchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -39670,7 +39705,9 @@ export const inputVolumeCreateCommandResponseSchema = v.looseObject({ * The `Status` field is optional, and is omitted if the volume driver * does not support this feature. */ - Status: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Status: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * User-defined key/value metadata. */ @@ -39791,7 +39828,7 @@ export const inputVolumeCreateCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -39996,7 +40033,7 @@ export const volumeCreateCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -40118,7 +40155,9 @@ export const volumeCreateCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -40352,7 +40391,9 @@ export const inputVolumeInspectCommandResponseSchema = v.looseObject({ * The `Status` field is optional, and is omitted if the volume driver * does not support this feature. */ - Status: v.optional(v.record(v.string(), v.record(v.string(), v.unknown()))), + Status: v.optional( + v.record(v.string(), v.record(v.string(), jsonValueSchema)), + ), /** * User-defined key/value metadata. */ @@ -40473,7 +40514,7 @@ export const inputVolumeInspectCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -40678,7 +40719,7 @@ export const volumeInspectCommandResponseSchema = v.looseObject({ * does not support this feature. */ Status: v.exactOptional( - v.record(v.string(), v.record(v.string(), v.unknown())), + v.record(v.string(), v.record(v.string(), jsonValueSchema)), ), /** * User-defined key/value metadata. @@ -40800,7 +40841,9 @@ export const volumeInspectCommandResponseSchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -41096,7 +41139,7 @@ export const inputVolumeUpdateCommandBodySchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.optional(v.record(v.string(), v.unknown())), + MountVolume: v.optional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -41251,7 +41294,7 @@ export const volumeUpdateCommandBodySchema = v.looseObject({ * * Intentionally empty. */ - MountVolume: v.exactOptional(v.record(v.string(), v.unknown())), + MountVolume: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * Swarm Secrets that are passed to the CSI storage plugin when * operating on this volume. @@ -46260,7 +46303,9 @@ export const inputServiceListCommandResponseSchema = v.array( * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional( + v.record(v.string(), jsonValueSchema), + ), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -46563,7 +46608,7 @@ export const inputServiceListCommandResponseSchema = v.array( Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -46585,7 +46630,7 @@ export const inputServiceListCommandResponseSchema = v.array( * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -47505,7 +47550,7 @@ export const serviceListCommandResponseSchema = v.array( * > exclusive */ Runtime: v.exactOptional( - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), ), /** * ConfigID represents the ID of the specific config that we're @@ -47959,7 +48004,7 @@ export const serviceListCommandResponseSchema = v.array( ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -47993,7 +48038,7 @@ export const serviceListCommandResponseSchema = v.array( * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -48827,7 +48872,7 @@ export const inputServiceCreateCommandBodySchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -49128,7 +49173,7 @@ export const inputServiceCreateCommandBodySchema = v.looseObject({ Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -49150,7 +49195,7 @@ export const inputServiceCreateCommandBodySchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -49818,7 +49863,7 @@ export const serviceCreateCommandBodySchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -50205,7 +50250,7 @@ export const serviceCreateCommandBodySchema = v.looseObject({ ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -50239,7 +50284,7 @@ export const serviceCreateCommandBodySchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -50958,7 +51003,7 @@ export const inputServiceInspectCommandResponseSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -51259,7 +51304,7 @@ export const inputServiceInspectCommandResponseSchema = v.looseObject({ Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -51281,7 +51326,7 @@ export const inputServiceInspectCommandResponseSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -52154,7 +52199,9 @@ export const serviceInspectCommandResponseSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -52549,7 +52596,7 @@ export const serviceInspectCommandResponseSchema = v.looseObject({ ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -52583,7 +52630,7 @@ export const serviceInspectCommandResponseSchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -53422,7 +53469,7 @@ export const inputServiceUpdateCommandBodySchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -53723,7 +53770,7 @@ export const inputServiceUpdateCommandBodySchema = v.looseObject({ Replicas: v.optional(v.bigint()), }), ), - Global: v.optional(v.record(v.string(), v.unknown())), + Global: v.optional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -53745,7 +53792,7 @@ export const inputServiceUpdateCommandBodySchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.optional(v.record(v.string(), v.unknown())), + GlobalJob: v.optional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -54413,7 +54460,7 @@ export const serviceUpdateCommandBodySchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -54800,7 +54847,7 @@ export const serviceUpdateCommandBodySchema = v.looseObject({ ), }), ), - Global: v.exactOptional(v.record(v.string(), v.unknown())), + Global: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * The mode used for services with a finite number of tasks that run * to a completed state. @@ -54834,7 +54881,7 @@ export const serviceUpdateCommandBodySchema = v.looseObject({ * The mode used for services which run a task to the completed state * on each valid node. */ - GlobalJob: v.exactOptional(v.record(v.string(), v.unknown())), + GlobalJob: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), /** @@ -55594,7 +55641,7 @@ export const inputTaskListCommandResponseSchema = v.array( * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -56532,7 +56579,9 @@ export const taskListCommandResponseSchema = v.array( * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional( + v.record(v.string(), jsonValueSchema), + ), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -57517,7 +57566,7 @@ export const inputTaskInspectCommandResponseSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.optional(v.record(v.string(), v.unknown())), + Runtime: v.optional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. @@ -58453,7 +58502,7 @@ export const taskInspectCommandResponseSchema = v.looseObject({ * > **Note**: `Configs.File` and `Configs.Runtime` are mutually * > exclusive */ - Runtime: v.exactOptional(v.record(v.string(), v.unknown())), + Runtime: v.exactOptional(v.record(v.string(), jsonValueSchema)), /** * ConfigID represents the ID of the specific config that we're * referencing. diff --git a/__tests__/fixtures/openai/.openapi-codegen-manifest.json b/__tests__/fixtures/openai/.openapi-codegen-manifest.json index 0d8a91c..e6f86d9 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "dfa29fcb516184c923352b589d0a33f8", - "commands.ts": "99ac148005b23e09a53adb6b62620dc0", - "types.ts": "09755ea8c2e057904e6e57c6ad14d7ed", - "main.ts": "8147604a37254400a015b78650466094", - "valibot.ts": "0d298d838136dd6e76996d9ebfe4af82", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", + "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", + "types.ts": "bc453b1a7fcd330909a23ae01be97f52", + "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", + "valibot.ts": "3be60d2491963c2904292438b7de247b", "hono.ts": "54130437a23164b228769eb3ec967e4e", - "commands-validated.ts": "9725b4bdcac4632927d011b9a54886d9", + "commands-validated.ts": "e4929484f6a64b784ff7b03327f58a3a", "enums.ts": "87a5ccd7e57cc937104b2d256e8d67b1" } diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index d274f5f..842f089 100644 --- a/__tests__/fixtures/openai/types.ts +++ b/__tests__/fixtures/openai/types.ts @@ -7,7 +7,7 @@ // oxlint-disable block65/max-comment-lines, block65/no-absence-comment, block65/no-comment-list, block65/no-comment-punctuation, block65/no-figurative-comment, block65/no-hedging-comment, block65/no-jargon-comment, block65/no-narrative-comment, block65/no-negated-comment, block65/no-padded-comment, block65/no-trailing-comment-punctuation, unicorn-unported/comment-content import type { - Jsonifiable, + JsonValue, LiteralUnion, UndefinedOnPartialDeep, } from "type-fest"; @@ -28,7 +28,7 @@ export type ChatCompletionRole = * Represents a streamed chunk of a chat completion response returned by * model, based on the provided input. */ -export type CreateChatCompletionImageResponse = Record; +export type CreateChatCompletionImageResponse = Record; export type CreateImageRequest = { /** * A text description of the desired image(s). The maximum length is 1000 @@ -320,7 +320,7 @@ export type CompleteUploadRequest = { part_ids: readonly string[]; md5?: string; }; -export type CancelUploadRequest = Record; +export type CancelUploadRequest = Record; export type CreateFineTuningJobRequest = { /** * The name of the model to fine-tune. You can select one of the @@ -518,7 +518,7 @@ export type DeleteAssistantResponse = { object: "assistant.deleted"; }; export type ModifyRunRequest = { - metadata?: Record | null; + metadata?: Record | null; }; export type SubmitToolOutputsRunRequest = { tool_outputs: readonly { @@ -542,7 +542,7 @@ export type ModifyThreadRequest = { vector_store_ids?: readonly string[]; }; } | null; - metadata?: Record | null; + metadata?: Record | null; }; export type DeleteThreadResponse = { id: string; @@ -550,7 +550,7 @@ export type DeleteThreadResponse = { object: "thread.deleted"; }; export type ModifyMessageRequest = { - metadata?: Record | null; + metadata?: Record | null; }; export type DeleteMessageResponse = { id: string; @@ -609,7 +609,7 @@ export type BatchRequestOutput = { response?: { status_code?: number; request_id?: string; - body?: Record; + body?: Record; } | null; error?: { code?: string; @@ -1101,7 +1101,7 @@ export type Batch = { completed: number; failed: number; }; - metadata?: Record | null; + metadata?: Record | null; }; export type ListBatchesResponse = { data: readonly Batch[]; @@ -1423,7 +1423,7 @@ export type MessageObject = { )[]; }[] | null; - metadata: Record | null; + metadata: Record | null; }; export type MessageStreamEvent = | { @@ -1478,7 +1478,7 @@ export type RunStepDeltaStepDetailsToolCallsFileSearchObject = { * @enum file_search */ type: "file_search"; - file_search: Record; + file_search: Record; }; export type RunStepDeltaStepDetailsToolCallsCodeOutputImageObject = { index: number; @@ -1719,7 +1719,7 @@ export type RunStepObject = { cancelled_at: number | null; failed_at: number | null; completed_at: number | null; - metadata: Record | null; + metadata: Record | null; /** * Usage statistics related to the run step. This value will be `null` while * the run step's status is `in_progress`. @@ -1766,7 +1766,7 @@ export type RunStepStreamEvent = data: RunStepObject; }; /** The schema for the response format, described as a JSON Schema object. */ -export type ResponseFormatJsonSchemaSchema = Record; +export type ResponseFormatJsonSchemaSchema = Record; export type ResponseFormatJsonSchema = { /** * The type of response format being defined: `json_schema` @@ -1892,7 +1892,7 @@ export type RunCompletionUsage = { * * Omitting `parameters` defines a function with an empty parameter list. */ -export type FunctionParameters = Record; +export type FunctionParameters = Record; export type FunctionObject = { description?: string; name: string; @@ -2035,7 +2035,7 @@ export type RunObject = { | AssistantToolsFileSearch | AssistantToolsFunction )[]; - metadata: Record | null; + metadata: Record | null; /** * Usage statistics related to the run. This value will be `null` if the run * is not in a terminal state (i.e. `in_progress`, `queued`, etc.). @@ -2167,7 +2167,7 @@ export type ThreadObject = { vector_store_ids?: readonly string[]; }; } | null; - metadata: Record | null; + metadata: Record | null; }; export type ThreadStreamEvent = { event: "thread.created"; @@ -2355,7 +2355,7 @@ export type VectorStoreObject = { expires_after?: VectorStoreExpirationAfter; expires_at?: number | null; last_active_at: number | null; - metadata: Record | null; + metadata: Record | null; }; export type ListVectorStoresResponse = { object: string; @@ -2368,7 +2368,7 @@ export type UpdateVectorStoreRequest = { name?: string | null; /** The expiration policy for a vector store. */ expires_after?: VectorStoreExpirationAfter; - metadata?: Record | null; + metadata?: Record | null; }; export type CreateVectorStoreRequest = { file_ids?: readonly string[]; @@ -2378,7 +2378,7 @@ export type CreateVectorStoreRequest = { chunking_strategy?: | AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - metadata?: Record | null; + metadata?: Record | null; }; export type ListRunStepsResponse = { object: string; @@ -2437,7 +2437,7 @@ export type CreateMessageRequest = { )[]; }[] | null; - metadata?: Record | null; + metadata?: Record | null; }; export type CreateThreadRequest = { messages?: readonly CreateMessageRequest[]; @@ -2453,7 +2453,7 @@ export type CreateThreadRequest = { }; file_search?: unknown; } | null; - metadata?: Record | null; + metadata?: Record | null; }; export type CreateThreadAndRunRequest = { assistant_id: string; @@ -2513,7 +2513,7 @@ export type CreateThreadAndRunRequest = { vector_store_ids?: readonly string[]; }; } | null; - metadata?: Record | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2636,7 +2636,7 @@ export type CreateRunRequest = { | AssistantToolsFunction )[] | null; - metadata?: Record | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2745,7 +2745,7 @@ export type AssistantObject = { vector_store_ids?: readonly string[]; }; } | null; - metadata: Record | null; + metadata: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2826,7 +2826,7 @@ export type ModifyAssistantRequest = { vector_store_ids?: readonly string[]; }; } | null; - metadata?: Record | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -2930,7 +2930,7 @@ export type CreateAssistantRequest = { }; file_search?: unknown; } | null; - metadata?: Record | null; + metadata?: Record | null; /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it diff --git a/__tests__/fixtures/openai/valibot.ts b/__tests__/fixtures/openai/valibot.ts index 642c514..3ebff2b 100644 --- a/__tests__/fixtures/openai/valibot.ts +++ b/__tests__/fixtures/openai/valibot.ts @@ -6,8 +6,19 @@ // oxlint-disable block65/max-comment-lines, block65/no-absence-comment, block65/no-comment-list, block65/no-comment-punctuation, block65/no-figurative-comment, block65/no-hedging-comment, block65/no-jargon-comment, block65/no-narrative-comment, block65/no-negated-comment, block65/no-padded-comment, block65/no-trailing-comment-punctuation, block65/prefer-exact-optional, unicorn-unported/comment-content +import type { JsonValue } from "type-fest"; import * as v from "valibot"; +const jsonValueSchema: v.GenericSchema = v.lazy(() => + v.union([ + v.string(), + v.number(), + v.boolean(), + v.null(), + v.record(v.string(), jsonValueSchema), + v.array(jsonValueSchema), + ]), +); export const inputDeleteModelResponseSchema = v.looseObject({ id: v.string(), deleted: v.boolean(), @@ -33,7 +44,7 @@ export const chatCompletionRoleSchema = inputChatCompletionRoleSchema; */ export const inputCreateChatCompletionImageResponseSchema = v.record( v.string(), - v.unknown(), + jsonValueSchema, ); export const createChatCompletionImageResponseSchema = inputCreateChatCompletionImageResponseSchema; @@ -974,7 +985,10 @@ export const completeUploadRequestSchema = v.strictObject({ */ md5: v.exactOptional(v.pipe(v.string(), v.trim())), }); -export const inputCancelUploadRequestSchema = v.record(v.string(), v.unknown()); +export const inputCancelUploadRequestSchema = v.record( + v.string(), + jsonValueSchema, +); export const cancelUploadRequestSchema = inputCancelUploadRequestSchema; export const inputCreateFineTuningJobRequestSchema = v.looseObject({ /** @@ -1552,7 +1566,7 @@ export const inputModifyRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const modifyRunRequestSchema = v.strictObject({ /** @@ -1561,7 +1575,7 @@ export const modifyRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputSubmitToolOutputsRunRequestSchema = v.strictObject({ /** @@ -1652,7 +1666,7 @@ export const inputModifyThreadRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const modifyThreadRequestSchema = v.strictObject({ /** @@ -1697,7 +1711,7 @@ export const modifyThreadRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputDeleteThreadResponseSchema = v.looseObject({ id: v.string(), @@ -1716,7 +1730,7 @@ export const inputModifyMessageRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const modifyMessageRequestSchema = v.strictObject({ /** @@ -1725,7 +1739,7 @@ export const modifyMessageRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputDeleteMessageResponseSchema = v.looseObject({ id: v.string(), @@ -1915,7 +1929,7 @@ export const inputBatchRequestOutputSchema = v.looseObject({ /** * The JSON body of the response */ - body: v.optional(v.record(v.string(), v.unknown())), + body: v.optional(v.record(v.string(), jsonValueSchema)), }), ), ), @@ -1960,7 +1974,7 @@ export const batchRequestOutputSchema = v.looseObject({ /** * The JSON body of the response */ - body: v.exactOptional(v.record(v.string(), v.unknown())), + body: v.exactOptional(v.record(v.string(), jsonValueSchema)), }), ), ), @@ -3705,7 +3719,7 @@ export const inputBatchSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const batchSchema = v.looseObject({ id: v.pipe(v.string(), v.trim()), @@ -3838,7 +3852,7 @@ export const batchSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputListBatchesResponseSchema = v.looseObject({ data: v.array(inputBatchSchema), @@ -4612,7 +4626,7 @@ export const inputMessageObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const messageObjectSchema = v.looseObject({ /** @@ -4718,7 +4732,7 @@ export const messageObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const inputMessageStreamEventSchema = v.union([ v.looseObject({ @@ -4833,7 +4847,7 @@ export const inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema = /** * For now, this is always going to be an empty object. */ - file_search: v.record(v.string(), v.unknown()), + file_search: v.record(v.string(), jsonValueSchema), }); export const runStepDeltaStepDetailsToolCallsFileSearchObjectSchema = v.looseObject({ @@ -4853,7 +4867,7 @@ export const runStepDeltaStepDetailsToolCallsFileSearchObjectSchema = /** * For now, this is always going to be an empty object. */ - file_search: v.record(v.string(), v.unknown()), + file_search: v.record(v.string(), jsonValueSchema), }); export const inputRunStepDeltaStepDetailsToolCallsCodeOutputImageObjectSchema = v.looseObject({ @@ -5626,7 +5640,7 @@ export const inputRunStepObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), usage: inputRunStepCompletionUsageSchema, }); export const runStepObjectSchema = v.looseObject({ @@ -5718,7 +5732,7 @@ export const runStepObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), usage: runStepCompletionUsageSchema, }); export const inputRunStepStreamEventSchema = v.union([ @@ -5755,7 +5769,7 @@ export const runStepStreamEventSchema = inputRunStepStreamEventSchema; /** The schema for the response format, described as a JSON Schema object. */ export const inputResponseFormatJsonSchemaSchemaSchema = v.record( v.string(), - v.unknown(), + jsonValueSchema, ); export const responseFormatJsonSchemaSchemaSchema = inputResponseFormatJsonSchemaSchemaSchema; @@ -5983,7 +5997,10 @@ export const runCompletionUsageSchema = inputRunCompletionUsageSchema; * * Omitting `parameters` defines a function with an empty parameter list. */ -export const inputFunctionParametersSchema = v.record(v.string(), v.unknown()); +export const inputFunctionParametersSchema = v.record( + v.string(), + jsonValueSchema, +); export const functionParametersSchema = inputFunctionParametersSchema; export const inputFunctionObjectSchema = v.looseObject({ /** @@ -6324,7 +6341,7 @@ export const inputRunObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), usage: inputRunCompletionUsageSchema, /** * The sampling temperature used for this run. If not set, defaults to 1. @@ -6498,7 +6515,7 @@ export const runObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), usage: runCompletionUsageSchema, /** * The sampling temperature used for this run. If not set, defaults to 1. @@ -6625,7 +6642,7 @@ export const inputThreadObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const threadObjectSchema = v.looseObject({ /** @@ -6680,7 +6697,7 @@ export const threadObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const inputThreadStreamEventSchema = v.looseObject({ event: v.picklist(["thread.created"]), @@ -7050,7 +7067,7 @@ export const inputVectorStoreObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const vectorStoreObjectSchema = v.looseObject({ /** @@ -7116,7 +7133,7 @@ export const vectorStoreObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), }); export const inputListVectorStoresResponseSchema = v.looseObject({ object: v.string(), @@ -7144,7 +7161,7 @@ export const inputUpdateVectorStoreRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const updateVectorStoreRequestSchema = v.strictObject({ /** @@ -7158,7 +7175,7 @@ export const updateVectorStoreRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputCreateVectorStoreRequestSchema = v.strictObject({ /** @@ -7187,7 +7204,7 @@ export const inputCreateVectorStoreRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const createVectorStoreRequestSchema = v.strictObject({ /** @@ -7218,7 +7235,7 @@ export const createVectorStoreRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputListRunStepsResponseSchema = v.looseObject({ object: v.string(), @@ -7342,7 +7359,7 @@ export const inputCreateMessageRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const createMessageRequestSchema = v.strictObject({ /** @@ -7400,7 +7417,7 @@ export const createMessageRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputCreateThreadRequestSchema = v.strictObject({ /** @@ -7429,8 +7446,8 @@ export const inputCreateThreadRequestSchema = v.strictObject({ ), file_search: v.optional( v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), ]), ), }), @@ -7442,7 +7459,7 @@ export const inputCreateThreadRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const createThreadRequestSchema = v.strictObject({ /** @@ -7473,8 +7490,8 @@ export const createThreadRequestSchema = v.strictObject({ ), file_search: v.exactOptional( v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), ]), ), }), @@ -7486,7 +7503,7 @@ export const createThreadRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), }); export const inputCreateThreadAndRunRequestSchema = v.strictObject({ /** @@ -7597,7 +7614,7 @@ export const inputCreateThreadAndRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -7759,7 +7776,7 @@ export const createThreadAndRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -7911,7 +7928,7 @@ export const inputCreateRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8051,7 +8068,7 @@ export const createRunRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8194,7 +8211,7 @@ export const inputAssistantObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8306,7 +8323,7 @@ export const assistantObjectSchema = v.looseObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.nullable(v.record(v.string(), v.unknown())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8422,7 +8439,7 @@ export const inputModifyAssistantRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8530,7 +8547,7 @@ export const modifyAssistantRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8641,8 +8658,8 @@ export const inputCreateAssistantRequestSchema = v.strictObject({ ), file_search: v.optional( v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), ]), ), }), @@ -8654,7 +8671,7 @@ export const inputCreateAssistantRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it @@ -8771,8 +8788,8 @@ export const createAssistantRequestSchema = v.strictObject({ ), file_search: v.exactOptional( v.union([ - v.record(v.string(), v.unknown()), - v.record(v.string(), v.unknown()), + v.record(v.string(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), ]), ), }), @@ -8784,7 +8801,7 @@ export const createAssistantRequestSchema = v.strictObject({ * format. Keys can be a maximum of 64 characters long and values can be a * maximum of 512 characters long. */ - metadata: v.exactOptional(v.nullable(v.record(v.string(), v.unknown()))), + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), /** * What sampling temperature to use, between 0 and 2. Higher values like 0.8 * will make the output more random, while lower values like 0.2 will make it diff --git a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json index cedf0e0..bb3e0e4 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "dfa29fcb516184c923352b589d0a33f8", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", - "valibot.ts": "2383058357d21e704546455f4e073d67", + "valibot.ts": "a754e3506dd239dc9fa4973e39198cbd", "hono.ts": "be7061d9a002b7d6f42bbdfc53727ec7", - "commands-validated.ts": "21f5e9e15233b504d8509d93e00911fd" + "commands-validated.ts": "90b52a2210f1b9cc0e123225210fe74a" } diff --git a/__tests__/fixtures/petstore/valibot.ts b/__tests__/fixtures/petstore/valibot.ts index 4971f65..cb5dcce 100644 --- a/__tests__/fixtures/petstore/valibot.ts +++ b/__tests__/fixtures/petstore/valibot.ts @@ -7,7 +7,6 @@ // oxlint-disable block65/prefer-exact-optional import * as v from "valibot"; - export const inputErrorSchema = v.looseObject({ code: v.pipe(v.number(), v.integer()), message: v.string(), diff --git a/__tests__/fixtures/test1/.openapi-codegen-manifest.json b/__tests__/fixtures/test1/.openapi-codegen-manifest.json index 9dad7b5..819b6d4 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,10 +1,10 @@ { - "#generator": "dfa29fcb516184c923352b589d0a33f8", - "commands.ts": "0e6777a5287ed2535587a0f5180bbbd5", - "types.ts": "ce23bfa944b6b2d51dfb0c97062dc8ad", - "main.ts": "5c768be2e48d0b06d7ed8da665653404", - "valibot.ts": "f150b977a0fcd30da6d15f4890bedb2f", - "hono.ts": "12cc7ef64bfc4acf632ba9d9011880d8", - "commands-validated.ts": "afd10b6462e83dbe33e5d42dd227cd97", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", + "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", + "types.ts": "2f7230842affe9bd6e7f727702f0c581", + "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", + "valibot.ts": "d6a449becdabb642ffc6d904277f3f41", + "hono.ts": "26885b9a53e8c0343a2fdb21f4eb8a37", + "commands-validated.ts": "cc5f84090799e163e229aabd160311f8", "enums.ts": "26ade5ccad3bf30118ce8691b99b7c91" } diff --git a/__tests__/fixtures/test1/types.ts b/__tests__/fixtures/test1/types.ts index f848fd1..e1593e3 100644 --- a/__tests__/fixtures/test1/types.ts +++ b/__tests__/fixtures/test1/types.ts @@ -6,7 +6,7 @@ // oxlint-disable block65/no-narrative-comment -import type { Jsonifiable, UndefinedOnPartialDeep } from "type-fest"; +import type { JsonValue, UndefinedOnPartialDeep } from "type-fest"; export type PromoCode = string; /** The API version */ @@ -213,7 +213,7 @@ export type LongRunningOperationSuccess = { operationId: Uuid; done: boolean; result: { - response: Record; + response: Record; }; }; export type LongRunningOperation = diff --git a/__tests__/fixtures/test1/valibot.ts b/__tests__/fixtures/test1/valibot.ts index 438f1c1..6e03a5e 100644 --- a/__tests__/fixtures/test1/valibot.ts +++ b/__tests__/fixtures/test1/valibot.ts @@ -6,8 +6,19 @@ // oxlint-disable block65/no-narrative-comment, block65/prefer-exact-optional +import type { JsonValue } from "type-fest"; import * as v from "valibot"; +const jsonValueSchema: v.GenericSchema = v.lazy(() => + v.union([ + v.string(), + v.number(), + v.boolean(), + v.null(), + v.record(v.string(), jsonValueSchema), + v.array(jsonValueSchema), + ]), +); export const inputPromoCodeSchema = v.pipe( v.string(), v.minLength(1), @@ -489,7 +500,7 @@ export const inputLongRunningOperationSuccessSchema = v.strictObject({ operationId: inputUuidSchema, done: v.literal(true), result: v.strictObject({ - response: v.record(v.string(), v.unknown()), + response: v.record(v.string(), jsonValueSchema), }), }); export const longRunningOperationSuccessSchema = diff --git a/lib/process-document.ts b/lib/process-document.ts index d999956..69e2678 100644 --- a/lib/process-document.ts +++ b/lib/process-document.ts @@ -41,6 +41,7 @@ import { createValibotFile, createValidatorForOperationInput, registerValidatorFromSchema, + removeUnusedJsonValueSchema, } from "./valibot.ts"; export type CodegenOptions = { @@ -367,6 +368,7 @@ function addModulePreambles({ commandsFile, typesFile }: OutputFiles) { namedImports: [ "Jsonifiable", "Jsonify", + "JsonValue", "LiteralUnion", "UndefinedOnPartialDeep", ], @@ -1946,6 +1948,7 @@ export async function processOpenApiDocument( files.typesFile.fixUnusedIdentifiers(); files.commandsFile.fixUnusedIdentifiers(); files.commandsValidatedFile.fixUnusedIdentifiers(); + removeUnusedJsonValueSchema(files.valibotFile); files.valibotFile.fixUnusedIdentifiers(); const honoFile = emitHonoModule( diff --git a/lib/process-schema.ts b/lib/process-schema.ts index 3bd347c..6ec1c09 100644 --- a/lib/process-schema.ts +++ b/lib/process-schema.ts @@ -517,13 +517,13 @@ function objectType( ); return { - type: recordType(value.type ?? "Jsonifiable"), + type: recordType(value.type ?? "JsonValue"), isReadonly: !!schemaObject.readOnly, }; } return { - type: "Record", + type: "Record", }; } @@ -628,7 +628,7 @@ function schemaObjectType( // empty schemaObject if (Object.keys(schemaObject).length === 0) { return { - type: maybeWithNullUnion("Jsonifiable", schemaTypeIsNull(schemaObject)), + type: maybeWithNullUnion("JsonValue", schemaTypeIsNull(schemaObject)), isReadonly: !!schemaObject.readOnly, }; } @@ -871,7 +871,7 @@ export function registerTypesFromSchema( // in TypeScript, since JSON Schema names such as `integer` differ register( schemaToType(typesAndInterfaces, {}, schemaName, schemaObject).type ?? - "Record", + "Record", schemaObject.description, ); } diff --git a/lib/valibot.ts b/lib/valibot.ts index 527b207..c0249f9 100644 --- a/lib/valibot.ts +++ b/lib/valibot.ts @@ -5,6 +5,7 @@ import { type CodeBlockWriter, type Project, type SourceFile, + SyntaxKind, VariableDeclarationKind, type WriterFunction, Writers, @@ -239,6 +240,9 @@ function shouldCoerceSchema( return combinator ? combinator.some((s) => shouldCoerceSchema(s)) : false; } +// the generated passthrough for a value a schema leaves open +const jsonValueSchema = "jsonValueSchema"; + function resolveRef( validators: Map, ref: string, @@ -660,7 +664,7 @@ function objectValidator( if (Object.keys(props).length === 0) { return maybeNullable( maybePipe( - vcall("record", vcall("string"), rest ?? vcall("unknown")), + vcall("record", vcall("string"), rest ?? jsonValueSchema), ...minMaxProperties(schema), ), isNullable, @@ -743,7 +747,7 @@ function schemaToValidator( if (schema.type === "array") { const items = schema.items ? schemaToValidator(validators, schema.items, mode) - : vcall("unknown"); + : jsonValueSchema; return maybeNullable( maybePipe( @@ -771,6 +775,11 @@ function schemaToValidator( ); } + // an empty schema admits any JSON value, as the TS side types it + if (Object.keys(schema).length === 0) { + return jsonValueSchema; + } + if (schema.type === "object" || schema.properties || !schema.type) { return objectValidator(validators, schema, mode, isNullable); } @@ -778,6 +787,26 @@ function schemaToValidator( return schema.type === "null" ? vcall("null") : vcall("unknown"); } +/** + * Removes the JSON value schema when no validator uses it. The recursion + * inside it refers to it, so fixUnusedIdentifiers keeps it otherwise + */ +export function removeUnusedJsonValueSchema(file: SourceFile) { + const declaration = file.getVariableDeclaration(jsonValueSchema); + + const usedOutside = file + .getDescendantsOfKind(SyntaxKind.Identifier) + .some( + (identifier) => + identifier.getText() === jsonValueSchema && + !identifier.getAncestors().includes(declaration ?? identifier), + ); + + if (declaration && !usedOutside) { + declaration.getVariableStatementOrThrow().remove(); + } +} + export function createValibotFile(project: Project, outputDir: string) { const file = project.createSourceFile( path.join(outputDir, "valibot.ts"), @@ -793,6 +822,25 @@ export function createValibotFile(project: Project, outputDir: string) { namespaceImport: "v", }); + file.addImportDeclaration({ + moduleSpecifier: "type-fest", + namedImports: ["JsonValue"], + isTypeOnly: true, + }); + + // A value a schema leaves open is checked as JSON, recursively, so both + // sides type it as JsonValue + file.addVariableStatement({ + declarationKind: VariableDeclarationKind.Const, + declarations: [ + { + name: jsonValueSchema, + type: "v.GenericSchema", + initializer: `v.lazy(() => v.union([v.string(), v.number(), v.boolean(), v.null(), v.record(v.string(), ${jsonValueSchema}), v.array(${jsonValueSchema})]))`, + }, + ], + }); + return file; }