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..10f338b --- /dev/null +++ b/__tests__/__snapshots__/codegen-regressions/a-ref-nested-past-the-top-level-registers-after-its-target/valibot.ts @@ -0,0 +1,33 @@ +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__/__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-types-the-record-value-instead-of-widening-to-unknown/types.ts b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts similarity index 76% rename from __tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts rename to __tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts index 5bbfb1d..8eb1824 100644 --- a/__tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/types.ts +++ b/__tests__/__snapshots__/codegen-regressions/additionalproperties-is-a-string-keyed-record-of-the-value-type/types.ts @@ -1,5 +1,5 @@ import type { UndefinedOnPartialDeep } from "type-fest"; -export type Labels = Record; +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-is-a-string-keyed-record-of-the-value-type/valibot.ts similarity index 99% rename from __tests__/__snapshots__/codegen-regressions/additionalproperties-types-the-record-value-instead-of-widening-to-unknown/valibot.ts rename to __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-types-the-record-value-instead-of-widening-to-unknown/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/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..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__/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__/__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..b8a1e89 --- /dev/null +++ b/__tests__/__snapshots__/nullables/3-0-nullable-objects-arrays-strings-and-combinator-members-admit-null/valibot.ts @@ -0,0 +1,61 @@ +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__/__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 d090143..cc74217 100644 --- a/__tests__/codegen-regressions.test.ts +++ b/__tests__/codegen-regressions.test.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", { @@ -470,3 +470,81 @@ 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]); +}); + +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]); +}); + +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 5bb2570..24a8e04 100644 --- a/__tests__/fixtures/docker/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/docker/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", "commands.ts": "137aa1b06856ca44a0c780958480af81", - "types.ts": "6b85d6261f52a556a0dc6a584b3da2db", + "types.ts": "f1e7d6c61bb9e15c5034a3cc3cc729b5", "main.ts": "0f596fab7f6e9bb140fcd133caccb38d", - "valibot.ts": "2c62b6192664e3a42e1b44700d430df7", + "valibot.ts": "25d47efaf15282d72c20aed794bd32da", "hono.ts": "4dee43760e6f999bf0da89d4c063bcd4", "commands-validated.ts": "c6066f3a4ead3dadfad70443e923a265", "enums.ts": "6d2420ab590db68349e2e8463a1b026d" diff --git a/__tests__/fixtures/docker/types.ts b/__tests__/fixtures/docker/types.ts index 180b553..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 = { @@ -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; @@ -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; @@ -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,19 +455,20 @@ export type HostConfig = { * @example [object Object] */ PortBindings?: Record< - string | number, - 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; - }[] + 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?: { /** @@ -523,10 +524,10 @@ export type HostConfig = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -534,8 +535,8 @@ export type HostConfig = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; - Annotations?: Record; + ConsoleSize?: readonly number[] | null; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -569,12 +570,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 +620,7 @@ export type ContainerConfig = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -653,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/ @@ -669,28 +670,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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. * @@ -820,7 +821,7 @@ export type ImageConfig = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -852,28 +853,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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 @@ -883,13 +884,13 @@ export type ImageConfig = { */ export type NetworkingConfig = { EndpointsConfig?: Record< - string | number, + string, { IPAMConfig?: { 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; } >; }; @@ -984,33 +985,38 @@ export type NetworkSettings = { * @example [object Object] */ Ports?: Record< - string | number, - 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; - }[] + 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. * @@ -1116,13 +1122,13 @@ export type NetworkSettings = { */ MacAddress?: string; Networks?: Record< - string | number, + string, { IPAMConfig?: { 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; } >; }; @@ -1194,19 +1200,20 @@ export type Address = { * are added to the mapping table. */ export type PortMap = Record< - string | number, - 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; - }[] + 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 @@ -1241,7 +1248,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 +1362,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -1392,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/ @@ -1408,28 +1412,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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. @@ -1506,10 +1510,7 @@ export type ImageInspect = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -1576,7 +1577,7 @@ export type ImageInspect = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -1608,28 +1609,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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. @@ -1640,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 @@ -1651,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 @@ -1683,7 +1684,7 @@ export type ImageInspect = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; RootFS?: { Type: string; @@ -1698,7 +1699,7 @@ export type ImageInspect = { * and omitted otherwise. * @example 2022-02-28T14:40:02.623929178Z */ - LastTagTime?: string; + LastTagTime?: string | null; }; }; export type ImageSummary = { @@ -1781,7 +1782,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 +1836,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 +1882,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 +1910,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 +1935,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 @@ -1957,7 +1958,7 @@ export type Volume = { * @default -1 */ RefCount: bigint; - }; + } | null; }; /** Volume configuration */ export type VolumeCreateOptions = { @@ -1977,12 +1978,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 +2009,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 +2068,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 +2114,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 +2142,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 +2167,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 @@ -2189,7 +2190,7 @@ export type VolumeListResponse = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; /** * Warnings that occurred when fetching the list of volumes. @@ -2242,13 +2243,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 +2283,7 @@ export type Network = { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -2295,24 +2296,26 @@ 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; - 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; - }[]; + 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; + }[] + | null; }; /** * The config-only network source to provide the configuration for @@ -2338,19 +2341,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; @@ -2407,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 @@ -2456,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 */ @@ -2508,7 +2511,7 @@ export type EndpointSettings = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -2561,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; @@ -2730,7 +2733,7 @@ export type NodeSpec = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -2767,7 +2770,7 @@ export type Node = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -2817,7 +2820,7 @@ export type Node = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -2861,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 @@ -2903,7 +2906,7 @@ export type NodeDescription = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -2937,7 +2940,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; @@ -2992,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. */ @@ -3006,7 +3009,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 @@ -3014,7 +3017,7 @@ export type SwarmSpec = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3054,7 +3057,7 @@ export type SwarmSpec = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3070,13 +3073,13 @@ export type SwarmSpec = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -3097,7 +3100,7 @@ export type SwarmSpec = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3136,7 +3139,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 @@ -3144,7 +3147,7 @@ export type ClusterInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3184,7 +3187,7 @@ export type ClusterInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3200,13 +3203,13 @@ export type ClusterInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -3227,7 +3230,7 @@ export type ClusterInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3260,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 = { /** @@ -3305,7 +3308,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 @@ -3313,7 +3316,7 @@ export type Swarm = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -3353,7 +3356,7 @@ export type Swarm = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -3369,13 +3372,13 @@ export type Swarm = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -3396,7 +3399,7 @@ export type Swarm = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -3457,7 +3460,7 @@ export type TaskSpec = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -3547,10 +3550,10 @@ export type TaskSpec = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -3590,7 +3593,7 @@ export type TaskSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -3601,7 +3604,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 +3728,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 +3759,7 @@ export type Task = { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -3770,7 +3773,7 @@ export type Task = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -3860,10 +3863,10 @@ export type Task = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -3903,7 +3906,7 @@ export type Task = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -3914,7 +3917,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 +4041,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 +4115,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 +4129,7 @@ export type ServiceSpec = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -4216,10 +4219,10 @@ export type ServiceSpec = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -4259,7 +4262,7 @@ export type ServiceSpec = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4270,7 +4273,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 +4397,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 +4417,7 @@ export type ServiceSpec = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -4457,7 +4460,7 @@ export type ServiceSpec = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -4558,7 +4561,7 @@ export type Service = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -4572,7 +4575,7 @@ export type Service = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -4662,10 +4665,10 @@ export type Service = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -4705,7 +4708,7 @@ export type Service = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -4716,7 +4719,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 +4843,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 +4863,7 @@ export type Service = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -4903,7 +4906,7 @@ export type Service = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -5052,7 +5055,7 @@ export type ContainerSummary = { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -5060,13 +5063,13 @@ export type ContainerSummary = { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -5119,7 +5122,7 @@ export type ContainerSummary = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -5197,7 +5200,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 +5208,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 +5229,7 @@ export type SecretSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -5238,7 +5241,7 @@ export type SecretSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type Secret = { @@ -5254,7 +5257,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 +5278,7 @@ export type Secret = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -5287,13 +5290,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 +5308,7 @@ export type ConfigSpec = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type Config = { @@ -5317,7 +5320,7 @@ export type Config = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -5329,7 +5332,7 @@ export type Config = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -5425,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. @@ -5449,9 +5452,9 @@ export type ContainerState = { */ ExitCode?: number; Output?: string; - }[]; - }; -}; + } | null)[]; + } | null; +} | null; /** OK response to ContainerCreate operation */ export type ContainerCreateResponse = { /** @@ -5492,7 +5495,7 @@ export type SystemVersion = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record | null; }[]; /** * The version of the daemon @@ -5897,7 +5900,7 @@ export type SystemInfo = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -5931,7 +5934,7 @@ export type SystemInfo = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -5939,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`). @@ -6033,7 +6036,7 @@ export type SystemInfo = { * @example [object Object] */ Runtimes?: Record< - string | number, + string, { /** * Name and, optional, path, of the OCI executable binary. @@ -6047,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; } >; /** @@ -6088,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 @@ -6133,7 +6138,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 @@ -6141,7 +6146,7 @@ export type SystemInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -6181,7 +6186,7 @@ export type SystemInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -6197,13 +6202,13 @@ export type SystemInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -6224,7 +6229,7 @@ export type SystemInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -6257,7 +6262,7 @@ export type SystemInfo = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** * Indicates if live restore is enabled. @@ -6473,7 +6478,7 @@ export type RegistryServiceConfig = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -6507,7 +6512,7 @@ export type RegistryServiceConfig = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -6515,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 = { /** @@ -6550,7 +6555,7 @@ export type IndexInfo = { * @example true */ Official?: boolean; -}; +} | null; /** * Runtime describes an [OCI * compliant](https://github.com/opencontainers/runtime-spec) @@ -6573,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 @@ -6617,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 @@ -6662,7 +6669,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 @@ -6670,7 +6677,7 @@ export type SwarmInfo = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -6710,7 +6717,7 @@ export type SwarmInfo = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -6726,13 +6733,13 @@ export type SwarmInfo = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -6753,7 +6760,7 @@ export type SwarmInfo = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -6786,7 +6793,7 @@ export type SwarmInfo = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** Current local status of this node. */ export type LocalNodeState = @@ -6805,7 +6812,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 +6828,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 +6864,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 +7029,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 +7057,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 +7082,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 +7111,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 +7142,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 +7165,7 @@ export type ContainerListCommandOutput = readonly { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -7166,13 +7173,13 @@ export type ContainerListCommandOutput = readonly { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -7225,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; } >; }; @@ -7323,7 +7330,7 @@ type ContainerCreateJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -7357,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/ @@ -7373,28 +7380,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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; @@ -7446,7 +7453,7 @@ type ContainerCreateJsonBody = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -7479,7 +7486,7 @@ type ContainerCreateJsonBody = { | "splunk" | "etwlogs" | "none"; - Config?: Record; + Config?: Record; }; NetworkMode?: string; /** @@ -7493,19 +7500,20 @@ type ContainerCreateJsonBody = { * @example [object Object] */ PortBindings?: Record< - string | number, - 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; - }[] + 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?: { /** @@ -7561,10 +7569,10 @@ type ContainerCreateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -7572,8 +7580,8 @@ type ContainerCreateJsonBody = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; - Annotations?: Record; + ConsoleSize?: readonly number[] | null; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -7607,12 +7615,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,13 +7639,13 @@ type ContainerCreateJsonBody = { */ NetworkingConfig?: { EndpointsConfig?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -7690,7 +7698,7 @@ type ContainerCreateJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -7812,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. @@ -7836,9 +7844,9 @@ export type ContainerInspectCommandOutput = { */ ExitCode?: number; Output?: string; - }[]; - }; - }; + } | null)[]; + } | null; + } | null; Image?: string; ResolvConfPath?: string; HostnamePath?: string; @@ -7851,7 +7859,7 @@ export type ContainerInspectCommandOutput = { MountLabel?: string; ProcessLabel?: string; AppArmorProfile?: string; - ExecIDs?: readonly string[]; + ExecIDs?: readonly string[] | null; HostConfig?: { CpuShares?: number; Memory?: bigint; @@ -7902,7 +7910,7 @@ export type ContainerInspectCommandOutput = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -7935,7 +7943,7 @@ export type ContainerInspectCommandOutput = { | "splunk" | "etwlogs" | "none"; - Config?: Record; + Config?: Record; }; NetworkMode?: string; /** @@ -7949,19 +7957,20 @@ export type ContainerInspectCommandOutput = { * @example [object Object] */ PortBindings?: Record< - string | number, - 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; - }[] + 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?: { /** @@ -8017,10 +8026,10 @@ export type ContainerInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -8028,8 +8037,8 @@ export type ContainerInspectCommandOutput = { Mode?: number; }; }[]; - ConsoleSize?: readonly number[]; - Annotations?: Record; + ConsoleSize?: readonly number[] | null; + Annotations?: Record; CapAdd?: readonly string[]; CapDrop?: readonly string[]; /** @@ -8063,12 +8072,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 +8100,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 +8191,7 @@ export type ContainerInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -8219,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/ @@ -8235,28 +8241,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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?: { /** @@ -8295,33 +8301,38 @@ export type ContainerInspectCommandOutput = { * @example [object Object] */ Ports?: Record< - string | number, - 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; - }[] + 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. * @@ -8427,13 +8438,13 @@ export type ContainerInspectCommandOutput = { */ MacAddress?: string; Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -8486,7 +8497,7 @@ export type ContainerInspectCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -8554,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 = { @@ -8652,7 +8661,7 @@ type ContainerUpdateJsonBody = { * @example gpu,nvidia,compute */ Capabilities?: readonly (readonly string[])[]; - Options?: Record; + Options?: Record; }[]; KernelMemoryTCP?: bigint; MemoryReservation?: bigint; @@ -8901,7 +8910,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 +9087,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -9115,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/ @@ -9131,28 +9137,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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. @@ -9229,10 +9235,7 @@ export type ImageInspectCommandOutput = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record< - string | number, - Record - >; + ExposedPorts?: Record> | null; /** * Attach standard streams to a TTY, including `stdin` if it is not closed. * @@ -9299,7 +9302,7 @@ export type ImageInspectCommandOutput = { * objects. * @example [object Object] */ - Volumes?: Record>; + Volumes?: Record>; /** * The working directory for commands to run in. * @example /public/ @@ -9331,28 +9334,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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. @@ -9363,7 +9366,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 @@ -9374,7 +9377,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 +9409,7 @@ export type ImageInspectCommandOutput = { * in use, and should be used for informational purposes only. * @example [object Object] */ - Data: Record; + Data: Record; }; RootFS?: { Type: string; @@ -9421,7 +9424,7 @@ export type ImageInspectCommandOutput = { * and omitted otherwise. * @example 2022-02-28T14:40:02.623929178Z */ - LastTagTime?: string; + LastTagTime?: string | null; }; }; export type InputImageInspectCommandResponse = @@ -9864,7 +9867,7 @@ export type SystemInfoCommandOutput = { */ InsecureRegistryCIDRs?: readonly string[]; IndexConfigs?: Record< - string | number, + string, { /** * Name of the registry, such as "docker.io". @@ -9898,7 +9901,7 @@ export type SystemInfoCommandOutput = { * @example true */ Official?: boolean; - } + } | null >; /** * List of registry URLs that act as a mirror for the official @@ -9906,7 +9909,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`). @@ -10000,7 +10003,7 @@ export type SystemInfoCommandOutput = { * @example [object Object] */ Runtimes?: Record< - string | number, + string, { /** * Name and, optional, path, of the OCI executable binary. @@ -10014,7 +10017,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; } >; /** @@ -10055,10 +10058,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 @@ -10100,7 +10105,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 @@ -10108,7 +10113,7 @@ export type SystemInfoCommandOutput = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -10148,7 +10153,7 @@ export type SystemInfoCommandOutput = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -10164,13 +10169,13 @@ export type SystemInfoCommandOutput = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -10191,7 +10196,7 @@ export type SystemInfoCommandOutput = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -10224,7 +10229,7 @@ export type SystemInfoCommandOutput = { * @example 24 */ SubnetSize?: number; - }; + } | null; }; /** * Indicates if live restore is enabled. @@ -10348,7 +10353,7 @@ export type SystemVersionCommandOutput = { * @example 19.03.12 */ Version: string; - Details?: Record; + Details?: Record | null; }[]; /** * The version of the daemon @@ -10444,7 +10449,7 @@ type ImageCommitJsonBody = { * `{"/": {}}` * @example [object Object] */ - ExposedPorts?: Record>; + ExposedPorts?: Record> | null; Tty?: boolean; OpenStdin?: boolean; StdinOnce?: boolean; @@ -10478,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/ @@ -10494,28 +10499,28 @@ 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] */ - Labels?: Record; + Labels?: Record; /** * 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 & @@ -10564,7 +10569,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 +10676,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 +10702,7 @@ export type SystemDataUsageCommandOutput = { }[]; SizeRw?: bigint; SizeRootFs?: bigint; - Labels?: Record; + Labels?: Record; State?: string; Status?: string; HostConfig?: { @@ -10705,13 +10710,13 @@ export type SystemDataUsageCommandOutput = { }; NetworkSettings?: { Networks?: Record< - string | number, + string, { IPAMConfig?: { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -10764,7 +10769,7 @@ export type SystemDataUsageCommandOutput = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; } >; }; @@ -10861,12 +10866,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 +10912,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 +10940,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 +10965,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 @@ -10983,7 +10988,7 @@ export type SystemDataUsageCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; BuildCache?: readonly { /** @@ -10997,12 +11002,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 @@ -11046,7 +11051,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; }[]; }; @@ -11073,7 +11078,7 @@ type ContainerExecJsonBody = { AttachStdin?: boolean; AttachStdout?: boolean; AttachStderr?: boolean; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; DetachKeys?: string; Tty?: boolean; Env?: readonly string[]; @@ -11096,7 +11101,7 @@ export type InputContainerExecCommandResponse = type ExecStartJsonBody = { Detach?: boolean; Tty?: boolean; - ConsoleSize?: readonly number[]; + ConsoleSize?: readonly number[] | null; }; export type ExecStartCommandParams = { id: string; @@ -11172,12 +11177,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 +11223,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 +11251,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 +11276,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 @@ -11294,7 +11299,7 @@ export type VolumeListCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }[]; /** * Warnings that occurred when fetching the list of volumes. @@ -11321,12 +11326,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 +11357,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 +11416,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 +11462,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 +11490,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 +11515,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 @@ -11533,7 +11538,7 @@ export type VolumeCreateCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }; export type InputVolumeCreateCommandResponse = UndefinedOnPartialDeep; @@ -11571,12 +11576,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 +11622,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 +11650,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 +11675,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 @@ -11693,7 +11698,7 @@ export type VolumeInspectCommandOutput = { * @default -1 */ RefCount: bigint; - }; + } | null; }; export type InputVolumeInspectCommandResponse = UndefinedOnPartialDeep; @@ -11726,14 +11731,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 +11832,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 +11872,7 @@ export type NetworkListCommandOutput = readonly { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -11880,24 +11885,26 @@ 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; - 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; - }[]; + 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; + }[] + | null; }[]; export type InputNetworkListCommandResponse = UndefinedOnPartialDeep; @@ -11955,13 +11962,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 +12002,7 @@ export type NetworkInspectCommandOutput = { * @example [object Object] */ Containers?: Record< - string | number, + string, { Name?: string; EndpointID?: string; @@ -12008,24 +12015,26 @@ 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; - 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; - }[]; + 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; + }[] + | null; }; export type InputNetworkInspectCommandResponse = UndefinedOnPartialDeep; @@ -12098,13 +12107,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 +12124,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; @@ -12137,7 +12146,7 @@ type NetworkConnectJsonBody = { IPv4Address?: string; IPv6Address?: string; LinkLocalIPs?: readonly string[]; - }; + } | null; Links?: readonly string[]; Aliases?: readonly string[]; /** @@ -12190,7 +12199,7 @@ type NetworkConnectJsonBody = { * are passed directly to the driver and are driver specific. * @example [object Object] */ - DriverOpts?: Record; + DriverOpts?: Record | null; }; }; export type NetworkConnectCommandParams = { @@ -12668,7 +12677,7 @@ export type NodeListCommandOutput = readonly { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12718,7 +12727,7 @@ export type NodeListCommandOutput = readonly { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -12762,7 +12771,7 @@ export type NodeListCommandOutput = readonly { * @example 10.0.0.46:2377 */ Addr?: string; - }; + } | null; }[]; export type InputNodeListCommandResponse = UndefinedOnPartialDeep; @@ -12793,7 +12802,7 @@ export type NodeInspectCommandOutput = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12843,7 +12852,7 @@ export type NodeInspectCommandOutput = { }; Engine?: { EngineVersion?: string; - Labels?: Record; + Labels?: Record; Plugins?: readonly { Type?: string; Name?: string; @@ -12887,7 +12896,7 @@ export type NodeInspectCommandOutput = { * @example 10.0.0.46:2377 */ Addr?: string; - }; + } | null; }; export type InputNodeInspectCommandResponse = UndefinedOnPartialDeep; @@ -12908,7 +12917,7 @@ type NodeUpdateJsonBody = { * @example my-node */ Name?: string; - Labels?: Record; + Labels?: Record; /** * Role of the node. * @enum worker,manager @@ -12961,7 +12970,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 @@ -12969,7 +12978,7 @@ export type SwarmInspectCommandOutput = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -13009,7 +13018,7 @@ export type SwarmInspectCommandOutput = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13025,13 +13034,13 @@ export type SwarmInspectCommandOutput = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -13052,7 +13061,7 @@ export type SwarmInspectCommandOutput = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13119,7 +13128,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 @@ -13127,7 +13136,7 @@ type SwarmInitJsonBody = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -13167,7 +13176,7 @@ type SwarmInitJsonBody = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13183,13 +13192,13 @@ type SwarmInitJsonBody = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -13210,7 +13219,7 @@ type SwarmInitJsonBody = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13249,7 +13258,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 @@ -13257,7 +13266,7 @@ type SwarmUpdateJsonBody = { * @example 10 */ TaskHistoryRetentionLimit?: bigint; - }; + } | null; Raft?: { /** * The number of log entries between snapshots. @@ -13297,7 +13306,7 @@ type SwarmUpdateJsonBody = { * @example 5000000000 */ HeartbeatPeriod?: bigint; - }; + } | null; CAConfig?: { /** * The duration node certificates are issued for. @@ -13313,13 +13322,13 @@ type SwarmUpdateJsonBody = { */ Protocol?: "cfssl"; URL?: string; - Options?: Record; + Options?: Record; CACert?: string; }[]; SigningCACert?: string; SigningCAKey?: string; ForceRotate?: number; - }; + } | null; EncryptionConfig?: { /** * If set, generate a key and use it to lock data stored on the @@ -13340,7 +13349,7 @@ type SwarmUpdateJsonBody = { * as key/value pairs. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -13372,7 +13381,7 @@ export type ServiceListCommandOutput = readonly { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -13386,7 +13395,7 @@ export type ServiceListCommandOutput = readonly { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -13476,10 +13485,10 @@ export type ServiceListCommandOutput = readonly { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -13519,7 +13528,7 @@ export type ServiceListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -13530,7 +13539,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 +13663,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 +13683,7 @@ export type ServiceListCommandOutput = readonly { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -13717,7 +13726,7 @@ export type ServiceListCommandOutput = readonly { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -13851,7 +13860,7 @@ export type ServiceCreateCommandHeader = { }; type ServiceCreateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -13865,7 +13874,7 @@ type ServiceCreateJsonBody = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -13955,10 +13964,10 @@ type ServiceCreateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -13998,7 +14007,7 @@ type ServiceCreateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14009,7 +14018,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 +14142,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 +14162,7 @@ type ServiceCreateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14196,7 +14205,7 @@ type ServiceCreateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -14230,7 +14239,7 @@ type ServiceCreateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceCreateCommandBody = ServiceCreateJsonBody; export type ServiceCreateCommandInput = ServiceCreateJsonBody; export type ServiceCreateCommandOutput = { @@ -14256,7 +14265,7 @@ export type ServiceInspectCommandOutput = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -14270,7 +14279,7 @@ export type ServiceInspectCommandOutput = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -14360,10 +14369,10 @@ export type ServiceInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -14403,7 +14412,7 @@ export type ServiceInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14414,7 +14423,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 +14547,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 +14567,7 @@ export type ServiceInspectCommandOutput = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -14601,7 +14610,7 @@ export type ServiceInspectCommandOutput = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -14744,7 +14753,7 @@ export type ServiceUpdateCommandHeader = { }; type ServiceUpdateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; TaskTemplate?: { PluginSpec?: { Name?: string; @@ -14758,7 +14767,7 @@ type ServiceUpdateJsonBody = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -14848,10 +14857,10 @@ type ServiceUpdateJsonBody = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -14891,7 +14900,7 @@ type ServiceUpdateJsonBody = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -14902,7 +14911,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 +15035,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 +15055,7 @@ type ServiceUpdateJsonBody = { MaxConcurrent?: bigint; TotalCompletions?: bigint; }; - GlobalJob?: Record; + GlobalJob?: Record; }; UpdateConfig?: { Parallelism?: bigint; @@ -15089,7 +15098,7 @@ type ServiceUpdateJsonBody = { Networks?: readonly { Target?: string; Aliases?: readonly string[]; - DriverOpts?: Record; + DriverOpts?: Record; }[]; EndpointSpec?: { /** @@ -15123,7 +15132,7 @@ type ServiceUpdateJsonBody = { PublishMode?: "ingress" | "host"; }[]; }; -} & Record; +} & Record; export type ServiceUpdateCommandParams = { id: string; }; @@ -15162,7 +15171,7 @@ export type TaskListCommandOutput = readonly { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -15176,7 +15185,7 @@ export type TaskListCommandOutput = readonly { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -15266,10 +15275,10 @@ export type TaskListCommandOutput = readonly { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -15309,7 +15318,7 @@ export type TaskListCommandOutput = readonly { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15320,7 +15329,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 +15453,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 +15538,7 @@ export type TaskInspectCommandOutput = { CreatedAt?: string; UpdatedAt?: string; Name?: string; - Labels?: Record; + Labels?: Record; Spec?: { PluginSpec?: { Name?: string; @@ -15543,7 +15552,7 @@ export type TaskInspectCommandOutput = { }; ContainerSpec?: { Image?: string; - Labels?: Record; + Labels?: Record; Command?: readonly string[]; Args?: readonly string[]; Hostname?: string; @@ -15633,10 +15642,10 @@ export type TaskInspectCommandOutput = { }; VolumeOptions?: { NoCopy?: boolean; - Labels?: Record; + Labels?: Record; DriverConfig?: { Name?: string; - Options?: Record; + Options?: Record; }; }; TmpfsOptions?: { @@ -15676,7 +15685,7 @@ export type TaskInspectCommandOutput = { GID?: string; Mode?: number; }; - Runtime?: Record; + Runtime?: Record; ConfigID?: string; ConfigName?: string; }[]; @@ -15687,7 +15696,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 +15820,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 +15923,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 +15944,7 @@ export type SecretListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -15947,7 +15956,7 @@ export type SecretListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }[]; @@ -15959,7 +15968,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 +15989,7 @@ type SecretCreateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -15992,9 +16001,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 +16028,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 +16049,7 @@ export type SecretInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -16052,7 +16061,7 @@ export type SecretInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -16071,7 +16080,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 +16101,7 @@ type SecretUpdateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; Templating?: { /** @@ -16104,7 +16113,7 @@ type SecretUpdateJsonBody = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; export type SecretUpdateCommandParams = { @@ -16127,7 +16136,7 @@ export type ConfigListCommandOutput = readonly { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16139,7 +16148,7 @@ export type ConfigListCommandOutput = readonly { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }[]; @@ -16147,7 +16156,7 @@ export type InputConfigListCommandResponse = UndefinedOnPartialDeep; type ConfigCreateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16159,9 +16168,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 +16191,7 @@ export type ConfigInspectCommandOutput = { UpdatedAt?: string; Spec?: { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16194,7 +16203,7 @@ export type ConfigInspectCommandOutput = { * Key/value map of driver-specific options. * @example [object Object] */ - Options?: Record; + Options?: Record; }; }; }; @@ -16209,7 +16218,7 @@ export type ConfigUpdateCommandQuery = { }; type ConfigUpdateJsonBody = { Name?: string; - Labels?: Record; + Labels?: Record; Data?: string; Templating?: { /** @@ -16221,7 +16230,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/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 a2bb01a..e6f86d9 100644 --- a/__tests__/fixtures/openai/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/openai/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", "commands.ts": "82d7434078d4f7ba525c36db35c4c33b", - "types.ts": "605fb801d1203d2e523cbcb63cb8d0e6", + "types.ts": "bc453b1a7fcd330909a23ae01be97f52", "main.ts": "5ba91c2efb44e3e5c5bd1e1a1b90bb51", - "valibot.ts": "9d670c8ddc0f9bb81a5dd1a80efd5eee", + "valibot.ts": "3be60d2491963c2904292438b7de247b", "hono.ts": "54130437a23164b228769eb3ec967e4e", "commands-validated.ts": "e4929484f6a64b784ff7b03327f58a3a", "enums.ts": "87a5ccd7e57cc937104b2d256e8d67b1" diff --git a/__tests__/fixtures/openai/types.ts b/__tests__/fixtures/openai/types.ts index 46ea6fa..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"; @@ -24,77 +24,11 @@ export type ChatCompletionRole = | "assistant" | "tool" | "function"; -export type ChatCompletionTokenLogprob = { - token: string; - logprob: number; - bytes: readonly number[]; - top_logprobs: readonly { - token: string; - logprob: number; - bytes: readonly number[]; - }[]; -}; -/** - * 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[]; - refusal: readonly ChatCompletionTokenLogprob[]; - }; - /** - * 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"; - 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"; - 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. */ -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 @@ -132,7 +66,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 @@ -141,7 +75,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 @@ -151,7 +85,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 @@ -189,7 +123,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 @@ -198,7 +132,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 @@ -231,7 +165,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`. @@ -239,7 +173,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 @@ -386,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 @@ -438,7 +372,7 @@ export type CreateFineTuningJobRequest = { */ n_epochs?: "auto" | number; }; - suffix?: string; + suffix?: string | null; /** * The ID of an uploaded file that contains validation data. * @@ -453,20 +387,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 @@ -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; - entity?: string; - tags?: readonly string[]; - }; -}; /** * The per-line training example of a fine-tuning input file for completions * models @@ -598,22 +517,8 @@ 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; + metadata?: Record | null; }; export type SubmitToolOutputsRunRequest = { tool_outputs: readonly { @@ -636,8 +541,8 @@ export type ModifyThreadRequest = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata?: Record; + } | null; + metadata?: Record | null; }; export type DeleteThreadResponse = { id: string; @@ -645,408 +550,93 @@ export type DeleteThreadResponse = { object: "thread.deleted"; }; export type ModifyMessageRequest = { - metadata?: Record; + metadata?: Record | null; }; export type DeleteMessageResponse = { id: string; 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; - }; -}; -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; - }; -}; -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; - }; - error?: { - code?: string; - message?: string; - }; -}; -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"; }; @@ -1476,49 +1066,173 @@ export type Batch = { data?: readonly { code?: string; message?: string; - param?: string; + param?: string | null; line?: number | null; }[]; }; input_file_id: string; completion_window: string; /** - * The current status of the batch. - * @enum validating,failed,in_progress,finalizing,completed,expired,cancelling,cancelled + * The current status of the batch. + * @enum validating,failed,in_progress,finalizing,completed,expired,cancelling,cancelled + */ + status: + | "validating" + | "failed" + | "in_progress" + | "finalizing" + | "completed" + | "expired" + | "cancelling" + | "cancelled"; + output_file_id?: string; + error_file_id?: string; + created_at: number; + in_progress_at?: number; + expires_at?: number; + finalizing_at?: number; + completed_at?: number; + failed_at?: number; + expired_at?: number; + cancelling_at?: number; + cancelled_at?: number; + request_counts?: { + total: number; + completed: number; + failed: number; + }; + 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 + )[]; + }; +}; +/** + * 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 */ - status: - | "validating" - | "failed" - | "in_progress" - | "finalizing" - | "completed" - | "expired" - | "cancelling" - | "cancelled"; - output_file_id?: string; - error_file_id?: string; - created_at: number; - in_progress_at?: number; - expires_at?: number; - finalizing_at?: number; - completed_at?: number; - failed_at?: number; - expired_at?: number; - cancelling_at?: number; - cancelled_at?: number; - request_counts?: { - total: number; - completed: number; - failed: number; + 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"; }; - metadata?: Record; -}; -export type ListBatchesResponse = { - data: readonly Batch[]; - first_id?: string; - last_id?: string; - has_more: boolean; - object: "list"; }; /** * 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; - message: string; - param: string; - 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 = { @@ -1591,57 +1398,127 @@ export type MessageObject = { | "run_cancelled" | "run_expired" | "run_failed"; - }; + } | null; completed_at: number | null; incomplete_at: number | null; /** * 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; - run_id: string; - attachments: readonly { - file_id?: string; - tools?: readonly (AssistantToolsCode | AssistantToolsFileSearchTypeOnly)[]; - }[]; - metadata: Record; + 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 = { /** @@ -1691,6 +1568,93 @@ export type RunStepCompletionUsage = { completion_tokens: number; 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 = { @@ -1701,6 +1665,7 @@ export type RunStepDetailsToolCallsObject = { type: "tool_calls"; tool_calls: readonly ( | RunStepDetailsToolCallsCodeObject + | RunStepDetailsToolCallsFileSearchObject | RunStepDetailsToolCallsFunctionObject )[]; }; @@ -1749,12 +1714,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`. @@ -1801,10 +1766,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` @@ -1921,6 +1883,73 @@ export type RunCompletionUsage = { completion_tokens: number; 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 = { @@ -1972,7 +2001,7 @@ export type RunObject = { submit_tool_outputs: { tool_calls: readonly RunToolCallObject[]; }; - }; + } | null; last_error: { /** * One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`. @@ -1980,7 +2009,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; @@ -1993,7 +2022,7 @@ export type RunObject = { * @enum max_completion_tokens,max_prompt_tokens */ reason?: "max_completion_tokens" | "max_prompt_tokens"; - }; + } | null; model: string; instructions: string; /** @@ -2001,8 +2030,12 @@ export type RunObject = { * for this run. * @default */ - tools: readonly AssistantToolsCode[]; - metadata: Record; + tools: readonly ( + | AssistantToolsCode + | AssistantToolsFileSearch + | AssistantToolsFunction + )[]; + 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.). @@ -2133,8 +2166,8 @@ export type ThreadObject = { file_search?: { vector_store_ids?: readonly string[]; }; - }; - metadata: Record; + } | null; + metadata: Record | null; }; export type ThreadStreamEvent = { event: "thread.created"; @@ -2260,7 +2293,7 @@ export type VectorStoreFileObject = { */ code: "server_error" | "unsupported_file" | "invalid_file"; message: string; - }; + } | null; chunking_strategy?: | StaticChunkingStrategyResponseParam | OtherChunkingStrategyResponseParam; @@ -2322,7 +2355,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; @@ -2332,10 +2365,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[]; @@ -2345,44 +2378,7 @@ export type CreateVectorStoreRequest = { chunking_strategy?: | AutoChunkingStrategyRequestParam | StaticChunkingStrategyRequestParam; - metadata?: Record; -}; -/** 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[]; - }; + metadata?: Record | null; }; export type ListRunStepsResponse = { object: string; @@ -2398,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[]; @@ -2422,12 +2427,17 @@ export type CreateMessageRequest = { | MessageContentImageFileObject | 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[]; @@ -2442,8 +2452,8 @@ export type CreateThreadRequest = { file_ids?: readonly string[]; }; file_search?: unknown; - }; - metadata?: Record; + } | null; + metadata?: Record | null; }; export type CreateThreadAndRunRequest = { assistant_id: string; @@ -2481,8 +2491,14 @@ export type CreateThreadAndRunRequest = { | "gpt-3.5-turbo-16k-0613", string > | null; - instructions?: string; - tools?: readonly AssistantToolsCode[]; + instructions?: string | null; + tools?: + | readonly ( + | AssistantToolsCode + | AssistantToolsFileSearch + | AssistantToolsFunction + )[] + | null; tool_resources?: { code_interpreter?: { /** @@ -2496,8 +2512,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 @@ -2610,11 +2626,17 @@ 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 + | AssistantToolsFileSearch + | AssistantToolsFunction + )[] + | 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 @@ -2685,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; @@ -2761,10 +2716,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`, @@ -2789,8 +2744,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 @@ -2843,9 +2798,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`, @@ -2870,8 +2825,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 @@ -2949,9 +2904,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`, @@ -2974,8 +2929,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 @@ -3040,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 @@ -3056,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; @@ -3093,7 +3196,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 = { @@ -3253,8 +3356,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 */ @@ -3279,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 @@ -3293,9 +3493,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: { /** @@ -3331,8 +3531,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; }; @@ -3350,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. @@ -3367,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; @@ -3406,12 +3627,12 @@ 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[]; - refusal: readonly ChatCompletionTokenLogprob[]; - }; + content: readonly ChatCompletionTokenLogprob[] | null; + refusal: readonly ChatCompletionTokenLogprob[] | null; + } | null; }[]; created: number; model: string; @@ -3421,7 +3642,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`. @@ -3473,124 +3694,7 @@ export type ChatCompletionToolChoiceOption = /** Options for streaming response. Only set this when you set `stream: true`. */ export type ChatCompletionStreamOptions = { include_usage?: boolean; -}; -export type ChatCompletionRequestFunctionMessage = { - /** - * The role of the messages author, in this case `function`. - * @enum function - */ - role: "function"; - content: string; - 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; - /** - * 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; - }; -}; -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; -}; +} | null; export type ChatCompletionRequestMessage = | ChatCompletionRequestSystemMessage | ChatCompletionRequestUserMessage @@ -3638,7 +3742,7 @@ export type CreateChatCompletionRequest = { string >; frequency_penalty?: number | null; - logit_bias?: Record; + logit_bias?: Record | null; logprobs?: boolean | null; top_logprobs?: number | null; /** @@ -3687,8 +3791,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; @@ -3765,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; - /** - * 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; -}; -/** A chat completion message generated by the model. */ -export type ChatCompletionResponseMessage = { - content: string; - refusal: string; - /** 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 @@ -3850,8 +3892,8 @@ export type CreateCompletionResponse = { text_offset?: readonly number[]; token_logprobs?: readonly number[]; tokens?: readonly string[]; - top_logprobs?: readonly Record[]; - }; + top_logprobs?: readonly Record[]; + } | null; text: string; }[]; created: number; @@ -3900,7 +3942,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 @@ -3936,7 +3978,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 @@ -4482,7 +4524,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/openai/valibot.ts b/__tests__/fixtures/openai/valibot.ts index a68fffc..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(), @@ -27,432 +38,128 @@ 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(), + jsonValueSchema, +); +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. - */ - 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). + * 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())), }); @@ -1278,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({ /** @@ -1815,95 +1525,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 +1559,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 @@ -1949,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({ /** @@ -1958,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({ /** @@ -2049,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({ /** @@ -2094,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(), @@ -2113,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({ /** @@ -2122,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(), @@ -2134,1464 +1751,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(), jsonValueSchema)), + }), + ), + ), + /** + * 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(), jsonValueSchema)), + }), + ), + ), + /** + * 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(), /** @@ -4052,125 +2709,499 @@ export const inviteListResponseSchema = v.looseObject({ /** The service account that performed the audit logged action. */ export const inputAuditLogActorServiceAccountSchema = v.looseObject({ /** - * The service account id. + * The service account id. + */ + id: v.optional(v.string()), +}); +export const auditLogActorServiceAccountSchema = v.looseObject({ + /** + * 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.optional(v.string()), -}); -export const auditLogActorServiceAccountSchema = v.looseObject({ + "invite.accepted": v.optional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.optional(v.string()), + }), + ), /** - * The service account id. + * 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.deleted": 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()), + "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 email. + * The details for events with this `type`. */ - email: v.optional(v.string()), -}); -export const auditLogActorUserSchema = v.looseObject({ + "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 id. + * The details for events with this `type`. */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), + "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 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({ + "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 tracking id of the API key. + * The details for events with this `type`. */ - id: v.optional(v.string()), + "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 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.archived": v.optional( + v.looseObject({ + /** + * The project ID. + */ + id: 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())), + "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 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.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.optional(v.string()), -}); -export const auditLogActorSessionSchema = v.looseObject({ - user: v.exactOptional(auditLogActorUserSchema), + "service_account.deleted": v.optional( + v.looseObject({ + /** + * The service account ID. + */ + id: 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({ + "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.optional(v.picklist(["session", "api_key"])), - session: v.optional(inputAuditLogActorSessionSchema), - api_key: v.optional(inputAuditLogActorApiKeySchema), -}); -export const auditLogActorSchema = v.looseObject({ + "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 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.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 +3210,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 +3248,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 +3270,184 @@ 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.exactOptional( + v.looseObject({ + /** + * The ID of the invite. + */ + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The payload used to create the invite. + */ + 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())), + }), + ), + }), + ), + /** + * 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())), + }), + ), }), ), /** * The details for events with this `type`. */ - "invite.sent": 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 create the invite. + * The payload used to update the project. */ - data: v.optional( + changes_requested: v.exactOptional( 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`. + * The title of the project as seen on the dashboard. */ - role: v.optional(v.string()), + title: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), }), @@ -4276,95 +3455,87 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "invite.accepted": 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`. */ - "invite.deleted": v.optional( + "service_account.created": v.exactOptional( v.looseObject({ /** - * The ID of the invite. + * The service account ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The payload used to create the service account. + */ + 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`. */ - "login.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`. */ - "logout.failed": v.optional( + "service_account.deleted": v.exactOptional( v.looseObject({ /** - * The error code of the failure. - */ - error_code: v.optional(v.string()), - /** - * The error message of the failure. + * The service account ID. */ - error_message: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), /** * The details for events with this `type`. */ - "organization.updated": v.optional( + "user.added": v.exactOptional( v.looseObject({ /** - * The organization ID. + * The user ID. */ - id: v.optional(v.string()), + id: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The payload used to update the organization settings. + * The payload used to add the user to the project. */ - changes_requested: v.optional( + data: v.exactOptional( v.looseObject({ /** - * The organization title. - */ - title: v.optional(v.string()), - /** - * The organization description. - */ - description: v.optional(v.string()), - /** - * The organization name. + * The role of the user. Is either `owner` or `member`. */ - 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()), - }), - ), + role: v.exactOptional(v.pipe(v.string(), v.trim())), }), ), }), @@ -4372,25 +3543,21 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "project.created": 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 create the project. + * The payload used to update the user. */ - data: v.optional( + changes_requested: 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,796 +3565,1166 @@ export const inputAuditLogSchema = v.looseObject({ /** * The details for events with this `type`. */ - "project.updated": 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 object type, which is always `batch`. + */ + object: v.picklist(["batch"]), + /** + * The OpenAI API endpoint used by the batch. + */ + endpoint: v.string(), + errors: v.optional( + v.looseObject({ /** - * The payload used to update the project. + * The object type, which is always `list`. */ - changes_requested: v.optional( - v.looseObject({ - /** - * The title of the project as seen on the dashboard. - */ - title: v.optional(v.string()), - }), + 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()))), + }), + ), ), }), ), /** - * 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. */ - "project.archived": v.optional( + request_counts: v.optional( v.looseObject({ /** - * The project ID. + * Total number of requests in the batch. */ - id: v.optional(v.string()), - }), - ), - /** - * The details for events with this `type`. - */ - "service_account.created": v.optional( - v.looseObject({ + total: v.pipe(v.number(), v.integer()), /** - * The service account ID. + * Number of requests that have been completed successfully. */ - id: v.optional(v.string()), + completed: v.pipe(v.number(), v.integer()), /** - * The payload used to create the service account. + * Number of requests that have failed. */ - data: v.optional( - v.looseObject({ - /** - * The role of the service account. Is either `owner` or `member`. - */ - role: 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. */ - "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()), - }), - ), - }), - ), + metadata: v.optional(v.nullable(v.record(v.string(), jsonValueSchema))), +}); +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`. */ - "service_account.deleted": v.optional( - v.looseObject({ - /** - * The service account ID. - */ - id: v.optional(v.string()), - }), - ), + object: v.picklist(["batch"]), /** - * The details for events with this `type`. + * The OpenAI API endpoint used by the batch. */ - "user.added": v.optional( + endpoint: v.pipe(v.string(), v.trim()), + errors: v.exactOptional( v.looseObject({ /** - * The user ID. - */ - id: v.optional(v.string()), - /** - * The payload used to add the user to the project. + * The object type, which is always `list`. */ - data: 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.updated": v.optional( + 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", + ]), + /** + * The ID of the file containing the outputs of successfully executed + * requests. + */ + output_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + /** + * The ID of the file containing the outputs of requests with errors. + */ + 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 project ID. + * Total number of requests in the batch. */ - id: v.optional(v.string()), + total: v.pipe(v.number(), v.integer()), /** - * The payload used to update the user. + * Number of requests that have been completed successfully. */ - 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({ + completed: v.pipe(v.number(), v.integer()), /** - * The user ID. + * Number of requests that have failed. */ - id: v.optional(v.string()), + failed: v.pipe(v.number(), v.integer()), }), ), -}); -export const auditLogSchema = v.looseObject({ /** - * The ID of this log. + * 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. */ - id: v.pipe(v.string(), v.trim()), - type: auditLogEventTypeSchema, + metadata: v.exactOptional(v.nullable(v.record(v.string(), jsonValueSchema))), +}); +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 Unix timestamp (in seconds) of the event. + * The index of the content part in the message. */ - effective_at: v.pipe(v.number(), v.integer()), + index: v.pipe(v.number(), v.integer()), /** - * The project that the action was scoped to. Absent for actions not scoped to - * projects. + * Always `image_url`. */ - project: v.exactOptional( + type: v.picklist(["image_url"]), + image_url: v.optional( v.looseObject({ /** - * The project ID. + * 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 project title. + * Specifies the detail level of the image. `low` uses fewer tokens, you can + * opt in to high resolution using `high`. */ - name: v.exactOptional(v.pipe(v.string(), v.trim())), + detail: v.optional(v.picklist(["auto", "low", "high"])), }), ), - actor: auditLogActorSchema, +}); +export const messageDeltaContentImageUrlObjectSchema = v.looseObject({ /** - * The details for events with this `type`. + * The index of the content part in the message. */ - "api_key.created": v.exactOptional( - v.looseObject({ - /** - * The tracking ID of the API key. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to create the API key. - */ - 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()))), - }), - ), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `image_url`. */ - "api_key.updated": v.exactOptional( + type: v.picklist(["image_url"]), + image_url: v.exactOptional( 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.exactOptional(v.pipe(v.string(), v.trim())), /** - * 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.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. */ - "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 `refusal`. */ - "invite.sent": v.exactOptional( - v.looseObject({ - /** - * The ID of the invite. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to create the invite. - */ - 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())), - }), - ), - }), - ), + 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. */ - "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()), + /** + * 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. */ - "invite.deleted": 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 `text`. */ - "login.failed": v.exactOptional( + type: v.picklist(["text"]), + text: v.optional( v.looseObject({ /** - * The error code of the failure. - */ - error_code: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The error message of the failure. + * The data that makes up the text. */ - error_message: 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. */ - "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.exactOptional( 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.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.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())), - }), - ), - }), - ), + index: v.pipe(v.number(), v.integer()), /** - * The details for events with this `type`. + * Always `image_file`. */ - "project.updated": v.exactOptional( + 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 details for events with this `type`. + * The identifier of the message, which can be referenced in API endpoints. */ - "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())), - }), - ), - }), - ), + id: v.string(), /** - * The details for events with this `type`. + * The object type, which is always `thread.message.delta`. */ - "service_account.deleted": v.exactOptional( - v.looseObject({ - /** - * The service account ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + 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 details for events with this `type`. + * The identifier of the message, which can be referenced in API endpoints. */ - "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())), - }), - ), - }), - ), + id: v.pipe(v.string(), v.trim()), /** - * The details for events with this `type`. + * The object type, which is always `thread.message.delta`. */ - "user.updated": v.exactOptional( - v.looseObject({ - /** - * The project ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - /** - * The payload used to update the user. - */ - 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())), - }), - ), - }), - ), + object: v.picklist(["thread.message.delta"]), /** - * The details for events with this `type`. + * The delta containing the fields that have changed on the Message. */ - "user.deleted": v.exactOptional( - v.looseObject({ - /** - * The user ID. - */ - id: v.exactOptional(v.pipe(v.string(), v.trim())), - }), - ), + 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 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 inputAssistantToolsFileSearchTypeOnlySchema = v.looseObject({ + /** + * The type of tool being defined: `file_search` + */ + type: v.picklist(["file_search"]), }); -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 assistantToolsFileSearchTypeOnlySchema = + inputAssistantToolsFileSearchTypeOnlySchema; +export const inputAssistantToolsCodeSchema = v.looseObject({ + /** + * The type of tool being defined: `code_interpreter` + */ + type: v.picklist(["code_interpreter"]), }); -export const inputBatchSchema = v.looseObject({ - id: v.string(), +export const assistantToolsCodeSchema = inputAssistantToolsCodeSchema; +/** + * The refusal content generated by the assistant. + * @title Refusal + */ +export const inputMessageContentRefusalObjectSchema = v.looseObject({ /** - * The object type, which is always `batch`. + * Always `refusal`. */ - object: v.picklist(["batch"]), + type: v.picklist(["refusal"]), + refusal: v.string(), +}); +export const messageContentRefusalObjectSchema = v.looseObject({ /** - * The OpenAI API endpoint used by the batch. + * Always `refusal`. */ - endpoint: v.string(), - errors: v.optional( - 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 object type, which is always `list`. + * The ID of the file that was generated. */ - 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()))), - }), - ), - ), + file_id: v.string(), }), - ), - /** - * The ID of the input file for the batch. - */ - input_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 time frame within which the batch should be processed. + * Always `file_path`. */ - completion_window: v.string(), + type: v.picklist(["file_path"]), /** - * The current status of the batch. + * The text in the message content that needs to be replaced. */ - status: v.picklist([ - "validating", - "failed", - "in_progress", - "finalizing", - "completed", - "expired", - "cancelling", - "cancelled", - ]), + 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 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)), + }); +/** + * The text content that is part of a message. + * @title Text + */ +export const inputMessageContentTextObjectSchema = v.looseObject({ /** - * The ID of the file containing the outputs of successfully executed - * requests. + * Always `text`. */ - output_file_id: v.optional(v.string()), + 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 messageContentTextObjectSchema = v.looseObject({ /** - * The ID of the file containing the outputs of requests with errors. + * Always `text`. */ - error_file_id: v.optional(v.string()), + 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 Unix timestamp (in seconds) for when the batch was created. + * The type of the content part. */ - created_at: 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 Unix timestamp (in seconds) for when the batch started processing. + * The type of the content part. */ - in_progress_at: v.optional(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.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 Unix timestamp (in seconds) for when the batch will expire. + * Always `image_file`. */ - expires_at: v.optional(v.pipe(v.number(), v.integer())), + 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 Unix timestamp (in seconds) for when the batch started finalizing. + * Always `image_file`. */ - finalizing_at: v.optional(v.pipe(v.number(), v.integer())), + 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 Unix timestamp (in seconds) for when the batch was completed. + * The identifier, which can be referenced in API endpoints. */ - completed_at: v.optional(v.pipe(v.number(), v.integer())), + id: v.string(), /** - * The Unix timestamp (in seconds) for when the batch failed. + * The object type, which is always `thread.message`. */ - failed_at: v.optional(v.pipe(v.number(), v.integer())), + object: v.picklist(["thread.message"]), /** - * The Unix timestamp (in seconds) for when the batch expired. + * The Unix timestamp (in seconds) for when the message was created. */ - expired_at: v.optional(v.pipe(v.number(), v.integer())), + created_at: v.pipe(v.number(), v.integer()), /** - * The Unix timestamp (in seconds) for when the batch started cancelling. + * The [thread](/docs/api-reference/threads) ID that this message belongs to. */ - cancelling_at: v.optional(v.pipe(v.number(), v.integer())), + thread_id: v.string(), /** - * The Unix timestamp (in seconds) for when the batch was cancelled. + * The status of the message, which can be either `in_progress`, `incomplete`, + * or `completed`. */ - cancelled_at: v.optional(v.pipe(v.number(), v.integer())), + status: v.picklist(["in_progress", "incomplete", "completed"]), /** - * The request counts for different statuses within the batch. + * On an incomplete message, details about why the message is incomplete. */ - request_counts: v.optional( + incomplete_details: v.nullable( 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. + * The reason the message is incomplete. */ - failed: v.pipe(v.number(), v.integer()), + reason: v.picklist([ + "content_filter", + "max_tokens", + "run_cancelled", + "run_expired", + "run_failed", + ]), }), ), /** - * 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 Unix timestamp (in seconds) for when the message was completed. */ - metadata: v.optional(v.nullable(v.record(v.string(), v.unknown()))), -}); -export const batchSchema = v.looseObject({ - id: v.pipe(v.string(), v.trim()), + completed_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The object type, which is always `batch`. + * The Unix timestamp (in seconds) for when the message was marked as + * incomplete. */ - object: v.picklist(["batch"]), + incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), /** - * The OpenAI API endpoint used by the batch. + * The entity that produced the message. One of `user` or `assistant`. */ - 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()))), - }), - ), - ), - }), + 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, + ]), ), /** - * The ID of the input file for the batch. + * If applicable, the ID of the [assistant](/docs/api-reference/assistants) + * that authored this message. */ - input_file_id: v.pipe(v.string(), v.trim()), + assistant_id: v.nullable(v.string()), /** - * The time frame within which the batch should be processed. + * 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. */ - completion_window: v.pipe(v.string(), v.trim()), + run_id: v.nullable(v.string()), /** - * The current status of the batch. + * A list of files attached to the message, and the tools they were added to. */ - status: v.picklist([ - "validating", - "failed", - "in_progress", - "finalizing", - "completed", - "expired", - "cancelling", - "cancelled", - ]), + 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, + ]), + ), + ), + }), + ), + ), /** - * The ID of the file containing the outputs of successfully executed - * requests. + * 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. */ - output_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + metadata: v.nullable(v.record(v.string(), jsonValueSchema)), +}); +export const messageObjectSchema = v.looseObject({ /** - * The ID of the file containing the outputs of requests with errors. + * The identifier, which can be referenced in API endpoints. */ - error_file_id: v.exactOptional(v.pipe(v.string(), v.trim())), + id: v.pipe(v.string(), v.trim()), /** - * The Unix timestamp (in seconds) for when the batch was created. + * 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()), /** - * 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 +4732,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(), jsonValueSchema)), }); -/** - * 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"]), /** - * The entity that produced the message. One of `user` or `assistant`. + * For now, this is always going to be an empty object. */ - role: v.optional(v.picklist(["user", "assistant"])), + file_search: v.record(v.string(), jsonValueSchema), + }); +export const runStepDeltaStepDetailsToolCallsFileSearchObjectSchema = + v.looseObject({ /** - * The content of the message in array of text and/or images. + * The index of the tool call in the tool calls array. */ - content: v.optional( - v.array( - v.union([ - inputMessageDeltaContentImageFileObjectSchema, - inputMessageDeltaContentTextObjectSchema, - inputMessageDeltaContentRefusalObjectSchema, - inputMessageDeltaContentImageUrlObjectSchema, - ]), - ), + 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(), jsonValueSchema), + }); +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`. + * Always `tool_calls`. */ - role: v.picklist(["user", "assistant"]), + type: v.picklist(["tool_calls"]), /** - * The content of the message in array of text and/or images. + * 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`. */ - content: v.array( - v.union([ - inputMessageContentImageFileObjectSchema, - inputMessageContentImageUrlObjectSchema, - inputMessageContentTextObjectSchema, - inputMessageContentRefusalObjectSchema, - ]), + tool_calls: v.optional( + v.array( + v.union([ + inputRunStepDeltaStepDetailsToolCallsCodeObjectSchema, + inputRunStepDeltaStepDetailsToolCallsFileSearchObjectSchema, + inputRunStepDeltaStepDetailsToolCallsFunctionObjectSchema, + ]), + ), ), +}); +export const runStepDeltaStepDetailsToolCallsObjectSchema = v.looseObject({ /** - * If applicable, the ID of the [assistant](/docs/api-reference/assistants) - * that authored this message. - */ - assistant_id: v.nullable(v.string()), - /** - * 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. + * Always `tool_calls`. */ - run_id: v.nullable(v.string()), + type: v.picklist(["tool_calls"]), /** - * A list of files attached to the message, and the tools they were added to. + * 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`. */ - attachments: v.nullable( + 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, ]), - }), - ), - /** - * The Unix timestamp (in seconds) for when the message was completed. - */ - completed_at: v.nullable(v.pipe(v.number(), v.integer())), + ), + }), +}); +export const runStepDeltaObjectSchema = v.looseObject({ /** - * The Unix timestamp (in seconds) for when the message was marked as - * incomplete. + * The identifier of the run step, which can be referenced in API endpoints. */ - incomplete_at: v.nullable(v.pipe(v.number(), v.integer())), + id: v.pipe(v.string(), v.trim()), /** - * The entity that produced the message. One of `user` or `assistant`. + * The object type, which is always `thread.run.step.delta`. */ - role: v.picklist(["user", "assistant"]), + object: v.picklist(["thread.run.step.delta"]), /** - * The content of the message in array of text and/or images. + * The delta containing the fields that have changed on the run step. */ - content: v.array( - v.union([ - messageContentImageFileObjectSchema, - messageContentImageUrlObjectSchema, - messageContentTextObjectSchema, - messageContentRefusalObjectSchema, - ]), - ), + 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({ /** - * If applicable, the ID of the [assistant](/docs/api-reference/assistants) - * that authored this message. + * The ID of the tool call object. */ - assistant_id: v.nullable(v.pipe(v.string(), v.trim())), + id: v.string(), /** - * 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 type of tool call. This is always going to be `function` for this type + * of tool call. */ - run_id: v.nullable(v.pipe(v.string(), v.trim())), + type: v.picklist(["function"]), /** - * A list of files attached to the message, and the tools they were added to. + * The definition of the function that was called. */ - 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, - ]), - ), - ), - }), - ), - ), + 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({ /** - * 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 ID of the tool call object. */ - 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, + 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())), }), +}); +/** + * 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 +5512,7 @@ export const inputRunStepDetailsToolCallsObjectSchema = v.looseObject({ tool_calls: v.array( v.union([ inputRunStepDetailsToolCallsCodeObjectSchema, - v.unknown(), + inputRunStepDetailsToolCallsFileSearchObjectSchema, inputRunStepDetailsToolCallsFunctionObjectSchema, ]), ), @@ -5844,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({ @@ -5936,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([ @@ -5973,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; @@ -6155,44 +5951,194 @@ export const inputTruncationObjectSchema = v.looseObject({ v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1))), ), }); -export const truncationObjectSchema = v.looseObject({ +export const truncationObjectSchema = v.looseObject({ + /** + * The truncation strategy to use for the thread. The default is `auto`. If + * set to `last_messages`, the thread will be truncated to the n most recent + * messages in the thread. When set to `auto`, messages in the middle of the + * thread will be dropped to fit the context length of the model, + * `max_prompt_tokens`. + */ + type: v.picklist(["auto", "last_messages"]), + /** + * The number of most recent messages from the thread when constructing the + * context for the run. + */ + last_messages: v.exactOptional( + 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; +/** + * 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(), + jsonValueSchema, +); +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 truncation strategy to use for the thread. The default is `auto`. If - * set to `last_messages`, the thread will be truncated to the n most recent - * messages in the thread. When set to `auto`, messages in the middle of the - * thread will be dropped to fit the context length of the model, - * `max_prompt_tokens`. + * The type of tool being defined: `file_search` */ - type: v.picklist(["auto", "last_messages"]), + type: v.picklist(["file_search"]), /** - * The number of most recent messages from the thread when constructing the - * context for the run. + * Overrides for the file search tool. */ - last_messages: v.exactOptional( - v.nullable(v.pipe(v.number(), v.integer(), v.minValue(1))), + 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), + }), ), }); -/** - * 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; /** Tool call objects */ export const inputRunToolCallObjectSchema = v.looseObject({ /** @@ -6380,7 +6326,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), ), /** @@ -6389,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. @@ -6548,7 +6500,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), ), /** @@ -6557,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. @@ -6684,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({ /** @@ -6739,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"]), @@ -7109,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({ /** @@ -7175,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(), @@ -7203,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({ /** @@ -7214,212 +7172,70 @@ export const updateVectorStoreRequestSchema = v.strictObject({ /** * 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({ + * 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(), jsonValueSchema))), +}); +export const inputCreateVectorStoreRequestSchema = v.strictObject({ /** - * The ID of the tool call object. + * 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. */ - id: v.pipe(v.string(), v.trim()), + file_ids: v.optional(v.pipe(v.array(v.string()), v.maxLength(500))), /** - * The type of tool call. This is always going to be `file_search` for this - * type of tool call. + * The name of the vector store. */ - type: v.picklist(["file_search"]), + name: v.optional(v.string()), + expires_after: v.optional(inputVectorStoreExpirationAfterSchema), /** - * For now, this is always going to be an empty object. + * 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. */ - file_search: v.looseObject({ - ranking_options: v.exactOptional( - runStepDetailsToolCallsFileSearchRankingOptionsObjectSchema, - ), - /** - * The results of the file search. - */ - results: v.exactOptional( - v.array(runStepDetailsToolCallsFileSearchResultObjectSchema), - ), - }), + 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(), jsonValueSchema))), +}); +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(), jsonValueSchema))), }); export const inputListRunStepsResponseSchema = v.looseObject({ object: v.string(), @@ -7449,6 +7265,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), @@ -7519,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({ /** @@ -7577,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({ /** @@ -7606,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), ]), ), }), @@ -7619,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({ /** @@ -7650,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), ]), ), }), @@ -7663,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({ /** @@ -7724,7 +7564,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), ), @@ -7770,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 @@ -7879,7 +7723,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), ), ), @@ -7926,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 @@ -8062,7 +7912,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), ), @@ -8074,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 @@ -8197,7 +8051,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,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 @@ -8231,180 +8091,33 @@ export const createRunRequestSchema = v.strictObject({ /** * 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, -}); -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({ + * `data: [DONE]` message. + */ + stream: v.exactOptional(v.nullable(v.boolean())), /** - * The type of tool being defined: `file_search` + * 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. */ - type: v.picklist(["file_search"]), + max_prompt_tokens: v.exactOptional( + v.nullable(v.pipe(v.number(), v.integer(), v.minValue(256))), + ), /** - * Overrides for the file search tool. + * 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. */ - 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), - }), + 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. @@ -8456,7 +8169,235 @@ export const inputAssistantObjectSchema = v.looseObject({ inputAssistantToolsFunctionSchema, ]), ), - v.maxLength(128), + 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(), 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 + * more focused and deterministic. + */ + temperature: v.optional( + 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.optional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), + ), + 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"]), + /** + * 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.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()), + /** + * 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))), + /** + * 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, + ]), + ), + 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.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)), + ), + }), + ), + }), + ), + ), + /** + * 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(), 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 + * 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 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.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.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.optional( + 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 @@ -8470,9 +8411,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 +8421,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 +8439,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(), 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 @@ -8520,53 +8461,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 +8517,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 +8529,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 +8547,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(), 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 @@ -8632,28 +8569,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,25 +8649,149 @@ 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.union([ + v.record(v.string(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), + ]), + ), + }), + ), + ), + /** + * 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(), 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 + * more focused and deterministic. + */ + temperature: v.optional( + 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.optional( + v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), + ), + response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), +}); +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.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. + */ + 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.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.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.exactOptional( + 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({ /** - * 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. + * 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. */ - vector_store_ids: v.optional( - v.pipe(v.array(v.string()), v.maxLength(1)), + 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(), jsonValueSchema), + v.record(v.string(), jsonValueSchema), + ]), + ), }), ), ), @@ -8726,13 +8801,13 @@ 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.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 * more focused and deterministic. */ - temperature: v.optional( + temperature: v.exactOptional( v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(2))), ), /** @@ -8743,418 +8818,487 @@ export const inputModifyAssistantRequestSchema = v.strictObject({ * * We generally recommend altering this or temperature but not both. */ - top_p: v.optional( + top_p: v.exactOptional( v.nullable(v.pipe(v.number(), v.minValue(0), v.maxValue(1))), ), - response_format: v.optional(inputAssistantsApiResponseFormatOptionSchema), + response_format: v.exactOptional(assistantsApiResponseFormatOptionSchema), }); -export const modifyAssistantRequestSchema = v.strictObject({ +export const inputChatCompletionFunctionsSchema = 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. + * A description of what the function does, used by the model to choose when + * and how to call the function. */ - model: v.exactOptional(v.pipe(v.string(), v.trim())), + description: v.optional(v.string()), /** - * The name of the assistant. The maximum length is 256 characters. + * 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.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256))), - ), + name: v.string(), + parameters: v.optional(inputFunctionParametersSchema), +}); +export const chatCompletionFunctionsSchema = v.looseObject({ /** - * The description of the assistant. The maximum length is 512 characters. + * A description of what the function does, used by the model to choose when + * and how to call the function. */ - description: v.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(512))), - ), + description: v.exactOptional(v.pipe(v.string(), v.trim())), /** - * The system instructions that the assistant uses. The maximum length is - * 256,000 characters. + * 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. */ - instructions: v.exactOptional( - v.nullable(v.pipe(v.string(), v.trim(), v.maxLength(256_000))), - ), + name: v.pipe(v.string(), v.trim()), + parameters: v.exactOptional(functionParametersSchema), +}); +export const inputChatCompletionToolSchema = 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 type of the tool. Currently, only `function` is supported. */ - tools: v.exactOptional( + 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( - v.union([ - assistantToolsCodeSchema, - assistantToolsFileSearchSchema, - assistantToolsFunctionSchema, - ]), - ), - v.maxLength(128), + v.array(inputChatCompletionRequestToolMessageContentPartSchema), + v.minLength(1), ), - ), + ]), /** - * 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 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. */ - tool_resources: v.exactOptional( + content: v.optional( v.nullable( - v.looseObject({ - 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. - */ - file_ids: v.exactOptional( - v.pipe(v.array(v.pipe(v.string(), v.trim())), v.maxLength(20)), - ), - }), - ), - 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.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 +9320,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 +10149,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 +10640,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 +10683,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 +11915,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 2717dd8..bb3e0e4 100644 --- a/__tests__/fixtures/petstore/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/petstore/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", "commands.ts": "69c6a9f2924568fc08fd489508c9df34", "types.ts": "ea65c3e67352d4e22b97af80085727b4", "main.ts": "64edb526dcbcbd345e631ccff959f11d", - "valibot.ts": "2383058357d21e704546455f4e073d67", + "valibot.ts": "a754e3506dd239dc9fa4973e39198cbd", "hono.ts": "be7061d9a002b7d6f42bbdfc53727ec7", "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 b1d5c83..819b6d4 100644 --- a/__tests__/fixtures/test1/.openapi-codegen-manifest.json +++ b/__tests__/fixtures/test1/.openapi-codegen-manifest.json @@ -1,9 +1,9 @@ { - "#generator": "25c3995293e37099b578d8abd616d258", + "#generator": "cf9ab7bd8a80e3339d9237d5dee0deb3", "commands.ts": "19fd590dfc5cc8616a70dcf78326c027", - "types.ts": "2fa39af3c41c92051312d9ba51ee2a5a", + "types.ts": "2f7230842affe9bd6e7f727702f0c581", "main.ts": "1e2091a697e1aa9d8b770d777c172bf8", - "valibot.ts": "d7e166b84040d92d2eefc8b2f986e5a1", + "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 fab8006..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/__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-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 62e738a..6ec1c09 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(); @@ -107,7 +118,7 @@ function maybeUnion(...types: (string | WriterFunction)[]) { function recordType(value: string | WriterFunction) { return (writer: CodeBlockWriter) => { - writer.write("Record, - "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); @@ -401,30 +399,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 @@ -503,13 +517,13 @@ function objectType( ); return { - type: recordType(value.type ?? "Jsonifiable"), + type: recordType(value.type ?? "JsonValue"), isReadonly: !!schemaObject.readOnly, }; } return { - type: "Record", + type: "Record", }; } @@ -527,11 +541,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 +572,10 @@ function schemaObjectType( } if (schemaObject.type === "array") { - return arrayType(typesAndInterfaces, propertyName, schemaObject, options); + return withNullable( + schemaObject, + arrayType(typesAndInterfaces, propertyName, schemaObject, options), + ); } if ( @@ -582,7 +595,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,13 +622,13 @@ function schemaObjectType( } if (schemaObject.type === "string") { - return { type: stringType(schemaObject) }; + return withNullable(schemaObject, { type: stringType(schemaObject) }); } // empty schemaObject if (Object.keys(schemaObject).length === 0) { return { - type: maybeWithNullUnion("Jsonifiable", schemaTypeIsNull(schemaObject)), + type: maybeWithNullUnion("JsonValue", schemaTypeIsNull(schemaObject)), isReadonly: !!schemaObject.readOnly, }; } @@ -651,7 +667,7 @@ export function schemaToType( ): OptionalKind { const name = `"${propertyName}"`; const hasQuestionToken = - parentSchema.type === "object" && + isObjectSchema(parentSchema) && !parentSchema.required?.includes(propertyName); if (isReferenceObject(schemaObject)) { @@ -855,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/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..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,15 +240,21 @@ 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, 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; } @@ -657,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, @@ -740,7 +747,7 @@ function schemaToValidator( if (schema.type === "array") { const items = schema.items ? schemaToValidator(validators, schema.items, mode) - : vcall("unknown"); + : jsonValueSchema; return maybeNullable( maybePipe( @@ -768,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); } @@ -775,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"), @@ -790,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; }