@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.
Files changed (73) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +112 -69
  3. package/SKILL.md +252 -0
  4. package/dist/errors.d.ts +40 -0
  5. package/dist/errors.js +74 -0
  6. package/dist/file.d.ts +2 -0
  7. package/dist/file.js +38 -0
  8. package/dist/http.d.ts +75 -0
  9. package/dist/http.js +122 -0
  10. package/dist/index.d.ts +56 -2
  11. package/dist/index.js +65 -17
  12. package/dist/mic.d.ts +75 -0
  13. package/dist/mic.js +258 -0
  14. package/dist/realtime.d.ts +132 -0
  15. package/dist/realtime.js +450 -0
  16. package/dist/resources.d.ts +521 -0
  17. package/dist/resources.js +787 -0
  18. package/dist/subscription.d.ts +55 -0
  19. package/dist/subscription.js +164 -0
  20. package/dist/ws.d.ts +12 -0
  21. package/dist/ws.js +15 -0
  22. package/package.json +32 -36
  23. package/skills/vocalstack/SKILL.md +252 -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,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,68 +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.Polyglot = exports.zPolyglotSession = void 0;
13
- const zod_1 = require("zod");
14
- const generics_zod_1 = require("../generics.zod");
15
- const VocalStackApi_1 = require("../VocalStackApi");
16
- exports.zPolyglotSession = zod_1.z.object({
17
- name: zod_1.z.string(),
18
- link: zod_1.z.string(),
19
- password: zod_1.z.string().optional(),
20
- language: generics_zod_1.zLanguage.optional(),
21
- max_duration_s: zod_1.z.number().optional(),
22
- timeout_period_s: zod_1.z.number().optional(),
23
- livestream_url: zod_1.z.string().optional(),
24
- });
25
- class Polyglot extends VocalStackApi_1.VocalStackApi {
26
- getSession(_a) {
27
- return __awaiter(this, arguments, void 0, function* ({ id }) {
28
- return this._rest().get(`/polyglot/${id}`);
29
- });
30
- }
31
- getAllSessions() {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return this._rest().get('/polyglot');
34
- });
35
- }
36
- deleteSession(_a) {
37
- return __awaiter(this, arguments, void 0, function* ({ id }) {
38
- return this._rest().delete(`/polyglot/${id}`);
39
- });
40
- }
41
- createSession(session) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const validation = this.withValidation(exports.zPolyglotSession, session);
44
- return (validation.badResponse ||
45
- this._rest().post('/polyglot', {
46
- json: validation.data,
47
- }));
48
- });
49
- }
50
- updateSession(session) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const validation = this.withValidation(exports.zPolyglotSession, session);
53
- return (validation.badResponse ||
54
- this._rest().put(`/polyglot/${session.id}`, {
55
- json: validation.data,
56
- }));
57
- });
58
- }
59
- getLiveSessionStream(_a) {
60
- return __awaiter(this, arguments, void 0, function* ({ link, password }) {
61
- return this._ws().connect({
62
- path: `/async/polyglot/${link}`,
63
- headers: { password: !password ? '' : password },
64
- });
65
- });
66
- }
67
- }
68
- exports.Polyglot = Polyglot;
@@ -1,25 +0,0 @@
1
- import { z } from 'zod';
2
- import { VocalStackApi } from '../VocalStackApi';
3
- import { ApiResponse } from '../RestApi';
4
- declare const zGenerateTokenRequest: z.ZodObject<{
5
- access: z.ZodOptional<z.ZodUnion<[z.ZodLiteral<"readonly">, z.ZodLiteral<"readwrite">]>>;
6
- lifetime_s: z.ZodOptional<z.ZodNumber>;
7
- one_time: z.ZodOptional<z.ZodBoolean>;
8
- }, "strip", z.ZodTypeAny, {
9
- access?: "readonly" | "readwrite" | undefined;
10
- lifetime_s?: number | undefined;
11
- one_time?: boolean | undefined;
12
- }, {
13
- access?: "readonly" | "readwrite" | undefined;
14
- lifetime_s?: number | undefined;
15
- one_time?: boolean | undefined;
16
- }>;
17
- type GenerateTokenRequest = z.infer<typeof zGenerateTokenRequest>;
18
- export type GenerateTokenResponse = {
19
- status: 'done' | 'error';
20
- data: string;
21
- };
22
- export declare class Security extends VocalStackApi {
23
- generateToken(request?: GenerateTokenRequest): Promise<ApiResponse<GenerateTokenResponse>>;
24
- }
25
- export {};
@@ -1,35 +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.Security = void 0;
13
- const zod_1 = require("zod");
14
- const VocalStackApi_1 = require("../VocalStackApi");
15
- const zGenerateTokenRequest = zod_1.z.object({
16
- access: zod_1.z.union([zod_1.z.literal('readonly'), zod_1.z.literal('readwrite')]).optional(),
17
- lifetime_s: zod_1.z.optional(zod_1.z.number().gt(0).lte(120)),
18
- one_time: zod_1.z.optional(zod_1.z.boolean()),
19
- });
20
- class Security extends VocalStackApi_1.VocalStackApi {
21
- generateToken(request) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- if (typeof window !== 'undefined') {
24
- return Promise.resolve({
25
- success: false,
26
- error: 'Cannot generate token in a browser window. Please use a server environment.',
27
- status: 'error',
28
- data: null,
29
- });
30
- }
31
- return this._rest().get(`/security/generate-token?${this.buildQueryString(request || {})}`);
32
- });
33
- }
34
- }
35
- exports.Security = Security;
@@ -1,60 +0,0 @@
1
- import { Language, Timeline, Uuid } from '../generics.zod';
2
- import { VocalStackApi } from '../VocalStackApi';
3
- import { ApiResponse } from '../RestApi';
4
- import { WebsocketConnection } from '../WebsocketApi';
5
- export type { Timeline };
6
- export type Operation = 'transcription-prerecorded' | 'transcription-live';
7
- export type Status = 'waiting' | 'processing' | 'done' | 'stopping' | 'error';
8
- export type FinishedTranscription = {
9
- id: Uuid;
10
- status: Status;
11
- operation: Operation;
12
- start: string;
13
- end?: string;
14
- keywords?: string | null;
15
- timeline: Timeline;
16
- paragraphs?: string[] | null;
17
- summary?: string | null;
18
- url?: string;
19
- duration: number;
20
- };
21
- export type SummaryTranscription = {
22
- id: string;
23
- operation: Operation;
24
- status: Status;
25
- duration?: number;
26
- start: string;
27
- end: string | null;
28
- polyglot_id: string;
29
- url?: string;
30
- keywords: string | null;
31
- };
32
- export type SummaryTranscriptions = SummaryTranscription[];
33
- export type FinishedTranscriptionRequest = {
34
- id: string;
35
- };
36
- export type FinishedTranscriptionResponse = ApiResponse<FinishedTranscription>;
37
- export type AllTranscriptionsResponse = ApiResponse<SummaryTranscriptions>;
38
- export type AddTranscriptionTranslationRequest = {
39
- id: string;
40
- languages: Language[];
41
- };
42
- export type AddTranslationResponse = ApiResponse<{
43
- timeline: Timeline;
44
- }>;
45
- export type RemoveTranscriptionTranslationRequest = {
46
- id: string;
47
- language: Language;
48
- };
49
- export type RemoveTranslationResponse = ApiResponse<null>;
50
- export type AddTranscriptionTranslationAsyncResponse = {
51
- status: Status;
52
- data: FinishedTranscription | null;
53
- };
54
- export type AddTranscriptionTranslationConnection = WebsocketConnection<AddTranscriptionTranslationAsyncResponse>;
55
- export declare class Transcriptions extends VocalStackApi {
56
- getTranscription({ id }: FinishedTranscriptionRequest): Promise<FinishedTranscriptionResponse>;
57
- getAllTranscriptions(): Promise<AllTranscriptionsResponse>;
58
- addTranslations({ id, languages }: AddTranscriptionTranslationRequest): Promise<AddTranslationResponse>;
59
- addTranslationAsync({ id, languages, }: AddTranscriptionTranslationRequest): Promise<AddTranscriptionTranslationConnection>;
60
- }
@@ -1,38 +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.Transcriptions = void 0;
13
- const VocalStackApi_1 = require("../VocalStackApi");
14
- class Transcriptions extends VocalStackApi_1.VocalStackApi {
15
- getTranscription(_a) {
16
- return __awaiter(this, arguments, void 0, function* ({ id }) {
17
- return this._rest().get(`/transcriptions/${id}`);
18
- });
19
- }
20
- getAllTranscriptions() {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- return this._rest().get('/transcriptions');
23
- });
24
- }
25
- addTranslations(_a) {
26
- return __awaiter(this, arguments, void 0, function* ({ id, languages }) {
27
- return this._rest().post(`/transcription/${id}/translate?${this.buildQueryString({ languages })}`);
28
- });
29
- }
30
- addTranslationAsync(_a) {
31
- return __awaiter(this, arguments, void 0, function* ({ id, languages, }) {
32
- return this._ws().connect({
33
- path: `/async/transcription/${id}/translate?${this.buildQueryString({ languages })}`,
34
- });
35
- });
36
- }
37
- }
38
- exports.Transcriptions = Transcriptions;
@@ -1,59 +0,0 @@
1
- import { z } from 'zod';
2
- import { Timeline, Uuid } from '../generics.zod';
3
- import { VocalStackApi } from '../VocalStackApi';
4
- import { WebsocketConnection } from '../WebsocketApi';
5
- import { ApiResponse } from '../RestApi';
6
- import { Status } from './Transcriptions';
7
- declare const zUrlTranscriptionStartRequest: z.ZodObject<{
8
- url: z.ZodString;
9
- duration_s: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
10
- max_duration_s: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
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
- }, "strip", z.ZodTypeAny, {
13
- url: string;
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
- max_duration_s?: number | undefined;
16
- duration_s?: number | undefined;
17
- }, {
18
- url: string;
19
- 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;
20
- max_duration_s?: number | undefined;
21
- duration_s?: number | undefined;
22
- }>;
23
- export type UrlTranscriptionStartRequest = z.infer<typeof zUrlTranscriptionStartRequest>;
24
- export type UrlTranscriptionStreamData = ArrayBufferLike;
25
- export type UrlTranscriptionResponse = {
26
- status: Status;
27
- data: UrlTranscriptionResponseData | null;
28
- http_code?: number;
29
- };
30
- export type UrlTranscriptionResponseData = {
31
- id: Uuid;
32
- status: Status;
33
- operation: 'transcription-prerecorded';
34
- start: string;
35
- end: string | null;
36
- flags?: {
37
- started: boolean;
38
- } | null;
39
- keywords?: string | null;
40
- timeline?: Timeline;
41
- paragraphs?: string[] | null;
42
- summary?: string | null;
43
- progress: number;
44
- };
45
- export type UrlTranscriptionStopRequest = {
46
- id: string;
47
- };
48
- export type UrlTranscriptionConnection = WebsocketConnection<UrlTranscriptionResponse>;
49
- export type UrlTranscriptionRestResponse = ApiResponse<{
50
- id: Uuid;
51
- status: 'processing' | 'error';
52
- http_code?: number;
53
- }>;
54
- export declare class UrlTranscription extends VocalStackApi {
55
- connect(request: UrlTranscriptionStartRequest): Promise<UrlTranscriptionConnection>;
56
- transcribe(request: UrlTranscriptionStartRequest): Promise<UrlTranscriptionRestResponse>;
57
- private getQuery;
58
- }
59
- export {};
@@ -1,53 +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.UrlTranscription = void 0;
13
- const zod_1 = require("zod");
14
- const generics_zod_1 = require("../generics.zod");
15
- const VocalStackApi_1 = require("../VocalStackApi");
16
- const zUrlTranscriptionStartRequest = zod_1.z.object({
17
- url: zod_1.z.string(),
18
- duration_s: generics_zod_1.zDuration.optional(),
19
- max_duration_s: generics_zod_1.zDuration.optional(),
20
- language: generics_zod_1.zLanguage.optional(),
21
- });
22
- class UrlTranscription extends VocalStackApi_1.VocalStackApi {
23
- connect(request) {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- const queryString = this.getQuery(request);
26
- return this._ws().connect({
27
- path: `/async/transcribe/url?${queryString}`,
28
- mustStart: true,
29
- headers: {},
30
- });
31
- });
32
- }
33
- transcribe(request) {
34
- return __awaiter(this, void 0, void 0, function* () {
35
- const queryString = this.getQuery(request);
36
- return this._rest().post(`/async/transcribe/url?${queryString}`);
37
- });
38
- }
39
- getQuery(request) {
40
- const validation = this.withValidation(zUrlTranscriptionStartRequest, request);
41
- if (validation.badResponse) {
42
- throw new Error(validation.badResponse.error);
43
- }
44
- const queryString = this.buildQueryString({
45
- language: request.language || 'auto',
46
- url: encodeURIComponent(request.url),
47
- duration_s: request.duration_s,
48
- max_duration_s: request.max_duration_s,
49
- });
50
- return queryString;
51
- }
52
- }
53
- exports.UrlTranscription = UrlTranscription;
@@ -1,6 +0,0 @@
1
- export * from './Transcriptions';
2
- export * from './LiveTranscription';
3
- export * from './UrlTranscription';
4
- export * from './Polyglot';
5
- export * from './Security';
6
- export * from './Billing';
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Transcriptions"), exports);
18
- __exportStar(require("./LiveTranscription"), exports);
19
- __exportStar(require("./UrlTranscription"), exports);
20
- __exportStar(require("./Polyglot"), exports);
21
- __exportStar(require("./Security"), exports);
22
- __exportStar(require("./Billing"), exports);
@@ -1,2 +0,0 @@
1
- export declare const EXPECTED_VOCALSTACK_API_VERSION = "1.1.0";
2
- export declare const verifyApiVersion: (actualVersion: string | null, discontinued?: boolean) => void;
@@ -1,28 +0,0 @@
1
- export const EXPECTED_VOCALSTACK_API_VERSION = '1.1.0';
2
- export const verifyApiVersion = (actualVersion, discontinued = false) => {
3
- if (!actualVersion) {
4
- throw new Error('VocalStack API version is missing.');
5
- }
6
- if (discontinued) {
7
- throw Error(`The VocalStack API has undergone a new release (v.${actualVersion}) and no longer supports this SDK. Please update the SDK to the latest version by running 'npm update @vocalstack/js-sdk'.`);
8
- }
9
- const [major, minor, patch] = parseVersion(actualVersion);
10
- const [expectedMajor, expectedMinor, expectedPatch] = EXPECTED_VOCALSTACK_API_VERSION.split('.').map((v) => parseInt(v, 10));
11
- if (major < expectedMajor ||
12
- (major === expectedMajor && minor < expectedMinor) ||
13
- (major === expectedMajor && minor === expectedMinor && patch < expectedPatch)) {
14
- throw new Error(`VocalStack API version ${actualVersion} is lower than that expected by this SDK. Expected version >= ${EXPECTED_VOCALSTACK_API_VERSION}`);
15
- }
16
- if (major > expectedMajor || (major === expectedMajor && minor > expectedMinor)) {
17
- const type = major > expectedMajor ? 'major' : 'minor';
18
- console[type === 'major' ? 'error' : 'warn'](`The VocalStack API has undergone a new ${type} release (v.${actualVersion}). Your SDK version may not support all new API features. Consider updating by running 'npm update @vocalstack/js-sdk'.`);
19
- }
20
- };
21
- function parseVersion(version) {
22
- const regex = /^\d+\.\d+\.\d+$/;
23
- if (!regex.test(version)) {
24
- throw new Error(`Invalid version format: ${version}. Expected format "major.minor.patch" with numeric segments.`);
25
- }
26
- const segments = version.split('.').map((v) => parseInt(v, 10));
27
- return [segments[0], segments[1], segments[2]];
28
- }
@@ -1,21 +0,0 @@
1
- export type ApiResponse<T> = {
2
- status: 'waiting' | 'processing' | 'done' | 'error';
3
- data?: null | T;
4
- success: boolean;
5
- error?: string;
6
- };
7
- export type RequestOptions = RequestInit & {
8
- json?: Record<string, unknown>;
9
- };
10
- export declare class RestApi {
11
- private apiServer;
12
- private headers;
13
- constructor(apiServer: string, headers: Record<string, string>);
14
- get<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
15
- post<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
16
- put<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
17
- patch<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
18
- delete<T>(path: string, options?: RequestOptions): Promise<ApiResponse<T>>;
19
- private apiCall;
20
- private respond;
21
- }
@@ -1,91 +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
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { verifyApiVersion, EXPECTED_VOCALSTACK_API_VERSION } from './ApiVersion';
22
- export class RestApi {
23
- constructor(apiServer, headers) {
24
- this.apiServer = apiServer;
25
- this.headers = headers;
26
- }
27
- get(path, options) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return this.apiCall('GET', path, options);
30
- });
31
- }
32
- post(path, options) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- return this.apiCall('POST', path, options);
35
- });
36
- }
37
- put(path, options) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- return this.apiCall('PUT', path, options);
40
- });
41
- }
42
- patch(path, options) {
43
- return __awaiter(this, void 0, void 0, function* () {
44
- return this.apiCall('PATCH', path, options);
45
- });
46
- }
47
- delete(path, options) {
48
- return __awaiter(this, void 0, void 0, function* () {
49
- return this.apiCall('DELETE', path, options);
50
- });
51
- }
52
- apiCall(method, path, options) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- try {
55
- const fixedPath = path.startsWith('/') ? path.slice(1) : path;
56
- const _a = options || {}, { json } = _a, fetchOptions = __rest(_a, ["json"]);
57
- const body = json ? JSON.stringify(json) : undefined;
58
- const headers = Object.assign(Object.assign({}, this.headers), { 'X-Expected-API-Version': EXPECTED_VOCALSTACK_API_VERSION });
59
- if (body) {
60
- headers['Content-Type'] = 'application/json';
61
- }
62
- const response = yield fetch(`${this.apiServer}/${fixedPath}`, Object.assign({ method,
63
- headers,
64
- body }, fetchOptions));
65
- verifyApiVersion(response.headers.get('X-API-Version'), response.headers.get('X-API-Version-Discontinued') === '1');
66
- return this.respond(response);
67
- }
68
- catch (e) {
69
- console.log(e);
70
- return {
71
- success: false,
72
- error: String(e),
73
- status: 'error',
74
- data: undefined,
75
- };
76
- }
77
- });
78
- }
79
- respond(response) {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- const success = response.ok;
82
- const json = success ? yield response.json() : undefined;
83
- const data = Object.assign({ success, error: !success ? response.statusText : undefined }, json);
84
- if ((data === null || data === void 0 ? void 0 : data.status) === 'error') {
85
- data.error = 'An error occurred while processing the request.';
86
- data.success = false;
87
- }
88
- return data;
89
- });
90
- }
91
- }