@vocalstack/js-sdk 1.1.0 → 2.0.0-alpha.1

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.
Files changed (73) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +112 -65
  3. package/SKILL.md +249 -0
  4. package/dist/errors.d.ts +22 -0
  5. package/dist/errors.js +56 -0
  6. package/dist/file.d.ts +2 -0
  7. package/dist/file.js +38 -0
  8. package/dist/http.d.ts +43 -0
  9. package/dist/http.js +124 -0
  10. package/dist/index.d.ts +42 -2
  11. package/dist/index.js +51 -17
  12. package/dist/mic.d.ts +27 -0
  13. package/dist/mic.js +236 -0
  14. package/dist/realtime.d.ts +77 -0
  15. package/dist/realtime.js +490 -0
  16. package/dist/resources.d.ts +374 -0
  17. package/dist/resources.js +712 -0
  18. package/dist/subscription.d.ts +38 -0
  19. package/dist/subscription.js +153 -0
  20. package/dist/ws.d.ts +9 -0
  21. package/dist/ws.js +12 -0
  22. package/package.json +32 -36
  23. package/skills/vocalstack/SKILL.md +249 -0
  24. package/dist/ApiVersion.d.ts +0 -2
  25. package/dist/ApiVersion.js +0 -32
  26. package/dist/RestApi.d.ts +0 -21
  27. package/dist/RestApi.js +0 -95
  28. package/dist/VocalStackApi.d.ts +0 -19
  29. package/dist/VocalStackApi.js +0 -60
  30. package/dist/WebsocketApi.d.ts +0 -38
  31. package/dist/WebsocketApi.js +0 -150
  32. package/dist/apis/Billing.d.ts +0 -59
  33. package/dist/apis/Billing.js +0 -21
  34. package/dist/apis/LiveTranscription.d.ts +0 -58
  35. package/dist/apis/LiveTranscription.js +0 -55
  36. package/dist/apis/Polyglot.d.ts +0 -113
  37. package/dist/apis/Polyglot.js +0 -68
  38. package/dist/apis/Security.d.ts +0 -25
  39. package/dist/apis/Security.js +0 -35
  40. package/dist/apis/Transcriptions.d.ts +0 -60
  41. package/dist/apis/Transcriptions.js +0 -38
  42. package/dist/apis/UrlTranscription.d.ts +0 -59
  43. package/dist/apis/UrlTranscription.js +0 -53
  44. package/dist/apis/index.d.ts +0 -6
  45. package/dist/apis/index.js +0 -22
  46. package/dist/esm/ApiVersion.d.ts +0 -2
  47. package/dist/esm/ApiVersion.js +0 -28
  48. package/dist/esm/RestApi.d.ts +0 -21
  49. package/dist/esm/RestApi.js +0 -91
  50. package/dist/esm/VocalStackApi.d.ts +0 -19
  51. package/dist/esm/VocalStackApi.js +0 -56
  52. package/dist/esm/WebsocketApi.d.ts +0 -38
  53. package/dist/esm/WebsocketApi.js +0 -146
  54. package/dist/esm/apis/Billing.d.ts +0 -59
  55. package/dist/esm/apis/Billing.js +0 -17
  56. package/dist/esm/apis/LiveTranscription.d.ts +0 -58
  57. package/dist/esm/apis/LiveTranscription.js +0 -51
  58. package/dist/esm/apis/Polyglot.d.ts +0 -113
  59. package/dist/esm/apis/Polyglot.js +0 -64
  60. package/dist/esm/apis/Security.d.ts +0 -25
  61. package/dist/esm/apis/Security.js +0 -31
  62. package/dist/esm/apis/Transcriptions.d.ts +0 -60
  63. package/dist/esm/apis/Transcriptions.js +0 -34
  64. package/dist/esm/apis/UrlTranscription.d.ts +0 -59
  65. package/dist/esm/apis/UrlTranscription.js +0 -49
  66. package/dist/esm/apis/index.d.ts +0 -6
  67. package/dist/esm/apis/index.js +0 -6
  68. package/dist/esm/generics.zod.d.ts +0 -83
  69. package/dist/esm/generics.zod.js +0 -47
  70. package/dist/esm/index.d.ts +0 -2
  71. package/dist/esm/index.js +0 -2
  72. package/dist/generics.zod.d.ts +0 -83
  73. package/dist/generics.zod.js +0 -50
