Skip to content

Commit 57dab8a

Browse files
committed
Release 0.8.1
1 parent ca57b73 commit 57dab8a

File tree

20 files changed

+369
-177
lines changed

20 files changed

+369
-177
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vapi-ai/server-sdk",
3-
"version": "0.9.0",
3+
"version": "0.8.1",
44
"private": false,
55
"repository": "https://github.com/VapiAI/server-sdk-typescript",
66
"main": "./index.js",

reference.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
# Reference
22

3+
<details><summary><code>client.<a href="/src/Client.ts">prometheusControllerIndex</a>() -> void</code></summary>
4+
<dl>
5+
<dd>
6+
7+
#### 🔌 Usage
8+
9+
<dl>
10+
<dd>
11+
12+
<dl>
13+
<dd>
14+
15+
```typescript
16+
await client.prometheusControllerIndex();
17+
```
18+
19+
</dd>
20+
</dl>
21+
</dd>
22+
</dl>
23+
24+
#### ⚙️ Parameters
25+
26+
<dl>
27+
<dd>
28+
29+
<dl>
30+
<dd>
31+
32+
**requestOptions:** `VapiClient.RequestOptions`
33+
34+
</dd>
35+
</dl>
36+
</dd>
37+
</dl>
38+
39+
</dd>
40+
</dl>
41+
</details>
42+
43+
##
44+
345
## Calls
446

547
<details><summary><code>client.calls.<a href="/src/api/resources/calls/client/Client.ts">list</a>({ ...params }) -> Vapi.Call[]</code></summary>

src/Client.ts

Lines changed: 79 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import * as environments from "./environments";
66
import * as core from "./core";
7+
import urlJoin from "url-join";
8+
import * as errors from "./errors/index";
79
import { Calls } from "./api/resources/calls/client/Client";
810
import { Assistants } from "./api/resources/assistants/client/Client";
911
import { PhoneNumbers } from "./api/resources/phoneNumbers/client/Client";
@@ -23,7 +25,7 @@ export declare namespace VapiClient {
2325
environment?: core.Supplier<environments.VapiEnvironment | string>;
2426
/** Specify a custom URL to connect the client to. */
2527
baseUrl?: core.Supplier<string>;
26-
token: core.Supplier<core.BearerToken>;
28+
token?: core.Supplier<core.BearerToken | undefined>;
2729
fetcher?: core.FetchFunction;
2830
}
2931

