diff --git a/.fern/metadata.json b/.fern/metadata.json index 7c906e18..44137cc0 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,5 +1,5 @@ { - "cliVersion": "4.3.0", + "cliVersion": "4.67.1", "generatorName": "fernapi/fern-typescript-node-sdk", "generatorVersion": "3.53.3", "generatorConfig": { @@ -9,10 +9,8 @@ "skipResponseValidation": true, "includeApiReference": true, "shouldGenerateWebsocketClients": true, - "enableForwardCompatibleEnums": true, - "packageJson": { - "name": "@deepgram/sdk" - } + "enableForwardCompatibleEnums": true }, - "sdkVersion": "5.0.0" + "originGitCommit": "7c77ce0f15bf78cb7e10ec5c4e79556f4f8dbbbe", + "sdkVersion": "5.0.1" } diff --git a/context7.json b/context7.json deleted file mode 100644 index 7714df0e..00000000 --- a/context7.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "url": "https://context7.com/deepgram/deepgram-js-sdk", - "public_key": "pk_hu7APZeIXQ14hNyaCBm0A" -} diff --git a/package.json b/package.json index a001cc39..bf71a3d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@deepgram/sdk", - "version": "5.0.0", + "version": "5.0.1", "private": false, "repository": { "type": "git", @@ -452,6 +452,39 @@ }, "default": "./dist/cjs/api/resources/speak/resources/v1/resources/audio/exports.js" }, + "./voiceAgent": { + "import": { + "types": "./dist/esm/api/resources/voiceAgent/exports.d.mts", + "default": "./dist/esm/api/resources/voiceAgent/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/voiceAgent/exports.d.ts", + "default": "./dist/cjs/api/resources/voiceAgent/exports.js" + }, + "default": "./dist/cjs/api/resources/voiceAgent/exports.js" + }, + "./voiceAgent/configurations": { + "import": { + "types": "./dist/esm/api/resources/voiceAgent/resources/configurations/exports.d.mts", + "default": "./dist/esm/api/resources/voiceAgent/resources/configurations/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/voiceAgent/resources/configurations/exports.d.ts", + "default": "./dist/cjs/api/resources/voiceAgent/resources/configurations/exports.js" + }, + "default": "./dist/cjs/api/resources/voiceAgent/resources/configurations/exports.js" + }, + "./voiceAgent/variables": { + "import": { + "types": "./dist/esm/api/resources/voiceAgent/resources/variables/exports.d.mts", + "default": "./dist/esm/api/resources/voiceAgent/resources/variables/exports.mjs" + }, + "require": { + "types": "./dist/cjs/api/resources/voiceAgent/resources/variables/exports.d.ts", + "default": "./dist/cjs/api/resources/voiceAgent/resources/variables/exports.js" + }, + "default": "./dist/cjs/api/resources/voiceAgent/resources/variables/exports.js" + }, "./package.json": "./package.json" }, "files": [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a7c79aab..ddf8312b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: ws: specifier: ^8.16.0 - version: 8.19.0 + version: 8.20.0 devDependencies: '@biomejs/biome': specifier: 2.4.3 @@ -1148,8 +1148,8 @@ packages: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} - ws@8.19.0: - resolution: {integrity: sha512-blAT2mjOEIi0ZzruJfIhb3nps74PRWTCz1IjglWEEpQl5XS/UNama6u2/rjFkDDouqr4L67ry+1aGIALViWjDg==} + ws@8.20.0: + resolution: {integrity: sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -2174,7 +2174,7 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - ws@8.19.0: {} + ws@8.20.0: {} y18n@5.0.8: {} diff --git a/reference.md b/reference.md index b36e3004..3b3f91d3 100644 --- a/reference.md +++ b/reference.md @@ -2930,3 +2930,730 @@ await client.speak.v1.audio.generate({ +## VoiceAgent Configurations +
client.voiceAgent.configurations.list(project_id) -> Deepgram.ListAgentConfigurationsV1Response +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Returns all agent configurations for the specified project. Configurations are returned in their uninterpolated formβ€”template variable placeholders appear as-is rather than with their substituted values. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.configurations.list("123456-7890-1234-5678-901234"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**requestOptions:** `ConfigurationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.configurations.create(project_id, { ...params }) -> Deepgram.CreateAgentConfigurationV1Response +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Creates a new reusable agent configuration. The `config` field must be a valid JSON string representing the `agent` block of a Settings message. The returned `agent_id` can be passed in place of the full `agent` object in future Settings messages. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.configurations.create("123456-7890-1234-5678-901234", { + config: "config" +}); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**request:** `Deepgram.voiceAgent.CreateAgentConfigurationV1Request` + +
+
+ +
+
+ +**requestOptions:** `ConfigurationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.configurations.get(project_id, agent_id) -> Deepgram.AgentConfigurationV1 +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Returns the specified agent configuration in its uninterpolated form +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.configurations.get("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**agent_id:** `string` β€” The unique identifier of the agent configuration + +
+
+ +
+
+ +**requestOptions:** `ConfigurationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.configurations.update(project_id, agent_id, { ...params }) -> Deepgram.AgentConfigurationV1 +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Updates the metadata associated with an agent configuration. The config itself is immutableβ€”to change the configuration, delete the existing agent and create a new one. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.configurations.update("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890", { + metadata: { + "key": "value" + } +}); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**agent_id:** `string` β€” The unique identifier of the agent configuration + +
+
+ +
+
+ +**request:** `Deepgram.voiceAgent.UpdateAgentMetadataV1Request` + +
+
+ +
+
+ +**requestOptions:** `ConfigurationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.configurations.delete(project_id, agent_id) -> Deepgram.DeleteAgentConfigurationV1Response +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Deletes the specified agent configuration. Deleting an agent configuration can cause a production outage if your service references this agent UUID. Migrate all active sessions to a new configuration before deleting. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.configurations.delete("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**agent_id:** `string` β€” The unique identifier of the agent configuration + +
+
+ +
+
+ +**requestOptions:** `ConfigurationsClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +## VoiceAgent Variables +
client.voiceAgent.variables.list(project_id) -> Deepgram.ListAgentVariablesV1Response +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Returns all template variables for the specified project +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.variables.list("123456-7890-1234-5678-901234"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**requestOptions:** `VariablesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.variables.create(project_id, { ...params }) -> Deepgram.AgentVariableV1 +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Creates a new template variable. Variables follow the `DG_` naming format and can substitute any JSON value in an agent configuration. +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.variables.create("project_id", { + key: "key", + value: { + "key": "value" + } +}); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**request:** `Deepgram.voiceAgent.CreateAgentVariableV1Request` + +
+
+ +
+
+ +**requestOptions:** `VariablesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.variables.get(project_id, variable_id) -> Deepgram.AgentVariableV1 +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Returns the specified template variable +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.variables.get("123456-7890-1234-5678-901234", "v1a2b3c4-d5e6-7890-abcd-ef1234567890"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**variable_id:** `string` β€” The unique identifier of the agent variable + +
+
+ +
+
+ +**requestOptions:** `VariablesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.variables.delete(project_id, variable_id) -> Deepgram.DeleteAgentVariableV1Response +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Deletes the specified template variable +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.variables.delete("123456-7890-1234-5678-901234", "v1a2b3c4-d5e6-7890-abcd-ef1234567890"); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**variable_id:** `string` β€” The unique identifier of the agent variable + +
+
+ +
+
+ +**requestOptions:** `VariablesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ +
client.voiceAgent.variables.update(project_id, variable_id, { ...params }) -> Deepgram.AgentVariableV1 +
+
+ +#### πŸ“ Description + +
+
+ +
+
+ +Updates the value of an existing template variable +
+
+
+
+ +#### πŸ”Œ Usage + +
+
+ +
+
+ +```typescript +await client.voiceAgent.variables.update("project_id", "variable_id", { + value: { + "key": "value" + } +}); + +``` +
+
+
+
+ +#### βš™οΈ Parameters + +
+
+ +
+
+ +**project_id:** `string` β€” The unique identifier of the project + +
+
+ +
+
+ +**variable_id:** `string` β€” The unique identifier of the agent variable + +
+
+ +
+
+ +**request:** `Deepgram.voiceAgent.UpdateAgentVariableV1Request` + +
+
+ +
+
+ +**requestOptions:** `VariablesClient.RequestOptions` + +
+
+
+
+ + +
+
+
+ diff --git a/src/BaseClient.ts b/src/BaseClient.ts index 0c5c9340..25ae78ab 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -52,8 +52,8 @@ export function normalizeClientOptions; + protected _configurations: ConfigurationsClient | undefined; + protected _variables: VariablesClient | undefined; + + constructor(options: VoiceAgentClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + public get configurations(): ConfigurationsClient { + return (this._configurations ??= new ConfigurationsClient(this._options)); + } + + public get variables(): VariablesClient { + return (this._variables ??= new VariablesClient(this._options)); + } +} diff --git a/src/api/resources/voiceAgent/client/index.ts b/src/api/resources/voiceAgent/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/voiceAgent/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/voiceAgent/exports.ts b/src/api/resources/voiceAgent/exports.ts new file mode 100644 index 00000000..4dceb6e0 --- /dev/null +++ b/src/api/resources/voiceAgent/exports.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +export { VoiceAgentClient } from "./client/Client.js"; +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/voiceAgent/index.ts b/src/api/resources/voiceAgent/index.ts new file mode 100644 index 00000000..9eb1192d --- /dev/null +++ b/src/api/resources/voiceAgent/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./resources/index.js"; diff --git a/src/api/resources/voiceAgent/resources/configurations/client/Client.ts b/src/api/resources/voiceAgent/resources/configurations/client/Client.ts new file mode 100644 index 00000000..4023fe1a --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/client/Client.ts @@ -0,0 +1,415 @@ +// 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 } 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 Deepgram from "../../../../../index.js"; + +export declare namespace ConfigurationsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class ConfigurationsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: ConfigurationsClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns all agent configurations for the specified project. Configurations are returned in their uninterpolated formβ€”template variable placeholders appear as-is rather than with their substituted values. + * + * @param {string} project_id - The unique identifier of the project + * @param {ConfigurationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.configurations.list("123456-7890-1234-5678-901234") + */ + public list( + project_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(project_id, requestOptions)); + } + + private async __list( + project_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agents`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.ListAgentConfigurationsV1Response, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/agents", + ); + } + + /** + * Creates a new reusable agent configuration. The `config` field must be a valid JSON string representing the `agent` block of a Settings message. The returned `agent_id` can be passed in place of the full `agent` object in future Settings messages. + * + * @param {string} project_id - The unique identifier of the project + * @param {Deepgram.voiceAgent.CreateAgentConfigurationV1Request} request + * @param {ConfigurationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.configurations.create("123456-7890-1234-5678-901234", { + * config: "config" + * }) + */ + public create( + project_id: string, + request: Deepgram.voiceAgent.CreateAgentConfigurationV1Request, + requestOptions?: ConfigurationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(project_id, request, requestOptions)); + } + + private async __create( + project_id: string, + request: Deepgram.voiceAgent.CreateAgentConfigurationV1Request, + requestOptions?: ConfigurationsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agents`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + 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 Deepgram.CreateAgentConfigurationV1Response, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/agents", + ); + } + + /** + * Returns the specified agent configuration in its uninterpolated form + * + * @param {string} project_id - The unique identifier of the project + * @param {string} agent_id - The unique identifier of the agent configuration + * @param {ConfigurationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.configurations.get("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890") + */ + public get( + project_id: string, + agent_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(project_id, agent_id, requestOptions)); + } + + private async __get( + project_id: string, + agent_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agents/${core.url.encodePathParam(agent_id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.AgentConfigurationV1, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/agents/{agent_id}", + ); + } + + /** + * Updates the metadata associated with an agent configuration. The config itself is immutableβ€”to change the configuration, delete the existing agent and create a new one. + * + * @param {string} project_id - The unique identifier of the project + * @param {string} agent_id - The unique identifier of the agent configuration + * @param {Deepgram.voiceAgent.UpdateAgentMetadataV1Request} request + * @param {ConfigurationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.configurations.update("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890", { + * metadata: { + * "key": "value" + * } + * }) + */ + public update( + project_id: string, + agent_id: string, + request: Deepgram.voiceAgent.UpdateAgentMetadataV1Request, + requestOptions?: ConfigurationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(project_id, agent_id, request, requestOptions)); + } + + private async __update( + project_id: string, + agent_id: string, + request: Deepgram.voiceAgent.UpdateAgentMetadataV1Request, + requestOptions?: ConfigurationsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agents/${core.url.encodePathParam(agent_id)}`, + ), + method: "PUT", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + 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 Deepgram.AgentConfigurationV1, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PUT", + "/v1/projects/{project_id}/agents/{agent_id}", + ); + } + + /** + * Deletes the specified agent configuration. Deleting an agent configuration can cause a production outage if your service references this agent UUID. Migrate all active sessions to a new configuration before deleting. + * + * @param {string} project_id - The unique identifier of the project + * @param {string} agent_id - The unique identifier of the agent configuration + * @param {ConfigurationsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.configurations.delete("123456-7890-1234-5678-901234", "a1b2c3d4-e5f6-7890-abcd-ef1234567890") + */ + public delete( + project_id: string, + agent_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(project_id, agent_id, requestOptions)); + } + + private async __delete( + project_id: string, + agent_id: string, + requestOptions?: ConfigurationsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agents/${core.url.encodePathParam(agent_id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.DeleteAgentConfigurationV1Response, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/v1/projects/{project_id}/agents/{agent_id}", + ); + } +} diff --git a/src/api/resources/voiceAgent/resources/configurations/client/index.ts b/src/api/resources/voiceAgent/resources/configurations/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.ts b/src/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.ts new file mode 100644 index 00000000..5acf7e0d --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/client/requests/CreateAgentConfigurationV1Request.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * config: "config" + * } + */ +export interface CreateAgentConfigurationV1Request { + /** A valid JSON string representing the agent block of a Settings message */ + config: string; + /** A map of arbitrary key-value pairs for labeling or organizing the agent configuration */ + metadata?: Record; + /** API version. Defaults to 1 */ + api_version?: number; +} diff --git a/src/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.ts b/src/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.ts new file mode 100644 index 00000000..35d67f41 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/client/requests/UpdateAgentMetadataV1Request.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * metadata: { + * "key": "value" + * } + * } + */ +export interface UpdateAgentMetadataV1Request { + /** A map of string key-value pairs to associate with this agent configuration */ + metadata: Record; +} diff --git a/src/api/resources/voiceAgent/resources/configurations/client/requests/index.ts b/src/api/resources/voiceAgent/resources/configurations/client/requests/index.ts new file mode 100644 index 00000000..d41e3c72 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { CreateAgentConfigurationV1Request } from "./CreateAgentConfigurationV1Request.js"; +export type { UpdateAgentMetadataV1Request } from "./UpdateAgentMetadataV1Request.js"; diff --git a/src/api/resources/voiceAgent/resources/configurations/exports.ts b/src/api/resources/voiceAgent/resources/configurations/exports.ts new file mode 100644 index 00000000..0ca0f7ff --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { ConfigurationsClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/voiceAgent/resources/configurations/index.ts b/src/api/resources/voiceAgent/resources/configurations/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/voiceAgent/resources/configurations/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/voiceAgent/resources/index.ts b/src/api/resources/voiceAgent/resources/index.ts new file mode 100644 index 00000000..7d0d5e0e --- /dev/null +++ b/src/api/resources/voiceAgent/resources/index.ts @@ -0,0 +1,4 @@ +export * from "./configurations/client/requests/index.js"; +export * as configurations from "./configurations/index.js"; +export * from "./variables/client/requests/index.js"; +export * as variables from "./variables/index.js"; diff --git a/src/api/resources/voiceAgent/resources/variables/client/Client.ts b/src/api/resources/voiceAgent/resources/variables/client/Client.ts new file mode 100644 index 00000000..75eafa3a --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/client/Client.ts @@ -0,0 +1,415 @@ +// 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 } 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 Deepgram from "../../../../../index.js"; + +export declare namespace VariablesClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class VariablesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: VariablesClient.Options = {}) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * Returns all template variables for the specified project + * + * @param {string} project_id - The unique identifier of the project + * @param {VariablesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.variables.list("123456-7890-1234-5678-901234") + */ + public list( + project_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(project_id, requestOptions)); + } + + private async __list( + project_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agent-variables`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.ListAgentVariablesV1Response, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/agent-variables", + ); + } + + /** + * Creates a new template variable. Variables follow the `DG_` naming format and can substitute any JSON value in an agent configuration. + * + * @param {string} project_id - The unique identifier of the project + * @param {Deepgram.voiceAgent.CreateAgentVariableV1Request} request + * @param {VariablesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.variables.create("project_id", { + * key: "key", + * value: { + * "key": "value" + * } + * }) + */ + public create( + project_id: string, + request: Deepgram.voiceAgent.CreateAgentVariableV1Request, + requestOptions?: VariablesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(project_id, request, requestOptions)); + } + + private async __create( + project_id: string, + request: Deepgram.voiceAgent.CreateAgentVariableV1Request, + requestOptions?: VariablesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agent-variables`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + 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 Deepgram.AgentVariableV1, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/v1/projects/{project_id}/agent-variables", + ); + } + + /** + * Returns the specified template variable + * + * @param {string} project_id - The unique identifier of the project + * @param {string} variable_id - The unique identifier of the agent variable + * @param {VariablesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.variables.get("123456-7890-1234-5678-901234", "v1a2b3c4-d5e6-7890-abcd-ef1234567890") + */ + public get( + project_id: string, + variable_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(project_id, variable_id, requestOptions)); + } + + private async __get( + project_id: string, + variable_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agent-variables/${core.url.encodePathParam(variable_id)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.AgentVariableV1, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/v1/projects/{project_id}/agent-variables/{variable_id}", + ); + } + + /** + * Deletes the specified template variable + * + * @param {string} project_id - The unique identifier of the project + * @param {string} variable_id - The unique identifier of the agent variable + * @param {VariablesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.variables.delete("123456-7890-1234-5678-901234", "v1a2b3c4-d5e6-7890-abcd-ef1234567890") + */ + public delete( + project_id: string, + variable_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(project_id, variable_id, requestOptions)); + } + + private async __delete( + project_id: string, + variable_id: string, + requestOptions?: VariablesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agent-variables/${core.url.encodePathParam(variable_id)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + 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 Deepgram.DeleteAgentVariableV1Response, + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/v1/projects/{project_id}/agent-variables/{variable_id}", + ); + } + + /** + * Updates the value of an existing template variable + * + * @param {string} project_id - The unique identifier of the project + * @param {string} variable_id - The unique identifier of the agent variable + * @param {Deepgram.voiceAgent.UpdateAgentVariableV1Request} request + * @param {VariablesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Deepgram.BadRequestError} + * + * @example + * await client.voiceAgent.variables.update("project_id", "variable_id", { + * value: { + * "key": "value" + * } + * }) + */ + public update( + project_id: string, + variable_id: string, + request: Deepgram.voiceAgent.UpdateAgentVariableV1Request, + requestOptions?: VariablesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(project_id, variable_id, request, requestOptions)); + } + + private async __update( + project_id: string, + variable_id: string, + request: Deepgram.voiceAgent.UpdateAgentVariableV1Request, + requestOptions?: VariablesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + requestOptions?.headers, + ); + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + ( + (await core.Supplier.get(this._options.environment)) ?? + environments.DeepgramEnvironment.Production + ).base, + `v1/projects/${core.url.encodePathParam(project_id)}/agent-variables/${core.url.encodePathParam(variable_id)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + 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 Deepgram.AgentVariableV1, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Deepgram.BadRequestError(_response.error.body as unknown, _response.rawResponse); + default: + throw new errors.DeepgramError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PATCH", + "/v1/projects/{project_id}/agent-variables/{variable_id}", + ); + } +} diff --git a/src/api/resources/voiceAgent/resources/variables/client/index.ts b/src/api/resources/voiceAgent/resources/variables/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.ts b/src/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.ts new file mode 100644 index 00000000..ea9150d4 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/client/requests/CreateAgentVariableV1Request.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * key: "key", + * value: { + * "key": "value" + * } + * } + */ +export interface CreateAgentVariableV1Request { + /** The variable name, following the DG_ format */ + key: string; + value?: unknown; + /** API version. Defaults to 1 */ + api_version?: number; +} diff --git a/src/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.ts b/src/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.ts new file mode 100644 index 00000000..80cc3bab --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/client/requests/UpdateAgentVariableV1Request.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * { + * value: { + * "key": "value" + * } + * } + */ +export interface UpdateAgentVariableV1Request { + value?: unknown; +} diff --git a/src/api/resources/voiceAgent/resources/variables/client/requests/index.ts b/src/api/resources/voiceAgent/resources/variables/client/requests/index.ts new file mode 100644 index 00000000..d2c7c770 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { CreateAgentVariableV1Request } from "./CreateAgentVariableV1Request.js"; +export type { UpdateAgentVariableV1Request } from "./UpdateAgentVariableV1Request.js"; diff --git a/src/api/resources/voiceAgent/resources/variables/exports.ts b/src/api/resources/voiceAgent/resources/variables/exports.ts new file mode 100644 index 00000000..698f5784 --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/exports.ts @@ -0,0 +1,4 @@ +// This file was auto-generated by Fern from our API Definition. + +export { VariablesClient } from "./client/Client.js"; +export * from "./client/index.js"; diff --git a/src/api/resources/voiceAgent/resources/variables/index.ts b/src/api/resources/voiceAgent/resources/variables/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/voiceAgent/resources/variables/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/types/AgentConfigurationV1.ts b/src/api/types/AgentConfigurationV1.ts new file mode 100644 index 00000000..c6d9778e --- /dev/null +++ b/src/api/types/AgentConfigurationV1.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A reusable agent configuration + */ +export interface AgentConfigurationV1 { + /** The unique identifier of the agent configuration */ + agent_id: string; + /** The agent configuration object */ + config: Record; + /** A map of arbitrary key-value pairs for labeling or organizing the agent configuration */ + metadata?: Record | undefined; + /** Timestamp when the configuration was created */ + created_at?: string | undefined; + /** Timestamp when the configuration was last updated */ + updated_at?: string | undefined; +} diff --git a/src/api/types/AgentVariableV1.ts b/src/api/types/AgentVariableV1.ts new file mode 100644 index 00000000..4a5a872b --- /dev/null +++ b/src/api/types/AgentVariableV1.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * A template variable for agent configurations + */ +export interface AgentVariableV1 { + /** The unique identifier of the variable */ + variable_id: string; + /** The variable name, following the DG_ format */ + key: string; + value?: unknown | undefined; + /** Timestamp when the variable was created */ + created_at?: string | undefined; + /** Timestamp when the variable was last updated */ + updated_at?: string | undefined; +} diff --git a/src/api/types/Cartesia.ts b/src/api/types/Cartesia.ts index e3de482f..68c35283 100644 --- a/src/api/types/Cartesia.ts +++ b/src/api/types/Cartesia.ts @@ -9,6 +9,8 @@ export interface Cartesia { voice: Cartesia.Voice; /** Cartesia language code */ language?: string | undefined; + /** Volume level for Cartesia TTS output. Valid range: 0.5 to 2.0. See [Cartesia documentation](https://docs.cartesia.ai/build-with-cartesia/sonic-3/volume-speed-emotion#volume-speed-and-emotion). */ + volume?: number | undefined; } export namespace Cartesia { diff --git a/src/api/types/CreateAgentConfigurationV1Response.ts b/src/api/types/CreateAgentConfigurationV1Response.ts new file mode 100644 index 00000000..9465d027 --- /dev/null +++ b/src/api/types/CreateAgentConfigurationV1Response.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface CreateAgentConfigurationV1Response { + /** The unique identifier of the newly created agent configuration */ + agent_id: string; + /** The parsed agent configuration object */ + config: Record; + /** Metadata associated with the agent configuration */ + metadata?: Record | undefined; +} diff --git a/src/api/types/Deepgram.ts b/src/api/types/Deepgram.ts index a161a99a..c454f2ca 100644 --- a/src/api/types/Deepgram.ts +++ b/src/api/types/Deepgram.ts @@ -6,6 +6,8 @@ export interface Deepgram { version?: "v1" | undefined; /** Deepgram TTS model */ model: Deepgram.Model; + /** Speaking rate multiplier that adjusts the pace of generated speech while preserving natural prosody and voice quality. Not yet supported in all languages. */ + speed?: number | undefined; } export namespace Deepgram { diff --git a/src/api/types/DeleteAgentConfigurationV1Response.ts b/src/api/types/DeleteAgentConfigurationV1Response.ts new file mode 100644 index 00000000..e7e7cf2a --- /dev/null +++ b/src/api/types/DeleteAgentConfigurationV1Response.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Confirmation that the agent configuration was deleted + */ +export type DeleteAgentConfigurationV1Response = Record; diff --git a/src/api/types/DeleteAgentVariableV1Response.ts b/src/api/types/DeleteAgentVariableV1Response.ts new file mode 100644 index 00000000..faee0a57 --- /dev/null +++ b/src/api/types/DeleteAgentVariableV1Response.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Confirmation that the agent variable was deleted + */ +export type DeleteAgentVariableV1Response = Record; diff --git a/src/api/types/ListAgentConfigurationsV1Response.ts b/src/api/types/ListAgentConfigurationsV1Response.ts new file mode 100644 index 00000000..8a2c1b61 --- /dev/null +++ b/src/api/types/ListAgentConfigurationsV1Response.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Deepgram from "../index.js"; + +export interface ListAgentConfigurationsV1Response { + /** A list of agent configurations for the project */ + agents?: Deepgram.AgentConfigurationV1[] | undefined; +} diff --git a/src/api/types/ListAgentVariablesV1Response.ts b/src/api/types/ListAgentVariablesV1Response.ts new file mode 100644 index 00000000..b67487d2 --- /dev/null +++ b/src/api/types/ListAgentVariablesV1Response.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Deepgram from "../index.js"; + +export interface ListAgentVariablesV1Response { + /** A list of agent variables for the project */ + variables?: Deepgram.AgentVariableV1[] | undefined; +} diff --git a/src/api/types/ListenV1Callback.ts b/src/api/types/ListenV1Callback.ts index d9046700..c6dff70d 100644 --- a/src/api/types/ListenV1Callback.ts +++ b/src/api/types/ListenV1Callback.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * URL to which we'll make the callback request + */ export type ListenV1Callback = unknown; diff --git a/src/api/types/ListenV1Channels.ts b/src/api/types/ListenV1Channels.ts index 362953e4..354f7af1 100644 --- a/src/api/types/ListenV1Channels.ts +++ b/src/api/types/ListenV1Channels.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * The number of channels in the submitted audio + */ export type ListenV1Channels = unknown; diff --git a/src/api/types/ListenV1Endpointing.ts b/src/api/types/ListenV1Endpointing.ts index 2b313a03..cc6a9049 100644 --- a/src/api/types/ListenV1Endpointing.ts +++ b/src/api/types/ListenV1Endpointing.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Indicates how long Deepgram will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech_final parameter set to true. Can also be set to false to disable endpointing + */ export type ListenV1Endpointing = unknown; diff --git a/src/api/types/ListenV1Extra.ts b/src/api/types/ListenV1Extra.ts index 8457e361..c81e1193 100644 --- a/src/api/types/ListenV1Extra.ts +++ b/src/api/types/ListenV1Extra.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Arbitrary key-value pairs that are attached to the API response for usage in downstream processing + */ export type ListenV1Extra = unknown; diff --git a/src/api/types/ListenV1Keyterm.ts b/src/api/types/ListenV1Keyterm.ts index 6446ffc3..0f9911aa 100644 --- a/src/api/types/ListenV1Keyterm.ts +++ b/src/api/types/ListenV1Keyterm.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Key term prompting can boost specialized terminology and brands. Only compatible with Nova-3 + */ export type ListenV1Keyterm = unknown; diff --git a/src/api/types/ListenV1Keywords.ts b/src/api/types/ListenV1Keywords.ts index 0d88bed7..06f90204 100644 --- a/src/api/types/ListenV1Keywords.ts +++ b/src/api/types/ListenV1Keywords.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Keywords can boost or suppress specialized terminology and brands + */ export type ListenV1Keywords = unknown; diff --git a/src/api/types/ListenV1Language.ts b/src/api/types/ListenV1Language.ts index 1f614f5a..a159407e 100644 --- a/src/api/types/ListenV1Language.ts +++ b/src/api/types/ListenV1Language.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * The [BCP-47 language tag](https://tools.ietf.org/html/bcp47) that hints at the primary spoken language. Depending on the Model you choose only certain languages are available + */ export type ListenV1Language = unknown; diff --git a/src/api/types/ListenV1MipOptOut.ts b/src/api/types/ListenV1MipOptOut.ts index 8d86f80a..d016e8f6 100644 --- a/src/api/types/ListenV1MipOptOut.ts +++ b/src/api/types/ListenV1MipOptOut.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ export type ListenV1MipOptOut = unknown; diff --git a/src/api/types/ListenV1Replace.ts b/src/api/types/ListenV1Replace.ts index 9acccf5b..f12f2109 100644 --- a/src/api/types/ListenV1Replace.ts +++ b/src/api/types/ListenV1Replace.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Search for terms or phrases in submitted audio and replaces them + */ export type ListenV1Replace = unknown; diff --git a/src/api/types/ListenV1SampleRate.ts b/src/api/types/ListenV1SampleRate.ts index d37e86c8..5d704a76 100644 --- a/src/api/types/ListenV1SampleRate.ts +++ b/src/api/types/ListenV1SampleRate.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Sample rate of submitted audio. Required (and only read) when a value is provided for encoding + */ export type ListenV1SampleRate = unknown; diff --git a/src/api/types/ListenV1Search.ts b/src/api/types/ListenV1Search.ts index 3383114d..7953f17a 100644 --- a/src/api/types/ListenV1Search.ts +++ b/src/api/types/ListenV1Search.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Search for terms or phrases in submitted audio + */ export type ListenV1Search = unknown; diff --git a/src/api/types/ListenV1Tag.ts b/src/api/types/ListenV1Tag.ts index b1adf7c5..d434608c 100644 --- a/src/api/types/ListenV1Tag.ts +++ b/src/api/types/ListenV1Tag.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Label your requests for the purpose of identification during usage reporting + */ export type ListenV1Tag = unknown; diff --git a/src/api/types/ListenV1UtteranceEndMs.ts b/src/api/types/ListenV1UtteranceEndMs.ts index 31dcad6f..8fe22a4a 100644 --- a/src/api/types/ListenV1UtteranceEndMs.ts +++ b/src/api/types/ListenV1UtteranceEndMs.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Indicates how long Deepgram will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim_results + */ export type ListenV1UtteranceEndMs = unknown; diff --git a/src/api/types/ListenV1Version.ts b/src/api/types/ListenV1Version.ts index 5a11acdd..cd648458 100644 --- a/src/api/types/ListenV1Version.ts +++ b/src/api/types/ListenV1Version.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Version of an AI model to use + */ export type ListenV1Version = unknown; diff --git a/src/api/types/ListenV2EagerEotThreshold.ts b/src/api/types/ListenV2EagerEotThreshold.ts index ebb8480a..8f28cef2 100644 --- a/src/api/types/ListenV2EagerEotThreshold.ts +++ b/src/api/types/ListenV2EagerEotThreshold.ts @@ -1,3 +1,8 @@ // This file was auto-generated by Fern from our API Definition. +/** + * End-of-turn confidence required to fire an eager end-of-turn event. + * When set, enables `EagerEndOfTurn` and `TurnResumed` events. Valid + * Values 0.3 - 0.9. + */ export type ListenV2EagerEotThreshold = unknown; diff --git a/src/api/types/ListenV2EotThreshold.ts b/src/api/types/ListenV2EotThreshold.ts index 272c229c..79b8eb6f 100644 --- a/src/api/types/ListenV2EotThreshold.ts +++ b/src/api/types/ListenV2EotThreshold.ts @@ -1,3 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +/** + * End-of-turn confidence required to finish a turn. Valid Values 0.5 - + * 0.9. + */ export type ListenV2EotThreshold = unknown; diff --git a/src/api/types/ListenV2EotTimeoutMs.ts b/src/api/types/ListenV2EotTimeoutMs.ts index f61e2e56..ebc50d51 100644 --- a/src/api/types/ListenV2EotTimeoutMs.ts +++ b/src/api/types/ListenV2EotTimeoutMs.ts @@ -1,3 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +/** + * A turn will be finished when this much time has passed after speech, + * regardless of EOT confidence. + */ export type ListenV2EotTimeoutMs = unknown; diff --git a/src/api/types/ListenV2MipOptOut.ts b/src/api/types/ListenV2MipOptOut.ts index 75085a59..fdc17da7 100644 --- a/src/api/types/ListenV2MipOptOut.ts +++ b/src/api/types/ListenV2MipOptOut.ts @@ -1,3 +1,8 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Opts out requests from the Deepgram Model Improvement Program. Refer + * to our Docs for pricing impacts before setting this to true. + * https://dpgr.am/deepgram-mip + */ export type ListenV2MipOptOut = unknown; diff --git a/src/api/types/ListenV2Model.ts b/src/api/types/ListenV2Model.ts index 1b3431c8..c0f4aa36 100644 --- a/src/api/types/ListenV2Model.ts +++ b/src/api/types/ListenV2Model.ts @@ -1,6 +1,8 @@ // This file was auto-generated by Fern from our API Definition. -/** - * Defines the AI model used to process submitted audio. - */ -export type ListenV2Model = "flux-general-en"; +/** Defines the AI model used to process submitted audio. */ +export const ListenV2Model = { + FluxGeneralEn: "flux-general-en", + FluxGeneralMulti: "flux-general-multi", +} as const; +export type ListenV2Model = (typeof ListenV2Model)[keyof typeof ListenV2Model] | string; diff --git a/src/api/types/ListenV2SampleRate.ts b/src/api/types/ListenV2SampleRate.ts index 178ecdf6..47a79c2e 100644 --- a/src/api/types/ListenV2SampleRate.ts +++ b/src/api/types/ListenV2SampleRate.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Sample rate of the audio stream in Hz. Required if sending non-containerized/raw audio. If sending containerized audio, this parameter should be omitted. + */ export type ListenV2SampleRate = unknown; diff --git a/src/api/types/ListenV2Tag.ts b/src/api/types/ListenV2Tag.ts index 18aee426..22ef2d07 100644 --- a/src/api/types/ListenV2Tag.ts +++ b/src/api/types/ListenV2Tag.ts @@ -1,3 +1,7 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Label your requests for the purpose of identification during usage + * reporting + */ export type ListenV2Tag = unknown; diff --git a/src/api/types/SpeakV1MipOptOut.ts b/src/api/types/SpeakV1MipOptOut.ts index 51bda46f..344b1721 100644 --- a/src/api/types/SpeakV1MipOptOut.ts +++ b/src/api/types/SpeakV1MipOptOut.ts @@ -1,3 +1,6 @@ // This file was auto-generated by Fern from our API Definition. +/** + * Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip + */ export type SpeakV1MipOptOut = unknown; diff --git a/src/api/types/UsageBreakdownV1Response.ts b/src/api/types/UsageBreakdownV1Response.ts index 3e112b72..5c03feab 100644 --- a/src/api/types/UsageBreakdownV1Response.ts +++ b/src/api/types/UsageBreakdownV1Response.ts @@ -50,8 +50,7 @@ export namespace UsageBreakdownV1Response { endpoint?: string | undefined; /** Optional feature set identifier */ feature_set?: string | undefined; - /** Optional models identifier */ - models?: string | undefined; + models?: (string | undefined)[] | undefined; /** Optional method identifier */ method?: string | undefined; /** Optional tags */ diff --git a/src/api/types/index.ts b/src/api/types/index.ts index 6e15f166..c6975627 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -1,14 +1,19 @@ +export * from "./AgentConfigurationV1.js"; export * from "./AgentThinkModelsV1Response.js"; +export * from "./AgentVariableV1.js"; export * from "./Anthropic.js"; export * from "./AwsBedrockThinkProvider.js"; export * from "./AwsPollySpeakProvider.js"; export * from "./BillingBreakdownV1Response.js"; export * from "./Cartesia.js"; +export * from "./CreateAgentConfigurationV1Response.js"; export * from "./CreateKeyV1RequestOne.js"; export * from "./CreateKeyV1Response.js"; export * from "./CreateProjectDistributionCredentialsV1Response.js"; export * from "./CreateProjectInviteV1Response.js"; export * from "./Deepgram.js"; +export * from "./DeleteAgentConfigurationV1Response.js"; +export * from "./DeleteAgentVariableV1Response.js"; export * from "./DeleteProjectInviteV1Response.js"; export * from "./DeleteProjectKeyV1Response.js"; export * from "./DeleteProjectMemberV1Response.js"; @@ -28,6 +33,8 @@ export * from "./Google.js"; export * from "./GrantV1Response.js"; export * from "./Groq.js"; export * from "./LeaveProjectV1Response.js"; +export * from "./ListAgentConfigurationsV1Response.js"; +export * from "./ListAgentVariablesV1Response.js"; export * from "./ListBillingFieldsV1Response.js"; export * from "./ListenV1AcceptedResponse.js"; export * from "./ListenV1Callback.js"; diff --git a/src/version.ts b/src/version.ts index 486d377d..25cf4d29 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const SDK_VERSION = "4.11.4"; +export const SDK_VERSION = "5.0.1"; diff --git a/tests/wire/manage/v1/projects/usage/breakdown.test.ts b/tests/wire/manage/v1/projects/usage/breakdown.test.ts index 40c51fe3..b06b97fd 100644 --- a/tests/wire/manage/v1/projects/usage/breakdown.test.ts +++ b/tests/wire/manage/v1/projects/usage/breakdown.test.ts @@ -32,7 +32,7 @@ describe("BreakdownClient", () => { accessor: "123456789012345678901234", endpoint: "listen", feature_set: "punctuate", - models: "Nova-2", + models: ["Nova-2"], method: "async", tags: "tag1", deployment: "self-hosted", @@ -117,7 +117,7 @@ describe("BreakdownClient", () => { accessor: "123456789012345678901234", endpoint: "listen", feature_set: "punctuate", - models: "Nova-2", + models: ["Nova-2"], method: "async", tags: "tag1", deployment: "self-hosted", diff --git a/tests/wire/voiceAgent/configurations.test.ts b/tests/wire/voiceAgent/configurations.test.ts new file mode 100644 index 00000000..568771d9 --- /dev/null +++ b/tests/wire/voiceAgent/configurations.test.ts @@ -0,0 +1,314 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Deepgram from "../../../src/api/index"; +import { DeepgramClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("ConfigurationsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { + agents: [ + { + agent_id: "agent_id", + config: { key: "value" }, + metadata: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + }; + server + .mockEndpoint() + .get("/v1/projects/123456-7890-1234-5678-901234/agents") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.configurations.list("123456-7890-1234-5678-901234"); + expect(response).toEqual({ + agents: [ + { + agent_id: "agent_id", + config: { + key: "value", + }, + metadata: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + }); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/v1/projects/project_id/agents") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.configurations.list("project_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { config: "config" }; + const rawResponseBody = { agent_id: "agent_id", config: { key: "value" }, metadata: { key: "value" } }; + server + .mockEndpoint() + .post("/v1/projects/123456-7890-1234-5678-901234/agents") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.configurations.create("123456-7890-1234-5678-901234", { + config: "config", + }); + expect(response).toEqual({ + agent_id: "agent_id", + config: { + key: "value", + }, + metadata: { + key: "value", + }, + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { config: "config" }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/v1/projects/project_id/agents") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.configurations.create("project_id", { + config: "config", + }); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { + agent_id: "agent_id", + config: { key: "value" }, + metadata: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .get("/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.configurations.get( + "123456-7890-1234-5678-901234", + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + ); + expect(response).toEqual({ + agent_id: "agent_id", + config: { + key: "value", + }, + metadata: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/v1/projects/project_id/agents/agent_id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.configurations.get("project_id", "agent_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { metadata: { key: "value" } }; + const rawResponseBody = { + agent_id: "agent_id", + config: { key: "value" }, + metadata: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .put("/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.configurations.update( + "123456-7890-1234-5678-901234", + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + { + metadata: { + key: "value", + }, + }, + ); + expect(response).toEqual({ + agent_id: "agent_id", + config: { + key: "value", + }, + metadata: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { metadata: { metadata: "metadata" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .put("/v1/projects/project_id/agents/agent_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.configurations.update("project_id", "agent_id", { + metadata: { + metadata: "metadata", + }, + }); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/v1/projects/123456-7890-1234-5678-901234/agents/a1b2c3d4-e5f6-7890-abcd-ef1234567890") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.configurations.delete( + "123456-7890-1234-5678-901234", + "a1b2c3d4-e5f6-7890-abcd-ef1234567890", + ); + expect(response).toEqual({ + key: "value", + }); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/v1/projects/project_id/agents/agent_id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.configurations.delete("project_id", "agent_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); +}); diff --git a/tests/wire/voiceAgent/variables.test.ts b/tests/wire/voiceAgent/variables.test.ts new file mode 100644 index 00000000..8a5070ea --- /dev/null +++ b/tests/wire/voiceAgent/variables.test.ts @@ -0,0 +1,316 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Deepgram from "../../../src/api/index"; +import { DeepgramClient } from "../../../src/Client"; +import { mockServerPool } from "../../mock-server/MockServerPool"; + +describe("VariablesClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { + variables: [ + { + variable_id: "variable_id", + key: "key", + value: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + }; + server + .mockEndpoint() + .get("/v1/projects/123456-7890-1234-5678-901234/agent-variables") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.variables.list("123456-7890-1234-5678-901234"); + expect(response).toEqual({ + variables: [ + { + variable_id: "variable_id", + key: "key", + value: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }, + ], + }); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/v1/projects/project_id/agent-variables") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.variables.list("project_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { key: "key", value: { key: "value" } }; + const rawResponseBody = { + variable_id: "variable_id", + key: "key", + value: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .post("/v1/projects/project_id/agent-variables") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.variables.create("project_id", { + key: "key", + value: { + key: "value", + }, + }); + expect(response).toEqual({ + variable_id: "variable_id", + key: "key", + value: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { key: "key", value: { key: "value" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .post("/v1/projects/project_id/agent-variables") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.variables.create("project_id", { + key: "key", + value: { + key: "value", + }, + }); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { + variable_id: "variable_id", + key: "key", + value: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .get("/v1/projects/123456-7890-1234-5678-901234/agent-variables/v1a2b3c4-d5e6-7890-abcd-ef1234567890") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.variables.get( + "123456-7890-1234-5678-901234", + "v1a2b3c4-d5e6-7890-abcd-ef1234567890", + ); + expect(response).toEqual({ + variable_id: "variable_id", + key: "key", + value: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .get("/v1/projects/project_id/agent-variables/variable_id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.variables.get("project_id", "variable_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/v1/projects/123456-7890-1234-5678-901234/agent-variables/v1a2b3c4-d5e6-7890-abcd-ef1234567890") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.variables.delete( + "123456-7890-1234-5678-901234", + "v1a2b3c4-d5e6-7890-abcd-ef1234567890", + ); + expect(response).toEqual({ + key: "value", + }); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .delete("/v1/projects/project_id/agent-variables/variable_id") + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.variables.delete("project_id", "variable_id"); + }).rejects.toThrow(Deepgram.BadRequestError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { value: { key: "value" } }; + const rawResponseBody = { + variable_id: "variable_id", + key: "key", + value: { key: "value" }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }; + server + .mockEndpoint() + .patch("/v1/projects/project_id/agent-variables/variable_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.voiceAgent.variables.update("project_id", "variable_id", { + value: { + key: "value", + }, + }); + expect(response).toEqual({ + variable_id: "variable_id", + key: "key", + value: { + key: "value", + }, + created_at: "2024-01-15T09:30:00Z", + updated_at: "2024-01-15T09:30:00Z", + }); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + const client = new DeepgramClient({ + maxRetries: 0, + apiKey: "test", + environment: { base: server.baseUrl, agent: server.baseUrl, production: server.baseUrl }, + }); + const rawRequestBody = { value: { key: "value" } }; + const rawResponseBody = { key: "value" }; + server + .mockEndpoint() + .patch("/v1/projects/project_id/agent-variables/variable_id") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.voiceAgent.variables.update("project_id", "variable_id", { + value: { + key: "value", + }, + }); + }).rejects.toThrow(Deepgram.BadRequestError); + }); +});