@vocalstack/js-sdk 1.1.0 → 2.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +112 -69
- package/SKILL.md +252 -0
- package/dist/errors.d.ts +40 -0
- package/dist/errors.js +74 -0
- package/dist/file.d.ts +2 -0
- package/dist/file.js +38 -0
- package/dist/http.d.ts +75 -0
- package/dist/http.js +122 -0
- package/dist/index.d.ts +56 -2
- package/dist/index.js +65 -17
- package/dist/mic.d.ts +75 -0
- package/dist/mic.js +258 -0
- package/dist/realtime.d.ts +132 -0
- package/dist/realtime.js +450 -0
- package/dist/resources.d.ts +521 -0
- package/dist/resources.js +787 -0
- package/dist/subscription.d.ts +55 -0
- package/dist/subscription.js +164 -0
- package/dist/ws.d.ts +12 -0
- package/dist/ws.js +15 -0
- package/package.json +32 -36
- package/skills/vocalstack/SKILL.md +252 -0
- package/dist/ApiVersion.d.ts +0 -2
- package/dist/ApiVersion.js +0 -32
- package/dist/RestApi.d.ts +0 -21
- package/dist/RestApi.js +0 -95
- package/dist/VocalStackApi.d.ts +0 -19
- package/dist/VocalStackApi.js +0 -60
- package/dist/WebsocketApi.d.ts +0 -38
- package/dist/WebsocketApi.js +0 -150
- package/dist/apis/Billing.d.ts +0 -59
- package/dist/apis/Billing.js +0 -21
- package/dist/apis/LiveTranscription.d.ts +0 -58
- package/dist/apis/LiveTranscription.js +0 -55
- package/dist/apis/Polyglot.d.ts +0 -113
- package/dist/apis/Polyglot.js +0 -68
- package/dist/apis/Security.d.ts +0 -25
- package/dist/apis/Security.js +0 -35
- package/dist/apis/Transcriptions.d.ts +0 -60
- package/dist/apis/Transcriptions.js +0 -38
- package/dist/apis/UrlTranscription.d.ts +0 -59
- package/dist/apis/UrlTranscription.js +0 -53
- package/dist/apis/index.d.ts +0 -6
- package/dist/apis/index.js +0 -22
- package/dist/esm/ApiVersion.d.ts +0 -2
- package/dist/esm/ApiVersion.js +0 -28
- package/dist/esm/RestApi.d.ts +0 -21
- package/dist/esm/RestApi.js +0 -91
- package/dist/esm/VocalStackApi.d.ts +0 -19
- package/dist/esm/VocalStackApi.js +0 -56
- package/dist/esm/WebsocketApi.d.ts +0 -38
- package/dist/esm/WebsocketApi.js +0 -146
- package/dist/esm/apis/Billing.d.ts +0 -59
- package/dist/esm/apis/Billing.js +0 -17
- package/dist/esm/apis/LiveTranscription.d.ts +0 -58
- package/dist/esm/apis/LiveTranscription.js +0 -51
- package/dist/esm/apis/Polyglot.d.ts +0 -113
- package/dist/esm/apis/Polyglot.js +0 -64
- package/dist/esm/apis/Security.d.ts +0 -25
- package/dist/esm/apis/Security.js +0 -31
- package/dist/esm/apis/Transcriptions.d.ts +0 -60
- package/dist/esm/apis/Transcriptions.js +0 -34
- package/dist/esm/apis/UrlTranscription.d.ts +0 -59
- package/dist/esm/apis/UrlTranscription.js +0 -49
- package/dist/esm/apis/index.d.ts +0 -6
- package/dist/esm/apis/index.js +0 -6
- package/dist/esm/generics.zod.d.ts +0 -83
- package/dist/esm/generics.zod.js +0 -47
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +0 -2
- package/dist/generics.zod.d.ts +0 -83
- package/dist/generics.zod.js +0 -50
package/dist/RestApi.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.RestApi = void 0;
|
|
24
|
-
const ApiVersion_1 = require("./ApiVersion");
|
|
25
|
-
class RestApi {
|
|
26
|
-
constructor(apiServer, headers) {
|
|
27
|
-
this.apiServer = apiServer;
|
|
28
|
-
this.headers = headers;
|
|
29
|
-
}
|
|
30
|
-
get(path, options) {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return this.apiCall('GET', path, options);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
post(path, options) {
|
|
36
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
-
return this.apiCall('POST', path, options);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
put(path, options) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
return this.apiCall('PUT', path, options);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
patch(path, options) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return this.apiCall('PATCH', path, options);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
delete(path, options) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
return this.apiCall('DELETE', path, options);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
apiCall(method, path, options) {
|
|
56
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
try {
|
|
58
|
-
const fixedPath = path.startsWith('/') ? path.slice(1) : path;
|
|
59
|
-
const _a = options || {}, { json } = _a, fetchOptions = __rest(_a, ["json"]);
|
|
60
|
-
const body = json ? JSON.stringify(json) : undefined;
|
|
61
|
-
const headers = Object.assign(Object.assign({}, this.headers), { 'X-Expected-API-Version': ApiVersion_1.EXPECTED_VOCALSTACK_API_VERSION });
|
|
62
|
-
if (body) {
|
|
63
|
-
headers['Content-Type'] = 'application/json';
|
|
64
|
-
}
|
|
65
|
-
const response = yield fetch(`${this.apiServer}/${fixedPath}`, Object.assign({ method,
|
|
66
|
-
headers,
|
|
67
|
-
body }, fetchOptions));
|
|
68
|
-
(0, ApiVersion_1.verifyApiVersion)(response.headers.get('X-API-Version'), response.headers.get('X-API-Version-Discontinued') === '1');
|
|
69
|
-
return this.respond(response);
|
|
70
|
-
}
|
|
71
|
-
catch (e) {
|
|
72
|
-
console.log(e);
|
|
73
|
-
return {
|
|
74
|
-
success: false,
|
|
75
|
-
error: String(e),
|
|
76
|
-
status: 'error',
|
|
77
|
-
data: undefined,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
respond(response) {
|
|
83
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
-
const success = response.ok;
|
|
85
|
-
const json = success ? yield response.json() : undefined;
|
|
86
|
-
const data = Object.assign({ success, error: !success ? response.statusText : undefined }, json);
|
|
87
|
-
if ((data === null || data === void 0 ? void 0 : data.status) === 'error') {
|
|
88
|
-
data.error = 'An error occurred while processing the request.';
|
|
89
|
-
data.success = false;
|
|
90
|
-
}
|
|
91
|
-
return data;
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
exports.RestApi = RestApi;
|
package/dist/VocalStackApi.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { ApiResponse, RestApi } from './RestApi';
|
|
3
|
-
import { WebSocketsApi } from './WebsocketApi';
|
|
4
|
-
import { Configuration } from './generics.zod';
|
|
5
|
-
export declare const VOCALSTACK_API_SERVER = "https://api.vocalstack.com";
|
|
6
|
-
export declare class VocalStackApi {
|
|
7
|
-
protected headers: Record<string, string>;
|
|
8
|
-
protected apiServer: string;
|
|
9
|
-
constructor(config: Configuration);
|
|
10
|
-
protected _rest(): RestApi;
|
|
11
|
-
protected _ws(): WebSocketsApi;
|
|
12
|
-
private buildConfiguration;
|
|
13
|
-
protected withValidation(zodType: z.ZodType, data: unknown): {
|
|
14
|
-
success: boolean;
|
|
15
|
-
badResponse: ApiResponse<null> | undefined;
|
|
16
|
-
data: any;
|
|
17
|
-
};
|
|
18
|
-
protected buildQueryString(params: Record<string, undefined | string | number | boolean | Array<string | number | boolean>>): string;
|
|
19
|
-
}
|
package/dist/VocalStackApi.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VocalStackApi = exports.VOCALSTACK_API_SERVER = void 0;
|
|
4
|
-
const RestApi_1 = require("./RestApi");
|
|
5
|
-
const WebsocketApi_1 = require("./WebsocketApi");
|
|
6
|
-
const generics_zod_1 = require("./generics.zod");
|
|
7
|
-
exports.VOCALSTACK_API_SERVER = 'https://api.vocalstack.com';
|
|
8
|
-
class VocalStackApi {
|
|
9
|
-
constructor(config) {
|
|
10
|
-
const { apiServer, headers } = this.buildConfiguration(config);
|
|
11
|
-
this.apiServer = apiServer;
|
|
12
|
-
this.headers = headers;
|
|
13
|
-
}
|
|
14
|
-
_rest() {
|
|
15
|
-
return new RestApi_1.RestApi(this.apiServer, this.headers);
|
|
16
|
-
}
|
|
17
|
-
_ws() {
|
|
18
|
-
return new WebsocketApi_1.WebSocketsApi(this.apiServer, this.headers);
|
|
19
|
-
}
|
|
20
|
-
buildConfiguration(config) {
|
|
21
|
-
const parsedConfiguration = generics_zod_1.zConfiguration.safeParse(config);
|
|
22
|
-
if (!parsedConfiguration.success) {
|
|
23
|
-
throw new Error(parsedConfiguration.error.errors.map((err) => err.message).join(', '));
|
|
24
|
-
}
|
|
25
|
-
const data = parsedConfiguration.data;
|
|
26
|
-
return Object.assign(Object.assign({}, data), { apiServer: data.apiServer || exports.VOCALSTACK_API_SERVER, headers: Object.assign(Object.assign({}, data.headers), { authorization: data.authToken ? `Bearer ${data.authToken}` : data.apiKey || '' }) });
|
|
27
|
-
}
|
|
28
|
-
withValidation(zodType, data) {
|
|
29
|
-
const parsedRequest = zodType.safeParse(data);
|
|
30
|
-
return {
|
|
31
|
-
success: parsedRequest.success,
|
|
32
|
-
badResponse: parsedRequest.success
|
|
33
|
-
? undefined
|
|
34
|
-
: {
|
|
35
|
-
status: 'error',
|
|
36
|
-
data: null,
|
|
37
|
-
success: false,
|
|
38
|
-
error: parsedRequest.error.errors.map((err) => err.message).join(', '),
|
|
39
|
-
},
|
|
40
|
-
data: parsedRequest.success ? parsedRequest.data : null,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
buildQueryString(params) {
|
|
44
|
-
return Object.entries(params)
|
|
45
|
-
.flatMap(([key, value]) => {
|
|
46
|
-
if (value === undefined || value === null)
|
|
47
|
-
return [];
|
|
48
|
-
if (Array.isArray(value)) {
|
|
49
|
-
return value
|
|
50
|
-
.filter((v) => v !== undefined && v !== null && v !== '')
|
|
51
|
-
.map((v) => `${key}=${encodeURIComponent(String(v))}`);
|
|
52
|
-
}
|
|
53
|
-
if (value === '')
|
|
54
|
-
return [];
|
|
55
|
-
return [`${key}=${encodeURIComponent(String(value))}`];
|
|
56
|
-
})
|
|
57
|
-
.join('&');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
exports.VocalStackApi = VocalStackApi;
|
package/dist/WebsocketApi.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export interface WebsocketRequestOptions {
|
|
2
|
-
path: string;
|
|
3
|
-
mustStart?: boolean;
|
|
4
|
-
headers?: Record<string, string>;
|
|
5
|
-
}
|
|
6
|
-
export type WebsocketConnection<ResponseType> = {
|
|
7
|
-
start: () => void;
|
|
8
|
-
close: () => void;
|
|
9
|
-
onClose: (callback: () => void) => void;
|
|
10
|
-
onData: (callback: (ev: ResponseType) => void) => void;
|
|
11
|
-
};
|
|
12
|
-
export type DuplexWebsocketConnection<RequestType, ResponseType> = WebsocketConnection<ResponseType> & {
|
|
13
|
-
stop: () => void;
|
|
14
|
-
sendBuffer: (message: RequestType) => void;
|
|
15
|
-
};
|
|
16
|
-
export declare class WebSocketsApi {
|
|
17
|
-
private apiServer;
|
|
18
|
-
private headers;
|
|
19
|
-
private socket;
|
|
20
|
-
private WebSocketClass;
|
|
21
|
-
private started;
|
|
22
|
-
private session;
|
|
23
|
-
constructor(apiServer: string, headers: Record<string, string>);
|
|
24
|
-
private makeSocketConnection;
|
|
25
|
-
connect<ResponseType>(options: WebsocketRequestOptions): Promise<{
|
|
26
|
-
start: () => void;
|
|
27
|
-
close: () => void;
|
|
28
|
-
onClose: (callback: () => void) => void;
|
|
29
|
-
onData: (callback: (ev: ResponseType) => void) => void;
|
|
30
|
-
}>;
|
|
31
|
-
connectDuplex<RequestType, ResponseType>(options: WebsocketRequestOptions): Promise<DuplexWebsocketConnection<RequestType, ResponseType>>;
|
|
32
|
-
private returnConnection;
|
|
33
|
-
private returnDuplexConnection;
|
|
34
|
-
private sendBuffer;
|
|
35
|
-
private onMessage;
|
|
36
|
-
private onClose;
|
|
37
|
-
private close;
|
|
38
|
-
}
|
package/dist/WebsocketApi.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.WebSocketsApi = void 0;
|
|
13
|
-
class WebSocketsApi {
|
|
14
|
-
constructor(apiServer, headers) {
|
|
15
|
-
this.apiServer = apiServer;
|
|
16
|
-
this.headers = headers;
|
|
17
|
-
this.socket = undefined;
|
|
18
|
-
this.WebSocketClass = undefined;
|
|
19
|
-
this.started = false;
|
|
20
|
-
if (typeof window !== 'undefined') {
|
|
21
|
-
// Browser environment: use native WebSocket
|
|
22
|
-
this.WebSocketClass = window.WebSocket;
|
|
23
|
-
}
|
|
24
|
-
else if (typeof globalThis.WebSocket !== 'undefined') {
|
|
25
|
-
// Node.js environment: use global WebSocket if available (e.g., Node 22+)
|
|
26
|
-
this.WebSocketClass = globalThis.WebSocket;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
// Node.js environment: use "ws" package where WebSocket is not available
|
|
30
|
-
this.WebSocketClass = require('ws').WebSocket;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
makeSocketConnection(options) {
|
|
34
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
-
yield new Promise((resolve, reject) => {
|
|
36
|
-
const base = this.apiServer.replace('https://', 'wss://').replace('http://', 'ws://');
|
|
37
|
-
const url = `${base}${options.path}`;
|
|
38
|
-
const headers = Object.assign(Object.assign(Object.assign({}, this.headers), options.headers), { path: options.path });
|
|
39
|
-
if (!this.WebSocketClass) {
|
|
40
|
-
throw Error('WebSocket class was not loaded.');
|
|
41
|
-
}
|
|
42
|
-
const socket = new this.WebSocketClass(url);
|
|
43
|
-
this.socket = socket;
|
|
44
|
-
if (!this.socket) {
|
|
45
|
-
throw Error('Failed to create WebSocket connection');
|
|
46
|
-
}
|
|
47
|
-
socket.onopen = () => {
|
|
48
|
-
socket.send(JSON.stringify({ headers, session: this.session }));
|
|
49
|
-
if (!options.mustStart) {
|
|
50
|
-
resolve();
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
socket.addEventListener('message', (event) => {
|
|
54
|
-
const data = JSON.parse(event.data.toString());
|
|
55
|
-
if (data === null || data === void 0 ? void 0 : data.session) {
|
|
56
|
-
resolve();
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
socket.onerror = (error) => {
|
|
61
|
-
console.error('WebSocket error:', error);
|
|
62
|
-
reject('A websocket error occurred connecting to the VocalStack API');
|
|
63
|
-
};
|
|
64
|
-
socket.addEventListener('message', (event) => {
|
|
65
|
-
var _a;
|
|
66
|
-
const data = JSON.parse(event.data.toString());
|
|
67
|
-
if (data === null || data === void 0 ? void 0 : data.session) {
|
|
68
|
-
this.session = data.session;
|
|
69
|
-
}
|
|
70
|
-
if ((data === null || data === void 0 ? void 0 : data.status) === 'done') {
|
|
71
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
connect(options) {
|
|
78
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
-
yield this.makeSocketConnection(options);
|
|
80
|
-
return this.returnConnection();
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
connectDuplex(options) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
yield this.makeSocketConnection(Object.assign(Object.assign({}, options), { mustStart: true }));
|
|
86
|
-
return this.returnDuplexConnection();
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
returnConnection() {
|
|
90
|
-
return {
|
|
91
|
-
start: () => {
|
|
92
|
-
if (!this.socket) {
|
|
93
|
-
console.error('Socket not connected');
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (this.started) {
|
|
97
|
-
console.error('Already started');
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.started = true;
|
|
101
|
-
this.socket.send(JSON.stringify({ start: true, session: this.session }));
|
|
102
|
-
},
|
|
103
|
-
close: () => this.close(),
|
|
104
|
-
onClose: (callback) => this.onClose(callback),
|
|
105
|
-
onData: (callback) => this.onMessage(callback),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
returnDuplexConnection() {
|
|
109
|
-
return Object.assign(Object.assign({}, this.returnConnection()), { stop: () => !this.socket
|
|
110
|
-
? console.error('Socket not connected')
|
|
111
|
-
: this.socket.send(JSON.stringify({ stop: true, session: this.session })), sendBuffer: (message) => this.sendBuffer(message) });
|
|
112
|
-
}
|
|
113
|
-
sendBuffer(buffer) {
|
|
114
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
var _a;
|
|
116
|
-
if (!this.socket || this.socket.readyState !== ((_a = this.WebSocketClass) === null || _a === void 0 ? void 0 : _a.OPEN)) {
|
|
117
|
-
throw Error('WebSocket is not connected.');
|
|
118
|
-
}
|
|
119
|
-
if (!(buffer instanceof ArrayBuffer) && !ArrayBuffer.isView(buffer)) {
|
|
120
|
-
throw Error('Unexpected data type being sent. Expected: ArrayBuffer or ArrayBufferView');
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.socket.send(buffer);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
onMessage(callback) {
|
|
128
|
-
if (!this.socket) {
|
|
129
|
-
throw Error('WebSocket is not connected.');
|
|
130
|
-
}
|
|
131
|
-
this.socket.addEventListener('message', (event) => {
|
|
132
|
-
const data = JSON.parse(event.data.toString());
|
|
133
|
-
callback(data);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
onClose(callback) {
|
|
137
|
-
if (!this.socket) {
|
|
138
|
-
throw Error('WebSocket is not connected.');
|
|
139
|
-
}
|
|
140
|
-
this.socket.addEventListener('close', callback);
|
|
141
|
-
}
|
|
142
|
-
close() {
|
|
143
|
-
if (!this.socket) {
|
|
144
|
-
console.error('WebSocket is not connected.');
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
this.socket.close();
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
exports.WebSocketsApi = WebSocketsApi;
|
package/dist/apis/Billing.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { VocalStackApi } from '../VocalStackApi';
|
|
2
|
-
import { SummaryTranscription } from './Transcriptions';
|
|
3
|
-
export type BillingDetailsPlan = {
|
|
4
|
-
uuid: string;
|
|
5
|
-
start_date: string;
|
|
6
|
-
stop_date: string;
|
|
7
|
-
price: number;
|
|
8
|
-
billing_frequency: string;
|
|
9
|
-
free_hours: number;
|
|
10
|
-
overage_rate_prerecorded: number;
|
|
11
|
-
overage_rate_live: number;
|
|
12
|
-
meta_name: string;
|
|
13
|
-
};
|
|
14
|
-
export type BillingDetails = {
|
|
15
|
-
balance: number;
|
|
16
|
-
prerecorded_hours_available: number;
|
|
17
|
-
live_hours_available: number;
|
|
18
|
-
free_hours_used: number;
|
|
19
|
-
free_hours_left: number;
|
|
20
|
-
total_per_month: Record<string, number>;
|
|
21
|
-
savings_per_month: Record<string, number>;
|
|
22
|
-
paid_per_month: Record<string, number>;
|
|
23
|
-
owed_per_month: Record<string, number>;
|
|
24
|
-
plans: BillingDetailsPlan[];
|
|
25
|
-
active_plan: BillingDetailsPlan;
|
|
26
|
-
hobby_plan: BillingDetailsPlan;
|
|
27
|
-
month_plans: Record<string, string[]>;
|
|
28
|
-
billing: Record<string, Array<Partial<SummaryTranscription> & {
|
|
29
|
-
plan: string;
|
|
30
|
-
length_in_adjusted_seconds: number;
|
|
31
|
-
free_seconds_available_before?: number;
|
|
32
|
-
free_seconds_available_after?: number;
|
|
33
|
-
cost: number;
|
|
34
|
-
notes: string[];
|
|
35
|
-
}>>;
|
|
36
|
-
invoices: Array<{
|
|
37
|
-
invoice_id: string;
|
|
38
|
-
plan_id?: string;
|
|
39
|
-
plan_uuid?: string;
|
|
40
|
-
interval?: 'year' | 'month';
|
|
41
|
-
status: 'open' | 'paid' | 'void';
|
|
42
|
-
status_transitions: {
|
|
43
|
-
paid_at: number;
|
|
44
|
-
finalized_at: number;
|
|
45
|
-
marked_uncollectible_at: number;
|
|
46
|
-
voided_at: number;
|
|
47
|
-
};
|
|
48
|
-
paid: boolean;
|
|
49
|
-
amount: number;
|
|
50
|
-
amount_paid: number;
|
|
51
|
-
amount_remaining: number;
|
|
52
|
-
view_link: string;
|
|
53
|
-
download_link: string;
|
|
54
|
-
metadata?: Record<string, string>;
|
|
55
|
-
}>;
|
|
56
|
-
};
|
|
57
|
-
export declare class Billing extends VocalStackApi {
|
|
58
|
-
getBillingDetails(): Promise<import("../RestApi").ApiResponse<BillingDetails>>;
|
|
59
|
-
}
|
package/dist/apis/Billing.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Billing = void 0;
|
|
13
|
-
const VocalStackApi_1 = require("../VocalStackApi");
|
|
14
|
-
class Billing extends VocalStackApi_1.VocalStackApi {
|
|
15
|
-
getBillingDetails() {
|
|
16
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
return this._rest().get('/billing/details');
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.Billing = Billing;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { Timeline, Uuid } from '../generics.zod';
|
|
3
|
-
import { VocalStackApi } from '../VocalStackApi';
|
|
4
|
-
import { DuplexWebsocketConnection } from '../WebsocketApi';
|
|
5
|
-
import { Status } from './Transcriptions';
|
|
6
|
-
declare const zLiveTranscriptionStartRequest: z.ZodObject<{
|
|
7
|
-
livestream_url: z.ZodOptional<z.ZodString>;
|
|
8
|
-
language: z.ZodOptional<z.ZodEnum<["af", "am", "an", "ar", "as", "az", "be", "bg", "bn", "br", "bs", "ca", "cs", "cy", "da", "de", "dz", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "ga", "gl", "gu", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "jv", "ka", "kk", "km", "kn", "ko", "ku", "ky", "la", "lb", "lo", "lt", "lv", "mg", "mk", "ml", "mn", "mr", "ms", "mt", "nb", "ne", "nl", "nn", "no", "oc", "or", "pa", "pl", "ps", "pt", "qu", "ro", "ru", "rw", "se", "si", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "ug", "uk", "ur", "vi", "vo", "wa", "xh", "zh", "zu"]>>;
|
|
9
|
-
translations: z.ZodOptional<z.ZodArray<z.ZodEnum<["af", "am", "an", "ar", "as", "az", "be", "bg", "bn", "br", "bs", "ca", "cs", "cy", "da", "de", "dz", "el", "en", "eo", "es", "et", "eu", "fa", "fi", "fo", "fr", "ga", "gl", "gu", "he", "hi", "hr", "ht", "hu", "hy", "id", "is", "it", "ja", "jv", "ka", "kk", "km", "kn", "ko", "ku", "ky", "la", "lb", "lo", "lt", "lv", "mg", "mk", "ml", "mn", "mr", "ms", "mt", "nb", "ne", "nl", "nn", "no", "oc", "or", "pa", "pl", "ps", "pt", "qu", "ro", "ru", "rw", "se", "si", "sk", "sl", "sq", "sr", "sv", "sw", "ta", "te", "th", "tl", "tr", "ug", "uk", "ur", "vi", "vo", "wa", "xh", "zh", "zu"]>, "many">>;
|
|
10
|
-
polyglot_id: z.ZodOptional<z.ZodString>;
|
|
11
|
-
timeout_period_s: z.ZodOptional<z.ZodNumber>;
|
|
12
|
-
max_duration_s: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
|
|
15
|
-
translations?: ("id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu")[] | undefined;
|
|
16
|
-
livestream_url?: string | undefined;
|
|
17
|
-
polyglot_id?: string | undefined;
|
|
18
|
-
timeout_period_s?: number | undefined;
|
|
19
|
-
max_duration_s?: number | undefined;
|
|
20
|
-
}, {
|
|
21
|
-
language?: "id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu" | undefined;
|
|
22
|
-
translations?: ("id" | "cy" | "br" | "hr" | "th" | "tr" | "mn" | "ms" | "or" | "af" | "am" | "an" | "ar" | "as" | "az" | "be" | "bg" | "bn" | "bs" | "ca" | "cs" | "da" | "de" | "dz" | "el" | "en" | "eo" | "es" | "et" | "eu" | "fa" | "fi" | "fo" | "fr" | "ga" | "gl" | "gu" | "he" | "hi" | "ht" | "hu" | "hy" | "is" | "it" | "ja" | "jv" | "ka" | "kk" | "km" | "kn" | "ko" | "ku" | "ky" | "la" | "lb" | "lo" | "lt" | "lv" | "mg" | "mk" | "ml" | "mr" | "mt" | "nb" | "ne" | "nl" | "nn" | "no" | "oc" | "pa" | "pl" | "ps" | "pt" | "qu" | "ro" | "ru" | "rw" | "se" | "si" | "sk" | "sl" | "sq" | "sr" | "sv" | "sw" | "ta" | "te" | "tl" | "ug" | "uk" | "ur" | "vi" | "vo" | "wa" | "xh" | "zh" | "zu")[] | undefined;
|
|
23
|
-
livestream_url?: string | undefined;
|
|
24
|
-
polyglot_id?: string | undefined;
|
|
25
|
-
timeout_period_s?: number | undefined;
|
|
26
|
-
max_duration_s?: number | undefined;
|
|
27
|
-
}>;
|
|
28
|
-
export type LiveTranscriptionStartRequest = z.infer<typeof zLiveTranscriptionStartRequest>;
|
|
29
|
-
export type LiveTranscriptionStreamData = ArrayBufferLike;
|
|
30
|
-
export type LiveTranscriptionResponse = {
|
|
31
|
-
status: Status;
|
|
32
|
-
data: LiveTranscriptionResponseData | null;
|
|
33
|
-
http_code?: number;
|
|
34
|
-
};
|
|
35
|
-
export type LiveTranscriptionResponseData = {
|
|
36
|
-
id: Uuid;
|
|
37
|
-
polyglot_id: Uuid | null;
|
|
38
|
-
start: string;
|
|
39
|
-
end: string | null;
|
|
40
|
-
status: Status;
|
|
41
|
-
operation: 'transcription-live';
|
|
42
|
-
flags?: {
|
|
43
|
-
started: boolean;
|
|
44
|
-
} | null;
|
|
45
|
-
keywords?: string | null;
|
|
46
|
-
timeline?: Timeline;
|
|
47
|
-
paragraphs?: string[] | null;
|
|
48
|
-
summary?: string | null;
|
|
49
|
-
};
|
|
50
|
-
export type LiveTranscriptionStopRequest = {
|
|
51
|
-
id: string;
|
|
52
|
-
};
|
|
53
|
-
export type LiveTranscriptionConnection = DuplexWebsocketConnection<LiveTranscriptionStreamData, LiveTranscriptionResponse>;
|
|
54
|
-
export declare class LiveTranscription extends VocalStackApi {
|
|
55
|
-
connect(request?: LiveTranscriptionStartRequest): Promise<LiveTranscriptionConnection>;
|
|
56
|
-
stopTranscribing({ id }: LiveTranscriptionStopRequest): Promise<import("../RestApi").ApiResponse<unknown>>;
|
|
57
|
-
}
|
|
58
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LiveTranscription = void 0;
|
|
13
|
-
const zod_1 = require("zod");
|
|
14
|
-
const generics_zod_1 = require("../generics.zod");
|
|
15
|
-
const VocalStackApi_1 = require("../VocalStackApi");
|
|
16
|
-
const zLiveTranscriptionStartRequest = zod_1.z.object({
|
|
17
|
-
livestream_url: zod_1.z.string().optional(),
|
|
18
|
-
language: generics_zod_1.zLanguage.optional(),
|
|
19
|
-
translations: generics_zod_1.zLanguage.array().optional(),
|
|
20
|
-
polyglot_id: zod_1.z.string().optional(),
|
|
21
|
-
timeout_period_s: zod_1.z.number().optional(),
|
|
22
|
-
max_duration_s: zod_1.z.number().optional(),
|
|
23
|
-
});
|
|
24
|
-
class LiveTranscription extends VocalStackApi_1.VocalStackApi {
|
|
25
|
-
connect() {
|
|
26
|
-
return __awaiter(this, arguments, void 0, function* (request = {}) {
|
|
27
|
-
var _a;
|
|
28
|
-
const validation = this.withValidation(zLiveTranscriptionStartRequest, request);
|
|
29
|
-
if (validation.badResponse) {
|
|
30
|
-
throw new Error(validation.badResponse.error);
|
|
31
|
-
}
|
|
32
|
-
const headers = {};
|
|
33
|
-
if (request['livestream_url'] && request['livestream_url'] !== 'undefined') {
|
|
34
|
-
headers['livestream-url'] = request.livestream_url;
|
|
35
|
-
}
|
|
36
|
-
const queryString = this.buildQueryString({
|
|
37
|
-
polyglot_id: request.polyglot_id,
|
|
38
|
-
language: request.language,
|
|
39
|
-
translations: (_a = request.translations) === null || _a === void 0 ? void 0 : _a.join(','),
|
|
40
|
-
timeout_period_s: request.timeout_period_s,
|
|
41
|
-
max_duration_s: request.max_duration_s,
|
|
42
|
-
});
|
|
43
|
-
return this._ws().connectDuplex({
|
|
44
|
-
path: `/async/live/transcribe?${queryString}`,
|
|
45
|
-
headers,
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
stopTranscribing(_a) {
|
|
50
|
-
return __awaiter(this, arguments, void 0, function* ({ id }) {
|
|
51
|
-
return this._rest().patch(`/live/transcribe/${id}/stop`);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.LiveTranscription = LiveTranscription;
|