@@ -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
- }
@@ -1,56 +0,0 @@
1
- import { RestApi } from './RestApi';
2
- import { WebSocketsApi } from './WebsocketApi';
3
- import { zConfiguration } from './generics.zod';
4
- export const VOCALSTACK_API_SERVER = 'https://api.vocalstack.com';
5
- export class VocalStackApi {
6
- constructor(config) {
7
- const { apiServer, headers } = this.buildConfiguration(config);
8
- this.apiServer = apiServer;
9
- this.headers = headers;
10
- }
11
- _rest() {
12
- return new RestApi(this.apiServer, this.headers);
13
- }
14
- _ws() {
15
- return new WebSocketsApi(this.apiServer, this.headers);
16
- }
17
- buildConfiguration(config) {
18
- const parsedConfiguration = zConfiguration.safeParse(config);
19
- if (!parsedConfiguration.success) {
20
- throw new Error(parsedConfiguration.error.errors.map((err) => err.message).join(', '));
21
- }
22
- const data = parsedConfiguration.data;
23
- return Object.assign(Object.assign({}, data), { apiServer: data.apiServer || VOCALSTACK_API_SERVER, headers: Object.assign(Object.assign({}, data.headers), { authorization: data.authToken ? `Bearer ${data.authToken}` : data.apiKey || '' }) });
24
- }
25
- withValidation(zodType, data) {
26
- const parsedRequest = zodType.safeParse(data);
27
- return {
28
- success: parsedRequest.success,
29
- badResponse: parsedRequest.success
30
- ? undefined
31
- : {
32
- status: 'error',
33
- data: null,
34
- success: false,
35
- error: parsedRequest.error.errors.map((err) => err.message).join(', '),
36
- },
37
- data: parsedRequest.success ? parsedRequest.data : null,
38
- };
39
- }
40
- buildQueryString(params) {
41
- return Object.entries(params)
42
- .flatMap(([key, value]) => {
43
- if (value === undefined || value === null)
44
- return [];
45
- if (Array.isArray(value)) {
46
- return value
47
- .filter((v) => v !== undefined && v !== null && v !== '')
48
- .map((v) => `${key}=${encodeURIComponent(String(v))}`);
49
- }
50
- if (value === '')
51
- return [];
52
- return [`${key}=${encodeURIComponent(String(value))}`];
53
- })
54
- .join('&');
55
- }
56
- }
@@ -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
- }
@@ -1,146 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- export class WebSocketsApi {
11
- constructor(apiServer, headers) {
12
- this.apiServer = apiServer;
13
- this.headers = headers;
14
- this.socket = undefined;
15
- this.WebSocketClass = undefined;
16
- this.started = false;
17
- if (typeof window !== 'undefined') {
18
- // Browser environment: use native WebSocket
19
- this.WebSocketClass = window.WebSocket;
20
- }
21
- else if (typeof globalThis.WebSocket !== 'undefined') {
22
- // Node.js environment: use global WebSocket if available (e.g., Node 22+)
23
- this.WebSocketClass = globalThis.WebSocket;
24
- }
25
- else {
26
- // Node.js environment: use "ws" package where WebSocket is not available
27
- this.WebSocketClass = require('ws').WebSocket;
28
- }
29
- }
30
- makeSocketConnection(options) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- yield new Promise((resolve, reject) => {
33
- const base = this.apiServer.replace('https://', 'wss://').replace('http://', 'ws://');
34
- const url = `${base}${options.path}`;
35
- const headers = Object.assign(Object.assign(Object.assign({}, this.headers), options.headers), { path: options.path });
36
- if (!this.WebSocketClass) {
37
- throw Error('WebSocket class was not loaded.');
38
- }
39
- const socket = new this.WebSocketClass(url);
40
- this.socket = socket;
41
- if (!this.socket) {
42
- throw Error('Failed to create WebSocket connection');
43
- }
44
- socket.onopen = () => {
45
- socket.send(JSON.stringify({ headers, session: this.session }));
46
- if (!options.mustStart) {
47
- resolve();
48
- return;
49
- }
50
- socket.addEventListener('message', (event) => {
51
- const data = JSON.parse(event.data.toString());
52
- if (data === null || data === void 0 ? void 0 : data.session) {
53
- resolve();
54
- }
55
- });
56
- };
57
- socket.onerror = (error) => {
58
- console.error('WebSocket error:', error);
59
- reject('A websocket error occurred connecting to the VocalStack API');
60
- };
61
- socket.addEventListener('message', (event) => {
62
- var _a;
63
- const data = JSON.parse(event.data.toString());
64
- if (data === null || data === void 0 ? void 0 : data.session) {
65
- this.session = data.session;
66
- }
67
- if ((data === null || data === void 0 ? void 0 : data.status) === 'done') {
68
- (_a = this.socket) === null || _a === void 0 ? void 0 : _a.close();
69
- }
70
- });
71
- });
72
- });
73
- }
74
- connect(options) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- yield this.makeSocketConnection(options);
77
- return this.returnConnection();
78
- });
79
- }
80
- connectDuplex(options) {
81
- return __awaiter(this, void 0, void 0, function* () {
82
- yield this.makeSocketConnection(Object.assign(Object.assign({}, options), { mustStart: true }));
83
- return this.returnDuplexConnection();
84
- });
85
- }
86
- returnConnection() {
87
- return {
88
- start: () => {
89
- if (!this.socket) {
90
- console.error('Socket not connected');
91
- return;
92
- }
93
- if (this.started) {
94
- console.error('Already started');
95
- return;
96
- }
97
- this.started = true;
98
- this.socket.send(JSON.stringify({ start: true, session: this.session }));
99
- },
100
- close: () => this.close(),
101
- onClose: (callback) => this.onClose(callback),
102
- onData: (callback) => this.onMessage(callback),
103
- };
104
- }
105
- returnDuplexConnection() {
106
- return Object.assign(Object.assign({}, this.returnConnection()), { stop: () => !this.socket
107
- ? console.error('Socket not connected')
108
- : this.socket.send(JSON.stringify({ stop: true, session: this.session })), sendBuffer: (message) => this.sendBuffer(message) });
109
- }
110
- sendBuffer(buffer) {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- var _a;
113
- if (!this.socket || this.socket.readyState !== ((_a = this.WebSocketClass) === null || _a === void 0 ? void 0 : _a.OPEN)) {
114
- throw Error('WebSocket is not connected.');
115
- }
116
- if (!(buffer instanceof ArrayBuffer) && !ArrayBuffer.isView(buffer)) {
117
- throw Error('Unexpected data type being sent. Expected: ArrayBuffer or ArrayBufferView');
118
- }
119
- else {
120
- this.socket.send(buffer);
121
- }
122
- });
123
- }
124
- onMessage(callback) {
125
- if (!this.socket) {
126
- throw Error('WebSocket is not connected.');
127
- }
128
- this.socket.addEventListener('message', (event) => {
129
- const data = JSON.parse(event.data.toString());
130
- callback(data);
131
- });
132
- }
133
- onClose(callback) {
134
- if (!this.socket) {
135
- throw Error('WebSocket is not connected.');
136
- }
137
- this.socket.addEventListener('close', callback);
138
- }
139
- close() {
140
- if (!this.socket) {
141
- console.error('WebSocket is not connected.');
142
- return;
143
- }
144
- this.socket.close();
145
- }
146
- }
@@ -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
- }
@@ -1,17 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { VocalStackApi } from '../VocalStackApi';
11
- export class Billing extends VocalStackApi {
12
- getBillingDetails() {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- return this._rest().get('/billing/details');
15
- });
16
- }
17
- }
@@ -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,51 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { z } from 'zod';
11
- import { zLanguage } from '../generics.zod';
12
- import { VocalStackApi } from '../VocalStackApi';
13
- const zLiveTranscriptionStartRequest = z.object({
14
- livestream_url: z.string().optional(),
15
- language: zLanguage.optional(),
16
- translations: zLanguage.array().optional(),
17
- polyglot_id: z.string().optional(),
18
- timeout_period_s: z.number().optional(),
19
- max_duration_s: z.number().optional(),
20
- });
21
- export class LiveTranscription extends VocalStackApi {
22
- connect() {
23
- return __awaiter(this, arguments, void 0, function* (request = {}) {
24
- var _a;
25
- const validation = this.withValidation(zLiveTranscriptionStartRequest, request);
26
- if (validation.badResponse) {
27
- throw new Error(validation.badResponse.error);
28
- }
29
- const headers = {};
30
- if (request['livestream_url'] && request['livestream_url'] !== 'undefined') {
31
- headers['livestream-url'] = request.livestream_url;
32
- }
33
- const queryString = this.buildQueryString({
34
- polyglot_id: request.polyglot_id,
35
- language: request.language,
36
- translations: (_a = request.translations) === null || _a === void 0 ? void 0 : _a.join(','),
37
- timeout_period_s: request.timeout_period_s,
38
- max_duration_s: request.max_duration_s,
39
- });
40
- return this._ws().connectDuplex({
41
- path: `/async/live/transcribe?${queryString}`,
42
- headers,
43
- });
44
- });
45
- }
46
- stopTranscribing(_a) {
47
- return __awaiter(this, arguments, void 0, function* ({ id }) {
48
- return this._rest().patch(`/live/transcribe/${id}/stop`);
49
- });
50
- }
51
- }
@@ -1,113 +0,0 @@
1
- import { z } from 'zod';
2
- import { Language, Timeline, Uuid } from '../generics.zod';
3
- import { ApiResponse } from '../RestApi';
4
- import { VocalStackApi } from '../VocalStackApi';
5
- import { WebsocketConnection } from '../WebsocketApi';
6
- import { SummaryTranscriptions } from './Transcriptions';
7
- export declare const zPolyglotSession: z.ZodObject<{
8
- name: z.ZodString;
9
- link: z.ZodString;
10
- password: z.ZodOptional<z.ZodString>;
11
- 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"]>>;
12
- max_duration_s: z.ZodOptional<z.ZodNumber>;
13
- timeout_period_s: z.ZodOptional<z.ZodNumber>;
14
- livestream_url: z.ZodOptional<z.ZodString>;
15
- }, "strip", z.ZodTypeAny, {
16
- link: string;
17
- name: string;
18
- 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;
19
- livestream_url?: string | undefined;
20
- timeout_period_s?: number | undefined;
21
- max_duration_s?: number | undefined;
22
- password?: string | undefined;
23
- }, {
24
- link: string;
25
- name: string;
26
- 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;
27
- livestream_url?: string | undefined;
28
- timeout_period_s?: number | undefined;
29
- max_duration_s?: number | undefined;
30
- password?: string | undefined;
31
- }>;
32
- export type PolyglotSessionRequest = {
33
- id?: string;
34
- password?: string;
35
- name: string;
36
- link: string;
37
- language: Language | null;
38
- max_duration_s: number | null;
39
- timeout_period_s: number | null;
40
- livestream_url: string | null;
41
- };
42
- export type PolyglotSession = {
43
- id: string;
44
- name: string;
45
- link: string;
46
- fullUrl: string;
47
- is_public: boolean;
48
- requests: SummaryTranscriptions;
49
- language: Language | null;
50
- max_duration_s: number | null;
51
- timeout_period_s: number | null;
52
- livestream_url: string | null;
53
- };
54
- export type PolyglotCreatedSession = {
55
- id: string;
56
- link: string;
57
- };
58
- export type PolyglotUpdatedSession = {
59
- id: string;
60
- link: string;
61
- };
62
- export type PolyglotGetSessionResponse = ApiResponse<PolyglotSession>;
63
- export type PolyglotGetAllSessionsResponse = ApiResponse<PolyglotSession[]>;
64
- export type PolyglotDeleteSessionResponse = ApiResponse<null>;
65
- export type PolyglotCreateSessionResponse = ApiResponse<PolyglotCreatedSession>;
66
- export type PolyglotUpdateSessionResponse = ApiResponse<PolyglotUpdatedSession>;
67
- export type PolyglotPresenterRequest = {
68
- link: string;
69
- password?: string;
70
- };
71
- export type PolyglotPresenterResponse = {
72
- status: string;
73
- data: {
74
- session: PolyglotPresenterSession;
75
- activeTranscription: PolyglotPresenterTranscription;
76
- };
77
- http_code?: number;
78
- error?: string;
79
- };
80
- export type PolyglotPresenterConnection = WebsocketConnection<PolyglotPresenterResponse>;
81
- export type PolyglotPresenterSession = {
82
- id: Uuid;
83
- name: string;
84
- link: string;
85
- fullUrl: string;
86
- is_public: boolean;
87
- requests: PolyglotPresenterTranscription[];
88
- };
89
- export type PolyglotPresenterTranscription = {
90
- id: Uuid;
91
- polyglot_id: Uuid | null;
92
- start: string;
93
- end: string | null;
94
- status: 'waiting' | 'processing' | 'done' | 'error';
95
- operation: 'transcription-live';
96
- flags?: {
97
- started: boolean;
98
- } | null;
99
- timeline?: Timeline;
100
- keywords?: string | null;
101
- };
102
- export declare class Polyglot extends VocalStackApi {
103
- getSession({ id }: {
104
- id: string;
105
- }): Promise<PolyglotGetSessionResponse>;
106
- getAllSessions(): Promise<PolyglotGetAllSessionsResponse>;
107
- deleteSession({ id }: {
108
- id: string;
109
- }): Promise<PolyglotDeleteSessionResponse>;
110
- createSession(session: PolyglotSessionRequest): Promise<PolyglotCreateSessionResponse>;
111
- updateSession(session: PolyglotSessionRequest): Promise<PolyglotUpdateSessionResponse>;
112
- getLiveSessionStream({ link, password }: PolyglotPresenterRequest): Promise<PolyglotPresenterConnection>;
113
- }
@@ -1,64 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { z } from 'zod';
11
- import { zLanguage } from '../generics.zod';
12
- import { VocalStackApi } from '../VocalStackApi';
13
- export const zPolyglotSession = z.object({
14
- name: z.string(),
15
- link: z.string(),
16
- password: z.string().optional(),
17
- language: zLanguage.optional(),
18
- max_duration_s: z.number().optional(),
19
- timeout_period_s: z.number().optional(),
20
- livestream_url: z.string().optional(),
21
- });
22
- export class Polyglot extends VocalStackApi {
23
- getSession(_a) {
24
- return __awaiter(this, arguments, void 0, function* ({ id }) {
25
- return this._rest().get(`/polyglot/${id}`);
26
- });
27
- }
28
- getAllSessions() {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- return this._rest().get('/polyglot');
31
- });
32
- }
33
- deleteSession(_a) {
34
- return __awaiter(this, arguments, void 0, function* ({ id }) {
35
- return this._rest().delete(`/polyglot/${id}`);
36
- });
37
- }
38
- createSession(session) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const validation = this.withValidation(zPolyglotSession, session);
41
- return (validation.badResponse ||
42
- this._rest().post('/polyglot', {
43
- json: validation.data,
44
- }));
45
- });
46
- }
47
- updateSession(session) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- const validation = this.withValidation(zPolyglotSession, session);
50
- return (validation.badResponse ||
51
- this._rest().put(`/polyglot/${session.id}`, {
52
- json: validation.data,
53
- }));
54
- });
55
- }
56
- getLiveSessionStream(_a) {
57
- return __awaiter(this, arguments, void 0, function* ({ link, password }) {
58
- return this._ws().connect({
59
- path: `/async/polyglot/${link}`,
60
- headers: { password: !password ? '' : password },
61
- });
62
- });
63
- }
64
- }