Skip to content

Commit 0cb388c

Browse files
committed
Release 0.5.2
1 parent a79fa0d commit 0cb388c

File tree

569 files changed

+9373
-2604
lines changed

Some content is hidden

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

569 files changed

+9373
-2604
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/** @type {import('jest').Config} */
2-
module.exports = {
2+
export default {
33
preset: "ts-jest",
44
testEnvironment: "node",
5+
moduleNameMapper: {
6+
"(.+)\.js$": "$1",
7+
},
58
};

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vapi-ai/server-sdk",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"private": false,
55
"repository": "https://github.com/VapiAI/server-sdk-typescript",
66
"main": "./index.js",
@@ -15,26 +15,26 @@
1515
"url-join": "4.0.1",
1616
"form-data": "^4.0.0",
1717
"formdata-node": "^6.0.3",
18-
"node-fetch": "2.7.0",
19-
"qs": "6.11.2",
18+
"node-fetch": "^2.7.0",
19+
"qs": "^6.13.1",
2020
"readable-stream": "^4.5.2",
21-
"js-base64": "3.7.2",
21+
"js-base64": "3.7.7",
2222
"form-data-encoder": "^4.0.2"
2323
},
2424
"devDependencies": {
2525
"@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-
"webpack": "^5.94.0",
30-
"ts-loader": "^9.3.1",
31-
"jest": "29.7.0",
32-
"@types/jest": "29.5.5",
33-
"ts-jest": "29.1.1",
34-
"jest-environment-jsdom": "29.7.0",
35-
"@types/node": "17.0.33",
36-
"prettier": "2.7.1",
37-
"typescript": "4.6.4"
26+
"@types/qs": "^6.9.17",
27+
"@types/node-fetch": "^2.6.12",
28+
"@types/readable-stream": "^4.0.18",
29+
"webpack": "^5.97.1",
30+
"ts-loader": "^9.5.1",
31+
"jest": "^29.7.0",
32+
"@types/jest": "^29.5.14",
33+
"ts-jest": "^29.1.1",
34+
"jest-environment-jsdom": "^29.7.0",
35+
"@types/node": "^18.19.70",
36+
"prettier": "^3.4.2",
37+
"typescript": "~5.7.2"
3838
},
3939
"browser": {
4040
"fs": false,

reference.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66

77
## PhoneNumbers
88

9-
## Squads
10-
11-
## KnowledgeBases
12-
13-
## Blocks
14-
159
## Tools
1610

1711
## Files
1812

19-
## Analytics
13+
## KnowledgeBases
2014

21-
## Logs
15+
## Workflow
16+
17+
## Squads
2218

2319
## TestSuites
2420

2521
## TestSuiteTests
2622

2723
## TestSuiteRuns
24+
25+
## Analytics
26+
27+
## Logs

scripts/rename-to-esm-files.js

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require("fs").promises;
4+
const path = require("path");
5+
6+
const extensionMap = {
7+
".js": ".mjs",
8+
".d.ts": ".d.mts",
9+
};
10+
const oldExtensions = Object.keys(extensionMap);
11+
12+
async function findFiles(rootPath) {
13+
const files = [];
14+
15+
async function scan(directory) {
16+
const entries = await fs.readdir(directory, { withFileTypes: true });
17+
18+
for (const entry of entries) {
19+
const fullPath = path.join(directory, entry.name);
20+
21+
if (entry.isDirectory()) {
22+
if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
23+
await scan(fullPath);
24+
}
25+
} else if (entry.isFile()) {
26+
if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
27+
files.push(fullPath);
28+
}
29+
}
30+
}
31+
}
32+
33+
await scan(rootPath);
34+
return files;
35+
}
36+
37+
async function updateFiles(files) {
38+
const updatedFiles = [];
39+
for (const file of files) {
40+
const updated = await updateFileContents(file);
41+
updatedFiles.push(updated);
42+
}
43+
44+
console.log(`Updated imports in ${updatedFiles.length} files.`);
45+
}
46+
47+
async function updateFileContents(file) {
48+
const content = await fs.readFile(file, "utf8");
49+
50+
let newContent = content;
51+
// Update each extension type defined in the map
52+
for (const [oldExt, newExt] of Object.entries(extensionMap)) {
53+
const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
54+
newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
55+
}
56+
57+
if (content !== newContent) {
58+
await fs.writeFile(file, newContent, "utf8");
59+
return true;
60+
}
61+
return false;
62+
}
63+
64+
async function renameFiles(files) {
65+
let counter = 0;
66+
for (const file of files) {
67+
const ext = oldExtensions.find((ext) => file.endsWith(ext));
68+
const newExt = extensionMap[ext];
69+
70+
if (newExt) {
71+
const newPath = file.slice(0, -ext.length) + newExt;
72+
await fs.rename(file, newPath);
73+
counter++;
74+
}
75+
}
76+
77+
console.log(`Renamed ${counter} files.`);
78+
}
79+
80+
async function main() {
81+
try {
82+
const targetDir = process.argv[2];
83+
if (!targetDir) {
84+
console.error("Please provide a target directory");
85+
process.exit(1);
86+
}
87+
88+
const targetPath = path.resolve(targetDir);
89+
const targetStats = await fs.stat(targetPath);
90+
91+
if (!targetStats.isDirectory()) {
92+
console.error("The provided path is not a directory");
93+
process.exit(1);
94+
}
95+
96+
console.log(`Scanning directory: ${targetDir}`);
97+
98+
const files = await findFiles(targetDir);
99+
100+
if (files.length === 0) {
101+
console.log("No matching files found.");
102+
process.exit(0);
103+
}
104+
105+
console.log(`Found ${files.length} files.`);
106+
await updateFiles(files);
107+
await renameFiles(files);
108+
console.log("\nDone!");
109+
} catch (error) {
110+
console.error("An error occurred:", error.message);
111+
process.exit(1);
112+
}
113+
}
114+
115+
main();

