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 eef1272 commit 0910f8c
Show file tree
Hide file tree
Showing 39 changed files with 643 additions and 531 deletions.
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
configured_endpoints: 13
configured_endpoints: 19
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ 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/toddlzt-node.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/toddlzt-node
cd toddlzt-node

# With yarn
yarn link
cd ../my-package
yarn link retell-sdk
yarn link toddlzt

# With pnpm
pnpm link --global
cd ../my-package
pnpm link -—global retell-sdk
pnpm link -—global toddlzt
```

## Running tests
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/toddlzt-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 Retell AI
Copyright 2024 Toddlzt

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Retell AI Node API Library
# Toddlzt Node API Library

[![NPM version](https://img.shields.io/npm/v/retell-sdk.svg)](https://npmjs.org/package/retell-sdk)
[![NPM version](https://img.shields.io/npm/v/toddlzt.svg)](https://npmjs.org/package/toddlzt)

This library provides convenient access to the Retell AI REST API from server-side TypeScript or JavaScript.
This library provides convenient access to the Toddlzt REST API from server-side TypeScript or JavaScript.

The REST API documentation can be found [on www.retellai.com](https://www.retellai.com/). The full API of this library can be found in [api.md](api.md).

Expand All @@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
## Installation

```sh
npm install retell-sdk
npm install toddlzt
```

## Usage
Expand All @@ -20,12 +20,12 @@ The full API of this library can be found in [api.md](api.md).

<!-- prettier-ignore -->
```js
import RetellAI from 'retell-sdk';
import Toddlzt from 'toddlzt';

const retellAI = new RetellAI();
const toddlzt = new Toddlzt();

