diff --git a/.gitignore b/.gitignore index ea906f8..9410656 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +/react-query +/.speakeasy/reports /models /models/errors /types diff --git a/.npmignore b/.npmignore index 06cd8ab..9ad259e 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,7 @@ **/* +!/FUNCTIONS.md +!/RUNTIMES.md +!/REACT_QUERY.md !/**/*.ts !/**/*.js !/**/*.map diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 6599165..20f0cf0 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 61a4ac00-e7ed-4a10-9e0f-47f8aef9702c management: - docChecksum: c58ce1a8f4761676d0ec62b40ce3b5af + docChecksum: e1f306b5ba0a01e1785143532d301bf4 docVersion: 2.3.0 - speakeasyVersion: 1.421.1 - generationVersion: 2.438.15 - releaseVersion: 0.0.5 - configChecksum: 20495d52a63fb99b59bfcbbc62b92c6b + speakeasyVersion: 1.462.2 + generationVersion: 2.486.1 + releaseVersion: 0.1.0 + configChecksum: 7368fbdfd96840ba79324b02deebb238 repoURL: https://github.com/argotdev/speakeasy-sdk.git installationURL: https://github.com/argotdev/speakeasy-sdk published: true @@ -14,22 +14,22 @@ features: typescript: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.11 - core: 3.18.2 + core: 3.18.12 defaultEnabledRetries: 0.1.0 deprecations: 2.81.1 devContainers: 2.90.0 downloadStreams: 0.1.1 enumUnions: 0.1.0 - envVarSecurityUsage: 0.1.1 - globalSecurity: 2.82.11 + envVarSecurityUsage: 0.1.2 + globalSecurity: 2.82.12 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 globalServerURLs: 2.82.4 nullables: 0.1.0 responseFormat: 0.2.3 retries: 2.83.0 - sdkHooks: 0.1.0 - unions: 2.85.7 + sdkHooks: 0.2.0 + unions: 2.85.8 uploadStreams: 0.1.0 generatedFiles: - .devcontainer/README.md @@ -1917,3 +1917,4 @@ examples: application/json: {"object": "organization.project.api_key.deleted", "id": "", "deleted": false} "400": application/json: {"error": {"code": "", "message": "", "param": "", "type": ""}} +generatedTests: {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index b94cfaa..dd8a249 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -14,8 +14,9 @@ generation: requestResponseComponentNamesFeb2024: true auth: oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false typescript: - version: 0.0.5 + version: 0.1.0 additionalDependencies: dependencies: {} devDependencies: {} @@ -23,6 +24,8 @@ typescript: additionalPackageJSON: {} author: Speakeasy clientServerStatusCodesAsErrors: true + defaultErrorName: SDKError + enableReactQuery: false enumFormat: union envVarPrefix: ARGOTOPENAI flattenGlobalSecurity: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 1ce5a99..4a92236 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,18 +1,21 @@ -speakeasyVersion: 1.421.1 +speakeasyVersion: 1.462.2 sources: ArgotOpenAi-OAS: sourceNamespace: argot-open-ai-oas - sourceRevisionDigest: sha256:57762a25bf2b9db92394f493016221caac15a961a8b0d0daf781fbf169cf11de - sourceBlobDigest: sha256:1ac004496342b737f8cbb62c2de296ce98c3851f1082d3b6d73d7f312b6d247e + sourceRevisionDigest: sha256:1cf9f2b2735ce891126bb1eb1aa9256826a291a80ca2b07adb272c46e71a765c + sourceBlobDigest: sha256:e89de7a85a3dfb63c1563aefa16ae940ce3d67eaa50d2d718fe9bedb74e902bb tags: - latest - - main + - speakeasy-sdk-regen-1729907398 + - 2.3.0 targets: argot-open-ai: source: ArgotOpenAi-OAS sourceNamespace: argot-open-ai-oas - sourceRevisionDigest: sha256:57762a25bf2b9db92394f493016221caac15a961a8b0d0daf781fbf169cf11de - sourceBlobDigest: sha256:1ac004496342b737f8cbb62c2de296ce98c3851f1082d3b6d73d7f312b6d247e + sourceRevisionDigest: sha256:1cf9f2b2735ce891126bb1eb1aa9256826a291a80ca2b07adb272c46e71a765c + sourceBlobDigest: sha256:e89de7a85a3dfb63c1563aefa16ae940ce3d67eaa50d2d718fe9bedb74e902bb + codeSamplesNamespace: argot-open-ai-oas-typescript-code-samples + codeSamplesRevisionDigest: sha256:6aa316ebc0883131949bd37cec5b736e48fad731b4786cd10ecd79f3929f6010 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest @@ -29,3 +32,9 @@ workflow: publish: npm: token: $npm_token + codeSamples: + registry: + location: registry.speakeasyapi.dev/argot/argot/argot-open-ai-oas-typescript-code-samples + labelOverride: + fixedValue: Typescript (SDK) + blocking: false diff --git a/.speakeasy/workflow.yaml b/.speakeasy/workflow.yaml index 0a08c4f..89b4fec 100644 --- a/.speakeasy/workflow.yaml +++ b/.speakeasy/workflow.yaml @@ -1,15 +1,21 @@ workflowVersion: 1.0.0 speakeasyVersion: latest sources: - ArgotOpenAi-OAS: - inputs: - - location: openai-openapi.yaml - registry: - location: registry.speakeasyapi.dev/argot/argot/argot-open-ai-oas + ArgotOpenAi-OAS: + inputs: + - location: openai-openapi.yaml + registry: + location: registry.speakeasyapi.dev/argot/argot/argot-open-ai-oas targets: - argot-open-ai: - target: typescript - source: ArgotOpenAi-OAS - publish: - npm: - token: $npm_token + argot-open-ai: + target: typescript + source: ArgotOpenAi-OAS + publish: + npm: + token: $npm_token + codeSamples: + registry: + location: registry.speakeasyapi.dev/argot/argot/argot-open-ai-oas-typescript-code-samples + labelOverride: + fixedValue: Typescript (SDK) + blocking: false diff --git a/README.md b/README.md index f6fd961..82ee390 100644 --- a/README.md +++ b/README.md @@ -22,19 +22,24 @@ OpenAI API: The OpenAI REST API. Please see https://platform.openai.com/docs/api ## Table of Contents + +* [argot-open-ai](#argot-open-ai) + * [SDK Installation](#sdk-installation) + * [Requirements](#requirements) + * [SDK Example Usage](#sdk-example-usage) + * [Available Resources and Operations](#available-resources-and-operations) + * [Standalone functions](#standalone-functions) + * [File uploads](#file-uploads) + * [Retries](#retries) + * [Error Handling](#error-handling) + * [Server Selection](#server-selection) + * [Custom HTTP Client](#custom-http-client) + * [Authentication](#authentication) + * [Debugging](#debugging) +* [Development](#development) + * [Maturity](#maturity) + * [Contributions](#contributions) -* [SDK Installation](#sdk-installation) -* [Requirements](#requirements) -* [SDK Example Usage](#sdk-example-usage) -* [Available Resources and Operations](#available-resources-and-operations) -* [Standalone functions](#standalone-functions) -* [File uploads](#file-uploads) -* [Retries](#retries) -* [Error Handling](#error-handling) -* [Server Selection](#server-selection) -* [Custom HTTP Client](#custom-http-client) -* [Authentication](#authentication) -* [Debugging](#debugging) @@ -664,24 +669,14 @@ run(); ## Error Handling -All SDK methods return a response object or throw an error. By default, an API error will throw a `errors.SDKError`. +Some methods specify known errors which can be thrown. All the known errors are enumerated in the `models/errors/errors.ts` module. The known errors for a method are documented under the *Errors* tables in SDK docs. For example, the `modifyProject` method may throw the following errors: -If a HTTP request fails, an operation my also throw an error from the `models/errors/httpclienterrors.ts` module: +| Error Type | Status Code | Content Type | +| -------------------- | ----------- | ---------------- | +| errors.ErrorResponse | 400 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | -| HTTP Client Error | Description | -| ---------------------------------------------------- | ---------------------------------------------------- | -| RequestAbortedError | HTTP request was aborted by the client | -| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | -| ConnectionError | HTTP client was unable to make a request to a server | -| InvalidRequestError | Any input used to create a request is invalid | -| UnexpectedClientError | Unrecognised or unexpected error | - -In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. For example, the `modifyProject` method may throw the following errors: - -| Error Type | Status Code | Content Type | -| -------------------- | -------------------- | -------------------- | -| errors.ErrorResponse | 400 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | +If the method throws an error and it is not captured by the known errors, it will default to throwing a `SDKError`. ```typescript import { ArgotOpenAi } from "argot-open-ai"; @@ -705,8 +700,9 @@ async function run() { console.log(result); } catch (err) { switch (true) { + // The server response does not match the expected SDK schema case (err instanceof SDKValidationError): { - // Validation errors can be pretty-printed + // Pretty-print will provide a human-readable multi-line error message console.error(err.pretty()); // Raw value may also be inspected console.error(err.rawValue); @@ -718,6 +714,7 @@ async function run() { return; } default: { + // Other errors such as network errors, see HTTPClientErrors for more details throw err; } } @@ -728,76 +725,25 @@ run(); ``` -Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging. +Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The `SDKValidationError` that is thrown as a result will capture the raw value that failed validation in an attribute called `rawValue`. Additionally, a `pretty()` method is available on this error that can be used to log a nicely formatted multi-line string since validation errors can list many issues and the plain error string may be difficult read when debugging. + +In some rare cases, the SDK can fail to get a response from the server or even make the request due to unexpected circumstances such as network conditions. These types of errors are captured in the `models/errors/httpclienterrors.ts` module: + +| HTTP Client Error | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | +| RequestAbortedError | HTTP request was aborted by the client | +| RequestTimeoutError | HTTP request timed out due to an AbortSignal signal | +| ConnectionError | HTTP client was unable to make a request to a server | +| InvalidRequestError | Any input used to create a request is invalid | +| UnexpectedClientError | Unrecognised or unexpected error | ## Server Selection -### Select Server by Index - -You can override the default server globally by passing a server index to the `serverIdx` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: - -| # | Server | Variables | -| - | ------ | --------- | -| 0 | `https://api.openai.com/v1` | None | - -```typescript -import { ArgotOpenAi } from "argot-open-ai"; - -const argotOpenAi = new ArgotOpenAi({ - serverIdx: 0, - apiKeyAuth: process.env["ARGOTOPENAI_API_KEY_AUTH"] ?? "", -}); - -async function run() { - const result = await argotOpenAi.chat.createChatCompletion({ - messages: [ - { - content: "", - role: "user", - }, - { - content: [ - { - type: "text", - text: "", - }, - { - type: "image_url", - imageUrl: { - url: "https://fixed-circumference.com", - }, - }, - ], - role: "user", - }, - { - role: "tool", - content: "", - toolCallId: "", - }, - ], - model: "gpt-4o", - n: 1, - temperature: 1, - topP: 1, - user: "user-1234", - }); - - // Handle the result - console.log(result); -} - -run(); - -``` - - ### Override Server URL Per-Client -The default server can also be overridden globally by passing a URL to the `serverURL` optional parameter when initializing the SDK client instance. For example: - +The default server can also be overridden globally by passing a URL to the `serverURL: string` optional parameter when initializing the SDK client instance. For example: ```typescript import { ArgotOpenAi } from "argot-open-ai"; @@ -906,9 +852,9 @@ const sdk = new ArgotOpenAi({ httpClient }); This SDK supports the following security scheme globally: -| Name | Type | Scheme | Environment Variable | -| -------------------------- | -------------------------- | -------------------------- | -------------------------- | -| `apiKeyAuth` | http | HTTP Bearer | `ARGOTOPENAI_API_KEY_AUTH` | +| Name | Type | Scheme | Environment Variable | +| ------------ | ---- | ----------- | -------------------------- | +| `apiKeyAuth` | http | HTTP Bearer | `ARGOTOPENAI_API_KEY_AUTH` | To authenticate with the API the `apiKeyAuth` parameter must be set when initializing the SDK client instance. For example: ```typescript diff --git a/RELEASES.md b/RELEASES.md index acaaf65..3742527 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -36,4 +36,14 @@ Based on: ### Generated - [typescript v0.0.5] . ### Releases -- [NPM v0.0.5] https://www.npmjs.com/package/argot-open-ai/v/0.0.5 - . \ No newline at end of file +- [NPM v0.0.5] https://www.npmjs.com/package/argot-open-ai/v/0.0.5 - . + +## 2025-01-04 00:09:14 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.462.2 (2.486.1) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.1.0] . +### Releases +- [NPM v0.1.0] https://www.npmjs.com/package/argot-open-ai/v/0.1.0 - . \ No newline at end of file diff --git a/RUNTIMES.md b/RUNTIMES.md index d08a0c0..db7ea94 100644 --- a/RUNTIMES.md +++ b/RUNTIMES.md @@ -1,6 +1,6 @@ # Supported JavaScript runtimes -This SDK is intended to be used in JavaScript runtimes that support the following features: +This SDK is intended to be used in JavaScript runtimes that support ECMAScript 2020 or newer. The SDK uses the following features: * [Web Fetch API][web-fetch] * [Web Streams API][web-streams] and in particular `ReadableStream` @@ -20,3 +20,29 @@ Runtime environments that are explicitly supported are: - Note that Deno does not currently have native support for streaming file uploads backed by the filesystem ([issue link][deno-file-streaming]) [deno-file-streaming]: https://github.com/denoland/deno/issues/11018 + +## Recommended TypeScript compiler options + +The following `tsconfig.json` options are recommended for projects using this +SDK in order to get static type support for features like async iterables, +streams and `fetch`-related APIs ([`for await...of`][for-await-of], +[`AbortSignal`][abort-signal], [`Request`][request], [`Response`][response] and +so on): + +[for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of +[abort-signal]: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal +[request]: https://developer.mozilla.org/en-US/docs/Web/API/Request +[response]: https://developer.mozilla.org/en-US/docs/Web/API/Response + +```jsonc +{ + "compilerOptions": { + "target": "es2020", // or higher + "lib": ["es2020", "dom", "dom.iterable"], + } +} +``` + +While `target` can be set to older ECMAScript versions, it may result in extra, +unnecessary compatibility code being generated if you are not targeting old +runtimes. \ No newline at end of file diff --git a/docs/models/components/createchatcompletionrequest.md b/docs/models/components/createchatcompletionrequest.md index 81872a4..18b4e36 100644 --- a/docs/models/components/createchatcompletionrequest.md +++ b/docs/models/components/createchatcompletionrequest.md @@ -49,6 +49,7 @@ let value: CreateChatCompletionRequest = { | `topP` | *number* | :heavy_minus_sign: | 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.
| 1 | | `tools` | [components.ChatCompletionTool](../../models/components/chatcompletiontool.md)[] | :heavy_minus_sign: | A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
| | | `toolChoice` | *components.ChatCompletionToolChoiceOption* | :heavy_minus_sign: | 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.
| | +| `parallelToolCalls` | *boolean* | :heavy_minus_sign: | Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. | | | `user` | *string* | :heavy_minus_sign: | 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-1234 | | ~~`functionCall`~~ | *components.CreateChatCompletionRequestFunctionCall* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated in favor of `tool_choice`.

Controls which (if any) function is called by the model.
`none` means the model will not call a function and instead generates a message.
`auto` means the model can pick between generating a message or calling a function.
Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.

`none` is the default when no functions are present. `auto` is the default if functions are present.
| | | ~~`functions`~~ | [components.ChatCompletionFunctions](../../models/components/chatcompletionfunctions.md)[] | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated in favor of `tools`.

A list of functions the model may generate JSON inputs for.
| | \ No newline at end of file diff --git a/docs/models/components/createrunrequest.md b/docs/models/components/createrunrequest.md index 0ff9feb..938fac8 100644 --- a/docs/models/components/createrunrequest.md +++ b/docs/models/components/createrunrequest.md @@ -31,4 +31,5 @@ let value: CreateRunRequest = { | `maxCompletionTokens` | *number* | :heavy_minus_sign: | 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.
| | | `truncationStrategy` | [components.TruncationObject](../../models/components/truncationobject.md) | :heavy_minus_sign: | Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. | | | `toolChoice` | *components.AssistantsApiToolChoiceOption* | :heavy_minus_sign: | Controls which (if any) tool is called by the model.
`none` means the model will not call any tools and instead generates a message.
`auto` is the default value and 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 before responding to the user.
Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
| | +| `parallelToolCalls` | *boolean* | :heavy_minus_sign: | Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. | | | `responseFormat` | *components.AssistantsApiResponseFormatOption* | :heavy_minus_sign: | Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
| | \ No newline at end of file diff --git a/docs/models/components/createthreadandrunrequest.md b/docs/models/components/createthreadandrunrequest.md index 4e49a35..6c4b5c1 100644 --- a/docs/models/components/createthreadandrunrequest.md +++ b/docs/models/components/createthreadandrunrequest.md @@ -31,4 +31,5 @@ let value: CreateThreadAndRunRequest = { | `maxCompletionTokens` | *number* | :heavy_minus_sign: | 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.
| | | `truncationStrategy` | [components.TruncationObject](../../models/components/truncationobject.md) | :heavy_minus_sign: | Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. | | | `toolChoice` | *components.AssistantsApiToolChoiceOption* | :heavy_minus_sign: | Controls which (if any) tool is called by the model.
`none` means the model will not call any tools and instead generates a message.
`auto` is the default value and 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 before responding to the user.
Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
| | +| `parallelToolCalls` | *boolean* | :heavy_minus_sign: | Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. | | | `responseFormat` | *components.AssistantsApiResponseFormatOption* | :heavy_minus_sign: | Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
| | \ No newline at end of file diff --git a/docs/models/components/runobject.md b/docs/models/components/runobject.md index cf46de4..80110cd 100644 --- a/docs/models/components/runobject.md +++ b/docs/models/components/runobject.md @@ -98,4 +98,5 @@ let value: RunObject = { | `maxCompletionTokens` | *number* | :heavy_check_mark: | The maximum number of completion tokens specified to have been used over the course of the run.
| | `truncationStrategy` | [components.TruncationObject](../../models/components/truncationobject.md) | :heavy_check_mark: | Controls for how a thread will be truncated prior to the run. Use this to control the intial context window of the run. | | `toolChoice` | *components.AssistantsApiToolChoiceOption* | :heavy_check_mark: | Controls which (if any) tool is called by the model.
`none` means the model will not call any tools and instead generates a message.
`auto` is the default value and 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 before responding to the user.
Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool.
| +| `parallelToolCalls` | *boolean* | :heavy_minus_sign: | Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. | | `responseFormat` | *components.AssistantsApiResponseFormatOption* | :heavy_check_mark: | Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.

Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured Outputs which ensures the model will match your supplied JSON schema. Learn more in the [Structured Outputs guide](/docs/guides/structured-outputs).

Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the message the model generates is valid JSON.

**Important:** when using JSON mode, you **must** also instruct the model to produce JSON yourself via a system or user message. Without this, the model may generate an unending stream of whitespace until the generation reaches the token limit, resulting in a long-running and seemingly "stuck" request. Also note that the message content may be partially cut off if `finish_reason="length"`, which indicates the generation exceeded `max_tokens` or the conversation exceeded the max context length.
| \ No newline at end of file diff --git a/docs/sdks/argotopenai/README.md b/docs/sdks/argotopenai/README.md index a7ed4fe..80cef6f 100644 --- a/docs/sdks/argotopenai/README.md +++ b/docs/sdks/argotopenai/README.md @@ -2,4 +2,6 @@ ## Overview -OpenAI API: The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details. \ No newline at end of file +OpenAI API: The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details. + +### Available Operations diff --git a/jsr.json b/jsr.json index b3c37ed..59f1d1d 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "argot-open-ai", - "version": "0.0.5", + "version": "0.1.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index 9bb9662..5bb5a69 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "argot-open-ai", - "version": "0.0.5", + "version": "0.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "argot-open-ai", - "version": "0.0.5", + "version": "0.1.0", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/package.json b/package.json index 2033ab7..0da3b1f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "argot-open-ai", - "version": "0.0.5", + "version": "0.1.0", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/assistantsCancelRun.ts b/src/funcs/assistantsCancelRun.ts index 286d274..84f3698 100644 --- a/src/funcs/assistantsCancelRun.ts +++ b/src/funcs/assistantsCancelRun.ts @@ -73,16 +73,25 @@ export async function assistantsCancelRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "cancelRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -96,9 +105,8 @@ export async function assistantsCancelRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsCreateAssistant.ts b/src/funcs/assistantsCreateAssistant.ts index e78e67e..5bb441d 100644 --- a/src/funcs/assistantsCreateAssistant.ts +++ b/src/funcs/assistantsCreateAssistant.ts @@ -60,16 +60,25 @@ export async function assistantsCreateAssistant( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createAssistant", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function assistantsCreateAssistant( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsCreateMessage.ts b/src/funcs/assistantsCreateMessage.ts index 876f0be..200d52e 100644 --- a/src/funcs/assistantsCreateMessage.ts +++ b/src/funcs/assistantsCreateMessage.ts @@ -70,16 +70,25 @@ export async function assistantsCreateMessage( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createMessage", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -93,9 +102,8 @@ export async function assistantsCreateMessage( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsCreateRun.ts b/src/funcs/assistantsCreateRun.ts index 7e799df..8af2f0b 100644 --- a/src/funcs/assistantsCreateRun.ts +++ b/src/funcs/assistantsCreateRun.ts @@ -72,16 +72,25 @@ export async function assistantsCreateRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -96,9 +105,8 @@ export async function assistantsCreateRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsCreateThread.ts b/src/funcs/assistantsCreateThread.ts index 091f66a..0ad2034 100644 --- a/src/funcs/assistantsCreateThread.ts +++ b/src/funcs/assistantsCreateThread.ts @@ -63,16 +63,25 @@ export async function assistantsCreateThread( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createThread", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -86,9 +95,8 @@ export async function assistantsCreateThread( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsCreateThreadAndRun.ts b/src/funcs/assistantsCreateThreadAndRun.ts index b65ceb4..dee91ac 100644 --- a/src/funcs/assistantsCreateThreadAndRun.ts +++ b/src/funcs/assistantsCreateThreadAndRun.ts @@ -60,16 +60,25 @@ export async function assistantsCreateThreadAndRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createThreadAndRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function assistantsCreateThreadAndRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsDeleteAssistant.ts b/src/funcs/assistantsDeleteAssistant.ts index 1f32395..4d5c899 100644 --- a/src/funcs/assistantsDeleteAssistant.ts +++ b/src/funcs/assistantsDeleteAssistant.ts @@ -67,16 +67,25 @@ export async function assistantsDeleteAssistant( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteAssistant", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function assistantsDeleteAssistant( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsDeleteMessage.ts b/src/funcs/assistantsDeleteMessage.ts index c87284b..b967a30 100644 --- a/src/funcs/assistantsDeleteMessage.ts +++ b/src/funcs/assistantsDeleteMessage.ts @@ -73,16 +73,25 @@ export async function assistantsDeleteMessage( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteMessage", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -96,9 +105,8 @@ export async function assistantsDeleteMessage( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsDeleteThread.ts b/src/funcs/assistantsDeleteThread.ts index 71dabd4..e3dd09d 100644 --- a/src/funcs/assistantsDeleteThread.ts +++ b/src/funcs/assistantsDeleteThread.ts @@ -67,16 +67,25 @@ export async function assistantsDeleteThread( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteThread", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function assistantsDeleteThread( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsGetAssistant.ts b/src/funcs/assistantsGetAssistant.ts index f1e8652..347c6fd 100644 --- a/src/funcs/assistantsGetAssistant.ts +++ b/src/funcs/assistantsGetAssistant.ts @@ -67,16 +67,25 @@ export async function assistantsGetAssistant( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getAssistant", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function assistantsGetAssistant( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsGetMessage.ts b/src/funcs/assistantsGetMessage.ts index fa22a18..6b10b5d 100644 --- a/src/funcs/assistantsGetMessage.ts +++ b/src/funcs/assistantsGetMessage.ts @@ -73,16 +73,25 @@ export async function assistantsGetMessage( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getMessage", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -96,9 +105,8 @@ export async function assistantsGetMessage( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsGetRun.ts b/src/funcs/assistantsGetRun.ts index 693dead..8b91380 100644 --- a/src/funcs/assistantsGetRun.ts +++ b/src/funcs/assistantsGetRun.ts @@ -71,16 +71,25 @@ export async function assistantsGetRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -94,9 +103,8 @@ export async function assistantsGetRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsGetRunStep.ts b/src/funcs/assistantsGetRunStep.ts index 71f36ff..1e30682 100644 --- a/src/funcs/assistantsGetRunStep.ts +++ b/src/funcs/assistantsGetRunStep.ts @@ -81,16 +81,25 @@ export async function assistantsGetRunStep( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getRunStep", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -105,9 +114,8 @@ export async function assistantsGetRunStep( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsGetThread.ts b/src/funcs/assistantsGetThread.ts index 289876f..255bd4e 100644 --- a/src/funcs/assistantsGetThread.ts +++ b/src/funcs/assistantsGetThread.ts @@ -67,16 +67,25 @@ export async function assistantsGetThread( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getThread", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function assistantsGetThread( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsListAssistants.ts b/src/funcs/assistantsListAssistants.ts index cd2c8e2..7331df2 100644 --- a/src/funcs/assistantsListAssistants.ts +++ b/src/funcs/assistantsListAssistants.ts @@ -67,16 +67,25 @@ export async function assistantsListAssistants( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listAssistants", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -91,9 +100,8 @@ export async function assistantsListAssistants( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsListMessages.ts b/src/funcs/assistantsListMessages.ts index 4f81889..a1822a7 100644 --- a/src/funcs/assistantsListMessages.ts +++ b/src/funcs/assistantsListMessages.ts @@ -75,16 +75,25 @@ export async function assistantsListMessages( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listMessages", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -99,9 +108,8 @@ export async function assistantsListMessages( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsListRunSteps.ts b/src/funcs/assistantsListRunSteps.ts index fe15f06..4b375b7 100644 --- a/src/funcs/assistantsListRunSteps.ts +++ b/src/funcs/assistantsListRunSteps.ts @@ -81,16 +81,25 @@ export async function assistantsListRunSteps( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listRunSteps", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -105,9 +114,8 @@ export async function assistantsListRunSteps( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsListRuns.ts b/src/funcs/assistantsListRuns.ts index a898da8..5bf6b97 100644 --- a/src/funcs/assistantsListRuns.ts +++ b/src/funcs/assistantsListRuns.ts @@ -74,16 +74,25 @@ export async function assistantsListRuns( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listRuns", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -98,9 +107,8 @@ export async function assistantsListRuns( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsModifyAssistant.ts b/src/funcs/assistantsModifyAssistant.ts index 76eb292..6ed5c10 100644 --- a/src/funcs/assistantsModifyAssistant.ts +++ b/src/funcs/assistantsModifyAssistant.ts @@ -70,16 +70,25 @@ export async function assistantsModifyAssistant( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modifyAssistant", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -93,9 +102,8 @@ export async function assistantsModifyAssistant( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsModifyMessage.ts b/src/funcs/assistantsModifyMessage.ts index 46ceb4b..31c5d86 100644 --- a/src/funcs/assistantsModifyMessage.ts +++ b/src/funcs/assistantsModifyMessage.ts @@ -76,16 +76,25 @@ export async function assistantsModifyMessage( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modifyMessage", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -99,9 +108,8 @@ export async function assistantsModifyMessage( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsModifyRun.ts b/src/funcs/assistantsModifyRun.ts index e839729..a40038d 100644 --- a/src/funcs/assistantsModifyRun.ts +++ b/src/funcs/assistantsModifyRun.ts @@ -72,16 +72,25 @@ export async function assistantsModifyRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modifyRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -95,9 +104,8 @@ export async function assistantsModifyRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsModifyThread.ts b/src/funcs/assistantsModifyThread.ts index 41b1392..c61e28f 100644 --- a/src/funcs/assistantsModifyThread.ts +++ b/src/funcs/assistantsModifyThread.ts @@ -70,16 +70,25 @@ export async function assistantsModifyThread( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modifyThread", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -93,9 +102,8 @@ export async function assistantsModifyThread( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/assistantsSubmitToolOuputsToRun.ts b/src/funcs/assistantsSubmitToolOuputsToRun.ts index 729dabb..5d55d36 100644 --- a/src/funcs/assistantsSubmitToolOuputsToRun.ts +++ b/src/funcs/assistantsSubmitToolOuputsToRun.ts @@ -77,16 +77,25 @@ export async function assistantsSubmitToolOuputsToRun( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "submitToolOuputsToRun", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -100,9 +109,8 @@ export async function assistantsSubmitToolOuputsToRun( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/audioCreateSpeech.ts b/src/funcs/audioCreateSpeech.ts index 8645842..344259b 100644 --- a/src/funcs/audioCreateSpeech.ts +++ b/src/funcs/audioCreateSpeech.ts @@ -61,16 +61,25 @@ export async function audioCreateSpeech( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createSpeech", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -84,9 +93,8 @@ export async function audioCreateSpeech( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/audioCreateTranscription.ts b/src/funcs/audioCreateTranscription.ts index e02f910..18902c1 100644 --- a/src/funcs/audioCreateTranscription.ts +++ b/src/funcs/audioCreateTranscription.ts @@ -96,16 +96,25 @@ export async function audioCreateTranscription( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createTranscription", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -119,9 +128,8 @@ export async function audioCreateTranscription( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/audioCreateTranslation.ts b/src/funcs/audioCreateTranslation.ts index 7ee609f..92954c6 100644 --- a/src/funcs/audioCreateTranslation.ts +++ b/src/funcs/audioCreateTranslation.ts @@ -86,16 +86,25 @@ export async function audioCreateTranslation( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createTranslation", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -109,9 +118,8 @@ export async function audioCreateTranslation( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/auditLogsListAuditLogs.ts b/src/funcs/auditLogsListAuditLogs.ts index 7f7f60a..377b2af 100644 --- a/src/funcs/auditLogsListAuditLogs.ts +++ b/src/funcs/auditLogsListAuditLogs.ts @@ -72,16 +72,25 @@ export async function auditLogsListAuditLogs( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-audit-logs", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -96,9 +105,8 @@ export async function auditLogsListAuditLogs( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/batchCancelBatch.ts b/src/funcs/batchCancelBatch.ts index 53fe260..d6f1ffc 100644 --- a/src/funcs/batchCancelBatch.ts +++ b/src/funcs/batchCancelBatch.ts @@ -67,16 +67,25 @@ export async function batchCancelBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "cancelBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function batchCancelBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/batchCreateBatch.ts b/src/funcs/batchCreateBatch.ts index 2f834aa..26a7524 100644 --- a/src/funcs/batchCreateBatch.ts +++ b/src/funcs/batchCreateBatch.ts @@ -61,16 +61,25 @@ export async function batchCreateBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -84,9 +93,8 @@ export async function batchCreateBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/batchListBatches.ts b/src/funcs/batchListBatches.ts index 1e1f597..6db1acc 100644 --- a/src/funcs/batchListBatches.ts +++ b/src/funcs/batchListBatches.ts @@ -65,16 +65,25 @@ export async function batchListBatches( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listBatches", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -89,9 +98,8 @@ export async function batchListBatches( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/batchRetrieveBatch.ts b/src/funcs/batchRetrieveBatch.ts index e848768..b8cac4c 100644 --- a/src/funcs/batchRetrieveBatch.ts +++ b/src/funcs/batchRetrieveBatch.ts @@ -67,16 +67,25 @@ export async function batchRetrieveBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieveBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function batchRetrieveBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/chatCreateChatCompletion.ts b/src/funcs/chatCreateChatCompletion.ts index ddb81b2..f2a0578 100644 --- a/src/funcs/chatCreateChatCompletion.ts +++ b/src/funcs/chatCreateChatCompletion.ts @@ -61,16 +61,25 @@ export async function chatCreateChatCompletion( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createChatCompletion", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -84,9 +93,8 @@ export async function chatCreateChatCompletion( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/completionsCreateCompletion.ts b/src/funcs/completionsCreateCompletion.ts index 002d69e..a1771e5 100644 --- a/src/funcs/completionsCreateCompletion.ts +++ b/src/funcs/completionsCreateCompletion.ts @@ -60,16 +60,25 @@ export async function completionsCreateCompletion( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createCompletion", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function completionsCreateCompletion( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/embeddingsCreateEmbedding.ts b/src/funcs/embeddingsCreateEmbedding.ts index bc5a1c7..757f080 100644 --- a/src/funcs/embeddingsCreateEmbedding.ts +++ b/src/funcs/embeddingsCreateEmbedding.ts @@ -60,16 +60,25 @@ export async function embeddingsCreateEmbedding( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createEmbedding", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function embeddingsCreateEmbedding( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/filesCreateFile.ts b/src/funcs/filesCreateFile.ts index 0f4341e..47b14fc 100644 --- a/src/funcs/filesCreateFile.ts +++ b/src/funcs/filesCreateFile.ts @@ -84,16 +84,25 @@ export async function filesCreateFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -107,9 +116,8 @@ export async function filesCreateFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/filesDeleteFile.ts b/src/funcs/filesDeleteFile.ts index 019242d..a59aceb 100644 --- a/src/funcs/filesDeleteFile.ts +++ b/src/funcs/filesDeleteFile.ts @@ -67,16 +67,25 @@ export async function filesDeleteFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function filesDeleteFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/filesDownloadFile.ts b/src/funcs/filesDownloadFile.ts index 88fc46e..fa173ee 100644 --- a/src/funcs/filesDownloadFile.ts +++ b/src/funcs/filesDownloadFile.ts @@ -67,16 +67,25 @@ export async function filesDownloadFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "downloadFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function filesDownloadFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/filesListFiles.ts b/src/funcs/filesListFiles.ts index 4bb29c9..e8fc13f 100644 --- a/src/funcs/filesListFiles.ts +++ b/src/funcs/filesListFiles.ts @@ -64,16 +64,25 @@ export async function filesListFiles( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listFiles", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -88,9 +97,8 @@ export async function filesListFiles( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/filesRetrieveFile.ts b/src/funcs/filesRetrieveFile.ts index 22ce77a..21b98ea 100644 --- a/src/funcs/filesRetrieveFile.ts +++ b/src/funcs/filesRetrieveFile.ts @@ -67,16 +67,25 @@ export async function filesRetrieveFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieveFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function filesRetrieveFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningCancelFineTuningJob.ts b/src/funcs/fineTuningCancelFineTuningJob.ts index 32b18ff..84f0530 100644 --- a/src/funcs/fineTuningCancelFineTuningJob.ts +++ b/src/funcs/fineTuningCancelFineTuningJob.ts @@ -71,16 +71,25 @@ export async function fineTuningCancelFineTuningJob( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "cancelFineTuningJob", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -94,9 +103,8 @@ export async function fineTuningCancelFineTuningJob( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningCreateFineTuningJob.ts b/src/funcs/fineTuningCreateFineTuningJob.ts index c02dea6..298065e 100644 --- a/src/funcs/fineTuningCreateFineTuningJob.ts +++ b/src/funcs/fineTuningCreateFineTuningJob.ts @@ -65,16 +65,25 @@ export async function fineTuningCreateFineTuningJob( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createFineTuningJob", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -88,9 +97,8 @@ export async function fineTuningCreateFineTuningJob( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningListFineTuningEvents.ts b/src/funcs/fineTuningListFineTuningEvents.ts index 5dd6c9a..77c08ac 100644 --- a/src/funcs/fineTuningListFineTuningEvents.ts +++ b/src/funcs/fineTuningListFineTuningEvents.ts @@ -76,16 +76,25 @@ export async function fineTuningListFineTuningEvents( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listFineTuningEvents", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -100,9 +109,8 @@ export async function fineTuningListFineTuningEvents( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningListFineTuningJobCheckpoints.ts b/src/funcs/fineTuningListFineTuningJobCheckpoints.ts index 667bb4c..06530bb 100644 --- a/src/funcs/fineTuningListFineTuningJobCheckpoints.ts +++ b/src/funcs/fineTuningListFineTuningJobCheckpoints.ts @@ -78,16 +78,25 @@ export async function fineTuningListFineTuningJobCheckpoints( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listFineTuningJobCheckpoints", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -102,9 +111,8 @@ export async function fineTuningListFineTuningJobCheckpoints( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningListPaginatedFineTuningJobs.ts b/src/funcs/fineTuningListPaginatedFineTuningJobs.ts index 809e123..81a39dc 100644 --- a/src/funcs/fineTuningListPaginatedFineTuningJobs.ts +++ b/src/funcs/fineTuningListPaginatedFineTuningJobs.ts @@ -66,16 +66,25 @@ export async function fineTuningListPaginatedFineTuningJobs( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listPaginatedFineTuningJobs", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -90,9 +99,8 @@ export async function fineTuningListPaginatedFineTuningJobs( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/fineTuningRetrieveFineTuningJob.ts b/src/funcs/fineTuningRetrieveFineTuningJob.ts index 23c52ab..639cf1d 100644 --- a/src/funcs/fineTuningRetrieveFineTuningJob.ts +++ b/src/funcs/fineTuningRetrieveFineTuningJob.ts @@ -71,16 +71,25 @@ export async function fineTuningRetrieveFineTuningJob( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieveFineTuningJob", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -94,9 +103,8 @@ export async function fineTuningRetrieveFineTuningJob( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/imagesCreateImage.ts b/src/funcs/imagesCreateImage.ts index 32192ee..ac2cd2c 100644 --- a/src/funcs/imagesCreateImage.ts +++ b/src/funcs/imagesCreateImage.ts @@ -60,16 +60,25 @@ export async function imagesCreateImage( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createImage", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function imagesCreateImage( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/imagesCreateImageEdit.ts b/src/funcs/imagesCreateImageEdit.ts index 9222862..fb3553d 100644 --- a/src/funcs/imagesCreateImageEdit.ts +++ b/src/funcs/imagesCreateImageEdit.ts @@ -106,16 +106,25 @@ export async function imagesCreateImageEdit( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createImageEdit", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -129,9 +138,8 @@ export async function imagesCreateImageEdit( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/imagesCreateImageVariation.ts b/src/funcs/imagesCreateImageVariation.ts index 88f42bd..a41b48e 100644 --- a/src/funcs/imagesCreateImageVariation.ts +++ b/src/funcs/imagesCreateImageVariation.ts @@ -91,16 +91,25 @@ export async function imagesCreateImageVariation( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createImageVariation", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -114,9 +123,8 @@ export async function imagesCreateImageVariation( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/invitesDeleteInvite.ts b/src/funcs/invitesDeleteInvite.ts index b0481ee..a9684af 100644 --- a/src/funcs/invitesDeleteInvite.ts +++ b/src/funcs/invitesDeleteInvite.ts @@ -67,16 +67,25 @@ export async function invitesDeleteInvite( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "delete-invite", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function invitesDeleteInvite( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/invitesInviteUser.ts b/src/funcs/invitesInviteUser.ts index 691dde4..f1457fc 100644 --- a/src/funcs/invitesInviteUser.ts +++ b/src/funcs/invitesInviteUser.ts @@ -60,16 +60,25 @@ export async function invitesInviteUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "inviteUser", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function invitesInviteUser( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/invitesListInvites.ts b/src/funcs/invitesListInvites.ts index 89f3598..0af6bb0 100644 --- a/src/funcs/invitesListInvites.ts +++ b/src/funcs/invitesListInvites.ts @@ -65,16 +65,25 @@ export async function invitesListInvites( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-invites", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -89,9 +98,8 @@ export async function invitesListInvites( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/invitesRetrieveInvite.ts b/src/funcs/invitesRetrieveInvite.ts index fd55f26..1db6160 100644 --- a/src/funcs/invitesRetrieveInvite.ts +++ b/src/funcs/invitesRetrieveInvite.ts @@ -67,16 +67,25 @@ export async function invitesRetrieveInvite( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-invite", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function invitesRetrieveInvite( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/modelsDeleteModel.ts b/src/funcs/modelsDeleteModel.ts index b7807ab..e63e969 100644 --- a/src/funcs/modelsDeleteModel.ts +++ b/src/funcs/modelsDeleteModel.ts @@ -67,16 +67,25 @@ export async function modelsDeleteModel( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteModel", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function modelsDeleteModel( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/modelsListModels.ts b/src/funcs/modelsListModels.ts index c87bceb..713c802 100644 --- a/src/funcs/modelsListModels.ts +++ b/src/funcs/modelsListModels.ts @@ -45,16 +45,25 @@ export async function modelsListModels( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listModels", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, @@ -67,9 +76,8 @@ export async function modelsListModels( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/modelsRetrieveModel.ts b/src/funcs/modelsRetrieveModel.ts index f9b69ef..1d80853 100644 --- a/src/funcs/modelsRetrieveModel.ts +++ b/src/funcs/modelsRetrieveModel.ts @@ -67,16 +67,25 @@ export async function modelsRetrieveModel( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieveModel", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function modelsRetrieveModel( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/moderationsCreateModeration.ts b/src/funcs/moderationsCreateModeration.ts index f8e6006..7415dd9 100644 --- a/src/funcs/moderationsCreateModeration.ts +++ b/src/funcs/moderationsCreateModeration.ts @@ -61,16 +61,25 @@ export async function moderationsCreateModeration( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createModeration", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -84,9 +93,8 @@ export async function moderationsCreateModeration( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsArchiveProject.ts b/src/funcs/projectsArchiveProject.ts index 09cf1be..a40d5aa 100644 --- a/src/funcs/projectsArchiveProject.ts +++ b/src/funcs/projectsArchiveProject.ts @@ -69,16 +69,25 @@ export async function projectsArchiveProject( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "archive-project", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -92,9 +101,8 @@ export async function projectsArchiveProject( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsCreateProject.ts b/src/funcs/projectsCreateProject.ts index 54f0541..409aa97 100644 --- a/src/funcs/projectsCreateProject.ts +++ b/src/funcs/projectsCreateProject.ts @@ -60,16 +60,25 @@ export async function projectsCreateProject( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "create-project", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function projectsCreateProject( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsCreateProjectServiceAccount.ts b/src/funcs/projectsCreateProjectServiceAccount.ts index 712cec9..1b0f311 100644 --- a/src/funcs/projectsCreateProjectServiceAccount.ts +++ b/src/funcs/projectsCreateProjectServiceAccount.ts @@ -75,16 +75,25 @@ export async function projectsCreateProjectServiceAccount( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "create-project-service-account", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -98,9 +107,8 @@ export async function projectsCreateProjectServiceAccount( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsCreateProjectUser.ts b/src/funcs/projectsCreateProjectUser.ts index bc5ce06..5b07f68 100644 --- a/src/funcs/projectsCreateProjectUser.ts +++ b/src/funcs/projectsCreateProjectUser.ts @@ -74,16 +74,25 @@ export async function projectsCreateProjectUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "create-project-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function projectsCreateProjectUser( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsDeleteProjectApiKey.ts b/src/funcs/projectsDeleteProjectApiKey.ts index aae8556..3655864 100644 --- a/src/funcs/projectsDeleteProjectApiKey.ts +++ b/src/funcs/projectsDeleteProjectApiKey.ts @@ -76,16 +76,25 @@ export async function projectsDeleteProjectApiKey( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "delete-project-api-key", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -99,9 +108,8 @@ export async function projectsDeleteProjectApiKey( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsDeleteProjectServiceAccount.ts b/src/funcs/projectsDeleteProjectServiceAccount.ts index 45a6da8..4706ecd 100644 --- a/src/funcs/projectsDeleteProjectServiceAccount.ts +++ b/src/funcs/projectsDeleteProjectServiceAccount.ts @@ -75,16 +75,25 @@ export async function projectsDeleteProjectServiceAccount( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "delete-project-service-account", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -98,9 +107,8 @@ export async function projectsDeleteProjectServiceAccount( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsDeleteProjectUser.ts b/src/funcs/projectsDeleteProjectUser.ts index c8333f5..9f1012d 100644 --- a/src/funcs/projectsDeleteProjectUser.ts +++ b/src/funcs/projectsDeleteProjectUser.ts @@ -75,16 +75,25 @@ export async function projectsDeleteProjectUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "delete-project-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -98,9 +107,8 @@ export async function projectsDeleteProjectUser( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsListProjectApiKeys.ts b/src/funcs/projectsListProjectApiKeys.ts index 003cc2f..4d1ca98 100644 --- a/src/funcs/projectsListProjectApiKeys.ts +++ b/src/funcs/projectsListProjectApiKeys.ts @@ -74,16 +74,25 @@ export async function projectsListProjectApiKeys( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-project-api-keys", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -98,9 +107,8 @@ export async function projectsListProjectApiKeys( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsListProjectServiceAccounts.ts b/src/funcs/projectsListProjectServiceAccounts.ts index 960ed6c..6ad4fb6 100644 --- a/src/funcs/projectsListProjectServiceAccounts.ts +++ b/src/funcs/projectsListProjectServiceAccounts.ts @@ -77,16 +77,25 @@ export async function projectsListProjectServiceAccounts( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-project-service-accounts", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -101,9 +110,8 @@ export async function projectsListProjectServiceAccounts( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsListProjectUsers.ts b/src/funcs/projectsListProjectUsers.ts index ca9c7b7..daba676 100644 --- a/src/funcs/projectsListProjectUsers.ts +++ b/src/funcs/projectsListProjectUsers.ts @@ -76,16 +76,25 @@ export async function projectsListProjectUsers( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-project-users", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -100,9 +109,8 @@ export async function projectsListProjectUsers( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsListProjects.ts b/src/funcs/projectsListProjects.ts index 3f1cf74..5bd142e 100644 --- a/src/funcs/projectsListProjects.ts +++ b/src/funcs/projectsListProjects.ts @@ -66,16 +66,25 @@ export async function projectsListProjects( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-projects", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -90,9 +99,8 @@ export async function projectsListProjects( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsModifyProject.ts b/src/funcs/projectsModifyProject.ts index 1ca8890..50f771a 100644 --- a/src/funcs/projectsModifyProject.ts +++ b/src/funcs/projectsModifyProject.ts @@ -72,16 +72,25 @@ export async function projectsModifyProject( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modify-project", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -95,9 +104,8 @@ export async function projectsModifyProject( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsModifyProjectUser.ts b/src/funcs/projectsModifyProjectUser.ts index 3742ddf..deb959e 100644 --- a/src/funcs/projectsModifyProjectUser.ts +++ b/src/funcs/projectsModifyProjectUser.ts @@ -78,16 +78,25 @@ export async function projectsModifyProjectUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modify-project-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -101,9 +110,8 @@ export async function projectsModifyProjectUser( const doResult = await client._do(req, { context, errorCodes: ["400", "4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsRetrieveProject.ts b/src/funcs/projectsRetrieveProject.ts index 3ddb09a..05763ea 100644 --- a/src/funcs/projectsRetrieveProject.ts +++ b/src/funcs/projectsRetrieveProject.ts @@ -67,16 +67,25 @@ export async function projectsRetrieveProject( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-project", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function projectsRetrieveProject( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsRetrieveProjectApiKey.ts b/src/funcs/projectsRetrieveProjectApiKey.ts index e16c0e3..2b253e4 100644 --- a/src/funcs/projectsRetrieveProjectApiKey.ts +++ b/src/funcs/projectsRetrieveProjectApiKey.ts @@ -74,16 +74,25 @@ export async function projectsRetrieveProjectApiKey( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-project-api-key", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function projectsRetrieveProjectApiKey( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsRetrieveProjectServiceAccount.ts b/src/funcs/projectsRetrieveProjectServiceAccount.ts index b8d0799..c910d14 100644 --- a/src/funcs/projectsRetrieveProjectServiceAccount.ts +++ b/src/funcs/projectsRetrieveProjectServiceAccount.ts @@ -77,16 +77,25 @@ export async function projectsRetrieveProjectServiceAccount( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-project-service-account", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -100,9 +109,8 @@ export async function projectsRetrieveProjectServiceAccount( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/projectsRetrieveProjectUser.ts b/src/funcs/projectsRetrieveProjectUser.ts index b08b6fa..06fac11 100644 --- a/src/funcs/projectsRetrieveProjectUser.ts +++ b/src/funcs/projectsRetrieveProjectUser.ts @@ -74,16 +74,25 @@ export async function projectsRetrieveProjectUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-project-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function projectsRetrieveProjectUser( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/uploadsAddUploadPart.ts b/src/funcs/uploadsAddUploadPart.ts index b546c72..dde1240 100644 --- a/src/funcs/uploadsAddUploadPart.ts +++ b/src/funcs/uploadsAddUploadPart.ts @@ -92,16 +92,25 @@ export async function uploadsAddUploadPart( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "addUploadPart", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -115,9 +124,8 @@ export async function uploadsAddUploadPart( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/uploadsCancelUpload.ts b/src/funcs/uploadsCancelUpload.ts index 768b7f7..c57a102 100644 --- a/src/funcs/uploadsCancelUpload.ts +++ b/src/funcs/uploadsCancelUpload.ts @@ -67,16 +67,25 @@ export async function uploadsCancelUpload( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "cancelUpload", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function uploadsCancelUpload( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/uploadsCompleteUpload.ts b/src/funcs/uploadsCompleteUpload.ts index 05e98e4..73de099 100644 --- a/src/funcs/uploadsCompleteUpload.ts +++ b/src/funcs/uploadsCompleteUpload.ts @@ -76,16 +76,25 @@ export async function uploadsCompleteUpload( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "completeUpload", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -99,9 +108,8 @@ export async function uploadsCompleteUpload( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/uploadsCreateUpload.ts b/src/funcs/uploadsCreateUpload.ts index 8d26fb3..c625187 100644 --- a/src/funcs/uploadsCreateUpload.ts +++ b/src/funcs/uploadsCreateUpload.ts @@ -67,16 +67,25 @@ export async function uploadsCreateUpload( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createUpload", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function uploadsCreateUpload( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/usersDeleteUser.ts b/src/funcs/usersDeleteUser.ts index 28ac050..56dfae7 100644 --- a/src/funcs/usersDeleteUser.ts +++ b/src/funcs/usersDeleteUser.ts @@ -67,16 +67,25 @@ export async function usersDeleteUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "delete-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function usersDeleteUser( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/usersListUsers.ts b/src/funcs/usersListUsers.ts index 5fc1f3a..8a13c50 100644 --- a/src/funcs/usersListUsers.ts +++ b/src/funcs/usersListUsers.ts @@ -65,16 +65,25 @@ export async function usersListUsers( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "list-users", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -89,9 +98,8 @@ export async function usersListUsers( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/usersModifyUser.ts b/src/funcs/usersModifyUser.ts index 52ccf71..513c2d6 100644 --- a/src/funcs/usersModifyUser.ts +++ b/src/funcs/usersModifyUser.ts @@ -70,16 +70,25 @@ export async function usersModifyUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modify-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -93,9 +102,8 @@ export async function usersModifyUser( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/usersRetrieveUser.ts b/src/funcs/usersRetrieveUser.ts index e3488d3..d074065 100644 --- a/src/funcs/usersRetrieveUser.ts +++ b/src/funcs/usersRetrieveUser.ts @@ -67,16 +67,25 @@ export async function usersRetrieveUser( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "retrieve-user", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function usersRetrieveUser( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresCancelVectorStoreFileBatch.ts b/src/funcs/vectorStoresCancelVectorStoreFileBatch.ts index 17531bf..a014b59 100644 --- a/src/funcs/vectorStoresCancelVectorStoreFileBatch.ts +++ b/src/funcs/vectorStoresCancelVectorStoreFileBatch.ts @@ -74,16 +74,25 @@ export async function vectorStoresCancelVectorStoreFileBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "cancelVectorStoreFileBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function vectorStoresCancelVectorStoreFileBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresCreateVectorStore.ts b/src/funcs/vectorStoresCreateVectorStore.ts index a79fdc0..25a35ae 100644 --- a/src/funcs/vectorStoresCreateVectorStore.ts +++ b/src/funcs/vectorStoresCreateVectorStore.ts @@ -60,16 +60,25 @@ export async function vectorStoresCreateVectorStore( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createVectorStore", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -83,9 +92,8 @@ export async function vectorStoresCreateVectorStore( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresCreateVectorStoreFile.ts b/src/funcs/vectorStoresCreateVectorStoreFile.ts index 788ba9e..81c04cd 100644 --- a/src/funcs/vectorStoresCreateVectorStoreFile.ts +++ b/src/funcs/vectorStoresCreateVectorStoreFile.ts @@ -71,16 +71,25 @@ export async function vectorStoresCreateVectorStoreFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createVectorStoreFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -94,9 +103,8 @@ export async function vectorStoresCreateVectorStoreFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresCreateVectorStoreFileBatch.ts b/src/funcs/vectorStoresCreateVectorStoreFileBatch.ts index 4b41bc9..041faad 100644 --- a/src/funcs/vectorStoresCreateVectorStoreFileBatch.ts +++ b/src/funcs/vectorStoresCreateVectorStoreFileBatch.ts @@ -73,16 +73,25 @@ export async function vectorStoresCreateVectorStoreFileBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "createVectorStoreFileBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -96,9 +105,8 @@ export async function vectorStoresCreateVectorStoreFileBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresDeleteVectorStore.ts b/src/funcs/vectorStoresDeleteVectorStore.ts index 18612d5..e247dee 100644 --- a/src/funcs/vectorStoresDeleteVectorStore.ts +++ b/src/funcs/vectorStoresDeleteVectorStore.ts @@ -67,16 +67,25 @@ export async function vectorStoresDeleteVectorStore( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteVectorStore", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function vectorStoresDeleteVectorStore( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresDeleteVectorStoreFile.ts b/src/funcs/vectorStoresDeleteVectorStoreFile.ts index c70a586..7f8a97f 100644 --- a/src/funcs/vectorStoresDeleteVectorStoreFile.ts +++ b/src/funcs/vectorStoresDeleteVectorStoreFile.ts @@ -74,16 +74,25 @@ export async function vectorStoresDeleteVectorStoreFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "deleteVectorStoreFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "DELETE", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function vectorStoresDeleteVectorStoreFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresGetVectorStore.ts b/src/funcs/vectorStoresGetVectorStore.ts index 98bb5dc..04304dc 100644 --- a/src/funcs/vectorStoresGetVectorStore.ts +++ b/src/funcs/vectorStoresGetVectorStore.ts @@ -67,16 +67,25 @@ export async function vectorStoresGetVectorStore( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getVectorStore", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -90,9 +99,8 @@ export async function vectorStoresGetVectorStore( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresGetVectorStoreFile.ts b/src/funcs/vectorStoresGetVectorStoreFile.ts index 8e7848c..cc142fc 100644 --- a/src/funcs/vectorStoresGetVectorStoreFile.ts +++ b/src/funcs/vectorStoresGetVectorStoreFile.ts @@ -73,16 +73,25 @@ export async function vectorStoresGetVectorStoreFile( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getVectorStoreFile", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -96,9 +105,8 @@ export async function vectorStoresGetVectorStoreFile( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresGetVectorStoreFileBatch.ts b/src/funcs/vectorStoresGetVectorStoreFileBatch.ts index 59dbbbd..3ecec1b 100644 --- a/src/funcs/vectorStoresGetVectorStoreFileBatch.ts +++ b/src/funcs/vectorStoresGetVectorStoreFileBatch.ts @@ -74,16 +74,25 @@ export async function vectorStoresGetVectorStoreFileBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "getVectorStoreFileBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -97,9 +106,8 @@ export async function vectorStoresGetVectorStoreFileBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresListFilesInVectorStoreBatch.ts b/src/funcs/vectorStoresListFilesInVectorStoreBatch.ts index 9f7323b..b2af63f 100644 --- a/src/funcs/vectorStoresListFilesInVectorStoreBatch.ts +++ b/src/funcs/vectorStoresListFilesInVectorStoreBatch.ts @@ -82,16 +82,25 @@ export async function vectorStoresListFilesInVectorStoreBatch( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listFilesInVectorStoreBatch", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -106,9 +115,8 @@ export async function vectorStoresListFilesInVectorStoreBatch( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresListVectorStoreFiles.ts b/src/funcs/vectorStoresListVectorStoreFiles.ts index e3d8f2a..81ce85a 100644 --- a/src/funcs/vectorStoresListVectorStoreFiles.ts +++ b/src/funcs/vectorStoresListVectorStoreFiles.ts @@ -76,16 +76,25 @@ export async function vectorStoresListVectorStoreFiles( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listVectorStoreFiles", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -100,9 +109,8 @@ export async function vectorStoresListVectorStoreFiles( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresListVectorStores.ts b/src/funcs/vectorStoresListVectorStores.ts index ca5d8a8..a070c21 100644 --- a/src/funcs/vectorStoresListVectorStores.ts +++ b/src/funcs/vectorStoresListVectorStores.ts @@ -67,16 +67,25 @@ export async function vectorStoresListVectorStores( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "listVectorStores", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "GET", + baseURL: options?.serverURL, path: path, headers: headers, query: query, @@ -91,9 +100,8 @@ export async function vectorStoresListVectorStores( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/vectorStoresModifyVectorStore.ts b/src/funcs/vectorStoresModifyVectorStore.ts index 49b9c9f..cf10449 100644 --- a/src/funcs/vectorStoresModifyVectorStore.ts +++ b/src/funcs/vectorStoresModifyVectorStore.ts @@ -70,16 +70,25 @@ export async function vectorStoresModifyVectorStore( const secConfig = await extractSecurity(client._options.apiKeyAuth); const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "modifyVectorStore", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKeyAuth, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, method: "POST", + baseURL: options?.serverURL, path: path, headers: headers, body: body, @@ -93,9 +102,8 @@ export async function vectorStoresModifyVectorStore( const doResult = await client._do(req, { context, errorCodes: ["4XX", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/hooks/hooks.ts b/src/hooks/hooks.ts index e892d77..fc9b13b 100644 --- a/src/hooks/hooks.ts +++ b/src/hooks/hooks.ts @@ -12,6 +12,7 @@ import { BeforeCreateRequestHook, BeforeRequestContext, BeforeRequestHook, + Hook, Hooks, SDKInitHook, SDKInitOptions, @@ -25,6 +26,25 @@ export class SDKHooks implements Hooks { afterErrorHooks: AfterErrorHook[] = []; constructor() { + const presetHooks: Array = []; + + for (const hook of presetHooks) { + if ("sdkInit" in hook) { + this.registerSDKInitHook(hook); + } + if ("beforeCreateRequest" in hook) { + this.registerBeforeCreateRequestHook(hook); + } + if ("beforeRequest" in hook) { + this.registerBeforeRequestHook(hook); + } + if ("afterSuccess" in hook) { + this.registerAfterSuccessHook(hook); + } + if ("afterError" in hook) { + this.registerAfterErrorHook(hook); + } + } } registerSDKInitHook(hook: SDKInitHook) { diff --git a/src/hooks/types.ts b/src/hooks/types.ts index 656b9e3..8a27c65 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -3,11 +3,15 @@ */ import { HTTPClient, RequestInput } from "../lib/http.js"; +import { RetryConfig } from "../lib/retries.js"; +import { SecurityState } from "../lib/security.js"; export type HookContext = { operationID: string; oAuth2Scopes?: string[]; securitySource?: any | (() => Promise); + retryConfig: RetryConfig; + resolvedSecurity: SecurityState | null; }; export type Awaitable = T | Promise; @@ -96,3 +100,10 @@ export interface Hooks { /** Registers a hook to be used by the SDK for the after error event. */ registerAfterErrorHook(hook: AfterErrorHook): void; } + +export type Hook = + | SDKInitHook + | BeforeCreateRequestHook + | BeforeRequestHook + | AfterSuccessHook + | AfterErrorHook; diff --git a/src/lib/config.ts b/src/lib/config.ts index 228d486..28ce969 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -54,7 +54,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "2.3.0", - sdkVersion: "0.0.5", - genVersion: "2.438.15", - userAgent: "speakeasy-sdk/typescript 0.0.5 2.438.15 2.3.0 argot-open-ai", + sdkVersion: "0.1.0", + genVersion: "2.486.1", + userAgent: "speakeasy-sdk/typescript 0.1.0 2.486.1 2.3.0 argot-open-ai", } as const; diff --git a/src/lib/env.ts b/src/lib/env.ts index 949eb23..8ce6ab9 100644 --- a/src/lib/env.ts +++ b/src/lib/env.ts @@ -13,11 +13,10 @@ export interface Env { } export const envSchema: z.ZodType = z.object({ - ARGOTOPENAI_API_KEY_AUTH: z.string(), + ARGOTOPENAI_API_KEY_AUTH: z.string().optional(), - ARGOTOPENAI_DEBUG: z.coerce.boolean(), -}) - .partial(); + ARGOTOPENAI_DEBUG: z.coerce.boolean().optional(), +}); let envMemo: Env | undefined = undefined; /** diff --git a/src/lib/matchers.ts b/src/lib/matchers.ts index 55a9e14..19b46b3 100644 --- a/src/lib/matchers.ts +++ b/src/lib/matchers.ts @@ -205,7 +205,7 @@ export function match( raw = await response.json(); break; case "bytes": - raw = await response.arrayBuffer(); + raw = new Uint8Array(await response.arrayBuffer()); break; case "stream": raw = response.body; diff --git a/src/lib/primitives.ts b/src/lib/primitives.ts index 23794a2..1dc4ee4 100644 --- a/src/lib/primitives.ts +++ b/src/lib/primitives.ts @@ -2,6 +2,26 @@ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ +class InvariantError extends Error { + constructor(message: string) { + super(message); + this.name = "InvariantError"; + } +} + +export function invariant( + condition: unknown, + message: string, +): asserts condition { + if (!condition) { + throw new InvariantError(message); + } +} + +export type ExactPartial = { + [P in keyof T]?: T[P] | undefined; +}; + export type Remap = { [k in keyof Inp as Mapping[k] extends string /* if we have a string mapping for this key then use it */ ? Mapping[k] @@ -38,3 +58,65 @@ export function remap< return out; } + +export function combineSignals( + ...signals: Array +): AbortSignal | null { + const filtered: AbortSignal[] = []; + for (const signal of signals) { + if (signal) { + filtered.push(signal); + } + } + + switch (filtered.length) { + case 0: + case 1: + return filtered[0] || null; + default: + if ("any" in AbortSignal && typeof AbortSignal.any === "function") { + return AbortSignal.any(filtered); + } + return abortSignalAny(filtered); + } +} + +export function abortSignalAny(signals: AbortSignal[]): AbortSignal { + const controller = new AbortController(); + const result = controller.signal; + if (!signals.length) { + return controller.signal; + } + + if (signals.length === 1) { + return signals[0] || controller.signal; + } + + for (const signal of signals) { + if (signal.aborted) { + return signal; + } + } + + function abort(this: AbortSignal) { + controller.abort(this.reason); + clean(); + } + + const signalRefs: WeakRef[] = []; + function clean() { + for (const signalRef of signalRefs) { + const signal = signalRef.deref(); + if (signal) { + signal.removeEventListener("abort", abort); + } + } + } + + for (const signal of signals) { + signalRefs.push(new WeakRef(signal)); + signal.addEventListener("abort", abort); + } + + return result; +} diff --git a/src/lib/retries.ts b/src/lib/retries.ts index df3e0bc..93ebc8d 100644 --- a/src/lib/retries.ts +++ b/src/lib/retries.ts @@ -26,23 +26,44 @@ export type RetryConfig = retryConnectionErrors?: boolean; }; -class PermanentError extends Error { - inner: unknown; +/** + * PermanentError is an error that is not recoverable. Throwing this error will + * cause a retry loop to terminate. + */ +export class PermanentError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + + constructor(message: string, options?: { cause?: unknown }) { + let msg = message; + if (options?.cause) { + msg += `: ${options.cause}`; + } - constructor(inner: unknown) { - super("Permanent error"); - this.inner = inner; + super(msg, options); + this.name = "PermanentError"; + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = options?.cause; + } Object.setPrototypeOf(this, PermanentError.prototype); } } -class TemporaryError extends Error { - res: Response; +/** + * TemporaryError is an error is used to signal that an HTTP request can be + * retried as part of a retry loop. If retry attempts are exhausted and this + * error is thrown, the response will be returned to the caller. + */ +export class TemporaryError extends Error { + response: Response; - constructor(res: Response) { - super("Temporary error"); - this.res = res; + constructor(message: string, response: Response) { + super(message); + this.response = response; + this.name = "TemporaryError"; Object.setPrototypeOf(this, TemporaryError.prototype); } @@ -80,11 +101,14 @@ function wrapFetcher( try { const res = await fn(); if (isRetryableResponse(res, options.statusCodes)) { - throw new TemporaryError(res); + throw new TemporaryError( + "Response failed with retryable status code", + res, + ); } return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof TemporaryError) { throw err; } @@ -96,7 +120,7 @@ function wrapFetcher( throw err; } - throw new PermanentError(err); + throw new PermanentError("Permanent error", { cause: err }); } }; } @@ -139,37 +163,25 @@ async function retryBackoff( try { const res = await fn(); return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof PermanentError) { - throw err.inner; + throw err.cause; } const elapsed = Date.now() - start; if (elapsed > maxElapsedTime) { if (err instanceof TemporaryError) { - return err.res; + return err.response; } throw err; } let retryInterval = 0; - if (err instanceof TemporaryError && err.res && err.res.headers) { - const retryVal = err.res.headers.get("retry-after") || ""; - if (retryVal != "") { - const parsedNumber = Number(retryVal); - if (!isNaN(parsedNumber) && Number.isInteger(parsedNumber)) { - retryInterval = parsedNumber * 1000; - } else { - const parsedDate = Date.parse(retryVal); - if (!isNaN(parsedDate)) { - const deltaMS = parsedDate - Date.now(); - retryInterval = deltaMS > 0 ? Math.ceil(deltaMS) : 0; - } - } - } + if (err instanceof TemporaryError) { + retryInterval = retryIntervalFromResponse(err.response); } - if (retryInterval == 0) { + if (retryInterval <= 0) { retryInterval = initialInterval * Math.pow(x, exponent) + Math.random() * 1000; } @@ -182,6 +194,26 @@ async function retryBackoff( } } +function retryIntervalFromResponse(res: Response): number { + const retryVal = res.headers.get("retry-after") || ""; + if (!retryVal) { + return 0; + } + + const parsedNumber = Number(retryVal); + if (Number.isInteger(parsedNumber)) { + return parsedNumber * 1000; + } + + const parsedDate = Date.parse(retryVal); + if (Number.isInteger(parsedDate)) { + const deltaMS = parsedDate - Date.now(); + return deltaMS > 0 ? Math.ceil(deltaMS) : 0; + } + + return 0; +} + async function delay(delay: number): Promise { return new Promise((resolve) => setTimeout(resolve, delay)); } diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index ad559b7..7c6145f 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -42,6 +42,10 @@ export type RequestOptions = { * Specifies the status codes which should be retried using the given retry policy. */ retryCodes?: string[]; + /** + * Overrides the base server URL that will be used by an operation. + */ + serverURL?: string | URL; /** * Sets various request options on the `fetch` call made by an SDK method. * @@ -53,7 +57,7 @@ export type RequestOptions = { type RequestConfig = { method: string; path: string; - baseURL?: string | URL; + baseURL?: string | URL | undefined; query?: string; body?: RequestInit["body"]; headers?: HeadersInit; @@ -123,6 +127,7 @@ export class ClientSDK { const inputURL = new URL(path, reqURL); if (path) { + reqURL.pathname += reqURL.pathname.endsWith("/") ? "" : "/"; reqURL.pathname += inputURL.pathname.replace(/^\/+/, ""); } @@ -224,8 +229,8 @@ export class ClientSDK { options: { context: HookContext; errorCodes: number | string | (number | string)[]; - retryConfig?: RetryConfig | undefined; - retryCodes?: string[] | undefined; + retryConfig: RetryConfig; + retryCodes: string[]; }, ): Promise< Result< @@ -237,8 +242,6 @@ export class ClientSDK { > > { const { context, errorCodes } = options; - const retryConfig = options.retryConfig || { strategy: "none" }; - const retryCodes = options.retryCodes || []; return retry( async () => { @@ -249,22 +252,28 @@ export class ClientSDK { let response = await this.#httpClient.request(req); - if (matchStatusCode(response, errorCodes)) { - const result = await this.#hooks.afterError(context, response, null); - if (result.error) { - throw result.error; + try { + if (matchStatusCode(response, errorCodes)) { + const result = await this.#hooks.afterError( + context, + response, + null, + ); + if (result.error) { + throw result.error; + } + response = result.response || response; + } else { + response = await this.#hooks.afterSuccess(context, response); } - response = result.response || response; - } else { - response = await this.#hooks.afterSuccess(context, response); + } finally { + await logResponse(this.#logger, response, req) + .catch(e => this.#logger?.log("Failed to log response:", e)); } - await logResponse(this.#logger, response, req) - .catch(e => this.#logger?.log("Failed to log response:", e)); - return response; }, - { config: retryConfig, statusCodes: retryCodes }, + { config: options.retryConfig, statusCodes: options.retryCodes }, ).then( (r) => OK(r), (err) => { diff --git a/src/lib/security.ts b/src/lib/security.ts index c0e2b7a..a5e96ef 100644 --- a/src/lib/security.ts +++ b/src/lib/security.ts @@ -5,6 +5,14 @@ import * as components from "../models/components/index.js"; import { env } from "./env.js"; +type OAuth2PasswordFlow = { + username: string; + password?: string | undefined; + clientID: string; + clientSecret?: string | undefined; + tokenURL: string; +}; + export enum SecurityErrorCode { Incomplete = "incomplete", UnrecognisedSecurityType = "unrecognized_security_type", @@ -38,6 +46,7 @@ export type SecurityState = { headers: Record; queryParams: Record; cookies: Record; + oauth2: ({ type: "password" } & OAuth2PasswordFlow) | { type: "none" }; }; type SecurityInputBasic = { @@ -74,7 +83,18 @@ type SecurityInputOAuth2 = { type SecurityInputOAuth2ClientCredentials = { type: "oauth2:client_credentials"; - value: string | null | undefined; + value: + | { clientID?: string | undefined; clientSecret?: string | undefined } + | null + | undefined; +}; + +type SecurityInputOAuth2PasswordCredentials = { + type: "oauth2:password"; + value: + | string + | null + | undefined; fieldName: string; }; @@ -90,6 +110,7 @@ export type SecurityInput = | SecurityInputAPIKey | SecurityInputOAuth2 | SecurityInputOAuth2ClientCredentials + | SecurityInputOAuth2PasswordCredentials | SecurityInputOIDC | SecurityInputCustom; @@ -97,10 +118,11 @@ export function resolveSecurity( ...options: SecurityInput[][] ): SecurityState | null { const state: SecurityState = { - basic: { username: "", password: "" }, + basic: {}, headers: {}, queryParams: {}, cookies: {}, + oauth2: { type: "none" }, }; const option = options.find((opts) => { @@ -111,6 +133,12 @@ export function resolveSecurity( return o.value.username != null || o.value.password != null; } else if (o.type === "http:custom") { return null; + } else if (o.type === "oauth2:password") { + return ( + typeof o.value === "string" && !!o.value + ); + } else if (o.type === "oauth2:client_credentials") { + return o.value.clientID != null || o.value.clientSecret != null; } else if (typeof o.value === "string") { return !!o.value; } else { @@ -153,6 +181,9 @@ export function resolveSecurity( case "oauth2": applyBearer(state, spec); break; + case "oauth2:password": + applyBearer(state, spec); + break; case "oauth2:client_credentials": break; case "openIdConnect": @@ -180,9 +211,13 @@ function applyBasic( function applyBearer( state: SecurityState, - spec: SecurityInputBearer | SecurityInputOAuth2 | SecurityInputOIDC, + spec: + | SecurityInputBearer + | SecurityInputOAuth2 + | SecurityInputOIDC + | SecurityInputOAuth2PasswordCredentials, ) { - if (spec.value == null) { + if (typeof spec.value !== "string" || !spec.value) { return; } @@ -193,6 +228,7 @@ function applyBearer( state.headers[spec.fieldName] = value; } + export function resolveGlobalSecurity( security: Partial | null | undefined, ): SecurityState | null { diff --git a/src/models/components/adduploadpartrequest.ts b/src/models/components/adduploadpartrequest.ts index c79babf..846e8c2 100644 --- a/src/models/components/adduploadpartrequest.ts +++ b/src/models/components/adduploadpartrequest.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Data = { fileName: string; @@ -62,6 +65,20 @@ export namespace Data$ { export type Outbound = Data$Outbound; } +export function dataToJSON(data: Data): string { + return JSON.stringify(Data$outboundSchema.parse(data)); +} + +export function dataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Data$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Data' from JSON`, + ); +} + /** @internal */ export const AddUploadPartRequest$inboundSchema: z.ZodType< AddUploadPartRequest, @@ -97,3 +114,21 @@ export namespace AddUploadPartRequest$ { /** @deprecated use `AddUploadPartRequest$Outbound` instead. */ export type Outbound = AddUploadPartRequest$Outbound; } + +export function addUploadPartRequestToJSON( + addUploadPartRequest: AddUploadPartRequest, +): string { + return JSON.stringify( + AddUploadPartRequest$outboundSchema.parse(addUploadPartRequest), + ); +} + +export function addUploadPartRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AddUploadPartRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AddUploadPartRequest' from JSON`, + ); +} diff --git a/src/models/components/assistantobject.ts b/src/models/components/assistantobject.ts index fa01e1d..23eedf5 100644 --- a/src/models/components/assistantobject.ts +++ b/src/models/components/assistantobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -228,6 +231,20 @@ export namespace Tools$ { export type Outbound = Tools$Outbound; } +export function toolsToJSON(tools: Tools): string { + return JSON.stringify(Tools$outboundSchema.parse(tools)); +} + +export function toolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Tools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Tools' from JSON`, + ); +} + /** @internal */ export const AssistantObjectCodeInterpreter$inboundSchema: z.ZodType< AssistantObjectCodeInterpreter, @@ -272,6 +289,26 @@ export namespace AssistantObjectCodeInterpreter$ { export type Outbound = AssistantObjectCodeInterpreter$Outbound; } +export function assistantObjectCodeInterpreterToJSON( + assistantObjectCodeInterpreter: AssistantObjectCodeInterpreter, +): string { + return JSON.stringify( + AssistantObjectCodeInterpreter$outboundSchema.parse( + assistantObjectCodeInterpreter, + ), + ); +} + +export function assistantObjectCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantObjectCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantObjectCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const AssistantObjectFileSearch$inboundSchema: z.ZodType< AssistantObjectFileSearch, @@ -316,6 +353,24 @@ export namespace AssistantObjectFileSearch$ { export type Outbound = AssistantObjectFileSearch$Outbound; } +export function assistantObjectFileSearchToJSON( + assistantObjectFileSearch: AssistantObjectFileSearch, +): string { + return JSON.stringify( + AssistantObjectFileSearch$outboundSchema.parse(assistantObjectFileSearch), + ); +} + +export function assistantObjectFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantObjectFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantObjectFileSearch' from JSON`, + ); +} + /** @internal */ export const ToolResources$inboundSchema: z.ZodType< ToolResources, @@ -367,6 +422,20 @@ export namespace ToolResources$ { export type Outbound = ToolResources$Outbound; } +export function toolResourcesToJSON(toolResources: ToolResources): string { + return JSON.stringify(ToolResources$outboundSchema.parse(toolResources)); +} + +export function toolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ToolResources' from JSON`, + ); +} + /** @internal */ export const Metadata$inboundSchema: z.ZodType< Metadata, @@ -397,6 +466,20 @@ export namespace Metadata$ { export type Outbound = Metadata$Outbound; } +export function metadataToJSON(metadata: Metadata): string { + return JSON.stringify(Metadata$outboundSchema.parse(metadata)); +} + +export function metadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Metadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Metadata' from JSON`, + ); +} + /** @internal */ export const AssistantObject$inboundSchema: z.ZodType< AssistantObject, @@ -500,3 +583,19 @@ export namespace AssistantObject$ { /** @deprecated use `AssistantObject$Outbound` instead. */ export type Outbound = AssistantObject$Outbound; } + +export function assistantObjectToJSON( + assistantObject: AssistantObject, +): string { + return JSON.stringify(AssistantObject$outboundSchema.parse(assistantObject)); +} + +export function assistantObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantObject' from JSON`, + ); +} diff --git a/src/models/components/assistantsapiresponseformatoption.ts b/src/models/components/assistantsapiresponseformatoption.ts index e36dd21..0ab5987 100644 --- a/src/models/components/assistantsapiresponseformatoption.ts +++ b/src/models/components/assistantsapiresponseformatoption.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ResponseFormatJsonObject, ResponseFormatJsonObject$inboundSchema, @@ -123,3 +126,23 @@ export namespace AssistantsApiResponseFormatOption$ { /** @deprecated use `AssistantsApiResponseFormatOption$Outbound` instead. */ export type Outbound = AssistantsApiResponseFormatOption$Outbound; } + +export function assistantsApiResponseFormatOptionToJSON( + assistantsApiResponseFormatOption: AssistantsApiResponseFormatOption, +): string { + return JSON.stringify( + AssistantsApiResponseFormatOption$outboundSchema.parse( + assistantsApiResponseFormatOption, + ), + ); +} + +export function assistantsApiResponseFormatOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantsApiResponseFormatOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantsApiResponseFormatOption' from JSON`, + ); +} diff --git a/src/models/components/assistantsapitoolchoiceoption.ts b/src/models/components/assistantsapitoolchoiceoption.ts index 7562c92..f290d23 100644 --- a/src/models/components/assistantsapitoolchoiceoption.ts +++ b/src/models/components/assistantsapitoolchoiceoption.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsNamedToolChoice, AssistantsNamedToolChoice$inboundSchema, @@ -101,3 +104,23 @@ export namespace AssistantsApiToolChoiceOption$ { /** @deprecated use `AssistantsApiToolChoiceOption$Outbound` instead. */ export type Outbound = AssistantsApiToolChoiceOption$Outbound; } + +export function assistantsApiToolChoiceOptionToJSON( + assistantsApiToolChoiceOption: AssistantsApiToolChoiceOption, +): string { + return JSON.stringify( + AssistantsApiToolChoiceOption$outboundSchema.parse( + assistantsApiToolChoiceOption, + ), + ); +} + +export function assistantsApiToolChoiceOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantsApiToolChoiceOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantsApiToolChoiceOption' from JSON`, + ); +} diff --git a/src/models/components/assistantsnamedtoolchoice.ts b/src/models/components/assistantsnamedtoolchoice.ts index eca4dea..f6a04ed 100644 --- a/src/models/components/assistantsnamedtoolchoice.ts +++ b/src/models/components/assistantsnamedtoolchoice.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the tool. If type is `function`, the function name must be set @@ -96,6 +99,26 @@ export namespace AssistantsNamedToolChoiceFunction$ { export type Outbound = AssistantsNamedToolChoiceFunction$Outbound; } +export function assistantsNamedToolChoiceFunctionToJSON( + assistantsNamedToolChoiceFunction: AssistantsNamedToolChoiceFunction, +): string { + return JSON.stringify( + AssistantsNamedToolChoiceFunction$outboundSchema.parse( + assistantsNamedToolChoiceFunction, + ), + ); +} + +export function assistantsNamedToolChoiceFunctionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantsNamedToolChoiceFunction$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantsNamedToolChoiceFunction' from JSON`, + ); +} + /** @internal */ export const AssistantsNamedToolChoice$inboundSchema: z.ZodType< AssistantsNamedToolChoice, @@ -136,3 +159,21 @@ export namespace AssistantsNamedToolChoice$ { /** @deprecated use `AssistantsNamedToolChoice$Outbound` instead. */ export type Outbound = AssistantsNamedToolChoice$Outbound; } + +export function assistantsNamedToolChoiceToJSON( + assistantsNamedToolChoice: AssistantsNamedToolChoice, +): string { + return JSON.stringify( + AssistantsNamedToolChoice$outboundSchema.parse(assistantsNamedToolChoice), + ); +} + +export function assistantsNamedToolChoiceFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantsNamedToolChoice$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantsNamedToolChoice' from JSON`, + ); +} diff --git a/src/models/components/assistanttoolscode.ts b/src/models/components/assistanttoolscode.ts index 2951273..67d699c 100644 --- a/src/models/components/assistanttoolscode.ts +++ b/src/models/components/assistanttoolscode.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of tool being defined: `code_interpreter` @@ -79,3 +82,21 @@ export namespace AssistantToolsCode$ { /** @deprecated use `AssistantToolsCode$Outbound` instead. */ export type Outbound = AssistantToolsCode$Outbound; } + +export function assistantToolsCodeToJSON( + assistantToolsCode: AssistantToolsCode, +): string { + return JSON.stringify( + AssistantToolsCode$outboundSchema.parse(assistantToolsCode), + ); +} + +export function assistantToolsCodeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantToolsCode$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantToolsCode' from JSON`, + ); +} diff --git a/src/models/components/assistanttoolsfilesearch.ts b/src/models/components/assistanttoolsfilesearch.ts index 2cfb017..6efb1cd 100644 --- a/src/models/components/assistanttoolsfilesearch.ts +++ b/src/models/components/assistanttoolsfilesearch.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FileSearchRankingOptions, FileSearchRankingOptions$inboundSchema, @@ -128,6 +131,20 @@ export namespace FileSearch$ { export type Outbound = FileSearch$Outbound; } +export function fileSearchToJSON(fileSearch: FileSearch): string { + return JSON.stringify(FileSearch$outboundSchema.parse(fileSearch)); +} + +export function fileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearch' from JSON`, + ); +} + /** @internal */ export const AssistantToolsFileSearch$inboundSchema: z.ZodType< AssistantToolsFileSearch, @@ -174,3 +191,21 @@ export namespace AssistantToolsFileSearch$ { /** @deprecated use `AssistantToolsFileSearch$Outbound` instead. */ export type Outbound = AssistantToolsFileSearch$Outbound; } + +export function assistantToolsFileSearchToJSON( + assistantToolsFileSearch: AssistantToolsFileSearch, +): string { + return JSON.stringify( + AssistantToolsFileSearch$outboundSchema.parse(assistantToolsFileSearch), + ); +} + +export function assistantToolsFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantToolsFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantToolsFileSearch' from JSON`, + ); +} diff --git a/src/models/components/assistanttoolsfilesearchtypeonly.ts b/src/models/components/assistanttoolsfilesearchtypeonly.ts index fa7bc41..42f3b7f 100644 --- a/src/models/components/assistanttoolsfilesearchtypeonly.ts +++ b/src/models/components/assistanttoolsfilesearchtypeonly.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of tool being defined: `file_search` @@ -84,3 +87,23 @@ export namespace AssistantToolsFileSearchTypeOnly$ { /** @deprecated use `AssistantToolsFileSearchTypeOnly$Outbound` instead. */ export type Outbound = AssistantToolsFileSearchTypeOnly$Outbound; } + +export function assistantToolsFileSearchTypeOnlyToJSON( + assistantToolsFileSearchTypeOnly: AssistantToolsFileSearchTypeOnly, +): string { + return JSON.stringify( + AssistantToolsFileSearchTypeOnly$outboundSchema.parse( + assistantToolsFileSearchTypeOnly, + ), + ); +} + +export function assistantToolsFileSearchTypeOnlyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantToolsFileSearchTypeOnly$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantToolsFileSearchTypeOnly' from JSON`, + ); +} diff --git a/src/models/components/assistanttoolsfunction.ts b/src/models/components/assistanttoolsfunction.ts index 090fa28..78f8b87 100644 --- a/src/models/components/assistanttoolsfunction.ts +++ b/src/models/components/assistanttoolsfunction.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FunctionObject, FunctionObject$inboundSchema, @@ -91,3 +94,21 @@ export namespace AssistantToolsFunction$ { /** @deprecated use `AssistantToolsFunction$Outbound` instead. */ export type Outbound = AssistantToolsFunction$Outbound; } + +export function assistantToolsFunctionToJSON( + assistantToolsFunction: AssistantToolsFunction, +): string { + return JSON.stringify( + AssistantToolsFunction$outboundSchema.parse(assistantToolsFunction), + ); +} + +export function assistantToolsFunctionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AssistantToolsFunction$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AssistantToolsFunction' from JSON`, + ); +} diff --git a/src/models/components/auditlog.ts b/src/models/components/auditlog.ts index 7fa137b..eabf54d 100644 --- a/src/models/components/auditlog.ts +++ b/src/models/components/auditlog.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditLogActor, AuditLogActor$inboundSchema, @@ -523,6 +526,22 @@ export namespace AuditLogProject$ { export type Outbound = AuditLogProject$Outbound; } +export function auditLogProjectToJSON( + auditLogProject: AuditLogProject, +): string { + return JSON.stringify(AuditLogProject$outboundSchema.parse(auditLogProject)); +} + +export function auditLogProjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogProject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogProject' from JSON`, + ); +} + /** @internal */ export const AuditLogData$inboundSchema: z.ZodType< AuditLogData, @@ -559,6 +578,20 @@ export namespace AuditLogData$ { export type Outbound = AuditLogData$Outbound; } +export function auditLogDataToJSON(auditLogData: AuditLogData): string { + return JSON.stringify(AuditLogData$outboundSchema.parse(auditLogData)); +} + +export function auditLogDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogData' from JSON`, + ); +} + /** @internal */ export const ApiKeyCreated$inboundSchema: z.ZodType< ApiKeyCreated, @@ -598,6 +631,20 @@ export namespace ApiKeyCreated$ { export type Outbound = ApiKeyCreated$Outbound; } +export function apiKeyCreatedToJSON(apiKeyCreated: ApiKeyCreated): string { + return JSON.stringify(ApiKeyCreated$outboundSchema.parse(apiKeyCreated)); +} + +export function apiKeyCreatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ApiKeyCreated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ApiKeyCreated' from JSON`, + ); +} + /** @internal */ export const ChangesRequested$inboundSchema: z.ZodType< ChangesRequested, @@ -634,6 +681,24 @@ export namespace ChangesRequested$ { export type Outbound = ChangesRequested$Outbound; } +export function changesRequestedToJSON( + changesRequested: ChangesRequested, +): string { + return JSON.stringify( + ChangesRequested$outboundSchema.parse(changesRequested), + ); +} + +export function changesRequestedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChangesRequested$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChangesRequested' from JSON`, + ); +} + /** @internal */ export const ApiKeyUpdated$inboundSchema: z.ZodType< ApiKeyUpdated, @@ -681,6 +746,20 @@ export namespace ApiKeyUpdated$ { export type Outbound = ApiKeyUpdated$Outbound; } +export function apiKeyUpdatedToJSON(apiKeyUpdated: ApiKeyUpdated): string { + return JSON.stringify(ApiKeyUpdated$outboundSchema.parse(apiKeyUpdated)); +} + +export function apiKeyUpdatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ApiKeyUpdated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ApiKeyUpdated' from JSON`, + ); +} + /** @internal */ export const ApiKeyDeleted$inboundSchema: z.ZodType< ApiKeyDeleted, @@ -717,6 +796,20 @@ export namespace ApiKeyDeleted$ { export type Outbound = ApiKeyDeleted$Outbound; } +export function apiKeyDeletedToJSON(apiKeyDeleted: ApiKeyDeleted): string { + return JSON.stringify(ApiKeyDeleted$outboundSchema.parse(apiKeyDeleted)); +} + +export function apiKeyDeletedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ApiKeyDeleted$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ApiKeyDeleted' from JSON`, + ); +} + /** @internal */ export const AuditLogInviteSentData$inboundSchema: z.ZodType< AuditLogInviteSentData, @@ -756,6 +849,24 @@ export namespace AuditLogInviteSentData$ { export type Outbound = AuditLogInviteSentData$Outbound; } +export function auditLogInviteSentDataToJSON( + auditLogInviteSentData: AuditLogInviteSentData, +): string { + return JSON.stringify( + AuditLogInviteSentData$outboundSchema.parse(auditLogInviteSentData), + ); +} + +export function auditLogInviteSentDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogInviteSentData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogInviteSentData' from JSON`, + ); +} + /** @internal */ export const InviteSent$inboundSchema: z.ZodType< InviteSent, @@ -795,6 +906,20 @@ export namespace InviteSent$ { export type Outbound = InviteSent$Outbound; } +export function inviteSentToJSON(inviteSent: InviteSent): string { + return JSON.stringify(InviteSent$outboundSchema.parse(inviteSent)); +} + +export function inviteSentFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteSent$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteSent' from JSON`, + ); +} + /** @internal */ export const InviteAccepted$inboundSchema: z.ZodType< InviteAccepted, @@ -831,6 +956,20 @@ export namespace InviteAccepted$ { export type Outbound = InviteAccepted$Outbound; } +export function inviteAcceptedToJSON(inviteAccepted: InviteAccepted): string { + return JSON.stringify(InviteAccepted$outboundSchema.parse(inviteAccepted)); +} + +export function inviteAcceptedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteAccepted$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteAccepted' from JSON`, + ); +} + /** @internal */ export const InviteDeleted$inboundSchema: z.ZodType< InviteDeleted, @@ -867,6 +1006,20 @@ export namespace InviteDeleted$ { export type Outbound = InviteDeleted$Outbound; } +export function inviteDeletedToJSON(inviteDeleted: InviteDeleted): string { + return JSON.stringify(InviteDeleted$outboundSchema.parse(inviteDeleted)); +} + +export function inviteDeletedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteDeleted$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteDeleted' from JSON`, + ); +} + /** @internal */ export const LoginFailed$inboundSchema: z.ZodType< LoginFailed, @@ -916,6 +1069,20 @@ export namespace LoginFailed$ { export type Outbound = LoginFailed$Outbound; } +export function loginFailedToJSON(loginFailed: LoginFailed): string { + return JSON.stringify(LoginFailed$outboundSchema.parse(loginFailed)); +} + +export function loginFailedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => LoginFailed$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'LoginFailed' from JSON`, + ); +} + /** @internal */ export const LogoutFailed$inboundSchema: z.ZodType< LogoutFailed, @@ -965,6 +1132,20 @@ export namespace LogoutFailed$ { export type Outbound = LogoutFailed$Outbound; } +export function logoutFailedToJSON(logoutFailed: LogoutFailed): string { + return JSON.stringify(LogoutFailed$outboundSchema.parse(logoutFailed)); +} + +export function logoutFailedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => LogoutFailed$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'LogoutFailed' from JSON`, + ); +} + /** @internal */ export const Settings$inboundSchema: z.ZodType< Settings, @@ -1014,6 +1195,20 @@ export namespace Settings$ { export type Outbound = Settings$Outbound; } +export function settingsToJSON(settings: Settings): string { + return JSON.stringify(Settings$outboundSchema.parse(settings)); +} + +export function settingsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Settings$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Settings' from JSON`, + ); +} + /** @internal */ export const AuditLogChangesRequested$inboundSchema: z.ZodType< AuditLogChangesRequested, @@ -1059,6 +1254,24 @@ export namespace AuditLogChangesRequested$ { export type Outbound = AuditLogChangesRequested$Outbound; } +export function auditLogChangesRequestedToJSON( + auditLogChangesRequested: AuditLogChangesRequested, +): string { + return JSON.stringify( + AuditLogChangesRequested$outboundSchema.parse(auditLogChangesRequested), + ); +} + +export function auditLogChangesRequestedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogChangesRequested$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogChangesRequested' from JSON`, + ); +} + /** @internal */ export const OrganizationUpdated$inboundSchema: z.ZodType< OrganizationUpdated, @@ -1108,6 +1321,24 @@ export namespace OrganizationUpdated$ { export type Outbound = OrganizationUpdated$Outbound; } +export function organizationUpdatedToJSON( + organizationUpdated: OrganizationUpdated, +): string { + return JSON.stringify( + OrganizationUpdated$outboundSchema.parse(organizationUpdated), + ); +} + +export function organizationUpdatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => OrganizationUpdated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'OrganizationUpdated' from JSON`, + ); +} + /** @internal */ export const AuditLogProjectCreatedData$inboundSchema: z.ZodType< AuditLogProjectCreatedData, @@ -1147,6 +1378,24 @@ export namespace AuditLogProjectCreatedData$ { export type Outbound = AuditLogProjectCreatedData$Outbound; } +export function auditLogProjectCreatedDataToJSON( + auditLogProjectCreatedData: AuditLogProjectCreatedData, +): string { + return JSON.stringify( + AuditLogProjectCreatedData$outboundSchema.parse(auditLogProjectCreatedData), + ); +} + +export function auditLogProjectCreatedDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogProjectCreatedData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogProjectCreatedData' from JSON`, + ); +} + /** @internal */ export const ProjectCreated$inboundSchema: z.ZodType< ProjectCreated, @@ -1186,6 +1435,20 @@ export namespace ProjectCreated$ { export type Outbound = ProjectCreated$Outbound; } +export function projectCreatedToJSON(projectCreated: ProjectCreated): string { + return JSON.stringify(ProjectCreated$outboundSchema.parse(projectCreated)); +} + +export function projectCreatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectCreated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectCreated' from JSON`, + ); +} + /** @internal */ export const AuditLogProjectUpdatedChangesRequested$inboundSchema: z.ZodType< AuditLogProjectUpdatedChangesRequested, @@ -1224,6 +1487,28 @@ export namespace AuditLogProjectUpdatedChangesRequested$ { export type Outbound = AuditLogProjectUpdatedChangesRequested$Outbound; } +export function auditLogProjectUpdatedChangesRequestedToJSON( + auditLogProjectUpdatedChangesRequested: + AuditLogProjectUpdatedChangesRequested, +): string { + return JSON.stringify( + AuditLogProjectUpdatedChangesRequested$outboundSchema.parse( + auditLogProjectUpdatedChangesRequested, + ), + ); +} + +export function auditLogProjectUpdatedChangesRequestedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + AuditLogProjectUpdatedChangesRequested$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogProjectUpdatedChangesRequested' from JSON`, + ); +} + /** @internal */ export const ProjectUpdated$inboundSchema: z.ZodType< ProjectUpdated, @@ -1277,6 +1562,20 @@ export namespace ProjectUpdated$ { export type Outbound = ProjectUpdated$Outbound; } +export function projectUpdatedToJSON(projectUpdated: ProjectUpdated): string { + return JSON.stringify(ProjectUpdated$outboundSchema.parse(projectUpdated)); +} + +export function projectUpdatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUpdated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUpdated' from JSON`, + ); +} + /** @internal */ export const ProjectArchived$inboundSchema: z.ZodType< ProjectArchived, @@ -1313,6 +1612,22 @@ export namespace ProjectArchived$ { export type Outbound = ProjectArchived$Outbound; } +export function projectArchivedToJSON( + projectArchived: ProjectArchived, +): string { + return JSON.stringify(ProjectArchived$outboundSchema.parse(projectArchived)); +} + +export function projectArchivedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectArchived$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectArchived' from JSON`, + ); +} + /** @internal */ export const AuditLogServiceAccountCreatedData$inboundSchema: z.ZodType< AuditLogServiceAccountCreatedData, @@ -1350,6 +1665,26 @@ export namespace AuditLogServiceAccountCreatedData$ { export type Outbound = AuditLogServiceAccountCreatedData$Outbound; } +export function auditLogServiceAccountCreatedDataToJSON( + auditLogServiceAccountCreatedData: AuditLogServiceAccountCreatedData, +): string { + return JSON.stringify( + AuditLogServiceAccountCreatedData$outboundSchema.parse( + auditLogServiceAccountCreatedData, + ), + ); +} + +export function auditLogServiceAccountCreatedDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogServiceAccountCreatedData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogServiceAccountCreatedData' from JSON`, + ); +} + /** @internal */ export const ServiceAccountCreated$inboundSchema: z.ZodType< ServiceAccountCreated, @@ -1391,6 +1726,24 @@ export namespace ServiceAccountCreated$ { export type Outbound = ServiceAccountCreated$Outbound; } +export function serviceAccountCreatedToJSON( + serviceAccountCreated: ServiceAccountCreated, +): string { + return JSON.stringify( + ServiceAccountCreated$outboundSchema.parse(serviceAccountCreated), + ); +} + +export function serviceAccountCreatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServiceAccountCreated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServiceAccountCreated' from JSON`, + ); +} + /** @internal */ export const AuditLogServiceAccountUpdatedChangesRequested$inboundSchema: z.ZodType< @@ -1431,6 +1784,33 @@ export namespace AuditLogServiceAccountUpdatedChangesRequested$ { export type Outbound = AuditLogServiceAccountUpdatedChangesRequested$Outbound; } +export function auditLogServiceAccountUpdatedChangesRequestedToJSON( + auditLogServiceAccountUpdatedChangesRequested: + AuditLogServiceAccountUpdatedChangesRequested, +): string { + return JSON.stringify( + AuditLogServiceAccountUpdatedChangesRequested$outboundSchema.parse( + auditLogServiceAccountUpdatedChangesRequested, + ), + ); +} + +export function auditLogServiceAccountUpdatedChangesRequestedFromJSON( + jsonString: string, +): SafeParseResult< + AuditLogServiceAccountUpdatedChangesRequested, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + AuditLogServiceAccountUpdatedChangesRequested$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'AuditLogServiceAccountUpdatedChangesRequested' from JSON`, + ); +} + /** @internal */ export const ServiceAccountUpdated$inboundSchema: z.ZodType< ServiceAccountUpdated, @@ -1484,6 +1864,24 @@ export namespace ServiceAccountUpdated$ { export type Outbound = ServiceAccountUpdated$Outbound; } +export function serviceAccountUpdatedToJSON( + serviceAccountUpdated: ServiceAccountUpdated, +): string { + return JSON.stringify( + ServiceAccountUpdated$outboundSchema.parse(serviceAccountUpdated), + ); +} + +export function serviceAccountUpdatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServiceAccountUpdated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServiceAccountUpdated' from JSON`, + ); +} + /** @internal */ export const ServiceAccountDeleted$inboundSchema: z.ZodType< ServiceAccountDeleted, @@ -1520,6 +1918,24 @@ export namespace ServiceAccountDeleted$ { export type Outbound = ServiceAccountDeleted$Outbound; } +export function serviceAccountDeletedToJSON( + serviceAccountDeleted: ServiceAccountDeleted, +): string { + return JSON.stringify( + ServiceAccountDeleted$outboundSchema.parse(serviceAccountDeleted), + ); +} + +export function serviceAccountDeletedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ServiceAccountDeleted$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ServiceAccountDeleted' from JSON`, + ); +} + /** @internal */ export const AuditLogUserAddedData$inboundSchema: z.ZodType< AuditLogUserAddedData, @@ -1556,6 +1972,24 @@ export namespace AuditLogUserAddedData$ { export type Outbound = AuditLogUserAddedData$Outbound; } +export function auditLogUserAddedDataToJSON( + auditLogUserAddedData: AuditLogUserAddedData, +): string { + return JSON.stringify( + AuditLogUserAddedData$outboundSchema.parse(auditLogUserAddedData), + ); +} + +export function auditLogUserAddedDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogUserAddedData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogUserAddedData' from JSON`, + ); +} + /** @internal */ export const UserAdded$inboundSchema: z.ZodType< UserAdded, @@ -1595,6 +2029,20 @@ export namespace UserAdded$ { export type Outbound = UserAdded$Outbound; } +export function userAddedToJSON(userAdded: UserAdded): string { + return JSON.stringify(UserAdded$outboundSchema.parse(userAdded)); +} + +export function userAddedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserAdded$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserAdded' from JSON`, + ); +} + /** @internal */ export const AuditLogUserUpdatedChangesRequested$inboundSchema: z.ZodType< AuditLogUserUpdatedChangesRequested, @@ -1633,6 +2081,27 @@ export namespace AuditLogUserUpdatedChangesRequested$ { export type Outbound = AuditLogUserUpdatedChangesRequested$Outbound; } +export function auditLogUserUpdatedChangesRequestedToJSON( + auditLogUserUpdatedChangesRequested: AuditLogUserUpdatedChangesRequested, +): string { + return JSON.stringify( + AuditLogUserUpdatedChangesRequested$outboundSchema.parse( + auditLogUserUpdatedChangesRequested, + ), + ); +} + +export function auditLogUserUpdatedChangesRequestedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + AuditLogUserUpdatedChangesRequested$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogUserUpdatedChangesRequested' from JSON`, + ); +} + /** @internal */ export const UserUpdated$inboundSchema: z.ZodType< UserUpdated, @@ -1684,6 +2153,20 @@ export namespace UserUpdated$ { export type Outbound = UserUpdated$Outbound; } +export function userUpdatedToJSON(userUpdated: UserUpdated): string { + return JSON.stringify(UserUpdated$outboundSchema.parse(userUpdated)); +} + +export function userUpdatedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserUpdated$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserUpdated' from JSON`, + ); +} + /** @internal */ export const UserDeleted$inboundSchema: z.ZodType< UserDeleted, @@ -1720,6 +2203,20 @@ export namespace UserDeleted$ { export type Outbound = UserDeleted$Outbound; } +export function userDeletedToJSON(userDeleted: UserDeleted): string { + return JSON.stringify(UserDeleted$outboundSchema.parse(userDeleted)); +} + +export function userDeletedFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserDeleted$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserDeleted' from JSON`, + ); +} + /** @internal */ export const AuditLog$inboundSchema: z.ZodType< AuditLog, @@ -1873,3 +2370,17 @@ export namespace AuditLog$ { /** @deprecated use `AuditLog$Outbound` instead. */ export type Outbound = AuditLog$Outbound; } + +export function auditLogToJSON(auditLog: AuditLog): string { + return JSON.stringify(AuditLog$outboundSchema.parse(auditLog)); +} + +export function auditLogFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLog$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLog' from JSON`, + ); +} diff --git a/src/models/components/auditlogactor.ts b/src/models/components/auditlogactor.ts index 871113a..a693052 100644 --- a/src/models/components/auditlogactor.ts +++ b/src/models/components/auditlogactor.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditLogActorApiKey, AuditLogActorApiKey$inboundSchema, @@ -118,3 +121,17 @@ export namespace AuditLogActor$ { /** @deprecated use `AuditLogActor$Outbound` instead. */ export type Outbound = AuditLogActor$Outbound; } + +export function auditLogActorToJSON(auditLogActor: AuditLogActor): string { + return JSON.stringify(AuditLogActor$outboundSchema.parse(auditLogActor)); +} + +export function auditLogActorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogActor$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogActor' from JSON`, + ); +} diff --git a/src/models/components/auditlogactorapikey.ts b/src/models/components/auditlogactorapikey.ts index be23c96..68e6e93 100644 --- a/src/models/components/auditlogactorapikey.ts +++ b/src/models/components/auditlogactorapikey.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditLogActorServiceAccount, AuditLogActorServiceAccount$inboundSchema, @@ -127,3 +130,21 @@ export namespace AuditLogActorApiKey$ { /** @deprecated use `AuditLogActorApiKey$Outbound` instead. */ export type Outbound = AuditLogActorApiKey$Outbound; } + +export function auditLogActorApiKeyToJSON( + auditLogActorApiKey: AuditLogActorApiKey, +): string { + return JSON.stringify( + AuditLogActorApiKey$outboundSchema.parse(auditLogActorApiKey), + ); +} + +export function auditLogActorApiKeyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogActorApiKey$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogActorApiKey' from JSON`, + ); +} diff --git a/src/models/components/auditlogactorserviceaccount.ts b/src/models/components/auditlogactorserviceaccount.ts index 2863449..840060a 100644 --- a/src/models/components/auditlogactorserviceaccount.ts +++ b/src/models/components/auditlogactorserviceaccount.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The service account that performed the audit logged action. @@ -49,3 +52,23 @@ export namespace AuditLogActorServiceAccount$ { /** @deprecated use `AuditLogActorServiceAccount$Outbound` instead. */ export type Outbound = AuditLogActorServiceAccount$Outbound; } + +export function auditLogActorServiceAccountToJSON( + auditLogActorServiceAccount: AuditLogActorServiceAccount, +): string { + return JSON.stringify( + AuditLogActorServiceAccount$outboundSchema.parse( + auditLogActorServiceAccount, + ), + ); +} + +export function auditLogActorServiceAccountFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogActorServiceAccount$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogActorServiceAccount' from JSON`, + ); +} diff --git a/src/models/components/auditlogactorsession.ts b/src/models/components/auditlogactorsession.ts index 781057b..75112a9 100644 --- a/src/models/components/auditlogactorsession.ts +++ b/src/models/components/auditlogactorsession.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditLogActorUser, AuditLogActorUser$inboundSchema, @@ -71,3 +74,21 @@ export namespace AuditLogActorSession$ { /** @deprecated use `AuditLogActorSession$Outbound` instead. */ export type Outbound = AuditLogActorSession$Outbound; } + +export function auditLogActorSessionToJSON( + auditLogActorSession: AuditLogActorSession, +): string { + return JSON.stringify( + AuditLogActorSession$outboundSchema.parse(auditLogActorSession), + ); +} + +export function auditLogActorSessionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogActorSession$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogActorSession' from JSON`, + ); +} diff --git a/src/models/components/auditlogactoruser.ts b/src/models/components/auditlogactoruser.ts index debcf8c..4a4b19a 100644 --- a/src/models/components/auditlogactoruser.ts +++ b/src/models/components/auditlogactoruser.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The user who performed the audit logged action. @@ -56,3 +59,21 @@ export namespace AuditLogActorUser$ { /** @deprecated use `AuditLogActorUser$Outbound` instead. */ export type Outbound = AuditLogActorUser$Outbound; } + +export function auditLogActorUserToJSON( + auditLogActorUser: AuditLogActorUser, +): string { + return JSON.stringify( + AuditLogActorUser$outboundSchema.parse(auditLogActorUser), + ); +} + +export function auditLogActorUserFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AuditLogActorUser$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AuditLogActorUser' from JSON`, + ); +} diff --git a/src/models/components/autochunkingstrategyrequestparam.ts b/src/models/components/autochunkingstrategyrequestparam.ts index 9c8a96b..bc3dfff 100644 --- a/src/models/components/autochunkingstrategyrequestparam.ts +++ b/src/models/components/autochunkingstrategyrequestparam.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `auto`. @@ -87,3 +90,23 @@ export namespace AutoChunkingStrategyRequestParam$ { /** @deprecated use `AutoChunkingStrategyRequestParam$Outbound` instead. */ export type Outbound = AutoChunkingStrategyRequestParam$Outbound; } + +export function autoChunkingStrategyRequestParamToJSON( + autoChunkingStrategyRequestParam: AutoChunkingStrategyRequestParam, +): string { + return JSON.stringify( + AutoChunkingStrategyRequestParam$outboundSchema.parse( + autoChunkingStrategyRequestParam, + ), + ); +} + +export function autoChunkingStrategyRequestParamFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AutoChunkingStrategyRequestParam$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AutoChunkingStrategyRequestParam' from JSON`, + ); +} diff --git a/src/models/components/batch.ts b/src/models/components/batch.ts index 842294d..8a53945 100644 --- a/src/models/components/batch.ts +++ b/src/models/components/batch.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `batch`. @@ -230,6 +233,20 @@ export namespace BatchData$ { export type Outbound = BatchData$Outbound; } +export function batchDataToJSON(batchData: BatchData): string { + return JSON.stringify(BatchData$outboundSchema.parse(batchData)); +} + +export function batchDataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchData$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchData' from JSON`, + ); +} + /** @internal */ export const Errors$inboundSchema: z.ZodType = z .object({ @@ -266,6 +283,20 @@ export namespace Errors$ { export type Outbound = Errors$Outbound; } +export function errorsToJSON(errors: Errors): string { + return JSON.stringify(Errors$outboundSchema.parse(errors)); +} + +export function errorsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Errors$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Errors' from JSON`, + ); +} + /** @internal */ export const BatchStatus$inboundSchema: z.ZodNativeEnum = z .nativeEnum(BatchStatus); @@ -327,6 +358,20 @@ export namespace RequestCounts$ { export type Outbound = RequestCounts$Outbound; } +export function requestCountsToJSON(requestCounts: RequestCounts): string { + return JSON.stringify(RequestCounts$outboundSchema.parse(requestCounts)); +} + +export function requestCountsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RequestCounts$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RequestCounts' from JSON`, + ); +} + /** @internal */ export const BatchMetadata$inboundSchema: z.ZodType< BatchMetadata, @@ -357,6 +402,20 @@ export namespace BatchMetadata$ { export type Outbound = BatchMetadata$Outbound; } +export function batchMetadataToJSON(batchMetadata: BatchMetadata): string { + return JSON.stringify(BatchMetadata$outboundSchema.parse(batchMetadata)); +} + +export function batchMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchMetadata' from JSON`, + ); +} + /** @internal */ export const Batch$inboundSchema: z.ZodType = z .object({ @@ -480,3 +539,17 @@ export namespace Batch$ { /** @deprecated use `Batch$Outbound` instead. */ export type Outbound = Batch$Outbound; } + +export function batchToJSON(batch: Batch): string { + return JSON.stringify(Batch$outboundSchema.parse(batch)); +} + +export function batchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Batch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Batch' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionfunctioncalloption.ts b/src/models/components/chatcompletionfunctioncalloption.ts index 0fe3c21..f3f2d11 100644 --- a/src/models/components/chatcompletionfunctioncalloption.ts +++ b/src/models/components/chatcompletionfunctioncalloption.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Specifying a particular function via `{"name": "my_function"}` forces the model to call that function. @@ -51,3 +54,23 @@ export namespace ChatCompletionFunctionCallOption$ { /** @deprecated use `ChatCompletionFunctionCallOption$Outbound` instead. */ export type Outbound = ChatCompletionFunctionCallOption$Outbound; } + +export function chatCompletionFunctionCallOptionToJSON( + chatCompletionFunctionCallOption: ChatCompletionFunctionCallOption, +): string { + return JSON.stringify( + ChatCompletionFunctionCallOption$outboundSchema.parse( + chatCompletionFunctionCallOption, + ), + ); +} + +export function chatCompletionFunctionCallOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionFunctionCallOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionFunctionCallOption' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionfunctions.ts b/src/models/components/chatcompletionfunctions.ts index 8067b65..775ea9b 100644 --- a/src/models/components/chatcompletionfunctions.ts +++ b/src/models/components/chatcompletionfunctions.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. @@ -67,3 +70,21 @@ export namespace ChatCompletionFunctions$ { /** @deprecated use `ChatCompletionFunctions$Outbound` instead. */ export type Outbound = ChatCompletionFunctions$Outbound; } + +export function chatCompletionFunctionsToJSON( + chatCompletionFunctions: ChatCompletionFunctions, +): string { + return JSON.stringify( + ChatCompletionFunctions$outboundSchema.parse(chatCompletionFunctions), + ); +} + +export function chatCompletionFunctionsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionFunctions$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionFunctions' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionmessagetoolcall.ts b/src/models/components/chatcompletionmessagetoolcall.ts index 5f59c89..08880ad 100644 --- a/src/models/components/chatcompletionmessagetoolcall.ts +++ b/src/models/components/chatcompletionmessagetoolcall.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the tool. Currently, only `function` is supported. @@ -108,6 +111,20 @@ export namespace FunctionT$ { export type Outbound = FunctionT$Outbound; } +export function functionToJSON(functionT: FunctionT): string { + return JSON.stringify(FunctionT$outboundSchema.parse(functionT)); +} + +export function functionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FunctionT$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FunctionT' from JSON`, + ); +} + /** @internal */ export const ChatCompletionMessageToolCall$inboundSchema: z.ZodType< ChatCompletionMessageToolCall, @@ -149,3 +166,23 @@ export namespace ChatCompletionMessageToolCall$ { /** @deprecated use `ChatCompletionMessageToolCall$Outbound` instead. */ export type Outbound = ChatCompletionMessageToolCall$Outbound; } + +export function chatCompletionMessageToolCallToJSON( + chatCompletionMessageToolCall: ChatCompletionMessageToolCall, +): string { + return JSON.stringify( + ChatCompletionMessageToolCall$outboundSchema.parse( + chatCompletionMessageToolCall, + ), + ); +} + +export function chatCompletionMessageToolCallFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionMessageToolCall$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionMessageToolCall' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionnamedtoolchoice.ts b/src/models/components/chatcompletionnamedtoolchoice.ts index 17eaf1f..e06c198 100644 --- a/src/models/components/chatcompletionnamedtoolchoice.ts +++ b/src/models/components/chatcompletionnamedtoolchoice.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the tool. Currently, only `function` is supported. @@ -96,6 +99,27 @@ export namespace ChatCompletionNamedToolChoiceFunction$ { export type Outbound = ChatCompletionNamedToolChoiceFunction$Outbound; } +export function chatCompletionNamedToolChoiceFunctionToJSON( + chatCompletionNamedToolChoiceFunction: ChatCompletionNamedToolChoiceFunction, +): string { + return JSON.stringify( + ChatCompletionNamedToolChoiceFunction$outboundSchema.parse( + chatCompletionNamedToolChoiceFunction, + ), + ); +} + +export function chatCompletionNamedToolChoiceFunctionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChatCompletionNamedToolChoiceFunction$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionNamedToolChoiceFunction' from JSON`, + ); +} + /** @internal */ export const ChatCompletionNamedToolChoice$inboundSchema: z.ZodType< ChatCompletionNamedToolChoice, @@ -134,3 +158,23 @@ export namespace ChatCompletionNamedToolChoice$ { /** @deprecated use `ChatCompletionNamedToolChoice$Outbound` instead. */ export type Outbound = ChatCompletionNamedToolChoice$Outbound; } + +export function chatCompletionNamedToolChoiceToJSON( + chatCompletionNamedToolChoice: ChatCompletionNamedToolChoice, +): string { + return JSON.stringify( + ChatCompletionNamedToolChoice$outboundSchema.parse( + chatCompletionNamedToolChoice, + ), + ); +} + +export function chatCompletionNamedToolChoiceFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionNamedToolChoice$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionNamedToolChoice' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestassistantmessage.ts b/src/models/components/chatcompletionrequestassistantmessage.ts index a01ce79..a4aa456 100644 --- a/src/models/components/chatcompletionrequestassistantmessage.ts +++ b/src/models/components/chatcompletionrequestassistantmessage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionMessageToolCall, ChatCompletionMessageToolCall$inboundSchema, @@ -133,6 +136,33 @@ export namespace ChatCompletionRequestAssistantMessageContent$ { export type Outbound = ChatCompletionRequestAssistantMessageContent$Outbound; } +export function chatCompletionRequestAssistantMessageContentToJSON( + chatCompletionRequestAssistantMessageContent: + ChatCompletionRequestAssistantMessageContent, +): string { + return JSON.stringify( + ChatCompletionRequestAssistantMessageContent$outboundSchema.parse( + chatCompletionRequestAssistantMessageContent, + ), + ); +} + +export function chatCompletionRequestAssistantMessageContentFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestAssistantMessageContent, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestAssistantMessageContent$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestAssistantMessageContent' from JSON`, + ); +} + /** @internal */ export const ChatCompletionRequestAssistantMessageRole$inboundSchema: z.ZodNativeEnum = z @@ -195,6 +225,20 @@ export namespace FunctionCall$ { export type Outbound = FunctionCall$Outbound; } +export function functionCallToJSON(functionCall: FunctionCall): string { + return JSON.stringify(FunctionCall$outboundSchema.parse(functionCall)); +} + +export function functionCallFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FunctionCall$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FunctionCall' from JSON`, + ); +} + /** @internal */ export const ChatCompletionRequestAssistantMessage$inboundSchema: z.ZodType< ChatCompletionRequestAssistantMessage, @@ -273,3 +317,24 @@ export namespace ChatCompletionRequestAssistantMessage$ { /** @deprecated use `ChatCompletionRequestAssistantMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestAssistantMessage$Outbound; } + +export function chatCompletionRequestAssistantMessageToJSON( + chatCompletionRequestAssistantMessage: ChatCompletionRequestAssistantMessage, +): string { + return JSON.stringify( + ChatCompletionRequestAssistantMessage$outboundSchema.parse( + chatCompletionRequestAssistantMessage, + ), + ); +} + +export function chatCompletionRequestAssistantMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestAssistantMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestAssistantMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestassistantmessagecontentpart.ts b/src/models/components/chatcompletionrequestassistantmessagecontentpart.ts index 59199bb..fdfd026 100644 --- a/src/models/components/chatcompletionrequestassistantmessagecontentpart.ts +++ b/src/models/components/chatcompletionrequestassistantmessagecontentpart.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestMessageContentPartRefusal, ChatCompletionRequestMessageContentPartRefusal$inboundSchema, @@ -62,3 +65,30 @@ export namespace ChatCompletionRequestAssistantMessageContentPart$ { export type Outbound = ChatCompletionRequestAssistantMessageContentPart$Outbound; } + +export function chatCompletionRequestAssistantMessageContentPartToJSON( + chatCompletionRequestAssistantMessageContentPart: + ChatCompletionRequestAssistantMessageContentPart, +): string { + return JSON.stringify( + ChatCompletionRequestAssistantMessageContentPart$outboundSchema.parse( + chatCompletionRequestAssistantMessageContentPart, + ), + ); +} + +export function chatCompletionRequestAssistantMessageContentPartFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestAssistantMessageContentPart, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestAssistantMessageContentPart$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestAssistantMessageContentPart' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestfunctionmessage.ts b/src/models/components/chatcompletionrequestfunctionmessage.ts index d695f79..340b327 100644 --- a/src/models/components/chatcompletionrequestfunctionmessage.ts +++ b/src/models/components/chatcompletionrequestfunctionmessage.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The role of the messages author, in this case `function`. @@ -102,3 +105,24 @@ export namespace ChatCompletionRequestFunctionMessage$ { /** @deprecated use `ChatCompletionRequestFunctionMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestFunctionMessage$Outbound; } + +export function chatCompletionRequestFunctionMessageToJSON( + chatCompletionRequestFunctionMessage: ChatCompletionRequestFunctionMessage, +): string { + return JSON.stringify( + ChatCompletionRequestFunctionMessage$outboundSchema.parse( + chatCompletionRequestFunctionMessage, + ), + ); +} + +export function chatCompletionRequestFunctionMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestFunctionMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestFunctionMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestmessage.ts b/src/models/components/chatcompletionrequestmessage.ts index eb4f7d8..3959ad1 100644 --- a/src/models/components/chatcompletionrequestmessage.ts +++ b/src/models/components/chatcompletionrequestmessage.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestAssistantMessage, ChatCompletionRequestAssistantMessage$inboundSchema, @@ -87,3 +90,23 @@ export namespace ChatCompletionRequestMessage$ { /** @deprecated use `ChatCompletionRequestMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestMessage$Outbound; } + +export function chatCompletionRequestMessageToJSON( + chatCompletionRequestMessage: ChatCompletionRequestMessage, +): string { + return JSON.stringify( + ChatCompletionRequestMessage$outboundSchema.parse( + chatCompletionRequestMessage, + ), + ); +} + +export function chatCompletionRequestMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionRequestMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestmessagecontentpartimage.ts b/src/models/components/chatcompletionrequestmessagecontentpartimage.ts index b8b73e9..76fca43 100644 --- a/src/models/components/chatcompletionrequestmessagecontentpartimage.ts +++ b/src/models/components/chatcompletionrequestmessagecontentpartimage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the content part. @@ -132,6 +135,20 @@ export namespace ImageUrl$ { export type Outbound = ImageUrl$Outbound; } +export function imageUrlToJSON(imageUrl: ImageUrl): string { + return JSON.stringify(ImageUrl$outboundSchema.parse(imageUrl)); +} + +export function imageUrlFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ImageUrl$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ImageUrl' from JSON`, + ); +} + /** @internal */ export const ChatCompletionRequestMessageContentPartImage$inboundSchema: z.ZodType< @@ -182,3 +199,30 @@ export namespace ChatCompletionRequestMessageContentPartImage$ { /** @deprecated use `ChatCompletionRequestMessageContentPartImage$Outbound` instead. */ export type Outbound = ChatCompletionRequestMessageContentPartImage$Outbound; } + +export function chatCompletionRequestMessageContentPartImageToJSON( + chatCompletionRequestMessageContentPartImage: + ChatCompletionRequestMessageContentPartImage, +): string { + return JSON.stringify( + ChatCompletionRequestMessageContentPartImage$outboundSchema.parse( + chatCompletionRequestMessageContentPartImage, + ), + ); +} + +export function chatCompletionRequestMessageContentPartImageFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestMessageContentPartImage, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestMessageContentPartImage$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestMessageContentPartImage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestmessagecontentpartrefusal.ts b/src/models/components/chatcompletionrequestmessagecontentpartrefusal.ts index 25e0150..1044528 100644 --- a/src/models/components/chatcompletionrequestmessagecontentpartrefusal.ts +++ b/src/models/components/chatcompletionrequestmessagecontentpartrefusal.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the content part. @@ -95,3 +98,30 @@ export namespace ChatCompletionRequestMessageContentPartRefusal$ { export type Outbound = ChatCompletionRequestMessageContentPartRefusal$Outbound; } + +export function chatCompletionRequestMessageContentPartRefusalToJSON( + chatCompletionRequestMessageContentPartRefusal: + ChatCompletionRequestMessageContentPartRefusal, +): string { + return JSON.stringify( + ChatCompletionRequestMessageContentPartRefusal$outboundSchema.parse( + chatCompletionRequestMessageContentPartRefusal, + ), + ); +} + +export function chatCompletionRequestMessageContentPartRefusalFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestMessageContentPartRefusal, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestMessageContentPartRefusal$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestMessageContentPartRefusal' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestmessagecontentparttext.ts b/src/models/components/chatcompletionrequestmessagecontentparttext.ts index 670475a..7d5274c 100644 --- a/src/models/components/chatcompletionrequestmessagecontentparttext.ts +++ b/src/models/components/chatcompletionrequestmessagecontentparttext.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the content part. @@ -89,3 +92,30 @@ export namespace ChatCompletionRequestMessageContentPartText$ { /** @deprecated use `ChatCompletionRequestMessageContentPartText$Outbound` instead. */ export type Outbound = ChatCompletionRequestMessageContentPartText$Outbound; } + +export function chatCompletionRequestMessageContentPartTextToJSON( + chatCompletionRequestMessageContentPartText: + ChatCompletionRequestMessageContentPartText, +): string { + return JSON.stringify( + ChatCompletionRequestMessageContentPartText$outboundSchema.parse( + chatCompletionRequestMessageContentPartText, + ), + ); +} + +export function chatCompletionRequestMessageContentPartTextFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestMessageContentPartText, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestMessageContentPartText$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestMessageContentPartText' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestsystemmessage.ts b/src/models/components/chatcompletionrequestsystemmessage.ts index 18d548f..1a28042 100644 --- a/src/models/components/chatcompletionrequestsystemmessage.ts +++ b/src/models/components/chatcompletionrequestsystemmessage.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestSystemMessageContentPart, ChatCompletionRequestSystemMessageContentPart$inboundSchema, @@ -79,6 +82,20 @@ export namespace Content$ { export type Outbound = Content$Outbound; } +export function contentToJSON(content: Content): string { + return JSON.stringify(Content$outboundSchema.parse(content)); +} + +export function contentFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Content$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Content' from JSON`, + ); +} + /** @internal */ export const Role$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Role, @@ -149,3 +166,24 @@ export namespace ChatCompletionRequestSystemMessage$ { /** @deprecated use `ChatCompletionRequestSystemMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestSystemMessage$Outbound; } + +export function chatCompletionRequestSystemMessageToJSON( + chatCompletionRequestSystemMessage: ChatCompletionRequestSystemMessage, +): string { + return JSON.stringify( + ChatCompletionRequestSystemMessage$outboundSchema.parse( + chatCompletionRequestSystemMessage, + ), + ); +} + +export function chatCompletionRequestSystemMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestSystemMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestSystemMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestsystemmessagecontentpart.ts b/src/models/components/chatcompletionrequestsystemmessagecontentpart.ts index 1c0d67c..384b2c8 100644 --- a/src/models/components/chatcompletionrequestsystemmessagecontentpart.ts +++ b/src/models/components/chatcompletionrequestsystemmessagecontentpart.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartText$inboundSchema, @@ -47,3 +50,30 @@ export namespace ChatCompletionRequestSystemMessageContentPart$ { /** @deprecated use `ChatCompletionRequestSystemMessageContentPart$Outbound` instead. */ export type Outbound = ChatCompletionRequestSystemMessageContentPart$Outbound; } + +export function chatCompletionRequestSystemMessageContentPartToJSON( + chatCompletionRequestSystemMessageContentPart: + ChatCompletionRequestSystemMessageContentPart, +): string { + return JSON.stringify( + ChatCompletionRequestSystemMessageContentPart$outboundSchema.parse( + chatCompletionRequestSystemMessageContentPart, + ), + ); +} + +export function chatCompletionRequestSystemMessageContentPartFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestSystemMessageContentPart, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestSystemMessageContentPart$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestSystemMessageContentPart' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequesttoolmessage.ts b/src/models/components/chatcompletionrequesttoolmessage.ts index b0aa1af..25ed971 100644 --- a/src/models/components/chatcompletionrequesttoolmessage.ts +++ b/src/models/components/chatcompletionrequesttoolmessage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestToolMessageContentPart, ChatCompletionRequestToolMessageContentPart$inboundSchema, @@ -111,6 +114,33 @@ export namespace ChatCompletionRequestToolMessageContent$ { export type Outbound = ChatCompletionRequestToolMessageContent$Outbound; } +export function chatCompletionRequestToolMessageContentToJSON( + chatCompletionRequestToolMessageContent: + ChatCompletionRequestToolMessageContent, +): string { + return JSON.stringify( + ChatCompletionRequestToolMessageContent$outboundSchema.parse( + chatCompletionRequestToolMessageContent, + ), + ); +} + +export function chatCompletionRequestToolMessageContentFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestToolMessageContent, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestToolMessageContent$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestToolMessageContent' from JSON`, + ); +} + /** @internal */ export const ChatCompletionRequestToolMessage$inboundSchema: z.ZodType< ChatCompletionRequestToolMessage, @@ -166,3 +196,23 @@ export namespace ChatCompletionRequestToolMessage$ { /** @deprecated use `ChatCompletionRequestToolMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestToolMessage$Outbound; } + +export function chatCompletionRequestToolMessageToJSON( + chatCompletionRequestToolMessage: ChatCompletionRequestToolMessage, +): string { + return JSON.stringify( + ChatCompletionRequestToolMessage$outboundSchema.parse( + chatCompletionRequestToolMessage, + ), + ); +} + +export function chatCompletionRequestToolMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionRequestToolMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestToolMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequesttoolmessagecontentpart.ts b/src/models/components/chatcompletionrequesttoolmessagecontentpart.ts index 2fe3bd3..15b0a5b 100644 --- a/src/models/components/chatcompletionrequesttoolmessagecontentpart.ts +++ b/src/models/components/chatcompletionrequesttoolmessagecontentpart.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestMessageContentPartText, ChatCompletionRequestMessageContentPartText$inboundSchema, @@ -47,3 +50,30 @@ export namespace ChatCompletionRequestToolMessageContentPart$ { /** @deprecated use `ChatCompletionRequestToolMessageContentPart$Outbound` instead. */ export type Outbound = ChatCompletionRequestToolMessageContentPart$Outbound; } + +export function chatCompletionRequestToolMessageContentPartToJSON( + chatCompletionRequestToolMessageContentPart: + ChatCompletionRequestToolMessageContentPart, +): string { + return JSON.stringify( + ChatCompletionRequestToolMessageContentPart$outboundSchema.parse( + chatCompletionRequestToolMessageContentPart, + ), + ); +} + +export function chatCompletionRequestToolMessageContentPartFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestToolMessageContentPart, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestToolMessageContentPart$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestToolMessageContentPart' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestusermessage.ts b/src/models/components/chatcompletionrequestusermessage.ts index 13eb297..ce6623f 100644 --- a/src/models/components/chatcompletionrequestusermessage.ts +++ b/src/models/components/chatcompletionrequestusermessage.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestUserMessageContentPart, ChatCompletionRequestUserMessageContentPart$inboundSchema, @@ -90,6 +93,33 @@ export namespace ChatCompletionRequestUserMessageContent$ { export type Outbound = ChatCompletionRequestUserMessageContent$Outbound; } +export function chatCompletionRequestUserMessageContentToJSON( + chatCompletionRequestUserMessageContent: + ChatCompletionRequestUserMessageContent, +): string { + return JSON.stringify( + ChatCompletionRequestUserMessageContent$outboundSchema.parse( + chatCompletionRequestUserMessageContent, + ), + ); +} + +export function chatCompletionRequestUserMessageContentFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestUserMessageContent, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestUserMessageContent$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestUserMessageContent' from JSON`, + ); +} + /** @internal */ export const ChatCompletionRequestUserMessageRole$inboundSchema: z.ZodNativeEnum = z.nativeEnum( @@ -161,3 +191,23 @@ export namespace ChatCompletionRequestUserMessage$ { /** @deprecated use `ChatCompletionRequestUserMessage$Outbound` instead. */ export type Outbound = ChatCompletionRequestUserMessage$Outbound; } + +export function chatCompletionRequestUserMessageToJSON( + chatCompletionRequestUserMessage: ChatCompletionRequestUserMessage, +): string { + return JSON.stringify( + ChatCompletionRequestUserMessage$outboundSchema.parse( + chatCompletionRequestUserMessage, + ), + ); +} + +export function chatCompletionRequestUserMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionRequestUserMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionRequestUserMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionrequestusermessagecontentpart.ts b/src/models/components/chatcompletionrequestusermessagecontentpart.ts index 3d71f3d..6dfa387 100644 --- a/src/models/components/chatcompletionrequestusermessagecontentpart.ts +++ b/src/models/components/chatcompletionrequestusermessagecontentpart.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionRequestMessageContentPartImage, ChatCompletionRequestMessageContentPartImage$inboundSchema, @@ -61,3 +64,30 @@ export namespace ChatCompletionRequestUserMessageContentPart$ { /** @deprecated use `ChatCompletionRequestUserMessageContentPart$Outbound` instead. */ export type Outbound = ChatCompletionRequestUserMessageContentPart$Outbound; } + +export function chatCompletionRequestUserMessageContentPartToJSON( + chatCompletionRequestUserMessageContentPart: + ChatCompletionRequestUserMessageContentPart, +): string { + return JSON.stringify( + ChatCompletionRequestUserMessageContentPart$outboundSchema.parse( + chatCompletionRequestUserMessageContentPart, + ), + ); +} + +export function chatCompletionRequestUserMessageContentPartFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionRequestUserMessageContentPart, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionRequestUserMessageContentPart$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionRequestUserMessageContentPart' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionresponsemessage.ts b/src/models/components/chatcompletionresponsemessage.ts index f630634..45a5b0b 100644 --- a/src/models/components/chatcompletionresponsemessage.ts +++ b/src/models/components/chatcompletionresponsemessage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionMessageToolCall, ChatCompletionMessageToolCall$inboundSchema, @@ -133,6 +136,33 @@ export namespace ChatCompletionResponseMessageFunctionCall$ { export type Outbound = ChatCompletionResponseMessageFunctionCall$Outbound; } +export function chatCompletionResponseMessageFunctionCallToJSON( + chatCompletionResponseMessageFunctionCall: + ChatCompletionResponseMessageFunctionCall, +): string { + return JSON.stringify( + ChatCompletionResponseMessageFunctionCall$outboundSchema.parse( + chatCompletionResponseMessageFunctionCall, + ), + ); +} + +export function chatCompletionResponseMessageFunctionCallFromJSON( + jsonString: string, +): SafeParseResult< + ChatCompletionResponseMessageFunctionCall, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + ChatCompletionResponseMessageFunctionCall$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'ChatCompletionResponseMessageFunctionCall' from JSON`, + ); +} + /** @internal */ export const ChatCompletionResponseMessage$inboundSchema: z.ZodType< ChatCompletionResponseMessage, @@ -196,3 +226,23 @@ export namespace ChatCompletionResponseMessage$ { /** @deprecated use `ChatCompletionResponseMessage$Outbound` instead. */ export type Outbound = ChatCompletionResponseMessage$Outbound; } + +export function chatCompletionResponseMessageToJSON( + chatCompletionResponseMessage: ChatCompletionResponseMessage, +): string { + return JSON.stringify( + ChatCompletionResponseMessage$outboundSchema.parse( + chatCompletionResponseMessage, + ), + ); +} + +export function chatCompletionResponseMessageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionResponseMessage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionResponseMessage' from JSON`, + ); +} diff --git a/src/models/components/chatcompletionstreamoptions.ts b/src/models/components/chatcompletionstreamoptions.ts index 6783b9a..2d2bff5 100644 --- a/src/models/components/chatcompletionstreamoptions.ts +++ b/src/models/components/chatcompletionstreamoptions.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Options for streaming response. Only set this when you set `stream: true`. @@ -62,3 +65,23 @@ export namespace ChatCompletionStreamOptions$ { /** @deprecated use `ChatCompletionStreamOptions$Outbound` instead. */ export type Outbound = ChatCompletionStreamOptions$Outbound; } + +export function chatCompletionStreamOptionsToJSON( + chatCompletionStreamOptions: ChatCompletionStreamOptions, +): string { + return JSON.stringify( + ChatCompletionStreamOptions$outboundSchema.parse( + chatCompletionStreamOptions, + ), + ); +} + +export function chatCompletionStreamOptionsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionStreamOptions$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionStreamOptions' from JSON`, + ); +} diff --git a/src/models/components/chatcompletiontokenlogprob.ts b/src/models/components/chatcompletiontokenlogprob.ts index cff8e8d..40bda7d 100644 --- a/src/models/components/chatcompletiontokenlogprob.ts +++ b/src/models/components/chatcompletiontokenlogprob.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TopLogprobs = { /** @@ -81,6 +84,20 @@ export namespace TopLogprobs$ { export type Outbound = TopLogprobs$Outbound; } +export function topLogprobsToJSON(topLogprobs: TopLogprobs): string { + return JSON.stringify(TopLogprobs$outboundSchema.parse(topLogprobs)); +} + +export function topLogprobsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TopLogprobs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TopLogprobs' from JSON`, + ); +} + /** @internal */ export const ChatCompletionTokenLogprob$inboundSchema: z.ZodType< ChatCompletionTokenLogprob, @@ -133,3 +150,21 @@ export namespace ChatCompletionTokenLogprob$ { /** @deprecated use `ChatCompletionTokenLogprob$Outbound` instead. */ export type Outbound = ChatCompletionTokenLogprob$Outbound; } + +export function chatCompletionTokenLogprobToJSON( + chatCompletionTokenLogprob: ChatCompletionTokenLogprob, +): string { + return JSON.stringify( + ChatCompletionTokenLogprob$outboundSchema.parse(chatCompletionTokenLogprob), + ); +} + +export function chatCompletionTokenLogprobFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionTokenLogprob$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionTokenLogprob' from JSON`, + ); +} diff --git a/src/models/components/chatcompletiontool.ts b/src/models/components/chatcompletiontool.ts index de0b4b1..3e9787e 100644 --- a/src/models/components/chatcompletiontool.ts +++ b/src/models/components/chatcompletiontool.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FunctionObject, FunctionObject$inboundSchema, @@ -89,3 +92,21 @@ export namespace ChatCompletionTool$ { /** @deprecated use `ChatCompletionTool$Outbound` instead. */ export type Outbound = ChatCompletionTool$Outbound; } + +export function chatCompletionToolToJSON( + chatCompletionTool: ChatCompletionTool, +): string { + return JSON.stringify( + ChatCompletionTool$outboundSchema.parse(chatCompletionTool), + ); +} + +export function chatCompletionToolFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionTool$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionTool' from JSON`, + ); +} diff --git a/src/models/components/chatcompletiontoolchoiceoption.ts b/src/models/components/chatcompletiontoolchoiceoption.ts index 698a62f..662a825 100644 --- a/src/models/components/chatcompletiontoolchoiceoption.ts +++ b/src/models/components/chatcompletiontoolchoiceoption.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionNamedToolChoice, ChatCompletionNamedToolChoice$inboundSchema, @@ -103,3 +106,23 @@ export namespace ChatCompletionToolChoiceOption$ { /** @deprecated use `ChatCompletionToolChoiceOption$Outbound` instead. */ export type Outbound = ChatCompletionToolChoiceOption$Outbound; } + +export function chatCompletionToolChoiceOptionToJSON( + chatCompletionToolChoiceOption: ChatCompletionToolChoiceOption, +): string { + return JSON.stringify( + ChatCompletionToolChoiceOption$outboundSchema.parse( + chatCompletionToolChoiceOption, + ), + ); +} + +export function chatCompletionToolChoiceOptionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChatCompletionToolChoiceOption$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChatCompletionToolChoiceOption' from JSON`, + ); +} diff --git a/src/models/components/chunkingstrategyrequestparam.ts b/src/models/components/chunkingstrategyrequestparam.ts index 90a0107..122646f 100644 --- a/src/models/components/chunkingstrategyrequestparam.ts +++ b/src/models/components/chunkingstrategyrequestparam.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AutoChunkingStrategyRequestParam, AutoChunkingStrategyRequestParam$inboundSchema, @@ -60,3 +63,23 @@ export namespace ChunkingStrategyRequestParam$ { /** @deprecated use `ChunkingStrategyRequestParam$Outbound` instead. */ export type Outbound = ChunkingStrategyRequestParam$Outbound; } + +export function chunkingStrategyRequestParamToJSON( + chunkingStrategyRequestParam: ChunkingStrategyRequestParam, +): string { + return JSON.stringify( + ChunkingStrategyRequestParam$outboundSchema.parse( + chunkingStrategyRequestParam, + ), + ); +} + +export function chunkingStrategyRequestParamFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChunkingStrategyRequestParam$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChunkingStrategyRequestParam' from JSON`, + ); +} diff --git a/src/models/components/completeuploadrequest.ts b/src/models/components/completeuploadrequest.ts index 9da252a..9d1e16c 100644 --- a/src/models/components/completeuploadrequest.ts +++ b/src/models/components/completeuploadrequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CompleteUploadRequest = { /** @@ -66,3 +69,21 @@ export namespace CompleteUploadRequest$ { /** @deprecated use `CompleteUploadRequest$Outbound` instead. */ export type Outbound = CompleteUploadRequest$Outbound; } + +export function completeUploadRequestToJSON( + completeUploadRequest: CompleteUploadRequest, +): string { + return JSON.stringify( + CompleteUploadRequest$outboundSchema.parse(completeUploadRequest), + ); +} + +export function completeUploadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompleteUploadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompleteUploadRequest' from JSON`, + ); +} diff --git a/src/models/components/completionusage.ts b/src/models/components/completionusage.ts index b6f22d2..5dd939d 100644 --- a/src/models/components/completionusage.ts +++ b/src/models/components/completionusage.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Breakdown of tokens used in a completion. @@ -81,6 +84,24 @@ export namespace CompletionTokensDetails$ { export type Outbound = CompletionTokensDetails$Outbound; } +export function completionTokensDetailsToJSON( + completionTokensDetails: CompletionTokensDetails, +): string { + return JSON.stringify( + CompletionTokensDetails$outboundSchema.parse(completionTokensDetails), + ); +} + +export function completionTokensDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompletionTokensDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompletionTokensDetails' from JSON`, + ); +} + /** @internal */ export const CompletionUsage$inboundSchema: z.ZodType< CompletionUsage, @@ -141,3 +162,19 @@ export namespace CompletionUsage$ { /** @deprecated use `CompletionUsage$Outbound` instead. */ export type Outbound = CompletionUsage$Outbound; } + +export function completionUsageToJSON( + completionUsage: CompletionUsage, +): string { + return JSON.stringify(CompletionUsage$outboundSchema.parse(completionUsage)); +} + +export function completionUsageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompletionUsage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompletionUsage' from JSON`, + ); +} diff --git a/src/models/components/createassistantrequest.ts b/src/models/components/createassistantrequest.ts index e0953e2..65c7bbe 100644 --- a/src/models/components/createassistantrequest.ts +++ b/src/models/components/createassistantrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -444,6 +447,26 @@ export namespace CreateAssistantRequestModel$ { export type Outbound = CreateAssistantRequestModel$Outbound; } +export function createAssistantRequestModelToJSON( + createAssistantRequestModel: CreateAssistantRequestModel, +): string { + return JSON.stringify( + CreateAssistantRequestModel$outboundSchema.parse( + createAssistantRequestModel, + ), + ); +} + +export function createAssistantRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateAssistantRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestTools$inboundSchema: z.ZodType< CreateAssistantRequestTools, @@ -485,6 +508,26 @@ export namespace CreateAssistantRequestTools$ { export type Outbound = CreateAssistantRequestTools$Outbound; } +export function createAssistantRequestToolsToJSON( + createAssistantRequestTools: CreateAssistantRequestTools, +): string { + return JSON.stringify( + CreateAssistantRequestTools$outboundSchema.parse( + createAssistantRequestTools, + ), + ); +} + +export function createAssistantRequestToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateAssistantRequestTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestTools' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestCodeInterpreter$inboundSchema: z.ZodType< CreateAssistantRequestCodeInterpreter, @@ -531,6 +574,27 @@ export namespace CreateAssistantRequestCodeInterpreter$ { export type Outbound = CreateAssistantRequestCodeInterpreter$Outbound; } +export function createAssistantRequestCodeInterpreterToJSON( + createAssistantRequestCodeInterpreter: CreateAssistantRequestCodeInterpreter, +): string { + return JSON.stringify( + CreateAssistantRequestCodeInterpreter$outboundSchema.parse( + createAssistantRequestCodeInterpreter, + ), + ); +} + +export function createAssistantRequestCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateAssistantRequestCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestChunkingStrategyToolResourcesFileSearchType$inboundSchema: z.ZodNativeEnum< @@ -608,6 +672,24 @@ export namespace ChunkingStrategyStatic$ { export type Outbound = ChunkingStrategyStatic$Outbound; } +export function chunkingStrategyStaticToJSON( + chunkingStrategyStatic: ChunkingStrategyStatic, +): string { + return JSON.stringify( + ChunkingStrategyStatic$outboundSchema.parse(chunkingStrategyStatic), + ); +} + +export function chunkingStrategyStaticFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChunkingStrategyStatic$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChunkingStrategyStatic' from JSON`, + ); +} + /** @internal */ export const ChunkingStrategyStaticChunkingStrategy$inboundSchema: z.ZodType< ChunkingStrategyStaticChunkingStrategy, @@ -651,6 +733,28 @@ export namespace ChunkingStrategyStaticChunkingStrategy$ { export type Outbound = ChunkingStrategyStaticChunkingStrategy$Outbound; } +export function chunkingStrategyStaticChunkingStrategyToJSON( + chunkingStrategyStaticChunkingStrategy: + ChunkingStrategyStaticChunkingStrategy, +): string { + return JSON.stringify( + ChunkingStrategyStaticChunkingStrategy$outboundSchema.parse( + chunkingStrategyStaticChunkingStrategy, + ), + ); +} + +export function chunkingStrategyStaticChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChunkingStrategyStaticChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChunkingStrategyStaticChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestChunkingStrategyToolResourcesType$inboundSchema: z.ZodNativeEnum< @@ -714,6 +818,27 @@ export namespace ChunkingStrategyAutoChunkingStrategy$ { export type Outbound = ChunkingStrategyAutoChunkingStrategy$Outbound; } +export function chunkingStrategyAutoChunkingStrategyToJSON( + chunkingStrategyAutoChunkingStrategy: ChunkingStrategyAutoChunkingStrategy, +): string { + return JSON.stringify( + ChunkingStrategyAutoChunkingStrategy$outboundSchema.parse( + chunkingStrategyAutoChunkingStrategy, + ), + ); +} + +export function chunkingStrategyAutoChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ChunkingStrategyAutoChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChunkingStrategyAutoChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const FileSearchChunkingStrategy$inboundSchema: z.ZodType< FileSearchChunkingStrategy, @@ -752,6 +877,24 @@ export namespace FileSearchChunkingStrategy$ { export type Outbound = FileSearchChunkingStrategy$Outbound; } +export function fileSearchChunkingStrategyToJSON( + fileSearchChunkingStrategy: FileSearchChunkingStrategy, +): string { + return JSON.stringify( + FileSearchChunkingStrategy$outboundSchema.parse(fileSearchChunkingStrategy), + ); +} + +export function fileSearchChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearchChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearchChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestFileSearchMetadata$inboundSchema: z.ZodType< CreateAssistantRequestFileSearchMetadata, @@ -784,6 +927,33 @@ export namespace CreateAssistantRequestFileSearchMetadata$ { export type Outbound = CreateAssistantRequestFileSearchMetadata$Outbound; } +export function createAssistantRequestFileSearchMetadataToJSON( + createAssistantRequestFileSearchMetadata: + CreateAssistantRequestFileSearchMetadata, +): string { + return JSON.stringify( + CreateAssistantRequestFileSearchMetadata$outboundSchema.parse( + createAssistantRequestFileSearchMetadata, + ), + ); +} + +export function createAssistantRequestFileSearchMetadataFromJSON( + jsonString: string, +): SafeParseResult< + CreateAssistantRequestFileSearchMetadata, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateAssistantRequestFileSearchMetadata$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateAssistantRequestFileSearchMetadata' from JSON`, + ); +} + /** @internal */ export const FileSearchVectorStores$inboundSchema: z.ZodType< FileSearchVectorStores, @@ -848,6 +1018,24 @@ export namespace FileSearchVectorStores$ { export type Outbound = FileSearchVectorStores$Outbound; } +export function fileSearchVectorStoresToJSON( + fileSearchVectorStores: FileSearchVectorStores, +): string { + return JSON.stringify( + FileSearchVectorStores$outboundSchema.parse(fileSearchVectorStores), + ); +} + +export function fileSearchVectorStoresFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearchVectorStores$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearchVectorStores' from JSON`, + ); +} + /** @internal */ export const FileSearch2$inboundSchema: z.ZodType< FileSearch2, @@ -897,6 +1085,20 @@ export namespace FileSearch2$ { export type Outbound = FileSearch2$Outbound; } +export function fileSearch2ToJSON(fileSearch2: FileSearch2): string { + return JSON.stringify(FileSearch2$outboundSchema.parse(fileSearch2)); +} + +export function fileSearch2FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearch2$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearch2' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestChunkingStrategyType$inboundSchema: z.ZodNativeEnum = z @@ -966,6 +1168,20 @@ export namespace Static$ { export type Outbound = Static$Outbound; } +export function staticToJSON(value: Static): string { + return JSON.stringify(Static$outboundSchema.parse(value)); +} + +export function staticFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Static$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Static' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestChunkingStrategyStaticChunkingStrategy$inboundSchema: z.ZodType< @@ -1011,6 +1227,31 @@ export namespace CreateAssistantRequestChunkingStrategyStaticChunkingStrategy$ { CreateAssistantRequestChunkingStrategyStaticChunkingStrategy$Outbound; } +export function createAssistantRequestChunkingStrategyStaticChunkingStrategyToJSON( + createAssistantRequestChunkingStrategyStaticChunkingStrategy: + CreateAssistantRequestChunkingStrategyStaticChunkingStrategy, +): string { + return JSON.stringify( + CreateAssistantRequestChunkingStrategyStaticChunkingStrategy$outboundSchema + .parse(createAssistantRequestChunkingStrategyStaticChunkingStrategy), + ); +} + +export function createAssistantRequestChunkingStrategyStaticChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateAssistantRequestChunkingStrategyStaticChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateAssistantRequestChunkingStrategyStaticChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestChunkingStrategyStaticChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const ChunkingStrategyType$inboundSchema: z.ZodNativeEnum< typeof ChunkingStrategyType @@ -1068,6 +1309,24 @@ export namespace AutoChunkingStrategy$ { export type Outbound = AutoChunkingStrategy$Outbound; } +export function autoChunkingStrategyToJSON( + autoChunkingStrategy: AutoChunkingStrategy, +): string { + return JSON.stringify( + AutoChunkingStrategy$outboundSchema.parse(autoChunkingStrategy), + ); +} + +export function autoChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AutoChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AutoChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestFileSearchChunkingStrategy$inboundSchema: z.ZodType< @@ -1115,6 +1374,33 @@ export namespace CreateAssistantRequestFileSearchChunkingStrategy$ { CreateAssistantRequestFileSearchChunkingStrategy$Outbound; } +export function createAssistantRequestFileSearchChunkingStrategyToJSON( + createAssistantRequestFileSearchChunkingStrategy: + CreateAssistantRequestFileSearchChunkingStrategy, +): string { + return JSON.stringify( + CreateAssistantRequestFileSearchChunkingStrategy$outboundSchema.parse( + createAssistantRequestFileSearchChunkingStrategy, + ), + ); +} + +export function createAssistantRequestFileSearchChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateAssistantRequestFileSearchChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateAssistantRequestFileSearchChunkingStrategy$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateAssistantRequestFileSearchChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const FileSearchMetadata$inboundSchema: z.ZodType< FileSearchMetadata, @@ -1145,6 +1431,24 @@ export namespace FileSearchMetadata$ { export type Outbound = FileSearchMetadata$Outbound; } +export function fileSearchMetadataToJSON( + fileSearchMetadata: FileSearchMetadata, +): string { + return JSON.stringify( + FileSearchMetadata$outboundSchema.parse(fileSearchMetadata), + ); +} + +export function fileSearchMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearchMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearchMetadata' from JSON`, + ); +} + /** @internal */ export const VectorStores$inboundSchema: z.ZodType< VectorStores, @@ -1210,6 +1514,20 @@ export namespace VectorStores$ { export type Outbound = VectorStores$Outbound; } +export function vectorStoresToJSON(vectorStores: VectorStores): string { + return JSON.stringify(VectorStores$outboundSchema.parse(vectorStores)); +} + +export function vectorStoresFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStores$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStores' from JSON`, + ); +} + /** @internal */ export const FileSearch1$inboundSchema: z.ZodType< FileSearch1, @@ -1259,6 +1577,20 @@ export namespace FileSearch1$ { export type Outbound = FileSearch1$Outbound; } +export function fileSearch1ToJSON(fileSearch1: FileSearch1): string { + return JSON.stringify(FileSearch1$outboundSchema.parse(fileSearch1)); +} + +export function fileSearch1FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearch1$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearch1' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestFileSearch$inboundSchema: z.ZodType< CreateAssistantRequestFileSearch, @@ -1297,6 +1629,26 @@ export namespace CreateAssistantRequestFileSearch$ { export type Outbound = CreateAssistantRequestFileSearch$Outbound; } +export function createAssistantRequestFileSearchToJSON( + createAssistantRequestFileSearch: CreateAssistantRequestFileSearch, +): string { + return JSON.stringify( + CreateAssistantRequestFileSearch$outboundSchema.parse( + createAssistantRequestFileSearch, + ), + ); +} + +export function createAssistantRequestFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateAssistantRequestFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestFileSearch' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestToolResources$inboundSchema: z.ZodType< CreateAssistantRequestToolResources, @@ -1358,6 +1710,27 @@ export namespace CreateAssistantRequestToolResources$ { export type Outbound = CreateAssistantRequestToolResources$Outbound; } +export function createAssistantRequestToolResourcesToJSON( + createAssistantRequestToolResources: CreateAssistantRequestToolResources, +): string { + return JSON.stringify( + CreateAssistantRequestToolResources$outboundSchema.parse( + createAssistantRequestToolResources, + ), + ); +} + +export function createAssistantRequestToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateAssistantRequestToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestToolResources' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequestMetadata$inboundSchema: z.ZodType< CreateAssistantRequestMetadata, @@ -1388,6 +1761,26 @@ export namespace CreateAssistantRequestMetadata$ { export type Outbound = CreateAssistantRequestMetadata$Outbound; } +export function createAssistantRequestMetadataToJSON( + createAssistantRequestMetadata: CreateAssistantRequestMetadata, +): string { + return JSON.stringify( + CreateAssistantRequestMetadata$outboundSchema.parse( + createAssistantRequestMetadata, + ), + ); +} + +export function createAssistantRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateAssistantRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateAssistantRequest$inboundSchema: z.ZodType< CreateAssistantRequest, @@ -1491,3 +1884,21 @@ export namespace CreateAssistantRequest$ { /** @deprecated use `CreateAssistantRequest$Outbound` instead. */ export type Outbound = CreateAssistantRequest$Outbound; } + +export function createAssistantRequestToJSON( + createAssistantRequest: CreateAssistantRequest, +): string { + return JSON.stringify( + CreateAssistantRequest$outboundSchema.parse(createAssistantRequest), + ); +} + +export function createAssistantRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateAssistantRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateAssistantRequest' from JSON`, + ); +} diff --git a/src/models/components/createchatcompletionrequest.ts b/src/models/components/createchatcompletionrequest.ts index b810cae..6381815 100644 --- a/src/models/components/createchatcompletionrequest.ts +++ b/src/models/components/createchatcompletionrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionFunctionCallOption, ChatCompletionFunctionCallOption$inboundSchema, @@ -332,6 +335,10 @@ export type CreateChatCompletionRequest = { * `none` is the default when no tools are present. `auto` is the default if tools are present. */ toolChoice?: ChatCompletionToolChoiceOption | undefined; + /** + * Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + */ + parallelToolCalls?: boolean | undefined; /** * 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). * @@ -413,6 +420,26 @@ export namespace CreateChatCompletionRequestModel$ { export type Outbound = CreateChatCompletionRequestModel$Outbound; } +export function createChatCompletionRequestModelToJSON( + createChatCompletionRequestModel: CreateChatCompletionRequestModel, +): string { + return JSON.stringify( + CreateChatCompletionRequestModel$outboundSchema.parse( + createChatCompletionRequestModel, + ), + ); +} + +export function createChatCompletionRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateChatCompletionRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateChatCompletionRequestModel' from JSON`, + ); +} + /** @internal */ export const ResponseFormat$inboundSchema: z.ZodType< ResponseFormat, @@ -454,6 +481,20 @@ export namespace ResponseFormat$ { export type Outbound = ResponseFormat$Outbound; } +export function responseFormatToJSON(responseFormat: ResponseFormat): string { + return JSON.stringify(ResponseFormat$outboundSchema.parse(responseFormat)); +} + +export function responseFormatFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ResponseFormat$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ResponseFormat' from JSON`, + ); +} + /** @internal */ export const ServiceTier$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ServiceTier); @@ -497,6 +538,20 @@ export namespace Stop$ { export type Outbound = Stop$Outbound; } +export function stopToJSON(stop: Stop): string { + return JSON.stringify(Stop$outboundSchema.parse(stop)); +} + +export function stopFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Stop$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Stop' from JSON`, + ); +} + /** @internal */ export const One$inboundSchema: z.ZodNativeEnum = z.nativeEnum(One); @@ -555,6 +610,33 @@ export namespace CreateChatCompletionRequestFunctionCall$ { export type Outbound = CreateChatCompletionRequestFunctionCall$Outbound; } +export function createChatCompletionRequestFunctionCallToJSON( + createChatCompletionRequestFunctionCall: + CreateChatCompletionRequestFunctionCall, +): string { + return JSON.stringify( + CreateChatCompletionRequestFunctionCall$outboundSchema.parse( + createChatCompletionRequestFunctionCall, + ), + ); +} + +export function createChatCompletionRequestFunctionCallFromJSON( + jsonString: string, +): SafeParseResult< + CreateChatCompletionRequestFunctionCall, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateChatCompletionRequestFunctionCall$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateChatCompletionRequestFunctionCall' from JSON`, + ); +} + /** @internal */ export const CreateChatCompletionRequest$inboundSchema: z.ZodType< CreateChatCompletionRequest, @@ -586,6 +668,7 @@ export const CreateChatCompletionRequest$inboundSchema: z.ZodType< top_p: z.nullable(z.number().default(1)), tools: z.array(ChatCompletionTool$inboundSchema).optional(), tool_choice: ChatCompletionToolChoiceOption$inboundSchema.optional(), + parallel_tool_calls: z.boolean().default(true), user: z.string().optional(), function_call: z.union([ ChatCompletionFunctionCallOption$inboundSchema, @@ -605,6 +688,7 @@ export const CreateChatCompletionRequest$inboundSchema: z.ZodType< "stream_options": "streamOptions", "top_p": "topP", "tool_choice": "toolChoice", + "parallel_tool_calls": "parallelToolCalls", "function_call": "functionCall", }); }); @@ -635,6 +719,7 @@ export type CreateChatCompletionRequest$Outbound = { top_p: number | null; tools?: Array | undefined; tool_choice?: ChatCompletionToolChoiceOption$Outbound | undefined; + parallel_tool_calls: boolean; user?: string | undefined; function_call?: | ChatCompletionFunctionCallOption$Outbound @@ -674,6 +759,7 @@ export const CreateChatCompletionRequest$outboundSchema: z.ZodType< topP: z.nullable(z.number().default(1)), tools: z.array(ChatCompletionTool$outboundSchema).optional(), toolChoice: ChatCompletionToolChoiceOption$outboundSchema.optional(), + parallelToolCalls: z.boolean().default(true), user: z.string().optional(), functionCall: z.union([ ChatCompletionFunctionCallOption$outboundSchema, @@ -693,6 +779,7 @@ export const CreateChatCompletionRequest$outboundSchema: z.ZodType< streamOptions: "stream_options", topP: "top_p", toolChoice: "tool_choice", + parallelToolCalls: "parallel_tool_calls", functionCall: "function_call", }); }); @@ -709,3 +796,23 @@ export namespace CreateChatCompletionRequest$ { /** @deprecated use `CreateChatCompletionRequest$Outbound` instead. */ export type Outbound = CreateChatCompletionRequest$Outbound; } + +export function createChatCompletionRequestToJSON( + createChatCompletionRequest: CreateChatCompletionRequest, +): string { + return JSON.stringify( + CreateChatCompletionRequest$outboundSchema.parse( + createChatCompletionRequest, + ), + ); +} + +export function createChatCompletionRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateChatCompletionRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateChatCompletionRequest' from JSON`, + ); +} diff --git a/src/models/components/createchatcompletionresponse.ts b/src/models/components/createchatcompletionresponse.ts index e12d228..44a395e 100644 --- a/src/models/components/createchatcompletionresponse.ts +++ b/src/models/components/createchatcompletionresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionResponseMessage, ChatCompletionResponseMessage$inboundSchema, @@ -212,6 +215,20 @@ export namespace Logprobs$ { export type Outbound = Logprobs$Outbound; } +export function logprobsToJSON(logprobs: Logprobs): string { + return JSON.stringify(Logprobs$outboundSchema.parse(logprobs)); +} + +export function logprobsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Logprobs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Logprobs' from JSON`, + ); +} + /** @internal */ export const Choices$inboundSchema: z.ZodType = z.object({ @@ -262,6 +279,20 @@ export namespace Choices$ { export type Outbound = Choices$Outbound; } +export function choicesToJSON(choices: Choices): string { + return JSON.stringify(Choices$outboundSchema.parse(choices)); +} + +export function choicesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Choices$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Choices' from JSON`, + ); +} + /** @internal */ export const CreateChatCompletionResponseServiceTier$inboundSchema: z.ZodNativeEnum = z @@ -374,3 +405,23 @@ export namespace CreateChatCompletionResponse$ { /** @deprecated use `CreateChatCompletionResponse$Outbound` instead. */ export type Outbound = CreateChatCompletionResponse$Outbound; } + +export function createChatCompletionResponseToJSON( + createChatCompletionResponse: CreateChatCompletionResponse, +): string { + return JSON.stringify( + CreateChatCompletionResponse$outboundSchema.parse( + createChatCompletionResponse, + ), + ); +} + +export function createChatCompletionResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateChatCompletionResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateChatCompletionResponse' from JSON`, + ); +} diff --git a/src/models/components/createcompletionrequest.ts b/src/models/components/createcompletionrequest.ts index f0274c8..f928d2c 100644 --- a/src/models/components/createcompletionrequest.ts +++ b/src/models/components/createcompletionrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChatCompletionStreamOptions, ChatCompletionStreamOptions$inboundSchema, @@ -234,6 +237,26 @@ export namespace CreateCompletionRequestModel$ { export type Outbound = CreateCompletionRequestModel$Outbound; } +export function createCompletionRequestModelToJSON( + createCompletionRequestModel: CreateCompletionRequestModel, +): string { + return JSON.stringify( + CreateCompletionRequestModel$outboundSchema.parse( + createCompletionRequestModel, + ), + ); +} + +export function createCompletionRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionRequestModel' from JSON`, + ); +} + /** @internal */ export const Prompt$inboundSchema: z.ZodType = z .union([ @@ -275,6 +298,20 @@ export namespace Prompt$ { export type Outbound = Prompt$Outbound; } +export function promptToJSON(prompt: Prompt): string { + return JSON.stringify(Prompt$outboundSchema.parse(prompt)); +} + +export function promptFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Prompt$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Prompt' from JSON`, + ); +} + /** @internal */ export const CreateCompletionRequestStop$inboundSchema: z.ZodType< CreateCompletionRequestStop, @@ -305,6 +342,26 @@ export namespace CreateCompletionRequestStop$ { export type Outbound = CreateCompletionRequestStop$Outbound; } +export function createCompletionRequestStopToJSON( + createCompletionRequestStop: CreateCompletionRequestStop, +): string { + return JSON.stringify( + CreateCompletionRequestStop$outboundSchema.parse( + createCompletionRequestStop, + ), + ); +} + +export function createCompletionRequestStopFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionRequestStop$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionRequestStop' from JSON`, + ); +} + /** @internal */ export const CreateCompletionRequest$inboundSchema: z.ZodType< CreateCompletionRequest, @@ -427,3 +484,21 @@ export namespace CreateCompletionRequest$ { /** @deprecated use `CreateCompletionRequest$Outbound` instead. */ export type Outbound = CreateCompletionRequest$Outbound; } + +export function createCompletionRequestToJSON( + createCompletionRequest: CreateCompletionRequest, +): string { + return JSON.stringify( + CreateCompletionRequest$outboundSchema.parse(createCompletionRequest), + ); +} + +export function createCompletionRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionRequest' from JSON`, + ); +} diff --git a/src/models/components/createcompletionresponse.ts b/src/models/components/createcompletionresponse.ts index dce8a02..52bfc49 100644 --- a/src/models/components/createcompletionresponse.ts +++ b/src/models/components/createcompletionresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CompletionUsage, CompletionUsage$inboundSchema, @@ -190,6 +193,26 @@ export namespace CreateCompletionResponseLogprobs$ { export type Outbound = CreateCompletionResponseLogprobs$Outbound; } +export function createCompletionResponseLogprobsToJSON( + createCompletionResponseLogprobs: CreateCompletionResponseLogprobs, +): string { + return JSON.stringify( + CreateCompletionResponseLogprobs$outboundSchema.parse( + createCompletionResponseLogprobs, + ), + ); +} + +export function createCompletionResponseLogprobsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionResponseLogprobs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionResponseLogprobs' from JSON`, + ); +} + /** @internal */ export const CreateCompletionResponseChoices$inboundSchema: z.ZodType< CreateCompletionResponseChoices, @@ -247,6 +270,26 @@ export namespace CreateCompletionResponseChoices$ { export type Outbound = CreateCompletionResponseChoices$Outbound; } +export function createCompletionResponseChoicesToJSON( + createCompletionResponseChoices: CreateCompletionResponseChoices, +): string { + return JSON.stringify( + CreateCompletionResponseChoices$outboundSchema.parse( + createCompletionResponseChoices, + ), + ); +} + +export function createCompletionResponseChoicesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionResponseChoices$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionResponseChoices' from JSON`, + ); +} + /** @internal */ export const CreateCompletionResponseObject$inboundSchema: z.ZodNativeEnum< typeof CreateCompletionResponseObject @@ -331,3 +374,21 @@ export namespace CreateCompletionResponse$ { /** @deprecated use `CreateCompletionResponse$Outbound` instead. */ export type Outbound = CreateCompletionResponse$Outbound; } + +export function createCompletionResponseToJSON( + createCompletionResponse: CreateCompletionResponse, +): string { + return JSON.stringify( + CreateCompletionResponse$outboundSchema.parse(createCompletionResponse), + ); +} + +export function createCompletionResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateCompletionResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateCompletionResponse' from JSON`, + ); +} diff --git a/src/models/components/createembeddingrequest.ts b/src/models/components/createembeddingrequest.ts index 6e6527a..27cc31f 100644 --- a/src/models/components/createembeddingrequest.ts +++ b/src/models/components/createembeddingrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Input text to embed, encoded as a string or array of tokens. To embed multiple inputs in a single request, pass an array of strings or array of token arrays. The input must not exceed the max input tokens for the model (8192 tokens for `text-embedding-ada-002`), cannot be an empty string, and any array must be 2048 dimensions or less. [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken) for counting tokens. @@ -117,6 +120,20 @@ export namespace Input$ { export type Outbound = Input$Outbound; } +export function inputToJSON(input: Input): string { + return JSON.stringify(Input$outboundSchema.parse(input)); +} + +export function inputFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Input$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Input' from JSON`, + ); +} + /** @internal */ export const CreateEmbeddingRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateEmbeddingRequestModel2 @@ -168,6 +185,26 @@ export namespace CreateEmbeddingRequestModel$ { export type Outbound = CreateEmbeddingRequestModel$Outbound; } +export function createEmbeddingRequestModelToJSON( + createEmbeddingRequestModel: CreateEmbeddingRequestModel, +): string { + return JSON.stringify( + CreateEmbeddingRequestModel$outboundSchema.parse( + createEmbeddingRequestModel, + ), + ); +} + +export function createEmbeddingRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateEmbeddingRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateEmbeddingRequestModel' from JSON`, + ); +} + /** @internal */ export const EncodingFormat$inboundSchema: z.ZodNativeEnum< typeof EncodingFormat @@ -254,3 +291,21 @@ export namespace CreateEmbeddingRequest$ { /** @deprecated use `CreateEmbeddingRequest$Outbound` instead. */ export type Outbound = CreateEmbeddingRequest$Outbound; } + +export function createEmbeddingRequestToJSON( + createEmbeddingRequest: CreateEmbeddingRequest, +): string { + return JSON.stringify( + CreateEmbeddingRequest$outboundSchema.parse(createEmbeddingRequest), + ); +} + +export function createEmbeddingRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateEmbeddingRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateEmbeddingRequest' from JSON`, + ); +} diff --git a/src/models/components/createembeddingresponse.ts b/src/models/components/createembeddingresponse.ts index e517e3a..07b4e0e 100644 --- a/src/models/components/createembeddingresponse.ts +++ b/src/models/components/createembeddingresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Embedding, Embedding$inboundSchema, @@ -125,6 +128,20 @@ export namespace Usage$ { export type Outbound = Usage$Outbound; } +export function usageToJSON(usage: Usage): string { + return JSON.stringify(Usage$outboundSchema.parse(usage)); +} + +export function usageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Usage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Usage' from JSON`, + ); +} + /** @internal */ export const CreateEmbeddingResponse$inboundSchema: z.ZodType< CreateEmbeddingResponse, @@ -169,3 +186,21 @@ export namespace CreateEmbeddingResponse$ { /** @deprecated use `CreateEmbeddingResponse$Outbound` instead. */ export type Outbound = CreateEmbeddingResponse$Outbound; } + +export function createEmbeddingResponseToJSON( + createEmbeddingResponse: CreateEmbeddingResponse, +): string { + return JSON.stringify( + CreateEmbeddingResponse$outboundSchema.parse(createEmbeddingResponse), + ); +} + +export function createEmbeddingResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateEmbeddingResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateEmbeddingResponse' from JSON`, + ); +} diff --git a/src/models/components/createfilerequest.ts b/src/models/components/createfilerequest.ts index 61b1fe6..d93ea17 100644 --- a/src/models/components/createfilerequest.ts +++ b/src/models/components/createfilerequest.ts @@ -3,8 +3,11 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateFileRequestFile = { fileName: string; @@ -101,6 +104,24 @@ export namespace CreateFileRequestFile$ { export type Outbound = CreateFileRequestFile$Outbound; } +export function createFileRequestFileToJSON( + createFileRequestFile: CreateFileRequestFile, +): string { + return JSON.stringify( + CreateFileRequestFile$outboundSchema.parse(createFileRequestFile), + ); +} + +export function createFileRequestFileFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFileRequestFile$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFileRequestFile' from JSON`, + ); +} + /** @internal */ export const CreateFileRequestPurpose$inboundSchema: z.ZodNativeEnum< typeof CreateFileRequestPurpose @@ -160,3 +181,21 @@ export namespace CreateFileRequest$ { /** @deprecated use `CreateFileRequest$Outbound` instead. */ export type Outbound = CreateFileRequest$Outbound; } + +export function createFileRequestToJSON( + createFileRequest: CreateFileRequest, +): string { + return JSON.stringify( + CreateFileRequest$outboundSchema.parse(createFileRequest), + ); +} + +export function createFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFileRequest' from JSON`, + ); +} diff --git a/src/models/components/createfinetuningjobrequest.ts b/src/models/components/createfinetuningjobrequest.ts index 21ed37c..3ef87de 100644 --- a/src/models/components/createfinetuningjobrequest.ts +++ b/src/models/components/createfinetuningjobrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const CreateFineTuningJobRequestModel2 = { Babbage002: "babbage-002", @@ -272,6 +275,26 @@ export namespace CreateFineTuningJobRequestModel$ { export type Outbound = CreateFineTuningJobRequestModel$Outbound; } +export function createFineTuningJobRequestModelToJSON( + createFineTuningJobRequestModel: CreateFineTuningJobRequestModel, +): string { + return JSON.stringify( + CreateFineTuningJobRequestModel$outboundSchema.parse( + createFineTuningJobRequestModel, + ), + ); +} + +export function createFineTuningJobRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFineTuningJobRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFineTuningJobRequestModel' from JSON`, + ); +} + /** @internal */ export const BatchSize1$inboundSchema: z.ZodNativeEnum = z .nativeEnum(BatchSize1); @@ -321,6 +344,20 @@ export namespace BatchSize$ { export type Outbound = BatchSize$Outbound; } +export function batchSizeToJSON(batchSize: BatchSize): string { + return JSON.stringify(BatchSize$outboundSchema.parse(batchSize)); +} + +export function batchSizeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => BatchSize$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'BatchSize' from JSON`, + ); +} + /** @internal */ export const LearningRateMultiplier1$inboundSchema: z.ZodNativeEnum< typeof LearningRateMultiplier1 @@ -372,6 +409,24 @@ export namespace LearningRateMultiplier$ { export type Outbound = LearningRateMultiplier$Outbound; } +export function learningRateMultiplierToJSON( + learningRateMultiplier: LearningRateMultiplier, +): string { + return JSON.stringify( + LearningRateMultiplier$outboundSchema.parse(learningRateMultiplier), + ); +} + +export function learningRateMultiplierFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => LearningRateMultiplier$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'LearningRateMultiplier' from JSON`, + ); +} + /** @internal */ export const NEpochs1$inboundSchema: z.ZodNativeEnum = z .nativeEnum(NEpochs1); @@ -418,6 +473,20 @@ export namespace NEpochs$ { export type Outbound = NEpochs$Outbound; } +export function nEpochsToJSON(nEpochs: NEpochs): string { + return JSON.stringify(NEpochs$outboundSchema.parse(nEpochs)); +} + +export function nEpochsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => NEpochs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'NEpochs' from JSON`, + ); +} + /** @internal */ export const Hyperparameters$inboundSchema: z.ZodType< Hyperparameters, @@ -478,6 +547,22 @@ export namespace Hyperparameters$ { export type Outbound = Hyperparameters$Outbound; } +export function hyperparametersToJSON( + hyperparameters: Hyperparameters, +): string { + return JSON.stringify(Hyperparameters$outboundSchema.parse(hyperparameters)); +} + +export function hyperparametersFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Hyperparameters$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Hyperparameters' from JSON`, + ); +} + /** @internal */ export const Type1$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Type1, @@ -528,6 +613,26 @@ export namespace CreateFineTuningJobRequestType$ { export type Outbound = CreateFineTuningJobRequestType$Outbound; } +export function createFineTuningJobRequestTypeToJSON( + createFineTuningJobRequestType: CreateFineTuningJobRequestType, +): string { + return JSON.stringify( + CreateFineTuningJobRequestType$outboundSchema.parse( + createFineTuningJobRequestType, + ), + ); +} + +export function createFineTuningJobRequestTypeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFineTuningJobRequestType$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFineTuningJobRequestType' from JSON`, + ); +} + /** @internal */ export const CreateFineTuningJobRequestWandb$inboundSchema: z.ZodType< CreateFineTuningJobRequestWandb, @@ -573,6 +678,26 @@ export namespace CreateFineTuningJobRequestWandb$ { export type Outbound = CreateFineTuningJobRequestWandb$Outbound; } +export function createFineTuningJobRequestWandbToJSON( + createFineTuningJobRequestWandb: CreateFineTuningJobRequestWandb, +): string { + return JSON.stringify( + CreateFineTuningJobRequestWandb$outboundSchema.parse( + createFineTuningJobRequestWandb, + ), + ); +} + +export function createFineTuningJobRequestWandbFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFineTuningJobRequestWandb$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFineTuningJobRequestWandb' from JSON`, + ); +} + /** @internal */ export const Integrations$inboundSchema: z.ZodType< Integrations, @@ -612,6 +737,20 @@ export namespace Integrations$ { export type Outbound = Integrations$Outbound; } +export function integrationsToJSON(integrations: Integrations): string { + return JSON.stringify(Integrations$outboundSchema.parse(integrations)); +} + +export function integrationsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Integrations$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Integrations' from JSON`, + ); +} + /** @internal */ export const CreateFineTuningJobRequest$inboundSchema: z.ZodType< CreateFineTuningJobRequest, @@ -677,3 +816,21 @@ export namespace CreateFineTuningJobRequest$ { /** @deprecated use `CreateFineTuningJobRequest$Outbound` instead. */ export type Outbound = CreateFineTuningJobRequest$Outbound; } + +export function createFineTuningJobRequestToJSON( + createFineTuningJobRequest: CreateFineTuningJobRequest, +): string { + return JSON.stringify( + CreateFineTuningJobRequest$outboundSchema.parse(createFineTuningJobRequest), + ); +} + +export function createFineTuningJobRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateFineTuningJobRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateFineTuningJobRequest' from JSON`, + ); +} diff --git a/src/models/components/createimageeditrequest.ts b/src/models/components/createimageeditrequest.ts index 070d5e4..0832c08 100644 --- a/src/models/components/createimageeditrequest.ts +++ b/src/models/components/createimageeditrequest.ts @@ -4,8 +4,11 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateImageEditRequestImage = { fileName: string; @@ -144,6 +147,26 @@ export namespace CreateImageEditRequestImage$ { export type Outbound = CreateImageEditRequestImage$Outbound; } +export function createImageEditRequestImageToJSON( + createImageEditRequestImage: CreateImageEditRequestImage, +): string { + return JSON.stringify( + CreateImageEditRequestImage$outboundSchema.parse( + createImageEditRequestImage, + ), + ); +} + +export function createImageEditRequestImageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageEditRequestImage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageEditRequestImage' from JSON`, + ); +} + /** @internal */ export const Mask$inboundSchema: z.ZodType = z .object({ @@ -187,6 +210,20 @@ export namespace Mask$ { export type Outbound = Mask$Outbound; } +export function maskToJSON(mask: Mask): string { + return JSON.stringify(Mask$outboundSchema.parse(mask)); +} + +export function maskFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Mask$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Mask' from JSON`, + ); +} + /** @internal */ export const CreateImageEditRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateImageEditRequestModel2 @@ -238,6 +275,26 @@ export namespace CreateImageEditRequestModel$ { export type Outbound = CreateImageEditRequestModel$Outbound; } +export function createImageEditRequestModelToJSON( + createImageEditRequestModel: CreateImageEditRequestModel, +): string { + return JSON.stringify( + CreateImageEditRequestModel$outboundSchema.parse( + createImageEditRequestModel, + ), + ); +} + +export function createImageEditRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageEditRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageEditRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateImageEditRequestSize$inboundSchema: z.ZodNativeEnum< typeof CreateImageEditRequestSize @@ -361,3 +418,21 @@ export namespace CreateImageEditRequest$ { /** @deprecated use `CreateImageEditRequest$Outbound` instead. */ export type Outbound = CreateImageEditRequest$Outbound; } + +export function createImageEditRequestToJSON( + createImageEditRequest: CreateImageEditRequest, +): string { + return JSON.stringify( + CreateImageEditRequest$outboundSchema.parse(createImageEditRequest), + ); +} + +export function createImageEditRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageEditRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageEditRequest' from JSON`, + ); +} diff --git a/src/models/components/createimagerequest.ts b/src/models/components/createimagerequest.ts index 86b46c4..4fafbfa 100644 --- a/src/models/components/createimagerequest.ts +++ b/src/models/components/createimagerequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const CreateImageRequestModel2 = { DallE2: "dall-e-2", @@ -160,6 +163,24 @@ export namespace CreateImageRequestModel$ { export type Outbound = CreateImageRequestModel$Outbound; } +export function createImageRequestModelToJSON( + createImageRequestModel: CreateImageRequestModel, +): string { + return JSON.stringify( + CreateImageRequestModel$outboundSchema.parse(createImageRequestModel), + ); +} + +export function createImageRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageRequestModel' from JSON`, + ); +} + /** @internal */ export const Quality$inboundSchema: z.ZodNativeEnum = z .nativeEnum(Quality); @@ -312,3 +333,21 @@ export namespace CreateImageRequest$ { /** @deprecated use `CreateImageRequest$Outbound` instead. */ export type Outbound = CreateImageRequest$Outbound; } + +export function createImageRequestToJSON( + createImageRequest: CreateImageRequest, +): string { + return JSON.stringify( + CreateImageRequest$outboundSchema.parse(createImageRequest), + ); +} + +export function createImageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageRequest' from JSON`, + ); +} diff --git a/src/models/components/createimagevariationrequest.ts b/src/models/components/createimagevariationrequest.ts index 8b100e1..1f33ebf 100644 --- a/src/models/components/createimagevariationrequest.ts +++ b/src/models/components/createimagevariationrequest.ts @@ -4,8 +4,11 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateImageVariationRequestImage = { fileName: string; @@ -133,6 +136,26 @@ export namespace CreateImageVariationRequestImage$ { export type Outbound = CreateImageVariationRequestImage$Outbound; } +export function createImageVariationRequestImageToJSON( + createImageVariationRequestImage: CreateImageVariationRequestImage, +): string { + return JSON.stringify( + CreateImageVariationRequestImage$outboundSchema.parse( + createImageVariationRequestImage, + ), + ); +} + +export function createImageVariationRequestImageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageVariationRequestImage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageVariationRequestImage' from JSON`, + ); +} + /** @internal */ export const CreateImageVariationRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateImageVariationRequestModel2 @@ -185,6 +208,26 @@ export namespace CreateImageVariationRequestModel$ { export type Outbound = CreateImageVariationRequestModel$Outbound; } +export function createImageVariationRequestModelToJSON( + createImageVariationRequestModel: CreateImageVariationRequestModel, +): string { + return JSON.stringify( + CreateImageVariationRequestModel$outboundSchema.parse( + createImageVariationRequestModel, + ), + ); +} + +export function createImageVariationRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageVariationRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageVariationRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateImageVariationRequestResponseFormat$inboundSchema: z.ZodNativeEnum = z @@ -301,3 +344,23 @@ export namespace CreateImageVariationRequest$ { /** @deprecated use `CreateImageVariationRequest$Outbound` instead. */ export type Outbound = CreateImageVariationRequest$Outbound; } + +export function createImageVariationRequestToJSON( + createImageVariationRequest: CreateImageVariationRequest, +): string { + return JSON.stringify( + CreateImageVariationRequest$outboundSchema.parse( + createImageVariationRequest, + ), + ); +} + +export function createImageVariationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateImageVariationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateImageVariationRequest' from JSON`, + ); +} diff --git a/src/models/components/createmessagerequest.ts b/src/models/components/createmessagerequest.ts index 7df2093..30847e2 100644 --- a/src/models/components/createmessagerequest.ts +++ b/src/models/components/createmessagerequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantToolsCode, AssistantToolsCode$inboundSchema, @@ -185,6 +188,20 @@ export namespace Content2$ { export type Outbound = Content2$Outbound; } +export function content2ToJSON(content2: Content2): string { + return JSON.stringify(Content2$outboundSchema.parse(content2)); +} + +export function content2FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Content2$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Content2' from JSON`, + ); +} + /** @internal */ export const CreateMessageRequestContent$inboundSchema: z.ZodType< CreateMessageRequestContent, @@ -239,6 +256,26 @@ export namespace CreateMessageRequestContent$ { export type Outbound = CreateMessageRequestContent$Outbound; } +export function createMessageRequestContentToJSON( + createMessageRequestContent: CreateMessageRequestContent, +): string { + return JSON.stringify( + CreateMessageRequestContent$outboundSchema.parse( + createMessageRequestContent, + ), + ); +} + +export function createMessageRequestContentFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateMessageRequestContent$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateMessageRequestContent' from JSON`, + ); +} + /** @internal */ export const CreateMessageRequestTools$inboundSchema: z.ZodType< CreateMessageRequestTools, @@ -277,6 +314,24 @@ export namespace CreateMessageRequestTools$ { export type Outbound = CreateMessageRequestTools$Outbound; } +export function createMessageRequestToolsToJSON( + createMessageRequestTools: CreateMessageRequestTools, +): string { + return JSON.stringify( + CreateMessageRequestTools$outboundSchema.parse(createMessageRequestTools), + ); +} + +export function createMessageRequestToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateMessageRequestTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateMessageRequestTools' from JSON`, + ); +} + /** @internal */ export const Attachments$inboundSchema: z.ZodType< Attachments, @@ -338,6 +393,20 @@ export namespace Attachments$ { export type Outbound = Attachments$Outbound; } +export function attachmentsToJSON(attachments: Attachments): string { + return JSON.stringify(Attachments$outboundSchema.parse(attachments)); +} + +export function attachmentsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Attachments$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Attachments' from JSON`, + ); +} + /** @internal */ export const CreateMessageRequestMetadata$inboundSchema: z.ZodType< CreateMessageRequestMetadata, @@ -368,6 +437,26 @@ export namespace CreateMessageRequestMetadata$ { export type Outbound = CreateMessageRequestMetadata$Outbound; } +export function createMessageRequestMetadataToJSON( + createMessageRequestMetadata: CreateMessageRequestMetadata, +): string { + return JSON.stringify( + CreateMessageRequestMetadata$outboundSchema.parse( + createMessageRequestMetadata, + ), + ); +} + +export function createMessageRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateMessageRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateMessageRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateMessageRequest$inboundSchema: z.ZodType< CreateMessageRequest, @@ -441,3 +530,21 @@ export namespace CreateMessageRequest$ { /** @deprecated use `CreateMessageRequest$Outbound` instead. */ export type Outbound = CreateMessageRequest$Outbound; } + +export function createMessageRequestToJSON( + createMessageRequest: CreateMessageRequest, +): string { + return JSON.stringify( + CreateMessageRequest$outboundSchema.parse(createMessageRequest), + ); +} + +export function createMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateMessageRequest' from JSON`, + ); +} diff --git a/src/models/components/createmoderationrequest.ts b/src/models/components/createmoderationrequest.ts index 358d271..239f101 100644 --- a/src/models/components/createmoderationrequest.ts +++ b/src/models/components/createmoderationrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `text`. @@ -177,6 +180,20 @@ export namespace Three2$ { export type Outbound = Three2$Outbound; } +export function three2ToJSON(three2: Three2): string { + return JSON.stringify(Three2$outboundSchema.parse(three2)); +} + +export function three2FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Three2$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Three2' from JSON`, + ); +} + /** @internal */ export const ThreeType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ThreeType); @@ -232,6 +249,20 @@ export namespace ThreeImageUrl$ { export type Outbound = ThreeImageUrl$Outbound; } +export function threeImageUrlToJSON(threeImageUrl: ThreeImageUrl): string { + return JSON.stringify(ThreeImageUrl$outboundSchema.parse(threeImageUrl)); +} + +export function threeImageUrlFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreeImageUrl$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreeImageUrl' from JSON`, + ); +} + /** @internal */ export const Three1$inboundSchema: z.ZodType = z .object({ @@ -276,6 +307,20 @@ export namespace Three1$ { export type Outbound = Three1$Outbound; } +export function three1ToJSON(three1: Three1): string { + return JSON.stringify(Three1$outboundSchema.parse(three1)); +} + +export function three1FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Three1$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Three1' from JSON`, + ); +} + /** @internal */ export const Three$inboundSchema: z.ZodType = z .union([ @@ -309,6 +354,20 @@ export namespace Three$ { export type Outbound = Three$Outbound; } +export function threeToJSON(three: Three): string { + return JSON.stringify(Three$outboundSchema.parse(three)); +} + +export function threeFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Three$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Three' from JSON`, + ); +} + /** @internal */ export const CreateModerationRequestInput$inboundSchema: z.ZodType< CreateModerationRequestInput, @@ -356,6 +415,26 @@ export namespace CreateModerationRequestInput$ { export type Outbound = CreateModerationRequestInput$Outbound; } +export function createModerationRequestInputToJSON( + createModerationRequestInput: CreateModerationRequestInput, +): string { + return JSON.stringify( + CreateModerationRequestInput$outboundSchema.parse( + createModerationRequestInput, + ), + ); +} + +export function createModerationRequestInputFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateModerationRequestInput$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateModerationRequestInput' from JSON`, + ); +} + /** @internal */ export const CreateModerationRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateModerationRequestModel2 @@ -407,6 +486,26 @@ export namespace CreateModerationRequestModel$ { export type Outbound = CreateModerationRequestModel$Outbound; } +export function createModerationRequestModelToJSON( + createModerationRequestModel: CreateModerationRequestModel, +): string { + return JSON.stringify( + CreateModerationRequestModel$outboundSchema.parse( + createModerationRequestModel, + ), + ); +} + +export function createModerationRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateModerationRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateModerationRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateModerationRequest$inboundSchema: z.ZodType< CreateModerationRequest, @@ -461,3 +560,21 @@ export namespace CreateModerationRequest$ { /** @deprecated use `CreateModerationRequest$Outbound` instead. */ export type Outbound = CreateModerationRequest$Outbound; } + +export function createModerationRequestToJSON( + createModerationRequest: CreateModerationRequest, +): string { + return JSON.stringify( + CreateModerationRequest$outboundSchema.parse(createModerationRequest), + ); +} + +export function createModerationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateModerationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateModerationRequest' from JSON`, + ); +} diff --git a/src/models/components/createmoderationresponse.ts b/src/models/components/createmoderationresponse.ts index 153427b..7c5380c 100644 --- a/src/models/components/createmoderationresponse.ts +++ b/src/models/components/createmoderationresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * A list of the categories, and whether they are flagged or not. @@ -382,6 +385,20 @@ export namespace Categories$ { export type Outbound = Categories$Outbound; } +export function categoriesToJSON(categories: Categories): string { + return JSON.stringify(Categories$outboundSchema.parse(categories)); +} + +export function categoriesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Categories$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Categories' from JSON`, + ); +} + /** @internal */ export const CategoryScores$inboundSchema: z.ZodType< CategoryScores, @@ -476,6 +493,20 @@ export namespace CategoryScores$ { export type Outbound = CategoryScores$Outbound; } +export function categoryScoresToJSON(categoryScores: CategoryScores): string { + return JSON.stringify(CategoryScores$outboundSchema.parse(categoryScores)); +} + +export function categoryScoresFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CategoryScores$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CategoryScores' from JSON`, + ); +} + /** @internal */ export const Hate$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Hate, @@ -830,6 +861,24 @@ export namespace CategoryAppliedInputTypes$ { export type Outbound = CategoryAppliedInputTypes$Outbound; } +export function categoryAppliedInputTypesToJSON( + categoryAppliedInputTypes: CategoryAppliedInputTypes, +): string { + return JSON.stringify( + CategoryAppliedInputTypes$outboundSchema.parse(categoryAppliedInputTypes), + ); +} + +export function categoryAppliedInputTypesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CategoryAppliedInputTypes$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CategoryAppliedInputTypes' from JSON`, + ); +} + /** @internal */ export const Results$inboundSchema: z.ZodType = z.object({ @@ -886,6 +935,20 @@ export namespace Results$ { export type Outbound = Results$Outbound; } +export function resultsToJSON(results: Results): string { + return JSON.stringify(Results$outboundSchema.parse(results)); +} + +export function resultsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Results$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Results' from JSON`, + ); +} + /** @internal */ export const CreateModerationResponse$inboundSchema: z.ZodType< CreateModerationResponse, @@ -927,3 +990,21 @@ export namespace CreateModerationResponse$ { /** @deprecated use `CreateModerationResponse$Outbound` instead. */ export type Outbound = CreateModerationResponse$Outbound; } + +export function createModerationResponseToJSON( + createModerationResponse: CreateModerationResponse, +): string { + return JSON.stringify( + CreateModerationResponse$outboundSchema.parse(createModerationResponse), + ); +} + +export function createModerationResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateModerationResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateModerationResponse' from JSON`, + ); +} diff --git a/src/models/components/createrunrequest.ts b/src/models/components/createrunrequest.ts index 33731b2..ec91c7a 100644 --- a/src/models/components/createrunrequest.ts +++ b/src/models/components/createrunrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -174,6 +177,10 @@ export type CreateRunRequest = { * Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. */ toolChoice?: AssistantsApiToolChoiceOption | undefined; + /** + * Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + */ + parallelToolCalls?: boolean | undefined; /** * Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. * @@ -239,6 +246,24 @@ export namespace CreateRunRequestModel$ { export type Outbound = CreateRunRequestModel$Outbound; } +export function createRunRequestModelToJSON( + createRunRequestModel: CreateRunRequestModel, +): string { + return JSON.stringify( + CreateRunRequestModel$outboundSchema.parse(createRunRequestModel), + ); +} + +export function createRunRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateRunRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateRunRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateRunRequestTools$inboundSchema: z.ZodType< CreateRunRequestTools, @@ -280,6 +305,24 @@ export namespace CreateRunRequestTools$ { export type Outbound = CreateRunRequestTools$Outbound; } +export function createRunRequestToolsToJSON( + createRunRequestTools: CreateRunRequestTools, +): string { + return JSON.stringify( + CreateRunRequestTools$outboundSchema.parse(createRunRequestTools), + ); +} + +export function createRunRequestToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateRunRequestTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateRunRequestTools' from JSON`, + ); +} + /** @internal */ export const CreateRunRequestMetadata$inboundSchema: z.ZodType< CreateRunRequestMetadata, @@ -310,6 +353,24 @@ export namespace CreateRunRequestMetadata$ { export type Outbound = CreateRunRequestMetadata$Outbound; } +export function createRunRequestMetadataToJSON( + createRunRequestMetadata: CreateRunRequestMetadata, +): string { + return JSON.stringify( + CreateRunRequestMetadata$outboundSchema.parse(createRunRequestMetadata), + ); +} + +export function createRunRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateRunRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateRunRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateRunRequest$inboundSchema: z.ZodType< CreateRunRequest, @@ -341,6 +402,7 @@ export const CreateRunRequest$inboundSchema: z.ZodType< max_completion_tokens: z.nullable(z.number().int()).optional(), truncation_strategy: TruncationObject$inboundSchema.optional(), tool_choice: AssistantsApiToolChoiceOption$inboundSchema.optional(), + parallel_tool_calls: z.boolean().default(true), response_format: AssistantsApiResponseFormatOption$inboundSchema.optional(), }).transform((v) => { return remap$(v, { @@ -352,6 +414,7 @@ export const CreateRunRequest$inboundSchema: z.ZodType< "max_completion_tokens": "maxCompletionTokens", "truncation_strategy": "truncationStrategy", "tool_choice": "toolChoice", + "parallel_tool_calls": "parallelToolCalls", "response_format": "responseFormat", }); }); @@ -379,6 +442,7 @@ export type CreateRunRequest$Outbound = { max_completion_tokens?: number | null | undefined; truncation_strategy?: TruncationObject$Outbound | undefined; tool_choice?: AssistantsApiToolChoiceOption$Outbound | undefined; + parallel_tool_calls: boolean; response_format?: AssistantsApiResponseFormatOption$Outbound | undefined; }; @@ -414,6 +478,7 @@ export const CreateRunRequest$outboundSchema: z.ZodType< maxCompletionTokens: z.nullable(z.number().int()).optional(), truncationStrategy: TruncationObject$outboundSchema.optional(), toolChoice: AssistantsApiToolChoiceOption$outboundSchema.optional(), + parallelToolCalls: z.boolean().default(true), responseFormat: AssistantsApiResponseFormatOption$outboundSchema.optional(), }).transform((v) => { return remap$(v, { @@ -425,6 +490,7 @@ export const CreateRunRequest$outboundSchema: z.ZodType< maxCompletionTokens: "max_completion_tokens", truncationStrategy: "truncation_strategy", toolChoice: "tool_choice", + parallelToolCalls: "parallel_tool_calls", responseFormat: "response_format", }); }); @@ -441,3 +507,21 @@ export namespace CreateRunRequest$ { /** @deprecated use `CreateRunRequest$Outbound` instead. */ export type Outbound = CreateRunRequest$Outbound; } + +export function createRunRequestToJSON( + createRunRequest: CreateRunRequest, +): string { + return JSON.stringify( + CreateRunRequest$outboundSchema.parse(createRunRequest), + ); +} + +export function createRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateRunRequest' from JSON`, + ); +} diff --git a/src/models/components/createspeechrequest.ts b/src/models/components/createspeechrequest.ts index 875ac7d..40e2c23 100644 --- a/src/models/components/createspeechrequest.ts +++ b/src/models/components/createspeechrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const CreateSpeechRequestModel2 = { Tts1: "tts-1", @@ -131,6 +134,24 @@ export namespace CreateSpeechRequestModel$ { export type Outbound = CreateSpeechRequestModel$Outbound; } +export function createSpeechRequestModelToJSON( + createSpeechRequestModel: CreateSpeechRequestModel, +): string { + return JSON.stringify( + CreateSpeechRequestModel$outboundSchema.parse(createSpeechRequestModel), + ); +} + +export function createSpeechRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateSpeechRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateSpeechRequestModel' from JSON`, + ); +} + /** @internal */ export const Voice$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Voice, @@ -232,3 +253,21 @@ export namespace CreateSpeechRequest$ { /** @deprecated use `CreateSpeechRequest$Outbound` instead. */ export type Outbound = CreateSpeechRequest$Outbound; } + +export function createSpeechRequestToJSON( + createSpeechRequest: CreateSpeechRequest, +): string { + return JSON.stringify( + CreateSpeechRequest$outboundSchema.parse(createSpeechRequest), + ); +} + +export function createSpeechRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateSpeechRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateSpeechRequest' from JSON`, + ); +} diff --git a/src/models/components/createthreadandrunrequest.ts b/src/models/components/createthreadandrunrequest.ts index 3cd8980..ab5decc 100644 --- a/src/models/components/createthreadandrunrequest.ts +++ b/src/models/components/createthreadandrunrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -205,6 +208,10 @@ export type CreateThreadAndRunRequest = { * Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. */ toolChoice?: AssistantsApiToolChoiceOption | undefined; + /** + * Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + */ + parallelToolCalls?: boolean | undefined; /** * Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. * @@ -270,6 +277,26 @@ export namespace CreateThreadAndRunRequestModel$ { export type Outbound = CreateThreadAndRunRequestModel$Outbound; } +export function createThreadAndRunRequestModelToJSON( + createThreadAndRunRequestModel: CreateThreadAndRunRequestModel, +): string { + return JSON.stringify( + CreateThreadAndRunRequestModel$outboundSchema.parse( + createThreadAndRunRequestModel, + ), + ); +} + +export function createThreadAndRunRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadAndRunRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequestTools$inboundSchema: z.ZodType< CreateThreadAndRunRequestTools, @@ -311,6 +338,26 @@ export namespace CreateThreadAndRunRequestTools$ { export type Outbound = CreateThreadAndRunRequestTools$Outbound; } +export function createThreadAndRunRequestToolsToJSON( + createThreadAndRunRequestTools: CreateThreadAndRunRequestTools, +): string { + return JSON.stringify( + CreateThreadAndRunRequestTools$outboundSchema.parse( + createThreadAndRunRequestTools, + ), + ); +} + +export function createThreadAndRunRequestToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadAndRunRequestTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequestTools' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequestCodeInterpreter$inboundSchema: z.ZodType< CreateThreadAndRunRequestCodeInterpreter, @@ -357,6 +404,33 @@ export namespace CreateThreadAndRunRequestCodeInterpreter$ { export type Outbound = CreateThreadAndRunRequestCodeInterpreter$Outbound; } +export function createThreadAndRunRequestCodeInterpreterToJSON( + createThreadAndRunRequestCodeInterpreter: + CreateThreadAndRunRequestCodeInterpreter, +): string { + return JSON.stringify( + CreateThreadAndRunRequestCodeInterpreter$outboundSchema.parse( + createThreadAndRunRequestCodeInterpreter, + ), + ); +} + +export function createThreadAndRunRequestCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadAndRunRequestCodeInterpreter, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadAndRunRequestCodeInterpreter$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateThreadAndRunRequestCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequestFileSearch$inboundSchema: z.ZodType< CreateThreadAndRunRequestFileSearch, @@ -403,6 +477,27 @@ export namespace CreateThreadAndRunRequestFileSearch$ { export type Outbound = CreateThreadAndRunRequestFileSearch$Outbound; } +export function createThreadAndRunRequestFileSearchToJSON( + createThreadAndRunRequestFileSearch: CreateThreadAndRunRequestFileSearch, +): string { + return JSON.stringify( + CreateThreadAndRunRequestFileSearch$outboundSchema.parse( + createThreadAndRunRequestFileSearch, + ), + ); +} + +export function createThreadAndRunRequestFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateThreadAndRunRequestFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequestFileSearch' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequestToolResources$inboundSchema: z.ZodType< CreateThreadAndRunRequestToolResources, @@ -462,6 +557,28 @@ export namespace CreateThreadAndRunRequestToolResources$ { export type Outbound = CreateThreadAndRunRequestToolResources$Outbound; } +export function createThreadAndRunRequestToolResourcesToJSON( + createThreadAndRunRequestToolResources: + CreateThreadAndRunRequestToolResources, +): string { + return JSON.stringify( + CreateThreadAndRunRequestToolResources$outboundSchema.parse( + createThreadAndRunRequestToolResources, + ), + ); +} + +export function createThreadAndRunRequestToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateThreadAndRunRequestToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequestToolResources' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequestMetadata$inboundSchema: z.ZodType< CreateThreadAndRunRequestMetadata, @@ -493,6 +610,26 @@ export namespace CreateThreadAndRunRequestMetadata$ { export type Outbound = CreateThreadAndRunRequestMetadata$Outbound; } +export function createThreadAndRunRequestMetadataToJSON( + createThreadAndRunRequestMetadata: CreateThreadAndRunRequestMetadata, +): string { + return JSON.stringify( + CreateThreadAndRunRequestMetadata$outboundSchema.parse( + createThreadAndRunRequestMetadata, + ), + ); +} + +export function createThreadAndRunRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadAndRunRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateThreadAndRunRequest$inboundSchema: z.ZodType< CreateThreadAndRunRequest, @@ -527,6 +664,7 @@ export const CreateThreadAndRunRequest$inboundSchema: z.ZodType< max_completion_tokens: z.nullable(z.number().int()).optional(), truncation_strategy: TruncationObject$inboundSchema.optional(), tool_choice: AssistantsApiToolChoiceOption$inboundSchema.optional(), + parallel_tool_calls: z.boolean().default(true), response_format: AssistantsApiResponseFormatOption$inboundSchema.optional(), }).transform((v) => { return remap$(v, { @@ -537,6 +675,7 @@ export const CreateThreadAndRunRequest$inboundSchema: z.ZodType< "max_completion_tokens": "maxCompletionTokens", "truncation_strategy": "truncationStrategy", "tool_choice": "toolChoice", + "parallel_tool_calls": "parallelToolCalls", "response_format": "responseFormat", }); }); @@ -567,6 +706,7 @@ export type CreateThreadAndRunRequest$Outbound = { max_completion_tokens?: number | null | undefined; truncation_strategy?: TruncationObject$Outbound | undefined; tool_choice?: AssistantsApiToolChoiceOption$Outbound | undefined; + parallel_tool_calls: boolean; response_format?: AssistantsApiResponseFormatOption$Outbound | undefined; }; @@ -604,6 +744,7 @@ export const CreateThreadAndRunRequest$outboundSchema: z.ZodType< maxCompletionTokens: z.nullable(z.number().int()).optional(), truncationStrategy: TruncationObject$outboundSchema.optional(), toolChoice: AssistantsApiToolChoiceOption$outboundSchema.optional(), + parallelToolCalls: z.boolean().default(true), responseFormat: AssistantsApiResponseFormatOption$outboundSchema.optional(), }).transform((v) => { return remap$(v, { @@ -614,6 +755,7 @@ export const CreateThreadAndRunRequest$outboundSchema: z.ZodType< maxCompletionTokens: "max_completion_tokens", truncationStrategy: "truncation_strategy", toolChoice: "tool_choice", + parallelToolCalls: "parallel_tool_calls", responseFormat: "response_format", }); }); @@ -630,3 +772,21 @@ export namespace CreateThreadAndRunRequest$ { /** @deprecated use `CreateThreadAndRunRequest$Outbound` instead. */ export type Outbound = CreateThreadAndRunRequest$Outbound; } + +export function createThreadAndRunRequestToJSON( + createThreadAndRunRequest: CreateThreadAndRunRequest, +): string { + return JSON.stringify( + CreateThreadAndRunRequest$outboundSchema.parse(createThreadAndRunRequest), + ); +} + +export function createThreadAndRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadAndRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadAndRunRequest' from JSON`, + ); +} diff --git a/src/models/components/createthreadrequest.ts b/src/models/components/createthreadrequest.ts index 7618155..51d5e42 100644 --- a/src/models/components/createthreadrequest.ts +++ b/src/models/components/createthreadrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CreateMessageRequest, CreateMessageRequest$inboundSchema, @@ -333,6 +336,27 @@ export namespace CreateThreadRequestCodeInterpreter$ { export type Outbound = CreateThreadRequestCodeInterpreter$Outbound; } +export function createThreadRequestCodeInterpreterToJSON( + createThreadRequestCodeInterpreter: CreateThreadRequestCodeInterpreter, +): string { + return JSON.stringify( + CreateThreadRequestCodeInterpreter$outboundSchema.parse( + createThreadRequestCodeInterpreter, + ), + ); +} + +export function createThreadRequestCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateThreadRequestCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyToolResourcesFileSearch2Type$inboundSchema: z.ZodNativeEnum< @@ -415,6 +439,32 @@ export namespace CreateThreadRequestChunkingStrategyToolResourcesStatic$ { CreateThreadRequestChunkingStrategyToolResourcesStatic$Outbound; } +export function createThreadRequestChunkingStrategyToolResourcesStaticToJSON( + createThreadRequestChunkingStrategyToolResourcesStatic: + CreateThreadRequestChunkingStrategyToolResourcesStatic, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyToolResourcesStatic$outboundSchema.parse( + createThreadRequestChunkingStrategyToolResourcesStatic, + ), + ); +} + +export function createThreadRequestChunkingStrategyToolResourcesStaticFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyToolResourcesStatic, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyToolResourcesStatic$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestChunkingStrategyToolResourcesStatic' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy$inboundSchema: z.ZodType< @@ -466,6 +516,33 @@ export namespace CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingS CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy$Outbound; } +export function createThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategyToJSON( + createThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy: + CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy$outboundSchema + .parse( + createThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy, + ), + ); +} + +export function createThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestChunkingStrategyToolResourcesStaticChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyToolResourcesFileSearchType$inboundSchema: z.ZodNativeEnum< @@ -538,6 +615,33 @@ export namespace CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStr CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy$Outbound; } +export function createThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategyToJSON( + createThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy: + CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy$outboundSchema + .parse( + createThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy, + ), + ); +} + +export function createThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestChunkingStrategyToolResourcesAutoChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchToolResourcesChunkingStrategy$inboundSchema: z.ZodType< @@ -589,6 +693,31 @@ export namespace CreateThreadRequestFileSearchToolResourcesChunkingStrategy$ { CreateThreadRequestFileSearchToolResourcesChunkingStrategy$Outbound; } +export function createThreadRequestFileSearchToolResourcesChunkingStrategyToJSON( + createThreadRequestFileSearchToolResourcesChunkingStrategy: + CreateThreadRequestFileSearchToolResourcesChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchToolResourcesChunkingStrategy$outboundSchema + .parse(createThreadRequestFileSearchToolResourcesChunkingStrategy), + ); +} + +export function createThreadRequestFileSearchToolResourcesChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestFileSearchToolResourcesChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchToolResourcesChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearchToolResourcesChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchToolResourcesMetadata$inboundSchema: z.ZodType< @@ -624,6 +753,33 @@ export namespace CreateThreadRequestFileSearchToolResourcesMetadata$ { CreateThreadRequestFileSearchToolResourcesMetadata$Outbound; } +export function createThreadRequestFileSearchToolResourcesMetadataToJSON( + createThreadRequestFileSearchToolResourcesMetadata: + CreateThreadRequestFileSearchToolResourcesMetadata, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchToolResourcesMetadata$outboundSchema.parse( + createThreadRequestFileSearchToolResourcesMetadata, + ), + ); +} + +export function createThreadRequestFileSearchToolResourcesMetadataFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestFileSearchToolResourcesMetadata, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchToolResourcesMetadata$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateThreadRequestFileSearchToolResourcesMetadata' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchToolResourcesVectorStores$inboundSchema: z.ZodType< @@ -704,6 +860,32 @@ export namespace CreateThreadRequestFileSearchToolResourcesVectorStores$ { CreateThreadRequestFileSearchToolResourcesVectorStores$Outbound; } +export function createThreadRequestFileSearchToolResourcesVectorStoresToJSON( + createThreadRequestFileSearchToolResourcesVectorStores: + CreateThreadRequestFileSearchToolResourcesVectorStores, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchToolResourcesVectorStores$outboundSchema.parse( + createThreadRequestFileSearchToolResourcesVectorStores, + ), + ); +} + +export function createThreadRequestFileSearchToolResourcesVectorStoresFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestFileSearchToolResourcesVectorStores, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchToolResourcesVectorStores$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearchToolResourcesVectorStores' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearch2$inboundSchema: z.ZodType< CreateThreadRequestFileSearch2, @@ -763,6 +945,26 @@ export namespace CreateThreadRequestFileSearch2$ { export type Outbound = CreateThreadRequestFileSearch2$Outbound; } +export function createThreadRequestFileSearch2ToJSON( + createThreadRequestFileSearch2: CreateThreadRequestFileSearch2, +): string { + return JSON.stringify( + CreateThreadRequestFileSearch2$outboundSchema.parse( + createThreadRequestFileSearch2, + ), + ); +} + +export function createThreadRequestFileSearch2FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequestFileSearch2$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearch2' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyToolResourcesType$inboundSchema: z.ZodNativeEnum = @@ -838,6 +1040,33 @@ export namespace CreateThreadRequestChunkingStrategyStatic$ { export type Outbound = CreateThreadRequestChunkingStrategyStatic$Outbound; } +export function createThreadRequestChunkingStrategyStaticToJSON( + createThreadRequestChunkingStrategyStatic: + CreateThreadRequestChunkingStrategyStatic, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyStatic$outboundSchema.parse( + createThreadRequestChunkingStrategyStatic, + ), + ); +} + +export function createThreadRequestChunkingStrategyStaticFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyStatic, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyStatic$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateThreadRequestChunkingStrategyStatic' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyStaticChunkingStrategy$inboundSchema: z.ZodType< @@ -887,6 +1116,31 @@ export namespace CreateThreadRequestChunkingStrategyStaticChunkingStrategy$ { CreateThreadRequestChunkingStrategyStaticChunkingStrategy$Outbound; } +export function createThreadRequestChunkingStrategyStaticChunkingStrategyToJSON( + createThreadRequestChunkingStrategyStaticChunkingStrategy: + CreateThreadRequestChunkingStrategyStaticChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyStaticChunkingStrategy$outboundSchema + .parse(createThreadRequestChunkingStrategyStaticChunkingStrategy), + ); +} + +export function createThreadRequestChunkingStrategyStaticChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyStaticChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyStaticChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestChunkingStrategyStaticChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestChunkingStrategyType$inboundSchema: z.ZodNativeEnum = z @@ -951,6 +1205,31 @@ export namespace CreateThreadRequestChunkingStrategyAutoChunkingStrategy$ { CreateThreadRequestChunkingStrategyAutoChunkingStrategy$Outbound; } +export function createThreadRequestChunkingStrategyAutoChunkingStrategyToJSON( + createThreadRequestChunkingStrategyAutoChunkingStrategy: + CreateThreadRequestChunkingStrategyAutoChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestChunkingStrategyAutoChunkingStrategy$outboundSchema + .parse(createThreadRequestChunkingStrategyAutoChunkingStrategy), + ); +} + +export function createThreadRequestChunkingStrategyAutoChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestChunkingStrategyAutoChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestChunkingStrategyAutoChunkingStrategy$inboundSchema + .parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestChunkingStrategyAutoChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchChunkingStrategy$inboundSchema: z.ZodType< @@ -1001,6 +1280,33 @@ export namespace CreateThreadRequestFileSearchChunkingStrategy$ { export type Outbound = CreateThreadRequestFileSearchChunkingStrategy$Outbound; } +export function createThreadRequestFileSearchChunkingStrategyToJSON( + createThreadRequestFileSearchChunkingStrategy: + CreateThreadRequestFileSearchChunkingStrategy, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchChunkingStrategy$outboundSchema.parse( + createThreadRequestFileSearchChunkingStrategy, + ), + ); +} + +export function createThreadRequestFileSearchChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestFileSearchChunkingStrategy, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchChunkingStrategy$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateThreadRequestFileSearchChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchMetadata$inboundSchema: z.ZodType< CreateThreadRequestFileSearchMetadata, @@ -1033,6 +1339,27 @@ export namespace CreateThreadRequestFileSearchMetadata$ { export type Outbound = CreateThreadRequestFileSearchMetadata$Outbound; } +export function createThreadRequestFileSearchMetadataToJSON( + createThreadRequestFileSearchMetadata: CreateThreadRequestFileSearchMetadata, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchMetadata$outboundSchema.parse( + createThreadRequestFileSearchMetadata, + ), + ); +} + +export function createThreadRequestFileSearchMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearchMetadata' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearchVectorStores$inboundSchema: z.ZodType< CreateThreadRequestFileSearchVectorStores, @@ -1107,6 +1434,33 @@ export namespace CreateThreadRequestFileSearchVectorStores$ { export type Outbound = CreateThreadRequestFileSearchVectorStores$Outbound; } +export function createThreadRequestFileSearchVectorStoresToJSON( + createThreadRequestFileSearchVectorStores: + CreateThreadRequestFileSearchVectorStores, +): string { + return JSON.stringify( + CreateThreadRequestFileSearchVectorStores$outboundSchema.parse( + createThreadRequestFileSearchVectorStores, + ), + ); +} + +export function createThreadRequestFileSearchVectorStoresFromJSON( + jsonString: string, +): SafeParseResult< + CreateThreadRequestFileSearchVectorStores, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + CreateThreadRequestFileSearchVectorStores$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'CreateThreadRequestFileSearchVectorStores' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearch1$inboundSchema: z.ZodType< CreateThreadRequestFileSearch1, @@ -1162,6 +1516,26 @@ export namespace CreateThreadRequestFileSearch1$ { export type Outbound = CreateThreadRequestFileSearch1$Outbound; } +export function createThreadRequestFileSearch1ToJSON( + createThreadRequestFileSearch1: CreateThreadRequestFileSearch1, +): string { + return JSON.stringify( + CreateThreadRequestFileSearch1$outboundSchema.parse( + createThreadRequestFileSearch1, + ), + ); +} + +export function createThreadRequestFileSearch1FromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequestFileSearch1$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearch1' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestFileSearch$inboundSchema: z.ZodType< CreateThreadRequestFileSearch, @@ -1200,6 +1574,26 @@ export namespace CreateThreadRequestFileSearch$ { export type Outbound = CreateThreadRequestFileSearch$Outbound; } +export function createThreadRequestFileSearchToJSON( + createThreadRequestFileSearch: CreateThreadRequestFileSearch, +): string { + return JSON.stringify( + CreateThreadRequestFileSearch$outboundSchema.parse( + createThreadRequestFileSearch, + ), + ); +} + +export function createThreadRequestFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequestFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestFileSearch' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestToolResources$inboundSchema: z.ZodType< CreateThreadRequestToolResources, @@ -1262,6 +1656,26 @@ export namespace CreateThreadRequestToolResources$ { export type Outbound = CreateThreadRequestToolResources$Outbound; } +export function createThreadRequestToolResourcesToJSON( + createThreadRequestToolResources: CreateThreadRequestToolResources, +): string { + return JSON.stringify( + CreateThreadRequestToolResources$outboundSchema.parse( + createThreadRequestToolResources, + ), + ); +} + +export function createThreadRequestToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequestToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestToolResources' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequestMetadata$inboundSchema: z.ZodType< CreateThreadRequestMetadata, @@ -1292,6 +1706,26 @@ export namespace CreateThreadRequestMetadata$ { export type Outbound = CreateThreadRequestMetadata$Outbound; } +export function createThreadRequestMetadataToJSON( + createThreadRequestMetadata: CreateThreadRequestMetadata, +): string { + return JSON.stringify( + CreateThreadRequestMetadata$outboundSchema.parse( + createThreadRequestMetadata, + ), + ); +} + +export function createThreadRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateThreadRequest$inboundSchema: z.ZodType< CreateThreadRequest, @@ -1347,3 +1781,21 @@ export namespace CreateThreadRequest$ { /** @deprecated use `CreateThreadRequest$Outbound` instead. */ export type Outbound = CreateThreadRequest$Outbound; } + +export function createThreadRequestToJSON( + createThreadRequest: CreateThreadRequest, +): string { + return JSON.stringify( + CreateThreadRequest$outboundSchema.parse(createThreadRequest), + ); +} + +export function createThreadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateThreadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateThreadRequest' from JSON`, + ); +} diff --git a/src/models/components/createtranscriptionrequest.ts b/src/models/components/createtranscriptionrequest.ts index fb09c11..11536c8 100644 --- a/src/models/components/createtranscriptionrequest.ts +++ b/src/models/components/createtranscriptionrequest.ts @@ -4,8 +4,11 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AudioResponseFormat, AudioResponseFormat$inboundSchema, @@ -130,6 +133,20 @@ export namespace FileT$ { export type Outbound = FileT$Outbound; } +export function fileToJSON(fileT: FileT): string { + return JSON.stringify(FileT$outboundSchema.parse(fileT)); +} + +export function fileFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileT$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileT' from JSON`, + ); +} + /** @internal */ export const CreateTranscriptionRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateTranscriptionRequestModel2 @@ -181,6 +198,26 @@ export namespace CreateTranscriptionRequestModel$ { export type Outbound = CreateTranscriptionRequestModel$Outbound; } +export function createTranscriptionRequestModelToJSON( + createTranscriptionRequestModel: CreateTranscriptionRequestModel, +): string { + return JSON.stringify( + CreateTranscriptionRequestModel$outboundSchema.parse( + createTranscriptionRequestModel, + ), + ); +} + +export function createTranscriptionRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranscriptionRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranscriptionRequestModel' from JSON`, + ); +} + /** @internal */ export const TimestampGranularities$inboundSchema: z.ZodNativeEnum< typeof TimestampGranularities @@ -267,3 +304,21 @@ export namespace CreateTranscriptionRequest$ { /** @deprecated use `CreateTranscriptionRequest$Outbound` instead. */ export type Outbound = CreateTranscriptionRequest$Outbound; } + +export function createTranscriptionRequestToJSON( + createTranscriptionRequest: CreateTranscriptionRequest, +): string { + return JSON.stringify( + CreateTranscriptionRequest$outboundSchema.parse(createTranscriptionRequest), + ); +} + +export function createTranscriptionRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranscriptionRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranscriptionRequest' from JSON`, + ); +} diff --git a/src/models/components/createtranscriptionresponsejson.ts b/src/models/components/createtranscriptionresponsejson.ts index 9a5ceb7..54ee764 100644 --- a/src/models/components/createtranscriptionresponsejson.ts +++ b/src/models/components/createtranscriptionresponsejson.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Represents a transcription response returned by model, based on the provided input. @@ -49,3 +52,23 @@ export namespace CreateTranscriptionResponseJson$ { /** @deprecated use `CreateTranscriptionResponseJson$Outbound` instead. */ export type Outbound = CreateTranscriptionResponseJson$Outbound; } + +export function createTranscriptionResponseJsonToJSON( + createTranscriptionResponseJson: CreateTranscriptionResponseJson, +): string { + return JSON.stringify( + CreateTranscriptionResponseJson$outboundSchema.parse( + createTranscriptionResponseJson, + ), + ); +} + +export function createTranscriptionResponseJsonFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranscriptionResponseJson$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranscriptionResponseJson' from JSON`, + ); +} diff --git a/src/models/components/createtranscriptionresponseverbosejson.ts b/src/models/components/createtranscriptionresponseverbosejson.ts index 29438d3..2310143 100644 --- a/src/models/components/createtranscriptionresponseverbosejson.ts +++ b/src/models/components/createtranscriptionresponseverbosejson.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { TranscriptionSegment, TranscriptionSegment$inboundSchema, @@ -91,3 +94,25 @@ export namespace CreateTranscriptionResponseVerboseJson$ { /** @deprecated use `CreateTranscriptionResponseVerboseJson$Outbound` instead. */ export type Outbound = CreateTranscriptionResponseVerboseJson$Outbound; } + +export function createTranscriptionResponseVerboseJsonToJSON( + createTranscriptionResponseVerboseJson: + CreateTranscriptionResponseVerboseJson, +): string { + return JSON.stringify( + CreateTranscriptionResponseVerboseJson$outboundSchema.parse( + createTranscriptionResponseVerboseJson, + ), + ); +} + +export function createTranscriptionResponseVerboseJsonFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateTranscriptionResponseVerboseJson$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranscriptionResponseVerboseJson' from JSON`, + ); +} diff --git a/src/models/components/createtranslationrequest.ts b/src/models/components/createtranslationrequest.ts index 07d5dec..1a8833b 100644 --- a/src/models/components/createtranslationrequest.ts +++ b/src/models/components/createtranslationrequest.ts @@ -4,8 +4,11 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { blobLikeSchema } from "../../types/blobs.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AudioResponseFormat, AudioResponseFormat$inboundSchema, @@ -115,6 +118,26 @@ export namespace CreateTranslationRequestFile$ { export type Outbound = CreateTranslationRequestFile$Outbound; } +export function createTranslationRequestFileToJSON( + createTranslationRequestFile: CreateTranslationRequestFile, +): string { + return JSON.stringify( + CreateTranslationRequestFile$outboundSchema.parse( + createTranslationRequestFile, + ), + ); +} + +export function createTranslationRequestFileFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranslationRequestFile$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationRequestFile' from JSON`, + ); +} + /** @internal */ export const CreateTranslationRequestModel2$inboundSchema: z.ZodNativeEnum< typeof CreateTranslationRequestModel2 @@ -166,6 +189,26 @@ export namespace CreateTranslationRequestModel$ { export type Outbound = CreateTranslationRequestModel$Outbound; } +export function createTranslationRequestModelToJSON( + createTranslationRequestModel: CreateTranslationRequestModel, +): string { + return JSON.stringify( + CreateTranslationRequestModel$outboundSchema.parse( + createTranslationRequestModel, + ), + ); +} + +export function createTranslationRequestModelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranslationRequestModel$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationRequestModel' from JSON`, + ); +} + /** @internal */ export const CreateTranslationRequest$inboundSchema: z.ZodType< CreateTranslationRequest, @@ -223,3 +266,21 @@ export namespace CreateTranslationRequest$ { /** @deprecated use `CreateTranslationRequest$Outbound` instead. */ export type Outbound = CreateTranslationRequest$Outbound; } + +export function createTranslationRequestToJSON( + createTranslationRequest: CreateTranslationRequest, +): string { + return JSON.stringify( + CreateTranslationRequest$outboundSchema.parse(createTranslationRequest), + ); +} + +export function createTranslationRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranslationRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationRequest' from JSON`, + ); +} diff --git a/src/models/components/createtranslationresponsejson.ts b/src/models/components/createtranslationresponsejson.ts index 4a20b82..0779852 100644 --- a/src/models/components/createtranslationresponsejson.ts +++ b/src/models/components/createtranslationresponsejson.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateTranslationResponseJson = { text: string; @@ -43,3 +46,23 @@ export namespace CreateTranslationResponseJson$ { /** @deprecated use `CreateTranslationResponseJson$Outbound` instead. */ export type Outbound = CreateTranslationResponseJson$Outbound; } + +export function createTranslationResponseJsonToJSON( + createTranslationResponseJson: CreateTranslationResponseJson, +): string { + return JSON.stringify( + CreateTranslationResponseJson$outboundSchema.parse( + createTranslationResponseJson, + ), + ); +} + +export function createTranslationResponseJsonFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranslationResponseJson$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationResponseJson' from JSON`, + ); +} diff --git a/src/models/components/createtranslationresponseverbosejson.ts b/src/models/components/createtranslationresponseverbosejson.ts index f744863..0ad95b3 100644 --- a/src/models/components/createtranslationresponseverbosejson.ts +++ b/src/models/components/createtranslationresponseverbosejson.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { TranscriptionSegment, TranscriptionSegment$inboundSchema, @@ -75,3 +78,24 @@ export namespace CreateTranslationResponseVerboseJson$ { /** @deprecated use `CreateTranslationResponseVerboseJson$Outbound` instead. */ export type Outbound = CreateTranslationResponseVerboseJson$Outbound; } + +export function createTranslationResponseVerboseJsonToJSON( + createTranslationResponseVerboseJson: CreateTranslationResponseVerboseJson, +): string { + return JSON.stringify( + CreateTranslationResponseVerboseJson$outboundSchema.parse( + createTranslationResponseVerboseJson, + ), + ); +} + +export function createTranslationResponseVerboseJsonFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateTranslationResponseVerboseJson$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationResponseVerboseJson' from JSON`, + ); +} diff --git a/src/models/components/createuploadrequest.ts b/src/models/components/createuploadrequest.ts index e45cd17..e839542 100644 --- a/src/models/components/createuploadrequest.ts +++ b/src/models/components/createuploadrequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The intended purpose of the uploaded file. @@ -134,3 +137,21 @@ export namespace CreateUploadRequest$ { /** @deprecated use `CreateUploadRequest$Outbound` instead. */ export type Outbound = CreateUploadRequest$Outbound; } + +export function createUploadRequestToJSON( + createUploadRequest: CreateUploadRequest, +): string { + return JSON.stringify( + CreateUploadRequest$outboundSchema.parse(createUploadRequest), + ); +} + +export function createUploadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateUploadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateUploadRequest' from JSON`, + ); +} diff --git a/src/models/components/createvectorstorefilebatchrequest.ts b/src/models/components/createvectorstorefilebatchrequest.ts index 41ca4b0..1f68ec8 100644 --- a/src/models/components/createvectorstorefilebatchrequest.ts +++ b/src/models/components/createvectorstorefilebatchrequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChunkingStrategyRequestParam, ChunkingStrategyRequestParam$inboundSchema, @@ -71,3 +74,23 @@ export namespace CreateVectorStoreFileBatchRequest$ { /** @deprecated use `CreateVectorStoreFileBatchRequest$Outbound` instead. */ export type Outbound = CreateVectorStoreFileBatchRequest$Outbound; } + +export function createVectorStoreFileBatchRequestToJSON( + createVectorStoreFileBatchRequest: CreateVectorStoreFileBatchRequest, +): string { + return JSON.stringify( + CreateVectorStoreFileBatchRequest$outboundSchema.parse( + createVectorStoreFileBatchRequest, + ), + ); +} + +export function createVectorStoreFileBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreFileBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreFileBatchRequest' from JSON`, + ); +} diff --git a/src/models/components/createvectorstorefilerequest.ts b/src/models/components/createvectorstorefilerequest.ts index f8501d4..9190cf1 100644 --- a/src/models/components/createvectorstorefilerequest.ts +++ b/src/models/components/createvectorstorefilerequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ChunkingStrategyRequestParam, ChunkingStrategyRequestParam$inboundSchema, @@ -70,3 +73,23 @@ export namespace CreateVectorStoreFileRequest$ { /** @deprecated use `CreateVectorStoreFileRequest$Outbound` instead. */ export type Outbound = CreateVectorStoreFileRequest$Outbound; } + +export function createVectorStoreFileRequestToJSON( + createVectorStoreFileRequest: CreateVectorStoreFileRequest, +): string { + return JSON.stringify( + CreateVectorStoreFileRequest$outboundSchema.parse( + createVectorStoreFileRequest, + ), + ); +} + +export function createVectorStoreFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreFileRequest' from JSON`, + ); +} diff --git a/src/models/components/createvectorstorerequest.ts b/src/models/components/createvectorstorerequest.ts index a512d38..1cccfb5 100644 --- a/src/models/components/createvectorstorerequest.ts +++ b/src/models/components/createvectorstorerequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AutoChunkingStrategyRequestParam, AutoChunkingStrategyRequestParam$inboundSchema, @@ -103,6 +106,24 @@ export namespace ChunkingStrategy$ { export type Outbound = ChunkingStrategy$Outbound; } +export function chunkingStrategyToJSON( + chunkingStrategy: ChunkingStrategy, +): string { + return JSON.stringify( + ChunkingStrategy$outboundSchema.parse(chunkingStrategy), + ); +} + +export function chunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const CreateVectorStoreRequestMetadata$inboundSchema: z.ZodType< CreateVectorStoreRequestMetadata, @@ -133,6 +154,26 @@ export namespace CreateVectorStoreRequestMetadata$ { export type Outbound = CreateVectorStoreRequestMetadata$Outbound; } +export function createVectorStoreRequestMetadataToJSON( + createVectorStoreRequestMetadata: CreateVectorStoreRequestMetadata, +): string { + return JSON.stringify( + CreateVectorStoreRequestMetadata$outboundSchema.parse( + createVectorStoreRequestMetadata, + ), + ); +} + +export function createVectorStoreRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreRequestMetadata' from JSON`, + ); +} + /** @internal */ export const CreateVectorStoreRequest$inboundSchema: z.ZodType< CreateVectorStoreRequest, @@ -205,3 +246,21 @@ export namespace CreateVectorStoreRequest$ { /** @deprecated use `CreateVectorStoreRequest$Outbound` instead. */ export type Outbound = CreateVectorStoreRequest$Outbound; } + +export function createVectorStoreRequestToJSON( + createVectorStoreRequest: CreateVectorStoreRequest, +): string { + return JSON.stringify( + CreateVectorStoreRequest$outboundSchema.parse(createVectorStoreRequest), + ); +} + +export function createVectorStoreRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreRequest' from JSON`, + ); +} diff --git a/src/models/components/deleteassistantresponse.ts b/src/models/components/deleteassistantresponse.ts index afa4860..8a97186 100644 --- a/src/models/components/deleteassistantresponse.ts +++ b/src/models/components/deleteassistantresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteAssistantResponseObject = { AssistantDeleted: "assistant.deleted", @@ -80,3 +83,21 @@ export namespace DeleteAssistantResponse$ { /** @deprecated use `DeleteAssistantResponse$Outbound` instead. */ export type Outbound = DeleteAssistantResponse$Outbound; } + +export function deleteAssistantResponseToJSON( + deleteAssistantResponse: DeleteAssistantResponse, +): string { + return JSON.stringify( + DeleteAssistantResponse$outboundSchema.parse(deleteAssistantResponse), + ); +} + +export function deleteAssistantResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteAssistantResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteAssistantResponse' from JSON`, + ); +} diff --git a/src/models/components/deletefileresponse.ts b/src/models/components/deletefileresponse.ts index c08f7f0..3ded08f 100644 --- a/src/models/components/deletefileresponse.ts +++ b/src/models/components/deletefileresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteFileResponseObject = { File: "file", @@ -80,3 +83,21 @@ export namespace DeleteFileResponse$ { /** @deprecated use `DeleteFileResponse$Outbound` instead. */ export type Outbound = DeleteFileResponse$Outbound; } + +export function deleteFileResponseToJSON( + deleteFileResponse: DeleteFileResponse, +): string { + return JSON.stringify( + DeleteFileResponse$outboundSchema.parse(deleteFileResponse), + ); +} + +export function deleteFileResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteFileResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteFileResponse' from JSON`, + ); +} diff --git a/src/models/components/deletemessageresponse.ts b/src/models/components/deletemessageresponse.ts index 84a1b44..ac9234d 100644 --- a/src/models/components/deletemessageresponse.ts +++ b/src/models/components/deletemessageresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteMessageResponseObject = { ThreadMessageDeleted: "thread.message.deleted", @@ -80,3 +83,21 @@ export namespace DeleteMessageResponse$ { /** @deprecated use `DeleteMessageResponse$Outbound` instead. */ export type Outbound = DeleteMessageResponse$Outbound; } + +export function deleteMessageResponseToJSON( + deleteMessageResponse: DeleteMessageResponse, +): string { + return JSON.stringify( + DeleteMessageResponse$outboundSchema.parse(deleteMessageResponse), + ); +} + +export function deleteMessageResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteMessageResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteMessageResponse' from JSON`, + ); +} diff --git a/src/models/components/deletemodelresponse.ts b/src/models/components/deletemodelresponse.ts index 8afca1b..47d4f67 100644 --- a/src/models/components/deletemodelresponse.ts +++ b/src/models/components/deletemodelresponse.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteModelResponse = { id: string; @@ -51,3 +54,21 @@ export namespace DeleteModelResponse$ { /** @deprecated use `DeleteModelResponse$Outbound` instead. */ export type Outbound = DeleteModelResponse$Outbound; } + +export function deleteModelResponseToJSON( + deleteModelResponse: DeleteModelResponse, +): string { + return JSON.stringify( + DeleteModelResponse$outboundSchema.parse(deleteModelResponse), + ); +} + +export function deleteModelResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteModelResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteModelResponse' from JSON`, + ); +} diff --git a/src/models/components/deletethreadresponse.ts b/src/models/components/deletethreadresponse.ts index 11dcb4d..04fb613 100644 --- a/src/models/components/deletethreadresponse.ts +++ b/src/models/components/deletethreadresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteThreadResponseObject = { ThreadDeleted: "thread.deleted", @@ -80,3 +83,21 @@ export namespace DeleteThreadResponse$ { /** @deprecated use `DeleteThreadResponse$Outbound` instead. */ export type Outbound = DeleteThreadResponse$Outbound; } + +export function deleteThreadResponseToJSON( + deleteThreadResponse: DeleteThreadResponse, +): string { + return JSON.stringify( + DeleteThreadResponse$outboundSchema.parse(deleteThreadResponse), + ); +} + +export function deleteThreadResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteThreadResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteThreadResponse' from JSON`, + ); +} diff --git a/src/models/components/deletevectorstorefileresponse.ts b/src/models/components/deletevectorstorefileresponse.ts index 174ee3c..6639881 100644 --- a/src/models/components/deletevectorstorefileresponse.ts +++ b/src/models/components/deletevectorstorefileresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteVectorStoreFileResponseObject = { VectorStoreFileDeleted: "vector_store.file.deleted", @@ -82,3 +85,23 @@ export namespace DeleteVectorStoreFileResponse$ { /** @deprecated use `DeleteVectorStoreFileResponse$Outbound` instead. */ export type Outbound = DeleteVectorStoreFileResponse$Outbound; } + +export function deleteVectorStoreFileResponseToJSON( + deleteVectorStoreFileResponse: DeleteVectorStoreFileResponse, +): string { + return JSON.stringify( + DeleteVectorStoreFileResponse$outboundSchema.parse( + deleteVectorStoreFileResponse, + ), + ); +} + +export function deleteVectorStoreFileResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteVectorStoreFileResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteVectorStoreFileResponse' from JSON`, + ); +} diff --git a/src/models/components/deletevectorstoreresponse.ts b/src/models/components/deletevectorstoreresponse.ts index 689b862..280a972 100644 --- a/src/models/components/deletevectorstoreresponse.ts +++ b/src/models/components/deletevectorstoreresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const DeleteVectorStoreResponseObject = { VectorStoreDeleted: "vector_store.deleted", @@ -80,3 +83,21 @@ export namespace DeleteVectorStoreResponse$ { /** @deprecated use `DeleteVectorStoreResponse$Outbound` instead. */ export type Outbound = DeleteVectorStoreResponse$Outbound; } + +export function deleteVectorStoreResponseToJSON( + deleteVectorStoreResponse: DeleteVectorStoreResponse, +): string { + return JSON.stringify( + DeleteVectorStoreResponse$outboundSchema.parse(deleteVectorStoreResponse), + ); +} + +export function deleteVectorStoreResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteVectorStoreResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteVectorStoreResponse' from JSON`, + ); +} diff --git a/src/models/components/embedding.ts b/src/models/components/embedding.ts index 77fc5ff..84c594c 100644 --- a/src/models/components/embedding.ts +++ b/src/models/components/embedding.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always "embedding". @@ -100,3 +103,17 @@ export namespace Embedding$ { /** @deprecated use `Embedding$Outbound` instead. */ export type Outbound = Embedding$Outbound; } + +export function embeddingToJSON(embedding: Embedding): string { + return JSON.stringify(Embedding$outboundSchema.parse(embedding)); +} + +export function embeddingFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Embedding$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Embedding' from JSON`, + ); +} diff --git a/src/models/components/error.ts b/src/models/components/error.ts index 631677b..fff9d76 100644 --- a/src/models/components/error.ts +++ b/src/models/components/error.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ErrorT = { code: string | null; @@ -52,3 +55,17 @@ export namespace ErrorT$ { /** @deprecated use `ErrorT$Outbound` instead. */ export type Outbound = ErrorT$Outbound; } + +export function errorToJSON(errorT: ErrorT): string { + return JSON.stringify(ErrorT$outboundSchema.parse(errorT)); +} + +export function errorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ErrorT$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ErrorT' from JSON`, + ); +} diff --git a/src/models/components/filesearchrankingoptions.ts b/src/models/components/filesearchrankingoptions.ts index cf4570e..a883d39 100644 --- a/src/models/components/filesearchrankingoptions.ts +++ b/src/models/components/filesearchrankingoptions.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The ranker to use for the file search. If not specified will use the `auto` ranker. @@ -101,3 +104,21 @@ export namespace FileSearchRankingOptions$ { /** @deprecated use `FileSearchRankingOptions$Outbound` instead. */ export type Outbound = FileSearchRankingOptions$Outbound; } + +export function fileSearchRankingOptionsToJSON( + fileSearchRankingOptions: FileSearchRankingOptions, +): string { + return JSON.stringify( + FileSearchRankingOptions$outboundSchema.parse(fileSearchRankingOptions), + ); +} + +export function fileSearchRankingOptionsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileSearchRankingOptions$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileSearchRankingOptions' from JSON`, + ); +} diff --git a/src/models/components/finetuningintegration.ts b/src/models/components/finetuningintegration.ts index 129b0b1..4d2adc9 100644 --- a/src/models/components/finetuningintegration.ts +++ b/src/models/components/finetuningintegration.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the integration being enabled for the fine-tuning job @@ -132,6 +135,20 @@ export namespace Wandb$ { export type Outbound = Wandb$Outbound; } +export function wandbToJSON(wandb: Wandb): string { + return JSON.stringify(Wandb$outboundSchema.parse(wandb)); +} + +export function wandbFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Wandb$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Wandb' from JSON`, + ); +} + /** @internal */ export const FineTuningIntegration$inboundSchema: z.ZodType< FineTuningIntegration, @@ -170,3 +187,21 @@ export namespace FineTuningIntegration$ { /** @deprecated use `FineTuningIntegration$Outbound` instead. */ export type Outbound = FineTuningIntegration$Outbound; } + +export function fineTuningIntegrationToJSON( + fineTuningIntegration: FineTuningIntegration, +): string { + return JSON.stringify( + FineTuningIntegration$outboundSchema.parse(fineTuningIntegration), + ); +} + +export function fineTuningIntegrationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningIntegration$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningIntegration' from JSON`, + ); +} diff --git a/src/models/components/finetuningjob.ts b/src/models/components/finetuningjob.ts index e49ef6c..9a8ec8b 100644 --- a/src/models/components/finetuningjob.ts +++ b/src/models/components/finetuningjob.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FineTuningIntegration, FineTuningIntegration$inboundSchema, @@ -203,6 +206,24 @@ export namespace FineTuningJobError$ { export type Outbound = FineTuningJobError$Outbound; } +export function fineTuningJobErrorToJSON( + fineTuningJobError: FineTuningJobError, +): string { + return JSON.stringify( + FineTuningJobError$outboundSchema.parse(fineTuningJobError), + ); +} + +export function fineTuningJobErrorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobError$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobError' from JSON`, + ); +} + /** @internal */ export const FineTuningJobNEpochs1$inboundSchema: z.ZodNativeEnum< typeof FineTuningJobNEpochs1 @@ -254,6 +275,24 @@ export namespace FineTuningJobNEpochs$ { export type Outbound = FineTuningJobNEpochs$Outbound; } +export function fineTuningJobNEpochsToJSON( + fineTuningJobNEpochs: FineTuningJobNEpochs, +): string { + return JSON.stringify( + FineTuningJobNEpochs$outboundSchema.parse(fineTuningJobNEpochs), + ); +} + +export function fineTuningJobNEpochsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobNEpochs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobNEpochs' from JSON`, + ); +} + /** @internal */ export const FineTuningJobHyperparameters$inboundSchema: z.ZodType< FineTuningJobHyperparameters, @@ -298,6 +337,26 @@ export namespace FineTuningJobHyperparameters$ { export type Outbound = FineTuningJobHyperparameters$Outbound; } +export function fineTuningJobHyperparametersToJSON( + fineTuningJobHyperparameters: FineTuningJobHyperparameters, +): string { + return JSON.stringify( + FineTuningJobHyperparameters$outboundSchema.parse( + fineTuningJobHyperparameters, + ), + ); +} + +export function fineTuningJobHyperparametersFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobHyperparameters$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobHyperparameters' from JSON`, + ); +} + /** @internal */ export const FineTuningJobObject$inboundSchema: z.ZodNativeEnum< typeof FineTuningJobObject @@ -370,6 +429,24 @@ export namespace FineTuningJobIntegrations$ { export type Outbound = FineTuningJobIntegrations$Outbound; } +export function fineTuningJobIntegrationsToJSON( + fineTuningJobIntegrations: FineTuningJobIntegrations, +): string { + return JSON.stringify( + FineTuningJobIntegrations$outboundSchema.parse(fineTuningJobIntegrations), + ); +} + +export function fineTuningJobIntegrationsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobIntegrations$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobIntegrations' from JSON`, + ); +} + /** @internal */ export const FineTuningJob$inboundSchema: z.ZodType< FineTuningJob, @@ -479,3 +556,17 @@ export namespace FineTuningJob$ { /** @deprecated use `FineTuningJob$Outbound` instead. */ export type Outbound = FineTuningJob$Outbound; } + +export function fineTuningJobToJSON(fineTuningJob: FineTuningJob): string { + return JSON.stringify(FineTuningJob$outboundSchema.parse(fineTuningJob)); +} + +export function fineTuningJobFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJob$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJob' from JSON`, + ); +} diff --git a/src/models/components/finetuningjobcheckpoint.ts b/src/models/components/finetuningjobcheckpoint.ts index 120bce3..f5b38d6 100644 --- a/src/models/components/finetuningjobcheckpoint.ts +++ b/src/models/components/finetuningjobcheckpoint.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Metrics at the step number during the fine-tuning job. @@ -137,6 +140,20 @@ export namespace Metrics$ { export type Outbound = Metrics$Outbound; } +export function metricsToJSON(metrics: Metrics): string { + return JSON.stringify(Metrics$outboundSchema.parse(metrics)); +} + +export function metricsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Metrics$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Metrics' from JSON`, + ); +} + /** @internal */ export const FineTuningJobCheckpointObject$inboundSchema: z.ZodNativeEnum< typeof FineTuningJobCheckpointObject @@ -225,3 +242,21 @@ export namespace FineTuningJobCheckpoint$ { /** @deprecated use `FineTuningJobCheckpoint$Outbound` instead. */ export type Outbound = FineTuningJobCheckpoint$Outbound; } + +export function fineTuningJobCheckpointToJSON( + fineTuningJobCheckpoint: FineTuningJobCheckpoint, +): string { + return JSON.stringify( + FineTuningJobCheckpoint$outboundSchema.parse(fineTuningJobCheckpoint), + ); +} + +export function fineTuningJobCheckpointFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobCheckpoint$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobCheckpoint' from JSON`, + ); +} diff --git a/src/models/components/finetuningjobevent.ts b/src/models/components/finetuningjobevent.ts index d7bc945..3fad150 100644 --- a/src/models/components/finetuningjobevent.ts +++ b/src/models/components/finetuningjobevent.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const Level = { Info: "info", @@ -127,3 +130,21 @@ export namespace FineTuningJobEvent$ { /** @deprecated use `FineTuningJobEvent$Outbound` instead. */ export type Outbound = FineTuningJobEvent$Outbound; } + +export function fineTuningJobEventToJSON( + fineTuningJobEvent: FineTuningJobEvent, +): string { + return JSON.stringify( + FineTuningJobEvent$outboundSchema.parse(fineTuningJobEvent), + ); +} + +export function fineTuningJobEventFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FineTuningJobEvent$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FineTuningJobEvent' from JSON`, + ); +} diff --git a/src/models/components/functionobject.ts b/src/models/components/functionobject.ts index 5f45707..82d9e60 100644 --- a/src/models/components/functionobject.ts +++ b/src/models/components/functionobject.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type FunctionObject = { /** @@ -71,3 +74,17 @@ export namespace FunctionObject$ { /** @deprecated use `FunctionObject$Outbound` instead. */ export type Outbound = FunctionObject$Outbound; } + +export function functionObjectToJSON(functionObject: FunctionObject): string { + return JSON.stringify(FunctionObject$outboundSchema.parse(functionObject)); +} + +export function functionObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FunctionObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FunctionObject' from JSON`, + ); +} diff --git a/src/models/components/image.ts b/src/models/components/image.ts index a9249d7..03f517a 100644 --- a/src/models/components/image.ts +++ b/src/models/components/image.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Represents the url or the content of an image generated by the OpenAI API. @@ -71,3 +74,17 @@ export namespace Image$ { /** @deprecated use `Image$Outbound` instead. */ export type Outbound = Image$Outbound; } + +export function imageToJSON(image: Image): string { + return JSON.stringify(Image$outboundSchema.parse(image)); +} + +export function imageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Image$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Image' from JSON`, + ); +} diff --git a/src/models/components/imagesresponse.ts b/src/models/components/imagesresponse.ts index 785827e..6a5b26a 100644 --- a/src/models/components/imagesresponse.ts +++ b/src/models/components/imagesresponse.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Image, Image$inboundSchema, @@ -53,3 +56,17 @@ export namespace ImagesResponse$ { /** @deprecated use `ImagesResponse$Outbound` instead. */ export type Outbound = ImagesResponse$Outbound; } + +export function imagesResponseToJSON(imagesResponse: ImagesResponse): string { + return JSON.stringify(ImagesResponse$outboundSchema.parse(imagesResponse)); +} + +export function imagesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ImagesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ImagesResponse' from JSON`, + ); +} diff --git a/src/models/components/invite.ts b/src/models/components/invite.ts index 876b12e..2dd7470 100644 --- a/src/models/components/invite.ts +++ b/src/models/components/invite.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.invite` @@ -202,3 +205,17 @@ export namespace Invite$ { /** @deprecated use `Invite$Outbound` instead. */ export type Outbound = Invite$Outbound; } + +export function inviteToJSON(invite: Invite): string { + return JSON.stringify(Invite$outboundSchema.parse(invite)); +} + +export function inviteFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Invite$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Invite' from JSON`, + ); +} diff --git a/src/models/components/invitedeleteresponse.ts b/src/models/components/invitedeleteresponse.ts index bffad08..5fc82fa 100644 --- a/src/models/components/invitedeleteresponse.ts +++ b/src/models/components/invitedeleteresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.invite.deleted` @@ -89,3 +92,21 @@ export namespace InviteDeleteResponse$ { /** @deprecated use `InviteDeleteResponse$Outbound` instead. */ export type Outbound = InviteDeleteResponse$Outbound; } + +export function inviteDeleteResponseToJSON( + inviteDeleteResponse: InviteDeleteResponse, +): string { + return JSON.stringify( + InviteDeleteResponse$outboundSchema.parse(inviteDeleteResponse), + ); +} + +export function inviteDeleteResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteDeleteResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteDeleteResponse' from JSON`, + ); +} diff --git a/src/models/components/invitelistresponse.ts b/src/models/components/invitelistresponse.ts index f772448..42f4f85 100644 --- a/src/models/components/invitelistresponse.ts +++ b/src/models/components/invitelistresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Invite, Invite$inboundSchema, @@ -125,3 +128,21 @@ export namespace InviteListResponse$ { /** @deprecated use `InviteListResponse$Outbound` instead. */ export type Outbound = InviteListResponse$Outbound; } + +export function inviteListResponseToJSON( + inviteListResponse: InviteListResponse, +): string { + return JSON.stringify( + InviteListResponse$outboundSchema.parse(inviteListResponse), + ); +} + +export function inviteListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteListResponse' from JSON`, + ); +} diff --git a/src/models/components/inviterequest.ts b/src/models/components/inviterequest.ts index 89d0a2f..a9dc695 100644 --- a/src/models/components/inviterequest.ts +++ b/src/models/components/inviterequest.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * `owner` or `reader` @@ -87,3 +90,17 @@ export namespace InviteRequest$ { /** @deprecated use `InviteRequest$Outbound` instead. */ export type Outbound = InviteRequest$Outbound; } + +export function inviteRequestToJSON(inviteRequest: InviteRequest): string { + return JSON.stringify(InviteRequest$outboundSchema.parse(inviteRequest)); +} + +export function inviteRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => InviteRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'InviteRequest' from JSON`, + ); +} diff --git a/src/models/components/listassistantsresponse.ts b/src/models/components/listassistantsresponse.ts index cd45541..8169335 100644 --- a/src/models/components/listassistantsresponse.ts +++ b/src/models/components/listassistantsresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantObject, AssistantObject$inboundSchema, @@ -78,3 +81,21 @@ export namespace ListAssistantsResponse$ { /** @deprecated use `ListAssistantsResponse$Outbound` instead. */ export type Outbound = ListAssistantsResponse$Outbound; } + +export function listAssistantsResponseToJSON( + listAssistantsResponse: ListAssistantsResponse, +): string { + return JSON.stringify( + ListAssistantsResponse$outboundSchema.parse(listAssistantsResponse), + ); +} + +export function listAssistantsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListAssistantsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListAssistantsResponse' from JSON`, + ); +} diff --git a/src/models/components/listauditlogsresponse.ts b/src/models/components/listauditlogsresponse.ts index 6b8c809..74b4aa0 100644 --- a/src/models/components/listauditlogsresponse.ts +++ b/src/models/components/listauditlogsresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AuditLog, AuditLog$inboundSchema, @@ -107,3 +110,21 @@ export namespace ListAuditLogsResponse$ { /** @deprecated use `ListAuditLogsResponse$Outbound` instead. */ export type Outbound = ListAuditLogsResponse$Outbound; } + +export function listAuditLogsResponseToJSON( + listAuditLogsResponse: ListAuditLogsResponse, +): string { + return JSON.stringify( + ListAuditLogsResponse$outboundSchema.parse(listAuditLogsResponse), + ); +} + +export function listAuditLogsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListAuditLogsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListAuditLogsResponse' from JSON`, + ); +} diff --git a/src/models/components/listbatchesresponse.ts b/src/models/components/listbatchesresponse.ts index d73dd6a..a74e56c 100644 --- a/src/models/components/listbatchesresponse.ts +++ b/src/models/components/listbatchesresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Batch, Batch$inboundSchema, @@ -107,3 +110,21 @@ export namespace ListBatchesResponse$ { /** @deprecated use `ListBatchesResponse$Outbound` instead. */ export type Outbound = ListBatchesResponse$Outbound; } + +export function listBatchesResponseToJSON( + listBatchesResponse: ListBatchesResponse, +): string { + return JSON.stringify( + ListBatchesResponse$outboundSchema.parse(listBatchesResponse), + ); +} + +export function listBatchesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListBatchesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListBatchesResponse' from JSON`, + ); +} diff --git a/src/models/components/listfilesresponse.ts b/src/models/components/listfilesresponse.ts index f258502..a58b620 100644 --- a/src/models/components/listfilesresponse.ts +++ b/src/models/components/listfilesresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { OpenAIFile, OpenAIFile$inboundSchema, @@ -82,3 +85,21 @@ export namespace ListFilesResponse$ { /** @deprecated use `ListFilesResponse$Outbound` instead. */ export type Outbound = ListFilesResponse$Outbound; } + +export function listFilesResponseToJSON( + listFilesResponse: ListFilesResponse, +): string { + return JSON.stringify( + ListFilesResponse$outboundSchema.parse(listFilesResponse), + ); +} + +export function listFilesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListFilesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFilesResponse' from JSON`, + ); +} diff --git a/src/models/components/listfinetuningjobcheckpointsresponse.ts b/src/models/components/listfinetuningjobcheckpointsresponse.ts index 2e3b63e..55b2b1b 100644 --- a/src/models/components/listfinetuningjobcheckpointsresponse.ts +++ b/src/models/components/listfinetuningjobcheckpointsresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FineTuningJobCheckpoint, FineTuningJobCheckpoint$inboundSchema, @@ -111,3 +114,24 @@ export namespace ListFineTuningJobCheckpointsResponse$ { /** @deprecated use `ListFineTuningJobCheckpointsResponse$Outbound` instead. */ export type Outbound = ListFineTuningJobCheckpointsResponse$Outbound; } + +export function listFineTuningJobCheckpointsResponseToJSON( + listFineTuningJobCheckpointsResponse: ListFineTuningJobCheckpointsResponse, +): string { + return JSON.stringify( + ListFineTuningJobCheckpointsResponse$outboundSchema.parse( + listFineTuningJobCheckpointsResponse, + ), + ); +} + +export function listFineTuningJobCheckpointsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListFineTuningJobCheckpointsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFineTuningJobCheckpointsResponse' from JSON`, + ); +} diff --git a/src/models/components/listfinetuningjobeventsresponse.ts b/src/models/components/listfinetuningjobeventsresponse.ts index 0191eb4..7a2a7fb 100644 --- a/src/models/components/listfinetuningjobeventsresponse.ts +++ b/src/models/components/listfinetuningjobeventsresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FineTuningJobEvent, FineTuningJobEvent$inboundSchema, @@ -85,3 +88,23 @@ export namespace ListFineTuningJobEventsResponse$ { /** @deprecated use `ListFineTuningJobEventsResponse$Outbound` instead. */ export type Outbound = ListFineTuningJobEventsResponse$Outbound; } + +export function listFineTuningJobEventsResponseToJSON( + listFineTuningJobEventsResponse: ListFineTuningJobEventsResponse, +): string { + return JSON.stringify( + ListFineTuningJobEventsResponse$outboundSchema.parse( + listFineTuningJobEventsResponse, + ), + ); +} + +export function listFineTuningJobEventsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListFineTuningJobEventsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFineTuningJobEventsResponse' from JSON`, + ); +} diff --git a/src/models/components/listmessagesresponse.ts b/src/models/components/listmessagesresponse.ts index f73a937..318bcbd 100644 --- a/src/models/components/listmessagesresponse.ts +++ b/src/models/components/listmessagesresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { MessageObject, MessageObject$inboundSchema, @@ -78,3 +81,21 @@ export namespace ListMessagesResponse$ { /** @deprecated use `ListMessagesResponse$Outbound` instead. */ export type Outbound = ListMessagesResponse$Outbound; } + +export function listMessagesResponseToJSON( + listMessagesResponse: ListMessagesResponse, +): string { + return JSON.stringify( + ListMessagesResponse$outboundSchema.parse(listMessagesResponse), + ); +} + +export function listMessagesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListMessagesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListMessagesResponse' from JSON`, + ); +} diff --git a/src/models/components/listmodelsresponse.ts b/src/models/components/listmodelsresponse.ts index ca38f0e..3d49f3c 100644 --- a/src/models/components/listmodelsresponse.ts +++ b/src/models/components/listmodelsresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Model, Model$inboundSchema, @@ -82,3 +85,21 @@ export namespace ListModelsResponse$ { /** @deprecated use `ListModelsResponse$Outbound` instead. */ export type Outbound = ListModelsResponse$Outbound; } + +export function listModelsResponseToJSON( + listModelsResponse: ListModelsResponse, +): string { + return JSON.stringify( + ListModelsResponse$outboundSchema.parse(listModelsResponse), + ); +} + +export function listModelsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListModelsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListModelsResponse' from JSON`, + ); +} diff --git a/src/models/components/listpaginatedfinetuningjobsresponse.ts b/src/models/components/listpaginatedfinetuningjobsresponse.ts index 61890e3..47a727c 100644 --- a/src/models/components/listpaginatedfinetuningjobsresponse.ts +++ b/src/models/components/listpaginatedfinetuningjobsresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { FineTuningJob, FineTuningJob$inboundSchema, @@ -99,3 +102,24 @@ export namespace ListPaginatedFineTuningJobsResponse$ { /** @deprecated use `ListPaginatedFineTuningJobsResponse$Outbound` instead. */ export type Outbound = ListPaginatedFineTuningJobsResponse$Outbound; } + +export function listPaginatedFineTuningJobsResponseToJSON( + listPaginatedFineTuningJobsResponse: ListPaginatedFineTuningJobsResponse, +): string { + return JSON.stringify( + ListPaginatedFineTuningJobsResponse$outboundSchema.parse( + listPaginatedFineTuningJobsResponse, + ), + ); +} + +export function listPaginatedFineTuningJobsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListPaginatedFineTuningJobsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListPaginatedFineTuningJobsResponse' from JSON`, + ); +} diff --git a/src/models/components/listrunsresponse.ts b/src/models/components/listrunsresponse.ts index a6e4bb9..750f9bf 100644 --- a/src/models/components/listrunsresponse.ts +++ b/src/models/components/listrunsresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunObject, RunObject$inboundSchema, @@ -78,3 +81,21 @@ export namespace ListRunsResponse$ { /** @deprecated use `ListRunsResponse$Outbound` instead. */ export type Outbound = ListRunsResponse$Outbound; } + +export function listRunsResponseToJSON( + listRunsResponse: ListRunsResponse, +): string { + return JSON.stringify( + ListRunsResponse$outboundSchema.parse(listRunsResponse), + ); +} + +export function listRunsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListRunsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListRunsResponse' from JSON`, + ); +} diff --git a/src/models/components/listrunstepsresponse.ts b/src/models/components/listrunstepsresponse.ts index 854d3de..f99a395 100644 --- a/src/models/components/listrunstepsresponse.ts +++ b/src/models/components/listrunstepsresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunStepObject, RunStepObject$inboundSchema, @@ -78,3 +81,21 @@ export namespace ListRunStepsResponse$ { /** @deprecated use `ListRunStepsResponse$Outbound` instead. */ export type Outbound = ListRunStepsResponse$Outbound; } + +export function listRunStepsResponseToJSON( + listRunStepsResponse: ListRunStepsResponse, +): string { + return JSON.stringify( + ListRunStepsResponse$outboundSchema.parse(listRunStepsResponse), + ); +} + +export function listRunStepsResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListRunStepsResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListRunStepsResponse' from JSON`, + ); +} diff --git a/src/models/components/listvectorstorefilesresponse.ts b/src/models/components/listvectorstorefilesresponse.ts index a542c30..1bef67b 100644 --- a/src/models/components/listvectorstorefilesresponse.ts +++ b/src/models/components/listvectorstorefilesresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { VectorStoreFileObject, VectorStoreFileObject$inboundSchema, @@ -78,3 +81,23 @@ export namespace ListVectorStoreFilesResponse$ { /** @deprecated use `ListVectorStoreFilesResponse$Outbound` instead. */ export type Outbound = ListVectorStoreFilesResponse$Outbound; } + +export function listVectorStoreFilesResponseToJSON( + listVectorStoreFilesResponse: ListVectorStoreFilesResponse, +): string { + return JSON.stringify( + ListVectorStoreFilesResponse$outboundSchema.parse( + listVectorStoreFilesResponse, + ), + ); +} + +export function listVectorStoreFilesResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListVectorStoreFilesResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListVectorStoreFilesResponse' from JSON`, + ); +} diff --git a/src/models/components/listvectorstoresresponse.ts b/src/models/components/listvectorstoresresponse.ts index e98da78..5e55403 100644 --- a/src/models/components/listvectorstoresresponse.ts +++ b/src/models/components/listvectorstoresresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { VectorStoreObject, VectorStoreObject$inboundSchema, @@ -78,3 +81,21 @@ export namespace ListVectorStoresResponse$ { /** @deprecated use `ListVectorStoresResponse$Outbound` instead. */ export type Outbound = ListVectorStoresResponse$Outbound; } + +export function listVectorStoresResponseToJSON( + listVectorStoresResponse: ListVectorStoresResponse, +): string { + return JSON.stringify( + ListVectorStoresResponse$outboundSchema.parse(listVectorStoresResponse), + ); +} + +export function listVectorStoresResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListVectorStoresResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListVectorStoresResponse' from JSON`, + ); +} diff --git a/src/models/components/messagecontentimagefileobject.ts b/src/models/components/messagecontentimagefileobject.ts index 538d7e4..ead6ad8 100644 --- a/src/models/components/messagecontentimagefileobject.ts +++ b/src/models/components/messagecontentimagefileobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `image_file`. @@ -148,6 +151,20 @@ export namespace ImageFile$ { export type Outbound = ImageFile$Outbound; } +export function imageFileToJSON(imageFile: ImageFile): string { + return JSON.stringify(ImageFile$outboundSchema.parse(imageFile)); +} + +export function imageFileFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ImageFile$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ImageFile' from JSON`, + ); +} + /** @internal */ export const MessageContentImageFileObject$inboundSchema: z.ZodType< MessageContentImageFileObject, @@ -194,3 +211,23 @@ export namespace MessageContentImageFileObject$ { /** @deprecated use `MessageContentImageFileObject$Outbound` instead. */ export type Outbound = MessageContentImageFileObject$Outbound; } + +export function messageContentImageFileObjectToJSON( + messageContentImageFileObject: MessageContentImageFileObject, +): string { + return JSON.stringify( + MessageContentImageFileObject$outboundSchema.parse( + messageContentImageFileObject, + ), + ); +} + +export function messageContentImageFileObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageContentImageFileObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageContentImageFileObject' from JSON`, + ); +} diff --git a/src/models/components/messagecontentimageurlobject.ts b/src/models/components/messagecontentimageurlobject.ts index e7f0e94..f431801 100644 --- a/src/models/components/messagecontentimageurlobject.ts +++ b/src/models/components/messagecontentimageurlobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the content part. @@ -140,6 +143,27 @@ export namespace MessageContentImageUrlObjectImageUrl$ { export type Outbound = MessageContentImageUrlObjectImageUrl$Outbound; } +export function messageContentImageUrlObjectImageUrlToJSON( + messageContentImageUrlObjectImageUrl: MessageContentImageUrlObjectImageUrl, +): string { + return JSON.stringify( + MessageContentImageUrlObjectImageUrl$outboundSchema.parse( + messageContentImageUrlObjectImageUrl, + ), + ); +} + +export function messageContentImageUrlObjectImageUrlFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + MessageContentImageUrlObjectImageUrl$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageContentImageUrlObjectImageUrl' from JSON`, + ); +} + /** @internal */ export const MessageContentImageUrlObject$inboundSchema: z.ZodType< MessageContentImageUrlObject, @@ -186,3 +210,23 @@ export namespace MessageContentImageUrlObject$ { /** @deprecated use `MessageContentImageUrlObject$Outbound` instead. */ export type Outbound = MessageContentImageUrlObject$Outbound; } + +export function messageContentImageUrlObjectToJSON( + messageContentImageUrlObject: MessageContentImageUrlObject, +): string { + return JSON.stringify( + MessageContentImageUrlObject$outboundSchema.parse( + messageContentImageUrlObject, + ), + ); +} + +export function messageContentImageUrlObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageContentImageUrlObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageContentImageUrlObject' from JSON`, + ); +} diff --git a/src/models/components/messagecontentrefusalobject.ts b/src/models/components/messagecontentrefusalobject.ts index 41fe89d..f5803aa 100644 --- a/src/models/components/messagecontentrefusalobject.ts +++ b/src/models/components/messagecontentrefusalobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `refusal`. @@ -88,3 +91,23 @@ export namespace MessageContentRefusalObject$ { /** @deprecated use `MessageContentRefusalObject$Outbound` instead. */ export type Outbound = MessageContentRefusalObject$Outbound; } + +export function messageContentRefusalObjectToJSON( + messageContentRefusalObject: MessageContentRefusalObject, +): string { + return JSON.stringify( + MessageContentRefusalObject$outboundSchema.parse( + messageContentRefusalObject, + ), + ); +} + +export function messageContentRefusalObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageContentRefusalObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageContentRefusalObject' from JSON`, + ); +} diff --git a/src/models/components/messagecontenttextannotationsfilecitationobject.ts b/src/models/components/messagecontenttextannotationsfilecitationobject.ts index e1d895d..fbce3bb 100644 --- a/src/models/components/messagecontenttextannotationsfilecitationobject.ts +++ b/src/models/components/messagecontenttextannotationsfilecitationobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `file_citation`. @@ -110,6 +113,20 @@ export namespace FileCitation$ { export type Outbound = FileCitation$Outbound; } +export function fileCitationToJSON(fileCitation: FileCitation): string { + return JSON.stringify(FileCitation$outboundSchema.parse(fileCitation)); +} + +export function fileCitationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileCitation$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileCitation' from JSON`, + ); +} + /** @internal */ export const MessageContentTextAnnotationsFileCitationObject$inboundSchema: z.ZodType< @@ -174,3 +191,30 @@ export namespace MessageContentTextAnnotationsFileCitationObject$ { export type Outbound = MessageContentTextAnnotationsFileCitationObject$Outbound; } + +export function messageContentTextAnnotationsFileCitationObjectToJSON( + messageContentTextAnnotationsFileCitationObject: + MessageContentTextAnnotationsFileCitationObject, +): string { + return JSON.stringify( + MessageContentTextAnnotationsFileCitationObject$outboundSchema.parse( + messageContentTextAnnotationsFileCitationObject, + ), + ); +} + +export function messageContentTextAnnotationsFileCitationObjectFromJSON( + jsonString: string, +): SafeParseResult< + MessageContentTextAnnotationsFileCitationObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + MessageContentTextAnnotationsFileCitationObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'MessageContentTextAnnotationsFileCitationObject' from JSON`, + ); +} diff --git a/src/models/components/messagecontenttextannotationsfilepathobject.ts b/src/models/components/messagecontenttextannotationsfilepathobject.ts index f803452..5e9032f 100644 --- a/src/models/components/messagecontenttextannotationsfilepathobject.ts +++ b/src/models/components/messagecontenttextannotationsfilepathobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `file_path`. @@ -110,6 +113,20 @@ export namespace FilePath$ { export type Outbound = FilePath$Outbound; } +export function filePathToJSON(filePath: FilePath): string { + return JSON.stringify(FilePath$outboundSchema.parse(filePath)); +} + +export function filePathFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FilePath$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FilePath' from JSON`, + ); +} + /** @internal */ export const MessageContentTextAnnotationsFilePathObject$inboundSchema: z.ZodType< @@ -173,3 +190,30 @@ export namespace MessageContentTextAnnotationsFilePathObject$ { /** @deprecated use `MessageContentTextAnnotationsFilePathObject$Outbound` instead. */ export type Outbound = MessageContentTextAnnotationsFilePathObject$Outbound; } + +export function messageContentTextAnnotationsFilePathObjectToJSON( + messageContentTextAnnotationsFilePathObject: + MessageContentTextAnnotationsFilePathObject, +): string { + return JSON.stringify( + MessageContentTextAnnotationsFilePathObject$outboundSchema.parse( + messageContentTextAnnotationsFilePathObject, + ), + ); +} + +export function messageContentTextAnnotationsFilePathObjectFromJSON( + jsonString: string, +): SafeParseResult< + MessageContentTextAnnotationsFilePathObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + MessageContentTextAnnotationsFilePathObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'MessageContentTextAnnotationsFilePathObject' from JSON`, + ); +} diff --git a/src/models/components/messagecontenttextobject.ts b/src/models/components/messagecontenttextobject.ts index 8c37224..afa771e 100644 --- a/src/models/components/messagecontenttextobject.ts +++ b/src/models/components/messagecontenttextobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { MessageContentTextAnnotationsFileCitationObject, MessageContentTextAnnotationsFileCitationObject$inboundSchema, @@ -115,6 +118,20 @@ export namespace Annotations$ { export type Outbound = Annotations$Outbound; } +export function annotationsToJSON(annotations: Annotations): string { + return JSON.stringify(Annotations$outboundSchema.parse(annotations)); +} + +export function annotationsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Annotations$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Annotations' from JSON`, + ); +} + /** @internal */ export const Text$inboundSchema: z.ZodType = z .object({ @@ -161,6 +178,20 @@ export namespace Text$ { export type Outbound = Text$Outbound; } +export function textToJSON(text: Text): string { + return JSON.stringify(Text$outboundSchema.parse(text)); +} + +export function textFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Text$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Text' from JSON`, + ); +} + /** @internal */ export const MessageContentTextObject$inboundSchema: z.ZodType< MessageContentTextObject, @@ -199,3 +230,21 @@ export namespace MessageContentTextObject$ { /** @deprecated use `MessageContentTextObject$Outbound` instead. */ export type Outbound = MessageContentTextObject$Outbound; } + +export function messageContentTextObjectToJSON( + messageContentTextObject: MessageContentTextObject, +): string { + return JSON.stringify( + MessageContentTextObject$outboundSchema.parse(messageContentTextObject), + ); +} + +export function messageContentTextObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageContentTextObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageContentTextObject' from JSON`, + ); +} diff --git a/src/models/components/messageobject.ts b/src/models/components/messageobject.ts index ee9b578..597d157 100644 --- a/src/models/components/messageobject.ts +++ b/src/models/components/messageobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantToolsCode, AssistantToolsCode$inboundSchema, @@ -299,6 +302,24 @@ export namespace IncompleteDetails$ { export type Outbound = IncompleteDetails$Outbound; } +export function incompleteDetailsToJSON( + incompleteDetails: IncompleteDetails, +): string { + return JSON.stringify( + IncompleteDetails$outboundSchema.parse(incompleteDetails), + ); +} + +export function incompleteDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => IncompleteDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'IncompleteDetails' from JSON`, + ); +} + /** @internal */ export const MessageObjectRole$inboundSchema: z.ZodNativeEnum< typeof MessageObjectRole @@ -364,6 +385,24 @@ export namespace MessageObjectContent$ { export type Outbound = MessageObjectContent$Outbound; } +export function messageObjectContentToJSON( + messageObjectContent: MessageObjectContent, +): string { + return JSON.stringify( + MessageObjectContent$outboundSchema.parse(messageObjectContent), + ); +} + +export function messageObjectContentFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageObjectContent$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageObjectContent' from JSON`, + ); +} + /** @internal */ export const MessageObjectTools$inboundSchema: z.ZodType< MessageObjectTools, @@ -402,6 +441,24 @@ export namespace MessageObjectTools$ { export type Outbound = MessageObjectTools$Outbound; } +export function messageObjectToolsToJSON( + messageObjectTools: MessageObjectTools, +): string { + return JSON.stringify( + MessageObjectTools$outboundSchema.parse(messageObjectTools), + ); +} + +export function messageObjectToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageObjectTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageObjectTools' from JSON`, + ); +} + /** @internal */ export const MessageObjectAttachments$inboundSchema: z.ZodType< MessageObjectAttachments, @@ -463,6 +520,24 @@ export namespace MessageObjectAttachments$ { export type Outbound = MessageObjectAttachments$Outbound; } +export function messageObjectAttachmentsToJSON( + messageObjectAttachments: MessageObjectAttachments, +): string { + return JSON.stringify( + MessageObjectAttachments$outboundSchema.parse(messageObjectAttachments), + ); +} + +export function messageObjectAttachmentsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageObjectAttachments$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageObjectAttachments' from JSON`, + ); +} + /** @internal */ export const MessageObjectMetadata$inboundSchema: z.ZodType< MessageObjectMetadata, @@ -493,6 +568,24 @@ export namespace MessageObjectMetadata$ { export type Outbound = MessageObjectMetadata$Outbound; } +export function messageObjectMetadataToJSON( + messageObjectMetadata: MessageObjectMetadata, +): string { + return JSON.stringify( + MessageObjectMetadata$outboundSchema.parse(messageObjectMetadata), + ); +} + +export function messageObjectMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageObjectMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageObjectMetadata' from JSON`, + ); +} + /** @internal */ export const MessageObject$inboundSchema: z.ZodType< MessageObject, @@ -610,3 +703,17 @@ export namespace MessageObject$ { /** @deprecated use `MessageObject$Outbound` instead. */ export type Outbound = MessageObject$Outbound; } + +export function messageObjectToJSON(messageObject: MessageObject): string { + return JSON.stringify(MessageObject$outboundSchema.parse(messageObject)); +} + +export function messageObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageObject' from JSON`, + ); +} diff --git a/src/models/components/messagerequestcontenttextobject.ts b/src/models/components/messagerequestcontenttextobject.ts index 4cc1988..bf68dad 100644 --- a/src/models/components/messagerequestcontenttextobject.ts +++ b/src/models/components/messagerequestcontenttextobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `text`. @@ -93,3 +96,23 @@ export namespace MessageRequestContentTextObject$ { /** @deprecated use `MessageRequestContentTextObject$Outbound` instead. */ export type Outbound = MessageRequestContentTextObject$Outbound; } + +export function messageRequestContentTextObjectToJSON( + messageRequestContentTextObject: MessageRequestContentTextObject, +): string { + return JSON.stringify( + MessageRequestContentTextObject$outboundSchema.parse( + messageRequestContentTextObject, + ), + ); +} + +export function messageRequestContentTextObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageRequestContentTextObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageRequestContentTextObject' from JSON`, + ); +} diff --git a/src/models/components/model.ts b/src/models/components/model.ts index 41aea35..4deeb0f 100644 --- a/src/models/components/model.ts +++ b/src/models/components/model.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always "model". @@ -107,3 +110,17 @@ export namespace Model$ { /** @deprecated use `Model$Outbound` instead. */ export type Outbound = Model$Outbound; } + +export function modelToJSON(model: Model): string { + return JSON.stringify(Model$outboundSchema.parse(model)); +} + +export function modelFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Model$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Model' from JSON`, + ); +} diff --git a/src/models/components/modifyassistantrequest.ts b/src/models/components/modifyassistantrequest.ts index d0941ac..ad49e08 100644 --- a/src/models/components/modifyassistantrequest.ts +++ b/src/models/components/modifyassistantrequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -185,6 +188,26 @@ export namespace ModifyAssistantRequestTools$ { export type Outbound = ModifyAssistantRequestTools$Outbound; } +export function modifyAssistantRequestToolsToJSON( + modifyAssistantRequestTools: ModifyAssistantRequestTools, +): string { + return JSON.stringify( + ModifyAssistantRequestTools$outboundSchema.parse( + modifyAssistantRequestTools, + ), + ); +} + +export function modifyAssistantRequestToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyAssistantRequestTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequestTools' from JSON`, + ); +} + /** @internal */ export const ModifyAssistantRequestCodeInterpreter$inboundSchema: z.ZodType< ModifyAssistantRequestCodeInterpreter, @@ -231,6 +254,27 @@ export namespace ModifyAssistantRequestCodeInterpreter$ { export type Outbound = ModifyAssistantRequestCodeInterpreter$Outbound; } +export function modifyAssistantRequestCodeInterpreterToJSON( + modifyAssistantRequestCodeInterpreter: ModifyAssistantRequestCodeInterpreter, +): string { + return JSON.stringify( + ModifyAssistantRequestCodeInterpreter$outboundSchema.parse( + modifyAssistantRequestCodeInterpreter, + ), + ); +} + +export function modifyAssistantRequestCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ModifyAssistantRequestCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequestCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const ModifyAssistantRequestFileSearch$inboundSchema: z.ZodType< ModifyAssistantRequestFileSearch, @@ -275,6 +319,26 @@ export namespace ModifyAssistantRequestFileSearch$ { export type Outbound = ModifyAssistantRequestFileSearch$Outbound; } +export function modifyAssistantRequestFileSearchToJSON( + modifyAssistantRequestFileSearch: ModifyAssistantRequestFileSearch, +): string { + return JSON.stringify( + ModifyAssistantRequestFileSearch$outboundSchema.parse( + modifyAssistantRequestFileSearch, + ), + ); +} + +export function modifyAssistantRequestFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyAssistantRequestFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequestFileSearch' from JSON`, + ); +} + /** @internal */ export const ModifyAssistantRequestToolResources$inboundSchema: z.ZodType< ModifyAssistantRequestToolResources, @@ -332,6 +396,27 @@ export namespace ModifyAssistantRequestToolResources$ { export type Outbound = ModifyAssistantRequestToolResources$Outbound; } +export function modifyAssistantRequestToolResourcesToJSON( + modifyAssistantRequestToolResources: ModifyAssistantRequestToolResources, +): string { + return JSON.stringify( + ModifyAssistantRequestToolResources$outboundSchema.parse( + modifyAssistantRequestToolResources, + ), + ); +} + +export function modifyAssistantRequestToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ModifyAssistantRequestToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequestToolResources' from JSON`, + ); +} + /** @internal */ export const ModifyAssistantRequestMetadata$inboundSchema: z.ZodType< ModifyAssistantRequestMetadata, @@ -362,6 +447,26 @@ export namespace ModifyAssistantRequestMetadata$ { export type Outbound = ModifyAssistantRequestMetadata$Outbound; } +export function modifyAssistantRequestMetadataToJSON( + modifyAssistantRequestMetadata: ModifyAssistantRequestMetadata, +): string { + return JSON.stringify( + ModifyAssistantRequestMetadata$outboundSchema.parse( + modifyAssistantRequestMetadata, + ), + ); +} + +export function modifyAssistantRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyAssistantRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequestMetadata' from JSON`, + ); +} + /** @internal */ export const ModifyAssistantRequest$inboundSchema: z.ZodType< ModifyAssistantRequest, @@ -465,3 +570,21 @@ export namespace ModifyAssistantRequest$ { /** @deprecated use `ModifyAssistantRequest$Outbound` instead. */ export type Outbound = ModifyAssistantRequest$Outbound; } + +export function modifyAssistantRequestToJSON( + modifyAssistantRequest: ModifyAssistantRequest, +): string { + return JSON.stringify( + ModifyAssistantRequest$outboundSchema.parse(modifyAssistantRequest), + ); +} + +export function modifyAssistantRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyAssistantRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequest' from JSON`, + ); +} diff --git a/src/models/components/modifymessagerequest.ts b/src/models/components/modifymessagerequest.ts index 2b5e84a..d7c06ec 100644 --- a/src/models/components/modifymessagerequest.ts +++ b/src/models/components/modifymessagerequest.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * 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. @@ -50,6 +53,26 @@ export namespace ModifyMessageRequestMetadata$ { export type Outbound = ModifyMessageRequestMetadata$Outbound; } +export function modifyMessageRequestMetadataToJSON( + modifyMessageRequestMetadata: ModifyMessageRequestMetadata, +): string { + return JSON.stringify( + ModifyMessageRequestMetadata$outboundSchema.parse( + modifyMessageRequestMetadata, + ), + ); +} + +export function modifyMessageRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyMessageRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyMessageRequestMetadata' from JSON`, + ); +} + /** @internal */ export const ModifyMessageRequest$inboundSchema: z.ZodType< ModifyMessageRequest, @@ -88,3 +111,21 @@ export namespace ModifyMessageRequest$ { /** @deprecated use `ModifyMessageRequest$Outbound` instead. */ export type Outbound = ModifyMessageRequest$Outbound; } + +export function modifyMessageRequestToJSON( + modifyMessageRequest: ModifyMessageRequest, +): string { + return JSON.stringify( + ModifyMessageRequest$outboundSchema.parse(modifyMessageRequest), + ); +} + +export function modifyMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyMessageRequest' from JSON`, + ); +} diff --git a/src/models/components/modifyrunrequest.ts b/src/models/components/modifyrunrequest.ts index 69663d3..f3eded2 100644 --- a/src/models/components/modifyrunrequest.ts +++ b/src/models/components/modifyrunrequest.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * 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. @@ -50,6 +53,24 @@ export namespace ModifyRunRequestMetadata$ { export type Outbound = ModifyRunRequestMetadata$Outbound; } +export function modifyRunRequestMetadataToJSON( + modifyRunRequestMetadata: ModifyRunRequestMetadata, +): string { + return JSON.stringify( + ModifyRunRequestMetadata$outboundSchema.parse(modifyRunRequestMetadata), + ); +} + +export function modifyRunRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyRunRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyRunRequestMetadata' from JSON`, + ); +} + /** @internal */ export const ModifyRunRequest$inboundSchema: z.ZodType< ModifyRunRequest, @@ -87,3 +108,21 @@ export namespace ModifyRunRequest$ { /** @deprecated use `ModifyRunRequest$Outbound` instead. */ export type Outbound = ModifyRunRequest$Outbound; } + +export function modifyRunRequestToJSON( + modifyRunRequest: ModifyRunRequest, +): string { + return JSON.stringify( + ModifyRunRequest$outboundSchema.parse(modifyRunRequest), + ); +} + +export function modifyRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyRunRequest' from JSON`, + ); +} diff --git a/src/models/components/modifythreadrequest.ts b/src/models/components/modifythreadrequest.ts index bf1eca8..1bff912 100644 --- a/src/models/components/modifythreadrequest.ts +++ b/src/models/components/modifythreadrequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyThreadRequestCodeInterpreter = { /** @@ -100,6 +103,27 @@ export namespace ModifyThreadRequestCodeInterpreter$ { export type Outbound = ModifyThreadRequestCodeInterpreter$Outbound; } +export function modifyThreadRequestCodeInterpreterToJSON( + modifyThreadRequestCodeInterpreter: ModifyThreadRequestCodeInterpreter, +): string { + return JSON.stringify( + ModifyThreadRequestCodeInterpreter$outboundSchema.parse( + modifyThreadRequestCodeInterpreter, + ), + ); +} + +export function modifyThreadRequestCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ModifyThreadRequestCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequestCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const ModifyThreadRequestFileSearch$inboundSchema: z.ZodType< ModifyThreadRequestFileSearch, @@ -144,6 +168,26 @@ export namespace ModifyThreadRequestFileSearch$ { export type Outbound = ModifyThreadRequestFileSearch$Outbound; } +export function modifyThreadRequestFileSearchToJSON( + modifyThreadRequestFileSearch: ModifyThreadRequestFileSearch, +): string { + return JSON.stringify( + ModifyThreadRequestFileSearch$outboundSchema.parse( + modifyThreadRequestFileSearch, + ), + ); +} + +export function modifyThreadRequestFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyThreadRequestFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequestFileSearch' from JSON`, + ); +} + /** @internal */ export const ModifyThreadRequestToolResources$inboundSchema: z.ZodType< ModifyThreadRequestToolResources, @@ -199,6 +243,26 @@ export namespace ModifyThreadRequestToolResources$ { export type Outbound = ModifyThreadRequestToolResources$Outbound; } +export function modifyThreadRequestToolResourcesToJSON( + modifyThreadRequestToolResources: ModifyThreadRequestToolResources, +): string { + return JSON.stringify( + ModifyThreadRequestToolResources$outboundSchema.parse( + modifyThreadRequestToolResources, + ), + ); +} + +export function modifyThreadRequestToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyThreadRequestToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequestToolResources' from JSON`, + ); +} + /** @internal */ export const ModifyThreadRequestMetadata$inboundSchema: z.ZodType< ModifyThreadRequestMetadata, @@ -229,6 +293,26 @@ export namespace ModifyThreadRequestMetadata$ { export type Outbound = ModifyThreadRequestMetadata$Outbound; } +export function modifyThreadRequestMetadataToJSON( + modifyThreadRequestMetadata: ModifyThreadRequestMetadata, +): string { + return JSON.stringify( + ModifyThreadRequestMetadata$outboundSchema.parse( + modifyThreadRequestMetadata, + ), + ); +} + +export function modifyThreadRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyThreadRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequestMetadata' from JSON`, + ); +} + /** @internal */ export const ModifyThreadRequest$inboundSchema: z.ZodType< ModifyThreadRequest, @@ -281,3 +365,21 @@ export namespace ModifyThreadRequest$ { /** @deprecated use `ModifyThreadRequest$Outbound` instead. */ export type Outbound = ModifyThreadRequest$Outbound; } + +export function modifyThreadRequestToJSON( + modifyThreadRequest: ModifyThreadRequest, +): string { + return JSON.stringify( + ModifyThreadRequest$outboundSchema.parse(modifyThreadRequest), + ); +} + +export function modifyThreadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyThreadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequest' from JSON`, + ); +} diff --git a/src/models/components/openaifile.ts b/src/models/components/openaifile.ts index ec421d7..74a6151 100644 --- a/src/models/components/openaifile.ts +++ b/src/models/components/openaifile.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `file`. @@ -218,3 +221,17 @@ export namespace OpenAIFile$ { /** @deprecated use `OpenAIFile$Outbound` instead. */ export type Outbound = OpenAIFile$Outbound; } + +export function openAIFileToJSON(openAIFile: OpenAIFile): string { + return JSON.stringify(OpenAIFile$outboundSchema.parse(openAIFile)); +} + +export function openAIFileFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => OpenAIFile$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'OpenAIFile' from JSON`, + ); +} diff --git a/src/models/components/otherchunkingstrategyresponseparam.ts b/src/models/components/otherchunkingstrategyresponseparam.ts index 102e1db..82810d0 100644 --- a/src/models/components/otherchunkingstrategyresponseparam.ts +++ b/src/models/components/otherchunkingstrategyresponseparam.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `other`. @@ -88,3 +91,24 @@ export namespace OtherChunkingStrategyResponseParam$ { /** @deprecated use `OtherChunkingStrategyResponseParam$Outbound` instead. */ export type Outbound = OtherChunkingStrategyResponseParam$Outbound; } + +export function otherChunkingStrategyResponseParamToJSON( + otherChunkingStrategyResponseParam: OtherChunkingStrategyResponseParam, +): string { + return JSON.stringify( + OtherChunkingStrategyResponseParam$outboundSchema.parse( + otherChunkingStrategyResponseParam, + ), + ); +} + +export function otherChunkingStrategyResponseParamFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + OtherChunkingStrategyResponseParam$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'OtherChunkingStrategyResponseParam' from JSON`, + ); +} diff --git a/src/models/components/project.ts b/src/models/components/project.ts index e5a16b6..8c514ca 100644 --- a/src/models/components/project.ts +++ b/src/models/components/project.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.project` @@ -158,3 +161,17 @@ export namespace Project$ { /** @deprecated use `Project$Outbound` instead. */ export type Outbound = Project$Outbound; } + +export function projectToJSON(project: Project): string { + return JSON.stringify(Project$outboundSchema.parse(project)); +} + +export function projectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Project$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Project' from JSON`, + ); +} diff --git a/src/models/components/projectapikey.ts b/src/models/components/projectapikey.ts index dd1c5f5..e5262a6 100644 --- a/src/models/components/projectapikey.ts +++ b/src/models/components/projectapikey.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProjectServiceAccount, ProjectServiceAccount$inboundSchema, @@ -172,6 +175,20 @@ export namespace Owner$ { export type Outbound = Owner$Outbound; } +export function ownerToJSON(owner: Owner): string { + return JSON.stringify(Owner$outboundSchema.parse(owner)); +} + +export function ownerFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Owner$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Owner' from JSON`, + ); +} + /** @internal */ export const ProjectApiKey$inboundSchema: z.ZodType< ProjectApiKey, @@ -232,3 +249,17 @@ export namespace ProjectApiKey$ { /** @deprecated use `ProjectApiKey$Outbound` instead. */ export type Outbound = ProjectApiKey$Outbound; } + +export function projectApiKeyToJSON(projectApiKey: ProjectApiKey): string { + return JSON.stringify(ProjectApiKey$outboundSchema.parse(projectApiKey)); +} + +export function projectApiKeyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectApiKey$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectApiKey' from JSON`, + ); +} diff --git a/src/models/components/projectapikeydeleteresponse.ts b/src/models/components/projectapikeydeleteresponse.ts index 2c9353e..2b5f995 100644 --- a/src/models/components/projectapikeydeleteresponse.ts +++ b/src/models/components/projectapikeydeleteresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const ProjectApiKeyDeleteResponseObject = { OrganizationProjectApiKeyDeleted: "organization.project.api_key.deleted", @@ -81,3 +84,23 @@ export namespace ProjectApiKeyDeleteResponse$ { /** @deprecated use `ProjectApiKeyDeleteResponse$Outbound` instead. */ export type Outbound = ProjectApiKeyDeleteResponse$Outbound; } + +export function projectApiKeyDeleteResponseToJSON( + projectApiKeyDeleteResponse: ProjectApiKeyDeleteResponse, +): string { + return JSON.stringify( + ProjectApiKeyDeleteResponse$outboundSchema.parse( + projectApiKeyDeleteResponse, + ), + ); +} + +export function projectApiKeyDeleteResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectApiKeyDeleteResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectApiKeyDeleteResponse' from JSON`, + ); +} diff --git a/src/models/components/projectapikeylistresponse.ts b/src/models/components/projectapikeylistresponse.ts index 4a6d09f..e7ea94f 100644 --- a/src/models/components/projectapikeylistresponse.ts +++ b/src/models/components/projectapikeylistresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProjectApiKey, ProjectApiKey$inboundSchema, @@ -107,3 +110,21 @@ export namespace ProjectApiKeyListResponse$ { /** @deprecated use `ProjectApiKeyListResponse$Outbound` instead. */ export type Outbound = ProjectApiKeyListResponse$Outbound; } + +export function projectApiKeyListResponseToJSON( + projectApiKeyListResponse: ProjectApiKeyListResponse, +): string { + return JSON.stringify( + ProjectApiKeyListResponse$outboundSchema.parse(projectApiKeyListResponse), + ); +} + +export function projectApiKeyListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectApiKeyListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectApiKeyListResponse' from JSON`, + ); +} diff --git a/src/models/components/projectcreaterequest.ts b/src/models/components/projectcreaterequest.ts index b193f61..01b41d6 100644 --- a/src/models/components/projectcreaterequest.ts +++ b/src/models/components/projectcreaterequest.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ProjectCreateRequest = { /** @@ -46,3 +49,21 @@ export namespace ProjectCreateRequest$ { /** @deprecated use `ProjectCreateRequest$Outbound` instead. */ export type Outbound = ProjectCreateRequest$Outbound; } + +export function projectCreateRequestToJSON( + projectCreateRequest: ProjectCreateRequest, +): string { + return JSON.stringify( + ProjectCreateRequest$outboundSchema.parse(projectCreateRequest), + ); +} + +export function projectCreateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectCreateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectCreateRequest' from JSON`, + ); +} diff --git a/src/models/components/projectlistresponse.ts b/src/models/components/projectlistresponse.ts index 1753410..65d2d69 100644 --- a/src/models/components/projectlistresponse.ts +++ b/src/models/components/projectlistresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Project, Project$inboundSchema, @@ -107,3 +110,21 @@ export namespace ProjectListResponse$ { /** @deprecated use `ProjectListResponse$Outbound` instead. */ export type Outbound = ProjectListResponse$Outbound; } + +export function projectListResponseToJSON( + projectListResponse: ProjectListResponse, +): string { + return JSON.stringify( + ProjectListResponse$outboundSchema.parse(projectListResponse), + ); +} + +export function projectListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectListResponse' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccount.ts b/src/models/components/projectserviceaccount.ts index e3e7579..a0a0525 100644 --- a/src/models/components/projectserviceaccount.ts +++ b/src/models/components/projectserviceaccount.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.project.service_account` @@ -156,3 +159,21 @@ export namespace ProjectServiceAccount$ { /** @deprecated use `ProjectServiceAccount$Outbound` instead. */ export type Outbound = ProjectServiceAccount$Outbound; } + +export function projectServiceAccountToJSON( + projectServiceAccount: ProjectServiceAccount, +): string { + return JSON.stringify( + ProjectServiceAccount$outboundSchema.parse(projectServiceAccount), + ); +} + +export function projectServiceAccountFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectServiceAccount$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccount' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccountapikey.ts b/src/models/components/projectserviceaccountapikey.ts index 21d058e..91261db 100644 --- a/src/models/components/projectserviceaccountapikey.ts +++ b/src/models/components/projectserviceaccountapikey.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.project.service_account.api_key` @@ -108,3 +111,23 @@ export namespace ProjectServiceAccountApiKey$ { /** @deprecated use `ProjectServiceAccountApiKey$Outbound` instead. */ export type Outbound = ProjectServiceAccountApiKey$Outbound; } + +export function projectServiceAccountApiKeyToJSON( + projectServiceAccountApiKey: ProjectServiceAccountApiKey, +): string { + return JSON.stringify( + ProjectServiceAccountApiKey$outboundSchema.parse( + projectServiceAccountApiKey, + ), + ); +} + +export function projectServiceAccountApiKeyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectServiceAccountApiKey$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccountApiKey' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccountcreaterequest.ts b/src/models/components/projectserviceaccountcreaterequest.ts index 66f67f0..9191d67 100644 --- a/src/models/components/projectserviceaccountcreaterequest.ts +++ b/src/models/components/projectserviceaccountcreaterequest.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ProjectServiceAccountCreateRequest = { /** @@ -47,3 +50,24 @@ export namespace ProjectServiceAccountCreateRequest$ { /** @deprecated use `ProjectServiceAccountCreateRequest$Outbound` instead. */ export type Outbound = ProjectServiceAccountCreateRequest$Outbound; } + +export function projectServiceAccountCreateRequestToJSON( + projectServiceAccountCreateRequest: ProjectServiceAccountCreateRequest, +): string { + return JSON.stringify( + ProjectServiceAccountCreateRequest$outboundSchema.parse( + projectServiceAccountCreateRequest, + ), + ); +} + +export function projectServiceAccountCreateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ProjectServiceAccountCreateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccountCreateRequest' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccountcreateresponse.ts b/src/models/components/projectserviceaccountcreateresponse.ts index 1ffd9ca..3392674 100644 --- a/src/models/components/projectserviceaccountcreateresponse.ts +++ b/src/models/components/projectserviceaccountcreateresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProjectServiceAccountApiKey, ProjectServiceAccountApiKey$inboundSchema, @@ -152,3 +155,24 @@ export namespace ProjectServiceAccountCreateResponse$ { /** @deprecated use `ProjectServiceAccountCreateResponse$Outbound` instead. */ export type Outbound = ProjectServiceAccountCreateResponse$Outbound; } + +export function projectServiceAccountCreateResponseToJSON( + projectServiceAccountCreateResponse: ProjectServiceAccountCreateResponse, +): string { + return JSON.stringify( + ProjectServiceAccountCreateResponse$outboundSchema.parse( + projectServiceAccountCreateResponse, + ), + ); +} + +export function projectServiceAccountCreateResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ProjectServiceAccountCreateResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccountCreateResponse' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccountdeleteresponse.ts b/src/models/components/projectserviceaccountdeleteresponse.ts index 9e1d076..3c84120 100644 --- a/src/models/components/projectserviceaccountdeleteresponse.ts +++ b/src/models/components/projectserviceaccountdeleteresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const ProjectServiceAccountDeleteResponseObject = { OrganizationProjectServiceAccountDeleted: @@ -85,3 +88,24 @@ export namespace ProjectServiceAccountDeleteResponse$ { /** @deprecated use `ProjectServiceAccountDeleteResponse$Outbound` instead. */ export type Outbound = ProjectServiceAccountDeleteResponse$Outbound; } + +export function projectServiceAccountDeleteResponseToJSON( + projectServiceAccountDeleteResponse: ProjectServiceAccountDeleteResponse, +): string { + return JSON.stringify( + ProjectServiceAccountDeleteResponse$outboundSchema.parse( + projectServiceAccountDeleteResponse, + ), + ); +} + +export function projectServiceAccountDeleteResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ProjectServiceAccountDeleteResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccountDeleteResponse' from JSON`, + ); +} diff --git a/src/models/components/projectserviceaccountlistresponse.ts b/src/models/components/projectserviceaccountlistresponse.ts index 04ef5c0..4861bda 100644 --- a/src/models/components/projectserviceaccountlistresponse.ts +++ b/src/models/components/projectserviceaccountlistresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProjectServiceAccount, ProjectServiceAccount$inboundSchema, @@ -110,3 +113,23 @@ export namespace ProjectServiceAccountListResponse$ { /** @deprecated use `ProjectServiceAccountListResponse$Outbound` instead. */ export type Outbound = ProjectServiceAccountListResponse$Outbound; } + +export function projectServiceAccountListResponseToJSON( + projectServiceAccountListResponse: ProjectServiceAccountListResponse, +): string { + return JSON.stringify( + ProjectServiceAccountListResponse$outboundSchema.parse( + projectServiceAccountListResponse, + ), + ); +} + +export function projectServiceAccountListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectServiceAccountListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectServiceAccountListResponse' from JSON`, + ); +} diff --git a/src/models/components/projectupdaterequest.ts b/src/models/components/projectupdaterequest.ts index 40fb4a4..37a68b7 100644 --- a/src/models/components/projectupdaterequest.ts +++ b/src/models/components/projectupdaterequest.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ProjectUpdateRequest = { /** @@ -46,3 +49,21 @@ export namespace ProjectUpdateRequest$ { /** @deprecated use `ProjectUpdateRequest$Outbound` instead. */ export type Outbound = ProjectUpdateRequest$Outbound; } + +export function projectUpdateRequestToJSON( + projectUpdateRequest: ProjectUpdateRequest, +): string { + return JSON.stringify( + ProjectUpdateRequest$outboundSchema.parse(projectUpdateRequest), + ); +} + +export function projectUpdateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUpdateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUpdateRequest' from JSON`, + ); +} diff --git a/src/models/components/projectuser.ts b/src/models/components/projectuser.ts index 8918c52..21c528c 100644 --- a/src/models/components/projectuser.ts +++ b/src/models/components/projectuser.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.project.user` @@ -159,3 +162,17 @@ export namespace ProjectUser$ { /** @deprecated use `ProjectUser$Outbound` instead. */ export type Outbound = ProjectUser$Outbound; } + +export function projectUserToJSON(projectUser: ProjectUser): string { + return JSON.stringify(ProjectUser$outboundSchema.parse(projectUser)); +} + +export function projectUserFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUser$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUser' from JSON`, + ); +} diff --git a/src/models/components/projectusercreaterequest.ts b/src/models/components/projectusercreaterequest.ts index 80255b4..5c9e684 100644 --- a/src/models/components/projectusercreaterequest.ts +++ b/src/models/components/projectusercreaterequest.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * `owner` or `member` @@ -98,3 +101,21 @@ export namespace ProjectUserCreateRequest$ { /** @deprecated use `ProjectUserCreateRequest$Outbound` instead. */ export type Outbound = ProjectUserCreateRequest$Outbound; } + +export function projectUserCreateRequestToJSON( + projectUserCreateRequest: ProjectUserCreateRequest, +): string { + return JSON.stringify( + ProjectUserCreateRequest$outboundSchema.parse(projectUserCreateRequest), + ); +} + +export function projectUserCreateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUserCreateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUserCreateRequest' from JSON`, + ); +} diff --git a/src/models/components/projectuserdeleteresponse.ts b/src/models/components/projectuserdeleteresponse.ts index 1445022..d5ade3a 100644 --- a/src/models/components/projectuserdeleteresponse.ts +++ b/src/models/components/projectuserdeleteresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const ProjectUserDeleteResponseObject = { OrganizationProjectUserDeleted: "organization.project.user.deleted", @@ -80,3 +83,21 @@ export namespace ProjectUserDeleteResponse$ { /** @deprecated use `ProjectUserDeleteResponse$Outbound` instead. */ export type Outbound = ProjectUserDeleteResponse$Outbound; } + +export function projectUserDeleteResponseToJSON( + projectUserDeleteResponse: ProjectUserDeleteResponse, +): string { + return JSON.stringify( + ProjectUserDeleteResponse$outboundSchema.parse(projectUserDeleteResponse), + ); +} + +export function projectUserDeleteResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUserDeleteResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUserDeleteResponse' from JSON`, + ); +} diff --git a/src/models/components/projectuserlistresponse.ts b/src/models/components/projectuserlistresponse.ts index 9e05e52..43d789e 100644 --- a/src/models/components/projectuserlistresponse.ts +++ b/src/models/components/projectuserlistresponse.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ProjectUser, ProjectUser$inboundSchema, @@ -78,3 +81,21 @@ export namespace ProjectUserListResponse$ { /** @deprecated use `ProjectUserListResponse$Outbound` instead. */ export type Outbound = ProjectUserListResponse$Outbound; } + +export function projectUserListResponseToJSON( + projectUserListResponse: ProjectUserListResponse, +): string { + return JSON.stringify( + ProjectUserListResponse$outboundSchema.parse(projectUserListResponse), + ); +} + +export function projectUserListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUserListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUserListResponse' from JSON`, + ); +} diff --git a/src/models/components/projectuserupdaterequest.ts b/src/models/components/projectuserupdaterequest.ts index 24a5696..22891a7 100644 --- a/src/models/components/projectuserupdaterequest.ts +++ b/src/models/components/projectuserupdaterequest.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * `owner` or `member` @@ -82,3 +85,21 @@ export namespace ProjectUserUpdateRequest$ { /** @deprecated use `ProjectUserUpdateRequest$Outbound` instead. */ export type Outbound = ProjectUserUpdateRequest$Outbound; } + +export function projectUserUpdateRequestToJSON( + projectUserUpdateRequest: ProjectUserUpdateRequest, +): string { + return JSON.stringify( + ProjectUserUpdateRequest$outboundSchema.parse(projectUserUpdateRequest), + ); +} + +export function projectUserUpdateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ProjectUserUpdateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ProjectUserUpdateRequest' from JSON`, + ); +} diff --git a/src/models/components/responseformatjsonobject.ts b/src/models/components/responseformatjsonobject.ts index 13e3e84..85c3066 100644 --- a/src/models/components/responseformatjsonobject.ts +++ b/src/models/components/responseformatjsonobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of response format being defined: `json_object` @@ -81,3 +84,21 @@ export namespace ResponseFormatJsonObject$ { /** @deprecated use `ResponseFormatJsonObject$Outbound` instead. */ export type Outbound = ResponseFormatJsonObject$Outbound; } + +export function responseFormatJsonObjectToJSON( + responseFormatJsonObject: ResponseFormatJsonObject, +): string { + return JSON.stringify( + ResponseFormatJsonObject$outboundSchema.parse(responseFormatJsonObject), + ); +} + +export function responseFormatJsonObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ResponseFormatJsonObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ResponseFormatJsonObject' from JSON`, + ); +} diff --git a/src/models/components/responseformatjsonschema.ts b/src/models/components/responseformatjsonschema.ts index a4ff4db..2ad1ee0 100644 --- a/src/models/components/responseformatjsonschema.ts +++ b/src/models/components/responseformatjsonschema.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of response format being defined: `json_schema` @@ -112,6 +115,20 @@ export namespace JsonSchema$ { export type Outbound = JsonSchema$Outbound; } +export function jsonSchemaToJSON(jsonSchema: JsonSchema): string { + return JSON.stringify(JsonSchema$outboundSchema.parse(jsonSchema)); +} + +export function jsonSchemaFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => JsonSchema$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'JsonSchema' from JSON`, + ); +} + /** @internal */ export const ResponseFormatJsonSchema$inboundSchema: z.ZodType< ResponseFormatJsonSchema, @@ -158,3 +175,21 @@ export namespace ResponseFormatJsonSchema$ { /** @deprecated use `ResponseFormatJsonSchema$Outbound` instead. */ export type Outbound = ResponseFormatJsonSchema$Outbound; } + +export function responseFormatJsonSchemaToJSON( + responseFormatJsonSchema: ResponseFormatJsonSchema, +): string { + return JSON.stringify( + ResponseFormatJsonSchema$outboundSchema.parse(responseFormatJsonSchema), + ); +} + +export function responseFormatJsonSchemaFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ResponseFormatJsonSchema$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ResponseFormatJsonSchema' from JSON`, + ); +} diff --git a/src/models/components/responseformattext.ts b/src/models/components/responseformattext.ts index c41e63c..ef23c0e 100644 --- a/src/models/components/responseformattext.ts +++ b/src/models/components/responseformattext.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of response format being defined: `text` @@ -79,3 +82,21 @@ export namespace ResponseFormatText$ { /** @deprecated use `ResponseFormatText$Outbound` instead. */ export type Outbound = ResponseFormatText$Outbound; } + +export function responseFormatTextToJSON( + responseFormatText: ResponseFormatText, +): string { + return JSON.stringify( + ResponseFormatText$outboundSchema.parse(responseFormatText), + ); +} + +export function responseFormatTextFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ResponseFormatText$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ResponseFormatText' from JSON`, + ); +} diff --git a/src/models/components/runcompletionusage.ts b/src/models/components/runcompletionusage.ts index 3a58fbb..590d097 100644 --- a/src/models/components/runcompletionusage.ts +++ b/src/models/components/runcompletionusage.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * 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.). @@ -76,3 +79,21 @@ export namespace RunCompletionUsage$ { /** @deprecated use `RunCompletionUsage$Outbound` instead. */ export type Outbound = RunCompletionUsage$Outbound; } + +export function runCompletionUsageToJSON( + runCompletionUsage: RunCompletionUsage, +): string { + return JSON.stringify( + RunCompletionUsage$outboundSchema.parse(runCompletionUsage), + ); +} + +export function runCompletionUsageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunCompletionUsage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunCompletionUsage' from JSON`, + ); +} diff --git a/src/models/components/runobject.ts b/src/models/components/runobject.ts index d14d606..704de6e 100644 --- a/src/models/components/runobject.ts +++ b/src/models/components/runobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AssistantsApiResponseFormatOption, AssistantsApiResponseFormatOption$inboundSchema, @@ -298,6 +301,10 @@ export type RunObject = { * Specifying a particular tool like `{"type": "file_search"}` or `{"type": "function", "function": {"name": "my_function"}}` forces the model to call that tool. */ toolChoice: AssistantsApiToolChoiceOption; + /** + * Whether to enable [parallel function calling](/docs/guides/function-calling/parallel-function-calling) during tool use. + */ + parallelToolCalls?: boolean | undefined; /** * Specifies the format that the model must output. Compatible with [GPT-4o](/docs/models/gpt-4o), [GPT-4 Turbo](/docs/models/gpt-4-turbo-and-gpt-4), and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`. * @@ -419,6 +426,24 @@ export namespace SubmitToolOutputs$ { export type Outbound = SubmitToolOutputs$Outbound; } +export function submitToolOutputsToJSON( + submitToolOutputs: SubmitToolOutputs, +): string { + return JSON.stringify( + SubmitToolOutputs$outboundSchema.parse(submitToolOutputs), + ); +} + +export function submitToolOutputsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SubmitToolOutputs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SubmitToolOutputs' from JSON`, + ); +} + /** @internal */ export const RequiredAction$inboundSchema: z.ZodType< RequiredAction, @@ -466,6 +491,20 @@ export namespace RequiredAction$ { export type Outbound = RequiredAction$Outbound; } +export function requiredActionToJSON(requiredAction: RequiredAction): string { + return JSON.stringify(RequiredAction$outboundSchema.parse(requiredAction)); +} + +export function requiredActionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RequiredAction$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RequiredAction' from JSON`, + ); +} + /** @internal */ export const Code$inboundSchema: z.ZodNativeEnum = z.nativeEnum( Code, @@ -525,6 +564,20 @@ export namespace LastError$ { export type Outbound = LastError$Outbound; } +export function lastErrorToJSON(lastError: LastError): string { + return JSON.stringify(LastError$outboundSchema.parse(lastError)); +} + +export function lastErrorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => LastError$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'LastError' from JSON`, + ); +} + /** @internal */ export const RunObjectReason$inboundSchema: z.ZodNativeEnum< typeof RunObjectReason @@ -582,6 +635,24 @@ export namespace RunObjectIncompleteDetails$ { export type Outbound = RunObjectIncompleteDetails$Outbound; } +export function runObjectIncompleteDetailsToJSON( + runObjectIncompleteDetails: RunObjectIncompleteDetails, +): string { + return JSON.stringify( + RunObjectIncompleteDetails$outboundSchema.parse(runObjectIncompleteDetails), + ); +} + +export function runObjectIncompleteDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunObjectIncompleteDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunObjectIncompleteDetails' from JSON`, + ); +} + /** @internal */ export const RunObjectTools$inboundSchema: z.ZodType< RunObjectTools, @@ -623,6 +694,20 @@ export namespace RunObjectTools$ { export type Outbound = RunObjectTools$Outbound; } +export function runObjectToolsToJSON(runObjectTools: RunObjectTools): string { + return JSON.stringify(RunObjectTools$outboundSchema.parse(runObjectTools)); +} + +export function runObjectToolsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunObjectTools$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunObjectTools' from JSON`, + ); +} + /** @internal */ export const RunObjectMetadata$inboundSchema: z.ZodType< RunObjectMetadata, @@ -653,6 +738,24 @@ export namespace RunObjectMetadata$ { export type Outbound = RunObjectMetadata$Outbound; } +export function runObjectMetadataToJSON( + runObjectMetadata: RunObjectMetadata, +): string { + return JSON.stringify( + RunObjectMetadata$outboundSchema.parse(runObjectMetadata), + ); +} + +export function runObjectMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunObjectMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunObjectMetadata' from JSON`, + ); +} + /** @internal */ export const RunObject$inboundSchema: z.ZodType< RunObject, @@ -692,6 +795,7 @@ export const RunObject$inboundSchema: z.ZodType< max_completion_tokens: z.nullable(z.number().int()), truncation_strategy: TruncationObject$inboundSchema, tool_choice: AssistantsApiToolChoiceOption$inboundSchema, + parallel_tool_calls: z.boolean().default(true), response_format: AssistantsApiResponseFormatOption$inboundSchema, }).transform((v) => { return remap$(v, { @@ -711,6 +815,7 @@ export const RunObject$inboundSchema: z.ZodType< "max_completion_tokens": "maxCompletionTokens", "truncation_strategy": "truncationStrategy", "tool_choice": "toolChoice", + "parallel_tool_calls": "parallelToolCalls", "response_format": "responseFormat", }); }); @@ -746,6 +851,7 @@ export type RunObject$Outbound = { max_completion_tokens: number | null; truncation_strategy: TruncationObject$Outbound; tool_choice: AssistantsApiToolChoiceOption$Outbound; + parallel_tool_calls: boolean; response_format: AssistantsApiResponseFormatOption$Outbound; }; @@ -788,6 +894,7 @@ export const RunObject$outboundSchema: z.ZodType< maxCompletionTokens: z.nullable(z.number().int()), truncationStrategy: TruncationObject$outboundSchema, toolChoice: AssistantsApiToolChoiceOption$outboundSchema, + parallelToolCalls: z.boolean().default(true), responseFormat: AssistantsApiResponseFormatOption$outboundSchema, }).transform((v) => { return remap$(v, { @@ -807,6 +914,7 @@ export const RunObject$outboundSchema: z.ZodType< maxCompletionTokens: "max_completion_tokens", truncationStrategy: "truncation_strategy", toolChoice: "tool_choice", + parallelToolCalls: "parallel_tool_calls", responseFormat: "response_format", }); }); @@ -823,3 +931,17 @@ export namespace RunObject$ { /** @deprecated use `RunObject$Outbound` instead. */ export type Outbound = RunObject$Outbound; } + +export function runObjectToJSON(runObject: RunObject): string { + return JSON.stringify(RunObject$outboundSchema.parse(runObject)); +} + +export function runObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunObject' from JSON`, + ); +} diff --git a/src/models/components/runstepcompletionusage.ts b/src/models/components/runstepcompletionusage.ts index ad735ee..5b01dfe 100644 --- a/src/models/components/runstepcompletionusage.ts +++ b/src/models/components/runstepcompletionusage.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Usage statistics related to the run step. This value will be `null` while the run step's status is `in_progress`. @@ -76,3 +79,21 @@ export namespace RunStepCompletionUsage$ { /** @deprecated use `RunStepCompletionUsage$Outbound` instead. */ export type Outbound = RunStepCompletionUsage$Outbound; } + +export function runStepCompletionUsageToJSON( + runStepCompletionUsage: RunStepCompletionUsage, +): string { + return JSON.stringify( + RunStepCompletionUsage$outboundSchema.parse(runStepCompletionUsage), + ); +} + +export function runStepCompletionUsageFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepCompletionUsage$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepCompletionUsage' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailsmessagecreationobject.ts b/src/models/components/runstepdetailsmessagecreationobject.ts index 94684f3..7689f03 100644 --- a/src/models/components/runstepdetailsmessagecreationobject.ts +++ b/src/models/components/runstepdetailsmessagecreationobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `message_creation`. @@ -104,6 +107,22 @@ export namespace MessageCreation$ { export type Outbound = MessageCreation$Outbound; } +export function messageCreationToJSON( + messageCreation: MessageCreation, +): string { + return JSON.stringify(MessageCreation$outboundSchema.parse(messageCreation)); +} + +export function messageCreationFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => MessageCreation$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'MessageCreation' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsMessageCreationObject$inboundSchema: z.ZodType< RunStepDetailsMessageCreationObject, @@ -152,3 +171,24 @@ export namespace RunStepDetailsMessageCreationObject$ { /** @deprecated use `RunStepDetailsMessageCreationObject$Outbound` instead. */ export type Outbound = RunStepDetailsMessageCreationObject$Outbound; } + +export function runStepDetailsMessageCreationObjectToJSON( + runStepDetailsMessageCreationObject: RunStepDetailsMessageCreationObject, +): string { + return JSON.stringify( + RunStepDetailsMessageCreationObject$outboundSchema.parse( + runStepDetailsMessageCreationObject, + ), + ); +} + +export function runStepDetailsMessageCreationObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + RunStepDetailsMessageCreationObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepDetailsMessageCreationObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallscodeobject.ts b/src/models/components/runstepdetailstoolcallscodeobject.ts index 0165798..2a8ec9d 100644 --- a/src/models/components/runstepdetailstoolcallscodeobject.ts +++ b/src/models/components/runstepdetailstoolcallscodeobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunStepDetailsToolCallsCodeOutputImageObject, RunStepDetailsToolCallsCodeOutputImageObject$inboundSchema, @@ -129,6 +132,20 @@ export namespace Outputs$ { export type Outbound = Outputs$Outbound; } +export function outputsToJSON(outputs: Outputs): string { + return JSON.stringify(Outputs$outboundSchema.parse(outputs)); +} + +export function outputsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Outputs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Outputs' from JSON`, + ); +} + /** @internal */ export const CodeInterpreter$inboundSchema: z.ZodType< CodeInterpreter, @@ -181,6 +198,22 @@ export namespace CodeInterpreter$ { export type Outbound = CodeInterpreter$Outbound; } +export function codeInterpreterToJSON( + codeInterpreter: CodeInterpreter, +): string { + return JSON.stringify(CodeInterpreter$outboundSchema.parse(codeInterpreter)); +} + +export function codeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CodeInterpreter' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsCodeObject$inboundSchema: z.ZodType< RunStepDetailsToolCallsCodeObject, @@ -231,3 +264,23 @@ export namespace RunStepDetailsToolCallsCodeObject$ { /** @deprecated use `RunStepDetailsToolCallsCodeObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsCodeObject$Outbound; } + +export function runStepDetailsToolCallsCodeObjectToJSON( + runStepDetailsToolCallsCodeObject: RunStepDetailsToolCallsCodeObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsCodeObject$outboundSchema.parse( + runStepDetailsToolCallsCodeObject, + ), + ); +} + +export function runStepDetailsToolCallsCodeObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepDetailsToolCallsCodeObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepDetailsToolCallsCodeObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallscodeoutputimageobject.ts b/src/models/components/runstepdetailstoolcallscodeoutputimageobject.ts index 6e121da..942f207 100644 --- a/src/models/components/runstepdetailstoolcallscodeoutputimageobject.ts +++ b/src/models/components/runstepdetailstoolcallscodeoutputimageobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `image`. @@ -106,6 +109,33 @@ export namespace RunStepDetailsToolCallsCodeOutputImageObjectImage$ { RunStepDetailsToolCallsCodeOutputImageObjectImage$Outbound; } +export function runStepDetailsToolCallsCodeOutputImageObjectImageToJSON( + runStepDetailsToolCallsCodeOutputImageObjectImage: + RunStepDetailsToolCallsCodeOutputImageObjectImage, +): string { + return JSON.stringify( + RunStepDetailsToolCallsCodeOutputImageObjectImage$outboundSchema.parse( + runStepDetailsToolCallsCodeOutputImageObjectImage, + ), + ); +} + +export function runStepDetailsToolCallsCodeOutputImageObjectImageFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsCodeOutputImageObjectImage, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsCodeOutputImageObjectImage$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsCodeOutputImageObjectImage' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsCodeOutputImageObject$inboundSchema: z.ZodType< @@ -152,3 +182,30 @@ export namespace RunStepDetailsToolCallsCodeOutputImageObject$ { /** @deprecated use `RunStepDetailsToolCallsCodeOutputImageObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsCodeOutputImageObject$Outbound; } + +export function runStepDetailsToolCallsCodeOutputImageObjectToJSON( + runStepDetailsToolCallsCodeOutputImageObject: + RunStepDetailsToolCallsCodeOutputImageObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsCodeOutputImageObject$outboundSchema.parse( + runStepDetailsToolCallsCodeOutputImageObject, + ), + ); +} + +export function runStepDetailsToolCallsCodeOutputImageObjectFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsCodeOutputImageObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsCodeOutputImageObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsCodeOutputImageObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallscodeoutputlogsobject.ts b/src/models/components/runstepdetailstoolcallscodeoutputlogsobject.ts index 82bc20e..52c910d 100644 --- a/src/models/components/runstepdetailstoolcallscodeoutputlogsobject.ts +++ b/src/models/components/runstepdetailstoolcallscodeoutputlogsobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Always `logs`. @@ -97,3 +100,30 @@ export namespace RunStepDetailsToolCallsCodeOutputLogsObject$ { /** @deprecated use `RunStepDetailsToolCallsCodeOutputLogsObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsCodeOutputLogsObject$Outbound; } + +export function runStepDetailsToolCallsCodeOutputLogsObjectToJSON( + runStepDetailsToolCallsCodeOutputLogsObject: + RunStepDetailsToolCallsCodeOutputLogsObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsCodeOutputLogsObject$outboundSchema.parse( + runStepDetailsToolCallsCodeOutputLogsObject, + ), + ); +} + +export function runStepDetailsToolCallsCodeOutputLogsObjectFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsCodeOutputLogsObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsCodeOutputLogsObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsCodeOutputLogsObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallsfilesearchobject.ts b/src/models/components/runstepdetailstoolcallsfilesearchobject.ts index 5abcbb9..a7eb11a 100644 --- a/src/models/components/runstepdetailstoolcallsfilesearchobject.ts +++ b/src/models/components/runstepdetailstoolcallsfilesearchobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunStepDetailsToolCallsFileSearchRankingOptionsObject, RunStepDetailsToolCallsFileSearchRankingOptionsObject$inboundSchema, @@ -149,6 +152,33 @@ export namespace RunStepDetailsToolCallsFileSearchObjectFileSearch$ { RunStepDetailsToolCallsFileSearchObjectFileSearch$Outbound; } +export function runStepDetailsToolCallsFileSearchObjectFileSearchToJSON( + runStepDetailsToolCallsFileSearchObjectFileSearch: + RunStepDetailsToolCallsFileSearchObjectFileSearch, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFileSearchObjectFileSearch$outboundSchema.parse( + runStepDetailsToolCallsFileSearchObjectFileSearch, + ), + ); +} + +export function runStepDetailsToolCallsFileSearchObjectFileSearchFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFileSearchObjectFileSearch, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFileSearchObjectFileSearch$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFileSearchObjectFileSearch' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsFileSearchObject$inboundSchema: z.ZodType< RunStepDetailsToolCallsFileSearchObject, @@ -204,3 +234,30 @@ export namespace RunStepDetailsToolCallsFileSearchObject$ { /** @deprecated use `RunStepDetailsToolCallsFileSearchObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsFileSearchObject$Outbound; } + +export function runStepDetailsToolCallsFileSearchObjectToJSON( + runStepDetailsToolCallsFileSearchObject: + RunStepDetailsToolCallsFileSearchObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFileSearchObject$outboundSchema.parse( + runStepDetailsToolCallsFileSearchObject, + ), + ); +} + +export function runStepDetailsToolCallsFileSearchObjectFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFileSearchObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFileSearchObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFileSearchObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallsfilesearchrankingoptionsobject.ts b/src/models/components/runstepdetailstoolcallsfilesearchrankingoptionsobject.ts index e039242..162caa0 100644 --- a/src/models/components/runstepdetailstoolcallsfilesearchrankingoptionsobject.ts +++ b/src/models/components/runstepdetailstoolcallsfilesearchrankingoptionsobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The ranker used for the file search. @@ -112,3 +115,30 @@ export namespace RunStepDetailsToolCallsFileSearchRankingOptionsObject$ { export type Outbound = RunStepDetailsToolCallsFileSearchRankingOptionsObject$Outbound; } + +export function runStepDetailsToolCallsFileSearchRankingOptionsObjectToJSON( + runStepDetailsToolCallsFileSearchRankingOptionsObject: + RunStepDetailsToolCallsFileSearchRankingOptionsObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFileSearchRankingOptionsObject$outboundSchema.parse( + runStepDetailsToolCallsFileSearchRankingOptionsObject, + ), + ); +} + +export function runStepDetailsToolCallsFileSearchRankingOptionsObjectFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFileSearchRankingOptionsObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFileSearchRankingOptionsObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFileSearchRankingOptionsObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallsfilesearchresultobject.ts b/src/models/components/runstepdetailstoolcallsfilesearchresultobject.ts index f18f3a3..3cedf9a 100644 --- a/src/models/components/runstepdetailstoolcallsfilesearchresultobject.ts +++ b/src/models/components/runstepdetailstoolcallsfilesearchresultobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of the content. @@ -123,6 +126,33 @@ export namespace RunStepDetailsToolCallsFileSearchResultObjectContent$ { RunStepDetailsToolCallsFileSearchResultObjectContent$Outbound; } +export function runStepDetailsToolCallsFileSearchResultObjectContentToJSON( + runStepDetailsToolCallsFileSearchResultObjectContent: + RunStepDetailsToolCallsFileSearchResultObjectContent, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFileSearchResultObjectContent$outboundSchema.parse( + runStepDetailsToolCallsFileSearchResultObjectContent, + ), + ); +} + +export function runStepDetailsToolCallsFileSearchResultObjectContentFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFileSearchResultObjectContent, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFileSearchResultObjectContent$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFileSearchResultObjectContent' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsFileSearchResultObject$inboundSchema: z.ZodType< @@ -191,3 +221,30 @@ export namespace RunStepDetailsToolCallsFileSearchResultObject$ { /** @deprecated use `RunStepDetailsToolCallsFileSearchResultObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsFileSearchResultObject$Outbound; } + +export function runStepDetailsToolCallsFileSearchResultObjectToJSON( + runStepDetailsToolCallsFileSearchResultObject: + RunStepDetailsToolCallsFileSearchResultObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFileSearchResultObject$outboundSchema.parse( + runStepDetailsToolCallsFileSearchResultObject, + ), + ); +} + +export function runStepDetailsToolCallsFileSearchResultObjectFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFileSearchResultObject, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFileSearchResultObject$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFileSearchResultObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallsfunctionobject.ts b/src/models/components/runstepdetailstoolcallsfunctionobject.ts index dad91a0..f049610 100644 --- a/src/models/components/runstepdetailstoolcallsfunctionobject.ts +++ b/src/models/components/runstepdetailstoolcallsfunctionobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of tool call. This is always going to be `function` for this type of tool call. @@ -120,6 +123,33 @@ export namespace RunStepDetailsToolCallsFunctionObjectFunction$ { export type Outbound = RunStepDetailsToolCallsFunctionObjectFunction$Outbound; } +export function runStepDetailsToolCallsFunctionObjectFunctionToJSON( + runStepDetailsToolCallsFunctionObjectFunction: + RunStepDetailsToolCallsFunctionObjectFunction, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFunctionObjectFunction$outboundSchema.parse( + runStepDetailsToolCallsFunctionObjectFunction, + ), + ); +} + +export function runStepDetailsToolCallsFunctionObjectFunctionFromJSON( + jsonString: string, +): SafeParseResult< + RunStepDetailsToolCallsFunctionObjectFunction, + SDKValidationError +> { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFunctionObjectFunction$inboundSchema.parse( + JSON.parse(x), + ), + `Failed to parse 'RunStepDetailsToolCallsFunctionObjectFunction' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsFunctionObject$inboundSchema: z.ZodType< RunStepDetailsToolCallsFunctionObject, @@ -167,3 +197,24 @@ export namespace RunStepDetailsToolCallsFunctionObject$ { /** @deprecated use `RunStepDetailsToolCallsFunctionObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsFunctionObject$Outbound; } + +export function runStepDetailsToolCallsFunctionObjectToJSON( + runStepDetailsToolCallsFunctionObject: RunStepDetailsToolCallsFunctionObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsFunctionObject$outboundSchema.parse( + runStepDetailsToolCallsFunctionObject, + ), + ); +} + +export function runStepDetailsToolCallsFunctionObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + RunStepDetailsToolCallsFunctionObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepDetailsToolCallsFunctionObject' from JSON`, + ); +} diff --git a/src/models/components/runstepdetailstoolcallsobject.ts b/src/models/components/runstepdetailstoolcallsobject.ts index 9bcf118..735833d 100644 --- a/src/models/components/runstepdetailstoolcallsobject.ts +++ b/src/models/components/runstepdetailstoolcallsobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunStepDetailsToolCallsCodeObject, RunStepDetailsToolCallsCodeObject$inboundSchema, @@ -125,6 +128,20 @@ export namespace ToolCalls$ { export type Outbound = ToolCalls$Outbound; } +export function toolCallsToJSON(toolCalls: ToolCalls): string { + return JSON.stringify(ToolCalls$outboundSchema.parse(toolCalls)); +} + +export function toolCallsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ToolCalls$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ToolCalls' from JSON`, + ); +} + /** @internal */ export const RunStepDetailsToolCallsObject$inboundSchema: z.ZodType< RunStepDetailsToolCallsObject, @@ -187,3 +204,23 @@ export namespace RunStepDetailsToolCallsObject$ { /** @deprecated use `RunStepDetailsToolCallsObject$Outbound` instead. */ export type Outbound = RunStepDetailsToolCallsObject$Outbound; } + +export function runStepDetailsToolCallsObjectToJSON( + runStepDetailsToolCallsObject: RunStepDetailsToolCallsObject, +): string { + return JSON.stringify( + RunStepDetailsToolCallsObject$outboundSchema.parse( + runStepDetailsToolCallsObject, + ), + ); +} + +export function runStepDetailsToolCallsObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepDetailsToolCallsObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepDetailsToolCallsObject' from JSON`, + ); +} diff --git a/src/models/components/runstepobject.ts b/src/models/components/runstepobject.ts index 4bb47b6..0cc9893 100644 --- a/src/models/components/runstepobject.ts +++ b/src/models/components/runstepobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { RunStepCompletionUsage, RunStepCompletionUsage$inboundSchema, @@ -279,6 +282,20 @@ export namespace StepDetails$ { export type Outbound = StepDetails$Outbound; } +export function stepDetailsToJSON(stepDetails: StepDetails): string { + return JSON.stringify(StepDetails$outboundSchema.parse(stepDetails)); +} + +export function stepDetailsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => StepDetails$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'StepDetails' from JSON`, + ); +} + /** @internal */ export const RunStepObjectCode$inboundSchema: z.ZodNativeEnum< typeof RunStepObjectCode @@ -339,6 +356,24 @@ export namespace RunStepObjectLastError$ { export type Outbound = RunStepObjectLastError$Outbound; } +export function runStepObjectLastErrorToJSON( + runStepObjectLastError: RunStepObjectLastError, +): string { + return JSON.stringify( + RunStepObjectLastError$outboundSchema.parse(runStepObjectLastError), + ); +} + +export function runStepObjectLastErrorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepObjectLastError$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepObjectLastError' from JSON`, + ); +} + /** @internal */ export const RunStepObjectMetadata$inboundSchema: z.ZodType< RunStepObjectMetadata, @@ -369,6 +404,24 @@ export namespace RunStepObjectMetadata$ { export type Outbound = RunStepObjectMetadata$Outbound; } +export function runStepObjectMetadataToJSON( + runStepObjectMetadata: RunStepObjectMetadata, +): string { + return JSON.stringify( + RunStepObjectMetadata$outboundSchema.parse(runStepObjectMetadata), + ); +} + +export function runStepObjectMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepObjectMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepObjectMetadata' from JSON`, + ); +} + /** @internal */ export const RunStepObject$inboundSchema: z.ZodType< RunStepObject, @@ -483,3 +536,17 @@ export namespace RunStepObject$ { /** @deprecated use `RunStepObject$Outbound` instead. */ export type Outbound = RunStepObject$Outbound; } + +export function runStepObjectToJSON(runStepObject: RunStepObject): string { + return JSON.stringify(RunStepObject$outboundSchema.parse(runStepObject)); +} + +export function runStepObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunStepObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunStepObject' from JSON`, + ); +} diff --git a/src/models/components/runtoolcallobject.ts b/src/models/components/runtoolcallobject.ts index 0b77e12..433896d 100644 --- a/src/models/components/runtoolcallobject.ts +++ b/src/models/components/runtoolcallobject.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The type of tool call the output is required for. For now, this is always `function`. @@ -108,6 +111,24 @@ export namespace RunToolCallObjectFunction$ { export type Outbound = RunToolCallObjectFunction$Outbound; } +export function runToolCallObjectFunctionToJSON( + runToolCallObjectFunction: RunToolCallObjectFunction, +): string { + return JSON.stringify( + RunToolCallObjectFunction$outboundSchema.parse(runToolCallObjectFunction), + ); +} + +export function runToolCallObjectFunctionFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunToolCallObjectFunction$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunToolCallObjectFunction' from JSON`, + ); +} + /** @internal */ export const RunToolCallObject$inboundSchema: z.ZodType< RunToolCallObject, @@ -149,3 +170,21 @@ export namespace RunToolCallObject$ { /** @deprecated use `RunToolCallObject$Outbound` instead. */ export type Outbound = RunToolCallObject$Outbound; } + +export function runToolCallObjectToJSON( + runToolCallObject: RunToolCallObject, +): string { + return JSON.stringify( + RunToolCallObject$outboundSchema.parse(runToolCallObject), + ); +} + +export function runToolCallObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RunToolCallObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RunToolCallObject' from JSON`, + ); +} diff --git a/src/models/components/security.ts b/src/models/components/security.ts index ccb55d0..f8ea2f2 100644 --- a/src/models/components/security.ts +++ b/src/models/components/security.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type Security = { apiKeyAuth?: string | undefined; @@ -52,3 +55,17 @@ export namespace Security$ { /** @deprecated use `Security$Outbound` instead. */ export type Outbound = Security$Outbound; } + +export function securityToJSON(security: Security): string { + return JSON.stringify(Security$outboundSchema.parse(security)); +} + +export function securityFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Security$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Security' from JSON`, + ); +} diff --git a/src/models/components/staticchunkingstrategy.ts b/src/models/components/staticchunkingstrategy.ts index 555fd0c..f9413b2 100644 --- a/src/models/components/staticchunkingstrategy.ts +++ b/src/models/components/staticchunkingstrategy.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type StaticChunkingStrategy = { /** @@ -68,3 +71,21 @@ export namespace StaticChunkingStrategy$ { /** @deprecated use `StaticChunkingStrategy$Outbound` instead. */ export type Outbound = StaticChunkingStrategy$Outbound; } + +export function staticChunkingStrategyToJSON( + staticChunkingStrategy: StaticChunkingStrategy, +): string { + return JSON.stringify( + StaticChunkingStrategy$outboundSchema.parse(staticChunkingStrategy), + ); +} + +export function staticChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => StaticChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'StaticChunkingStrategy' from JSON`, + ); +} diff --git a/src/models/components/staticchunkingstrategyrequestparam.ts b/src/models/components/staticchunkingstrategyrequestparam.ts index 8bb7936..66df931 100644 --- a/src/models/components/staticchunkingstrategyrequestparam.ts +++ b/src/models/components/staticchunkingstrategyrequestparam.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { StaticChunkingStrategy, StaticChunkingStrategy$inboundSchema, @@ -95,3 +98,24 @@ export namespace StaticChunkingStrategyRequestParam$ { /** @deprecated use `StaticChunkingStrategyRequestParam$Outbound` instead. */ export type Outbound = StaticChunkingStrategyRequestParam$Outbound; } + +export function staticChunkingStrategyRequestParamToJSON( + staticChunkingStrategyRequestParam: StaticChunkingStrategyRequestParam, +): string { + return JSON.stringify( + StaticChunkingStrategyRequestParam$outboundSchema.parse( + staticChunkingStrategyRequestParam, + ), + ); +} + +export function staticChunkingStrategyRequestParamFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + StaticChunkingStrategyRequestParam$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'StaticChunkingStrategyRequestParam' from JSON`, + ); +} diff --git a/src/models/components/staticchunkingstrategyresponseparam.ts b/src/models/components/staticchunkingstrategyresponseparam.ts index 98296c2..c396a97 100644 --- a/src/models/components/staticchunkingstrategyresponseparam.ts +++ b/src/models/components/staticchunkingstrategyresponseparam.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { StaticChunkingStrategy, StaticChunkingStrategy$inboundSchema, @@ -95,3 +98,24 @@ export namespace StaticChunkingStrategyResponseParam$ { /** @deprecated use `StaticChunkingStrategyResponseParam$Outbound` instead. */ export type Outbound = StaticChunkingStrategyResponseParam$Outbound; } + +export function staticChunkingStrategyResponseParamToJSON( + staticChunkingStrategyResponseParam: StaticChunkingStrategyResponseParam, +): string { + return JSON.stringify( + StaticChunkingStrategyResponseParam$outboundSchema.parse( + staticChunkingStrategyResponseParam, + ), + ); +} + +export function staticChunkingStrategyResponseParamFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + StaticChunkingStrategyResponseParam$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'StaticChunkingStrategyResponseParam' from JSON`, + ); +} diff --git a/src/models/components/submittooloutputsrunrequest.ts b/src/models/components/submittooloutputsrunrequest.ts index def9c9a..ae59108 100644 --- a/src/models/components/submittooloutputsrunrequest.ts +++ b/src/models/components/submittooloutputsrunrequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ToolOutputs = { /** @@ -76,6 +79,20 @@ export namespace ToolOutputs$ { export type Outbound = ToolOutputs$Outbound; } +export function toolOutputsToJSON(toolOutputs: ToolOutputs): string { + return JSON.stringify(ToolOutputs$outboundSchema.parse(toolOutputs)); +} + +export function toolOutputsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ToolOutputs$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ToolOutputs' from JSON`, + ); +} + /** @internal */ export const SubmitToolOutputsRunRequest$inboundSchema: z.ZodType< SubmitToolOutputsRunRequest, @@ -122,3 +139,23 @@ export namespace SubmitToolOutputsRunRequest$ { /** @deprecated use `SubmitToolOutputsRunRequest$Outbound` instead. */ export type Outbound = SubmitToolOutputsRunRequest$Outbound; } + +export function submitToolOutputsRunRequestToJSON( + submitToolOutputsRunRequest: SubmitToolOutputsRunRequest, +): string { + return JSON.stringify( + SubmitToolOutputsRunRequest$outboundSchema.parse( + submitToolOutputsRunRequest, + ), + ); +} + +export function submitToolOutputsRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SubmitToolOutputsRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SubmitToolOutputsRunRequest' from JSON`, + ); +} diff --git a/src/models/components/threadobject.ts b/src/models/components/threadobject.ts index 82fc582..b740dd1 100644 --- a/src/models/components/threadobject.ts +++ b/src/models/components/threadobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `thread`. @@ -147,6 +150,26 @@ export namespace ThreadObjectCodeInterpreter$ { export type Outbound = ThreadObjectCodeInterpreter$Outbound; } +export function threadObjectCodeInterpreterToJSON( + threadObjectCodeInterpreter: ThreadObjectCodeInterpreter, +): string { + return JSON.stringify( + ThreadObjectCodeInterpreter$outboundSchema.parse( + threadObjectCodeInterpreter, + ), + ); +} + +export function threadObjectCodeInterpreterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreadObjectCodeInterpreter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreadObjectCodeInterpreter' from JSON`, + ); +} + /** @internal */ export const ThreadObjectFileSearch$inboundSchema: z.ZodType< ThreadObjectFileSearch, @@ -191,6 +214,24 @@ export namespace ThreadObjectFileSearch$ { export type Outbound = ThreadObjectFileSearch$Outbound; } +export function threadObjectFileSearchToJSON( + threadObjectFileSearch: ThreadObjectFileSearch, +): string { + return JSON.stringify( + ThreadObjectFileSearch$outboundSchema.parse(threadObjectFileSearch), + ); +} + +export function threadObjectFileSearchFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreadObjectFileSearch$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreadObjectFileSearch' from JSON`, + ); +} + /** @internal */ export const ThreadObjectToolResources$inboundSchema: z.ZodType< ThreadObjectToolResources, @@ -242,6 +283,24 @@ export namespace ThreadObjectToolResources$ { export type Outbound = ThreadObjectToolResources$Outbound; } +export function threadObjectToolResourcesToJSON( + threadObjectToolResources: ThreadObjectToolResources, +): string { + return JSON.stringify( + ThreadObjectToolResources$outboundSchema.parse(threadObjectToolResources), + ); +} + +export function threadObjectToolResourcesFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreadObjectToolResources$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreadObjectToolResources' from JSON`, + ); +} + /** @internal */ export const ThreadObjectMetadata$inboundSchema: z.ZodType< ThreadObjectMetadata, @@ -272,6 +331,24 @@ export namespace ThreadObjectMetadata$ { export type Outbound = ThreadObjectMetadata$Outbound; } +export function threadObjectMetadataToJSON( + threadObjectMetadata: ThreadObjectMetadata, +): string { + return JSON.stringify( + ThreadObjectMetadata$outboundSchema.parse(threadObjectMetadata), + ); +} + +export function threadObjectMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreadObjectMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreadObjectMetadata' from JSON`, + ); +} + /** @internal */ export const ThreadObject$inboundSchema: z.ZodType< ThreadObject, @@ -333,3 +410,17 @@ export namespace ThreadObject$ { /** @deprecated use `ThreadObject$Outbound` instead. */ export type Outbound = ThreadObject$Outbound; } + +export function threadObjectToJSON(threadObject: ThreadObject): string { + return JSON.stringify(ThreadObject$outboundSchema.parse(threadObject)); +} + +export function threadObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ThreadObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ThreadObject' from JSON`, + ); +} diff --git a/src/models/components/transcriptionsegment.ts b/src/models/components/transcriptionsegment.ts index b69c99d..5fed576 100644 --- a/src/models/components/transcriptionsegment.ts +++ b/src/models/components/transcriptionsegment.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TranscriptionSegment = { /** @@ -122,3 +125,21 @@ export namespace TranscriptionSegment$ { /** @deprecated use `TranscriptionSegment$Outbound` instead. */ export type Outbound = TranscriptionSegment$Outbound; } + +export function transcriptionSegmentToJSON( + transcriptionSegment: TranscriptionSegment, +): string { + return JSON.stringify( + TranscriptionSegment$outboundSchema.parse(transcriptionSegment), + ); +} + +export function transcriptionSegmentFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TranscriptionSegment$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TranscriptionSegment' from JSON`, + ); +} diff --git a/src/models/components/transcriptionword.ts b/src/models/components/transcriptionword.ts index eee7a0c..bc3fa65 100644 --- a/src/models/components/transcriptionword.ts +++ b/src/models/components/transcriptionword.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type TranscriptionWord = { /** @@ -60,3 +63,21 @@ export namespace TranscriptionWord$ { /** @deprecated use `TranscriptionWord$Outbound` instead. */ export type Outbound = TranscriptionWord$Outbound; } + +export function transcriptionWordToJSON( + transcriptionWord: TranscriptionWord, +): string { + return JSON.stringify( + TranscriptionWord$outboundSchema.parse(transcriptionWord), + ); +} + +export function transcriptionWordFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TranscriptionWord$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TranscriptionWord' from JSON`, + ); +} diff --git a/src/models/components/truncationobject.ts b/src/models/components/truncationobject.ts index defa78c..c805c28 100644 --- a/src/models/components/truncationobject.ts +++ b/src/models/components/truncationobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * 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`. @@ -99,3 +102,21 @@ export namespace TruncationObject$ { /** @deprecated use `TruncationObject$Outbound` instead. */ export type Outbound = TruncationObject$Outbound; } + +export function truncationObjectToJSON( + truncationObject: TruncationObject, +): string { + return JSON.stringify( + TruncationObject$outboundSchema.parse(truncationObject), + ); +} + +export function truncationObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => TruncationObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'TruncationObject' from JSON`, + ); +} diff --git a/src/models/components/updatevectorstorerequest.ts b/src/models/components/updatevectorstorerequest.ts index 8adac4a..28f993f 100644 --- a/src/models/components/updatevectorstorerequest.ts +++ b/src/models/components/updatevectorstorerequest.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { VectorStoreExpirationAfter, VectorStoreExpirationAfter$inboundSchema, @@ -65,6 +68,26 @@ export namespace UpdateVectorStoreRequestMetadata$ { export type Outbound = UpdateVectorStoreRequestMetadata$Outbound; } +export function updateVectorStoreRequestMetadataToJSON( + updateVectorStoreRequestMetadata: UpdateVectorStoreRequestMetadata, +): string { + return JSON.stringify( + UpdateVectorStoreRequestMetadata$outboundSchema.parse( + updateVectorStoreRequestMetadata, + ), + ); +} + +export function updateVectorStoreRequestMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UpdateVectorStoreRequestMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateVectorStoreRequestMetadata' from JSON`, + ); +} + /** @internal */ export const UpdateVectorStoreRequest$inboundSchema: z.ZodType< UpdateVectorStoreRequest, @@ -118,3 +141,21 @@ export namespace UpdateVectorStoreRequest$ { /** @deprecated use `UpdateVectorStoreRequest$Outbound` instead. */ export type Outbound = UpdateVectorStoreRequest$Outbound; } + +export function updateVectorStoreRequestToJSON( + updateVectorStoreRequest: UpdateVectorStoreRequest, +): string { + return JSON.stringify( + UpdateVectorStoreRequest$outboundSchema.parse(updateVectorStoreRequest), + ); +} + +export function updateVectorStoreRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UpdateVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UpdateVectorStoreRequest' from JSON`, + ); +} diff --git a/src/models/components/upload.ts b/src/models/components/upload.ts index bc698d8..b195ab7 100644 --- a/src/models/components/upload.ts +++ b/src/models/components/upload.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { OpenAIFile, OpenAIFile$inboundSchema, @@ -185,3 +188,17 @@ export namespace Upload$ { /** @deprecated use `Upload$Outbound` instead. */ export type Outbound = Upload$Outbound; } + +export function uploadToJSON(upload: Upload): string { + return JSON.stringify(Upload$outboundSchema.parse(upload)); +} + +export function uploadFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => Upload$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'Upload' from JSON`, + ); +} diff --git a/src/models/components/uploadpart.ts b/src/models/components/uploadpart.ts index 217368c..06a4058 100644 --- a/src/models/components/uploadpart.ts +++ b/src/models/components/uploadpart.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `upload.part`. @@ -116,3 +119,17 @@ export namespace UploadPart$ { /** @deprecated use `UploadPart$Outbound` instead. */ export type Outbound = UploadPart$Outbound; } + +export function uploadPartToJSON(uploadPart: UploadPart): string { + return JSON.stringify(UploadPart$outboundSchema.parse(uploadPart)); +} + +export function uploadPartFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UploadPart$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UploadPart' from JSON`, + ); +} diff --git a/src/models/components/user.ts b/src/models/components/user.ts index ca38045..b654300 100644 --- a/src/models/components/user.ts +++ b/src/models/components/user.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `organization.user` @@ -149,3 +152,17 @@ export namespace User$ { /** @deprecated use `User$Outbound` instead. */ export type Outbound = User$Outbound; } + +export function userToJSON(user: User): string { + return JSON.stringify(User$outboundSchema.parse(user)); +} + +export function userFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => User$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'User' from JSON`, + ); +} diff --git a/src/models/components/userdeleteresponse.ts b/src/models/components/userdeleteresponse.ts index e31a365..4a336cf 100644 --- a/src/models/components/userdeleteresponse.ts +++ b/src/models/components/userdeleteresponse.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const UserDeleteResponseObject = { OrganizationUserDeleted: "organization.user.deleted", @@ -80,3 +83,21 @@ export namespace UserDeleteResponse$ { /** @deprecated use `UserDeleteResponse$Outbound` instead. */ export type Outbound = UserDeleteResponse$Outbound; } + +export function userDeleteResponseToJSON( + userDeleteResponse: UserDeleteResponse, +): string { + return JSON.stringify( + UserDeleteResponse$outboundSchema.parse(userDeleteResponse), + ); +} + +export function userDeleteResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserDeleteResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserDeleteResponse' from JSON`, + ); +} diff --git a/src/models/components/userlistresponse.ts b/src/models/components/userlistresponse.ts index ff0c875..44f23ec 100644 --- a/src/models/components/userlistresponse.ts +++ b/src/models/components/userlistresponse.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { User, User$inboundSchema, @@ -105,3 +108,21 @@ export namespace UserListResponse$ { /** @deprecated use `UserListResponse$Outbound` instead. */ export type Outbound = UserListResponse$Outbound; } + +export function userListResponseToJSON( + userListResponse: UserListResponse, +): string { + return JSON.stringify( + UserListResponse$outboundSchema.parse(userListResponse), + ); +} + +export function userListResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserListResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserListResponse' from JSON`, + ); +} diff --git a/src/models/components/userroleupdaterequest.ts b/src/models/components/userroleupdaterequest.ts index a9e0151..e036cea 100644 --- a/src/models/components/userroleupdaterequest.ts +++ b/src/models/components/userroleupdaterequest.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * `owner` or `reader` @@ -82,3 +85,21 @@ export namespace UserRoleUpdateRequest$ { /** @deprecated use `UserRoleUpdateRequest$Outbound` instead. */ export type Outbound = UserRoleUpdateRequest$Outbound; } + +export function userRoleUpdateRequestToJSON( + userRoleUpdateRequest: UserRoleUpdateRequest, +): string { + return JSON.stringify( + UserRoleUpdateRequest$outboundSchema.parse(userRoleUpdateRequest), + ); +} + +export function userRoleUpdateRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => UserRoleUpdateRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'UserRoleUpdateRequest' from JSON`, + ); +} diff --git a/src/models/components/vectorstoreexpirationafter.ts b/src/models/components/vectorstoreexpirationafter.ts index 5866cf5..4588ad4 100644 --- a/src/models/components/vectorstoreexpirationafter.ts +++ b/src/models/components/vectorstoreexpirationafter.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Anchor timestamp after which the expiration policy applies. Supported anchors: `last_active_at`. @@ -87,3 +90,21 @@ export namespace VectorStoreExpirationAfter$ { /** @deprecated use `VectorStoreExpirationAfter$Outbound` instead. */ export type Outbound = VectorStoreExpirationAfter$Outbound; } + +export function vectorStoreExpirationAfterToJSON( + vectorStoreExpirationAfter: VectorStoreExpirationAfter, +): string { + return JSON.stringify( + VectorStoreExpirationAfter$outboundSchema.parse(vectorStoreExpirationAfter), + ); +} + +export function vectorStoreExpirationAfterFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreExpirationAfter$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreExpirationAfter' from JSON`, + ); +} diff --git a/src/models/components/vectorstorefilebatchobject.ts b/src/models/components/vectorstorefilebatchobject.ts index 33e1a40..eb4feb2 100644 --- a/src/models/components/vectorstorefilebatchobject.ts +++ b/src/models/components/vectorstorefilebatchobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The object type, which is always `vector_store.file_batch`. @@ -185,6 +188,27 @@ export namespace VectorStoreFileBatchObjectFileCounts$ { export type Outbound = VectorStoreFileBatchObjectFileCounts$Outbound; } +export function vectorStoreFileBatchObjectFileCountsToJSON( + vectorStoreFileBatchObjectFileCounts: VectorStoreFileBatchObjectFileCounts, +): string { + return JSON.stringify( + VectorStoreFileBatchObjectFileCounts$outboundSchema.parse( + vectorStoreFileBatchObjectFileCounts, + ), + ); +} + +export function vectorStoreFileBatchObjectFileCountsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + VectorStoreFileBatchObjectFileCounts$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreFileBatchObjectFileCounts' from JSON`, + ); +} + /** @internal */ export const VectorStoreFileBatchObject$inboundSchema: z.ZodType< VectorStoreFileBatchObject, @@ -247,3 +271,21 @@ export namespace VectorStoreFileBatchObject$ { /** @deprecated use `VectorStoreFileBatchObject$Outbound` instead. */ export type Outbound = VectorStoreFileBatchObject$Outbound; } + +export function vectorStoreFileBatchObjectToJSON( + vectorStoreFileBatchObject: VectorStoreFileBatchObject, +): string { + return JSON.stringify( + VectorStoreFileBatchObject$outboundSchema.parse(vectorStoreFileBatchObject), + ); +} + +export function vectorStoreFileBatchObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreFileBatchObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreFileBatchObject' from JSON`, + ); +} diff --git a/src/models/components/vectorstorefileobject.ts b/src/models/components/vectorstorefileobject.ts index b7a0b22..0bb91db 100644 --- a/src/models/components/vectorstorefileobject.ts +++ b/src/models/components/vectorstorefileobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { OtherChunkingStrategyResponseParam, OtherChunkingStrategyResponseParam$inboundSchema, @@ -226,6 +229,26 @@ export namespace VectorStoreFileObjectLastError$ { export type Outbound = VectorStoreFileObjectLastError$Outbound; } +export function vectorStoreFileObjectLastErrorToJSON( + vectorStoreFileObjectLastError: VectorStoreFileObjectLastError, +): string { + return JSON.stringify( + VectorStoreFileObjectLastError$outboundSchema.parse( + vectorStoreFileObjectLastError, + ), + ); +} + +export function vectorStoreFileObjectLastErrorFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreFileObjectLastError$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreFileObjectLastError' from JSON`, + ); +} + /** @internal */ export const VectorStoreFileObjectChunkingStrategy$inboundSchema: z.ZodType< VectorStoreFileObjectChunkingStrategy, @@ -266,6 +289,27 @@ export namespace VectorStoreFileObjectChunkingStrategy$ { export type Outbound = VectorStoreFileObjectChunkingStrategy$Outbound; } +export function vectorStoreFileObjectChunkingStrategyToJSON( + vectorStoreFileObjectChunkingStrategy: VectorStoreFileObjectChunkingStrategy, +): string { + return JSON.stringify( + VectorStoreFileObjectChunkingStrategy$outboundSchema.parse( + vectorStoreFileObjectChunkingStrategy, + ), + ); +} + +export function vectorStoreFileObjectChunkingStrategyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + VectorStoreFileObjectChunkingStrategy$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreFileObjectChunkingStrategy' from JSON`, + ); +} + /** @internal */ export const VectorStoreFileObject$inboundSchema: z.ZodType< VectorStoreFileObject, @@ -351,3 +395,21 @@ export namespace VectorStoreFileObject$ { /** @deprecated use `VectorStoreFileObject$Outbound` instead. */ export type Outbound = VectorStoreFileObject$Outbound; } + +export function vectorStoreFileObjectToJSON( + vectorStoreFileObject: VectorStoreFileObject, +): string { + return JSON.stringify( + VectorStoreFileObject$outboundSchema.parse(vectorStoreFileObject), + ); +} + +export function vectorStoreFileObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreFileObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreFileObject' from JSON`, + ); +} diff --git a/src/models/components/vectorstoreobject.ts b/src/models/components/vectorstoreobject.ts index 878c939..a8cca14 100644 --- a/src/models/components/vectorstoreobject.ts +++ b/src/models/components/vectorstoreobject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { VectorStoreExpirationAfter, VectorStoreExpirationAfter$inboundSchema, @@ -196,6 +199,20 @@ export namespace FileCounts$ { export type Outbound = FileCounts$Outbound; } +export function fileCountsToJSON(fileCounts: FileCounts): string { + return JSON.stringify(FileCounts$outboundSchema.parse(fileCounts)); +} + +export function fileCountsFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => FileCounts$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'FileCounts' from JSON`, + ); +} + /** @internal */ export const VectorStoreObjectStatus$inboundSchema: z.ZodNativeEnum< typeof VectorStoreObjectStatus @@ -247,6 +264,24 @@ export namespace VectorStoreObjectMetadata$ { export type Outbound = VectorStoreObjectMetadata$Outbound; } +export function vectorStoreObjectMetadataToJSON( + vectorStoreObjectMetadata: VectorStoreObjectMetadata, +): string { + return JSON.stringify( + VectorStoreObjectMetadata$outboundSchema.parse(vectorStoreObjectMetadata), + ); +} + +export function vectorStoreObjectMetadataFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreObjectMetadata$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreObjectMetadata' from JSON`, + ); +} + /** @internal */ export const VectorStoreObject$inboundSchema: z.ZodType< VectorStoreObject, @@ -330,3 +365,21 @@ export namespace VectorStoreObject$ { /** @deprecated use `VectorStoreObject$Outbound` instead. */ export type Outbound = VectorStoreObject$Outbound; } + +export function vectorStoreObjectToJSON( + vectorStoreObject: VectorStoreObject, +): string { + return JSON.stringify( + VectorStoreObject$outboundSchema.parse(vectorStoreObject), + ); +} + +export function vectorStoreObjectFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => VectorStoreObject$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'VectorStoreObject' from JSON`, + ); +} diff --git a/src/models/operations/adduploadpart.ts b/src/models/operations/adduploadpart.ts index dd686c6..fca73b2 100644 --- a/src/models/operations/adduploadpart.ts +++ b/src/models/operations/adduploadpart.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type AddUploadPartRequest = { /** @@ -64,3 +67,21 @@ export namespace AddUploadPartRequest$ { /** @deprecated use `AddUploadPartRequest$Outbound` instead. */ export type Outbound = AddUploadPartRequest$Outbound; } + +export function addUploadPartRequestToJSON( + addUploadPartRequest: AddUploadPartRequest, +): string { + return JSON.stringify( + AddUploadPartRequest$outboundSchema.parse(addUploadPartRequest), + ); +} + +export function addUploadPartRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => AddUploadPartRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'AddUploadPartRequest' from JSON`, + ); +} diff --git a/src/models/operations/archiveproject.ts b/src/models/operations/archiveproject.ts index 46dd9c9..e8a8a68 100644 --- a/src/models/operations/archiveproject.ts +++ b/src/models/operations/archiveproject.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ArchiveProjectRequest = { /** @@ -55,3 +58,21 @@ export namespace ArchiveProjectRequest$ { /** @deprecated use `ArchiveProjectRequest$Outbound` instead. */ export type Outbound = ArchiveProjectRequest$Outbound; } + +export function archiveProjectRequestToJSON( + archiveProjectRequest: ArchiveProjectRequest, +): string { + return JSON.stringify( + ArchiveProjectRequest$outboundSchema.parse(archiveProjectRequest), + ); +} + +export function archiveProjectRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ArchiveProjectRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ArchiveProjectRequest' from JSON`, + ); +} diff --git a/src/models/operations/cancelbatch.ts b/src/models/operations/cancelbatch.ts index 79034a2..18ee018 100644 --- a/src/models/operations/cancelbatch.ts +++ b/src/models/operations/cancelbatch.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CancelBatchRequest = { /** @@ -55,3 +58,21 @@ export namespace CancelBatchRequest$ { /** @deprecated use `CancelBatchRequest$Outbound` instead. */ export type Outbound = CancelBatchRequest$Outbound; } + +export function cancelBatchRequestToJSON( + cancelBatchRequest: CancelBatchRequest, +): string { + return JSON.stringify( + CancelBatchRequest$outboundSchema.parse(cancelBatchRequest), + ); +} + +export function cancelBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CancelBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CancelBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/cancelfinetuningjob.ts b/src/models/operations/cancelfinetuningjob.ts index a7528bf..d7bade4 100644 --- a/src/models/operations/cancelfinetuningjob.ts +++ b/src/models/operations/cancelfinetuningjob.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CancelFineTuningJobRequest = { /** @@ -57,3 +60,21 @@ export namespace CancelFineTuningJobRequest$ { /** @deprecated use `CancelFineTuningJobRequest$Outbound` instead. */ export type Outbound = CancelFineTuningJobRequest$Outbound; } + +export function cancelFineTuningJobRequestToJSON( + cancelFineTuningJobRequest: CancelFineTuningJobRequest, +): string { + return JSON.stringify( + CancelFineTuningJobRequest$outboundSchema.parse(cancelFineTuningJobRequest), + ); +} + +export function cancelFineTuningJobRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CancelFineTuningJobRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CancelFineTuningJobRequest' from JSON`, + ); +} diff --git a/src/models/operations/cancelrun.ts b/src/models/operations/cancelrun.ts index ba19089..9c463ae 100644 --- a/src/models/operations/cancelrun.ts +++ b/src/models/operations/cancelrun.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CancelRunRequest = { /** @@ -64,3 +67,21 @@ export namespace CancelRunRequest$ { /** @deprecated use `CancelRunRequest$Outbound` instead. */ export type Outbound = CancelRunRequest$Outbound; } + +export function cancelRunRequestToJSON( + cancelRunRequest: CancelRunRequest, +): string { + return JSON.stringify( + CancelRunRequest$outboundSchema.parse(cancelRunRequest), + ); +} + +export function cancelRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CancelRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CancelRunRequest' from JSON`, + ); +} diff --git a/src/models/operations/cancelupload.ts b/src/models/operations/cancelupload.ts index b6e958b..b4bc656 100644 --- a/src/models/operations/cancelupload.ts +++ b/src/models/operations/cancelupload.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CancelUploadRequest = { /** @@ -57,3 +60,21 @@ export namespace CancelUploadRequest$ { /** @deprecated use `CancelUploadRequest$Outbound` instead. */ export type Outbound = CancelUploadRequest$Outbound; } + +export function cancelUploadRequestToJSON( + cancelUploadRequest: CancelUploadRequest, +): string { + return JSON.stringify( + CancelUploadRequest$outboundSchema.parse(cancelUploadRequest), + ); +} + +export function cancelUploadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CancelUploadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CancelUploadRequest' from JSON`, + ); +} diff --git a/src/models/operations/cancelvectorstorefilebatch.ts b/src/models/operations/cancelvectorstorefilebatch.ts index ad050a1..76fd97f 100644 --- a/src/models/operations/cancelvectorstorefilebatch.ts +++ b/src/models/operations/cancelvectorstorefilebatch.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CancelVectorStoreFileBatchRequest = { /** @@ -65,3 +68,23 @@ export namespace CancelVectorStoreFileBatchRequest$ { /** @deprecated use `CancelVectorStoreFileBatchRequest$Outbound` instead. */ export type Outbound = CancelVectorStoreFileBatchRequest$Outbound; } + +export function cancelVectorStoreFileBatchRequestToJSON( + cancelVectorStoreFileBatchRequest: CancelVectorStoreFileBatchRequest, +): string { + return JSON.stringify( + CancelVectorStoreFileBatchRequest$outboundSchema.parse( + cancelVectorStoreFileBatchRequest, + ), + ); +} + +export function cancelVectorStoreFileBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CancelVectorStoreFileBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CancelVectorStoreFileBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/completeupload.ts b/src/models/operations/completeupload.ts index 54921fd..d7d7fb0 100644 --- a/src/models/operations/completeupload.ts +++ b/src/models/operations/completeupload.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CompleteUploadRequest = { /** @@ -64,3 +67,21 @@ export namespace CompleteUploadRequest$ { /** @deprecated use `CompleteUploadRequest$Outbound` instead. */ export type Outbound = CompleteUploadRequest$Outbound; } + +export function completeUploadRequestToJSON( + completeUploadRequest: CompleteUploadRequest, +): string { + return JSON.stringify( + CompleteUploadRequest$outboundSchema.parse(completeUploadRequest), + ); +} + +export function completeUploadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CompleteUploadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CompleteUploadRequest' from JSON`, + ); +} diff --git a/src/models/operations/createbatch.ts b/src/models/operations/createbatch.ts index 977cb86..5a6f9e2 100644 --- a/src/models/operations/createbatch.ts +++ b/src/models/operations/createbatch.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The endpoint to be used for all requests in the batch. Currently `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions` are supported. Note that `/v1/embeddings` batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch. @@ -149,3 +152,21 @@ export namespace CreateBatchRequestBody$ { /** @deprecated use `CreateBatchRequestBody$Outbound` instead. */ export type Outbound = CreateBatchRequestBody$Outbound; } + +export function createBatchRequestBodyToJSON( + createBatchRequestBody: CreateBatchRequestBody, +): string { + return JSON.stringify( + CreateBatchRequestBody$outboundSchema.parse(createBatchRequestBody), + ); +} + +export function createBatchRequestBodyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateBatchRequestBody$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateBatchRequestBody' from JSON`, + ); +} diff --git a/src/models/operations/createmessage.ts b/src/models/operations/createmessage.ts index 0d5580c..cf0807a 100644 --- a/src/models/operations/createmessage.ts +++ b/src/models/operations/createmessage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateMessageRequest = { /** @@ -62,3 +65,21 @@ export namespace CreateMessageRequest$ { /** @deprecated use `CreateMessageRequest$Outbound` instead. */ export type Outbound = CreateMessageRequest$Outbound; } + +export function createMessageRequestToJSON( + createMessageRequest: CreateMessageRequest, +): string { + return JSON.stringify( + CreateMessageRequest$outboundSchema.parse(createMessageRequest), + ); +} + +export function createMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateMessageRequest' from JSON`, + ); +} diff --git a/src/models/operations/createprojectserviceaccount.ts b/src/models/operations/createprojectserviceaccount.ts index 5831034..cb9d345 100644 --- a/src/models/operations/createprojectserviceaccount.ts +++ b/src/models/operations/createprojectserviceaccount.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateProjectServiceAccountRequest = { /** @@ -70,3 +73,24 @@ export namespace CreateProjectServiceAccountRequest$ { /** @deprecated use `CreateProjectServiceAccountRequest$Outbound` instead. */ export type Outbound = CreateProjectServiceAccountRequest$Outbound; } + +export function createProjectServiceAccountRequestToJSON( + createProjectServiceAccountRequest: CreateProjectServiceAccountRequest, +): string { + return JSON.stringify( + CreateProjectServiceAccountRequest$outboundSchema.parse( + createProjectServiceAccountRequest, + ), + ); +} + +export function createProjectServiceAccountRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + CreateProjectServiceAccountRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateProjectServiceAccountRequest' from JSON`, + ); +} diff --git a/src/models/operations/createprojectuser.ts b/src/models/operations/createprojectuser.ts index 59ef74a..e63665b 100644 --- a/src/models/operations/createprojectuser.ts +++ b/src/models/operations/createprojectuser.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateProjectUserRequest = { /** @@ -65,3 +68,21 @@ export namespace CreateProjectUserRequest$ { /** @deprecated use `CreateProjectUserRequest$Outbound` instead. */ export type Outbound = CreateProjectUserRequest$Outbound; } + +export function createProjectUserRequestToJSON( + createProjectUserRequest: CreateProjectUserRequest, +): string { + return JSON.stringify( + CreateProjectUserRequest$outboundSchema.parse(createProjectUserRequest), + ); +} + +export function createProjectUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateProjectUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateProjectUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/createrun.ts b/src/models/operations/createrun.ts index e43c41e..3f222f6 100644 --- a/src/models/operations/createrun.ts +++ b/src/models/operations/createrun.ts @@ -4,8 +4,11 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const Include = { StepDetailsToolCallsWildcardFileSearchResultsWildcardContent: @@ -101,3 +104,21 @@ export namespace CreateRunRequest$ { /** @deprecated use `CreateRunRequest$Outbound` instead. */ export type Outbound = CreateRunRequest$Outbound; } + +export function createRunRequestToJSON( + createRunRequest: CreateRunRequest, +): string { + return JSON.stringify( + CreateRunRequest$outboundSchema.parse(createRunRequest), + ); +} + +export function createRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateRunRequest' from JSON`, + ); +} diff --git a/src/models/operations/createspeech.ts b/src/models/operations/createspeech.ts index b9e4e0e..186eb31 100644 --- a/src/models/operations/createspeech.ts +++ b/src/models/operations/createspeech.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateSpeechResponse = { headers: { [k: string]: Array }; @@ -58,3 +61,21 @@ export namespace CreateSpeechResponse$ { /** @deprecated use `CreateSpeechResponse$Outbound` instead. */ export type Outbound = CreateSpeechResponse$Outbound; } + +export function createSpeechResponseToJSON( + createSpeechResponse: CreateSpeechResponse, +): string { + return JSON.stringify( + CreateSpeechResponse$outboundSchema.parse(createSpeechResponse), + ); +} + +export function createSpeechResponseFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateSpeechResponse$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateSpeechResponse' from JSON`, + ); +} diff --git a/src/models/operations/createtranscription.ts b/src/models/operations/createtranscription.ts index db00d25..545c758 100644 --- a/src/models/operations/createtranscription.ts +++ b/src/models/operations/createtranscription.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * OK @@ -49,3 +52,23 @@ export namespace CreateTranscriptionResponseBody$ { /** @deprecated use `CreateTranscriptionResponseBody$Outbound` instead. */ export type Outbound = CreateTranscriptionResponseBody$Outbound; } + +export function createTranscriptionResponseBodyToJSON( + createTranscriptionResponseBody: CreateTranscriptionResponseBody, +): string { + return JSON.stringify( + CreateTranscriptionResponseBody$outboundSchema.parse( + createTranscriptionResponseBody, + ), + ); +} + +export function createTranscriptionResponseBodyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranscriptionResponseBody$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranscriptionResponseBody' from JSON`, + ); +} diff --git a/src/models/operations/createtranslation.ts b/src/models/operations/createtranslation.ts index dbf18ce..58362ee 100644 --- a/src/models/operations/createtranslation.ts +++ b/src/models/operations/createtranslation.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * OK @@ -49,3 +52,23 @@ export namespace CreateTranslationResponseBody$ { /** @deprecated use `CreateTranslationResponseBody$Outbound` instead. */ export type Outbound = CreateTranslationResponseBody$Outbound; } + +export function createTranslationResponseBodyToJSON( + createTranslationResponseBody: CreateTranslationResponseBody, +): string { + return JSON.stringify( + CreateTranslationResponseBody$outboundSchema.parse( + createTranslationResponseBody, + ), + ); +} + +export function createTranslationResponseBodyFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateTranslationResponseBody$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateTranslationResponseBody' from JSON`, + ); +} diff --git a/src/models/operations/createvectorstorefile.ts b/src/models/operations/createvectorstorefile.ts index 753079a..4e421fa 100644 --- a/src/models/operations/createvectorstorefile.ts +++ b/src/models/operations/createvectorstorefile.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateVectorStoreFileRequest = { /** @@ -67,3 +70,23 @@ export namespace CreateVectorStoreFileRequest$ { /** @deprecated use `CreateVectorStoreFileRequest$Outbound` instead. */ export type Outbound = CreateVectorStoreFileRequest$Outbound; } + +export function createVectorStoreFileRequestToJSON( + createVectorStoreFileRequest: CreateVectorStoreFileRequest, +): string { + return JSON.stringify( + CreateVectorStoreFileRequest$outboundSchema.parse( + createVectorStoreFileRequest, + ), + ); +} + +export function createVectorStoreFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/createvectorstorefilebatch.ts b/src/models/operations/createvectorstorefilebatch.ts index ecfee6c..0d7b422 100644 --- a/src/models/operations/createvectorstorefilebatch.ts +++ b/src/models/operations/createvectorstorefilebatch.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type CreateVectorStoreFileBatchRequest = { /** @@ -69,3 +72,23 @@ export namespace CreateVectorStoreFileBatchRequest$ { /** @deprecated use `CreateVectorStoreFileBatchRequest$Outbound` instead. */ export type Outbound = CreateVectorStoreFileBatchRequest$Outbound; } + +export function createVectorStoreFileBatchRequestToJSON( + createVectorStoreFileBatchRequest: CreateVectorStoreFileBatchRequest, +): string { + return JSON.stringify( + CreateVectorStoreFileBatchRequest$outboundSchema.parse( + createVectorStoreFileBatchRequest, + ), + ); +} + +export function createVectorStoreFileBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => CreateVectorStoreFileBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'CreateVectorStoreFileBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteassistant.ts b/src/models/operations/deleteassistant.ts index 1f07e2a..26c47a5 100644 --- a/src/models/operations/deleteassistant.ts +++ b/src/models/operations/deleteassistant.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteAssistantRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteAssistantRequest$ { /** @deprecated use `DeleteAssistantRequest$Outbound` instead. */ export type Outbound = DeleteAssistantRequest$Outbound; } + +export function deleteAssistantRequestToJSON( + deleteAssistantRequest: DeleteAssistantRequest, +): string { + return JSON.stringify( + DeleteAssistantRequest$outboundSchema.parse(deleteAssistantRequest), + ); +} + +export function deleteAssistantRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteAssistantRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteAssistantRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletefile.ts b/src/models/operations/deletefile.ts index 28e63c5..966f516 100644 --- a/src/models/operations/deletefile.ts +++ b/src/models/operations/deletefile.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteFileRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteFileRequest$ { /** @deprecated use `DeleteFileRequest$Outbound` instead. */ export type Outbound = DeleteFileRequest$Outbound; } + +export function deleteFileRequestToJSON( + deleteFileRequest: DeleteFileRequest, +): string { + return JSON.stringify( + DeleteFileRequest$outboundSchema.parse(deleteFileRequest), + ); +} + +export function deleteFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteinvite.ts b/src/models/operations/deleteinvite.ts index 582a96c..37fa32c 100644 --- a/src/models/operations/deleteinvite.ts +++ b/src/models/operations/deleteinvite.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteInviteRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteInviteRequest$ { /** @deprecated use `DeleteInviteRequest$Outbound` instead. */ export type Outbound = DeleteInviteRequest$Outbound; } + +export function deleteInviteRequestToJSON( + deleteInviteRequest: DeleteInviteRequest, +): string { + return JSON.stringify( + DeleteInviteRequest$outboundSchema.parse(deleteInviteRequest), + ); +} + +export function deleteInviteRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteInviteRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteInviteRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletemessage.ts b/src/models/operations/deletemessage.ts index cf43889..aa3c7d0 100644 --- a/src/models/operations/deletemessage.ts +++ b/src/models/operations/deletemessage.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteMessageRequest = { /** @@ -64,3 +67,21 @@ export namespace DeleteMessageRequest$ { /** @deprecated use `DeleteMessageRequest$Outbound` instead. */ export type Outbound = DeleteMessageRequest$Outbound; } + +export function deleteMessageRequestToJSON( + deleteMessageRequest: DeleteMessageRequest, +): string { + return JSON.stringify( + DeleteMessageRequest$outboundSchema.parse(deleteMessageRequest), + ); +} + +export function deleteMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteMessageRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletemodel.ts b/src/models/operations/deletemodel.ts index 78f7e74..f25c7a5 100644 --- a/src/models/operations/deletemodel.ts +++ b/src/models/operations/deletemodel.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteModelRequest = { /** @@ -46,3 +49,21 @@ export namespace DeleteModelRequest$ { /** @deprecated use `DeleteModelRequest$Outbound` instead. */ export type Outbound = DeleteModelRequest$Outbound; } + +export function deleteModelRequestToJSON( + deleteModelRequest: DeleteModelRequest, +): string { + return JSON.stringify( + DeleteModelRequest$outboundSchema.parse(deleteModelRequest), + ); +} + +export function deleteModelRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteModelRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteModelRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteprojectapikey.ts b/src/models/operations/deleteprojectapikey.ts index c6f98db..e371e6e 100644 --- a/src/models/operations/deleteprojectapikey.ts +++ b/src/models/operations/deleteprojectapikey.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteProjectApiKeyRequest = { /** @@ -64,3 +67,21 @@ export namespace DeleteProjectApiKeyRequest$ { /** @deprecated use `DeleteProjectApiKeyRequest$Outbound` instead. */ export type Outbound = DeleteProjectApiKeyRequest$Outbound; } + +export function deleteProjectApiKeyRequestToJSON( + deleteProjectApiKeyRequest: DeleteProjectApiKeyRequest, +): string { + return JSON.stringify( + DeleteProjectApiKeyRequest$outboundSchema.parse(deleteProjectApiKeyRequest), + ); +} + +export function deleteProjectApiKeyRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteProjectApiKeyRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteProjectApiKeyRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteprojectserviceaccount.ts b/src/models/operations/deleteprojectserviceaccount.ts index 43454a4..e49b044 100644 --- a/src/models/operations/deleteprojectserviceaccount.ts +++ b/src/models/operations/deleteprojectserviceaccount.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteProjectServiceAccountRequest = { /** @@ -65,3 +68,24 @@ export namespace DeleteProjectServiceAccountRequest$ { /** @deprecated use `DeleteProjectServiceAccountRequest$Outbound` instead. */ export type Outbound = DeleteProjectServiceAccountRequest$Outbound; } + +export function deleteProjectServiceAccountRequestToJSON( + deleteProjectServiceAccountRequest: DeleteProjectServiceAccountRequest, +): string { + return JSON.stringify( + DeleteProjectServiceAccountRequest$outboundSchema.parse( + deleteProjectServiceAccountRequest, + ), + ); +} + +export function deleteProjectServiceAccountRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + DeleteProjectServiceAccountRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteProjectServiceAccountRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteprojectuser.ts b/src/models/operations/deleteprojectuser.ts index 9d78d36..019318a 100644 --- a/src/models/operations/deleteprojectuser.ts +++ b/src/models/operations/deleteprojectuser.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteProjectUserRequest = { /** @@ -64,3 +67,21 @@ export namespace DeleteProjectUserRequest$ { /** @deprecated use `DeleteProjectUserRequest$Outbound` instead. */ export type Outbound = DeleteProjectUserRequest$Outbound; } + +export function deleteProjectUserRequestToJSON( + deleteProjectUserRequest: DeleteProjectUserRequest, +): string { + return JSON.stringify( + DeleteProjectUserRequest$outboundSchema.parse(deleteProjectUserRequest), + ); +} + +export function deleteProjectUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteProjectUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteProjectUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletethread.ts b/src/models/operations/deletethread.ts index a623fbb..1c28748 100644 --- a/src/models/operations/deletethread.ts +++ b/src/models/operations/deletethread.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteThreadRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteThreadRequest$ { /** @deprecated use `DeleteThreadRequest$Outbound` instead. */ export type Outbound = DeleteThreadRequest$Outbound; } + +export function deleteThreadRequestToJSON( + deleteThreadRequest: DeleteThreadRequest, +): string { + return JSON.stringify( + DeleteThreadRequest$outboundSchema.parse(deleteThreadRequest), + ); +} + +export function deleteThreadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteThreadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteThreadRequest' from JSON`, + ); +} diff --git a/src/models/operations/deleteuser.ts b/src/models/operations/deleteuser.ts index 403f4da..dbd46fe 100644 --- a/src/models/operations/deleteuser.ts +++ b/src/models/operations/deleteuser.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteUserRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteUserRequest$ { /** @deprecated use `DeleteUserRequest$Outbound` instead. */ export type Outbound = DeleteUserRequest$Outbound; } + +export function deleteUserRequestToJSON( + deleteUserRequest: DeleteUserRequest, +): string { + return JSON.stringify( + DeleteUserRequest$outboundSchema.parse(deleteUserRequest), + ); +} + +export function deleteUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletevectorstore.ts b/src/models/operations/deletevectorstore.ts index c70eda9..891b2cc 100644 --- a/src/models/operations/deletevectorstore.ts +++ b/src/models/operations/deletevectorstore.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteVectorStoreRequest = { /** @@ -55,3 +58,21 @@ export namespace DeleteVectorStoreRequest$ { /** @deprecated use `DeleteVectorStoreRequest$Outbound` instead. */ export type Outbound = DeleteVectorStoreRequest$Outbound; } + +export function deleteVectorStoreRequestToJSON( + deleteVectorStoreRequest: DeleteVectorStoreRequest, +): string { + return JSON.stringify( + DeleteVectorStoreRequest$outboundSchema.parse(deleteVectorStoreRequest), + ); +} + +export function deleteVectorStoreRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteVectorStoreRequest' from JSON`, + ); +} diff --git a/src/models/operations/deletevectorstorefile.ts b/src/models/operations/deletevectorstorefile.ts index 324d8ef..74d5a19 100644 --- a/src/models/operations/deletevectorstorefile.ts +++ b/src/models/operations/deletevectorstorefile.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DeleteVectorStoreFileRequest = { /** @@ -64,3 +67,23 @@ export namespace DeleteVectorStoreFileRequest$ { /** @deprecated use `DeleteVectorStoreFileRequest$Outbound` instead. */ export type Outbound = DeleteVectorStoreFileRequest$Outbound; } + +export function deleteVectorStoreFileRequestToJSON( + deleteVectorStoreFileRequest: DeleteVectorStoreFileRequest, +): string { + return JSON.stringify( + DeleteVectorStoreFileRequest$outboundSchema.parse( + deleteVectorStoreFileRequest, + ), + ); +} + +export function deleteVectorStoreFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DeleteVectorStoreFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DeleteVectorStoreFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/downloadfile.ts b/src/models/operations/downloadfile.ts index 690f5df..926f7c7 100644 --- a/src/models/operations/downloadfile.ts +++ b/src/models/operations/downloadfile.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type DownloadFileRequest = { /** @@ -55,3 +58,21 @@ export namespace DownloadFileRequest$ { /** @deprecated use `DownloadFileRequest$Outbound` instead. */ export type Outbound = DownloadFileRequest$Outbound; } + +export function downloadFileRequestToJSON( + downloadFileRequest: DownloadFileRequest, +): string { + return JSON.stringify( + DownloadFileRequest$outboundSchema.parse(downloadFileRequest), + ); +} + +export function downloadFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => DownloadFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'DownloadFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/getassistant.ts b/src/models/operations/getassistant.ts index 9eb5d6d..771d76f 100644 --- a/src/models/operations/getassistant.ts +++ b/src/models/operations/getassistant.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetAssistantRequest = { /** @@ -55,3 +58,21 @@ export namespace GetAssistantRequest$ { /** @deprecated use `GetAssistantRequest$Outbound` instead. */ export type Outbound = GetAssistantRequest$Outbound; } + +export function getAssistantRequestToJSON( + getAssistantRequest: GetAssistantRequest, +): string { + return JSON.stringify( + GetAssistantRequest$outboundSchema.parse(getAssistantRequest), + ); +} + +export function getAssistantRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetAssistantRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetAssistantRequest' from JSON`, + ); +} diff --git a/src/models/operations/getmessage.ts b/src/models/operations/getmessage.ts index 13fb072..59a9947 100644 --- a/src/models/operations/getmessage.ts +++ b/src/models/operations/getmessage.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetMessageRequest = { /** @@ -64,3 +67,21 @@ export namespace GetMessageRequest$ { /** @deprecated use `GetMessageRequest$Outbound` instead. */ export type Outbound = GetMessageRequest$Outbound; } + +export function getMessageRequestToJSON( + getMessageRequest: GetMessageRequest, +): string { + return JSON.stringify( + GetMessageRequest$outboundSchema.parse(getMessageRequest), + ); +} + +export function getMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetMessageRequest' from JSON`, + ); +} diff --git a/src/models/operations/getrun.ts b/src/models/operations/getrun.ts index 7e2e700..60e9d5c 100644 --- a/src/models/operations/getrun.ts +++ b/src/models/operations/getrun.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetRunRequest = { /** @@ -64,3 +67,17 @@ export namespace GetRunRequest$ { /** @deprecated use `GetRunRequest$Outbound` instead. */ export type Outbound = GetRunRequest$Outbound; } + +export function getRunRequestToJSON(getRunRequest: GetRunRequest): string { + return JSON.stringify(GetRunRequest$outboundSchema.parse(getRunRequest)); +} + +export function getRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetRunRequest' from JSON`, + ); +} diff --git a/src/models/operations/getrunstep.ts b/src/models/operations/getrunstep.ts index ffe54b7..332ec8c 100644 --- a/src/models/operations/getrunstep.ts +++ b/src/models/operations/getrunstep.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export const GetRunStepQueryParamInclude = { StepDetailsToolCallsWildcardFileSearchResultsWildcardContent: @@ -116,3 +119,21 @@ export namespace GetRunStepRequest$ { /** @deprecated use `GetRunStepRequest$Outbound` instead. */ export type Outbound = GetRunStepRequest$Outbound; } + +export function getRunStepRequestToJSON( + getRunStepRequest: GetRunStepRequest, +): string { + return JSON.stringify( + GetRunStepRequest$outboundSchema.parse(getRunStepRequest), + ); +} + +export function getRunStepRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetRunStepRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetRunStepRequest' from JSON`, + ); +} diff --git a/src/models/operations/getthread.ts b/src/models/operations/getthread.ts index 70b87bc..50118ad 100644 --- a/src/models/operations/getthread.ts +++ b/src/models/operations/getthread.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetThreadRequest = { /** @@ -55,3 +58,21 @@ export namespace GetThreadRequest$ { /** @deprecated use `GetThreadRequest$Outbound` instead. */ export type Outbound = GetThreadRequest$Outbound; } + +export function getThreadRequestToJSON( + getThreadRequest: GetThreadRequest, +): string { + return JSON.stringify( + GetThreadRequest$outboundSchema.parse(getThreadRequest), + ); +} + +export function getThreadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetThreadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetThreadRequest' from JSON`, + ); +} diff --git a/src/models/operations/getvectorstore.ts b/src/models/operations/getvectorstore.ts index 4e13ca4..74894c1 100644 --- a/src/models/operations/getvectorstore.ts +++ b/src/models/operations/getvectorstore.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetVectorStoreRequest = { /** @@ -55,3 +58,21 @@ export namespace GetVectorStoreRequest$ { /** @deprecated use `GetVectorStoreRequest$Outbound` instead. */ export type Outbound = GetVectorStoreRequest$Outbound; } + +export function getVectorStoreRequestToJSON( + getVectorStoreRequest: GetVectorStoreRequest, +): string { + return JSON.stringify( + GetVectorStoreRequest$outboundSchema.parse(getVectorStoreRequest), + ); +} + +export function getVectorStoreRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetVectorStoreRequest' from JSON`, + ); +} diff --git a/src/models/operations/getvectorstorefile.ts b/src/models/operations/getvectorstorefile.ts index 9f34bc9..10cbd56 100644 --- a/src/models/operations/getvectorstorefile.ts +++ b/src/models/operations/getvectorstorefile.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetVectorStoreFileRequest = { /** @@ -64,3 +67,21 @@ export namespace GetVectorStoreFileRequest$ { /** @deprecated use `GetVectorStoreFileRequest$Outbound` instead. */ export type Outbound = GetVectorStoreFileRequest$Outbound; } + +export function getVectorStoreFileRequestToJSON( + getVectorStoreFileRequest: GetVectorStoreFileRequest, +): string { + return JSON.stringify( + GetVectorStoreFileRequest$outboundSchema.parse(getVectorStoreFileRequest), + ); +} + +export function getVectorStoreFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetVectorStoreFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetVectorStoreFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/getvectorstorefilebatch.ts b/src/models/operations/getvectorstorefilebatch.ts index 84ddc5f..4ea09fb 100644 --- a/src/models/operations/getvectorstorefilebatch.ts +++ b/src/models/operations/getvectorstorefilebatch.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type GetVectorStoreFileBatchRequest = { /** @@ -64,3 +67,23 @@ export namespace GetVectorStoreFileBatchRequest$ { /** @deprecated use `GetVectorStoreFileBatchRequest$Outbound` instead. */ export type Outbound = GetVectorStoreFileBatchRequest$Outbound; } + +export function getVectorStoreFileBatchRequestToJSON( + getVectorStoreFileBatchRequest: GetVectorStoreFileBatchRequest, +): string { + return JSON.stringify( + GetVectorStoreFileBatchRequest$outboundSchema.parse( + getVectorStoreFileBatchRequest, + ), + ); +} + +export function getVectorStoreFileBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => GetVectorStoreFileBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'GetVectorStoreFileBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/listassistants.ts b/src/models/operations/listassistants.ts index 997580e..612aebf 100644 --- a/src/models/operations/listassistants.ts +++ b/src/models/operations/listassistants.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -112,3 +115,21 @@ export namespace ListAssistantsRequest$ { /** @deprecated use `ListAssistantsRequest$Outbound` instead. */ export type Outbound = ListAssistantsRequest$Outbound; } + +export function listAssistantsRequestToJSON( + listAssistantsRequest: ListAssistantsRequest, +): string { + return JSON.stringify( + ListAssistantsRequest$outboundSchema.parse(listAssistantsRequest), + ); +} + +export function listAssistantsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListAssistantsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListAssistantsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listauditlogs.ts b/src/models/operations/listauditlogs.ts index d05f22b..ec4141d 100644 --- a/src/models/operations/listauditlogs.ts +++ b/src/models/operations/listauditlogs.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Return only events whose `effective_at` (Unix seconds) is in this range. @@ -118,6 +121,20 @@ export namespace EffectiveAt$ { export type Outbound = EffectiveAt$Outbound; } +export function effectiveAtToJSON(effectiveAt: EffectiveAt): string { + return JSON.stringify(EffectiveAt$outboundSchema.parse(effectiveAt)); +} + +export function effectiveAtFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => EffectiveAt$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'EffectiveAt' from JSON`, + ); +} + /** @internal */ export const ListAuditLogsRequest$inboundSchema: z.ZodType< ListAuditLogsRequest, @@ -196,3 +213,21 @@ export namespace ListAuditLogsRequest$ { /** @deprecated use `ListAuditLogsRequest$Outbound` instead. */ export type Outbound = ListAuditLogsRequest$Outbound; } + +export function listAuditLogsRequestToJSON( + listAuditLogsRequest: ListAuditLogsRequest, +): string { + return JSON.stringify( + ListAuditLogsRequest$outboundSchema.parse(listAuditLogsRequest), + ); +} + +export function listAuditLogsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListAuditLogsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListAuditLogsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listbatches.ts b/src/models/operations/listbatches.ts index 3dac495..1d067e7 100644 --- a/src/models/operations/listbatches.ts +++ b/src/models/operations/listbatches.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListBatchesRequest = { /** @@ -57,3 +60,21 @@ export namespace ListBatchesRequest$ { /** @deprecated use `ListBatchesRequest$Outbound` instead. */ export type Outbound = ListBatchesRequest$Outbound; } + +export function listBatchesRequestToJSON( + listBatchesRequest: ListBatchesRequest, +): string { + return JSON.stringify( + ListBatchesRequest$outboundSchema.parse(listBatchesRequest), + ); +} + +export function listBatchesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListBatchesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListBatchesRequest' from JSON`, + ); +} diff --git a/src/models/operations/listfiles.ts b/src/models/operations/listfiles.ts index 05c6f0a..f4310af 100644 --- a/src/models/operations/listfiles.ts +++ b/src/models/operations/listfiles.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListFilesRequest = { /** @@ -46,3 +49,21 @@ export namespace ListFilesRequest$ { /** @deprecated use `ListFilesRequest$Outbound` instead. */ export type Outbound = ListFilesRequest$Outbound; } + +export function listFilesRequestToJSON( + listFilesRequest: ListFilesRequest, +): string { + return JSON.stringify( + ListFilesRequest$outboundSchema.parse(listFilesRequest), + ); +} + +export function listFilesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListFilesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFilesRequest' from JSON`, + ); +} diff --git a/src/models/operations/listfilesinvectorstorebatch.ts b/src/models/operations/listfilesinvectorstorebatch.ts index 2ad7740..65beed6 100644 --- a/src/models/operations/listfilesinvectorstorebatch.ts +++ b/src/models/operations/listfilesinvectorstorebatch.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -189,3 +192,24 @@ export namespace ListFilesInVectorStoreBatchRequest$ { /** @deprecated use `ListFilesInVectorStoreBatchRequest$Outbound` instead. */ export type Outbound = ListFilesInVectorStoreBatchRequest$Outbound; } + +export function listFilesInVectorStoreBatchRequestToJSON( + listFilesInVectorStoreBatchRequest: ListFilesInVectorStoreBatchRequest, +): string { + return JSON.stringify( + ListFilesInVectorStoreBatchRequest$outboundSchema.parse( + listFilesInVectorStoreBatchRequest, + ), + ); +} + +export function listFilesInVectorStoreBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListFilesInVectorStoreBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFilesInVectorStoreBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/listfinetuningevents.ts b/src/models/operations/listfinetuningevents.ts index 0308cc5..705b111 100644 --- a/src/models/operations/listfinetuningevents.ts +++ b/src/models/operations/listfinetuningevents.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListFineTuningEventsRequest = { /** @@ -71,3 +74,23 @@ export namespace ListFineTuningEventsRequest$ { /** @deprecated use `ListFineTuningEventsRequest$Outbound` instead. */ export type Outbound = ListFineTuningEventsRequest$Outbound; } + +export function listFineTuningEventsRequestToJSON( + listFineTuningEventsRequest: ListFineTuningEventsRequest, +): string { + return JSON.stringify( + ListFineTuningEventsRequest$outboundSchema.parse( + listFineTuningEventsRequest, + ), + ); +} + +export function listFineTuningEventsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListFineTuningEventsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFineTuningEventsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listfinetuningjobcheckpoints.ts b/src/models/operations/listfinetuningjobcheckpoints.ts index 6749ca7..981dcad 100644 --- a/src/models/operations/listfinetuningjobcheckpoints.ts +++ b/src/models/operations/listfinetuningjobcheckpoints.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListFineTuningJobCheckpointsRequest = { /** @@ -73,3 +76,24 @@ export namespace ListFineTuningJobCheckpointsRequest$ { /** @deprecated use `ListFineTuningJobCheckpointsRequest$Outbound` instead. */ export type Outbound = ListFineTuningJobCheckpointsRequest$Outbound; } + +export function listFineTuningJobCheckpointsRequestToJSON( + listFineTuningJobCheckpointsRequest: ListFineTuningJobCheckpointsRequest, +): string { + return JSON.stringify( + ListFineTuningJobCheckpointsRequest$outboundSchema.parse( + listFineTuningJobCheckpointsRequest, + ), + ); +} + +export function listFineTuningJobCheckpointsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListFineTuningJobCheckpointsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListFineTuningJobCheckpointsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listinvites.ts b/src/models/operations/listinvites.ts index c4691c4..8ae9654 100644 --- a/src/models/operations/listinvites.ts +++ b/src/models/operations/listinvites.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListInvitesRequest = { /** @@ -57,3 +60,21 @@ export namespace ListInvitesRequest$ { /** @deprecated use `ListInvitesRequest$Outbound` instead. */ export type Outbound = ListInvitesRequest$Outbound; } + +export function listInvitesRequestToJSON( + listInvitesRequest: ListInvitesRequest, +): string { + return JSON.stringify( + ListInvitesRequest$outboundSchema.parse(listInvitesRequest), + ); +} + +export function listInvitesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListInvitesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListInvitesRequest' from JSON`, + ); +} diff --git a/src/models/operations/listmessages.ts b/src/models/operations/listmessages.ts index 8d34a1e..b7b5ae8 100644 --- a/src/models/operations/listmessages.ts +++ b/src/models/operations/listmessages.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -140,3 +143,21 @@ export namespace ListMessagesRequest$ { /** @deprecated use `ListMessagesRequest$Outbound` instead. */ export type Outbound = ListMessagesRequest$Outbound; } + +export function listMessagesRequestToJSON( + listMessagesRequest: ListMessagesRequest, +): string { + return JSON.stringify( + ListMessagesRequest$outboundSchema.parse(listMessagesRequest), + ); +} + +export function listMessagesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListMessagesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListMessagesRequest' from JSON`, + ); +} diff --git a/src/models/operations/listpaginatedfinetuningjobs.ts b/src/models/operations/listpaginatedfinetuningjobs.ts index 3d2f087..aea6d69 100644 --- a/src/models/operations/listpaginatedfinetuningjobs.ts +++ b/src/models/operations/listpaginatedfinetuningjobs.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListPaginatedFineTuningJobsRequest = { /** @@ -54,3 +57,24 @@ export namespace ListPaginatedFineTuningJobsRequest$ { /** @deprecated use `ListPaginatedFineTuningJobsRequest$Outbound` instead. */ export type Outbound = ListPaginatedFineTuningJobsRequest$Outbound; } + +export function listPaginatedFineTuningJobsRequestToJSON( + listPaginatedFineTuningJobsRequest: ListPaginatedFineTuningJobsRequest, +): string { + return JSON.stringify( + ListPaginatedFineTuningJobsRequest$outboundSchema.parse( + listPaginatedFineTuningJobsRequest, + ), + ); +} + +export function listPaginatedFineTuningJobsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + ListPaginatedFineTuningJobsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListPaginatedFineTuningJobsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listprojectapikeys.ts b/src/models/operations/listprojectapikeys.ts index 18ef5dc..c9b6ac1 100644 --- a/src/models/operations/listprojectapikeys.ts +++ b/src/models/operations/listprojectapikeys.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListProjectApiKeysRequest = { /** @@ -73,3 +76,21 @@ export namespace ListProjectApiKeysRequest$ { /** @deprecated use `ListProjectApiKeysRequest$Outbound` instead. */ export type Outbound = ListProjectApiKeysRequest$Outbound; } + +export function listProjectApiKeysRequestToJSON( + listProjectApiKeysRequest: ListProjectApiKeysRequest, +): string { + return JSON.stringify( + ListProjectApiKeysRequest$outboundSchema.parse(listProjectApiKeysRequest), + ); +} + +export function listProjectApiKeysRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListProjectApiKeysRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListProjectApiKeysRequest' from JSON`, + ); +} diff --git a/src/models/operations/listprojects.ts b/src/models/operations/listprojects.ts index dc6289e..7639d79 100644 --- a/src/models/operations/listprojects.ts +++ b/src/models/operations/listprojects.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListProjectsRequest = { /** @@ -73,3 +76,21 @@ export namespace ListProjectsRequest$ { /** @deprecated use `ListProjectsRequest$Outbound` instead. */ export type Outbound = ListProjectsRequest$Outbound; } + +export function listProjectsRequestToJSON( + listProjectsRequest: ListProjectsRequest, +): string { + return JSON.stringify( + ListProjectsRequest$outboundSchema.parse(listProjectsRequest), + ); +} + +export function listProjectsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListProjectsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListProjectsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listprojectserviceaccounts.ts b/src/models/operations/listprojectserviceaccounts.ts index 5a6fa17..1ffb15a 100644 --- a/src/models/operations/listprojectserviceaccounts.ts +++ b/src/models/operations/listprojectserviceaccounts.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListProjectServiceAccountsRequest = { /** @@ -74,3 +77,23 @@ export namespace ListProjectServiceAccountsRequest$ { /** @deprecated use `ListProjectServiceAccountsRequest$Outbound` instead. */ export type Outbound = ListProjectServiceAccountsRequest$Outbound; } + +export function listProjectServiceAccountsRequestToJSON( + listProjectServiceAccountsRequest: ListProjectServiceAccountsRequest, +): string { + return JSON.stringify( + ListProjectServiceAccountsRequest$outboundSchema.parse( + listProjectServiceAccountsRequest, + ), + ); +} + +export function listProjectServiceAccountsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListProjectServiceAccountsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListProjectServiceAccountsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listprojectusers.ts b/src/models/operations/listprojectusers.ts index 9174443..621ca4d 100644 --- a/src/models/operations/listprojectusers.ts +++ b/src/models/operations/listprojectusers.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListProjectUsersRequest = { /** @@ -73,3 +76,21 @@ export namespace ListProjectUsersRequest$ { /** @deprecated use `ListProjectUsersRequest$Outbound` instead. */ export type Outbound = ListProjectUsersRequest$Outbound; } + +export function listProjectUsersRequestToJSON( + listProjectUsersRequest: ListProjectUsersRequest, +): string { + return JSON.stringify( + ListProjectUsersRequest$outboundSchema.parse(listProjectUsersRequest), + ); +} + +export function listProjectUsersRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListProjectUsersRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListProjectUsersRequest' from JSON`, + ); +} diff --git a/src/models/operations/listruns.ts b/src/models/operations/listruns.ts index 6406327..d7e142b 100644 --- a/src/models/operations/listruns.ts +++ b/src/models/operations/listruns.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -131,3 +134,19 @@ export namespace ListRunsRequest$ { /** @deprecated use `ListRunsRequest$Outbound` instead. */ export type Outbound = ListRunsRequest$Outbound; } + +export function listRunsRequestToJSON( + listRunsRequest: ListRunsRequest, +): string { + return JSON.stringify(ListRunsRequest$outboundSchema.parse(listRunsRequest)); +} + +export function listRunsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListRunsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListRunsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listrunsteps.ts b/src/models/operations/listrunsteps.ts index 809ff44..8c18b8e 100644 --- a/src/models/operations/listrunsteps.ts +++ b/src/models/operations/listrunsteps.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -180,3 +183,21 @@ export namespace ListRunStepsRequest$ { /** @deprecated use `ListRunStepsRequest$Outbound` instead. */ export type Outbound = ListRunStepsRequest$Outbound; } + +export function listRunStepsRequestToJSON( + listRunStepsRequest: ListRunStepsRequest, +): string { + return JSON.stringify( + ListRunStepsRequest$outboundSchema.parse(listRunStepsRequest), + ); +} + +export function listRunStepsRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListRunStepsRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListRunStepsRequest' from JSON`, + ); +} diff --git a/src/models/operations/listusers.ts b/src/models/operations/listusers.ts index bf7f1dc..ffd922e 100644 --- a/src/models/operations/listusers.ts +++ b/src/models/operations/listusers.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ListUsersRequest = { /** @@ -57,3 +60,21 @@ export namespace ListUsersRequest$ { /** @deprecated use `ListUsersRequest$Outbound` instead. */ export type Outbound = ListUsersRequest$Outbound; } + +export function listUsersRequestToJSON( + listUsersRequest: ListUsersRequest, +): string { + return JSON.stringify( + ListUsersRequest$outboundSchema.parse(listUsersRequest), + ); +} + +export function listUsersRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListUsersRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListUsersRequest' from JSON`, + ); +} diff --git a/src/models/operations/listvectorstorefiles.ts b/src/models/operations/listvectorstorefiles.ts index 13562b5..5b54ce2 100644 --- a/src/models/operations/listvectorstorefiles.ts +++ b/src/models/operations/listvectorstorefiles.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -173,3 +176,23 @@ export namespace ListVectorStoreFilesRequest$ { /** @deprecated use `ListVectorStoreFilesRequest$Outbound` instead. */ export type Outbound = ListVectorStoreFilesRequest$Outbound; } + +export function listVectorStoreFilesRequestToJSON( + listVectorStoreFilesRequest: ListVectorStoreFilesRequest, +): string { + return JSON.stringify( + ListVectorStoreFilesRequest$outboundSchema.parse( + listVectorStoreFilesRequest, + ), + ); +} + +export function listVectorStoreFilesRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListVectorStoreFilesRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListVectorStoreFilesRequest' from JSON`, + ); +} diff --git a/src/models/operations/listvectorstores.ts b/src/models/operations/listvectorstores.ts index b55a2d1..a2e2925 100644 --- a/src/models/operations/listvectorstores.ts +++ b/src/models/operations/listvectorstores.ts @@ -3,7 +3,10 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and `desc` for descending order. @@ -115,3 +118,21 @@ export namespace ListVectorStoresRequest$ { /** @deprecated use `ListVectorStoresRequest$Outbound` instead. */ export type Outbound = ListVectorStoresRequest$Outbound; } + +export function listVectorStoresRequestToJSON( + listVectorStoresRequest: ListVectorStoresRequest, +): string { + return JSON.stringify( + ListVectorStoresRequest$outboundSchema.parse(listVectorStoresRequest), + ); +} + +export function listVectorStoresRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ListVectorStoresRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ListVectorStoresRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyassistant.ts b/src/models/operations/modifyassistant.ts index 28dba78..f83f83c 100644 --- a/src/models/operations/modifyassistant.ts +++ b/src/models/operations/modifyassistant.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyAssistantRequest = { /** @@ -62,3 +65,21 @@ export namespace ModifyAssistantRequest$ { /** @deprecated use `ModifyAssistantRequest$Outbound` instead. */ export type Outbound = ModifyAssistantRequest$Outbound; } + +export function modifyAssistantRequestToJSON( + modifyAssistantRequest: ModifyAssistantRequest, +): string { + return JSON.stringify( + ModifyAssistantRequest$outboundSchema.parse(modifyAssistantRequest), + ); +} + +export function modifyAssistantRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyAssistantRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyAssistantRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifymessage.ts b/src/models/operations/modifymessage.ts index 8a0041a..42c7190 100644 --- a/src/models/operations/modifymessage.ts +++ b/src/models/operations/modifymessage.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyMessageRequest = { /** @@ -71,3 +74,21 @@ export namespace ModifyMessageRequest$ { /** @deprecated use `ModifyMessageRequest$Outbound` instead. */ export type Outbound = ModifyMessageRequest$Outbound; } + +export function modifyMessageRequestToJSON( + modifyMessageRequest: ModifyMessageRequest, +): string { + return JSON.stringify( + ModifyMessageRequest$outboundSchema.parse(modifyMessageRequest), + ); +} + +export function modifyMessageRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyMessageRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyMessageRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyproject.ts b/src/models/operations/modifyproject.ts index 9508afc..25dfe27 100644 --- a/src/models/operations/modifyproject.ts +++ b/src/models/operations/modifyproject.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyProjectRequest = { /** @@ -65,3 +68,21 @@ export namespace ModifyProjectRequest$ { /** @deprecated use `ModifyProjectRequest$Outbound` instead. */ export type Outbound = ModifyProjectRequest$Outbound; } + +export function modifyProjectRequestToJSON( + modifyProjectRequest: ModifyProjectRequest, +): string { + return JSON.stringify( + ModifyProjectRequest$outboundSchema.parse(modifyProjectRequest), + ); +} + +export function modifyProjectRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyProjectRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyProjectRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyprojectuser.ts b/src/models/operations/modifyprojectuser.ts index 1eb5ac3..5e2c353 100644 --- a/src/models/operations/modifyprojectuser.ts +++ b/src/models/operations/modifyprojectuser.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyProjectUserRequest = { /** @@ -74,3 +77,21 @@ export namespace ModifyProjectUserRequest$ { /** @deprecated use `ModifyProjectUserRequest$Outbound` instead. */ export type Outbound = ModifyProjectUserRequest$Outbound; } + +export function modifyProjectUserRequestToJSON( + modifyProjectUserRequest: ModifyProjectUserRequest, +): string { + return JSON.stringify( + ModifyProjectUserRequest$outboundSchema.parse(modifyProjectUserRequest), + ); +} + +export function modifyProjectUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyProjectUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyProjectUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyrun.ts b/src/models/operations/modifyrun.ts index 10ee3c6..7d9ca09 100644 --- a/src/models/operations/modifyrun.ts +++ b/src/models/operations/modifyrun.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyRunRequest = { /** @@ -71,3 +74,21 @@ export namespace ModifyRunRequest$ { /** @deprecated use `ModifyRunRequest$Outbound` instead. */ export type Outbound = ModifyRunRequest$Outbound; } + +export function modifyRunRequestToJSON( + modifyRunRequest: ModifyRunRequest, +): string { + return JSON.stringify( + ModifyRunRequest$outboundSchema.parse(modifyRunRequest), + ); +} + +export function modifyRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyRunRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifythread.ts b/src/models/operations/modifythread.ts index ca789a2..bf54b0b 100644 --- a/src/models/operations/modifythread.ts +++ b/src/models/operations/modifythread.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyThreadRequest = { /** @@ -62,3 +65,21 @@ export namespace ModifyThreadRequest$ { /** @deprecated use `ModifyThreadRequest$Outbound` instead. */ export type Outbound = ModifyThreadRequest$Outbound; } + +export function modifyThreadRequestToJSON( + modifyThreadRequest: ModifyThreadRequest, +): string { + return JSON.stringify( + ModifyThreadRequest$outboundSchema.parse(modifyThreadRequest), + ); +} + +export function modifyThreadRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyThreadRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyThreadRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyuser.ts b/src/models/operations/modifyuser.ts index 41fe3bf..c584304 100644 --- a/src/models/operations/modifyuser.ts +++ b/src/models/operations/modifyuser.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyUserRequest = { /** @@ -65,3 +68,21 @@ export namespace ModifyUserRequest$ { /** @deprecated use `ModifyUserRequest$Outbound` instead. */ export type Outbound = ModifyUserRequest$Outbound; } + +export function modifyUserRequestToJSON( + modifyUserRequest: ModifyUserRequest, +): string { + return JSON.stringify( + ModifyUserRequest$outboundSchema.parse(modifyUserRequest), + ); +} + +export function modifyUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/modifyvectorstore.ts b/src/models/operations/modifyvectorstore.ts index 50ee484..382a098 100644 --- a/src/models/operations/modifyvectorstore.ts +++ b/src/models/operations/modifyvectorstore.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ModifyVectorStoreRequest = { /** @@ -62,3 +65,21 @@ export namespace ModifyVectorStoreRequest$ { /** @deprecated use `ModifyVectorStoreRequest$Outbound` instead. */ export type Outbound = ModifyVectorStoreRequest$Outbound; } + +export function modifyVectorStoreRequestToJSON( + modifyVectorStoreRequest: ModifyVectorStoreRequest, +): string { + return JSON.stringify( + ModifyVectorStoreRequest$outboundSchema.parse(modifyVectorStoreRequest), + ); +} + +export function modifyVectorStoreRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => ModifyVectorStoreRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'ModifyVectorStoreRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrievebatch.ts b/src/models/operations/retrievebatch.ts index 68492e3..6476f81 100644 --- a/src/models/operations/retrievebatch.ts +++ b/src/models/operations/retrievebatch.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveBatchRequest = { /** @@ -55,3 +58,21 @@ export namespace RetrieveBatchRequest$ { /** @deprecated use `RetrieveBatchRequest$Outbound` instead. */ export type Outbound = RetrieveBatchRequest$Outbound; } + +export function retrieveBatchRequestToJSON( + retrieveBatchRequest: RetrieveBatchRequest, +): string { + return JSON.stringify( + RetrieveBatchRequest$outboundSchema.parse(retrieveBatchRequest), + ); +} + +export function retrieveBatchRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveBatchRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveBatchRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrievefile.ts b/src/models/operations/retrievefile.ts index eac3dd6..2f19ed1 100644 --- a/src/models/operations/retrievefile.ts +++ b/src/models/operations/retrievefile.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveFileRequest = { /** @@ -55,3 +58,21 @@ export namespace RetrieveFileRequest$ { /** @deprecated use `RetrieveFileRequest$Outbound` instead. */ export type Outbound = RetrieveFileRequest$Outbound; } + +export function retrieveFileRequestToJSON( + retrieveFileRequest: RetrieveFileRequest, +): string { + return JSON.stringify( + RetrieveFileRequest$outboundSchema.parse(retrieveFileRequest), + ); +} + +export function retrieveFileRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveFileRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveFileRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrievefinetuningjob.ts b/src/models/operations/retrievefinetuningjob.ts index 88ac66f..e5d3312 100644 --- a/src/models/operations/retrievefinetuningjob.ts +++ b/src/models/operations/retrievefinetuningjob.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveFineTuningJobRequest = { /** @@ -57,3 +60,23 @@ export namespace RetrieveFineTuningJobRequest$ { /** @deprecated use `RetrieveFineTuningJobRequest$Outbound` instead. */ export type Outbound = RetrieveFineTuningJobRequest$Outbound; } + +export function retrieveFineTuningJobRequestToJSON( + retrieveFineTuningJobRequest: RetrieveFineTuningJobRequest, +): string { + return JSON.stringify( + RetrieveFineTuningJobRequest$outboundSchema.parse( + retrieveFineTuningJobRequest, + ), + ); +} + +export function retrieveFineTuningJobRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveFineTuningJobRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveFineTuningJobRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveinvite.ts b/src/models/operations/retrieveinvite.ts index a50fb46..088d5c2 100644 --- a/src/models/operations/retrieveinvite.ts +++ b/src/models/operations/retrieveinvite.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveInviteRequest = { /** @@ -55,3 +58,21 @@ export namespace RetrieveInviteRequest$ { /** @deprecated use `RetrieveInviteRequest$Outbound` instead. */ export type Outbound = RetrieveInviteRequest$Outbound; } + +export function retrieveInviteRequestToJSON( + retrieveInviteRequest: RetrieveInviteRequest, +): string { + return JSON.stringify( + RetrieveInviteRequest$outboundSchema.parse(retrieveInviteRequest), + ); +} + +export function retrieveInviteRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveInviteRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveInviteRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrievemodel.ts b/src/models/operations/retrievemodel.ts index dd62100..d22c882 100644 --- a/src/models/operations/retrievemodel.ts +++ b/src/models/operations/retrievemodel.ts @@ -3,6 +3,9 @@ */ import * as z from "zod"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveModelRequest = { /** @@ -46,3 +49,21 @@ export namespace RetrieveModelRequest$ { /** @deprecated use `RetrieveModelRequest$Outbound` instead. */ export type Outbound = RetrieveModelRequest$Outbound; } + +export function retrieveModelRequestToJSON( + retrieveModelRequest: RetrieveModelRequest, +): string { + return JSON.stringify( + RetrieveModelRequest$outboundSchema.parse(retrieveModelRequest), + ); +} + +export function retrieveModelRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveModelRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveModelRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveproject.ts b/src/models/operations/retrieveproject.ts index 5aec2ef..b4f8f4b 100644 --- a/src/models/operations/retrieveproject.ts +++ b/src/models/operations/retrieveproject.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveProjectRequest = { /** @@ -55,3 +58,21 @@ export namespace RetrieveProjectRequest$ { /** @deprecated use `RetrieveProjectRequest$Outbound` instead. */ export type Outbound = RetrieveProjectRequest$Outbound; } + +export function retrieveProjectRequestToJSON( + retrieveProjectRequest: RetrieveProjectRequest, +): string { + return JSON.stringify( + RetrieveProjectRequest$outboundSchema.parse(retrieveProjectRequest), + ); +} + +export function retrieveProjectRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveProjectRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveProjectRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveprojectapikey.ts b/src/models/operations/retrieveprojectapikey.ts index b2f12ac..b5a4088 100644 --- a/src/models/operations/retrieveprojectapikey.ts +++ b/src/models/operations/retrieveprojectapikey.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveProjectApiKeyRequest = { /** @@ -64,3 +67,23 @@ export namespace RetrieveProjectApiKeyRequest$ { /** @deprecated use `RetrieveProjectApiKeyRequest$Outbound` instead. */ export type Outbound = RetrieveProjectApiKeyRequest$Outbound; } + +export function retrieveProjectApiKeyRequestToJSON( + retrieveProjectApiKeyRequest: RetrieveProjectApiKeyRequest, +): string { + return JSON.stringify( + RetrieveProjectApiKeyRequest$outboundSchema.parse( + retrieveProjectApiKeyRequest, + ), + ); +} + +export function retrieveProjectApiKeyRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveProjectApiKeyRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveProjectApiKeyRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveprojectserviceaccount.ts b/src/models/operations/retrieveprojectserviceaccount.ts index 649cac4..0cde8cd 100644 --- a/src/models/operations/retrieveprojectserviceaccount.ts +++ b/src/models/operations/retrieveprojectserviceaccount.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveProjectServiceAccountRequest = { /** @@ -66,3 +69,24 @@ export namespace RetrieveProjectServiceAccountRequest$ { /** @deprecated use `RetrieveProjectServiceAccountRequest$Outbound` instead. */ export type Outbound = RetrieveProjectServiceAccountRequest$Outbound; } + +export function retrieveProjectServiceAccountRequestToJSON( + retrieveProjectServiceAccountRequest: RetrieveProjectServiceAccountRequest, +): string { + return JSON.stringify( + RetrieveProjectServiceAccountRequest$outboundSchema.parse( + retrieveProjectServiceAccountRequest, + ), + ); +} + +export function retrieveProjectServiceAccountRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => + RetrieveProjectServiceAccountRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveProjectServiceAccountRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveprojectuser.ts b/src/models/operations/retrieveprojectuser.ts index e5b3f82..1be6a68 100644 --- a/src/models/operations/retrieveprojectuser.ts +++ b/src/models/operations/retrieveprojectuser.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveProjectUserRequest = { /** @@ -64,3 +67,21 @@ export namespace RetrieveProjectUserRequest$ { /** @deprecated use `RetrieveProjectUserRequest$Outbound` instead. */ export type Outbound = RetrieveProjectUserRequest$Outbound; } + +export function retrieveProjectUserRequestToJSON( + retrieveProjectUserRequest: RetrieveProjectUserRequest, +): string { + return JSON.stringify( + RetrieveProjectUserRequest$outboundSchema.parse(retrieveProjectUserRequest), + ); +} + +export function retrieveProjectUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveProjectUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveProjectUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/retrieveuser.ts b/src/models/operations/retrieveuser.ts index 6fded1f..faf7f4c 100644 --- a/src/models/operations/retrieveuser.ts +++ b/src/models/operations/retrieveuser.ts @@ -4,6 +4,9 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type RetrieveUserRequest = { /** @@ -55,3 +58,21 @@ export namespace RetrieveUserRequest$ { /** @deprecated use `RetrieveUserRequest$Outbound` instead. */ export type Outbound = RetrieveUserRequest$Outbound; } + +export function retrieveUserRequestToJSON( + retrieveUserRequest: RetrieveUserRequest, +): string { + return JSON.stringify( + RetrieveUserRequest$outboundSchema.parse(retrieveUserRequest), + ); +} + +export function retrieveUserRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => RetrieveUserRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'RetrieveUserRequest' from JSON`, + ); +} diff --git a/src/models/operations/submittoolouputstorun.ts b/src/models/operations/submittoolouputstorun.ts index ab67988..36f5063 100644 --- a/src/models/operations/submittoolouputstorun.ts +++ b/src/models/operations/submittoolouputstorun.ts @@ -4,7 +4,10 @@ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; +import { safeParse } from "../../lib/schemas.js"; +import { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; +import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type SubmitToolOuputsToRunRequest = { /** @@ -73,3 +76,23 @@ export namespace SubmitToolOuputsToRunRequest$ { /** @deprecated use `SubmitToolOuputsToRunRequest$Outbound` instead. */ export type Outbound = SubmitToolOuputsToRunRequest$Outbound; } + +export function submitToolOuputsToRunRequestToJSON( + submitToolOuputsToRunRequest: SubmitToolOuputsToRunRequest, +): string { + return JSON.stringify( + SubmitToolOuputsToRunRequest$outboundSchema.parse( + submitToolOuputsToRunRequest, + ), + ); +} + +export function submitToolOuputsToRunRequestFromJSON( + jsonString: string, +): SafeParseResult { + return safeParse( + jsonString, + (x) => SubmitToolOuputsToRunRequest$inboundSchema.parse(JSON.parse(x)), + `Failed to parse 'SubmitToolOuputsToRunRequest' from JSON`, + ); +} diff --git a/src/types/operations.ts b/src/types/operations.ts index 0952f6f..beb81e1 100644 --- a/src/types/operations.ts +++ b/src/types/operations.ts @@ -6,9 +6,10 @@ import { Result } from "./fp.js"; export type Paginator = () => Promise }> | null; -export type PageIterator = V & { +export type PageIterator = V & { next: Paginator; [Symbol.asyncIterator]: () => AsyncIterableIterator; + "~next"?: PageState | undefined; }; export function createPageIterator( @@ -40,7 +41,9 @@ export function createPageIterator( * terminates. It is useful in paginated SDK functions that have early return * paths when things go wrong. */ -export function haltIterator(v: V): PageIterator { +export function haltIterator( + v: V, +): PageIterator { return { ...v, next: () => null, @@ -54,9 +57,9 @@ export function haltIterator(v: V): PageIterator { * Converts an async iterator of `Result` into an async iterator of `V`. * When error results occur, the underlying error value is thrown. */ -export async function unwrapResultIterator( - iteratorPromise: Promise>>, -): Promise> { +export async function unwrapResultIterator( + iteratorPromise: Promise, PageState>>, +): Promise> { const resultIter = await iteratorPromise; if (!resultIter.ok) { @@ -66,6 +69,7 @@ export async function unwrapResultIterator( return { ...resultIter.value, next: unwrapPaginator(resultIter.next), + "~next": resultIter["~next"], [Symbol.asyncIterator]: async function* paginator() { for await (const page of resultIter) { if (!page.ok) { @@ -97,3 +101,5 @@ function unwrapPaginator( }); }; } + +export const URL_OVERRIDE = Symbol("URL_OVERRIDE"); diff --git a/tsconfig.json b/tsconfig.json index 7a86d2d..94d81a3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,8 +2,9 @@ "compilerOptions": { "incremental": true, "tsBuildInfoFile": ".tsbuildinfo", - "target": "ES2018", + "target": "ES2020", "lib": ["ES2022", "DOM", "DOM.Iterable"], + "jsx": "react-jsx", "module": "Node16", "moduleResolution": "Node16",