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 20, 2024
1 parent b549100 commit c7d20d9
Show file tree
Hide file tree
Showing 30 changed files with 101 additions and 101 deletions.
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/toddlzt-node.git
npm install git+ssh://git@github.com:stainless-sdks/retell-sdk-node.git
```

Alternatively, to link a local copy of the repo:

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

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

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

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

### Publish manually

Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Retell AI Node API Library

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

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

Expand All @@ -9,7 +9,7 @@ The REST API documentation can be found [on www.retellai.com](https://www.retell
## Installation

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

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

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

const retellAI = new RetellAI();

Expand All @@ -40,7 +40,7 @@ This library includes TypeScript definitions for all request params and response

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

const retellAI = new RetellAI();

Expand Down Expand Up @@ -173,19 +173,19 @@ add the following import before your first import `from "RetellAI"`:
```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 'toddlzt/shims/web';
import RetellAI from 'toddlzt';
import 'retell-sdk/shims/web';
import RetellAI from 'retell-sdk';
```

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

You may also provide a custom `fetch` function when instantiating the client,
which can be used to inspect or alter the `Request` or `Response` before/after each request:

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

const client = new RetellAI({
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
Expand Down Expand Up @@ -235,7 +235,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/toddlzt-node/issues) with questions, bugs, or suggestions.
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.

## Requirements

Expand All @@ -244,7 +244,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:toddlzt"`.
- Deno v1.28.0 or higher, using `import RetellAI from "npm:retell-sdk"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
Expand Down
6 changes: 3 additions & 3 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 `"toddlzt/resources/foo"` works
# This way importing from `"retell-sdk/resources/foo"` works
# even with `"moduleResolution": "node"`

rm -rf dist; mkdir dist
Expand Down Expand Up @@ -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("toddlzt")')
(cd dist && node -e 'import("toddlzt")' --input-type=module)
(cd dist && node -e 'require("retell-sdk")')
(cd dist && node -e 'import("retell-sdk")' --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: {
'^toddlzt$': '<rootDir>/src/index.ts',
'^toddlzt/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^toddlzt/(.*)$': '<rootDir>/src/$1',
'^retell-sdk$': '<rootDir>/src/index.ts',
'^retell-sdk/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^retell-sdk/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "toddlzt",
"name": "retell-sdk",
"version": "0.0.1-alpha.0",
"description": "The official TypeScript library for the Retell AI API",
"author": "Retell AI <founders@retellai.com>",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"type": "commonjs",
"repository": "github:stainless-sdks/toddlzt-node",
"repository": "github:stainless-sdks/retell-sdk-node",
"license": "Apache-2.0",
"packageManager": "yarn@1.22.21",
"files": [
Expand Down Expand Up @@ -62,8 +62,8 @@
"./shims/web.mjs"
],
"imports": {
"toddlzt": ".",
"toddlzt/*": "./src/*"
"retell-sdk": ".",
"retell-sdk/*": "./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'] ?? 'toddlzt/'
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'retell-sdk/'

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 'toddlzt/_shims/index'`,
// if we have `import { type Readable } from 'retell-sdk/_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
32 changes: 16 additions & 16 deletions src/_shims/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# 👋 Wondering what everything in here does?

`toddlzt` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
`retell-sdk` supports a wide variety of runtime environments like Node.js, Deno, Bun, browsers, and various
edge runtimes, as well as both CommonJS (CJS) and EcmaScript Modules (ESM).

To do this, `toddlzt` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.
To do this, `retell-sdk` provides shims for either using `node-fetch` when in Node (because `fetch` is still experimental there) or the global `fetch` API built into the environment when not in Node.

It uses [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) to
automatically select the correct shims for each environment. However, conditional exports are a fairly new
Expand All @@ -15,32 +15,32 @@ getting the wrong raw `Response` type from `.asResponse()`, for example.

The user can work around these issues by manually importing one of:

- `import 'toddlzt/shims/node'`
- `import 'toddlzt/shims/web'`
- `import 'retell-sdk/shims/node'`
- `import 'retell-sdk/shims/web'`

All of the code here in `_shims` handles selecting the automatic default shims or manual overrides.

### How it works - Runtime

Runtime shims get installed by calling `setShims` exported by `toddlzt/_shims/registry`.
Runtime shims get installed by calling `setShims` exported by `retell-sdk/_shims/registry`.