@@ -54,7 +56,7 @@ export class VapiClient {
5456
protected _analytics: Analytics | undefined;
5557
protected _logs: Logs | undefined;
5658

57-
constructor(protected readonly _options: VapiClient.Options) {}
59+
constructor(protected readonly _options: VapiClient.Options = {}) {}
5860

5961
public get calls(): Calls {
6062
return (this._calls ??= new Calls(this._options));
@@ -107,4 +109,79 @@ export class VapiClient {
107109
public get logs(): Logs {
108110
return (this._logs ??= new Logs(this._options));
109111
}
112+
113+
/**
114+
* @param {VapiClient.RequestOptions} requestOptions - Request-specific configuration.
115+
*
116+
* @example
117+
* await client.prometheusControllerIndex()
118+
*/
119+
public prometheusControllerIndex(requestOptions?: VapiClient.RequestOptions): core.HttpResponsePromise<void> {
120+
return core.HttpResponsePromise.fromPromise(this.__prometheusControllerIndex(requestOptions));
121+
}
122+
123+
private async __prometheusControllerIndex(
124+
requestOptions?: VapiClient.RequestOptions,
125+
): Promise<core.WithRawResponse<void>> {
126+
const _response = await (this._options.fetcher ?? core.fetcher)({
127+
url: urlJoin(
128+
(await core.Supplier.get(this._options.baseUrl)) ??
129+
(await core.Supplier.get(this._options.environment)) ??
130+
environments.VapiEnvironment.Default,
131+
"prometheus_metrics",
132+
),
133+
method: "GET",
134+
headers: {
135+
Authorization: await this._getAuthorizationHeader(),
136+
"X-Fern-Language": "JavaScript",
137+
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
138+
"X-Fern-SDK-Version": "0.8.1",
139+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
140+
"X-Fern-Runtime": core.RUNTIME.type,
141+
"X-Fern-Runtime-Version": core.RUNTIME.version,
142+
...requestOptions?.headers,
143+
},
144+
contentType: "application/json",
145+
requestType: "json",
146+
timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
147+
maxRetries: requestOptions?.maxRetries,
148+
abortSignal: requestOptions?.abortSignal,
149+
});
150+
if (_response.ok) {
151+
return { data: undefined, rawResponse: _response.rawResponse };
152+
}
153+
154+
if (_response.error.reason === "status-code") {
155+
throw new errors.VapiError({
156+
statusCode: _response.error.statusCode,
157+
body: _response.error.body,
158+
rawResponse: _response.rawResponse,
159+
});
160+
}
161+
162+
switch (_response.error.reason) {
163+
case "non-json":
164+
throw new errors.VapiError({
165+
statusCode: _response.error.statusCode,
166+
body: _response.error.rawBody,
167+
rawResponse: _response.rawResponse,
168+
});
169+
case "timeout":
170+
throw new errors.VapiTimeoutError("Timeout exceeded when calling GET /prometheus_metrics.");
171+
case "unknown":
172+
throw new errors.VapiError({
173+
message: _response.error.errorMessage,
174+
rawResponse: _response.rawResponse,
175+
});
176+
}
177+
}
178+
179+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
180+
const bearer = await core.Supplier.get(this._options.token);
181+
if (bearer != null) {
182+
return `Bearer ${bearer}`;
183+
}
184+
185+
return undefined;
186+
}
110187
}

src/api/resources/analytics/client/Client.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare namespace Analytics {
1313
environment?: core.Supplier<environments.VapiEnvironment | string>;
1414
/** Specify a custom URL to connect the client to. */
1515
baseUrl?: core.Supplier<string>;
16-
token: core.Supplier<core.BearerToken>;
16+
token?: core.Supplier<core.BearerToken | undefined>;
1717
fetcher?: core.FetchFunction;
1818
}
1919

@@ -30,7 +30,7 @@ export declare namespace Analytics {
3030
}
3131

3232
export class Analytics {
33-
constructor(protected readonly _options: Analytics.Options) {}
33+
constructor(protected readonly _options: Analytics.Options = {}) {}
3434

3535
/**
3636
* @param {Vapi.AnalyticsQueryDto} request
@@ -71,8 +71,8 @@ export class Analytics {
7171
Authorization: await this._getAuthorizationHeader(),
7272
"X-Fern-Language": "JavaScript",
7373
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
74-
"X-Fern-SDK-Version": "0.9.0",
75-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
74+
"X-Fern-SDK-Version": "0.8.1",
75+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
7676
"X-Fern-Runtime": core.RUNTIME.type,
7777
"X-Fern-Runtime-Version": core.RUNTIME.version,
7878
...requestOptions?.headers,
@@ -113,7 +113,12 @@ export class Analytics {
113113
}
114114
}
115115

116-
protected async _getAuthorizationHeader(): Promise<string> {
117-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
116+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
117+
const bearer = await core.Supplier.get(this._options.token);
118+
if (bearer != null) {
119+
return `Bearer ${bearer}`;
120+
}
121+
122+
return undefined;
118123
}
119124
}

src/api/resources/assistants/client/Client.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare namespace Assistants {
1313
environment?: core.Supplier<environments.VapiEnvironment | string>;
1414
/** Specify a custom URL to connect the client to. */
1515
baseUrl?: core.Supplier<string>;
16-
token: core.Supplier<core.BearerToken>;
16+
token?: core.Supplier<core.BearerToken | undefined>;
1717
fetcher?: core.FetchFunction;
1818
}
1919

@@ -30,7 +30,7 @@ export declare namespace Assistants {
3030
}
3131

3232
export class Assistants {
33-
constructor(protected readonly _options: Assistants.Options) {}
33+
constructor(protected readonly _options: Assistants.Options = {}) {}
3434

3535
/**
3636
* @param {Vapi.AssistantsListRequest} request
@@ -110,8 +110,8 @@ export class Assistants {
110110
Authorization: await this._getAuthorizationHeader(),
111111
"X-Fern-Language": "JavaScript",
112112
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
113-
"X-Fern-SDK-Version": "0.9.0",
114-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
113+
"X-Fern-SDK-Version": "0.8.1",
114+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
115115
"X-Fern-Runtime": core.RUNTIME.type,
116116
"X-Fern-Runtime-Version": core.RUNTIME.version,
117117
...requestOptions?.headers,
@@ -182,8 +182,8 @@ export class Assistants {
182182
Authorization: await this._getAuthorizationHeader(),
183183
"X-Fern-Language": "JavaScript",
184184
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
185-
"X-Fern-SDK-Version": "0.9.0",
186-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
185+
"X-Fern-SDK-Version": "0.8.1",
186+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
187187
"X-Fern-Runtime": core.RUNTIME.type,
188188
"X-Fern-Runtime-Version": core.RUNTIME.version,
189189
...requestOptions?.headers,
@@ -251,8 +251,8 @@ export class Assistants {
251251
Authorization: await this._getAuthorizationHeader(),
252252
"X-Fern-Language": "JavaScript",
253253
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
254-
"X-Fern-SDK-Version": "0.9.0",
255-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
254+
"X-Fern-SDK-Version": "0.8.1",
255+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
256256
"X-Fern-Runtime": core.RUNTIME.type,
257257
"X-Fern-Runtime-Version": core.RUNTIME.version,
258258
...requestOptions?.headers,
@@ -319,8 +319,8 @@ export class Assistants {
319319
Authorization: await this._getAuthorizationHeader(),
320320
"X-Fern-Language": "JavaScript",
321321
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
322-
"X-Fern-SDK-Version": "0.9.0",
323-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
322+
"X-Fern-SDK-Version": "0.8.1",
323+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
324324
"X-Fern-Runtime": core.RUNTIME.type,
325325
"X-Fern-Runtime-Version": core.RUNTIME.version,
326326
...requestOptions?.headers,
@@ -393,8 +393,8 @@ export class Assistants {
393393
Authorization: await this._getAuthorizationHeader(),
394394
"X-Fern-Language": "JavaScript",
395395
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
396-
"X-Fern-SDK-Version": "0.9.0",
397-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
396+
"X-Fern-SDK-Version": "0.8.1",
397+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
398398
"X-Fern-Runtime": core.RUNTIME.type,
399399
"X-Fern-Runtime-Version": core.RUNTIME.version,
400400
...requestOptions?.headers,
@@ -435,7 +435,12 @@ export class Assistants {
435435
}
436436
}
437437

438-
protected async _getAuthorizationHeader(): Promise<string> {
439-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
438+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
439+
const bearer = await core.Supplier.get(this._options.token);
440+
if (bearer != null) {
441+
return `Bearer ${bearer}`;
442+
}
443+
444+
return undefined;
440445
}
441446
}

src/api/resources/calls/client/Client.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export declare namespace Calls {
1313
environment?: core.Supplier<environments.VapiEnvironment | string>;
1414
/** Specify a custom URL to connect the client to. */
1515
baseUrl?: core.Supplier<string>;
16-
token: core.Supplier<core.BearerToken>;
16+
token?: core.Supplier<core.BearerToken | undefined>;
1717
fetcher?: core.FetchFunction;
1818
}
1919

@@ -30,7 +30,7 @@ export declare namespace Calls {
3030
}
3131

3232
export class Calls {
33-
constructor(protected readonly _options: Calls.Options) {}
33+
constructor(protected readonly _options: Calls.Options = {}) {}
3434

3535
/**
3636
* @param {Vapi.CallsListRequest} request
@@ -125,8 +125,8 @@ export class Calls {
125125
Authorization: await this._getAuthorizationHeader(),
126126
"X-Fern-Language": "JavaScript",
127127
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
128-
"X-Fern-SDK-Version": "0.9.0",
129-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
128+
"X-Fern-SDK-Version": "0.8.1",
129+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
130130
"X-Fern-Runtime": core.RUNTIME.type,
131131
"X-Fern-Runtime-Version": core.RUNTIME.version,
132132
...requestOptions?.headers,
@@ -197,8 +197,8 @@ export class Calls {
197197
Authorization: await this._getAuthorizationHeader(),
198198
"X-Fern-Language": "JavaScript",
199199
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
200-
"X-Fern-SDK-Version": "0.9.0",
201-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
200+
"X-Fern-SDK-Version": "0.8.1",
201+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
202202
"X-Fern-Runtime": core.RUNTIME.type,
203203
"X-Fern-Runtime-Version": core.RUNTIME.version,
204204
...requestOptions?.headers,
@@ -263,8 +263,8 @@ export class Calls {
263263
Authorization: await this._getAuthorizationHeader(),
264264
"X-Fern-Language": "JavaScript",
265265
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
266-
"X-Fern-SDK-Version": "0.9.0",
267-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
266+
"X-Fern-SDK-Version": "0.8.1",
267+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
268268
"X-Fern-Runtime": core.RUNTIME.type,
269269
"X-Fern-Runtime-Version": core.RUNTIME.version,
270270
...requestOptions?.headers,
@@ -331,8 +331,8 @@ export class Calls {
331331
Authorization: await this._getAuthorizationHeader(),
332332
"X-Fern-Language": "JavaScript",
333333
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
334-
"X-Fern-SDK-Version": "0.9.0",
335-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
334+
"X-Fern-SDK-Version": "0.8.1",
335+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
336336
"X-Fern-Runtime": core.RUNTIME.type,
337337
"X-Fern-Runtime-Version": core.RUNTIME.version,
338338
...requestOptions?.headers,
@@ -405,8 +405,8 @@ export class Calls {
405405
Authorization: await this._getAuthorizationHeader(),
406406
"X-Fern-Language": "JavaScript",
407407
"X-Fern-SDK-Name": "@vapi-ai/server-sdk",
408-
"X-Fern-SDK-Version": "0.9.0",
409-
"User-Agent": "@vapi-ai/server-sdk/0.9.0",
408+
"X-Fern-SDK-Version": "0.8.1",
409+
"User-Agent": "@vapi-ai/server-sdk/0.8.1",
410410
"X-Fern-Runtime": core.RUNTIME.type,
411411
"X-Fern-Runtime-Version": core.RUNTIME.version,
412412
...requestOptions?.headers,
@@ -447,7 +447,12 @@ export class Calls {
447447
}
448448
}
449449

450-
protected async _getAuthorizationHeader(): Promise<string> {
451-
return `Bearer ${await core.Supplier.get(this._options.token)}`;
450+
protected async _getAuthorizationHeader(): Promise<string | undefined> {
451+
const bearer = await core.Supplier.get(this._options.token);
452+
if (bearer != null) {
453+
return `Bearer ${bearer}`;
454+
}
455+
456+
return undefined;
452457
}
453458
}

0 commit comments

Comments
 (0)