src/Client.ts

+38-48
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,27 @@ import * as core from "./core";
77
import { Calls } from "./api/resources/calls/client/Client";
88
import { Assistants } from "./api/resources/assistants/client/Client";
99
import { PhoneNumbers } from "./api/resources/phoneNumbers/client/Client";
10-
import { Squads } from "./api/resources/squads/client/Client";
11-
import { KnowledgeBases } from "./api/resources/knowledgeBases/client/Client";
12-
import { Blocks } from "./api/resources/blocks/client/Client";
1310
import { Tools } from "./api/resources/tools/client/Client";
1411
import { Files } from "./api/resources/files/client/Client";
15-
import { Analytics } from "./api/resources/analytics/client/Client";
16-
import { Logs } from "./api/resources/logs/client/Client";
12+
import { KnowledgeBases } from "./api/resources/knowledgeBases/client/Client";
13+
import { Workflow } from "./api/resources/workflow/client/Client";
14+
import { Squads } from "./api/resources/squads/client/Client";
1715
import { TestSuites } from "./api/resources/testSuites/client/Client";
1816
import { TestSuiteTests } from "./api/resources/testSuiteTests/client/Client";
1917
import { TestSuiteRuns } from "./api/resources/testSuiteRuns/client/Client";
18+
import { Analytics } from "./api/resources/analytics/client/Client";
19+
import { Logs } from "./api/resources/logs/client/Client";
2020