Manually importing `toddlzt/shims/node` or `toddlzt/shims/web`, calls `setShims` with the respective runtime shims.
Manually importing `retell-sdk/shims/node` or `retell-sdk/shims/web`, calls `setShims` with the respective runtime shims.

All client code imports shims from `toddlzt/_shims/index`, which:
All client code imports shims from `retell-sdk/_shims/index`, which:

- checks if shims have been set manually
- if not, calls `setShims` with the shims from `toddlzt/_shims/auto/runtime`
- re-exports the installed shims from `toddlzt/_shims/registry`.
- if not, calls `setShims` with the shims from `retell-sdk/_shims/auto/runtime`
- re-exports the installed shims from `retell-sdk/_shims/registry`.

`toddlzt/_shims/auto/runtime` exports web runtime shims.
If the `node` export condition is set, the export map replaces it with `toddlzt/_shims/auto/runtime-node`.
`retell-sdk/_shims/auto/runtime` exports web runtime shims.
If the `node` export condition is set, the export map replaces it with `retell-sdk/_shims/auto/runtime-node`.

### How it works - Type time

All client code imports shim types from `toddlzt/_shims/index`, which selects the manual types from `toddlzt/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `toddlzt/_shims/auto/types`.
All client code imports shim types from `retell-sdk/_shims/index`, which selects the manual types from `retell-sdk/_shims/manual-types` if they have been declared, otherwise it exports the auto types from `retell-sdk/_shims/auto/types`.

`toddlzt/_shims/manual-types` exports an empty namespace.
Manually importing `toddlzt/shims/node` or `toddlzt/shims/web` merges declarations into this empty namespace, so they get picked up by `toddlzt/_shims/index`.
`retell-sdk/_shims/manual-types` exports an empty namespace.
Manually importing `retell-sdk/shims/node` or `retell-sdk/shims/web` merges declarations into this empty namespace, so they get picked up by `retell-sdk/_shims/index`.

`toddlzt/_shims/auto/types` exports web type definitions.
If the `node` export condition is set, the export map replaces it with `toddlzt/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
`retell-sdk/_shims/auto/types` exports web type definitions.
If the `node` export condition is set, the export map replaces it with `retell-sdk/_shims/auto/types-node`, though TS only picks this up if `"moduleResolution": "nodenext"` or `"moduleResolution": "bundler"`.
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/toddlzt-node#file-uploads',
'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',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/_shims/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
*/
import { manual } from './manual-types';
import * as auto from 'toddlzt/_shims/auto/types';
import * as auto from 'retell-sdk/_shims/auto/types';
import { type RequestOptions } from '../core';

