Skip to content

Commit

Permalink
feat(api): update via SDK Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Mar 25, 2024
1 parent 3576d16 commit 1614607
Show file tree
Hide file tree
Showing 21 changed files with 156 additions and 449 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```bash
npm install git+ssh://git@github.com:stainless-sdks/retell-sdk-node.git
npm install git+ssh://git@github.com:stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk.git
```

Alternatively, to link a local copy of the repo:

```bash
# Clone
git clone https://www.github.com/stainless-sdks/retell-sdk-node
cd retell-sdk-node
git clone https://www.github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk
cd https:

# With yarn
yarn link
Expand Down Expand Up @@ -99,7 +99,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/stainless-sdks/retell-sdk-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ import RetellSdk from 'retell-sdk';
```

To do the inverse, add `import "retell-sdk/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/tree/main/src/_shims#readme)).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk/tree/main/src/_shims#readme)).

### Logging and middleware

Expand Down Expand Up @@ -283,7 +283,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/retell-sdk-node/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk/issues) with questions, bugs, or suggestions.

## Requirements

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"main": "dist/index.js",
"type": "commonjs",
"repository": "github:stainless-sdks/retell-sdk-node",
"repository": "github:stainless-sdks/https:",
"license": "Apache-2.0",
"packageManager": "yarn@1.22.21",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/_shims/index-deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function getDefaultAgent(url: string) {
}
export function fileFromPath() {
throw new Error(
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/retell-sdk-node#file-uploads',
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk#file-uploads',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/_shims/web-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean }
getDefaultAgent: (url: string) => undefined,
fileFromPath: () => {
throw new Error(
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/retell-sdk-node#file-uploads',
'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/https://github.com/RetellAI/retell-typescript-sdk#file-uploads',
);
},
isFsReadStream: (value: any) => false,
Expand Down
14 changes: 12 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { VERSION } from './version';
;
import {
RetellSdkError,
APIError,
Expand Down Expand Up @@ -38,6 +39,8 @@ type APIResponseProps = {

async function defaultParseResponse<T>(props: APIResponseProps): Promise<T> {
const { response } = props;
;

// fetch refuses to read the body when the status code is 204.
if (response.status === 204) {
return null as T;
Expand Down Expand Up @@ -194,7 +197,7 @@ export abstract class APIClient {
Accept: 'application/json',
'Content-Type': 'application/json',
'User-Agent': this.getUserAgent(),
...getPlatformHeaders(),
...getPlatformHeaders(),
...this.authHeaders(opts),
};
}
Expand Down Expand Up @@ -735,7 +738,10 @@ export type RequestOptions<Req = unknown | Record<string, unknown> | Readable> =
signal?: AbortSignal | undefined | null;
idempotencyKey?: string;



__binaryResponse?: boolean | undefined;

};

// This is required so that we can determine if a given object matches the RequestOptions
Expand All @@ -755,7 +761,10 @@ const requestOptionsKeys: KeysEnum<RequestOptions> = {
signal: true,
idempotencyKey: true,



__binaryResponse: true,

};

export const isRequestOptions = (obj: unknown): obj is RequestOptions => {
Expand Down Expand Up @@ -963,7 +972,8 @@ export const castToError = (err: any): Error => {
};

export const ensurePresent = <T>(value: T | null | undefined): T => {
if (value == null) throw new RetellSdkError(`Expected a value to be given but received ${value} instead.`);
if (value == null)
throw new RetellSdkError(`Expected a value to be given but received ${value} instead.`);
return value;
};

Expand Down
25 changes: 9 additions & 16 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

import { castToError, Headers } from './core';

export class RetellSdkError extends Error {}
export class RetellSdkError extends Error {
}

export class APIError extends RetellSdkError {
readonly status: number | undefined;
readonly headers: Headers | undefined;
readonly error: Object | undefined;

constructor(
status: number | undefined,
error: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
;

constructor(status: number | undefined, error: Object | undefined, message: string | undefined, headers: Headers | undefined) {
super(`${APIError.makeMessage(status, error, message)}`);
this.status = status;
this.headers = headers;
Expand All @@ -24,8 +22,7 @@ export class APIError extends RetellSdkError {
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
const msg =
error?.message ?
typeof error.message === 'string' ?
error.message
typeof error.message === 'string' ? error.message
: JSON.stringify(error.message)
: error ? JSON.stringify(error)
: message;
Expand All @@ -42,12 +39,7 @@ export class APIError extends RetellSdkError {
return '(no status code or body)';
}

static generate(
status: number | undefined,
errorResponse: Object | undefined,
message: string | undefined,
headers: Headers | undefined,
) {
static generate(status: number | undefined, errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined) {
if (!status) {
return new APIConnectionError({ cause: castToError(errorResponse) });
}
Expand Down Expand Up @@ -143,4 +135,5 @@ export class RateLimitError extends APIError {
override readonly status: 429 = 429;
}

export class InternalServerError extends APIError {}
export class InternalServerError extends APIError {
}
22 changes: 5 additions & 17 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import * as Core from './core';
import * as Errors from './error';
import { isRequestOptions } from './core';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import DigestFetch from 'digest-fetch';
import * as qs from 'qs';
import * as API from 'retell-sdk/resources/index';

Expand Down Expand Up @@ -95,7 +97,7 @@ export class RetellSdk extends Core.APIClient {
}: ClientOptions = {}) {
if (apiKey === undefined) {
throw new Errors.RetellSdkError(
"The RETELL_API_KEY environment variable is missing or empty; either provide it, or instantiate the RetellSdk client with an apiKey option, like new RetellSdk({ apiKey: 'My API Key' }).",
'The RETELL_API_KEY environment variable is missing or empty; either provide it, or instantiate the RetellSdk client with an apiKey option, like new RetellSdk({ apiKey: \'My API Key\' }).'
);
}

Expand Down Expand Up @@ -138,7 +140,7 @@ export class RetellSdk extends Core.APIClient {
}

protected override stringifyQuery(query: Record<string, unknown>): string {
return qs.stringify(query, { arrayFormat: 'comma' });
return qs.stringify(query, { arrayFormat: 'comma' })
}

static RetellSdk = this;
Expand All @@ -158,21 +160,7 @@ export class RetellSdk extends Core.APIClient {
static UnprocessableEntityError = Errors.UnprocessableEntityError;
}

export const {
RetellSdkError,
APIError,
APIConnectionError,
APIConnectionTimeoutError,
APIUserAbortError,
NotFoundError,
ConflictError,
RateLimitError,
BadRequestError,
AuthenticationError,
InternalServerError,
PermissionDeniedError,
UnprocessableEntityError,
} = Errors;
export const { RetellSdkError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError } = Errors

export import toFile = Uploads.toFile;
export import fileFromPath = Uploads.fileFromPath;
Expand Down
52 changes: 9 additions & 43 deletions src/resources/agent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'retell-sdk/core';
import { APIPromise } from 'retell-sdk/core';
import { APIResource } from 'retell-sdk/resource';
import { isRequestOptions } from 'retell-sdk/core';
import { type Response } from 'retell-sdk/_shims/index';
import * as AgentAPI from 'retell-sdk/resources/agent';

export class Agent extends APIResource {
Expand All @@ -22,11 +25,7 @@ export class Agent extends APIResource {
/**
* Update an existing agent
*/
update(
agentId: string,
body: AgentUpdateParams,
options?: Core.RequestOptions,
): Core.APIPromise<AgentResponse> {
update(agentId: string, body: AgentUpdateParams, options?: Core.RequestOptions): Core.APIPromise<AgentResponse> {
return this._client.patch(`/update-agent/${agentId}`, { body, ...options });
}

Expand All @@ -41,10 +40,7 @@ export class Agent extends APIResource {
* Delete an existing agent
*/
delete(agentId: string, options?: Core.RequestOptions): Core.APIPromise<void> {
return this._client.delete(`/delete-agent/${agentId}`, {
...options,
headers: { Accept: '*/*', ...options?.headers },
});
return this._client.delete(`/delete-agent/${agentId}`, { ...options, headers: { 'Accept': '*/*', ...options?.headers } });
}
}

Expand Down Expand Up @@ -142,17 +138,7 @@ export interface AgentResponse {
*
* - `deepgram voices`: supports English(en)
*/
language?:
| 'en-US'
| 'en-IN'
| 'en-GB'
| 'de-DE'
| 'es-ES'
| 'es-419'
| 'hi-IN'
| 'ja-JP'
| 'pt-PT'
| 'pt-BR';
language?: 'en-US' | 'en-IN' | 'en-GB' | 'de-DE' | 'es-ES' | 'es-419' | 'hi-IN' | 'ja-JP' | 'pt-PT' | 'pt-BR';

/**
* Disable transcripts and recordings storage for enhanced privacy. Access
Expand Down Expand Up @@ -192,7 +178,7 @@ export interface AgentResponse {
webhook_url?: string;
}

export type AgentListResponse = Array<AgentResponse>;
export type AgentListResponse = Array<AgentResponse>

export interface AgentCreateParams {
/**
Expand Down Expand Up @@ -277,17 +263,7 @@ export interface AgentCreateParams {
*
* - `deepgram voices`: supports English(en)
*/
language?:
| 'en-US'
| 'en-IN'
| 'en-GB'
| 'de-DE'
| 'es-ES'
| 'es-419'
| 'hi-IN'
| 'ja-JP'
| 'pt-PT'
| 'pt-BR';
language?: 'en-US' | 'en-IN' | 'en-GB' | 'de-DE' | 'es-ES' | 'es-419' | 'hi-IN' | 'ja-JP' | 'pt-PT' | 'pt-BR';

/**
* Disable transcripts and recordings storage for enhanced privacy. Access
Expand Down Expand Up @@ -397,17 +373,7 @@ export interface AgentUpdateParams {
*
* - `deepgram voices`: supports English(en)
*/
language?:
| 'en-US'
| 'en-IN'
| 'en-GB'
| 'de-DE'
| 'es-ES'
| 'es-419'
| 'hi-IN'
| 'ja-JP'
| 'pt-PT'
| 'pt-BR';
language?: 'en-US' | 'en-IN' | 'en-GB' | 'de-DE' | 'es-ES' | 'es-419' | 'hi-IN' | 'ja-JP' | 'pt-PT' | 'pt-BR';

/**
* The URL we will establish LLM websocket for getting response, usually your
Expand Down
13 changes: 6 additions & 7 deletions src/resources/call.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

import * as Core from 'retell-sdk/core';
import { APIPromise } from 'retell-sdk/core';
import { APIResource } from 'retell-sdk/resource';
import { isRequestOptions } from 'retell-sdk/core';
import { type Response } from 'retell-sdk/_shims/index';
import * as CallAPI from 'retell-sdk/resources/call';

export class Call extends APIResource {
Expand All @@ -23,12 +25,9 @@ export class Call extends APIResource {
/**
* Retrieve call details
*/
list(query?: CallListParams, options?: Core.RequestOptions): Core.APIPromise<CallListResponse>;
list(options?: Core.RequestOptions): Core.APIPromise<CallListResponse>;
list(
query: CallListParams | Core.RequestOptions = {},
options?: Core.RequestOptions,
): Core.APIPromise<CallListResponse> {
list(query?: CallListParams, options?: Core.RequestOptions): Core.APIPromise<CallListResponse>
list(options?: Core.RequestOptions): Core.APIPromise<CallListResponse>
list(query: CallListParams | Core.RequestOptions = {}, options?: Core.RequestOptions): Core.APIPromise<CallListResponse> {
if (isRequestOptions(query)) {
return this.list({}, query);
}
Expand Down Expand Up @@ -261,7 +260,7 @@ export interface CallCreateResponse {
to_number?: string;
}

export type CallListResponse = Array<CallDetailResponse>;
export type CallListResponse = Array<CallDetailResponse>

export interface CallRegisterResponse {
/**
Expand Down
19 changes: 2 additions & 17 deletions src/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

export { AgentResponse, AgentListResponse, AgentCreateParams, AgentUpdateParams, Agent } from './agent';
export {
CallDetailResponse,
CallCreateResponse,
CallListResponse,
CallRegisterResponse,
CallCreateParams,
CallListParams,
CallRegisterParams,
Call,
} from './call';
export { CallDetailResponse, CallCreateResponse, CallListResponse, CallRegisterResponse, CallCreateParams, CallListParams, CallRegisterParams, Call } from './call';
export { LlmResponse, LlmListResponse, LlmCreateParams, LlmUpdateParams, Llm } from './llm';
export {
PhoneNumberResponse,
PhoneNumberListResponse,
PhoneNumberCreateParams,
PhoneNumberUpdateParams,
PhoneNumber,
} from './phone-number';
export { PhoneNumberResponse, PhoneNumberListResponse, PhoneNumberCreateParams, PhoneNumberUpdateParams, PhoneNumber } from './phone-number';
Loading

0 comments on commit 1614607

Please sign in to comment.