diff --git a/.fern/metadata.json b/.fern/metadata.json index 0eb4339..c1d41db 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,5 +1,5 @@ { - "cliVersion": "5.64.0", + "cliVersion": "5.128.0", "generatorName": "fernapi/fern-typescript-sdk", "generatorVersion": "3.70.1", "generatorConfig": { @@ -7,9 +7,9 @@ "skipResponseValidation": true, "namespaceExport": "Speechify" }, - "originGitCommit": "d18d0fff37ec3446bf44071a930fcad840b961e6", + "originGitCommit": "14383dab6762a97b9dab9778796ac2b4c41cdd6d", "originGitCommitIsDirty": false, "invokedBy": "ci", "ciProvider": "github", - "sdkVersion": "4.0.1" + "sdkVersion": "4.0.2" } diff --git a/.fern/replay.lock b/.fern/replay.lock new file mode 100644 index 0000000..447a268 --- /dev/null +++ b/.fern/replay.lock @@ -0,0 +1,16 @@ +# DO NOT EDIT MANUALLY - Managed by Fern Replay +version: "1.0" +generations: + - commit_sha: bdf2b9e0c6bf53daba5fca3165a6b423abf37d82 + tree_hash: 6581ce28e87de75bd5ae65eba8608fd8261042c0 + timestamp: 2026-10-27T16:45:49.589Z + cli_version: unknown + generator_versions: {} + - commit_sha: 13f22b8303d87937d8efec850796c50465d4a459 + tree_hash: d4bc6c5eded9b1edec6b9ad3cea3e56d9b7c2f37 + timestamp: 2026-10-27T16:46:34.251Z + cli_version: unknown + generator_versions: + fernapi/fern-typescript-sdk: 3.70.1 +current_generation: 13f22b8303d87937d8efec850796c50465d4a459 +patches: [] diff --git a/.fernignore b/.fernignore index 9ddef68..6c0bc02 100644 --- a/.fernignore +++ b/.fernignore @@ -85,3 +85,6 @@ reference.md # License file — not generated by Fern; keep listed so regen never deletes it. LICENSE +.fern/replay.lock +.fern/replay.yml +.gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..74928d6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.fern/replay.lock linguist-generated=true diff --git a/package.json b/package.json index a79ec02..643b3d8 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "@speechify/api", - "version": "4.0.1", + "version": "4.0.2", "private": false, "repository": { "type": "git", "url": "git+https://github.com/Speechify-AI/sdk-typescript.git" }, + "license": "MIT", "type": "commonjs", "main": "./dist/cjs/index.js", "module": "./dist/esm/index.mjs", @@ -55,6 +56,39 @@ }, "default": "./dist/cjs/api/resources/voices/exports.js" }, + "./projects": { + "import": { + "types": "./dist/esm/api/resources/projects/exports.d.mts", + "default": "./dist/esm/api/resources/projects/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/projects/exports.d.ts", + "default": "./dist/cjs/api/resources/projects/exports.js" + }, + "default": "./dist/cjs/api/resources/projects/exports.js" + }, + "./workspaces": { + "import": { + "types": "./dist/esm/api/resources/workspaces/exports.d.mts", + "default": "./dist/esm/api/resources/workspaces/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/workspaces/exports.d.ts", + "default": "./dist/cjs/api/resources/workspaces/exports.js" + }, + "default": "./dist/cjs/api/resources/workspaces/exports.js" + }, + "./audio/watermark": { + "import": { + "types": "./dist/esm/api/resources/audio/resources/watermark/exports.d.mts", + "default": "./dist/esm/api/resources/audio/resources/watermark/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/audio/resources/watermark/exports.d.ts", + "default": "./dist/cjs/api/resources/audio/resources/watermark/exports.js" + }, + "default": "./dist/cjs/api/resources/audio/resources/watermark/exports.js" + }, "./voices/consentChallenges": { "import": { "types": "./dist/esm/api/resources/voices/resources/consentChallenges/exports.d.mts", @@ -66,6 +100,28 @@ }, "default": "./dist/cjs/api/resources/voices/resources/consentChallenges/exports.js" }, + "./webhooks": { + "import": { + "types": "./dist/esm/api/resources/webhooks/exports.d.mts", + "default": "./dist/esm/api/resources/webhooks/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/webhooks/exports.d.ts", + "default": "./dist/cjs/api/resources/webhooks/exports.js" + }, + "default": "./dist/cjs/api/resources/webhooks/exports.js" + }, + "./webhooks/endpoints": { + "import": { + "types": "./dist/esm/api/resources/webhooks/resources/endpoints/exports.d.mts", + "default": "./dist/esm/api/resources/webhooks/resources/endpoints/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/webhooks/resources/endpoints/exports.d.ts", + "default": "./dist/cjs/api/resources/webhooks/resources/endpoints/exports.js" + }, + "default": "./dist/cjs/api/resources/webhooks/resources/endpoints/exports.js" + }, "./package.json": "./package.json" }, "files": [ diff --git a/src/BaseClient.ts b/src/BaseClient.ts index 7b13813..551eb37 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -12,7 +12,7 @@ export type AuthOption = | BearerAuthProvider.AuthOptions; export type BaseClientOptions = { - environment?: core.Supplier; + environment?: core.Supplier; /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; /** Override the Speechify-Version header */ @@ -63,11 +63,11 @@ export function normalizeClientOptions { + const env = await core.Supplier.get(this._options.environment); + return typeof env === "string" + ? env + : ((env as Record)?.base ?? environments.SpeechifyEnvironment.Default.base); + }), headers: this._options.headers, timeoutInSeconds: this._options.timeoutInSeconds, maxRetries: this._options.maxRetries, diff --git a/src/api/resources/audio/client/requests/GetSpeechRequest.ts b/src/api/resources/audio/client/requests/GetSpeechRequest.ts index 8f0f9fa..c21d06e 100644 --- a/src/api/resources/audio/client/requests/GetSpeechRequest.ts +++ b/src/api/resources/audio/client/requests/GetSpeechRequest.ts @@ -16,8 +16,9 @@ export interface GetSpeechRequest { audio_format?: GetSpeechRequest.AudioFormat; /** * Plain text or SSML to be synthesized to speech. + * Up to 2,000 characters of spoken text, the characters the request is billed for: SSML tags do not count. The input as sent, markup included, may be up to 20,000 characters. * Refer to https://docs.speechify.ai/docs/api-limits for the input size limits. - * Emotion, Pitch and Speed Rate are configured in the ssml input, please refer to the ssml documentation for more information: https://docs.speechify.ai/docs/ssml#prosody + * SSML sets pauses (``), speaking rate, pitch and volume (``) and pronunciation (``): see https://docs.speechify.ai/build/guides/text-to-speech/ssml for each tag. Emotion styles and emphasis are applied only by the Simba 1.6 models, until 2026-11-21; `simba-3.0`, `simba-3.2` and `simba-3.5` accept those tags without applying them. */ input: string; /** @@ -25,11 +26,18 @@ export interface GetSpeechRequest { * Please refer to the list of the supported languages and recommendations regarding this parameter: https://docs.speechify.ai/docs/language-support. */ language?: string; - /** Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity, and the recommended Simba 3 model; it is English only, so a non-English voice returns 400. `simba-english` and `simba-multilingual` are the legacy Simba 1.6 models, kept for compatibility. */ + /** + * Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity; it is English only, so a non-English voice returns 400. `simba-3.5` is the recommended model: streaming-native, covering 48 languages under one id, English included, routed by `language` like `simba-3.0`; every voice works on it, cloned voices included. + * + * The legacy Simba 1.6 models `simba-english` and `simba-multilingual` are retired from API version `2026-09-21`: naming one returns 400 `model_retired`. Pinning your API version to a date before `2026-09-21` keeps them on their Simba 1.6 training until **2026-11-21**; from then both ids are served by our current models on every API version that can still name them. Migrate to `simba-3.2` (English), `simba-3.0` or `simba-3.5` before then; call GET /v1/audio/models to see the set your workspace can select today. + */ model?: GetSpeechRequest.Model; options?: Speechify.GetSpeechOptionsRequest; /** The output audio format as a `codec_sampleRate_bitrate` string. Takes precedence over `audio_format` when set. */ output_format?: Speechify.AudioOutputFormat; + pronunciations?: Speechify.Pronunciations; + /** Optional. A stable, opaque identifier for the end user this request is made for: a hash of your own user id or an opaque id, never an email address or other personal data. It is recorded with the request even under zero data retention, and your workspace can be given per-end-user limits and a block list keyed on it. See https://docs.speechify.ai/build/guides/concepts/safety-identifiers. */ + safety_identifier?: Speechify.SafetyIdentifier; /** Id of the voice to be used for synthesizing speech. Refer to /v1/voices endpoint for available voices */ voice_id: string; } @@ -44,20 +52,21 @@ export namespace GetSpeechRequest { Pcm: "pcm", } as const; export type AudioFormat = (typeof AudioFormat)[keyof typeof AudioFormat]; - /** Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity, and the recommended Simba 3 model; it is English only, so a non-English voice returns 400. `simba-english` and `simba-multilingual` are the legacy Simba 1.6 models, kept for compatibility. */ + /** + * Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity; it is English only, so a non-English voice returns 400. `simba-3.5` is the recommended model: streaming-native, covering 48 languages under one id, English included, routed by `language` like `simba-3.0`; every voice works on it, cloned voices included. + * + * The legacy Simba 1.6 models `simba-english` and `simba-multilingual` are retired from API version `2026-09-21`: naming one returns 400 `model_retired`. Pinning your API version to a date before `2026-09-21` keeps them on their Simba 1.6 training until **2026-11-21**; from then both ids are served by our current models on every API version that can still name them. Migrate to `simba-3.2` (English), `simba-3.0` or `simba-3.5` before then; call GET /v1/audio/models to see the set your workspace can select today. + */ export const Model = { /** - * simba-english is the legacy Simba 1.6 English model. It accepts cloned voices self-serve; prefer simba-3.2 for new integrations. */ - SimbaEnglish: "simba-english", - /** - * simba-multilingual is the legacy Simba 1.6 multilingual model, covering the full 30+ locale set and mixed-language input. Prefer simba-3.0 for the languages it supports. */ - SimbaMultilingual: "simba-multilingual", - /** - * simba-3.0 is the streaming-native multilingual model, and the default when `model` is omitted. Officially supports English plus de-DE, es-ES, es-MX, fr-FR, it-IT and pt-BR; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Prefer simba-3.2 for English-only integrations. Cloned/personal voices work self-serve on simba-3.0. */ + * simba-3.0 is the streaming-native multilingual model, and the default when `model` is omitted. Officially supports English plus de-DE, es-ES, es-MX, fr-FR, it-IT and pt-BR; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Prefer simba-3.5 for new integrations. Cloned/personal voices work self-serve on simba-3.0. */ Simba30: "simba-3.0", /** - * simba-3.2 is the streaming-native model with the lowest TTFB and richest expressivity. English only; a non-English voice returns 400 - use simba-3.0 for the other supported languages. Cloned voices are supported on simba-3.2 alongside the curated stock roster, currently as a limited release enabled per workspace - contact Speechify to have it enabled for yours. */ + * simba-3.2 is the streaming-native model with the lowest TTFB and richest expressivity. English only; a non-English voice returns 400 - use simba-3.0 for the other supported languages. Every English voice in the catalog is supported, cloned voices included. */ Simba32: "simba-3.2", + /** + * simba-3.5 is the recommended streaming-native model, covering 48 languages under one id, English included; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Every voice in the catalog is supported, cloned voices included. */ + Simba35: "simba-3.5", } as const; export type Model = (typeof Model)[keyof typeof Model]; } diff --git a/src/api/resources/audio/exports.ts b/src/api/resources/audio/exports.ts index fade8b3..661ed16 100644 --- a/src/api/resources/audio/exports.ts +++ b/src/api/resources/audio/exports.ts @@ -2,3 +2,4 @@ export { AudioClient } from "./client/Client.js"; export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/audio/index.ts b/src/api/resources/audio/index.ts index d9adb1a..0ef16e7 100644 --- a/src/api/resources/audio/index.ts +++ b/src/api/resources/audio/index.ts @@ -1,2 +1,3 @@ export * from "./client/index.js"; +export * from "./resources/index.js"; export * from "./types/index.js"; diff --git a/src/api/resources/audio/resources/index.ts b/src/api/resources/audio/resources/index.ts new file mode 100644 index 0000000..ded83fd --- /dev/null +++ b/src/api/resources/audio/resources/index.ts @@ -0,0 +1,2 @@ +export * from "./watermark/client/requests/index.js"; +export * as watermark from "./watermark/index.js"; diff --git a/src/api/resources/audio/resources/watermark/client/Client.ts b/src/api/resources/audio/resources/watermark/client/Client.ts new file mode 100644 index 0000000..5c23849 --- /dev/null +++ b/src/api/resources/audio/resources/watermark/client/Client.ts @@ -0,0 +1,291 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Speechify from "../../../../../index.js"; + +export declare namespace WatermarkClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class WatermarkClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: WatermarkClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Check whether a clip carries the watermark Speechify seals into audio it + * generates. Upload the audio as `audio`; nothing about it is stored, and + * no voice is read or written. + * + * Read the answer carefully in one direction. A `watermarked: true` is + * positive evidence that the audio came from Speechify synthesis. A + * `watermarked: false` is NOT proof that it did not: only models + * redeployed since the watermark shipped mark their output, the detector + * needs at least three seconds of clear speech to judge, and re-encoding + * or changing the speed of a clip degrades the mark. Treat a negative as + * the absence of evidence rather than as evidence of absence. + * + * Checks are rate-limited well below the synthesis budget: this is a + * forensic question, not a data-plane call. + * + * @param {Speechify.audio.DetectWatermarkRequest} request + * @param {WatermarkClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.ContentTooLargeError} + * @throws {@link Speechify.UnprocessableEntityError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * @throws {@link Speechify.BadGatewayError} + * + * @example + * import { createReadStream } from "fs"; + * await client.audio.watermark.detect({ + * audio: fs.createReadStream("/path/to/your/file") + * }) + */ + public detect( + request: Speechify.audio.DetectWatermarkRequest, + requestOptions?: WatermarkClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__detect(request, requestOptions)); + } + + private async __detect( + request: Speechify.audio.DetectWatermarkRequest, + requestOptions?: WatermarkClient.RequestOptions, + ): Promise> { + const _body = await core.newFormData(); + await _body.appendFile("audio", request.audio); + const _maybeEncodedRequest = await _body.getRequest(); + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + "v1/audio/watermark/detect", + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.WatermarkDetectionResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 413: + throw new Speechify.ContentTooLargeError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 422: + throw new Speechify.UnprocessableEntityError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 502: + throw new Speechify.BadGatewayError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/audio/watermark/detect"); + } + + /** + * The public AI detection tool. Ask whether a clip carries the watermark + * Speechify seals into audio it generates, with no account, no API key and + * no credential of any kind. + * + * `verify` answers; `detect` measures. This route returns a bare yes or no, + * the way verifying a signature does. Its sibling + * `POST /v1/audio/watermark/detect` takes an API key and returns the + * detector's confidence alongside the verdict. + * + * This is the programmatic half of the tool published at + * , and it exists so the tool can be invoked + * without visiting our website, as California's AI Transparency Act + * (BPC 22757.2) requires. Nothing about the clip is stored, and nothing + * identifying about you is collected or retained. + * + * The answer is a bare verdict. `watermarked: true` is positive evidence + * that the audio came from Speechify synthesis. `watermarked: false` is + * NOT proof that it did not: only models redeployed since the watermark + * shipped mark their output, the detector needs at least three seconds of + * clear speech to judge, and re-encoding or changing the speed of a clip + * degrades the mark. Treat a negative as the absence of evidence rather + * than as evidence of absence. + * + * Because the tool takes no credential, it is rate-limited per client + * address and shares a platform-wide budget: expect a 429 under sustained + * automated use, and retry after the interval the response advertises. + * Use `POST /v1/audio/watermark/detect` with an API key for the detector's + * confidence score and a per-workspace allowance of its own. + * + * @param {Speechify.audio.VerifyWatermarkRequest} request + * @param {WatermarkClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.ContentTooLargeError} + * @throws {@link Speechify.UnprocessableEntityError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * @throws {@link Speechify.BadGatewayError} + * @throws {@link Speechify.ServiceUnavailableError} + * + * @example + * import { createReadStream } from "fs"; + * await client.audio.watermark.verify({ + * audio: fs.createReadStream("/path/to/your/file") + * }) + */ + public verify( + request: Speechify.audio.VerifyWatermarkRequest, + requestOptions?: WatermarkClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__verify(request, requestOptions)); + } + + private async __verify( + request: Speechify.audio.VerifyWatermarkRequest, + requestOptions?: WatermarkClient.RequestOptions, + ): Promise> { + const _body = await core.newFormData(); + await _body.appendFile("audio", request.audio); + const _maybeEncodedRequest = await _body.getRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + ..._maybeEncodedRequest.headers, + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + "v1/audio/watermark/verify", + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "file", + duplex: _maybeEncodedRequest.duplex, + body: _maybeEncodedRequest.body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.WatermarkVerificationResponse, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 413: + throw new Speechify.ContentTooLargeError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 422: + throw new Speechify.UnprocessableEntityError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 502: + throw new Speechify.BadGatewayError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 503: + throw new Speechify.ServiceUnavailableError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/audio/watermark/verify"); + } +} diff --git a/src/api/resources/audio/resources/watermark/client/index.ts b/src/api/resources/audio/resources/watermark/client/index.ts new file mode 100644 index 0000000..195f9aa --- /dev/null +++ b/src/api/resources/audio/resources/watermark/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/audio/resources/watermark/client/requests/DetectWatermarkRequest.ts b/src/api/resources/audio/resources/watermark/client/requests/DetectWatermarkRequest.ts new file mode 100644 index 0000000..a066adb --- /dev/null +++ b/src/api/resources/audio/resources/watermark/client/requests/DetectWatermarkRequest.ts @@ -0,0 +1,19 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../../../../core/index.js"; + +/** + * @example + * { + * audio: fs.createReadStream("/path/to/your/file") + * } + */ +export interface DetectWatermarkRequest { + /** + * The clip to check, at most 25MB. Give the detector at least + * three seconds of clear speech; below that its confidence is + * not worth acting on, and below half a second it always + * reports zero. + */ + audio: core.file.Uploadable; +} diff --git a/src/api/resources/audio/resources/watermark/client/requests/VerifyWatermarkRequest.ts b/src/api/resources/audio/resources/watermark/client/requests/VerifyWatermarkRequest.ts new file mode 100644 index 0000000..1566b45 --- /dev/null +++ b/src/api/resources/audio/resources/watermark/client/requests/VerifyWatermarkRequest.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as core from "../../../../../../../core/index.js"; + +/** + * @example + * { + * audio: fs.createReadStream("/path/to/your/file") + * } + */ +export interface VerifyWatermarkRequest { + /** + * The clip to check, at most 25MB. Give the detector at least + * three seconds of clear speech; below that its answer is not + * worth acting on. + */ + audio: core.file.Uploadable; +} diff --git a/src/api/resources/audio/resources/watermark/client/requests/index.ts b/src/api/resources/audio/resources/watermark/client/requests/index.ts new file mode 100644 index 0000000..b172e0d --- /dev/null +++ b/src/api/resources/audio/resources/watermark/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { DetectWatermarkRequest } from "./DetectWatermarkRequest.js"; +export type { VerifyWatermarkRequest } from "./VerifyWatermarkRequest.js"; diff --git a/src/api/resources/audio/resources/watermark/exports.ts b/src/api/resources/audio/resources/watermark/exports.ts new file mode 100644 index 0000000..609f0a7 --- /dev/null +++ b/src/api/resources/audio/resources/watermark/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { WatermarkClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/audio/resources/watermark/index.ts b/src/api/resources/audio/resources/watermark/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/audio/resources/watermark/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/audio/types/AudioStreamInputModel.ts b/src/api/resources/audio/types/AudioStreamInputModel.ts new file mode 100644 index 0000000..3641921 --- /dev/null +++ b/src/api/resources/audio/types/AudioStreamInputModel.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +/** Model used for every segment, as for `POST /v1/audio/stream`. `simba-3.2` is English only. */ +export const AudioStreamInputModel = { + Simba30: "simba-3.0", + Simba32: "simba-3.2", + Simba35: "simba-3.5", +} as const; +export type AudioStreamInputModel = (typeof AudioStreamInputModel)[keyof typeof AudioStreamInputModel]; diff --git a/src/api/resources/audio/types/AudioStreamInputOutputFormat.ts b/src/api/resources/audio/types/AudioStreamInputOutputFormat.ts new file mode 100644 index 0000000..ffa0f24 --- /dev/null +++ b/src/api/resources/audio/types/AudioStreamInputOutputFormat.ts @@ -0,0 +1,28 @@ +// This file was auto-generated by Fern from our API Definition. + +/** Audio format of every `speech.chunk`, as on `POST /v1/audio/stream`. Defaults to MP3 at 24 kHz. */ +export const AudioStreamInputOutputFormat = { + Pcm8000: "pcm_8000", + Pcm16000: "pcm_16000", + Pcm22050: "pcm_22050", + Pcm24000: "pcm_24000", + Pcm44100: "pcm_44100", + Pcm48000: "pcm_48000", + Mp32205032: "mp3_22050_32", + Mp32205064: "mp3_22050_64", + Mp32205096: "mp3_22050_96", + Mp322050128: "mp3_22050_128", + Mp322050160: "mp3_22050_160", + Mp322050192: "mp3_22050_192", + Mp32400032: "mp3_24000_32", + Mp32400064: "mp3_24000_64", + Mp32400096: "mp3_24000_96", + Mp324000128: "mp3_24000_128", + Mp324000160: "mp3_24000_160", + Mp324000192: "mp3_24000_192", + Ulaw8000: "ulaw_8000", + Ogg24000: "ogg_24000", + Aac24000: "aac_24000", +} as const; +export type AudioStreamInputOutputFormat = + (typeof AudioStreamInputOutputFormat)[keyof typeof AudioStreamInputOutputFormat]; diff --git a/src/api/resources/audio/types/AudioStreamInputSpeechMarks.ts b/src/api/resources/audio/types/AudioStreamInputSpeechMarks.ts new file mode 100644 index 0000000..c148749 --- /dev/null +++ b/src/api/resources/audio/types/AudioStreamInputSpeechMarks.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +/** When true, each `speech.chunk` carries the word marks that became final with it, indexing the session's whole text. */ +export const AudioStreamInputSpeechMarks = { + True: "true", + False: "false", +} as const; +export type AudioStreamInputSpeechMarks = + (typeof AudioStreamInputSpeechMarks)[keyof typeof AudioStreamInputSpeechMarks]; diff --git a/src/api/resources/audio/types/InputClose.ts b/src/api/resources/audio/types/InputClose.ts new file mode 100644 index 0000000..ea9728b --- /dev/null +++ b/src/api/resources/audio/types/InputClose.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Client message on GET /v1/audio/stream/ws: no more text is coming. The server speaks everything it was sent, sends speech.done with reason closed, and closes the socket. Keep reading until speech.done arrives: closing the socket first abandons the audio still to come, and the segment it cuts is billed in full. + */ +export interface InputClose { + type: InputClose.Type; +} + +export namespace InputClose { + export const Type = { + InputClose: "input.close", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} diff --git a/src/api/resources/audio/types/InputFlush.ts b/src/api/resources/audio/types/InputFlush.ts new file mode 100644 index 0000000..bebfca9 --- /dev/null +++ b/src/api/resources/audio/types/InputFlush.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Client message on GET /v1/audio/stream/ws: speak everything sent so far now, without waiting for its sentence to end. The server answers with speech.flushed once that audio has been sent, at once when nothing was waiting. Use it at the end of an LLM turn. + */ +export interface InputFlush { + type: InputFlush.Type; +} + +export namespace InputFlush { + export const Type = { + InputFlush: "input.flush", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} diff --git a/src/api/resources/audio/types/InputText.ts b/src/api/resources/audio/types/InputText.ts new file mode 100644 index 0000000..b8aaa49 --- /dev/null +++ b/src/api/resources/audio/types/InputText.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Client message on GET /v1/audio/stream/ws: text appended to what the session will speak. Send it as your application produces it, a few tokens at a time is fine; the server speaks each sentence once the next one starts, so a reply that arrives in pieces is cut at its sentence boundaries, not at the message boundaries. The text is spoken as plain text: SSML is read aloud, not interpreted. At most 20000 characters can wait to be spoken at once; more is refused with payload_too_large, which ends the session. + */ +export interface InputText { + type: InputText.Type; + /** The next piece of text. Include the spaces and newlines between words and sentences exactly as your source produced them: they are what tells the server a sentence has ended. */ + text: string; +} + +export namespace InputText { + export const Type = { + InputText: "input.text", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} diff --git a/src/api/resources/audio/types/SessionPronunciations.ts b/src/api/resources/audio/types/SessionPronunciations.ts new file mode 100644 index 0000000..deb2806 --- /dev/null +++ b/src/api/resources/audio/types/SessionPronunciations.ts @@ -0,0 +1,42 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface SessionPronunciations { + type: SessionPronunciations.Type; + /** + * Optional. How to pronounce words and phrases in `input`: each entry gives a `text` and either the phones to say it with (`ipa`) or plain text to say in its place (`alias`). Every entry applies to the whole request. + * + * Supported only in the languages a model's entry in GET /v1/audio/models lists in `pronunciation_languages`, which does not include English yet: any other model or language returns `400 pronunciations_unsupported`. An empty array is accepted by every model in every language. At most 200 entries. A malformed entry, a phone outside the model's phone set, an `ipa` entry whose `text` is more than one word, or two entries for the same `text` returns `400 validation_failed`, with `fields` naming each entry (for example `pronunciations[3].ipa`), before anything is synthesized or billed. So does an `input` longer than 20,000 characters once every alias stands in for its text. + * + * Entries match case-insensitively unless `case_sensitive` is true, as whole words, except in Chinese, Japanese, Korean, Thai, Lao, Khmer and Burmese, where they match anywhere in the text; the longest matching entry wins, and an entry takes precedence over the model's own pronunciation. Pronunciations are not billed, and speech marks still index `input` exactly as sent. See https://docs.speechify.ai/build/guides/text-to-speech/pronunciation. + */ + pronunciations: SessionPronunciations.Pronunciations.Item[]; +} + +export namespace SessionPronunciations { + export const Type = { + SessionPronunciations: "session.pronunciations", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + export type Pronunciations = Pronunciations.Item[]; + + export namespace Pronunciations { + /** + * One pronunciation entry. Set `text` and exactly one of `ipa` or `alias`. + */ + export type Item = + /** + * Say `text` with these phones. */ + | { + text: string; + ipa: string; + case_sensitive?: boolean | undefined; + } + /** + * Say this text in place of `text`. */ + | { + text: string; + alias: string; + case_sensitive?: boolean | undefined; + }; + } +} diff --git a/src/api/resources/audio/types/SpeechChunk.ts b/src/api/resources/audio/types/SpeechChunk.ts new file mode 100644 index 0000000..4b047cd --- /dev/null +++ b/src/api/resources/audio/types/SpeechChunk.ts @@ -0,0 +1,47 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A run of synthesized audio, the speech marks that became final with it, + * or both - a chunk may carry only one of the two, and the last chunk of + * a stream is often marks-only. Mark times are absolute milliseconds from + * the start of the synthesis: concatenate the audio chunks into one + * stream and apply the marks against that single timeline. Which chunk a + * mark arrives on is a delivery detail and carries no meaning. + */ +export interface SpeechChunk { + type: SpeechChunk.Type; + /** + * A run of the synthesized audio, Base64-encoded, in the format the + * request selected (echoed on the `Speechify-Audio-Content-Type` + * response header). Absent on a marks-only chunk. + */ + audio?: string | undefined; + /** + * Word timings addressing the original input text, with absolute + * millisecond times from the start of the synthesis. Absent when the + * chunk carries only audio. + */ + speech_marks?: SpeechChunk.SpeechMarks.Item[] | undefined; +} + +export namespace SpeechChunk { + export const Type = { + SpeechChunk: "speech.chunk", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + export type SpeechMarks = SpeechMarks.Item[]; + + export namespace SpeechMarks { + /** + * It details the type of segment, its start and end points in the text, and its start and end times in the synthesized speech audio. + */ + export interface Item { + end?: number | undefined; + end_time?: number | undefined; + start?: number | undefined; + start_time?: number | undefined; + type?: string | undefined; + value?: string | undefined; + } + } +} diff --git a/src/api/resources/audio/types/SpeechDone.ts b/src/api/resources/audio/types/SpeechDone.ts new file mode 100644 index 0000000..b165ce2 --- /dev/null +++ b/src/api/resources/audio/types/SpeechDone.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface SpeechDone { + type: SpeechDone.Type; + /** Number of billable characters processed. */ + billable_characters_count: number; + /** Duration of the synthesized audio in milliseconds. */ + audio_duration_ms: number; + /** closed: the client sent input.close and everything was spoken. idle: 60 seconds passed with nothing to speak and no message. session_limit: the session reached its 5 minute limit, and everything sent before it was spoken. shutdown: the server is restarting; reconnect, and the next session lands on another server. Ignore a reason you do not recognize. */ + reason: SpeechDone.Reason; +} + +export namespace SpeechDone { + export const Type = { + SpeechDone: "speech.done", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + /** closed: the client sent input.close and everything was spoken. idle: 60 seconds passed with nothing to speak and no message. session_limit: the session reached its 5 minute limit, and everything sent before it was spoken. shutdown: the server is restarting; reconnect, and the next session lands on another server. Ignore a reason you do not recognize. */ + export const Reason = { + Closed: "closed", + Idle: "idle", + SessionLimit: "session_limit", + Shutdown: "shutdown", + } as const; + export type Reason = (typeof Reason)[keyof typeof Reason]; +} diff --git a/src/api/resources/audio/types/SpeechError.ts b/src/api/resources/audio/types/SpeechError.ts new file mode 100644 index 0000000..4db1e88 --- /dev/null +++ b/src/api/resources/audio/types/SpeechError.ts @@ -0,0 +1,254 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Terminal event carrying the standard error envelope, emitted when a + * failure happens after the stream has started and the status code is + * already committed: an upstream fault (`upstream_failure`) or a content + * policy refusal (`content_policy_violation`). + */ +export interface SpeechError { + type: SpeechError.Type; + error: SpeechError.Error_; + /** + * Server-side request identifier. Echoes the `Speechify-Request-Id` + * response header. + */ + request_id?: string | undefined; +} + +export namespace SpeechError { + export const Type = { + SpeechError: "speech.error", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; + + export interface Error_ { + /** + * Stable machine-readable error code. Additive only: codes are + * never renamed, only deprecated. SDKs may map each code to a + * typed exception class. Status-code semantics: + * 4xx codes describe caller-fixable issues; 5xx codes describe + * server-side failures and are safe to retry with backoff for + * idempotent requests. + */ + code: Error_.Code; + /** + * Human-readable explanation of this specific occurrence. + * Safe to surface in UI banners or pass to support. The + * wording can change between releases; clients should + * match on `code`, not on the message string. + */ + message: string; + /** + * Per-field validation errors as `path -> message`. Only + * present on 400 responses caused by request validation + * (typically code=`validation_failed`). Keys are field + * paths in dotted/bracket notation; values are short + * human explanations safe to inline-surface next to the + * offending form field. + */ + fields?: Record | undefined; + /** + * Structured, endpoint-specific context beyond the flat + * `fields` map. Present only on the few errors that carry + * it (e.g. the `used_by` referrer list on a credential + * delete-conflict); its shape depends on the error `code`. + * Clients that don't recognise a `details` shape can ignore + * it - the `code` + `message` contract is unchanged. + */ + details?: Record | undefined; + /** + * Link to the documentation that resolves this class of + * error, when a stable page exists. Rate and concurrency + * 429s link the API limits reference, which lists each + * plan's limits and how to raise them. + */ + docs_url?: string | undefined; + } + + export namespace Error_ { + /** + * Stable machine-readable error code. Additive only: codes are + * never renamed, only deprecated. SDKs may map each code to a + * typed exception class. Status-code semantics: + * 4xx codes describe caller-fixable issues; 5xx codes describe + * server-side failures and are safe to retry with backoff for + * idempotent requests. + */ + export const Code = { + EndpointMoved: "endpoint_moved", + BadRequest: "bad_request", + ValidationFailed: "validation_failed", + Unauthorized: "unauthorized", + PaymentRequired: "payment_required", + Forbidden: "forbidden", + NotFound: "not_found", + MethodNotAllowed: "method_not_allowed", + Conflict: "conflict", + IdempotencyConflict: "idempotency_conflict", + PayloadTooLarge: "payload_too_large", + UnsupportedMediaType: "unsupported_media_type", + RateLimited: "rate_limited", + ConcurrencyLimitReached: "concurrency_limit_reached", + InvalidApiVersion: "invalid_api_version", + InternalError: "internal_error", + UpstreamFailure: "upstream_failure", + ServiceUnavailable: "service_unavailable", + CallerNotFound: "caller_not_found", + ContactNotFound: "contact_not_found", + ContactIdentifierNotFound: "contact_identifier_not_found", + ContactIdentifierConflict: "contact_identifier_conflict", + ContactResolverNotFound: "contact_resolver_not_found", + CredentialNotFound: "credential_not_found", + CredentialInUse: "credential_in_use", + AgentNotFound: "agent_not_found", + AgentInUse: "agent_in_use", + AgentRunNotFound: "agent_run_not_found", + KbNotFound: "kb_not_found", + KbDocumentNotFound: "kb_document_not_found", + KbFolderNotFound: "kb_folder_not_found", + ToolNotFound: "tool_not_found", + ToolNameTaken: "tool_name_taken", + ChannelInstanceNotFound: "channel_instance_not_found", + TeamNotFound: "team_not_found", + TriggerNotFound: "trigger_not_found", + StoreNotFound: "store_not_found", + StoreDocumentNotFound: "store_document_not_found", + HostedApiNotFound: "hosted_api_not_found", + ApiRouteNotFound: "api_route_not_found", + ConsumerKeyNotFound: "consumer_key_not_found", + SkillNotFound: "skill_not_found", + SkillVersionNotFound: "skill_version_not_found", + FileNotFound: "file_not_found", + FilePathTaken: "file_path_taken", + FileStorageLimitReached: "file_storage_limit_reached", + StoreLimitReached: "store_limit_reached", + StoreDocumentLimitReached: "store_document_limit_reached", + StoreBytesLimitReached: "store_bytes_limit_reached", + StoreNotConfigured: "store_not_configured", + StoreDocumentVersionConflict: "store_document_version_conflict", + StoreDocumentDeleted: "store_document_deleted", + EntitlementOverrideExists: "entitlement_override_exists", + HostedApisNotInPlan: "hosted_apis_not_in_plan", + SkillsNotInPlan: "skills_not_in_plan", + VoiceAgentsNotInPlan: "voice_agents_not_in_plan", + SkillInUse: "skill_in_use", + SkillToolNameConflict: "skill_tool_name_conflict", + SkillLimitReached: "skill_limit_reached", + AgentSkillLimitReached: "agent_skill_limit_reached", + HostedApiSlugTaken: "hosted_api_slug_taken", + ApiRouteConflict: "api_route_conflict", + MountPlanChanged: "mount_plan_changed", + RouteOutputUnavailable: "route_output_unavailable", + RouteRunTimeout: "route_run_timeout", + RouteRunFailed: "route_run_failed", + RouteRunLimitReached: "route_run_limit_reached", + RouteReadLimitReached: "route_read_limit_reached", + RouteWriteLimitReached: "route_write_limit_reached", + HostedApiPublicRefused: "hosted_api_public_refused", + RouteToolNotReadable: "route_tool_not_readable", + RouteToolUnavailable: "route_tool_unavailable", + RouteUpstreamRateLimited: "route_upstream_rate_limited", + RouteUpstreamError: "route_upstream_error", + HostedMcpNotEnabled: "hosted_mcp_not_enabled", + HostedApiBusy: "hosted_api_busy", + ConversationNotFound: "conversation_not_found", + PhoneNumberNotFound: "phone_number_not_found", + SipTrunkNotFound: "sip_trunk_not_found", + VoiceNotFound: "voice_not_found", + AudioAssetNotFound: "audio_asset_not_found", + BuiltinNotFound: "builtin_not_found", + BatchNotFound: "batch_not_found", + AgentTestNotFound: "agent_test_not_found", + WorkspaceNotFound: "workspace_not_found", + InviteNotFound: "invite_not_found", + ProjectNotFound: "project_not_found", + CrossProjectReference: "cross_project_reference", + ProjectHasScopedCredentials: "project_has_scoped_credentials", + ProjectNotEmpty: "project_not_empty", + ProjectLimitReached: "project_limit_reached", + AgentLimitReached: "agent_limit_reached", + ProjectTooLargeToPromote: "project_too_large_to_promote", + CallNotFound: "call_not_found", + MessageNotFound: "message_not_found", + ThreadNotFound: "thread_not_found", + CallNotActive: "call_not_active", + RelayDisplacesAgent: "relay_displaces_agent", + BrainNotFound: "brain_not_found", + BrainInUse: "brain_in_use", + CustomModelNotFound: "custom_model_not_found", + CustomModelInUse: "custom_model_in_use", + InsufficientScope: "insufficient_scope", + PurchasedNumbersNotIncluded: "purchased_numbers_not_included", + PhoneNumberQuotaReached: "phone_number_quota_reached", + BatchCallsNotIncluded: "batch_calls_not_included", + VoiceCloningNotIncluded: "voice_cloning_not_included", + VoiceCloningUnavailableInRegion: "voice_cloning_unavailable_in_region", + ConsentChallengeNotFound: "consent_challenge_not_found", + ConsentChallengeExpired: "consent_challenge_expired", + ConsentChallengeAlreadyUsed: "consent_challenge_already_used", + ConsentPhraseMismatch: "consent_phrase_mismatch", + ConsentSpeakerMismatch: "consent_speaker_mismatch", + ConsentRecordingUnusable: "consent_recording_unusable", + ConsentVerificationUnavailable: "consent_verification_unavailable", + ConsentVerificationRequired: "consent_verification_required", + WatermarkAudioUnusable: "watermark_audio_unusable", + WatermarkDetectionUnavailable: "watermark_detection_unavailable", + WorkspaceLastOwner: "workspace_last_owner", + WorkspaceLastWorkspace: "workspace_last_workspace", + AccountDeletionBlocked: "account_deletion_blocked", + WorkspaceFreeLimit: "workspace_free_limit", + WorkspaceSingleOwner: "workspace_single_owner", + InviteEmailMismatch: "invite_email_mismatch", + InviteAlreadyPending: "invite_already_pending", + ServiceAccountLimitReached: "service_account_limit_reached", + ServiceAccountsNotInPlan: "service_accounts_not_in_plan", + SpeechMarksUnsupported: "speech_marks_unsupported", + PronunciationsUnsupported: "pronunciations_unsupported", + ModelRetired: "model_retired", + TooManyVoices: "too_many_voices", + ContentPolicyViolation: "content_policy_violation", + SafetyIdentifierBlocked: "safety_identifier_blocked", + TopupNotInPlan: "topup_not_in_plan", + CreditPurchaseUnpaid: "credit_purchase_unpaid", + CreditPurchasePaymentInProgress: "credit_purchase_payment_in_progress", + ToolConfigShared: "tool_config_shared", + SpendCapExceeded: "spend_cap_exceeded", + SpendBudgetExceeded: "spend_budget_exceeded", + ProjectSpendLimitExceeded: "project_spend_limit_exceeded", + ProjectArchived: "project_archived", + ProjectNotArchived: "project_not_archived", + ProjectNotPurged: "project_not_purged", + ProjectRestoreWindowExpired: "project_restore_window_expired", + ProjectNameTaken: "project_name_taken", + FundedBalanceRequired: "funded_balance_required", + AgentPublishGateFailed: "agent_publish_gate_failed", + AgentPublishGateRequired: "agent_publish_gate_required", + AgentPublishGateUnavailable: "agent_publish_gate_unavailable", + AgentPublishGateToolUnreachable: "agent_publish_gate_tool_unreachable", + TextChannelNotInPlan: "text_channel_not_in_plan", + ChannelNotInPlan: "channel_not_in_plan", + TextTurnFailed: "text_turn_failed", + ConversationTurnInProgress: "conversation_turn_in_progress", + ConversationClosed: "conversation_closed", + ConversationNotReachable: "conversation_not_reachable", + ConversationChannelBound: "conversation_channel_bound", + ConversationPromptNotFound: "conversation_prompt_not_found", + TextMessageQuotaExceeded: "text_message_quota_exceeded", + DurableRunsNotInPlan: "durable_runs_not_in_plan", + ToolTransportUnsupported: "tool_transport_unsupported", + AgentConfigTooLarge: "agent_config_too_large", + AgentRunNotPending: "agent_run_not_pending", + AgentRunActionStale: "agent_run_action_stale", + ShareLinkNotFound: "share_link_not_found", + ShareLinkExhausted: "share_link_exhausted", + ShareLinkLimitReached: "share_link_limit_reached", + DestinationNotAllowed: "destination_not_allowed", + InternationalDialingNotEnabled: "international_dialing_not_enabled", + NumberNotSmsCapable: "number_not_sms_capable", + VerificationRequired: "verification_required", + IntendedUseRequired: "intended_use_required", + } as const; + export type Code = (typeof Code)[keyof typeof Code]; + } +} diff --git a/src/api/resources/audio/types/SpeechFlushed.ts b/src/api/resources/audio/types/SpeechFlushed.ts new file mode 100644 index 0000000..8e7204a --- /dev/null +++ b/src/api/resources/audio/types/SpeechFlushed.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Server event on GET /v1/audio/stream/ws: the audio for everything sent before an input.flush has been sent. One arrives for every input.flush, in order. + */ +export interface SpeechFlushed { + type: SpeechFlushed.Type; +} + +export namespace SpeechFlushed { + export const Type = { + SpeechFlushed: "speech.flushed", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} diff --git a/src/api/resources/audio/types/index.ts b/src/api/resources/audio/types/index.ts index 40471d7..2adc430 100644 --- a/src/api/resources/audio/types/index.ts +++ b/src/api/resources/audio/types/index.ts @@ -1,2 +1,13 @@ +export * from "./AudioStreamInputModel.js"; +export * from "./AudioStreamInputOutputFormat.js"; +export * from "./AudioStreamInputSpeechMarks.js"; +export * from "./InputClose.js"; +export * from "./InputFlush.js"; +export * from "./InputText.js"; +export * from "./SessionPronunciations.js"; +export * from "./SpeechChunk.js"; +export * from "./SpeechDone.js"; +export * from "./SpeechError.js"; +export * from "./SpeechFlushed.js"; export * from "./StreamAudioRequestAccept.js"; export * from "./StreamWithTimestampsAudioRequestAccept.js"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 98f85e0..3828d38 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -2,6 +2,10 @@ export * from "./audio/client/requests/index.js"; export * as audio from "./audio/index.js"; export * from "./audio/types/index.js"; export * as models from "./models/index.js"; +export * from "./projects/client/requests/index.js"; +export * as projects from "./projects/index.js"; export * from "./voices/client/requests/index.js"; export * as voices from "./voices/index.js"; export * from "./voices/types/index.js"; +export * as webhooks from "./webhooks/index.js"; +export * as workspaces from "./workspaces/index.js"; diff --git a/src/api/resources/models/client/Client.ts b/src/api/resources/models/client/Client.ts index 18dd6f4..c8de01a 100644 --- a/src/api/resources/models/client/Client.ts +++ b/src/api/resources/models/client/Client.ts @@ -61,15 +61,15 @@ export class ModelsClient { _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, "v1/audio/models", ), method: "GET", diff --git a/src/api/resources/projects/client/Client.ts b/src/api/resources/projects/client/Client.ts new file mode 100644 index 0000000..8249fa4 --- /dev/null +++ b/src/api/resources/projects/client/Client.ts @@ -0,0 +1,1371 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import * as environments from "../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as Speechify from "../../../index.js"; + +export declare namespace ProjectsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Workspace resource grouping. A project groups the workspace's resources + * under one label; the implicit Default project holds every resource not + * assigned to one. A project can also carry member grants, which scope a + * granted member to the projects they hold, and it can be named as a + * credential's pin. The invoice stays workspace-level: there is no billing + * split. + */ +export class ProjectsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ProjectsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * List the workspace's projects, newest first. The implicit Default + * project is not a row and is never listed; resources with no + * `project_id` live in it. Archived projects are hidden unless + * `include_archived=true`, and purged ones unless + * `include_purged=true`. Cursor-paginated: omit `cursor` for the + * first page; walk pages while `has_more` is true (default page size + * 50, max 200). + * + * @param {Speechify.ListProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.list() + */ + public async list( + request: Speechify.ListProjectsRequest = {}, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Speechify.ListProjectsRequest, + ): Promise> => { + const { cursor, limit, include_archived: includeArchived, include_purged: includePurged } = request; + const _queryParams: Record = { + cursor, + limit, + include_archived: includeArchived, + include_purged: includePurged, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, + "v1/projects", + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.ListProjectsResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/projects"); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.next_cursor != null && + !(typeof response?.next_cursor === "string" && response?.next_cursor === ""), + getItems: (response) => response?.projects ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "cursor", response?.next_cursor)); + }, + }); + } + + /** + * Create a project in the caller's workspace. Names are unique per + * workspace (case-insensitive). A workspace holds at most 100 live + * projects; at the cap the create refuses with + * `409 project_limit_reached` until one is deleted. + * + * @param {Speechify.CreateProjectRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ConflictError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.create({ + * name: "Production" + * }) + */ + public create( + request: Speechify.CreateProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Speechify.CreateProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + "v1/projects", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.Project, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Speechify.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/projects"); + } + + /** + * Fetch one project by id, scoped to the caller's workspace. Returns + * 404 for missing or foreign-workspace projects — project existence + * is never leaked across workspaces. + * + * @param {Speechify.GetProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.get({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public get( + request: Speechify.GetProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); + } + + private async __get( + request: Speechify.GetProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}`, + ), + method: "GET", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.Project, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/projects/{project_id}"); + } + + /** + * Delete a project. With no body it deletes a project that holds + * nothing, and refuses one that does; `mode` is how you say what + * should happen to what it holds. + * + * **Empty** (no body): the project is removed only while it holds no + * resources. A project that holds any is refused with 409 + * `project_not_empty`, and the refusal enumerates what is inside: + * `error.details.resource_count` is the total, and + * `error.details.contents` names each kind with a count and up to five + * names. Every project row also carries that total as + * `resource_count`, so an application can find the projects it may + * delete in one list call. Records of work never hold a project open + * and are not counted. + * + * **Detach** (`mode: detach`): only the grouping row is removed; every + * resource in the project moves to the implicit Default project, where + * it stays readable and is listed by `?project_id=default`. Refused + * with 409 `project_has_scoped_credentials` while an API key, service + * account, vault credential, webhook endpoint, member grant or pending + * invite is scoped to the project, because detaching any of those + * would silently widen it. + * + * **Purge** (`mode: purge` with `confirm` equal to the project's + * name): available only on an ARCHIVED project, because a teardown + * needs a state you can sit in and reverse first; a live project is + * refused with the coded `409 project_not_archived`. Archive the + * project, confirm it is the one you mean, then purge. The project is + * removed WITH its contents in one transaction: the resources it holds + * and its scoped webhook endpoints and vault credentials are deleted, + * API keys and service accounts pinned to the project are revoked, and + * member grants and pending-invite scopes on the project are cleared. + * Resources with a lifecycle and a delete of their own, such as + * stores, hosted APIs and files, are not removed: they move to the + * Default project, and because they do hold a project open, an + * unqualified delete refuses while any of them is in the project. + * Refused with 409 while a resource that must be released first is + * still attached (the refusal names it), while a member's only project + * grant is this one, or while a live invite carries only this project + * (clearing either would widen that person to the whole workspace, the + * invite one acceptance earlier). + * + * **A purge is recoverable for 30 days.** The project disappears from + * every list and read immediately, and its name is freed for reuse, + * but the project and its resources are kept and permanently deleted + * only once the window closes. `POST + * /v1/projects/{project_id}/restore` brings the project and its + * resources back inside that window; the credentials the purge revoked + * and the grants it cleared stay that way. + * + * The 409 carries the blockers under `error.details.blockers` (`kind`, + * typed `id`, `name`, and the `blocks` modes each refuses), their + * total under `error.details.blocker_count`, and, for existing + * clients, the same rows under `error.details.credentials`. The lists + * are capped at 50 rows; the counts are not, and the refusal is + * decided on the count. + * + * @param {Speechify.DeleteProjectRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.ConflictError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.delete({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * mode: "purge", + * confirm: "Staging" + * }) + */ + public delete( + request: Speechify.DeleteProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( + request: Speechify.DeleteProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}`, + ), + method: "DELETE", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Speechify.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v1/projects/{project_id}"); + } + + /** + * Edit a project in place - its name, its monthly spend limit, or its + * capacity ceilings - keeping the same id so every grouped resource + * follows the edit with no re-pointing. Names are unique per + * workspace (case-insensitive). The limit fields require + * `billing.manage`; a capacity ceiling above the workspace's own is + * refused, since it could never apply. + * + * @param {Speechify.UpdateProjectRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.ConflictError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.update({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public update( + request: Speechify.UpdateProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Speechify.UpdateProjectRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.Project, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Speechify.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/v1/projects/{project_id}"); + } + + /** + * Archive a project. From then on nothing new starts or bills inside + * it: requests on a credential pinned to the project, and every new + * piece of work attributed to it, are refused with the coded `409 + * project_archived`. Work already in flight is left to finish. + * Everything in the project stays readable and its configuration stays + * editable, and the project still answers by id. + * + * Idempotent: archiving an archived project is a no-op. Reverse it + * with the unarchive operation. + * + * @param {Speechify.ArchiveProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.archive({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public archive( + request: Speechify.ArchiveProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__archive(request, requestOptions)); + } + + private async __archive( + request: Speechify.ArchiveProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}/archive`, + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/archive", + ); + } + + /** + * Lift a project's archive so work and spend resume inside it. + * Idempotent: unarchiving a live project is a no-op. + * + * @param {Speechify.UnarchiveProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.unarchive({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public unarchive( + request: Speechify.UnarchiveProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__unarchive(request, requestOptions)); + } + + private async __unarchive( + request: Speechify.UnarchiveProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}/unarchive`, + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/unarchive", + ); + } + + /** + * Walk back a purge. A purged project is recoverable for 30 days: its + * row and its contents are kept, hidden from every list and read, and + * permanently deleted only once the window expires. + * + * **What comes back:** the project and exactly the resources the purge + * removed. A resource you had deleted yourself before the purge stays + * deleted. + * + * **What does NOT come back, on purpose:** every credential the purge + * revoked stays revoked, and every grant it cleared stays cleared. API + * keys and service accounts pinned to the project are not re-issued, + * vault credentials and webhook endpoints scoped to it are not + * undeleted, and member grants and pending-invite scopes are not + * restored. Bringing a credential or a grant back would re-grant + * access somebody deliberately ended, so the restore reports them + * under `still_revoked` instead. Re-create the credentials and + * re-grant the members the project still needs. + * + * The project returns ARCHIVED, the state it was purged from, so + * nothing dispatches or bills inside it until you unarchive it. + * + * Refused with `409 project_not_purged` when the project was never + * purged, `409 project_restore_window_expired` once the 30 days have + * passed, and `409 project_name_taken` when another project has taken + * this one's name since the purge (a purge frees the name immediately + * - rename the project holding it, then restore). + * + * @param {Speechify.RestoreProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.ConflictError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.restore({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public restore( + request: Speechify.RestoreProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__restore(request, requestOptions)); + } + + private async __restore( + request: Speechify.RestoreProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}/restore`, + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.ProjectRestore, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 409: + throw new Speechify.ConflictError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/restore", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Who changed this project's access or its lifecycle state, and when. + * Newest first. Covers the last 90 days; paginate by passing `cursor` + * from the previous response. + * + * Each entry names the SUBJECT (whose access changed) and the ACTOR (who + * changed it), with the role the actor held at the time. When a change + * was made by Speechify support acting on the workspace's behalf, the + * entry also carries that admin's email, so a support-initiated change + * never reads as one a colleague made. + * + * Requires `members.manage_project_scope` (owner or admin): who widened + * a member's access is a stronger fact than who currently holds it. + * Returns 404 for missing or foreign-workspace projects. + * + * @param {Speechify.AuditProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * @throws {@link Speechify.ServiceUnavailableError} + * + * @example + * await client.projects.audit({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public async audit( + request: Speechify.AuditProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Speechify.AuditProjectsRequest, + ): Promise> => { + const { project_id: projectId, cursor, limit } = request; + const _queryParams: Record = { + cursor, + limit, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, + `v1/projects/${core.url.encodePathParam(projectId)}/audit`, + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.ProjectAuditResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 403: + throw new Speechify.ForbiddenError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 503: + throw new Speechify.ServiceUnavailableError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/audit", + ); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.next_cursor != null && + !(typeof response?.next_cursor === "string" && response?.next_cursor === ""), + getItems: (response) => response?.events ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "cursor", response?.next_cursor)); + }, + }); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * List the workspace members granted access to this project, oldest + * grant first. Paginate by passing `cursor` from the previous response. + * + * A member with no grants anywhere is workspace-wide and does not appear + * here: this lists people who have been narrowed to specific projects, + * not everyone who can reach this one. + * + * @param {Speechify.ListMembersProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.listMembers({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public async listMembers( + request: Speechify.ListMembersProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Speechify.ListMembersProjectsRequest, + ): Promise> => { + const { project_id: projectId, cursor, limit } = request; + const _queryParams: Record = { + cursor, + limit, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, + `v1/projects/${core.url.encodePathParam(projectId)}/members`, + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.ProjectMembersResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/members", + ); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.next_cursor != null && + !(typeof response?.next_cursor === "string" && response?.next_cursor === ""), + getItems: (response) => response?.members ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "cursor", response?.next_cursor)); + }, + }); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Grant a workspace member access to this project. Once a member holds + * any grant, they see and touch only the projects they have been granted. + * + * Requires `members.manage_project_scope` (owner or admin). An owner or + * billing admin cannot be scoped: both already hold workspace-wide access + * that a project scope would contradict without restricting anything. + * Idempotent: granting a project the member already holds is a no-op. + * + * @param {Speechify.GrantProjectMemberRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.grantMember({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk" + * }) + */ + public grantMember( + request: Speechify.GrantProjectMemberRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__grantMember(request, requestOptions)); + } + + private async __grantMember( + request: Speechify.GrantProjectMemberRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}/members`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/members", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Remove a member's access to this project. + * + * A member who loses their last grant is not locked out - they return + * to workspace-wide access, because holding no grants is the unrestricted + * state. To restrict someone, grant them the projects they should keep + * rather than revoking everything. Requires `members.manage_project_scope`. + * + * @param {Speechify.RevokeMemberProjectsRequest} request + * @param {ProjectsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.projects.revokeMember({ + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk" + * }) + */ + public revokeMember( + request: Speechify.RevokeMemberProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__revokeMember(request, requestOptions)); + } + + private async __revokeMember( + request: Speechify.RevokeMemberProjectsRequest, + requestOptions?: ProjectsClient.RequestOptions, + ): Promise> { + const { project_id: projectId, user_id: userId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/projects/${core.url.encodePathParam(projectId)}/members/${core.url.encodePathParam(userId)}`, + ), + method: "DELETE", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/v1/projects/{project_id}/members/{user_id}", + ); + } +} diff --git a/src/api/resources/projects/client/index.ts b/src/api/resources/projects/client/index.ts new file mode 100644 index 0000000..195f9aa --- /dev/null +++ b/src/api/resources/projects/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/projects/client/requests/ArchiveProjectsRequest.ts b/src/api/resources/projects/client/requests/ArchiveProjectsRequest.ts new file mode 100644 index 0000000..b7ad973 --- /dev/null +++ b/src/api/resources/projects/client/requests/ArchiveProjectsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface ArchiveProjectsRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; +} diff --git a/src/api/resources/projects/client/requests/AuditProjectsRequest.ts b/src/api/resources/projects/client/requests/AuditProjectsRequest.ts new file mode 100644 index 0000000..3a06c87 --- /dev/null +++ b/src/api/resources/projects/client/requests/AuditProjectsRequest.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface AuditProjectsRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; + /** Opaque pagination cursor from a previous response. */ + cursor?: string; + /** Max items per page (default 50, max 200). */ + limit?: number; +} diff --git a/src/api/resources/projects/client/requests/CreateProjectRequest.ts b/src/api/resources/projects/client/requests/CreateProjectRequest.ts new file mode 100644 index 0000000..afcb215 --- /dev/null +++ b/src/api/resources/projects/client/requests/CreateProjectRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * name: "Production" + * } + */ +export interface CreateProjectRequest { + /** + * Project name; unique per workspace (case-insensitive), + * surrounding whitespace is trimmed. + */ + name: string; +} diff --git a/src/api/resources/projects/client/requests/DeleteProjectRequest.ts b/src/api/resources/projects/client/requests/DeleteProjectRequest.ts new file mode 100644 index 0000000..6eff5be --- /dev/null +++ b/src/api/resources/projects/client/requests/DeleteProjectRequest.ts @@ -0,0 +1,38 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * mode: "purge", + * confirm: "Staging" + * } + */ +export interface DeleteProjectRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; + /** + * `detach` removes the grouping row only and moves every resource + * to the Default project; `purge` removes the project with its + * contents. Omitted, the delete removes only an empty project. + */ + mode?: DeleteProjectRequest.Mode; + /** + * Required for `purge`: the project's name, exactly as returned by + * GET. A mismatch answers 400 `validation_failed` naming this field. + */ + confirm?: string; +} + +export namespace DeleteProjectRequest { + /** + * `detach` removes the grouping row only and moves every resource + * to the Default project; `purge` removes the project with its + * contents. Omitted, the delete removes only an empty project. + */ + export const Mode = { + Detach: "detach", + Purge: "purge", + } as const; + export type Mode = (typeof Mode)[keyof typeof Mode]; +} diff --git a/src/api/resources/projects/client/requests/GetProjectsRequest.ts b/src/api/resources/projects/client/requests/GetProjectsRequest.ts new file mode 100644 index 0000000..aed28fa --- /dev/null +++ b/src/api/resources/projects/client/requests/GetProjectsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface GetProjectsRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; +} diff --git a/src/api/resources/projects/client/requests/GrantProjectMemberRequest.ts b/src/api/resources/projects/client/requests/GrantProjectMemberRequest.ts new file mode 100644 index 0000000..a7cb2d6 --- /dev/null +++ b/src/api/resources/projects/client/requests/GrantProjectMemberRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk" + * } + */ +export interface GrantProjectMemberRequest { + /** Project ID. */ + project_id: string; + /** The prefixed user id of the workspace member to grant. */ + user_id: string; +} diff --git a/src/api/resources/projects/client/requests/ListMembersProjectsRequest.ts b/src/api/resources/projects/client/requests/ListMembersProjectsRequest.ts new file mode 100644 index 0000000..f0adbae --- /dev/null +++ b/src/api/resources/projects/client/requests/ListMembersProjectsRequest.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface ListMembersProjectsRequest { + /** Project ID. */ + project_id: string; + /** Opaque pagination cursor from a previous response. */ + cursor?: string; + /** Max items per page (default 50, max 200). */ + limit?: number; +} diff --git a/src/api/resources/projects/client/requests/ListProjectsRequest.ts b/src/api/resources/projects/client/requests/ListProjectsRequest.ts new file mode 100644 index 0000000..2d48dd6 --- /dev/null +++ b/src/api/resources/projects/client/requests/ListProjectsRequest.ts @@ -0,0 +1,29 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface ListProjectsRequest { + /** Opaque pagination cursor from a previous response. */ + cursor?: string; + /** Max items per page (default 50, max 200). */ + limit?: number; + /** + * Include archived projects. Defaults to `false`, so the list shows + * only live projects; archived ones stay readable by id. + */ + include_archived?: boolean; + /** + * Include purged projects that are still inside their 30-day restore + * window, each carrying the `purged_at` stamp its deadline is + * measured from. Defaults to `false`, so the list shows only projects + * that still exist. This is the only read that returns a purged + * project: the by-id read answers 404 for one, and a project past its + * window is never listed, because it is awaiting permanent deletion + * and a restore would refuse it. Independent of `include_archived`: + * a purge runs only from the archived state, so asking for purged + * projects never means asking for every archived one as well. + */ + include_purged?: boolean; +} diff --git a/src/api/resources/projects/client/requests/RestoreProjectsRequest.ts b/src/api/resources/projects/client/requests/RestoreProjectsRequest.ts new file mode 100644 index 0000000..8b60950 --- /dev/null +++ b/src/api/resources/projects/client/requests/RestoreProjectsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface RestoreProjectsRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; +} diff --git a/src/api/resources/projects/client/requests/RevokeMemberProjectsRequest.ts b/src/api/resources/projects/client/requests/RevokeMemberProjectsRequest.ts new file mode 100644 index 0000000..dbbaa7a --- /dev/null +++ b/src/api/resources/projects/client/requests/RevokeMemberProjectsRequest.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + * user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk" + * } + */ +export interface RevokeMemberProjectsRequest { + /** Project ID. */ + project_id: string; + /** The member's prefixed user id, as returned by the members list. */ + user_id: string; +} diff --git a/src/api/resources/projects/client/requests/UnarchiveProjectsRequest.ts b/src/api/resources/projects/client/requests/UnarchiveProjectsRequest.ts new file mode 100644 index 0000000..e219d50 --- /dev/null +++ b/src/api/resources/projects/client/requests/UnarchiveProjectsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface UnarchiveProjectsRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; +} diff --git a/src/api/resources/projects/client/requests/UpdateProjectRequest.ts b/src/api/resources/projects/client/requests/UpdateProjectRequest.ts new file mode 100644 index 0000000..aeaeea8 --- /dev/null +++ b/src/api/resources/projects/client/requests/UpdateProjectRequest.ts @@ -0,0 +1,42 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface UpdateProjectRequest { + /** Project id (prefixed external id, `proj_...`). */ + project_id: string; + /** + * Sets the project's request-rate ceiling in requests per + * minute; `null` removes it. Must be a positive integer at or + * below the workspace's widest per-surface request rate over a + * minute, otherwise the request is refused with + * `400 validation_failed` naming the field and the ceiling. + * Requires the `billing.manage` permission. Takes effect on the + * next request from a credential pinned to the project. + */ + max_requests_per_minute?: number | null; + /** + * New project name; unique per workspace (case-insensitive), + * surrounding whitespace is trimmed. + */ + name?: string; + /** + * Edits the project's MONTHLY spend limit in US dollars: omit to + * leave it unchanged, send a positive value to set or change it, or + * an explicit `0` to remove it. Amounts are whole cents written as a + * plain decimal; a finer value, or exponent notation, is refused + * rather than rounded. Requires the + * `billing.manage` + * permission (owners/admins), like the workspace budget — a + * spend ceiling is a billing control, not a grouping edit. Once the + * project's billed spend within the current calendar month (UTC) + * reaches the limit, new billable work attributed to that project is + * refused with the coded `402 project_spend_limit_exceeded` until + * the month resets or the limit is raised. + */ + monthly_budget?: number; +} diff --git a/src/api/resources/projects/client/requests/index.ts b/src/api/resources/projects/client/requests/index.ts new file mode 100644 index 0000000..2f73d4d --- /dev/null +++ b/src/api/resources/projects/client/requests/index.ts @@ -0,0 +1,12 @@ +export type { ArchiveProjectsRequest } from "./ArchiveProjectsRequest.js"; +export type { AuditProjectsRequest } from "./AuditProjectsRequest.js"; +export type { CreateProjectRequest } from "./CreateProjectRequest.js"; +export { DeleteProjectRequest } from "./DeleteProjectRequest.js"; +export type { GetProjectsRequest } from "./GetProjectsRequest.js"; +export type { GrantProjectMemberRequest } from "./GrantProjectMemberRequest.js"; +export type { ListMembersProjectsRequest } from "./ListMembersProjectsRequest.js"; +export type { ListProjectsRequest } from "./ListProjectsRequest.js"; +export type { RestoreProjectsRequest } from "./RestoreProjectsRequest.js"; +export type { RevokeMemberProjectsRequest } from "./RevokeMemberProjectsRequest.js"; +export type { UnarchiveProjectsRequest } from "./UnarchiveProjectsRequest.js"; +export type { UpdateProjectRequest } from "./UpdateProjectRequest.js"; diff --git a/src/api/resources/projects/exports.ts b/src/api/resources/projects/exports.ts new file mode 100644 index 0000000..5fa9c02 --- /dev/null +++ b/src/api/resources/projects/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { ProjectsClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/projects/index.ts b/src/api/resources/projects/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/projects/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/voices/client/Client.ts b/src/api/resources/voices/client/Client.ts index 9226485..9c28edd 100644 --- a/src/api/resources/voices/client/Client.ts +++ b/src/api/resources/voices/client/Client.ts @@ -34,13 +34,20 @@ export class VoicesClient { /** * Lists the voices available to the caller - the shared voice - * catalog plus the workspace's cloned voices, whichever member or - * service-account key created them. By default - * the full catalogue is returned in one response. Pagination is - * opt-in: pass `limit` (and then `cursor` from the previous - * response) to page through the list while `has_more` is true. Max - * page size is 200. Narrow the list with the `type` and `locale` - * filters (applied before pagination, so pages stay full). + * catalog plus the cloned voices they can reach, whichever member or + * service-account key created them. A clone filed under a project is + * listed only for a caller who can reach that project; a clone no + * project filed is shared with the whole workspace and is listed for + * everyone in it. The list is paged: a request without `limit` + * returns the first 50 voices, and `limit` raises that to at most + * 200. Pass `cursor` from the previous response to fetch the next + * page while `has_more` is true. API versions before 2026-07-16 + * returned the whole catalogue when `limit` was omitted. Narrow the + * list with the `type` and `locale` filters. + * + * A page can come back with fewer than `limit` voices, and a short + * page - an empty one included - is not the end of the list. Keep + * following `next_cursor` while `has_more` is true. * * @param {Speechify.ListVoicesRequest} request * @param {VoicesClient.RequestOptions} requestOptions - Request-specific configuration. @@ -54,7 +61,8 @@ export class VoicesClient { * @example * await client.voices.list({ * locale: "en", - * model: "simba-3.2" + * model: "simba-3.2", + * project_id: "proj_01arz3ndektsv4rrffq69g5fav" * }) */ public async list( @@ -65,7 +73,7 @@ export class VoicesClient { async ( request: Speechify.ListVoicesRequest, ): Promise> => { - const { cursor, limit, type: type_, locale, gender, model } = request; + const { cursor, limit, type: type_, locale, gender, model, project_id: projectId } = request; const _queryParams: Record = { cursor, limit, @@ -73,21 +81,24 @@ export class VoicesClient { locale, gender: gender != null ? gender : undefined, model, + project_id: projectId, }; const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); const _headers: core.Fetcher.Args["headers"] = mergeHeaders( _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, "v1/voices", ), method: "GET", @@ -160,9 +171,11 @@ export class VoicesClient { * * Cloning requires proof that the speaker agreed to it. Create a consent challenge with `POST /v1/voices/consent-challenges`, show the returned `phrase` to the speaker, record them reading it aloud, and send that recording here as `consent_recording` together with the challenge's `consent_challenge_id`. Speechify transcribes the recording, checks it against the phrase it issued, checks that its speaker is the speaker in your `sample`, and keeps it as the consent record for the voice. The person consenting therefore has to be the person being cloned. A challenge is single use and short-lived, so record and submit in one sitting. * - * The clone belongs to the workspace rather than the member who created it, and access follows the caller's workspace role and API-key scopes exactly as for any other voice: voices scopes to list it, audio scopes to synthesize with it, and the content-management permission plus a write scope on the key to delete it. Cloned voices are usable self-serve on `simba-3.0`, `simba-english` and `simba-multilingual`. `simba-3.2` also serves cloned voices, currently as a limited release enabled per workspace; contact Speechify to have it enabled for yours. + * The clone belongs to the workspace rather than the member who created it, and access follows the caller's workspace role and API-key scopes exactly as for any other voice: voices scopes to list it, audio scopes to synthesize with it, and the content-management permission plus a write scope on the key to delete it. Cloned voices are usable self-serve on `simba-3.0` (and, on a workspace pinned before API version `2026-09-21`, on the retired `simba-english` and `simba-multilingual`, which from 2026-11-21 are served by our current models and still take cloned voices). `simba-3.2` and `simba-3.5` also serve cloned voices. + * + * The previous flow, a `consent` form field carrying the speaker's name and email as a JSON string, was switched off on 2026-09-23 for every API version: a create that sends `consent` and no `consent_challenge_id` returns 400 `consent_verification_required`. * - * Callers pinned before `Speechify-Version: 2026-09-13` use the previous flow instead: no challenge, and a `consent` form field carrying the speaker's name and email as a JSON string. That flow is deprecated and will be removed after a sunset window announced in the changelog. + * Voice cloning is not available in some jurisdictions. A request from one returns 403 `voice_cloning_unavailable_in_region` before consent verification runs, so it does not spend the challenge. The location is read from the IP address that sends the request, which is your server's when your backend calls the API; a location header in the request is ignored. * * @param {Speechify.CreateVoicesRequest} request * @param {VoicesClient.RequestOptions} requestOptions - Request-specific configuration. @@ -222,7 +235,7 @@ export class VoicesClient { this._options?.headers, mergeOnlyDefinedHeaders({ "Idempotency-Key": request["Idempotency-Key"], - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", ..._maybeEncodedRequest.headers, }), requestOptions?.headers, @@ -230,8 +243,8 @@ export class VoicesClient { const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, "v1/voices", ), method: "POST", @@ -346,15 +359,15 @@ export class VoicesClient { _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, `v1/voices/${core.url.encodePathParam(voiceId)}`, ), method: "GET", @@ -415,6 +428,10 @@ export class VoicesClient { * `content.manage` permission (owner, admin, or member); a * service-account key is authorized by its scopes instead. * + * A voice that is also a member's personal voice (one cloned + * before workspaces owned voices and adopted into this workspace) + * is removed from the workspace only; the person keeps it. + * * @param {Speechify.DeleteVoicesRequest} request * @param {VoicesClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -449,15 +466,15 @@ export class VoicesClient { _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, `v1/voices/${core.url.encodePathParam(voiceId)}`, ), method: "DELETE", @@ -544,15 +561,15 @@ export class VoicesClient { _authRequest.headers, this._options?.headers, mergeOnlyDefinedHeaders({ - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, `v1/voices/${core.url.encodePathParam(voiceId)}/sample`, ), method: "GET", diff --git a/src/api/resources/voices/client/requests/ListVoicesRequest.ts b/src/api/resources/voices/client/requests/ListVoicesRequest.ts index 6c727dc..2f73dd7 100644 --- a/src/api/resources/voices/client/requests/ListVoicesRequest.ts +++ b/src/api/resources/voices/client/requests/ListVoicesRequest.ts @@ -6,7 +6,8 @@ import type * as Speechify from "../../../../index.js"; * @example * { * locale: "en", - * model: "simba-3.2" + * model: "simba-3.2", + * project_id: "proj_01arz3ndektsv4rrffq69g5fav" * } */ export interface ListVoicesRequest { @@ -32,4 +33,21 @@ export interface ListVoicesRequest { * `models[]`), e.g. `simba-3.2`. Omit to return voices for all models. */ model?: string; + /** + * Filter cloned voices by workspace project: omit for every voice you + * can reach, pass the literal `shared` for the clones no project + * filed, or a `proj_...` id for the clones filed under that project. + * The shared catalog carries no project and is returned either way. + * + * A clone is filed under a project when a project-pinned key created + * it. A clone with no project is shared with the whole workspace + * rather than sitting in a Default project, so the literal here is + * `shared`, never `default` - passing `default` is a 400. Returns 404 + * project_not_found for a malformed id and for any project outside + * your reach: a project-pinned key reaches only its pinned project, + * and a member holding project grants reaches only the granted ones. + * That 404 is the same in every case and does not reveal whether such + * a project exists. `shared` is always inside your reach. + */ + project_id?: string; } diff --git a/src/api/resources/voices/resources/consentChallenges/client/Client.ts b/src/api/resources/voices/resources/consentChallenges/client/Client.ts index f36fc04..92f238a 100644 --- a/src/api/resources/voices/resources/consentChallenges/client/Client.ts +++ b/src/api/resources/voices/resources/consentChallenges/client/Client.ts @@ -31,6 +31,8 @@ export class ConsentChallengesClient { * * Challenge creation is rate limited per workspace at a few dozen per hour, far more tightly than the rest of the voice surface, because each one precedes a person recording themselves - mint it when your speaker is ready, not speculatively. Read the live ceiling off `RateLimit-*` rather than hard-coding it. **On a `429`, always honour `Retry-After` rather than a fixed backoff of your own**: the wait is measured in minutes and can run to most of an hour. `RateLimit-*` are omitted rather than reporting a bucket that is not the one refusing. * + * Like `POST /v1/voices`, a challenge requested from a jurisdiction where voice cloning is not available returns 403 `voice_cloning_unavailable_in_region` and issues no phrase. The location is read from the IP address that sends the request, which is your server's when your backend calls the API. + * * @param {Speechify.voices.CreateConsentChallengeRequest} request * @param {ConsentChallengesClient.RequestOptions} requestOptions - Request-specific configuration. * @@ -68,15 +70,15 @@ export class ConsentChallengesClient { this._options?.headers, mergeOnlyDefinedHeaders({ "Idempotency-Key": idempotencyKey, - "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-13", + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", }), requestOptions?.headers, ); const _response = await core.fetcher({ url: core.url.join( (await core.Supplier.get(this._options.baseUrl)) ?? - (await core.Supplier.get(this._options.environment)) ?? - environments.SpeechifyEnvironment.Default, + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, "v1/voices/consent-challenges", ), method: "POST", diff --git a/src/api/resources/webhooks/client/Client.ts b/src/api/resources/webhooks/client/Client.ts new file mode 100644 index 0000000..dd1e1a6 --- /dev/null +++ b/src/api/resources/webhooks/client/Client.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { EndpointsClient } from "../resources/endpoints/client/Client.js"; + +export declare namespace WebhooksClient { + export type Options = BaseClientOptions; +} + +export class WebhooksClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + protected _endpoints: EndpointsClient | undefined; + + constructor(options: WebhooksClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + public get endpoints(): EndpointsClient { + return (this._endpoints ??= new EndpointsClient(this._options)); + } +} diff --git a/src/api/resources/webhooks/client/index.ts b/src/api/resources/webhooks/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/webhooks/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/webhooks/exports.ts b/src/api/resources/webhooks/exports.ts new file mode 100644 index 0000000..e0b5d46 --- /dev/null +++ b/src/api/resources/webhooks/exports.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +export { WebhooksClient } from "./client/Client.js"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/webhooks/index.ts b/src/api/resources/webhooks/index.ts new file mode 100644 index 0000000..9eb1192 --- /dev/null +++ b/src/api/resources/webhooks/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/webhooks/resources/endpoints/client/Client.ts b/src/api/resources/webhooks/resources/endpoints/client/Client.ts new file mode 100644 index 0000000..34791f4 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/Client.ts @@ -0,0 +1,781 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../../../core/headers.js"; +import * as core from "../../../../../../core/index.js"; +import * as environments from "../../../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../../../errors/index.js"; +import * as Speechify from "../../../../../index.js"; + +export declare namespace EndpointsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class EndpointsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: EndpointsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * The caller's workspace's registered webhook endpoints. Cursor-paginated: + * omit `cursor` for the first page; walk pages while `has_more` is true + * (default page size 50, max 200). The signing `secret` is never returned + * here — it is shown only when an endpoint is created or its secret is + * rotated. Filter by delivery scope with `project_id`. + * + * @param {Speechify.webhooks.ListEndpointsRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.list({ + * project_id: "proj_01arz3ndektsv4rrffq69g5fav" + * }) + */ + public async list( + request: Speechify.webhooks.ListEndpointsRequest = {}, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Speechify.webhooks.ListEndpointsRequest, + ): Promise> => { + const { cursor, limit, project_id: projectId } = request; + const _queryParams: Record = { + cursor, + limit, + project_id: projectId, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, + "v1/webhooks/endpoints", + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.ListWebhookEndpointsResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/webhooks/endpoints", + ); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.next_cursor != null && + !(typeof response?.next_cursor === "string" && response?.next_cursor === ""), + getItems: (response) => response?.endpoints ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "cursor", response?.next_cursor)); + }, + }); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Register a webhook endpoint. Speechify mints an HMAC signing secret + * and returns it in the response `secret` field — exactly once. Store it + * then; subsequent reads omit it (rotate it with the rotate-secret action + * if lost). Select events via `enabled_events`: a list of catalog event + * names or `["*"]` for every event. Optionally scope delivery to one + * project with `project_id`; omit it for a workspace-wide endpoint that + * receives every project's events. Limited to 50 endpoints per workspace. + * + * @param {Speechify.webhooks.CreateWebhookEndpointRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.UnprocessableEntityError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.create({ + * url: "https://example.com/speechify/webhooks", + * enabled_events: ["project.spend_budget.warning"], + * description: "Example description." + * }) + */ + public create( + request: Speechify.webhooks.CreateWebhookEndpointRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Speechify.webhooks.CreateWebhookEndpointRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + "v1/webhooks/endpoints", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: request, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.WebhookEndpoint, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 422: + throw new Speechify.UnprocessableEntityError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/webhooks/endpoints"); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Fetch a webhook endpoint by id. The signing secret is never returned. + * + * @param {Speechify.webhooks.GetEndpointsRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.get({ + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public get( + request: Speechify.webhooks.GetEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(request, requestOptions)); + } + + private async __get( + request: Speechify.webhooks.GetEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const { webhook_endpoint_id: webhookEndpointId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/webhooks/endpoints/${core.url.encodePathParam(webhookEndpointId)}`, + ), + method: "GET", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.WebhookEndpoint, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/webhooks/endpoints/{webhook_endpoint_id}", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Delete a webhook endpoint. In-flight deliveries stop; returns 204 on success. + * + * @param {Speechify.webhooks.DeleteEndpointsRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.delete({ + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public delete( + request: Speechify.webhooks.DeleteEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions)); + } + + private async __delete( + request: Speechify.webhooks.DeleteEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const { webhook_endpoint_id: webhookEndpointId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/webhooks/endpoints/${core.url.encodePathParam(webhookEndpointId)}`, + ), + method: "DELETE", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/v1/webhooks/endpoints/{webhook_endpoint_id}", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Partial update; omitted fields are left unchanged. Set `disabled` to pause delivery without deleting the endpoint. + * + * @param {Speechify.webhooks.UpdateWebhookEndpointRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.update({ + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + * url: "https://example.com/webhook", + * enabled_events: ["example"], + * description: "Example description.", + * disabled: false + * }) + */ + public update( + request: Speechify.webhooks.UpdateWebhookEndpointRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(request, requestOptions)); + } + + private async __update( + request: Speechify.webhooks.UpdateWebhookEndpointRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const { webhook_endpoint_id: webhookEndpointId, ..._body } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/webhooks/endpoints/${core.url.encodePathParam(webhookEndpointId)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + requestType: "json", + body: _body, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.WebhookEndpoint, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PATCH", + "/v1/webhooks/endpoints/{webhook_endpoint_id}", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Mint a new HMAC signing secret for the endpoint and return it in the + * response `secret` field (shown exactly once). The previous secret stops + * signing immediately, so accept both during your cutover window. + * + * @param {Speechify.webhooks.RotateSecretEndpointsRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.ForbiddenError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.rotateSecret({ + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public rotateSecret( + request: Speechify.webhooks.RotateSecretEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__rotateSecret(request, requestOptions)); + } + + private async __rotateSecret( + request: Speechify.webhooks.RotateSecretEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const { webhook_endpoint_id: webhookEndpointId } = request; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + `v1/webhooks/endpoints/${core.url.encodePathParam(webhookEndpointId)}/rotate-secret`, + ), + method: "POST", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.WebhookEndpoint, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 403: + throw new Speechify.ForbiddenError(_response.error.body as Speechify.Error_, _response.rawResponse); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/webhooks/endpoints/{webhook_endpoint_id}/rotate-secret", + ); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * Delivery attempts for one webhook endpoint, newest first. One row per + * (endpoint, event, resource), updated in place across retries. Each row + * includes the exact request payload and signed headers Speechify sent + * (`request_body`, `request_headers`) and the response your server returned + * (`last_status_code`, `last_response_body`, `last_response_headers`), so + * you can verify the signature and debug failures. Cursor-paginated: omit + * `cursor` for the first page; walk pages while `has_more` is true (default + * page size 50, max 200). + * + * An endpoint that was not a target of an event has no row for it: a + * project-scoped endpoint records nothing for another project's events. + * An empty list therefore means either nothing matched or nothing + * happened. To tell them apart, check the project's own activity first: + * activity there with no delivery here is a defect to report; none there + * means there was nothing to deliver. + * + * @param {Speechify.webhooks.ListDeliveriesEndpointsRequest} request + * @param {EndpointsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.BadRequestError} + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.NotFoundError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.webhooks.endpoints.listDeliveries({ + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * }) + */ + public async listDeliveries( + request: Speechify.webhooks.ListDeliveriesEndpointsRequest, + requestOptions?: EndpointsClient.RequestOptions, + ): Promise> { + const list = core.HttpResponsePromise.interceptFunction( + async ( + request: Speechify.webhooks.ListDeliveriesEndpointsRequest, + ): Promise> => { + const { webhook_endpoint_id: webhookEndpointId, cursor, limit } = request; + const _queryParams: Record = { + cursor, + limit, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.SpeechifyEnvironment.Default + ).base, + `v1/webhooks/endpoints/${core.url.encodePathParam(webhookEndpointId)}/deliveries`, + ), + method: "GET", + headers: _headers, + queryString: core.url + .queryBuilder() + .addMany(_queryParams) + .mergeAdditional(requestOptions?.queryParams) + .build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: _response.body as Speechify.ListWebhookEndpointDeliveriesResponse, + rawResponse: _response.rawResponse, + }; + } + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Speechify.BadRequestError(_response.error.body as unknown, _response.rawResponse); + case 401: + throw new Speechify.UnauthorizedError( + _response.error.body as unknown, + _response.rawResponse, + ); + case 404: + throw new Speechify.NotFoundError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/webhooks/endpoints/{webhook_endpoint_id}/deliveries", + ); + }, + ); + const dataWithRawResponse = await list(request).withRawResponse(); + return new core.Page({ + response: dataWithRawResponse.data, + rawResponse: dataWithRawResponse.rawResponse, + hasNextPage: (response) => + response?.next_cursor != null && + !(typeof response?.next_cursor === "string" && response?.next_cursor === ""), + getItems: (response) => response?.deliveries ?? [], + loadPage: (response) => { + return list(core.setObjectProperty(request, "cursor", response?.next_cursor)); + }, + }); + } +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/index.ts b/src/api/resources/webhooks/resources/endpoints/client/index.ts new file mode 100644 index 0000000..195f9aa --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/CreateWebhookEndpointRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/CreateWebhookEndpointRequest.ts new file mode 100644 index 0000000..7cf0983 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/CreateWebhookEndpointRequest.ts @@ -0,0 +1,41 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * url: "https://example.com/speechify/webhooks", + * enabled_events: ["project.spend_budget.warning"], + * description: "Example description." + * } + */ +export interface CreateWebhookEndpointRequest { + /** + * HTTPS destination for event deliveries. Must be a publicly + * reachable host: loopback, private, link-local, and cloud-metadata + * addresses (and reserved hostnames like `localhost`) are rejected. + */ + url: string; + /** + * Optionally scope the endpoint to one project (prefixed + * `proj_...` id): a scoped endpoint receives only that project's + * events. Omit (or null) for workspace-wide - it receives every + * project's events. An unknown id returns 404 project_not_found. + * A project-pinned API key creates into its own project and + * cannot name the workspace-wide tier. + */ + project_id?: string | null; + /** Catalog event names to subscribe to, or `["*"]` for all events. */ + enabled_events: string[]; + /** + * Optional payload-shaping keys (see `WebhookEndpoint.include`). + * Omit for the lean default. + */ + include?: string[]; + /** + * Optionally pin the endpoint's payload shape to a dated version + * (`YYYY-MM-DD`, see `WebhookEndpoint.api_version`). Omit to use the + * workspace's current version. An unknown version is rejected. + */ + api_version?: string; + description?: string | null; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/DeleteEndpointsRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/DeleteEndpointsRequest.ts new file mode 100644 index 0000000..016d2b4 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/DeleteEndpointsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface DeleteEndpointsRequest { + /** Webhook endpoint id (prefixed `whe_…`). */ + webhook_endpoint_id: string; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/GetEndpointsRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/GetEndpointsRequest.ts new file mode 100644 index 0000000..e8e97e3 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/GetEndpointsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface GetEndpointsRequest { + /** Webhook endpoint id (prefixed `whe_…`). */ + webhook_endpoint_id: string; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/ListDeliveriesEndpointsRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/ListDeliveriesEndpointsRequest.ts new file mode 100644 index 0000000..d13db26 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/ListDeliveriesEndpointsRequest.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface ListDeliveriesEndpointsRequest { + /** Webhook endpoint id (prefixed `whe_…`). */ + webhook_endpoint_id: string; + /** Opaque pagination cursor from a previous response. */ + cursor?: string; + /** Max items per page (default 50, max 200). */ + limit?: number; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/ListEndpointsRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/ListEndpointsRequest.ts new file mode 100644 index 0000000..9fef1be --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/ListEndpointsRequest.ts @@ -0,0 +1,31 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * project_id: "proj_01arz3ndektsv4rrffq69g5fav" + * } + */ +export interface ListEndpointsRequest { + /** Opaque pagination cursor from a previous response. */ + cursor?: string; + /** Max items per page (default 50, max 200). */ + limit?: number; + /** + * Filter endpoints by project scope: omit for everything the caller + * may see, pass the literal `shared` for workspace-wide endpoints + * only, or a `proj_...` id for endpoints scoped to that project. + * Endpoints have no Default project - a null `project_id` means + * workspace-wide, so the literal here is `shared`, never `default`. + * Returns 404 project_not_found for a malformed id and for any + * project outside your reach: a project-pinned API key or + * service-account key reaches only its pinned project, and a member + * holding project grants reaches only the granted projects. That 404 + * is the same in every case and does not reveal whether such a + * project exists - outside your reach a project is answered as + * nonexistent, never as forbidden. `shared` is always inside your + * reach. Inside it, a well-formed id that matches nothing yields an + * empty page. + */ + project_id?: string; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/RotateSecretEndpointsRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/RotateSecretEndpointsRequest.ts new file mode 100644 index 0000000..65fcc21 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/RotateSecretEndpointsRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t" + * } + */ +export interface RotateSecretEndpointsRequest { + /** Webhook endpoint id (prefixed `whe_…`). */ + webhook_endpoint_id: string; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/UpdateWebhookEndpointRequest.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/UpdateWebhookEndpointRequest.ts new file mode 100644 index 0000000..a3b9299 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/UpdateWebhookEndpointRequest.ts @@ -0,0 +1,46 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + * url: "https://example.com/webhook", + * enabled_events: ["example"], + * description: "Example description.", + * disabled: false + * } + */ +export interface UpdateWebhookEndpointRequest { + /** Webhook endpoint id (prefixed `whe_…`). */ + webhook_endpoint_id: string; + /** + * HTTPS destination for event deliveries. Must be a publicly + * reachable host: loopback, private, link-local, and cloud-metadata + * addresses (and reserved hostnames like `localhost`) are rejected. + */ + url?: string; + /** + * Re-scope the endpoint: a `proj_...` id narrows it to that + * project's events, an explicit null makes it workspace-wide + * (every project's events), omitted leaves it unchanged. The + * signing secret and delivery history are untouched, so + * re-scoping never requires redeploying your receiver. An + * unknown id returns 404 project_not_found. A project-pinned API + * key may only scope an endpoint to its own project. + */ + project_id?: string | null; + enabled_events?: string[]; + /** + * Payload-shaping keys (see `WebhookEndpoint.include`). Send `[]` to + * clear back to the lean default. + */ + include?: string[]; + /** + * Opt the endpoint into a different (typically newer) payload shape + * (`YYYY-MM-DD`, see `WebhookEndpoint.api_version`). Omit to leave it + * unchanged. An unknown version is rejected. + */ + api_version?: string; + description?: string | null; + disabled?: boolean; +} diff --git a/src/api/resources/webhooks/resources/endpoints/client/requests/index.ts b/src/api/resources/webhooks/resources/endpoints/client/requests/index.ts new file mode 100644 index 0000000..cbee744 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/client/requests/index.ts @@ -0,0 +1,7 @@ +export type { CreateWebhookEndpointRequest } from "./CreateWebhookEndpointRequest.js"; +export type { DeleteEndpointsRequest } from "./DeleteEndpointsRequest.js"; +export type { GetEndpointsRequest } from "./GetEndpointsRequest.js"; +export type { ListDeliveriesEndpointsRequest } from "./ListDeliveriesEndpointsRequest.js"; +export type { ListEndpointsRequest } from "./ListEndpointsRequest.js"; +export type { RotateSecretEndpointsRequest } from "./RotateSecretEndpointsRequest.js"; +export type { UpdateWebhookEndpointRequest } from "./UpdateWebhookEndpointRequest.js"; diff --git a/src/api/resources/webhooks/resources/endpoints/exports.ts b/src/api/resources/webhooks/resources/endpoints/exports.ts new file mode 100644 index 0000000..57505de --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { EndpointsClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/webhooks/resources/endpoints/index.ts b/src/api/resources/webhooks/resources/endpoints/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/webhooks/resources/endpoints/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/webhooks/resources/index.ts b/src/api/resources/webhooks/resources/index.ts new file mode 100644 index 0000000..8667dc4 --- /dev/null +++ b/src/api/resources/webhooks/resources/index.ts @@ -0,0 +1,2 @@ +export * from "./endpoints/client/requests/index.js"; +export * as endpoints from "./endpoints/index.js"; diff --git a/src/api/resources/workspaces/client/Client.ts b/src/api/resources/workspaces/client/Client.ts new file mode 100644 index 0000000..2443b50 --- /dev/null +++ b/src/api/resources/workspaces/client/Client.ts @@ -0,0 +1,126 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import * as environments from "../../../../environments.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as Speechify from "../../../index.js"; + +export declare namespace WorkspacesClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +/** + * Workspace management - members, invites, ownership, and billing + * contact. Session-authenticated (console session token); the + * `X-Tenant-ID` header selects the active workspace for endpoints + * that read/write workspace-scoped data. A header naming a workspace the + * caller is not a member of falls back to their default workspace on a + * read; every write under `/v1/workspaces/current` refuses it with 403, so + * a change can never land on a workspace the caller did not name. + */ +export class WorkspacesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: WorkspacesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @beta This endpoint is in pre-release and may change. + * + * The per-tier entitlements catalog plus the caller's RESOLVED + * entitlements for the current workspace (tier defaults composed with + * any per-tenant override). Readable with an API key as well as a + * console session: it is how an integration learns what it may use + * before a feature endpoint answers `402`. Branch on + * `current.voice_cloning` and `current.hosted_apis_access`, and size + * traffic from + * `current.tts_requests_per_second` and `current.tts_concurrency`. The + * console renders quota affordances and upgrade-card limits from the + * same single server-authoritative source instead of a hardcoded + * mirror. + * + * @param {WorkspacesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Speechify.UnauthorizedError} + * @throws {@link Speechify.TooManyRequestsError} + * @throws {@link Speechify.InternalServerError} + * + * @example + * await client.workspaces.getEntitlements() + */ + public getEntitlements( + requestOptions?: WorkspacesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__getEntitlements(requestOptions)); + } + + private async __getEntitlements( + requestOptions?: WorkspacesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ + "Speechify-Version": requestOptions?.version ?? this._options?.version ?? "2026-09-30", + }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ((await core.Supplier.get(this._options.environment)) ?? environments.SpeechifyEnvironment.Default) + .base, + "v1/workspaces/current/entitlements", + ), + method: "GET", + headers: _headers, + queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: _response.body as Speechify.EntitlementsResponse, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 401: + throw new Speechify.UnauthorizedError(_response.error.body as unknown, _response.rawResponse); + case 429: + throw new Speechify.TooManyRequestsError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + case 500: + throw new Speechify.InternalServerError( + _response.error.body as Speechify.Error_, + _response.rawResponse, + ); + default: + throw new errors.SpeechifyError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/workspaces/current/entitlements", + ); + } +} diff --git a/src/api/resources/workspaces/client/index.ts b/src/api/resources/workspaces/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/workspaces/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/workspaces/exports.ts b/src/api/resources/workspaces/exports.ts new file mode 100644 index 0000000..86d5506 --- /dev/null +++ b/src/api/resources/workspaces/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { WorkspacesClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/workspaces/index.ts b/src/api/resources/workspaces/index.ts new file mode 100644 index 0000000..914b8c3 --- /dev/null +++ b/src/api/resources/workspaces/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/types/AudioOutputFormat.ts b/src/api/types/AudioOutputFormat.ts index f1c7c5c..5c03db0 100644 --- a/src/api/types/AudioOutputFormat.ts +++ b/src/api/types/AudioOutputFormat.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. /** - * Audio output format as a `codec_sampleRate_bitrate` string, giving explicit control over sample rate and bitrate. `pcm_*` and `ulaw_8000` are headerless raw audio; `pcm_16000` and `ulaw_8000` are the telephony formats Twilio/LiveKit SIP expect. + * Audio output format as a `codec_sampleRate_bitrate` string, giving explicit control over sample rate and bitrate. `pcm_*` and `ulaw_8000` are headerless raw audio; `pcm_16000` and `ulaw_8000` are the telephony formats Twilio/LiveKit SIP expect. From API version `2026-09-30`, `pcm_16000` is 16 kHz audio; a workspace pinned to an earlier version keeps receiving 24 kHz audio for `pcm_16000`, as it always has. * * 160 kbps is the highest bitrate an mp3 can carry at 22.05 and 24 kHz, so `mp3_22050_160` and `mp3_24000_160` are the maximum-fidelity mp3 formats; a request for `mp3_*_192` is encoded at 160 kbps and reported as the matching `mp3_*_160`. The two `mp3_*_160` formats are served by the Simba 3 models only. */ diff --git a/src/api/types/AudioStreamOutputFormat.ts b/src/api/types/AudioStreamOutputFormat.ts index fa16e83..2a51a56 100644 --- a/src/api/types/AudioStreamOutputFormat.ts +++ b/src/api/types/AudioStreamOutputFormat.ts @@ -1,7 +1,7 @@ // This file was auto-generated by Fern from our API Definition. /** - * Audio output format for the streaming endpoint (`POST /v1/audio/stream`), as a `codec_sampleRate_bitrate` string. Same as `AudioOutputFormat` minus the `wav_*` formats: wav is only available on `POST /v1/audio/speech`. `pcm_*` and `ulaw_8000` are headerless raw audio; `pcm_16000` and `ulaw_8000` are the telephony formats Twilio/LiveKit SIP expect. + * Audio output format for the streaming endpoint (`POST /v1/audio/stream`), as a `codec_sampleRate_bitrate` string. Same as `AudioOutputFormat` minus the `wav_*` formats: wav is only available on `POST /v1/audio/speech`. `pcm_*` and `ulaw_8000` are headerless raw audio; `pcm_16000` and `ulaw_8000` are the telephony formats Twilio/LiveKit SIP expect. From API version `2026-09-30`, `pcm_16000` is 16 kHz audio; a workspace pinned to an earlier version keeps receiving 24 kHz audio for `pcm_16000`, as it always has. * * 160 kbps is the highest bitrate an mp3 can carry at 22.05 and 24 kHz, so `mp3_22050_160` and `mp3_24000_160` are the maximum-fidelity mp3 formats; a request for `mp3_*_192` is encoded at 160 kbps. The two `mp3_*_160` formats are served by the Simba 3 models only. */ diff --git a/src/api/types/BillingEntitlements.ts b/src/api/types/BillingEntitlements.ts new file mode 100644 index 0000000..34edfb4 --- /dev/null +++ b/src/api/types/BillingEntitlements.ts @@ -0,0 +1,74 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Customer-facing per-tier limits + feature flags, including the API + * rate limits the plan enforces. Numeric fields are caps; booleans gate + * features. + */ +export interface BillingEntitlements { + /** Members allowed in a single workspace (owner + invitees). */ + max_members: number; + /** + * Active service accounts allowed. 0 means service accounts are not + * included in the plan (creating one returns 402 + * service_accounts_not_in_plan); existing accounts keep working. + */ + max_service_accounts: number; + /** Sustained requests per second across the audio (TTS) endpoints. */ + tts_requests_per_second: number; + /** Simultaneous in-flight requests across the audio (TTS) endpoints. */ + tts_concurrency: number; + /** + * Sustained requests per second each end user (`safety_identifier`) may + * send across the audio (TTS) endpoints, inside the workspace's own + * limit. 0 means no per-end-user limit applies. + */ + tts_end_user_requests_per_second: number; + /** + * Simultaneous in-flight requests each end user (`safety_identifier`) + * may hold across the audio (TTS) endpoints, inside the workspace's own + * limit. 0 means no per-end-user limit applies. + */ + tts_end_user_concurrency: number; + /** Whether the workspace may create ADDITIONAL workspaces. */ + can_create_workspaces: boolean; + /** Whether prepaid funds may be added beyond the monthly grant. */ + topup_allowed: boolean; + /** Whether voice cloning is available. */ + voice_cloning: boolean; + /** Whether stores and hosted APIs are available. Off on every plan; granted per workspace. */ + hosted_apis_access: boolean; + /** Documents one store may hold; 0 means uncapped. */ + max_store_documents: number; + /** Bytes one store may hold across its documents; 0 means uncapped. */ + max_store_bytes: number; + /** Whether enterprise SAML/OIDC SSO is available. */ + enterprise_sso: boolean; + /** + * Whether zero data retention is enabled for this workspace on the + * Text to Speech API. Read-only: Speechify sets it against a signed + * agreement, never self-serve, and that agreement defines the scope. + */ + zero_data_retention: boolean; + /** + * Whether `POST /v1/voices` accepts a clone from this workspace + * without a consent challenge and verification recording, because the + * workspace captures and holds speaker consent under its own + * agreement with Speechify. Read-only: Speechify sets it against that + * agreement, never self-serve. It does not grant cloning - the + * `voice_cloning` entitlement still applies. + */ + voice_cloning_consent_exempt: boolean; + /** + * Largest single manual prepaid top-up accepted, in whole US dollars. + * 0 means adding prepaid credit is not included in the plan. This is + * the enforced amount, so a top-up of exactly this value succeeds; a + * client may offer it directly without applying further bounds. + */ + max_manual_top_up_usd: number; + /** + * Largest single automatic recharge, in whole US dollars. 0 means + * auto-recharge is not included in the plan. + */ + max_auto_recharge_charge_usd: number; +} diff --git a/src/api/types/EntitlementsResponse.ts b/src/api/types/EntitlementsResponse.ts new file mode 100644 index 0000000..d1cbd1f --- /dev/null +++ b/src/api/types/EntitlementsResponse.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * `catalog` is every sellable tier's FLOOR entitlements, keyed by tier + * (`free`/`starter`/`pro`/`scale`/`enterprise`) for the upgrade cards. + * `current` is the caller's workspace RESOLVED entitlements (tier floor + * composed with its per-tenant override), so a custom/Enterprise customer + * sees their actual caps - not just the tier floor. + */ +export interface EntitlementsResponse { + /** Per-tier floor entitlements, keyed by tier string. */ + catalog: Record; + current: Speechify.BillingEntitlements; +} diff --git a/src/api/types/ErrorCode.ts b/src/api/types/ErrorCode.ts index 1507fee..2e7f3d9 100644 --- a/src/api/types/ErrorCode.ts +++ b/src/api/types/ErrorCode.ts @@ -9,6 +9,7 @@ * idempotent requests. */ export const ErrorCode = { + EndpointMoved: "endpoint_moved", BadRequest: "bad_request", ValidationFailed: "validation_failed", Unauthorized: "unauthorized", @@ -34,10 +35,56 @@ export const ErrorCode = { CredentialNotFound: "credential_not_found", CredentialInUse: "credential_in_use", AgentNotFound: "agent_not_found", + AgentInUse: "agent_in_use", + AgentRunNotFound: "agent_run_not_found", KbNotFound: "kb_not_found", KbDocumentNotFound: "kb_document_not_found", KbFolderNotFound: "kb_folder_not_found", ToolNotFound: "tool_not_found", + ToolNameTaken: "tool_name_taken", + ChannelInstanceNotFound: "channel_instance_not_found", + TeamNotFound: "team_not_found", + TriggerNotFound: "trigger_not_found", + StoreNotFound: "store_not_found", + StoreDocumentNotFound: "store_document_not_found", + HostedApiNotFound: "hosted_api_not_found", + ApiRouteNotFound: "api_route_not_found", + ConsumerKeyNotFound: "consumer_key_not_found", + SkillNotFound: "skill_not_found", + SkillVersionNotFound: "skill_version_not_found", + FileNotFound: "file_not_found", + FilePathTaken: "file_path_taken", + FileStorageLimitReached: "file_storage_limit_reached", + StoreLimitReached: "store_limit_reached", + StoreDocumentLimitReached: "store_document_limit_reached", + StoreBytesLimitReached: "store_bytes_limit_reached", + StoreNotConfigured: "store_not_configured", + StoreDocumentVersionConflict: "store_document_version_conflict", + StoreDocumentDeleted: "store_document_deleted", + EntitlementOverrideExists: "entitlement_override_exists", + HostedApisNotInPlan: "hosted_apis_not_in_plan", + SkillsNotInPlan: "skills_not_in_plan", + VoiceAgentsNotInPlan: "voice_agents_not_in_plan", + SkillInUse: "skill_in_use", + SkillToolNameConflict: "skill_tool_name_conflict", + SkillLimitReached: "skill_limit_reached", + AgentSkillLimitReached: "agent_skill_limit_reached", + HostedApiSlugTaken: "hosted_api_slug_taken", + ApiRouteConflict: "api_route_conflict", + MountPlanChanged: "mount_plan_changed", + RouteOutputUnavailable: "route_output_unavailable", + RouteRunTimeout: "route_run_timeout", + RouteRunFailed: "route_run_failed", + RouteRunLimitReached: "route_run_limit_reached", + RouteReadLimitReached: "route_read_limit_reached", + RouteWriteLimitReached: "route_write_limit_reached", + HostedApiPublicRefused: "hosted_api_public_refused", + RouteToolNotReadable: "route_tool_not_readable", + RouteToolUnavailable: "route_tool_unavailable", + RouteUpstreamRateLimited: "route_upstream_rate_limited", + RouteUpstreamError: "route_upstream_error", + HostedMcpNotEnabled: "hosted_mcp_not_enabled", + HostedApiBusy: "hosted_api_busy", ConversationNotFound: "conversation_not_found", PhoneNumberNotFound: "phone_number_not_found", SipTrunkNotFound: "sip_trunk_not_found", @@ -50,11 +97,26 @@ export const ErrorCode = { InviteNotFound: "invite_not_found", ProjectNotFound: "project_not_found", CrossProjectReference: "cross_project_reference", + ProjectHasScopedCredentials: "project_has_scoped_credentials", + ProjectNotEmpty: "project_not_empty", + ProjectLimitReached: "project_limit_reached", + AgentLimitReached: "agent_limit_reached", + ProjectTooLargeToPromote: "project_too_large_to_promote", + CallNotFound: "call_not_found", + MessageNotFound: "message_not_found", + ThreadNotFound: "thread_not_found", + CallNotActive: "call_not_active", + RelayDisplacesAgent: "relay_displaces_agent", + BrainNotFound: "brain_not_found", + BrainInUse: "brain_in_use", + CustomModelNotFound: "custom_model_not_found", + CustomModelInUse: "custom_model_in_use", InsufficientScope: "insufficient_scope", PurchasedNumbersNotIncluded: "purchased_numbers_not_included", PhoneNumberQuotaReached: "phone_number_quota_reached", BatchCallsNotIncluded: "batch_calls_not_included", VoiceCloningNotIncluded: "voice_cloning_not_included", + VoiceCloningUnavailableInRegion: "voice_cloning_unavailable_in_region", ConsentChallengeNotFound: "consent_challenge_not_found", ConsentChallengeExpired: "consent_challenge_expired", ConsentChallengeAlreadyUsed: "consent_challenge_already_used", @@ -62,6 +124,9 @@ export const ErrorCode = { ConsentSpeakerMismatch: "consent_speaker_mismatch", ConsentRecordingUnusable: "consent_recording_unusable", ConsentVerificationUnavailable: "consent_verification_unavailable", + ConsentVerificationRequired: "consent_verification_required", + WatermarkAudioUnusable: "watermark_audio_unusable", + WatermarkDetectionUnavailable: "watermark_detection_unavailable", WorkspaceLastOwner: "workspace_last_owner", WorkspaceLastWorkspace: "workspace_last_workspace", AccountDeletionBlocked: "account_deletion_blocked", @@ -72,17 +137,49 @@ export const ErrorCode = { ServiceAccountLimitReached: "service_account_limit_reached", ServiceAccountsNotInPlan: "service_accounts_not_in_plan", SpeechMarksUnsupported: "speech_marks_unsupported", + PronunciationsUnsupported: "pronunciations_unsupported", + ModelRetired: "model_retired", TooManyVoices: "too_many_voices", ContentPolicyViolation: "content_policy_violation", + SafetyIdentifierBlocked: "safety_identifier_blocked", TopupNotInPlan: "topup_not_in_plan", CreditPurchaseUnpaid: "credit_purchase_unpaid", + CreditPurchasePaymentInProgress: "credit_purchase_payment_in_progress", ToolConfigShared: "tool_config_shared", SpendCapExceeded: "spend_cap_exceeded", SpendBudgetExceeded: "spend_budget_exceeded", + ProjectSpendLimitExceeded: "project_spend_limit_exceeded", + ProjectArchived: "project_archived", + ProjectNotArchived: "project_not_archived", + ProjectNotPurged: "project_not_purged", + ProjectRestoreWindowExpired: "project_restore_window_expired", + ProjectNameTaken: "project_name_taken", + FundedBalanceRequired: "funded_balance_required", + AgentPublishGateFailed: "agent_publish_gate_failed", + AgentPublishGateRequired: "agent_publish_gate_required", + AgentPublishGateUnavailable: "agent_publish_gate_unavailable", + AgentPublishGateToolUnreachable: "agent_publish_gate_tool_unreachable", + TextChannelNotInPlan: "text_channel_not_in_plan", + ChannelNotInPlan: "channel_not_in_plan", + TextTurnFailed: "text_turn_failed", + ConversationTurnInProgress: "conversation_turn_in_progress", + ConversationClosed: "conversation_closed", + ConversationNotReachable: "conversation_not_reachable", + ConversationChannelBound: "conversation_channel_bound", + ConversationPromptNotFound: "conversation_prompt_not_found", + TextMessageQuotaExceeded: "text_message_quota_exceeded", + DurableRunsNotInPlan: "durable_runs_not_in_plan", + ToolTransportUnsupported: "tool_transport_unsupported", + AgentConfigTooLarge: "agent_config_too_large", + AgentRunNotPending: "agent_run_not_pending", + AgentRunActionStale: "agent_run_action_stale", ShareLinkNotFound: "share_link_not_found", ShareLinkExhausted: "share_link_exhausted", ShareLinkLimitReached: "share_link_limit_reached", DestinationNotAllowed: "destination_not_allowed", InternationalDialingNotEnabled: "international_dialing_not_enabled", + NumberNotSmsCapable: "number_not_sms_capable", + VerificationRequired: "verification_required", + IntendedUseRequired: "intended_use_required", } as const; export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]; diff --git a/src/api/types/GetStreamRequest.ts b/src/api/types/GetStreamRequest.ts index aac0523..5cfba36 100644 --- a/src/api/types/GetStreamRequest.ts +++ b/src/api/types/GetStreamRequest.ts @@ -8,8 +8,9 @@ import type * as Speechify from "../index.js"; export interface GetStreamRequest { /** * Plain text or SSML to be synthesized to speech. + * Up to 20,000 characters of spoken text, the characters the request is billed for: SSML tags do not count. The input as sent, markup included, may be up to 32,000 characters. * Refer to https://docs.speechify.ai/docs/api-limits for the input size limits. - * Emotion, Pitch and Speed Rate are configured in the ssml input, please refer to the ssml documentation for more information: https://docs.speechify.ai/docs/ssml#prosody + * SSML sets pauses (``), speaking rate, pitch and volume (``) and pronunciation (``): see https://docs.speechify.ai/build/guides/text-to-speech/ssml for each tag. Emotion styles and emphasis are applied only by the Simba 1.6 models, until 2026-11-21; `simba-3.0`, `simba-3.2` and `simba-3.5` accept those tags without applying them. */ input: string; /** @@ -17,30 +18,38 @@ export interface GetStreamRequest { * Please refer to the list of the supported languages and recommendations regarding this parameter: https://docs.speechify.ai/docs/language-support. */ language?: string | undefined; - /** Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity, and the recommended Simba 3 model; it is English only, so a non-English voice returns 400. `simba-english` and `simba-multilingual` are the legacy Simba 1.6 models, kept for compatibility. */ + /** + * Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity; it is English only, so a non-English voice returns 400. `simba-3.5` is the recommended model: streaming-native, covering 48 languages under one id, English included, routed by `language` like `simba-3.0`; every voice works on it, cloned voices included. + * + * The legacy Simba 1.6 models `simba-english` and `simba-multilingual` are retired from API version `2026-09-21`: naming one returns 400 `model_retired`. Pinning your API version to a date before `2026-09-21` keeps them on their Simba 1.6 training until **2026-11-21**; from then both ids are served by our current models on every API version that can still name them. Migrate to `simba-3.2` (English), `simba-3.0` or `simba-3.5` before then; call GET /v1/audio/models to see the set your workspace can select today. + */ model?: GetStreamRequest.Model | undefined; options?: Speechify.GetStreamOptionsRequest | undefined; /** The output audio format as a `codec_sampleRate_bitrate` string. Takes precedence over the `Accept` header when set, so you can request formats the `Accept` enum does not cover (e.g. `pcm_16000`, `ulaw_8000`). `wav_*` formats are not supported on streaming - use `POST /v1/audio/speech` for wav. */ output_format?: Speechify.AudioStreamOutputFormat | undefined; + pronunciations?: Speechify.Pronunciations | undefined; + /** Optional. A stable, opaque identifier for the end user this request is made for: a hash of your own user id or an opaque id, never an email address or other personal data. It is recorded with the request even under zero data retention, and your workspace can be given per-end-user limits and a block list keyed on it. See https://docs.speechify.ai/build/guides/concepts/safety-identifiers. */ + safety_identifier?: Speechify.SafetyIdentifier | undefined; /** Id of the voice to be used for synthesizing speech. Refer to /v1/voices endpoint for available voices */ voice_id: string; } export namespace GetStreamRequest { - /** Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity, and the recommended Simba 3 model; it is English only, so a non-English voice returns 400. `simba-english` and `simba-multilingual` are the legacy Simba 1.6 models, kept for compatibility. */ + /** + * Model used for audio synthesis. Defaults to `simba-3.0`, which is streaming-native and multilingual: it officially supports English plus `de-DE`, `es-ES`, `es-MX`, `fr-FR`, `it-IT` and `pt-BR`, and routes each request to its English or its multilingual training based on `language` (falling back to the voice's locale when `language` is omitted). `simba-3.2` is the streaming-native model with the lowest TTFB and richest expressivity; it is English only, so a non-English voice returns 400. `simba-3.5` is the recommended model: streaming-native, covering 48 languages under one id, English included, routed by `language` like `simba-3.0`; every voice works on it, cloned voices included. + * + * The legacy Simba 1.6 models `simba-english` and `simba-multilingual` are retired from API version `2026-09-21`: naming one returns 400 `model_retired`. Pinning your API version to a date before `2026-09-21` keeps them on their Simba 1.6 training until **2026-11-21**; from then both ids are served by our current models on every API version that can still name them. Migrate to `simba-3.2` (English), `simba-3.0` or `simba-3.5` before then; call GET /v1/audio/models to see the set your workspace can select today. + */ export const Model = { /** - * simba-english is the legacy Simba 1.6 English model. It accepts cloned voices self-serve; prefer simba-3.2 for new integrations. */ - SimbaEnglish: "simba-english", - /** - * simba-multilingual is the legacy Simba 1.6 multilingual model, covering the full 30+ locale set and mixed-language input. Prefer simba-3.0 for the languages it supports. */ - SimbaMultilingual: "simba-multilingual", - /** - * simba-3.0 is the streaming-native multilingual model, and the default when `model` is omitted. Officially supports English plus de-DE, es-ES, es-MX, fr-FR, it-IT and pt-BR; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Prefer simba-3.2 for English-only integrations. Cloned/personal voices work self-serve on simba-3.0. */ + * simba-3.0 is the streaming-native multilingual model, and the default when `model` is omitted. Officially supports English plus de-DE, es-ES, es-MX, fr-FR, it-IT and pt-BR; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Prefer simba-3.5 for new integrations. Cloned/personal voices work self-serve on simba-3.0. */ Simba30: "simba-3.0", /** - * simba-3.2 is the streaming-native model with the lowest TTFB and richest expressivity. English only; a non-English voice returns 400 - use simba-3.0 for the other supported languages. Cloned voices are supported on simba-3.2 alongside the curated stock roster, currently as a limited release enabled per workspace - contact Speechify to have it enabled for yours. */ + * simba-3.2 is the streaming-native model with the lowest TTFB and richest expressivity. English only; a non-English voice returns 400 - use simba-3.0 for the other supported languages. Every English voice in the catalog is supported, cloned voices included. */ Simba32: "simba-3.2", + /** + * simba-3.5 is the recommended streaming-native model, covering 48 languages under one id, English included; the request language (or the voice's locale when it is omitted) selects the English or the multilingual training. Every voice in the catalog is supported, cloned voices included. */ + Simba35: "simba-3.5", } as const; export type Model = (typeof Model)[keyof typeof Model]; } diff --git a/src/api/types/GetVoice.ts b/src/api/types/GetVoice.ts index 97a4265..b1f9a48 100644 --- a/src/api/types/GetVoice.ts +++ b/src/api/types/GetVoice.ts @@ -10,6 +10,36 @@ export interface GetVoice { id: string; models: Speechify.GetVoicesModel[]; preview_audio?: (string | null) | undefined; + /** + * The workspace project this cloned voice is filed under, set when + * a project-pinned key created it. Returned wherever a cloned voice + * is: the list, a single-voice read, and the create response. + * + * Omitted for a shared-catalog voice and for a cloned voice no + * project filed, which is shared with the whole workspace and + * listed for every member of it. + */ + project_id?: string | undefined; + /** + * Whether this workspace may delete the voice and download its + * sample through this API. `true` for a cloned voice the workspace + * owns. `false` for a shared-catalog voice, and for a cloned voice + * that reaches this workspace only through its creator's personal + * account (a voice cloned before workspace ownership, or under + * another Speechify product), which is managed where it was made. + */ + can_manage?: boolean | undefined; + /** + * This voice's place among the staff picks for its `locale`: `1` + * is the voice Speechify recommends first for that language, `2` + * the next, and so on. Omitted for a voice that is not a staff + * pick, and always for a cloned voice. + * + * Simba 3.5 sounds best with a voice native to the language you + * generate, so to choose a voice for a language, filter by + * `locale` and start from its lowest `staff_pick_rank`. + */ + staff_pick_rank?: number | undefined; tags?: (string[] | null) | undefined; type: GetVoice.Type; } diff --git a/src/api/types/GetVoicesModel.ts b/src/api/types/GetVoicesModel.ts index 9c6ca6a..7a93fc2 100644 --- a/src/api/types/GetVoicesModel.ts +++ b/src/api/types/GetVoicesModel.ts @@ -4,15 +4,30 @@ import type * as Speechify from "../index.js"; export interface GetVoicesModel { languages: Speechify.GetVoiceLanguage[]; + /** + * A model this voice can be synthesized with. The set is filtered to + * what YOUR workspace's API version can select, so a voice never + * advertises a model your own synthesis request would reject. The + * legacy `simba-english` / `simba-multilingual` values appear only for + * a workspace pinned before API version `2026-09-21`. + */ name: GetVoicesModel.Name; } export namespace GetVoicesModel { + /** + * A model this voice can be synthesized with. The set is filtered to + * what YOUR workspace's API version can select, so a voice never + * advertises a model your own synthesis request would reject. The + * legacy `simba-english` / `simba-multilingual` values appear only for + * a workspace pinned before API version `2026-09-21`. + */ export const Name = { SimbaEnglish: "simba-english", SimbaMultilingual: "simba-multilingual", Simba30: "simba-3.0", Simba32: "simba-3.2", + Simba35: "simba-3.5", } as const; export type Name = (typeof Name)[keyof typeof Name]; } diff --git a/src/api/types/ListProjectsResponse.ts b/src/api/types/ListProjectsResponse.ts new file mode 100644 index 0000000..9ccd2b6 --- /dev/null +++ b/src/api/types/ListProjectsResponse.ts @@ -0,0 +1,7 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +export interface ListProjectsResponse extends Speechify.PaginationMeta { + projects: Speechify.Project[]; +} diff --git a/src/api/types/ListVoicesResponse.ts b/src/api/types/ListVoicesResponse.ts index 80909e3..2a9667f 100644 --- a/src/api/types/ListVoicesResponse.ts +++ b/src/api/types/ListVoicesResponse.ts @@ -5,9 +5,9 @@ import type * as Speechify from "../index.js"; /** * Payload for `GET /v1/voices` - the shared voice catalog plus the * workspace's personal cloned voices. Carries the shared pagination - * metadata so the list can be paged when `limit` is supplied; - * `next_cursor` is null and `has_more` is false when the full - * catalogue is returned in one response. + * metadata: pass `next_cursor` as `cursor` to fetch the next page + * while `has_more` is true. `next_cursor` is null and `has_more` is + * false on the last page. */ export interface ListVoicesResponse extends Speechify.PaginationMeta { voices: Speechify.GetVoice[]; diff --git a/src/api/types/ListWebhookEndpointDeliveriesResponse.ts b/src/api/types/ListWebhookEndpointDeliveriesResponse.ts new file mode 100644 index 0000000..7f20052 --- /dev/null +++ b/src/api/types/ListWebhookEndpointDeliveriesResponse.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * Payload for GET /v1/webhooks/endpoints/{webhook_endpoint_id}/deliveries. + */ +export interface ListWebhookEndpointDeliveriesResponse extends Speechify.PaginationMeta { + deliveries: Speechify.WebhookEndpointDelivery[]; +} diff --git a/src/api/types/ListWebhookEndpointsResponse.ts b/src/api/types/ListWebhookEndpointsResponse.ts new file mode 100644 index 0000000..7b00334 --- /dev/null +++ b/src/api/types/ListWebhookEndpointsResponse.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * Payload for GET /v1/webhooks/endpoints. + */ +export interface ListWebhookEndpointsResponse extends Speechify.PaginationMeta { + endpoints: Speechify.WebhookEndpoint[]; +} diff --git a/src/api/types/Model.ts b/src/api/types/Model.ts index 4a3ecc0..beb8e5a 100644 --- a/src/api/types/Model.ts +++ b/src/api/types/Model.ts @@ -14,8 +14,8 @@ export interface Model { /** * Whether this is the model used when a synthesis request omits * `model`. Exactly one model in the list is the default. Distinct - * from `recommended`: the default accepts every voice, while the - * recommended model may serve a curated or English-only set. + * from `recommended`: the default accepts every voice in every + * language, while the recommended model may be English-only. */ default: boolean; /** @@ -25,12 +25,35 @@ export interface Model { */ recommended: boolean; /** - * Whether this is a legacy model. Advisory only: a deprecated model - * stays selectable and behaves exactly as before, and nothing is - * scheduled for removal. De-emphasise it in a picker and steer new - * integrations to a current model. + * Whether this is a legacy model. De-emphasise it in a picker and + * steer new integrations to a current model. Read `retired_at` for + * whether it also has a withdrawal date. */ deprecated: boolean; + /** + * The API version at which this model stops being selectable, as + * `YYYY-MM-DD`. Absent when the model has no withdrawal date. + * + * It appears only while your workspace is pinned BELOW that version - + * at or after it the model is absent from this catalog entirely, and + * naming it returns 400 `model_retired`. So a present value means "you + * can still use this, and this is the date you lose it". Pinning your + * API version before this date keeps the model working, up to + * `sunset_at`. + */ + retired_at?: string | undefined; + /** + * The date this model's own training stops serving this id, as + * `YYYY-MM-DD`. Absent when no sunset is scheduled. + * + * This is the deadline `retired_at`'s version pin runs out against: + * from `sunset_at` the training behind the id changes on EVERY API + * version, including a workspace pinned below its retirement. The + * Simba 1.6 pair keeps answering from that date, served by our current + * models, so the change is to the audio, not to the request. Read the + * two together - a pin holds the old training, not forever. + */ + sunset_at?: string | undefined; /** One-line summary of the model, for a model picker. */ description: string; /** @@ -41,20 +64,18 @@ export interface Model { */ languages: string[]; /** - * The synthesis routes this model may be passed to. Only the - * streaming-native models serve `/v1/audio/stream/with-timestamps`; - * passing a model this list omits is a 400 rather than a degraded - * response, so branch on it instead of discovering it at call time. + * The synthesis routes this model may be passed to. Passing it to a + * route this list omits is a 400 rather than a degraded response, so + * branch on it instead of discovering it at call time. */ endpoints: string[]; /** - * Whether the model's stock voices are restricted to the set curated - * for it. When true, pick a stock voice whose `models` array in - * GET /v1/voices names this model; any other stock voice is rejected. - * When false, every stock catalogue voice works. Cloned voices are - * governed separately - always read each voice's own `models` array in - * GET /v1/voices, which reflects what your workspace may actually - * synthesize. + * Deprecated and always `false`. No model restricts synthesis to a + * registered voice set: every training conditions on the voice's own + * prompt audio, so every catalogue voice and every cloned voice works + * on every model, subject only to `english_voices_only`. Each voice's + * `models` array in GET /v1/voices stays the per-voice answer. The + * field remains on the response for compatibility. */ curated_voices: boolean; /** @@ -63,4 +84,13 @@ export interface Model { * voice. */ english_voices_only: boolean; + /** + * The `languages` in which a synthesis request naming this model may + * carry `pronunciations`; empty when the model takes none. A request + * in any other language with a non-empty `pronunciations` returns 400 + * `pronunciations_unsupported`, decided by the same language that + * picks the model's training: the request `language`, else the + * voice's locale. + */ + pronunciation_languages: string[]; } diff --git a/src/api/types/ModelsResponse.ts b/src/api/types/ModelsResponse.ts index 81bc073..465896d 100644 --- a/src/api/types/ModelsResponse.ts +++ b/src/api/types/ModelsResponse.ts @@ -3,7 +3,14 @@ import type * as Speechify from "../index.js"; /** - * The catalog of text-to-speech models available for synthesis. + * The catalog of text-to-speech models available for synthesis. The list + * is scoped to your workspace's API version: a model retired at or before + * it is absent here and returns 400 `model_retired` from the synthesis + * endpoints, so what this returns is exactly what you can call. The + * example below is the catalog at the current version - a workspace pinned + * before `2026-09-21` also sees `simba-english` and `simba-multilingual`, + * each carrying `retired_at` and the `sunset_at` date its pin expires + * against. */ export interface ModelsResponse { /** The models selectable on the single-utterance synthesis endpoints. */ diff --git a/src/api/types/Project.ts b/src/api/types/Project.ts new file mode 100644 index 0000000..2cb65f9 --- /dev/null +++ b/src/api/types/Project.ts @@ -0,0 +1,132 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A workspace project: a resource grouping that a member grant or a + * credential pin can also scope. Resources reference a project by id; + * a resource with no `project_id` lives in the implicit Default + * project. A project can carry member grants, which scope a granted + * member to the projects they hold, and the invoice stays + * workspace-level with no billing split. A project may carry a monthly + * spend LIMIT, which bounds work without splitting the bill, capacity + * CEILINGS such as `max_requests_per_minute` that sit below the + * workspace's own plan limits so one project cannot consume the whole + * allowance, and it may be ARCHIVED, which suspends all work and spend + * inside it while everything stays readable. + * + * An application building on this platform models one of its OWN + * business customers as a project: it is the level that both + * attributes cost (`monthly_spend`, grouped per project on the usage + * breakdown) and ENFORCES it (`monthly_budget` and the capacity + * ceilings). How many projects a workspace may hold is the workspace's + * own ceiling; a create past it answers `409 project_limit_reached`, + * and deleting an unused project frees a slot. + */ +export interface Project { + /** + * When the project was archived; `null` while it is live. While + * set, nothing new starts or bills inside the project and every + * such attempt answers `409 project_archived`. + * + * Absent rather than null while a console runs ahead of an API + * that predates archiving, which is why it is not required: + * read absent and null alike. + */ + archived_at?: (string | null) | undefined; + /** + * When this project was purged, present only on the rows returned + * by `include_purged=true`. A purged project is kept for 30 days + * from this stamp and permanently deleted after that, so the + * restore deadline is this value plus the window; it is absent on + * every project that still exists. Restore it with + * `POST /v1/projects/{project_id}/restore`. + */ + purged_at?: string | undefined; + /** + * The most API requests per minute credentials pinned to this + * project may make across every surface, present only when set. + * Checked after the workspace's own request-rate limit, in one + * bucket per project: a request over the ceiling is refused with + * the same `429 rate_limited` the workspace limit answers, while + * other projects and unpinned credentials are untouched. Never + * higher than the workspace's widest per-surface rate over a + * minute: a project can narrow the workspace's capacity, not + * raise it. Console sessions and unpinned keys carry no project + * and are never subject to it. + */ + max_requests_per_minute?: number | undefined; + /** + * The project's monthly spend limit in US dollars, present only + * when one is set. New billable work attributed to this project is + * refused with the coded `402 project_spend_limit_exceeded` once + * `monthly_spend` reaches it; the limit resets at the + * calendar-month boundary (UTC). + * + * Spend is attributed the same way it is billed: work from a + * project-pinned API key counts against that key's project, and + * work by a resource in a project counts against that project. The + * implicit Default project cannot carry a limit, since it has no + * project record, so spend there is bounded by the workspace's + * `monthly_budget` instead. + */ + monthly_budget?: number | undefined; + /** + * The project's billed month-to-date spend in US dollars, present + * whenever the billing plane answered - regardless of whether a + * spend limit is set. + */ + monthly_spend?: number | undefined; + /** + * Where `monthly_spend` stands against `monthly_budget`, present + * only when both are: `warning` from 80% of the budget, `reached` + * once the spend has reached it and new billable work attributed to + * the project is refused with `402 project_spend_limit_exceeded`, + * `ok` below 80%. These are the thresholds the + * `project.spend_budget.warning` and `project.spend_budget.reached` + * webhook events fire at, so polling this field and subscribing to + * the events give the same answer. + */ + monthly_budget_status?: Project.MonthlyBudgetStatus | undefined; + /** + * `monthly_budget` minus `monthly_spend` in US dollars, present only + * when both are. Negative once the spend has passed the budget, by + * the amount it overshot: enforcement trails billed usage by a + * couple of minutes, so work already under way can carry a project + * past its budget. + */ + monthly_budget_remaining?: number | undefined; + /** Workspace-scoped project identifier (prefixed external id). */ + id: string; + /** Human-readable label, unique per workspace (case-insensitive). */ + name: string; + /** + * How many resources this project holds. Records of work that + * happened are not counted, and never hold a project open. + * + * It is the count the unqualified delete refuses on, so a project + * reading `0` is one `DELETE /v1/projects/{project_id}` accepts + * with no body. That is what makes an application's own cleanup a + * single list call rather than a read per project. + */ + resource_count: number; + created_at: string; + updated_at: string; +} + +export namespace Project { + /** + * Where `monthly_spend` stands against `monthly_budget`, present + * only when both are: `warning` from 80% of the budget, `reached` + * once the spend has reached it and new billable work attributed to + * the project is refused with `402 project_spend_limit_exceeded`, + * `ok` below 80%. These are the thresholds the + * `project.spend_budget.warning` and `project.spend_budget.reached` + * webhook events fire at, so polling this field and subscribing to + * the events give the same answer. + */ + export const MonthlyBudgetStatus = { + Ok: "ok", + Warning: "warning", + Reached: "reached", + } as const; + export type MonthlyBudgetStatus = (typeof MonthlyBudgetStatus)[keyof typeof MonthlyBudgetStatus]; +} diff --git a/src/api/types/ProjectAuditEvent.ts b/src/api/types/ProjectAuditEvent.ts new file mode 100644 index 0000000..3cb8b48 --- /dev/null +++ b/src/api/types/ProjectAuditEvent.ts @@ -0,0 +1,52 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * One change to this project's access or lifecycle state. The subject is + * whose access changed; the actor is who changed it. + * + * Every field below is always present. A field the event did not carry is + * `null`, which is a different fact from the key being absent altogether: + * `null` means this event had no such party, an absent key would mean the + * entry predates the platform recording that party at all. Audit entries + * are never backfilled, so the two are kept distinct. + */ +export interface ProjectAuditEvent { + /** When the change was recorded. */ + time: string; + /** + * What changed. `access_widened_to_workspace` is the revoke that + * removed the subject's LAST grant anywhere: a member with no grants + * reaches the whole workspace, so that revoke widened them rather + * than narrowing them. + */ + type: ProjectAuditEvent.Type; + /** The member whose access changed. Null on a lifecycle change, which is done to the project rather than to a person. */ + subject_user_id?: (string | null) | undefined; + /** The member who made the change. Null when the change was system-initiated. */ + actor_user_id?: (string | null) | undefined; + /** The actor's email at the time of the change. Null when the change carried no email. */ + actor_email?: (string | null) | undefined; + /** The workspace role the actor held at the time. A role read back today cannot answer what they held when they acted. Null when the change carried no role. */ + actor_role?: (string | null) | undefined; + /** The Speechify support admin acting on the workspace's behalf. Null unless the change came through support. */ + impersonator_email?: (string | null) | undefined; + /** How many projects the subject held after the change. Null on a lifecycle change; zero is what makes a revoke a widening to the whole workspace. */ + remaining_grants?: (number | null) | undefined; +} + +export namespace ProjectAuditEvent { + /** + * What changed. `access_widened_to_workspace` is the revoke that + * removed the subject's LAST grant anywhere: a member with no grants + * reaches the whole workspace, so that revoke widened them rather + * than narrowing them. + */ + export const Type = { + AccessGranted: "access_granted", + AccessRevoked: "access_revoked", + AccessWidenedToWorkspace: "access_widened_to_workspace", + Archived: "archived", + Unarchived: "unarchived", + } as const; + export type Type = (typeof Type)[keyof typeof Type]; +} diff --git a/src/api/types/ProjectAuditResponse.ts b/src/api/types/ProjectAuditResponse.ts new file mode 100644 index 0000000..d76f16c --- /dev/null +++ b/src/api/types/ProjectAuditResponse.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * One page of a project's audit trail, newest change first. + */ +export interface ProjectAuditResponse extends Speechify.PaginationMeta { + events: Speechify.ProjectAuditEvent[]; +} diff --git a/src/api/types/ProjectMember.ts b/src/api/types/ProjectMember.ts new file mode 100644 index 0000000..3434d9d --- /dev/null +++ b/src/api/types/ProjectMember.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * One project grant - a workspace member who may reach this project. + */ +export interface ProjectMember { + /** The member's prefixed user id, joinable to the workspace members list. */ + user_id: string; + created_at: string; + /** The prefixed user id of whoever made the grant. Attribution only. */ + granted_by: string; +} diff --git a/src/api/types/ProjectMembersResponse.ts b/src/api/types/ProjectMembersResponse.ts new file mode 100644 index 0000000..e84f006 --- /dev/null +++ b/src/api/types/ProjectMembersResponse.ts @@ -0,0 +1,7 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +export interface ProjectMembersResponse extends Speechify.PaginationMeta { + members: Speechify.ProjectMember[]; +} diff --git a/src/api/types/ProjectRestore.ts b/src/api/types/ProjectRestore.ts new file mode 100644 index 0000000..1f9158e --- /dev/null +++ b/src/api/types/ProjectRestore.ts @@ -0,0 +1,37 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * The outcome of restoring a purged project: what deliberately did not + * come back. + * + * `still_revoked` counts the credentials the purge revoked and this + * call left revoked, because re-issuing a credential someone killed + * would hand back access rather than restore a project. Member grants + * and pending-invite scopes are in that group too, but their rows were + * removed by the purge, so they cannot be counted and appear only in + * `not_restored_note`. + * + * The project comes back ARCHIVED, the state it was purged from, so + * `archived_at` is always set: nothing dispatches or bills inside it + * until you unarchive it on purpose. + */ +export interface ProjectRestore { + id?: string | undefined; + name?: string | undefined; + /** When the purge this call walked back happened. */ + purged_at?: string | undefined; + /** + * When the project was archived. Always set on a restore: a project + * comes back suspended, never live. + */ + archived_at?: (string | null) | undefined; + still_revoked?: Speechify.ProjectStillRevokedCounts | undefined; + /** + * A plain-language statement of what a restore does not bring back. + * Constant text, meant to be shown to a person; branch on + * `still_revoked` rather than parsing it. + */ + not_restored_note?: string | undefined; +} diff --git a/src/api/types/ProjectStillRevokedCounts.ts b/src/api/types/ProjectStillRevokedCounts.ts new file mode 100644 index 0000000..8eeff74 --- /dev/null +++ b/src/api/types/ProjectStillRevokedCounts.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * What the restore deliberately left revoked: the credentials the purge + * killed. Every field is a real count, including zero. + */ +export interface ProjectStillRevokedCounts { + api_keys?: number | undefined; + service_accounts?: number | undefined; + credentials?: number | undefined; + webhook_endpoints?: number | undefined; +} diff --git a/src/api/types/Pronunciation.ts b/src/api/types/Pronunciation.ts new file mode 100644 index 0000000..445ae6a --- /dev/null +++ b/src/api/types/Pronunciation.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * One pronunciation entry. Set `text` and exactly one of `ipa` or `alias`. + */ +export type Pronunciation = Speechify.PronunciationIpa | Speechify.PronunciationAlias; diff --git a/src/api/types/PronunciationAlias.ts b/src/api/types/PronunciationAlias.ts new file mode 100644 index 0000000..26f1822 --- /dev/null +++ b/src/api/types/PronunciationAlias.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * Say this text in place of `text`. + */ +export interface PronunciationAlias { + text: Speechify.PronunciationText; + /** Plain text spoken in place of `text`: a respelling that sounds right (`koo-ber-net-eez`) or a substitution (`SaaS` spoken as `sass`). Up to 160 characters, no control characters. An alias is checked by the same content policy as `input`. */ + alias: string; + case_sensitive?: Speechify.PronunciationCaseSensitive | undefined; +} diff --git a/src/api/types/PronunciationCaseSensitive.ts b/src/api/types/PronunciationCaseSensitive.ts new file mode 100644 index 0000000..2928af0 --- /dev/null +++ b/src/api/types/PronunciationCaseSensitive.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * When true, the entry matches `text` only with the same capitalization. When false, the default, it matches regardless of case. + */ +export type PronunciationCaseSensitive = boolean; diff --git a/src/api/types/PronunciationIpa.ts b/src/api/types/PronunciationIpa.ts new file mode 100644 index 0000000..6fac5d6 --- /dev/null +++ b/src/api/types/PronunciationIpa.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * Say `text` with these phones. + */ +export interface PronunciationIpa { + text: Speechify.PronunciationIpaText; + /** The phones to say `text` with, from the model's phone set, separated by spaces or `|`: for example `s p ˈiː tʃ ɪ f aɪ` or `s|p|ˈiː|tʃ|ɪ|f|aɪ`. 1 to 64 phones. Stress marks belong to the vowel they stress (`ˈiː` is one phone), and phones compare after Unicode NFC normalization, so a precomposed and a decomposed spelling of the same phone are equal. A phone the model does not know returns `400 validation_failed` naming it. */ + ipa: string; + case_sensitive?: Speechify.PronunciationCaseSensitive | undefined; +} diff --git a/src/api/types/PronunciationIpaText.ts b/src/api/types/PronunciationIpaText.ts new file mode 100644 index 0000000..ac1e975 --- /dev/null +++ b/src/api/types/PronunciationIpaText.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * The one word the phones say, as it appears in `input`. Up to 64 characters, no whitespace and no control characters: give a phrase one entry per word, or an `alias`. Two entries with the same `text` return `400 validation_failed`; texts compare case-insensitively unless both entries are `case_sensitive`. + */ +export type PronunciationIpaText = string; diff --git a/src/api/types/PronunciationText.ts b/src/api/types/PronunciationText.ts new file mode 100644 index 0000000..f9e29a7 --- /dev/null +++ b/src/api/types/PronunciationText.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * The word or phrase as it appears in `input`. Up to 64 characters, no control characters, not only whitespace. Two entries with the same `text` return `400 validation_failed`; texts compare case-insensitively unless both entries are `case_sensitive`. + */ +export type PronunciationText = string; diff --git a/src/api/types/Pronunciations.ts b/src/api/types/Pronunciations.ts new file mode 100644 index 0000000..ea933e8 --- /dev/null +++ b/src/api/types/Pronunciations.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * Optional. How to pronounce words and phrases in `input`: each entry gives a `text` and either the phones to say it with (`ipa`) or plain text to say in its place (`alias`). Every entry applies to the whole request. + * + * Supported only in the languages a model's entry in GET /v1/audio/models lists in `pronunciation_languages`, which does not include English yet: any other model or language returns `400 pronunciations_unsupported`. An empty array is accepted by every model in every language. At most 200 entries. A malformed entry, a phone outside the model's phone set, an `ipa` entry whose `text` is more than one word, or two entries for the same `text` returns `400 validation_failed`, with `fields` naming each entry (for example `pronunciations[3].ipa`), before anything is synthesized or billed. So does an `input` longer than 20,000 characters once every alias stands in for its text. + * + * Entries match case-insensitively unless `case_sensitive` is true, as whole words, except in Chinese, Japanese, Korean, Thai, Lao, Khmer and Burmese, where they match anywhere in the text; the longest matching entry wins, and an entry takes precedence over the model's own pronunciation. Pronunciations are not billed, and speech marks still index `input` exactly as sent. See https://docs.speechify.ai/build/guides/text-to-speech/pronunciation. + */ +export type Pronunciations = Speechify.Pronunciation[]; diff --git a/src/api/types/SafetyIdentifier.ts b/src/api/types/SafetyIdentifier.ts new file mode 100644 index 0000000..83072f5 --- /dev/null +++ b/src/api/types/SafetyIdentifier.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A stable, opaque identifier for the end user of your application on whose behalf this request is made. Use it when many of your own users share one Speechify workspace, for example behind a gateway, a reseller or a consumer app. + * + * Send a hash of your internal user id (for example a hex or base64 SHA-256), or an opaque id that means nothing outside your system. Never send an email address, a name, a phone number or any other personal data: the field accepts only letters, digits and `. _ - : | + / =`, so an email address is refused with `400 validation_failed`. + * + * The identifier is request metadata, not content. It is recorded with the request even when your workspace has zero data retention, so abuse can be attributed to one end user rather than to your whole workspace. When your workspace has per-end-user limits, it also has its own rate and concurrency allowance inside the workspace's (`429` with a message naming the `safety_identifier`), and a blocked identifier is refused with `403 safety_identifier_blocked` while your other end users are unaffected. Omitting it changes nothing. See https://docs.speechify.ai/build/guides/concepts/safety-identifiers. + */ +export type SafetyIdentifier = string; diff --git a/src/api/types/SpeechErrorEvent.ts b/src/api/types/SpeechErrorEvent.ts index 3109b98..47a029e 100644 --- a/src/api/types/SpeechErrorEvent.ts +++ b/src/api/types/SpeechErrorEvent.ts @@ -5,7 +5,8 @@ import type * as Speechify from "../index.js"; /** * Terminal event carrying the standard error envelope, emitted when a * failure happens after the stream has started and the status code is - * already committed. + * already committed: an upstream fault (`upstream_failure`) or a content + * policy refusal (`content_policy_violation`). */ export interface SpeechErrorEvent { error: Speechify.ErrorDetail; diff --git a/src/api/types/WatermarkDetectionResponse.ts b/src/api/types/WatermarkDetectionResponse.ts new file mode 100644 index 0000000..f44080a --- /dev/null +++ b/src/api/types/WatermarkDetectionResponse.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * The watermark detector's answer for one clip. + * + * `watermarked: true` is positive evidence the audio came from Speechify + * synthesis. `watermarked: false` is the absence of that evidence, not + * proof of a negative - see the endpoint description for the three reasons + * genuinely Speechify-generated audio can come back unmarked. + */ +export interface WatermarkDetectionResponse { + /** + * Whether the clip carries the watermark, i.e. whether `confidence` + * cleared the service's configured bar. + */ + watermarked: boolean; + /** + * The detector's score for this clip, in [0, 1]. Comparable only + * between checks made against the same detector version. + */ + confidence: number; +} diff --git a/src/api/types/WatermarkVerificationResponse.ts b/src/api/types/WatermarkVerificationResponse.ts new file mode 100644 index 0000000..16dc1a8 --- /dev/null +++ b/src/api/types/WatermarkVerificationResponse.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * The verification answer for one clip. + * + * One field, and no confidence score: a score is a gradient, and a public + * gradient turns "does this carry the mark" into "adjust the clip until + * the number drops". Use `POST /v1/audio/watermark/detect` if you need it. + * + * `watermarked: true` is positive evidence the audio came from Speechify + * synthesis. `watermarked: false` is the absence of that evidence, not + * proof of a negative - see the endpoint description. + */ +export interface WatermarkVerificationResponse { + /** Whether the clip carries the Speechify watermark. */ + watermarked: boolean; +} diff --git a/src/api/types/WebhookDeliveryStatus.ts b/src/api/types/WebhookDeliveryStatus.ts new file mode 100644 index 0000000..289642f --- /dev/null +++ b/src/api/types/WebhookDeliveryStatus.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Lifecycle of a webhook delivery row. The sender updates the same row + * across retries, so a read always sees the latest outcome. + */ +export const WebhookDeliveryStatus = { + Pending: "pending", + Delivered: "delivered", + Failed: "failed", +} as const; +export type WebhookDeliveryStatus = (typeof WebhookDeliveryStatus)[keyof typeof WebhookDeliveryStatus]; diff --git a/src/api/types/WebhookEndpoint.ts b/src/api/types/WebhookEndpoint.ts new file mode 100644 index 0000000..fa65eb8 --- /dev/null +++ b/src/api/types/WebhookEndpoint.ts @@ -0,0 +1,70 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A workspace webhook endpoint: a destination URL, the events it + * subscribes to, and a server-minted HMAC signing secret. `secret` is + * returned ONLY in the create and rotate-secret responses — store it + * then; every other read omits it. + * + * An endpoint is either scoped to one project (`project_id`) or + * workspace-wide, and a workspace-wide endpoint receives events from + * every project. + */ +export interface WebhookEndpoint { + /** Prefixed wire id (`whe_<26 char Crockford base32>`). */ + id: string; + /** HTTPS destination Speechify POSTs signed events to. */ + url: string; + /** + * The project whose events this endpoint receives (prefixed + * external id). Null means workspace-wide - it receives every + * project's events. Endpoints have no Default project. + * + * An event is routed by the project frozen on the row that + * produced it (an API key's project, for example), and for a + * `project.spend_budget.*` event the project itself. + * Workspace-level events such as `workspace.spend_budget.*` belong + * to no project and reach workspace-wide endpoints only, so a + * scoped endpoint subscribed to those alone is refused with a 400 + * naming `enabled_events` rather than accepted and never delivered + * to. A scoped endpoint records no delivery for another project's + * events. + */ + project_id?: (string | null) | undefined; + /** + * The events this endpoint receives: a list of catalog event names + * (for example `workspace.spend_budget.warning`) or `["*"]` for + * every event, current and future. + */ + enabled_events: string[]; + /** + * Per-event payload shaping. Deliveries are lean by default: + * `data.object` carries only the resource GET snapshot. List heavy + * collections here to have them appended under the event's `data` + * alongside `object`, so receivers behind hard request-size caps + * stay lean unless they opt in. An event's documentation names the + * keys it recognises. Empty = lean. + */ + include: string[]; + /** + * The dated payload shape this endpoint receives (`YYYY-MM-DD`), the + * same versioning vocabulary the REST API uses. Every delivery is + * rendered back to this version and carries it in the + * `Speechify-Version` header and the payload's top-level `version` + * field. Defaults to your workspace's current version at creation; + * change it to opt into a newer shape. + */ + api_version: string; + /** Optional human-readable label for the endpoint. */ + description?: (string | null) | undefined; + /** When true, Speechify stops delivering to this endpoint. */ + disabled: boolean; + /** + * The HMAC-SHA256 signing secret (`whsec_…`) used to verify the + * `Speechify-Signature` header. Returned ONLY when the endpoint is + * created or its secret is rotated — it is never shown again. + */ + secret?: string | undefined; + created_at: string; + updated_at: string; +} diff --git a/src/api/types/WebhookEndpointDelivery.ts b/src/api/types/WebhookEndpointDelivery.ts new file mode 100644 index 0000000..2f2451c --- /dev/null +++ b/src/api/types/WebhookEndpointDelivery.ts @@ -0,0 +1,36 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Speechify from "../index.js"; + +/** + * One row of an endpoint's delivery log. One row per (endpoint, event, + * resource); updated in place across retry attempts. Each row records the + * exact request payload + signed headers Speechify sent and the response + * your server returned, so you can verify the signature and debug failures. + */ +export interface WebhookEndpointDelivery { + /** Prefixed delivery id (`whd_<26 char Crockford base32>`). */ + id: string; + /** The endpoint this delivery targeted (`whe_…`). */ + webhook_endpoint_id: string; + /** The event type delivered (see `WebhookEventType`). */ + event: string; + /** The destination URL at delivery time. */ + url: string; + status: Speechify.WebhookDeliveryStatus; + attempt_count: number; + last_attempt_at?: string | undefined; + last_status_code?: number | undefined; + last_error?: string | undefined; + created_at: string; + /** + * The verbatim payload the `Speechify-Signature` HMAC was computed over + * (as `.`). + */ + request_body?: string | undefined; + /** Headers sent, including `Speechify-Signature` / `Speechify-Event` / `Speechify-Delivery-Id`. */ + request_headers?: Record | undefined; + /** Your server's response body on the most recent attempt (truncated to 8 KiB). */ + last_response_body?: string | undefined; + last_response_headers?: Record | undefined; +} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index 6793d96..3a02ba4 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,6 +1,8 @@ export * from "./AudioOutputFormat.js"; export * from "./AudioStreamOutputFormat.js"; +export * from "./BillingEntitlements.js"; export * from "./ConsentChallenge.js"; +export * from "./EntitlementsResponse.js"; export * from "./Error_.js"; export * from "./ErrorCode.js"; export * from "./ErrorDetail.js"; @@ -11,13 +13,36 @@ export * from "./GetStreamRequest.js"; export * from "./GetVoice.js"; export * from "./GetVoiceLanguage.js"; export * from "./GetVoicesModel.js"; +export * from "./ListProjectsResponse.js"; export * from "./ListVoicesResponse.js"; +export * from "./ListWebhookEndpointDeliveriesResponse.js"; +export * from "./ListWebhookEndpointsResponse.js"; export * from "./Model.js"; export * from "./ModelsResponse.js"; export * from "./NestedChunk.js"; export * from "./PaginationMeta.js"; +export * from "./Project.js"; +export * from "./ProjectAuditEvent.js"; +export * from "./ProjectAuditResponse.js"; +export * from "./ProjectMember.js"; +export * from "./ProjectMembersResponse.js"; +export * from "./ProjectRestore.js"; +export * from "./ProjectStillRevokedCounts.js"; +export * from "./Pronunciation.js"; +export * from "./PronunciationAlias.js"; +export * from "./PronunciationCaseSensitive.js"; +export * from "./PronunciationIpa.js"; +export * from "./PronunciationIpaText.js"; +export * from "./Pronunciations.js"; +export * from "./PronunciationText.js"; +export * from "./SafetyIdentifier.js"; export * from "./SpeechChunkEvent.js"; export * from "./SpeechDoneEvent.js"; export * from "./SpeechErrorEvent.js"; export * from "./SpeechMarks.js"; export * from "./SpeechStreamEvent.js"; +export * from "./WatermarkDetectionResponse.js"; +export * from "./WatermarkVerificationResponse.js"; +export * from "./WebhookDeliveryStatus.js"; +export * from "./WebhookEndpoint.js"; +export * from "./WebhookEndpointDelivery.js"; diff --git a/src/environments.ts b/src/environments.ts index 978c27a..35680cf 100644 --- a/src/environments.ts +++ b/src/environments.ts @@ -1,7 +1,15 @@ // This file was auto-generated by Fern from our API Definition. +export interface SpeechifyEnvironmentUrls { + base: string; + websocket: string; +} + export const SpeechifyEnvironment = { - Default: "https://api.speechify.ai", + Default: { + base: "https://api.speechify.ai", + websocket: "wss://api.speechify.ai", + }, } as const; export type SpeechifyEnvironment = typeof SpeechifyEnvironment.Default; diff --git a/src/index.ts b/src/index.ts index 2279aae..6a72f12 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ export * as Speechify from "./api/index.js"; export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js"; export { SpeechifyClient } from "./Client.js"; -export { SpeechifyEnvironment } from "./environments.js"; +export { SpeechifyEnvironment, type SpeechifyEnvironmentUrls } from "./environments.js"; export { SpeechifyError, SpeechifyTimeoutError } from "./errors/index.js"; export * from "./exports.js"; diff --git a/src/version.ts b/src/version.ts index 45528ca..2c0fafc 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "4.0.1"; +export const SDK_VERSION = "4.0.2"; diff --git a/tests/wire/audio.test.ts b/tests/wire/audio.test.ts index 132e360..4a1d5e7 100644 --- a/tests/wire/audio.test.ts +++ b/tests/wire/audio.test.ts @@ -11,7 +11,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { audio_format: "mp3", @@ -59,7 +59,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -87,7 +87,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -115,10 +115,10 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -143,10 +143,10 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -171,7 +171,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -199,10 +199,66 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/audio/speech") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.audio.speech({ + input: "input", + voice_id: "voice_id", + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("speech (8)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { input: "input", voice_id: "voice_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/audio/speech") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(413) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.audio.speech({ + input: "input", + voice_id: "voice_id", + }); + }).rejects.toThrow(Speechify.ContentTooLargeError); + }); + + test("speech (9)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { input: "input", voice_id: "voice_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -221,16 +277,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.TooManyRequestsError); }); - test("speech (8)", async () => { + test("speech (10)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -249,16 +305,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.InternalServerError); }); - test("speech (9)", async () => { + test("speech (11)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -277,16 +333,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.BadGatewayError); }); - test("speech (10)", async () => { + test("speech (12)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -311,7 +367,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "Streaming long-form audio with the Speechify API.", @@ -365,7 +421,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -395,7 +451,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -425,10 +481,10 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -455,10 +511,10 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -485,7 +541,7 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; const rawResponseBody = { key: "value" }; @@ -515,10 +571,70 @@ describe("AudioClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { input: "input", voice_id: "voice_id" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/audio/stream/with-timestamps") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.audio.streamWithTimestamps({ + body: { + input: "input", + voice_id: "voice_id", + }, + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("streamWithTimestamps (8)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/audio/stream/with-timestamps") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(413) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.audio.streamWithTimestamps({ + body: { + input: "input", + voice_id: "voice_id", + }, + }); + }).rejects.toThrow(Speechify.ContentTooLargeError); + }); + + test("streamWithTimestamps (9)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { input: "input", voice_id: "voice_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -539,16 +655,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.TooManyRequestsError); }); - test("streamWithTimestamps (8)", async () => { + test("streamWithTimestamps (10)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -569,16 +685,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.InternalServerError); }); - test("streamWithTimestamps (9)", async () => { + test("streamWithTimestamps (11)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -599,16 +715,16 @@ describe("AudioClient", () => { }).rejects.toThrow(Speechify.BadGatewayError); }); - test("streamWithTimestamps (10)", async () => { + test("streamWithTimestamps (12)", async () => { const server = mockServerPool.createServer(); const client = new SpeechifyClient({ maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { input: "input", voice_id: "voice_id" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() diff --git a/tests/wire/models.test.ts b/tests/wire/models.test.ts index 931027b..a069cab 100644 --- a/tests/wire/models.test.ts +++ b/tests/wire/models.test.ts @@ -11,61 +11,155 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { models: [ - { - id: "simba-english", - name: "Simba 1.6 English", - default: false, - recommended: false, - deprecated: true, - description: "Legacy Simba 1.6 English model, kept for compatibility. Prefer simba-3.2.", - languages: ["en"], - endpoints: ["/v1/audio/speech", "/v1/audio/stream"], - curated_voices: false, - english_voices_only: false, - }, - { - id: "simba-multilingual", - name: "Simba 1.6 Multilingual", - default: false, - recommended: false, - deprecated: true, - description: - "Legacy Simba 1.6 multilingual model covering 30+ languages, including mixed-language input. Prefer simba-3.0 for the languages it supports.", - languages: ["en", "fr-FR", "de-DE", "es-MX", "pt-BR", "ja-JP"], - endpoints: ["/v1/audio/speech", "/v1/audio/stream"], - curated_voices: false, - english_voices_only: false, - }, { id: "simba-3.0", name: "Simba 3.0", default: true, recommended: false, deprecated: false, + retired_at: "2026-09-21", + sunset_at: "2026-11-21", description: - "Streaming-native synthesis in English and six European languages, routed by the request `language`. The default when a request omits `model`.", + "Streaming-native model serving both English and multilingual synthesis under one id: English, German, Spanish, French, Italian and Portuguese, routed by the request `language`. The default when a request omits `model`.", languages: ["en", "de-DE", "es-ES", "es-MX", "fr-FR", "it-IT", "pt-BR"], endpoints: ["/v1/audio/speech", "/v1/audio/stream", "/v1/audio/stream/with-timestamps"], curated_voices: false, english_voices_only: false, + pronunciation_languages: ["de-DE", "es-ES", "fr-FR"], }, { id: "simba-3.2", name: "Simba 3.2", default: false, - recommended: true, + recommended: false, deprecated: false, + retired_at: "2026-09-21", + sunset_at: "2026-11-21", description: - "Streaming-native model with the lowest time-to-first-byte and richest expressivity, English only today. Serves the curated voice roster, plus your workspace's own cloned voices where cloning has been enabled for it.", + "Streaming-native model with the lowest time-to-first-byte and richest expressivity, English only today. Serves every English voice in the catalog, your workspace's own cloned voices included. Use `simba-3.0` for any other language.", languages: ["en"], endpoints: ["/v1/audio/speech", "/v1/audio/stream", "/v1/audio/stream/with-timestamps"], - curated_voices: true, + curated_voices: false, english_voices_only: true, + pronunciation_languages: ["de-DE", "es-ES", "fr-FR"], + }, + { + id: "simba-3.5", + name: "Simba 3.5", + default: false, + recommended: true, + deprecated: false, + retired_at: "2026-09-21", + sunset_at: "2026-11-21", + description: + "Streaming-native model covering 48 languages under one id, English included, routed by the request `language`. Accepted on /v1/audio/speech, /v1/audio/stream, /v1/audio/stream/with-timestamps and the /v1/audio/stream/ws input stream.", + languages: [ + "en", + "ar", + "be", + "bn", + "bs", + "ca", + "cs", + "da", + "de", + "el", + "es", + "fa", + "fi", + "fr", + "gu", + "he", + "hi", + "hr", + "hu", + "id", + "it", + "ja", + "ka", + "kk", + "ko", + "la", + "mr", + "ms", + "my", + "nl", + "no", + "pl", + "pt", + "ro", + "ru", + "sk", + "sl", + "sr", + "sv", + "ta", + "te", + "th", + "tl", + "tr", + "uk", + "ur", + "vi", + "zh", + ], + endpoints: ["/v1/audio/speech", "/v1/audio/stream", "/v1/audio/stream/with-timestamps"], + curated_voices: false, + english_voices_only: false, + pronunciation_languages: [ + "ar", + "be", + "bn", + "bs", + "ca", + "cs", + "da", + "de", + "el", + "es", + "fa", + "fi", + "fr", + "gu", + "he", + "hi", + "hr", + "hu", + "id", + "it", + "ja", + "ka", + "kk", + "ko", + "la", + "mr", + "ms", + "my", + "nl", + "no", + "pl", + "pt", + "ro", + "ru", + "sk", + "sl", + "sr", + "sv", + "ta", + "te", + "th", + "tl", + "tr", + "uk", + "ur", + "vi", + "zh", + ], }, ], dialogue_models: [ @@ -75,12 +169,15 @@ describe("ModelsClient", () => { default: true, recommended: false, deprecated: false, + retired_at: "2026-09-21", + sunset_at: "2026-11-21", description: "Multi-speaker model that renders a speaker-attributed script as one conversation with natural turn-taking.", languages: ["en"], endpoints: ["/v1/audio/dialogue"], curated_voices: false, english_voices_only: true, + pronunciation_languages: ["de-DE", "es-ES", "fr-FR"], }, ], }; @@ -97,7 +194,7 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -115,7 +212,7 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -133,10 +230,10 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/audio/models").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); @@ -151,10 +248,10 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/audio/models").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); @@ -169,10 +266,10 @@ describe("ModelsClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/audio/models").respondWith().statusCode(500).jsonBody(rawResponseBody).build(); diff --git a/tests/wire/projects.test.ts b/tests/wire/projects.test.ts new file mode 100644 index 0000000..823b64a --- /dev/null +++ b/tests/wire/projects.test.ts @@ -0,0 +1,2077 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Speechify from "../../src/api/index"; +import { SpeechifyClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; + +describe("ProjectsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + next_cursor: "next_cursor", + has_more: true, + projects: [ + { + purged_at: "2026-08-01T09:14:22Z", + max_requests_per_minute: 600, + monthly_budget: 500, + monthly_spend: 128.4412, + monthly_budget_status: "ok", + monthly_budget_remaining: 371.5588, + id: "proj_01arz3ndektsv4rrffq69g5fav", + name: "Production", + resource_count: 12, + created_at: "2026-08-18T18:03:11Z", + updated_at: "2026-08-18T18:03:11Z", + }, + ], + }; + + server + .mockEndpoint({ once: false }) + .get("/v1/projects") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = rawResponseBody; + const page = await client.projects.list(); + + expect(expected.projects).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.projects).toEqual(nextPage.data); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server.mockEndpoint().get("/v1/projects").respondWith().statusCode(400).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.projects.list(); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("list (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server.mockEndpoint().get("/v1/projects").respondWith().statusCode(401).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.projects.list(); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("list (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server.mockEndpoint().get("/v1/projects").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.projects.list(); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("list (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server.mockEndpoint().get("/v1/projects").respondWith().statusCode(500).jsonBody(rawResponseBody).build(); + + await expect(async () => { + return await client.projects.list(); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "Production" }; + const rawResponseBody = { + purged_at: "2026-08-01T09:14:22Z", + max_requests_per_minute: 600, + monthly_budget: 500, + monthly_spend: 128.4412, + monthly_budget_status: "ok", + monthly_budget_remaining: 371.5588, + id: "proj_01arz3ndektsv4rrffq69g5fav", + name: "Production", + resource_count: 12, + created_at: "2026-08-18T18:03:11Z", + updated_at: "2026-08-18T18:03:11Z", + }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.create({ + name: "Production", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.create({ + name: "name", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("create (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.create({ + name: "name", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("create (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.create({ + name: "name", + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("create (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.create({ + name: "name", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("create (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { name: "name" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.create({ + name: "name", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + purged_at: "2026-08-01T09:14:22Z", + max_requests_per_minute: 600, + monthly_budget: 500, + monthly_spend: 128.4412, + monthly_budget_status: "ok", + monthly_budget_remaining: 371.5588, + id: "proj_01arz3ndektsv4rrffq69g5fav", + name: "Production", + resource_count: 12, + created_at: "2026-08-18T18:03:11Z", + updated_at: "2026-08-18T18:03:11Z", + }; + + server + .mockEndpoint() + .get("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.get({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.get({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("get (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.get({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("get (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.get({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("get (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.get({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { mode: "purge", confirm: "Staging" }; + + server + .mockEndpoint() + .delete("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .build(); + + const response = await client.projects.delete({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + mode: "purge", + confirm: "Staging", + }); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("delete (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("delete (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("delete (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("delete (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("delete (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.delete({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { + purged_at: "2026-08-01T09:14:22Z", + max_requests_per_minute: 600, + monthly_budget: 500, + monthly_spend: 128.4412, + monthly_budget_status: "ok", + monthly_budget_remaining: 371.5588, + id: "proj_01arz3ndektsv4rrffq69g5fav", + name: "Production", + resource_count: 12, + created_at: "2026-08-18T18:03:11Z", + updated_at: "2026-08-18T18:03:11Z", + }; + + server + .mockEndpoint() + .patch("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.update({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("update (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("update (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("update (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("update (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("update (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .patch("/v1/projects/project_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.update({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("archive (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + server + .mockEndpoint() + .post("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/archive") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.projects.archive({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(undefined); + }); + + test("archive (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/archive") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.archive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("archive (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/archive") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.archive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("archive (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/archive") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.archive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("archive (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/archive") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.archive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("archive (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/archive") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.archive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("unarchive (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + server + .mockEndpoint() + .post("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/unarchive") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.projects.unarchive({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(undefined); + }); + + test("unarchive (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/unarchive") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.unarchive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("unarchive (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/unarchive") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.unarchive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("unarchive (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/unarchive") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.unarchive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("unarchive (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/unarchive") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.unarchive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("unarchive (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/unarchive") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.unarchive({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("restore (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + name: "Staging", + purged_at: "2026-08-01T09:14:22Z", + archived_at: "2026-07-31T16:02:10Z", + still_revoked: { api_keys: 2, service_accounts: 1, credentials: 1, webhook_endpoints: 0 }, + not_restored_note: + "Credentials this project's purge revoked stay revoked and access it cleared stays cleared: API keys, service accounts, vault credentials and webhook endpoints are not re-issued, and member grants and pending-invite scopes are not restored. Re-create the credentials and re-grant the members this project still needs.", + }; + + server + .mockEndpoint() + .post("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/restore") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.projects.restore({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("restore (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("restore (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("restore (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("restore (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(409) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ConflictError); + }); + + test("restore (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("restore (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/restore") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.restore({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("audit (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + next_cursor: "eyJrIjoicHJvamF1ZGl0IiwibyI6Mn0", + has_more: true, + events: [ + { + time: "2026-08-24T18:03:11Z", + type: "access_granted", + subject_user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + actor_user_id: "user_mzxw6ytboi7hy3tbnvsqorsxg5c7nzqw2zi", + actor_email: "admin@example.com", + actor_role: "admin", + remaining_grants: 2, + }, + { + time: "2026-08-21T09:14:02Z", + type: "archived", + actor_user_id: "user_mzxw6ytboi7hy3tbnvsqorsxg5c7nzqw2zi", + actor_email: "owner@example.com", + actor_role: "owner", + impersonator_email: "support@speechify.ai", + }, + ], + }; + + server + .mockEndpoint({ once: false }) + .get("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/audit") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = rawResponseBody; + const page = await client.projects.audit({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + + expect(expected.events).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.events).toEqual(nextPage.data); + }); + + test("audit (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("audit (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("audit (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("audit (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("audit (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("audit (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("audit (8)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/audit") + .respondWith() + .statusCode(503) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.audit({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.ServiceUnavailableError); + }); + + test("listMembers (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + next_cursor: "next_cursor", + has_more: true, + members: [ + { + user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + created_at: "2026-08-24T18:03:11Z", + granted_by: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + }, + ], + }; + + server + .mockEndpoint({ once: false }) + .get("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/members") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = rawResponseBody; + const page = await client.projects.listMembers({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + + expect(expected.members).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.members).toEqual(nextPage.data); + }); + + test("listMembers (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/members") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.listMembers({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("listMembers (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/members") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.listMembers({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("listMembers (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/members") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.listMembers({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("listMembers (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/members") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.listMembers({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("listMembers (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/projects/project_id/members") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.listMembers({ + project_id: "project_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("grantMember (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk" }; + + server + .mockEndpoint() + .post("/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .build(); + + const response = await client.projects.grantMember({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + }); + expect(response).toEqual(undefined); + }); + + test("grantMember (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("grantMember (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("grantMember (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("grantMember (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("grantMember (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("grantMember (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { user_id: "user_id" }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/projects/project_id/members") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.grantMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("revokeMember (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + server + .mockEndpoint() + .delete( + "/v1/projects/proj_01jqr8x9zg5k2m3n4p5q6r7s8t/members/user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + ) + .respondWith() + .statusCode(200) + .build(); + + const response = await client.projects.revokeMember({ + project_id: "proj_01jqr8x9zg5k2m3n4p5q6r7s8t", + user_id: "user_kb3fim3yjnyto3kxli4g4ysdmyzgiuttjrudswlkgbawk", + }); + expect(response).toEqual(undefined); + }); + + test("revokeMember (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id/members/user_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.revokeMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("revokeMember (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id/members/user_id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.revokeMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("revokeMember (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id/members/user_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.revokeMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("revokeMember (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id/members/user_id") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.revokeMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("revokeMember (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/projects/project_id/members/user_id") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.projects.revokeMember({ + project_id: "project_id", + user_id: "user_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); +}); diff --git a/tests/wire/voices.test.ts b/tests/wire/voices.test.ts index 7f0f981..bccfacd 100644 --- a/tests/wire/voices.test.ts +++ b/tests/wire/voices.test.ts @@ -11,7 +11,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { @@ -24,8 +24,11 @@ describe("VoicesClient", () => { gender: "male", locale: "en-US", id: "scott", - models: [{ languages: [{ locale: "locale" }], name: "simba-english" }], + models: [{ languages: [{ locale: "locale" }], name: "simba-3.0" }], preview_audio: "example", + project_id: "proj_01kwxwcbyb6wk952swa0432cf1", + can_manage: true, + staff_pick_rank: 1, tags: ["example"], type: "shared", }, @@ -44,6 +47,7 @@ describe("VoicesClient", () => { const page = await client.voices.list({ locale: "en", model: "simba-3.2", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", }); expect(expected.voices).toEqual(page.data); @@ -58,7 +62,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -76,7 +80,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -94,10 +98,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/voices").respondWith().statusCode(403).jsonBody(rawResponseBody).build(); @@ -112,10 +116,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/voices").respondWith().statusCode(429).jsonBody(rawResponseBody).build(); @@ -130,10 +134,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server.mockEndpoint().get("/v1/voices").respondWith().statusCode(500).jsonBody(rawResponseBody).build(); @@ -148,7 +152,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { @@ -157,8 +161,11 @@ describe("VoicesClient", () => { gender: "male", locale: "en-US", id: "scott", - models: [{ languages: [{ locale: "locale" }], name: "simba-english" }], + models: [{ languages: [{ locale: "locale" }], name: "simba-3.0" }], preview_audio: "example", + project_id: "proj_01kwxwcbyb6wk952swa0432cf1", + can_manage: true, + staff_pick_rank: 1, tags: ["example"], type: "shared", }; @@ -183,7 +190,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -209,7 +216,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -235,7 +242,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -261,10 +268,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -287,10 +294,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -313,10 +320,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -339,10 +346,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -365,7 +372,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); server.mockEndpoint().delete("/v1/voices/voice_id").respondWith().statusCode(200).build(); @@ -382,7 +389,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -408,7 +415,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -434,10 +441,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -460,7 +467,7 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawResponseBody = { key: "value" }; @@ -486,10 +493,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -512,10 +519,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -538,10 +545,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -564,10 +571,10 @@ describe("VoicesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() diff --git a/tests/wire/voices/consentChallenges.test.ts b/tests/wire/voices/consentChallenges.test.ts index 489118b..acd4a3a 100644 --- a/tests/wire/voices/consentChallenges.test.ts +++ b/tests/wire/voices/consentChallenges.test.ts @@ -11,7 +11,7 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "Jane Doe" }; const rawResponseBody = { @@ -43,7 +43,7 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; const rawResponseBody = { key: "value" }; @@ -70,7 +70,7 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; const rawResponseBody = { key: "value" }; @@ -97,10 +97,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -124,10 +124,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -151,7 +151,7 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; const rawResponseBody = { key: "value" }; @@ -178,10 +178,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -205,10 +205,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -232,10 +232,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() @@ -259,10 +259,10 @@ describe("ConsentChallengesClient", () => { maxRetries: 0, token: "test", version: "test", - environment: server.baseUrl, + environment: { base: server.baseUrl, websocket: server.baseUrl }, }); const rawRequestBody = { full_name: "full_name" }; - const rawResponseBody = { error: { code: "bad_request", message: "message" } }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; server .mockEndpoint() diff --git a/tests/wire/webhooks/endpoints.test.ts b/tests/wire/webhooks/endpoints.test.ts new file mode 100644 index 0000000..544b388 --- /dev/null +++ b/tests/wire/webhooks/endpoints.test.ts @@ -0,0 +1,1265 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Speechify from "../../../src/api/index"; +import { SpeechifyClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("EndpointsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + next_cursor: "next_cursor", + has_more: true, + endpoints: [ + { + id: "whe_01kwxwcbyb6wk952swa0432cf1", + url: "https://example.com/speechify/webhooks", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + enabled_events: ["project.spend_budget.warning"], + include: ["include"], + api_version: "2026-06-28", + description: "Example description.", + disabled: false, + secret: "whsec_demo••••0000", + created_at: "2026-06-24T18:03:11Z", + updated_at: "2026-06-24T18:03:11Z", + }, + ], + }; + + server + .mockEndpoint({ once: false }) + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = rawResponseBody; + const page = await client.webhooks.endpoints.list({ + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + }); + + expect(expected.endpoints).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.endpoints).toEqual(nextPage.data); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.list(); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("list (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.list(); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("list (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.list(); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("list (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.list(); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("list (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.list(); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { + url: "https://example.com/speechify/webhooks", + enabled_events: ["project.spend_budget.warning"], + description: "Example description.", + }; + const rawResponseBody = { + id: "whe_01kwxwcbyb6wk952swa0432cf1", + url: "https://example.com/speechify/webhooks", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + enabled_events: ["project.spend_budget.warning"], + include: ["include"], + api_version: "2026-06-28", + description: "Example description.", + disabled: false, + secret: "whsec_demo••••0000", + created_at: "2026-06-24T18:03:11Z", + updated_at: "2026-06-24T18:03:11Z", + }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhooks.endpoints.create({ + url: "https://example.com/speechify/webhooks", + enabled_events: ["project.spend_budget.warning"], + description: "Example description.", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("create (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("create (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("create (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("create (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(422) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.UnprocessableEntityError); + }); + + test("create (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("create (8)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { url: "url", enabled_events: ["enabled_events", "enabled_events"] }; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.create({ + url: "url", + enabled_events: ["enabled_events", "enabled_events"], + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + id: "whe_01kwxwcbyb6wk952swa0432cf1", + url: "https://example.com/speechify/webhooks", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + enabled_events: ["project.spend_budget.warning"], + include: ["include"], + api_version: "2026-06-28", + description: "Example description.", + disabled: false, + secret: "whsec_demo••••0000", + created_at: "2026-06-24T18:03:11Z", + updated_at: "2026-06-24T18:03:11Z", + }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/whe_01jqr8x9zg5k2m3n4p5q6r7s8t") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhooks.endpoints.get({ + webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.get({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("get (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.get({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("get (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.get({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("get (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.get({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/whe_01jqr8x9zg5k2m3n4p5q6r7s8t") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("delete (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("delete (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("delete (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("delete (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .delete("/v1/webhooks/endpoints/webhook_endpoint_id") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.delete({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = { + url: "https://example.com/webhook", + enabled_events: ["example"], + description: "Example description.", + disabled: false, + }; + const rawResponseBody = { + id: "whe_01kwxwcbyb6wk952swa0432cf1", + url: "https://example.com/speechify/webhooks", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + enabled_events: ["project.spend_budget.warning"], + include: ["include"], + api_version: "2026-06-28", + description: "Example description.", + disabled: false, + secret: "whsec_demo••••0000", + created_at: "2026-06-24T18:03:11Z", + updated_at: "2026-06-24T18:03:11Z", + }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/whe_01jqr8x9zg5k2m3n4p5q6r7s8t") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhooks.endpoints.update({ + webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + url: "https://example.com/webhook", + enabled_events: ["example"], + description: "Example description.", + disabled: false, + }); + expect(response).toEqual(rawResponseBody); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("update (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("update (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("update (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("update (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("update (7)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .patch("/v1/webhooks/endpoints/webhook_endpoint_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.update({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("rotateSecret (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + id: "whe_01kwxwcbyb6wk952swa0432cf1", + url: "https://example.com/speechify/webhooks", + project_id: "proj_01arz3ndektsv4rrffq69g5fav", + enabled_events: ["project.spend_budget.warning"], + include: ["include"], + api_version: "2026-06-28", + description: "Example description.", + disabled: false, + secret: "whsec_demo••••0000", + created_at: "2026-06-24T18:03:11Z", + updated_at: "2026-06-24T18:03:11Z", + }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/whe_01jqr8x9zg5k2m3n4p5q6r7s8t/rotate-secret") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + expect(response).toEqual(rawResponseBody); + }); + + test("rotateSecret (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/webhook_endpoint_id/rotate-secret") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("rotateSecret (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/webhook_endpoint_id/rotate-secret") + .respondWith() + .statusCode(403) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.ForbiddenError); + }); + + test("rotateSecret (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/webhook_endpoint_id/rotate-secret") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("rotateSecret (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/webhook_endpoint_id/rotate-secret") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("rotateSecret (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .post("/v1/webhooks/endpoints/webhook_endpoint_id/rotate-secret") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.rotateSecret({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); + + test("listDeliveries (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + next_cursor: "next_cursor", + has_more: true, + deliveries: [ + { + id: "whd_01krzmwm42h2hpk18sxc1hf937", + webhook_endpoint_id: "whe_01kwxwcbyb6wk952swa0432cf1", + event: "project.spend_budget.warning", + url: "url", + status: "pending", + attempt_count: 1, + last_attempt_at: "2024-01-15T09:30:00Z", + last_status_code: 1, + last_error: "last_error", + created_at: "2024-01-15T09:30:00Z", + request_body: "request_body", + request_headers: { key: "value" }, + last_response_body: "last_response_body", + last_response_headers: { key: "value" }, + }, + ], + }; + + server + .mockEndpoint({ once: false }) + .get("/v1/webhooks/endpoints/whe_01jqr8x9zg5k2m3n4p5q6r7s8t/deliveries") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const expected = rawResponseBody; + const page = await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "whe_01jqr8x9zg5k2m3n4p5q6r7s8t", + }); + + expect(expected.deliveries).toEqual(page.data); + expect(page.hasNextPage()).toBe(true); + const nextPage = await page.getNextPage(); + expect(expected.deliveries).toEqual(nextPage.data); + }); + + test("listDeliveries (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id/deliveries") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.BadRequestError); + }); + + test("listDeliveries (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id/deliveries") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("listDeliveries (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id/deliveries") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.NotFoundError); + }); + + test("listDeliveries (5)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id/deliveries") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("listDeliveries (6)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/webhooks/endpoints/webhook_endpoint_id/deliveries") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.webhooks.endpoints.listDeliveries({ + webhook_endpoint_id: "webhook_endpoint_id", + }); + }).rejects.toThrow(Speechify.InternalServerError); + }); +}); diff --git a/tests/wire/workspaces.test.ts b/tests/wire/workspaces.test.ts new file mode 100644 index 0000000..1055605 --- /dev/null +++ b/tests/wire/workspaces.test.ts @@ -0,0 +1,143 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Speechify from "../../src/api/index"; +import { SpeechifyClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; + +describe("WorkspacesClient", () => { + test("getEntitlements (1)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { + catalog: { + pro: { + max_members: 1, + max_service_accounts: 50, + tts_requests_per_second: 20, + tts_concurrency: 15, + tts_end_user_requests_per_second: 1, + tts_end_user_concurrency: 1, + can_create_workspaces: true, + topup_allowed: true, + voice_cloning: true, + hosted_apis_access: true, + max_store_documents: 1, + max_store_bytes: 1000000, + enterprise_sso: false, + zero_data_retention: true, + voice_cloning_consent_exempt: true, + max_manual_top_up_usd: 1, + max_auto_recharge_charge_usd: 1, + }, + }, + current: { + max_members: 1, + max_service_accounts: 50, + tts_requests_per_second: 20, + tts_concurrency: 15, + tts_end_user_requests_per_second: 1, + tts_end_user_concurrency: 1, + can_create_workspaces: true, + topup_allowed: true, + voice_cloning: true, + hosted_apis_access: true, + max_store_documents: 1, + max_store_bytes: 1000000, + enterprise_sso: false, + zero_data_retention: true, + voice_cloning_consent_exempt: true, + max_manual_top_up_usd: 1, + max_auto_recharge_charge_usd: 1, + }, + }; + + server + .mockEndpoint() + .get("/v1/workspaces/current/entitlements") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.workspaces.getEntitlements(); + expect(response).toEqual(rawResponseBody); + }); + + test("getEntitlements (2)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/v1/workspaces/current/entitlements") + .respondWith() + .statusCode(401) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.workspaces.getEntitlements(); + }).rejects.toThrow(Speechify.UnauthorizedError); + }); + + test("getEntitlements (3)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/workspaces/current/entitlements") + .respondWith() + .statusCode(429) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.workspaces.getEntitlements(); + }).rejects.toThrow(Speechify.TooManyRequestsError); + }); + + test("getEntitlements (4)", async () => { + const server = mockServerPool.createServer(); + const client = new SpeechifyClient({ + maxRetries: 0, + token: "test", + version: "test", + environment: { base: server.baseUrl, websocket: server.baseUrl }, + }); + + const rawResponseBody = { error: { code: "endpoint_moved", message: "message" } }; + + server + .mockEndpoint() + .get("/v1/workspaces/current/entitlements") + .respondWith() + .statusCode(500) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.workspaces.getEntitlements(); + }).rejects.toThrow(Speechify.InternalServerError); + }); +});