type SelectType<Manual, Auto> = unknown extends Manual ? Auto : Manual;
Expand Down
2 changes: 1 addition & 1 deletion src/_shims/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
*/
const shims = require('./registry');
const auto = require('toddlzt/_shims/auto/runtime');
const auto = require('retell-sdk/_shims/auto/runtime');
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
for (const property of Object.keys(shims)) {
Object.defineProperty(exports, property, {
Expand Down
2 changes: 1 addition & 1 deletion src/_shims/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
* Disclaimer: modules in _shims aren't intended to be imported by SDK users.
*/
import * as shims from './registry.mjs';
import * as auto from 'toddlzt/_shims/auto/runtime';
import * as auto from 'retell-sdk/_shims/auto/runtime';
if (!shims.kind) shims.setShims(auto.getRuntime(), { auto: true });
export * from './registry.mjs';
4 changes: 2 additions & 2 deletions src/_shims/manual-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
/**
* Types will get added to this namespace when you import one of the following:
*
* import 'toddlzt/shims/node'
* import 'toddlzt/shims/web'
* import 'retell-sdk/shims/node'
* import 'retell-sdk/shims/web'
*
* Importing more than one will cause type and runtime errors.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/_shims/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ export let isFsReadStream: Shims['isFsReadStream'] | undefined = undefined;
export function setShims(shims: Shims, options: { auto: boolean } = { auto: false }) {
if (auto) {
throw new Error(
`you must \`import 'toddlzt/shims/${shims.kind}'\` before importing anything else from toddlzt`,
`you must \`import 'retell-sdk/shims/${shims.kind}'\` before importing anything else from retell-sdk`,
);
}
if (kind) {
throw new Error(
`can't \`import 'toddlzt/shims/${shims.kind}'\` after \`import 'toddlzt/shims/${kind}'\``,
`can't \`import 'retell-sdk/shims/${shims.kind}'\` after \`import 'retell-sdk/shims/${kind}'\``,
);
}
auto = options.auto;
Expand Down
8 changes: 4 additions & 4 deletions src/_shims/web-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean }
const recommendation =
manuallyImported ?
`You may need to use polyfills`
: `Add one of these imports before your first \`import … from 'toddlzt'\`:
- \`import 'toddlzt/shims/node'\` (if you're running on Node)
- \`import 'toddlzt/shims/web'\` (otherwise)
: `Add one of these imports before your first \`import … from 'retell-sdk'\`:
- \`import 'retell-sdk/shims/node'\` (if you're running on Node)
- \`import 'retell-sdk/shims/web'\` (otherwise)
`;

let _fetch, _Request, _Response, _Headers;
Expand Down 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/toddlzt-node#file-uploads',
'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',
);
},
isFsReadStream: (value: any) => false,
Expand Down
12 changes: 6 additions & 6 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export class APIPromise<T> extends Promise<T> {
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` if you can,
* or add one of these imports before your first `import … from 'toddlzt'`:
* - `import 'toddlzt/shims/node'` (if you're running on Node)
* - `import 'toddlzt/shims/web'` (otherwise)
* or add one of these imports before your first `import … from 'retell-sdk'`:
* - `import 'retell-sdk/shims/node'` (if you're running on Node)
* - `import 'retell-sdk/shims/web'` (otherwise)
*/
asResponse(): Promise<Response> {
return this.responsePromise.then((p) => p.response);
Expand All @@ -113,9 +113,9 @@ export class APIPromise<T> extends Promise<T> {
*
* 👋 Getting the wrong TypeScript type for `Response`?
* Try setting `"moduleResolution": "NodeNext"` if you can,
* or add one of these imports before your first `import … from 'toddlzt'`:
* - `import 'toddlzt/shims/node'` (if you're running on Node)
* - `import 'toddlzt/shims/web'` (otherwise)
* or add one of these imports before your first `import … from 'retell-sdk'`:
* - `import 'retell-sdk/shims/node'` (if you're running on Node)
* - `import 'retell-sdk/shims/web'` (otherwise)
*/
async withResponse(): Promise<{ data: T; response: Response }> {
const [data, response] = await Promise.all([this.parse(), this.asResponse()]);
Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import * as Errors from './error';
import { type Agent } from './_shims/index';
import * as Uploads from './uploads';
import * as qs from 'qs';
import * as API from 'toddlzt/resources/index';
import * as API from 'retell-sdk/resources/index';

export interface ClientOptions {
/**
* Defaults to process.env['TODDLZT_API_KEY'].
* Defaults to process.env['RETELL_API_KEY'].
*/
apiKey?: string | undefined;

Expand Down Expand Up @@ -79,7 +79,7 @@ export class RetellAI extends Core.APIClient {
/**
* API Client for interfacing with the Retell AI API.
*
* @param {string | undefined} [opts.apiKey=process.env['TODDLZT_API_KEY'] ?? undefined]
* @param {string | undefined} [opts.apiKey=process.env['RETELL_API_KEY'] ?? undefined]
* @param {string} [opts.baseURL=process.env['RETELL_AI_BASE_URL'] ?? https://api.retellai.com] - Override the default base URL for the API.
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
Expand All @@ -90,12 +90,12 @@ export class RetellAI extends Core.APIClient {
*/
constructor({
baseURL = Core.readEnv('RETELL_AI_BASE_URL'),
apiKey = Core.readEnv('TODDLZT_API_KEY'),
apiKey = Core.readEnv('RETELL_API_KEY'),
...opts
}: ClientOptions = {}) {
if (apiKey === undefined) {
throw new Errors.RetellAIError(
"The TODDLZT_API_KEY environment variable is missing or empty; either provide it, or instantiate the RetellAI client with an apiKey option, like new RetellAI({ apiKey: 'My API Key' }).",
"The RETELL_API_KEY environment variable is missing or empty; either provide it, or instantiate the RetellAI client with an apiKey option, like new RetellAI({ apiKey: 'My API Key' }).",
);
}

Expand Down
Loading

0 comments on commit c7d20d9

Please sign in to comment.