2121
export declare namespace VapiClient {
22-
interface Options {
22+
export interface Options {
2323
environment?: core.Supplier<environments.VapiEnvironment | string>;
24+
/** Specify a custom URL to connect the client to. */
25+
baseUrl?: core.Supplier<string>;
2426
token: core.Supplier<core.BearerToken>;
2527
fetcher?: core.FetchFunction;
2628
}
2729

28-
interface RequestOptions {
30+
export interface RequestOptions {
2931
/** The maximum time to wait for a response in seconds. */
3032
timeoutInSeconds?: number;
3133
/** The number of times to retry the request. Defaults to 2. */
@@ -38,83 +40,71 @@ export declare namespace VapiClient {
3840
}
3941

4042
export class VapiClient {
41-
constructor(protected readonly _options: VapiClient.Options) {}
42-
4343
protected _calls: Calls | undefined;
44+
protected _assistants: Assistants | undefined;
45+
protected _phoneNumbers: PhoneNumbers | undefined;
46+
protected _tools: Tools | undefined;
47+
protected _files: Files | undefined;
48+
protected _knowledgeBases: KnowledgeBases | undefined;
49+
protected _workflow: Workflow | undefined;
50+
protected _squads: Squads | undefined;
51+
protected _testSuites: TestSuites | undefined;
52+
protected _testSuiteTests: TestSuiteTests | undefined;
53+
protected _testSuiteRuns: TestSuiteRuns | undefined;
54+
protected _analytics: Analytics | undefined;
55+
protected _logs: Logs | undefined;
56+
57+
constructor(protected readonly _options: VapiClient.Options) {}
4458

4559
public get calls(): Calls {
4660
return (this._calls ??= new Calls(this._options));
4761
}
4862

49-
protected _assistants: Assistants | undefined;
50-
5163
public get assistants(): Assistants {
5264
return (this._assistants ??= new Assistants(this._options));
5365
}
5466

55-
protected _phoneNumbers: PhoneNumbers | undefined;
56-
5767
public get phoneNumbers(): PhoneNumbers {
5868
return (this._phoneNumbers ??= new PhoneNumbers(this._options));
5969
}
6070

61-
protected _squads: Squads | undefined;
62-
63-
public get squads(): Squads {
64-
return (this._squads ??= new Squads(this._options));
65-
}
66-
67-
protected _knowledgeBases: KnowledgeBases | undefined;
68-
69-
public get knowledgeBases(): KnowledgeBases {
70-
return (this._knowledgeBases ??= new KnowledgeBases(this._options));
71-
}
72-
73-
protected _blocks: Blocks | undefined;
74-
75-
public get blocks(): Blocks {
76-
return (this._blocks ??= new Blocks(this._options));
77-
}
78-
79-
protected _tools: Tools | undefined;
80-
8171
public get tools(): Tools {
8272
return (this._tools ??= new Tools(this._options));
8373
}
8474

85-
protected _files: Files | undefined;
86-
8775
public get files(): Files {
8876
return (this._files ??= new Files(this._options));
8977
}
9078

91-
protected _analytics: Analytics | undefined;
92-
93-
public get analytics(): Analytics {
94-
return (this._analytics ??= new Analytics(this._options));
79+
public get knowledgeBases(): KnowledgeBases {
80+
return (this._knowledgeBases ??= new KnowledgeBases(this._options));
9581
}
9682

97-
protected _logs: Logs | undefined;
98-
99-
public get logs(): Logs {
100-
return (this._logs ??= new Logs(this._options));
83+
public get workflow(): Workflow {
84+
return (this._workflow ??= new Workflow(this._options));
10185
}
10286

103-
protected _testSuites: TestSuites | undefined;
87+
public get squads(): Squads {
88+
return (this._squads ??= new Squads(this._options));
89+
}
10490

10591
public get testSuites(): TestSuites {
10692
return (this._testSuites ??= new TestSuites(this._options));
10793
}
10894

109-
protected _testSuiteTests: TestSuiteTests | undefined;
110-
11195
public get testSuiteTests(): TestSuiteTests {
11296
return (this._testSuiteTests ??= new TestSuiteTests(this._options));
11397
}
11498

115-
protected _testSuiteRuns: TestSuiteRuns | undefined;
116-
11799
public get testSuiteRuns(): TestSuiteRuns {
118100
return (this._testSuiteRuns ??= new TestSuiteRuns(this._options));
119101
}
102+
103+
public get analytics(): Analytics {
104+
return (this._analytics ??= new Analytics(this._options));
105+
}
106+
107+
public get logs(): Logs {
108+
return (this._logs ??= new Logs(this._options));
109+
}
120110
}

0 commit comments

Comments
 (0)