Skip to content

Commit 87ca5ca

Browse files
committed
Release 0.0.0
1 parent 3f43725 commit 87ca5ca

File tree

644 files changed

+28589
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

644 files changed

+28589
-2
lines changed

.fernignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Specify files that shouldn't be modified by Fern

.github/workflows/ci.yml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: ci
2+
3+
on: [push]
4+
5+
jobs:
6+
compile:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repo
11+
uses: actions/checkout@v3
12+
13+
- name: Set up node
14+
uses: actions/setup-node@v3
15+
16+
- name: Compile
17+
run: yarn && yarn build
18+
19+
test:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- name: Checkout repo
24+
uses: actions/checkout@v3
25+
26+
- name: Set up node
27+
uses: actions/setup-node@v3
28+
29+
- name: Compile
30+
run: yarn && yarn test

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
/dist

.npmignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules
2+
src
3+
tests
4+
.gitignore
5+
.github
6+
.fernignore
7+
.prettierrc.yml
8+
tsconfig.json
9+
yarn.lock

.prettierrc.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tabWidth: 4
2+
printWidth: 120

README.md

+135-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,135 @@
1-
# vapi-typescript-sdk
2-
The official TypeScript SDK for accessing Vapi's API
1+
# Vapi TypeScript Library
2+
3+
[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-SDK%20generated%20by%20Fern-brightgreen)](https://github.com/fern-api/fern)
4+
[![npm shield](https://img.shields.io/npm/v/vapi)](https://www.npmjs.com/package/vapi)
5+
6+
The Vapi TypeScript library provides convenient access to the Vapi API from TypeScript.
7+
8+
## Installation
9+
10+
```sh
11+
npm i -s vapi
12+
```
13+
14+
## Usage
15+
16+
Instantiate and use the client with the following:
17+
18+
```typescript
19+
import { VapiClient } from "vapi";
20+
21+
const client = new VapiClient({ token: "YOUR_TOKEN" });
22+
await client.calls.create();
23+
```
24+
25+
## Request And Response Types
26+
27+
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
28+
following namespace:
29+
30+
```typescript
31+
import { Vapi } from "vapi";
32+
33+
const request: Vapi.CallsListRequest = {
34+
...
35+
};
36+
```
37+
38+
## Exception Handling
39+
40+
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
41+
will be thrown.
42+
43+
```typescript
44+
import { VapiError } from "vapi";
45+
46+
try {
47+
await client.calls.create(...);
48+
} catch (err) {
49+
if (err instanceof VapiError) {
50+
console.log(err.statusCode);
51+
console.log(err.message);
52+
console.log(err.body);
53+
}
54+
}
55+
```
56+
57+
## Advanced
58+
59+
### Retries
60+
61+
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
62+
as the request is deemed retriable and the number of retry attempts has not grown larger than the configured
63+
retry limit (default: 2).
64+
65+
A request is deemed retriable when any of the following HTTP status codes is returned:
66+
67+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
68+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
69+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
70+
71+
Use the `maxRetries` request option to configure this behavior.
72+
73+
```typescript
74+
const response = await client.calls.create(..., {
75+
maxRetries: 0 // override maxRetries at the request level
76+
});
77+
```
78+
79+
### Timeouts
80+
81+
The SDK defaults to a 60 second timeout. Use the `timeoutInSeconds` option to configure this behavior.
82+
83+
```typescript
84+
const response = await client.calls.create(..., {
85+
timeoutInSeconds: 30 // override timeout to 30s
86+
});
87+
```
88+
89+
### Aborting Requests
90+
91+
The SDK allows users to abort requests at any point by passing in an abort signal.
92+
93+
```typescript
94+
const controller = new AbortController();
95+
const response = await client.calls.create(..., {
96+
abortSignal: controller.signal
97+
});
98+
controller.abort(); // aborts the request
99+
```
100+
101+
### Runtime Compatibility
102+
103+
The SDK defaults to `node-fetch` but will use the global fetch client if present. The SDK works in the following
104+
runtimes:
105+
106+
- Node.js 18+
107+
- Vercel
108+
- Cloudflare Workers
109+
- Deno v1.25+
110+
- Bun 1.0+
111+
- React Native
112+
113+
### Customizing Fetch Client
114+
115+
The SDK provides a way for your to customize the underlying HTTP client / Fetch function. If you're running in an
116+
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
117+
118+
```typescript
119+
import { VapiClient } from "vapi";
120+
121+
const client = new VapiClient({
122+
...
123+
fetcher: // provide your implementation here
124+
});
125+
```
126+
127+
## Contributing
128+
129+
While we value open-source contributions to this SDK, this library is generated programmatically.
130+
Additions made directly to this library would have to be moved over to our generation code,
131+
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
132+
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
133+
an issue first to discuss with us!
134+
135+
On the other hand, contributions to the README are always very welcome!

jest.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @type {import('jest').Config} */
2+
module.exports = {
3+
preset: "ts-jest",
4+
testEnvironment: "node",
5+
};

package.json

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"name": "vapi",
3+
"version": "0.0.0",
4+
"private": false,
5+
"repository": "https://github.com/fern-demo/vapi-typescript-sdk",
6+
"main": "./index.js",
7+
"types": "./index.d.ts",
8+
"scripts": {
9+
"format": "prettier . --write --ignore-unknown",
10+
"build": "tsc",
11+
"prepack": "cp -rv dist/. .",
12+
"test": "jest"
13+
},
14+
"dependencies": {
15+
"url-join": "4.0.1",
16+
"form-data": "^4.0.0",
17+
"formdata-node": "^6.0.3",
18+
"node-fetch": "2.7.0",
19+
"qs": "6.11.2",
20+
"readable-stream": "^4.5.2",
21+
"js-base64": "3.7.2",
22+
"form-data-encoder": "^4.0.2"
23+
},
24+
"devDependencies": {
25+
"@types/url-join": "4.0.1",
26+
"@types/qs": "6.9.8",
27+
"@types/node-fetch": "2.6.9",
28+
"@types/readable-stream": "^4.0.15",
29+
"fetch-mock-jest": "^1.5.1",
30+
"webpack": "^5.94.0",
31+
"ts-loader": "^9.3.1",
32+
"jest": "29.7.0",
33+
"@types/jest": "29.5.5",
34+
"ts-jest": "29.1.1",
35+
"jest-environment-jsdom": "29.7.0",
36+
"@types/node": "17.0.33",
37+
"prettier": "2.7.1",
38+
"typescript": "4.6.4"
39+
},
40+
"browser": {
41+
"fs": false,
42+
"os": false,
43+
"path": false
44+
}
45+
}

0 commit comments

Comments
 (0)