diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index a67d3df..f3472d3 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 81b65c50-f2e3-40a3-bd65-346524007b3d management: - docChecksum: ee15d853ecc28d415d6b33191893a6ff + docChecksum: 87f5a2bcfbc64bec79241e2b0de25b9f docVersion: 0.0.2 - speakeasyVersion: 1.434.4 - generationVersion: 2.452.0 - releaseVersion: 1.3.0 - configChecksum: d6bf2d23bd8b094865db557c870ba6fc + speakeasyVersion: 1.438.1 + generationVersion: 2.457.2 + releaseVersion: 1.3.1 + configChecksum: 592c371e12e0bb88cff133b730e6b426 repoURL: https://github.com/mistralai/client-ts.git installationURL: https://github.com/mistralai/client-ts published: true diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index f45462b..7e03a61 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -16,7 +16,7 @@ generation: oAuth2ClientCredentialsEnabled: true oAuth2PasswordEnabled: false typescript: - version: 1.3.0 + version: 1.3.1 additionalDependencies: dependencies: {} devDependencies: {} @@ -24,6 +24,7 @@ typescript: additionalPackageJSON: {} author: Speakeasy clientServerStatusCodesAsErrors: true + defaultErrorName: SDKError enumFormat: union envVarPrefix: MISTRAL flattenGlobalSecurity: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 5919fab..f8424c9 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -16,8 +16,8 @@ sources: - main mistral-openapi: sourceNamespace: mistral-openapi - sourceRevisionDigest: sha256:e658442ebfc83351cbb7873fb17b03f07ff9edebd8eddfce5577e2c5c7bfafce - sourceBlobDigest: sha256:559403eaaa97c021eaf0022adddb1066694d879a946c87057e942806d5a2a2a2 + sourceRevisionDigest: sha256:e44702b93f6a8ac450f1d85b4197f6640f8efb3d5e06be98418ea79acd8f70be + sourceBlobDigest: sha256:94a9891a3bdf3fafea5c41cee226c5e366c206e91e39e734cd2d1163af74f688 tags: - latest - main @@ -39,10 +39,10 @@ targets: mistralai-sdk: source: mistral-openapi sourceNamespace: mistral-openapi - sourceRevisionDigest: sha256:e658442ebfc83351cbb7873fb17b03f07ff9edebd8eddfce5577e2c5c7bfafce - sourceBlobDigest: sha256:559403eaaa97c021eaf0022adddb1066694d879a946c87057e942806d5a2a2a2 + sourceRevisionDigest: sha256:e44702b93f6a8ac450f1d85b4197f6640f8efb3d5e06be98418ea79acd8f70be + sourceBlobDigest: sha256:94a9891a3bdf3fafea5c41cee226c5e366c206e91e39e734cd2d1163af74f688 codeSamplesNamespace: mistral-openapi-code-samples - codeSamplesRevisionDigest: sha256:040e9e9020d7edd595d15e2879b2bc64e21dc00bea1952375373fef9e132f2fe + codeSamplesRevisionDigest: sha256:e11c906b44a1097fb47e0ced237d00da922a4a69c0a86283f18d391814915d42 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index e3d48ea..4f90f5e 100644 --- a/README.md +++ b/README.md @@ -436,10 +436,10 @@ If a HTTP request fails, an operation my also throw an error from the `models/er 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 `list` method may throw the following errors: -| Error Type | Status Code | Content Type | -| -------------------------- | -------------------------- | -------------------------- | -| errors.HTTPValidationError | 422 | application/json | -| errors.SDKError | 4XX, 5XX | \*/\* | +| Error Type | Status Code | Content Type | +| -------------------------- | ----------- | ---------------- | +| errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | ```typescript import { Mistral } from "@mistralai/mistralai"; @@ -492,11 +492,13 @@ Validation errors can also occur when either method arguments or data returned f ### Select Server by Name -You can override the default server globally by passing a server name to the `server` 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 names associated with the available servers: +You can override the default server globally by passing a server name to the `server: keyof typeof ServerList` 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 names associated with the available servers: -| Name | Server | Variables | -| ----- | ------ | --------- | -| `eu` | `https://api.mistral.ai` | None | +| Name | Server | +| ---- | ------------------------ | +| `eu` | `https://api.mistral.ai` | + +#### Example ```typescript import { Mistral } from "@mistralai/mistralai"; @@ -517,11 +519,9 @@ 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 { Mistral } from "@mistralai/mistralai"; @@ -598,9 +598,9 @@ const sdk = new Mistral({ httpClient }); This SDK supports the following security scheme globally: -| Name | Type | Scheme | Environment Variable | -| -------------------- | -------------------- | -------------------- | -------------------- | -| `apiKey` | http | HTTP Bearer | `MISTRAL_API_KEY` | +| Name | Type | Scheme | Environment Variable | +| -------- | ---- | ----------- | -------------------- | +| `apiKey` | http | HTTP Bearer | `MISTRAL_API_KEY` | To authenticate with the API the `apiKey` parameter must be set when initializing the SDK client instance. For example: ```typescript diff --git a/RELEASES.md b/RELEASES.md index c885ee9..bd467ef 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -78,4 +78,14 @@ Based on: ### Generated - [typescript v1.3.0] . ### Releases -- [NPM v1.3.0] https://www.npmjs.com/package/@mistralai/mistralai/v/1.3.0 - . \ No newline at end of file +- [NPM v1.3.0] https://www.npmjs.com/package/@mistralai/mistralai/v/1.3.0 - . + +## 2024-11-12 18:04:57 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.438.1 (2.457.2) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v1.3.1] . +### Releases +- [NPM v1.3.1] https://www.npmjs.com/package/@mistralai/mistralai/v/1.3.1 - . \ No newline at end of file diff --git a/jsr.json b/jsr.json index beacbda..8e1aa83 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@mistralai/mistralai", - "version": "1.3.0", + "version": "1.3.1", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index b1efd57..26750f5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@mistralai/mistralai", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@mistralai/mistralai", - "version": "1.3.0", + "version": "1.3.1", "devDependencies": { "@typescript-eslint/eslint-plugin": "^7.7.1", "@typescript-eslint/parser": "^7.7.1", diff --git a/package.json b/package.json index 12b1bfe..309bb4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mistralai/mistralai", - "version": "1.3.0", + "version": "1.3.1", "author": "Speakeasy", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/agentsComplete.ts b/src/funcs/agentsComplete.ts index c507efa..d2f25db 100644 --- a/src/funcs/agentsComplete.ts +++ b/src/funcs/agentsComplete.ts @@ -67,6 +67,9 @@ export async function agentsComplete( const context = { operationID: "agents_completion_v1_agents_completions_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/agentsStream.ts b/src/funcs/agentsStream.ts index 57d1de9..ca36503 100644 --- a/src/funcs/agentsStream.ts +++ b/src/funcs/agentsStream.ts @@ -73,6 +73,9 @@ export async function agentsStream( const context = { operationID: "stream_agents", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/batchJobsCancel.ts b/src/funcs/batchJobsCancel.ts index 46b614e..ff6bc74 100644 --- a/src/funcs/batchJobsCancel.ts +++ b/src/funcs/batchJobsCancel.ts @@ -78,6 +78,9 @@ export async function batchJobsCancel( const context = { operationID: "jobs_api_routes_batch_cancel_batch_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/batchJobsCreate.ts b/src/funcs/batchJobsCreate.ts index d7e095c..022c58b 100644 --- a/src/funcs/batchJobsCreate.ts +++ b/src/funcs/batchJobsCreate.ts @@ -68,6 +68,9 @@ export async function batchJobsCreate( const context = { operationID: "jobs_api_routes_batch_create_batch_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/batchJobsGet.ts b/src/funcs/batchJobsGet.ts index b991839..d13a0dd 100644 --- a/src/funcs/batchJobsGet.ts +++ b/src/funcs/batchJobsGet.ts @@ -78,6 +78,9 @@ export async function batchJobsGet( const context = { operationID: "jobs_api_routes_batch_get_batch_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/batchJobsList.ts b/src/funcs/batchJobsList.ts index bba9ee7..af3f684 100644 --- a/src/funcs/batchJobsList.ts +++ b/src/funcs/batchJobsList.ts @@ -80,6 +80,9 @@ export async function batchJobsList( const context = { operationID: "jobs_api_routes_batch_get_batch_jobs", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/chatComplete.ts b/src/funcs/chatComplete.ts index f53edd5..5a8ae29 100644 --- a/src/funcs/chatComplete.ts +++ b/src/funcs/chatComplete.ts @@ -67,6 +67,9 @@ export async function chatComplete( const context = { operationID: "chat_completion_v1_chat_completions_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/chatStream.ts b/src/funcs/chatStream.ts index 189dd95..aba2226 100644 --- a/src/funcs/chatStream.ts +++ b/src/funcs/chatStream.ts @@ -73,6 +73,9 @@ export async function chatStream( const context = { operationID: "stream_chat", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/classifiersModerate.ts b/src/funcs/classifiersModerate.ts index 9689a71..47f1fbe 100644 --- a/src/funcs/classifiersModerate.ts +++ b/src/funcs/classifiersModerate.ts @@ -67,6 +67,9 @@ export async function classifiersModerate( const context = { operationID: "moderations_v1_moderations_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/classifiersModerateChat.ts b/src/funcs/classifiersModerateChat.ts index 96825e3..9579014 100644 --- a/src/funcs/classifiersModerateChat.ts +++ b/src/funcs/classifiersModerateChat.ts @@ -67,6 +67,9 @@ export async function classifiersModerateChat( const context = { operationID: "moderations_chat_v1_chat_moderations_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/embeddingsCreate.ts b/src/funcs/embeddingsCreate.ts index bf78a8d..ca98879 100644 --- a/src/funcs/embeddingsCreate.ts +++ b/src/funcs/embeddingsCreate.ts @@ -70,6 +70,9 @@ export async function embeddingsCreate( const context = { operationID: "embeddings_v1_embeddings_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/filesDelete.ts b/src/funcs/filesDelete.ts index 68ab651..39e274e 100644 --- a/src/funcs/filesDelete.ts +++ b/src/funcs/filesDelete.ts @@ -76,6 +76,9 @@ export async function filesDelete( const context = { operationID: "files_api_routes_delete_file", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/filesDownload.ts b/src/funcs/filesDownload.ts index 72a3a26..43e9981 100644 --- a/src/funcs/filesDownload.ts +++ b/src/funcs/filesDownload.ts @@ -76,6 +76,9 @@ export async function filesDownload( const context = { operationID: "files_api_routes_download_file", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/filesList.ts b/src/funcs/filesList.ts index dc3634f..835717a 100644 --- a/src/funcs/filesList.ts +++ b/src/funcs/filesList.ts @@ -80,6 +80,9 @@ export async function filesList( const context = { operationID: "files_api_routes_list_files", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/filesRetrieve.ts b/src/funcs/filesRetrieve.ts index 02a2f7e..271f408 100644 --- a/src/funcs/filesRetrieve.ts +++ b/src/funcs/filesRetrieve.ts @@ -76,6 +76,9 @@ export async function filesRetrieve( const context = { operationID: "files_api_routes_retrieve_file", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/filesUpload.ts b/src/funcs/filesUpload.ts index 778fda5..e523c49 100644 --- a/src/funcs/filesUpload.ts +++ b/src/funcs/filesUpload.ts @@ -93,6 +93,9 @@ export async function filesUpload( const context = { operationID: "files_api_routes_upload_file", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fimComplete.ts b/src/funcs/fimComplete.ts index df81766..dac6060 100644 --- a/src/funcs/fimComplete.ts +++ b/src/funcs/fimComplete.ts @@ -70,6 +70,9 @@ export async function fimComplete( const context = { operationID: "fim_completion_v1_fim_completions_post", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fimStream.ts b/src/funcs/fimStream.ts index 7f3abc0..5e33d96 100644 --- a/src/funcs/fimStream.ts +++ b/src/funcs/fimStream.ts @@ -73,6 +73,9 @@ export async function fimStream( const context = { operationID: "stream_fim", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fineTuningJobsCancel.ts b/src/funcs/fineTuningJobsCancel.ts index 272d0c7..8efcfc0 100644 --- a/src/funcs/fineTuningJobsCancel.ts +++ b/src/funcs/fineTuningJobsCancel.ts @@ -79,6 +79,9 @@ export async function fineTuningJobsCancel( const context = { operationID: "jobs_api_routes_fine_tuning_cancel_fine_tuning_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fineTuningJobsCreate.ts b/src/funcs/fineTuningJobsCreate.ts index b97985a..a4041d2 100644 --- a/src/funcs/fineTuningJobsCreate.ts +++ b/src/funcs/fineTuningJobsCreate.ts @@ -69,6 +69,9 @@ export async function fineTuningJobsCreate( const context = { operationID: "jobs_api_routes_fine_tuning_create_fine_tuning_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fineTuningJobsGet.ts b/src/funcs/fineTuningJobsGet.ts index e400831..8811985 100644 --- a/src/funcs/fineTuningJobsGet.ts +++ b/src/funcs/fineTuningJobsGet.ts @@ -77,6 +77,9 @@ export async function fineTuningJobsGet( const context = { operationID: "jobs_api_routes_fine_tuning_get_fine_tuning_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fineTuningJobsList.ts b/src/funcs/fineTuningJobsList.ts index f122e35..3b82296 100644 --- a/src/funcs/fineTuningJobsList.ts +++ b/src/funcs/fineTuningJobsList.ts @@ -84,6 +84,9 @@ export async function fineTuningJobsList( const context = { operationID: "jobs_api_routes_fine_tuning_get_fine_tuning_jobs", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/fineTuningJobsStart.ts b/src/funcs/fineTuningJobsStart.ts index fb96200..808c3ac 100644 --- a/src/funcs/fineTuningJobsStart.ts +++ b/src/funcs/fineTuningJobsStart.ts @@ -77,6 +77,9 @@ export async function fineTuningJobsStart( const context = { operationID: "jobs_api_routes_fine_tuning_start_fine_tuning_job", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsArchive.ts b/src/funcs/modelsArchive.ts index a28c820..86dd19f 100644 --- a/src/funcs/modelsArchive.ts +++ b/src/funcs/modelsArchive.ts @@ -80,6 +80,9 @@ export async function modelsArchive( const context = { operationID: "jobs_api_routes_fine_tuning_archive_fine_tuned_model", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsDelete.ts b/src/funcs/modelsDelete.ts index 65b1b86..3cbd9bb 100644 --- a/src/funcs/modelsDelete.ts +++ b/src/funcs/modelsDelete.ts @@ -80,6 +80,9 @@ export async function modelsDelete( const context = { operationID: "delete_model_v1_models__model_id__delete", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsList.ts b/src/funcs/modelsList.ts index 3dfa0dd..8fb945a 100644 --- a/src/funcs/modelsList.ts +++ b/src/funcs/modelsList.ts @@ -55,6 +55,9 @@ export async function modelsList( const context = { operationID: "list_models_v1_models_get", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsRetrieve.ts b/src/funcs/modelsRetrieve.ts index c96c7b1..2608625 100644 --- a/src/funcs/modelsRetrieve.ts +++ b/src/funcs/modelsRetrieve.ts @@ -79,6 +79,9 @@ export async function modelsRetrieve( const context = { operationID: "retrieve_model_v1_models__model_id__get", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsUnarchive.ts b/src/funcs/modelsUnarchive.ts index 9631e3a..52ef889 100644 --- a/src/funcs/modelsUnarchive.ts +++ b/src/funcs/modelsUnarchive.ts @@ -80,6 +80,9 @@ export async function modelsUnarchive( const context = { operationID: "jobs_api_routes_fine_tuning_unarchive_fine_tuned_model", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/funcs/modelsUpdate.ts b/src/funcs/modelsUpdate.ts index b22f6cc..c45c3b4 100644 --- a/src/funcs/modelsUpdate.ts +++ b/src/funcs/modelsUpdate.ts @@ -79,6 +79,9 @@ export async function modelsUpdate( const context = { operationID: "jobs_api_routes_fine_tuning_update_fine_tuned_model", oAuth2Scopes: [], + + resolvedSecurity: requestSecurity, + securitySource: client._options.apiKey, retryConfig: options?.retries || client._options.retryConfig diff --git a/src/hooks/types.ts b/src/hooks/types.ts index 4079cc9..df5237d 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -4,12 +4,14 @@ 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; diff --git a/src/lib/config.ts b/src/lib/config.ts index 781345c..9783ac3 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -55,8 +55,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.2", - sdkVersion: "1.3.0", - genVersion: "2.452.0", + sdkVersion: "1.3.1", + genVersion: "2.457.2", userAgent: - "speakeasy-sdk/typescript 1.3.0 2.452.0 0.0.2 @mistralai/mistralai", + "speakeasy-sdk/typescript 1.3.1 2.457.2 0.0.2 @mistralai/mistralai", } as const; diff --git a/src/lib/env.ts b/src/lib/env.ts index 70d8b3b..384b519 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({ - MISTRAL_API_KEY: z.string(), + MISTRAL_API_KEY: z.string().optional(), - MISTRAL_DEBUG: z.coerce.boolean(), -}) - .partial(); + MISTRAL_DEBUG: z.coerce.boolean().optional(), +}); let envMemo: Env | undefined = undefined; /** diff --git a/src/lib/primitives.ts b/src/lib/primitives.ts index 23794a2..48b2867 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] diff --git a/src/lib/security.ts b/src/lib/security.ts index 384b2e0..cd9a17b 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; @@ -101,6 +122,7 @@ export function resolveSecurity( 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/agentscompletionrequest.ts b/src/models/components/agentscompletionrequest.ts index 4c47a49..927117c 100644 --- a/src/models/components/agentscompletionrequest.ts +++ b/src/models/components/agentscompletionrequest.ts @@ -281,8 +281,8 @@ export const AgentsCompletionRequest$inboundSchema: z.ZodType< tools: z.nullable(z.array(Tool$inboundSchema)).optional(), tool_choice: z.union([ToolChoice$inboundSchema, ToolChoiceEnum$inboundSchema]) .optional(), - presence_penalty: z.number().default(0), - frequency_penalty: z.number().default(0), + presence_penalty: z.number().optional(), + frequency_penalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), agent_id: z.string(), }).transform((v) => { @@ -312,8 +312,8 @@ export type AgentsCompletionRequest$Outbound = { response_format?: ResponseFormat$Outbound | undefined; tools?: Array | null | undefined; tool_choice?: ToolChoice$Outbound | string | undefined; - presence_penalty: number; - frequency_penalty: number; + presence_penalty?: number | undefined; + frequency_penalty?: number | undefined; n?: number | null | undefined; agent_id: string; }; @@ -358,8 +358,8 @@ export const AgentsCompletionRequest$outboundSchema: z.ZodType< ToolChoice$outboundSchema, ToolChoiceEnum$outboundSchema, ]).optional(), - presencePenalty: z.number().default(0), - frequencyPenalty: z.number().default(0), + presencePenalty: z.number().optional(), + frequencyPenalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), agentId: z.string(), }).transform((v) => { diff --git a/src/models/components/agentscompletionstreamrequest.ts b/src/models/components/agentscompletionstreamrequest.ts index 71b8f0a..e55989c 100644 --- a/src/models/components/agentscompletionstreamrequest.ts +++ b/src/models/components/agentscompletionstreamrequest.ts @@ -284,8 +284,8 @@ export const AgentsCompletionStreamRequest$inboundSchema: z.ZodType< tools: z.nullable(z.array(Tool$inboundSchema)).optional(), tool_choice: z.union([ToolChoice$inboundSchema, ToolChoiceEnum$inboundSchema]) .optional(), - presence_penalty: z.number().default(0), - frequency_penalty: z.number().default(0), + presence_penalty: z.number().optional(), + frequency_penalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), agent_id: z.string(), }).transform((v) => { @@ -315,8 +315,8 @@ export type AgentsCompletionStreamRequest$Outbound = { response_format?: ResponseFormat$Outbound | undefined; tools?: Array | null | undefined; tool_choice?: ToolChoice$Outbound | string | undefined; - presence_penalty: number; - frequency_penalty: number; + presence_penalty?: number | undefined; + frequency_penalty?: number | undefined; n?: number | null | undefined; agent_id: string; }; @@ -361,8 +361,8 @@ export const AgentsCompletionStreamRequest$outboundSchema: z.ZodType< ToolChoice$outboundSchema, ToolChoiceEnum$outboundSchema, ]).optional(), - presencePenalty: z.number().default(0), - frequencyPenalty: z.number().default(0), + presencePenalty: z.number().optional(), + frequencyPenalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), agentId: z.string(), }).transform((v) => { diff --git a/src/models/components/chatcompletionrequest.ts b/src/models/components/chatcompletionrequest.ts index e2ecb18..ab87097 100644 --- a/src/models/components/chatcompletionrequest.ts +++ b/src/models/components/chatcompletionrequest.ts @@ -289,8 +289,8 @@ export const ChatCompletionRequest$inboundSchema: z.ZodType< tools: z.nullable(z.array(Tool$inboundSchema)).optional(), tool_choice: z.union([ToolChoice$inboundSchema, ToolChoiceEnum$inboundSchema]) .optional(), - presence_penalty: z.number().default(0), - frequency_penalty: z.number().default(0), + presence_penalty: z.number().optional(), + frequency_penalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), safe_prompt: z.boolean().default(false), }).transform((v) => { @@ -324,8 +324,8 @@ export type ChatCompletionRequest$Outbound = { response_format?: ResponseFormat$Outbound | undefined; tools?: Array | null | undefined; tool_choice?: ToolChoice$Outbound | string | undefined; - presence_penalty: number; - frequency_penalty: number; + presence_penalty?: number | undefined; + frequency_penalty?: number | undefined; n?: number | null | undefined; safe_prompt: boolean; }; @@ -373,8 +373,8 @@ export const ChatCompletionRequest$outboundSchema: z.ZodType< ToolChoice$outboundSchema, ToolChoiceEnum$outboundSchema, ]).optional(), - presencePenalty: z.number().default(0), - frequencyPenalty: z.number().default(0), + presencePenalty: z.number().optional(), + frequencyPenalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), safePrompt: z.boolean().default(false), }).transform((v) => { diff --git a/src/models/components/chatcompletionstreamrequest.ts b/src/models/components/chatcompletionstreamrequest.ts index c438234..60795f5 100644 --- a/src/models/components/chatcompletionstreamrequest.ts +++ b/src/models/components/chatcompletionstreamrequest.ts @@ -296,8 +296,8 @@ export const ChatCompletionStreamRequest$inboundSchema: z.ZodType< tools: z.nullable(z.array(Tool$inboundSchema)).optional(), tool_choice: z.union([ToolChoice$inboundSchema, ToolChoiceEnum$inboundSchema]) .optional(), - presence_penalty: z.number().default(0), - frequency_penalty: z.number().default(0), + presence_penalty: z.number().optional(), + frequency_penalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), safe_prompt: z.boolean().default(false), }).transform((v) => { @@ -331,8 +331,8 @@ export type ChatCompletionStreamRequest$Outbound = { response_format?: ResponseFormat$Outbound | undefined; tools?: Array | null | undefined; tool_choice?: ToolChoice$Outbound | string | undefined; - presence_penalty: number; - frequency_penalty: number; + presence_penalty?: number | undefined; + frequency_penalty?: number | undefined; n?: number | null | undefined; safe_prompt: boolean; }; @@ -380,8 +380,8 @@ export const ChatCompletionStreamRequest$outboundSchema: z.ZodType< ToolChoice$outboundSchema, ToolChoiceEnum$outboundSchema, ]).optional(), - presencePenalty: z.number().default(0), - frequencyPenalty: z.number().default(0), + presencePenalty: z.number().optional(), + frequencyPenalty: z.number().optional(), n: z.nullable(z.number().int()).optional(), safePrompt: z.boolean().default(false), }).transform((v) => {