async function main() {
const agentCreateResponse = await retellAI.agents.create({
const agentCreateResponse = await toddlzt.agents.create({
llm_type: 'retell-llm',
voice_id: '11labs-Adrian',
});
Expand All @@ -42,13 +42,13 @@ This library includes TypeScript definitions for all request params and response

<!-- prettier-ignore -->
```ts
import RetellAI from 'retell-sdk';
import Toddlzt from 'toddlzt';

const retellAI = new RetellAI();
const toddlzt = new Toddlzt();

async function main() {
const params: RetellAI.AgentCreateParams = { llm_type: 'retell-llm', voice_id: '11labs-Adrian' };
const agentCreateResponse: RetellAI.AgentCreateResponse = await retellAI.agents.create(params);
const params: Toddlzt.AgentCreateParams = { llm_type: 'retell-llm', voice_id: '11labs-Adrian' };
const agentCreateResponse: Toddlzt.AgentCreateResponse = await toddlzt.agents.create(params);
}

main();
Expand All @@ -65,10 +65,10 @@ a subclass of `APIError` will be thrown:
<!-- prettier-ignore -->
```ts
async function main() {
const agentCreateResponse = await retellAI.agents
const agentCreateResponse = await toddlzt.agents
.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' })
.catch(async (err) => {
if (err instanceof RetellAI.APIError) {
if (err instanceof Toddlzt.APIError) {
console.log(err.status); // 400
console.log(err.name); // BadRequestError
console.log(err.headers); // {server: 'nginx', ...}
Expand Down Expand Up @@ -105,12 +105,12 @@ You can use the `maxRetries` option to configure or disable this:
<!-- prettier-ignore -->
```js
// Configure the default for all requests:
const retellAI = new RetellAI({
const toddlzt = new Toddlzt({
maxRetries: 0, // default is 2
});

// Or, configure per-request:
await retellAI.agents.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' }, {
await toddlzt.agents.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' }, {
maxRetries: 5,
});
```
Expand All @@ -122,12 +122,12 @@ Requests time out after 1 minute by default. You can configure this with a `time
<!-- prettier-ignore -->
```ts
// Configure the default for all requests:
const retellAI = new RetellAI({
const toddlzt = new Toddlzt({
timeout: 20 * 1000, // 20 seconds (default is 1 minute)
});

// Override per-request:
await retellAI.agents.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' }, {
await toddlzt.agents.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' }, {
timeout: 5 * 1000,
});
```
Expand All @@ -146,15 +146,15 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi

<!-- prettier-ignore -->
```ts
const retellAI = new RetellAI();
const toddlzt = new Toddlzt();

const response = await retellAI.agents
const response = await toddlzt.agents
.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' })
.asResponse();
console.log(response.headers.get('X-My-Header'));
console.log(response.statusText); // access the underlying Response object

const { data: agentCreateResponse, response: raw } = await retellAI.agents
const { data: agentCreateResponse, response: raw } = await toddlzt.agents
.create({ llm_type: 'retell-llm', voice_id: '11labs-Adrian' })
.withResponse();
console.log(raw.headers.get('X-My-Header'));
Expand Down Expand Up @@ -211,16 +211,16 @@ By default, this library uses `node-fetch` in Node, and expects a global `fetch`

If you would prefer to use a global, web-standards-compliant `fetch` function even in a Node environment,
(for example, if you are running Node with `--experimental-fetch` or using NextJS which polyfills with `undici`),
add the following import before your first import `from "RetellAI"`:
add the following import before your first import `from "Toddlzt"`:

```ts
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
import 'retell-sdk/shims/web';
import RetellAI from 'retell-sdk';
import 'toddlzt/shims/web';
import Toddlzt from 'toddlzt';
```

To do the inverse, add `import "retell-sdk/shims/node"` (which does import polyfills).
To do the inverse, add `import "toddlzt/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)).

### Logging and middleware
Expand All @@ -230,9 +230,9 @@ which can be used to inspect or alter the `Request` or `Response` before/after e

```ts
import { fetch } from 'undici'; // as one example
import RetellAI from 'retell-sdk';
import Toddlzt from 'toddlzt';

const client = new RetellAI({
const client = new Toddlzt({
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
console.log('About to make a request', url, init);
const response = await fetch(url, init);
Expand All @@ -257,12 +257,12 @@ import http from 'http';
import { HttpsProxyAgent } from 'https-proxy-agent';

// Configure the default for all requests:
const retellAI = new RetellAI({
const toddlzt = new Toddlzt({
httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
});

// Override per-request:
await retellAI.agents.create(
await toddlzt.agents.create(
{ llm_type: 'retell-llm', voice_id: '11labs-Adrian' },
{
httpAgent: new http.Agent({ keepAlive: false }),
Expand All @@ -280,7 +280,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/toddlzt-node/issues) with questions, bugs, or suggestions.

## Requirements

Expand All @@ -289,7 +289,7 @@ TypeScript >= 4.5 is supported.
The following runtimes are supported:

- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher, using `import RetellAI from "npm:retell-sdk"`.
- Deno v1.28.0 or higher, using `import Toddlzt from "npm:toddlzt"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
Expand Down
30 changes: 26 additions & 4 deletions api.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
# Shared

Types:

- <code><a href="./src/resources/shared.ts">CallBase</a></code>

# Calls

Types:

- <code><a href="./src/resources/calls.ts">CallRetrieveResponse</a></code>
- <code><a href="./src/resources/calls.ts">CallListResponse</a></code>
- <code><a href="./src/resources/calls.ts">CallRegisterResponse</a></code>

Methods:

- <code title="get /get-call/{call_id}">client.calls.<a href="./src/resources/calls.ts">retrieve</a>(callId) -> CallRetrieveResponse</code>
- <code title="post /create-phone-call">client.calls.<a href="./src/resources/calls.ts">create</a>({ ...params }) -> CallBase</code>
- <code title="get /get-call/{call_id}">client.calls.<a href="./src/resources/calls.ts">retrieve</a>(callId) -> CallBase</code>
- <code title="get /list-calls">client.calls.<a href="./src/resources/calls.ts">list</a>({ ...params }) -> CallListResponse</code>
- <code title="post /register-call">client.calls.<a href="./src/resources/calls.ts">register</a>({ ...params }) -> CallRegisterResponse</code>
- <code title="post /register-call">client.calls.<a href="./src/resources/calls.ts">register</a>({ ...params }) -> CallBase</code>

# PhoneNumbers

Types:

- <code><a href="./src/resources/phone-numbers.ts">PhoneNumberCreateResponse</a></code>
- <code><a href="./src/resources/phone-numbers.ts">PhoneNumberRetrieveResponse</a></code>
- <code><a href="./src/resources/phone-numbers.ts">PhoneNumberUpdateResponse</a></code>
- <code><a href="./src/resources/phone-numbers.ts">PhoneNumberListResponse</a></code>

Methods:

- <code title="post /create-phone-number">client.phoneNumbers.<a href="./src/resources/phone-numbers.ts">create</a>({ ...params }) -> PhoneNumberCreateResponse</code>
- <code title="get /get-phone-number/{phone_number}">client.phoneNumbers.<a href="./src/resources/phone-numbers.ts">retrieve</a>(phoneNumber) -> PhoneNumberRetrieveResponse</code>
- <code title="patch /update-phone-number/{phone_number}">client.phoneNumbers.<a href="./src/resources/phone-numbers.ts">update</a>(phoneNumber, { ...params }) -> PhoneNumberUpdateResponse</code>
- <code title="get /list-phone-number">client.phoneNumbers.<a href="./src/resources/phone-numbers.ts">list</a>() -> PhoneNumberListResponse</code>
- <code title="delete /delete-phone-number/{phone_number}">client.phoneNumbers.<a href="./src/resources/phone-numbers.ts">delete</a>(phoneNumber) -> void</code>

# Agents

Expand Down
8 changes: 4 additions & 4 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ node scripts/check-version.cjs

# Build into dist and will publish the package from there,
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
# This way importing from `"retell-sdk/resources/foo"` works
# This way importing from `"toddlzt/resources/foo"` works
# even with `"moduleResolution": "node"`

rm -rf dist; mkdir dist
Expand All @@ -29,7 +29,7 @@ npm exec tsc-multi
# copy over handwritten .js/.mjs/.d.ts files
cp src/_shims/*.{d.ts,js,mjs,md} dist/_shims
cp src/_shims/auto/*.{d.ts,js,mjs} dist/_shims/auto
# we need to add exports = module.exports = Retell AI Node to index.js;
# we need to add exports = module.exports = Toddlzt Node to index.js;
# No way to get that from index.ts because it would cause compile errors
# when building .mjs
node scripts/fix-index-exports.cjs
Expand All @@ -44,8 +44,8 @@ node scripts/postprocess-files.cjs

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
(cd dist && node -e 'require("retell-sdk")')
(cd dist && node -e 'import("retell-sdk")' --input-type=module)
(cd dist && node -e 'require("toddlzt")')
(cd dist && node -e 'import("toddlzt")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./build-deno ]
then
Expand Down
6 changes: 3 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const config: JestConfigWithTsJest = {
preset: 'ts-jest/presets/default-esm',
testEnvironment: 'node',
moduleNameMapper: {
'^retell-sdk$': '<rootDir>/src/index.ts',
'^retell-sdk/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^retell-sdk/(.*)$': '<rootDir>/src/$1',
'^toddlzt$': '<rootDir>/src/index.ts',
'^toddlzt/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^toddlzt/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "retell-sdk",
"name": "toddlzt",
"version": "0.0.1-alpha.0",
"description": "The official TypeScript library for the Retell AI API",
"author": "Retell AI <founders@retellai.com>",
"description": "The official TypeScript library for the Toddlzt API",
"author": "Toddlzt <founders@retellai.com>",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"type": "commonjs",
"repository": "github:stainless-sdks/retell-sdk-node",
"repository": "github:stainless-sdks/toddlzt-node",
"license": "Apache-2.0",
"packageManager": "yarn@1.22.21",
"files": [
Expand Down Expand Up @@ -62,8 +62,8 @@
"./shims/web.mjs"
],
"imports": {
"retell-sdk": ".",
"retell-sdk/*": "./src/*"
"toddlzt": ".",
"toddlzt/*": "./src/*"
},
"exports": {
"./_shims/auto/*": {
Expand Down
4 changes: 2 additions & 2 deletions scripts/postprocess-files.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');
const { parse } = require('@typescript-eslint/parser');

const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'retell-sdk/'
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'toddlzt/'

const distDir =
process.env['DIST_PATH'] ?
Expand Down Expand Up @@ -142,7 +142,7 @@ async function postprocess() {

if (file.endsWith('.d.ts')) {
// work around bad tsc behavior
// if we have `import { type Readable } from 'retell-sdk/_shims/index'`,
// if we have `import { type Readable } from 'toddlzt/_shims/index'`,
// tsc sometimes replaces `Readable` with `import("stream").Readable` inline
// in the output .d.ts
transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable');
Expand Down
Loading

0 comments on commit 0910f8c

Please sign in to comment.