vidnavigator 0.1.1 → 0.1.3
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/dist/errors.d.ts +56 -0
- package/dist/errors.js +99 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +54 -8
- package/package.json +1 -1
- package/src/errors.ts +107 -0
- package/src/index.ts +75 -8
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom exception classes for VidNavigator SDK.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Base class for all VidNavigator SDK errors.
|
|
6
|
+
* Contains additional information from the API response when available.
|
|
7
|
+
*/
|
|
8
|
+
export declare class VidNavigatorError extends Error {
|
|
9
|
+
readonly status_code?: number;
|
|
10
|
+
readonly error_code?: string;
|
|
11
|
+
readonly error_message?: string;
|
|
12
|
+
readonly details?: any;
|
|
13
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Raised on HTTP 401 errors (e.g., missing/invalid API key).
|
|
17
|
+
*/
|
|
18
|
+
export declare class AuthenticationError extends VidNavigatorError {
|
|
19
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Raised on HTTP 400 errors (invalid parameters).
|
|
23
|
+
*/
|
|
24
|
+
export declare class BadRequestError extends VidNavigatorError {
|
|
25
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Raised on HTTP 403 errors (insufficient permissions).
|
|
29
|
+
*/
|
|
30
|
+
export declare class AccessDeniedError extends VidNavigatorError {
|
|
31
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Raised when a requested resource is not found (HTTP 404).
|
|
35
|
+
*/
|
|
36
|
+
export declare class NotFoundError extends VidNavigatorError {
|
|
37
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Raised when rate limits are exceeded (HTTP 429).
|
|
41
|
+
*/
|
|
42
|
+
export declare class RateLimitExceededError extends VidNavigatorError {
|
|
43
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Raised when usage limits are exceeded and payment is required (HTTP 402).
|
|
47
|
+
*/
|
|
48
|
+
export declare class PaymentRequiredError extends VidNavigatorError {
|
|
49
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Raised on 5xx server errors.
|
|
53
|
+
*/
|
|
54
|
+
export declare class ServerError extends VidNavigatorError {
|
|
55
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
56
|
+
}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom exception classes for VidNavigator SDK.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ServerError = exports.PaymentRequiredError = exports.RateLimitExceededError = exports.NotFoundError = exports.AccessDeniedError = exports.BadRequestError = exports.AuthenticationError = exports.VidNavigatorError = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Base class for all VidNavigator SDK errors.
|
|
9
|
+
* Contains additional information from the API response when available.
|
|
10
|
+
*/
|
|
11
|
+
class VidNavigatorError extends Error {
|
|
12
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'VidNavigatorError';
|
|
15
|
+
this.status_code = status_code;
|
|
16
|
+
this.error_code = error_code;
|
|
17
|
+
this.error_message = error_message;
|
|
18
|
+
this.details = details;
|
|
19
|
+
Object.setPrototypeOf(this, VidNavigatorError.prototype);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.VidNavigatorError = VidNavigatorError;
|
|
23
|
+
/**
|
|
24
|
+
* Raised on HTTP 401 errors (e.g., missing/invalid API key).
|
|
25
|
+
*/
|
|
26
|
+
class AuthenticationError extends VidNavigatorError {
|
|
27
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
28
|
+
super(message, status_code, error_code, error_message, details);
|
|
29
|
+
this.name = 'AuthenticationError';
|
|
30
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AuthenticationError = AuthenticationError;
|
|
34
|
+
/**
|
|
35
|
+
* Raised on HTTP 400 errors (invalid parameters).
|
|
36
|
+
*/
|
|
37
|
+
class BadRequestError extends VidNavigatorError {
|
|
38
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
39
|
+
super(message, status_code, error_code, error_message, details);
|
|
40
|
+
this.name = 'BadRequestError';
|
|
41
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.BadRequestError = BadRequestError;
|
|
45
|
+
/**
|
|
46
|
+
* Raised on HTTP 403 errors (insufficient permissions).
|
|
47
|
+
*/
|
|
48
|
+
class AccessDeniedError extends VidNavigatorError {
|
|
49
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
50
|
+
super(message, status_code, error_code, error_message, details);
|
|
51
|
+
this.name = 'AccessDeniedError';
|
|
52
|
+
Object.setPrototypeOf(this, AccessDeniedError.prototype);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.AccessDeniedError = AccessDeniedError;
|
|
56
|
+
/**
|
|
57
|
+
* Raised when a requested resource is not found (HTTP 404).
|
|
58
|
+
*/
|
|
59
|
+
class NotFoundError extends VidNavigatorError {
|
|
60
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
61
|
+
super(message, status_code, error_code, error_message, details);
|
|
62
|
+
this.name = 'NotFoundError';
|
|
63
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.NotFoundError = NotFoundError;
|
|
67
|
+
/**
|
|
68
|
+
* Raised when rate limits are exceeded (HTTP 429).
|
|
69
|
+
*/
|
|
70
|
+
class RateLimitExceededError extends VidNavigatorError {
|
|
71
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
72
|
+
super(message, status_code, error_code, error_message, details);
|
|
73
|
+
this.name = 'RateLimitExceededError';
|
|
74
|
+
Object.setPrototypeOf(this, RateLimitExceededError.prototype);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.RateLimitExceededError = RateLimitExceededError;
|
|
78
|
+
/**
|
|
79
|
+
* Raised when usage limits are exceeded and payment is required (HTTP 402).
|
|
80
|
+
*/
|
|
81
|
+
class PaymentRequiredError extends VidNavigatorError {
|
|
82
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
83
|
+
super(message, status_code, error_code, error_message, details);
|
|
84
|
+
this.name = 'PaymentRequiredError';
|
|
85
|
+
Object.setPrototypeOf(this, PaymentRequiredError.prototype);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.PaymentRequiredError = PaymentRequiredError;
|
|
89
|
+
/**
|
|
90
|
+
* Raised on 5xx server errors.
|
|
91
|
+
*/
|
|
92
|
+
class ServerError extends VidNavigatorError {
|
|
93
|
+
constructor(message, status_code, error_code, error_message, details) {
|
|
94
|
+
super(message, status_code, error_code, error_message, details);
|
|
95
|
+
this.name = 'ServerError';
|
|
96
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.ServerError = ServerError;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import { VideoInfo, TranscriptSegment, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult } from './models';
|
|
3
3
|
export * from './models';
|
|
4
|
+
export * from './errors';
|
|
4
5
|
export interface SDKConfig {
|
|
5
6
|
apiKey: string;
|
|
6
7
|
baseURL?: string;
|
|
@@ -42,6 +43,21 @@ export declare class VidNavigatorClient {
|
|
|
42
43
|
file_id: string;
|
|
43
44
|
message: string;
|
|
44
45
|
}>;
|
|
46
|
+
getFileUrl(file_id: string): Promise<{
|
|
47
|
+
file_id: string;
|
|
48
|
+
file_url: string;
|
|
49
|
+
}>;
|
|
50
|
+
retryFileProcessing(file_id: string): Promise<{
|
|
51
|
+
file_id: string;
|
|
52
|
+
file_name: string;
|
|
53
|
+
file_status: string;
|
|
54
|
+
message: string;
|
|
55
|
+
}>;
|
|
56
|
+
cancelFileUpload(file_id: string): Promise<{
|
|
57
|
+
file_id: string;
|
|
58
|
+
file_name: string;
|
|
59
|
+
message: string;
|
|
60
|
+
}>;
|
|
45
61
|
analyzeVideo(payload: {
|
|
46
62
|
video_url: string;
|
|
47
63
|
query?: string;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,9 @@ const axios_1 = __importDefault(require("axios"));
|
|
|
22
22
|
const form_data_1 = __importDefault(require("form-data"));
|
|
23
23
|
const fs_1 = __importDefault(require("fs"));
|
|
24
24
|
const models_1 = require("./models");
|
|
25
|
+
const errors_1 = require("./errors");
|
|
25
26
|
__exportStar(require("./models"), exports);
|
|
27
|
+
__exportStar(require("./errors"), exports);
|
|
26
28
|
//endregion
|
|
27
29
|
class VidNavigatorClient {
|
|
28
30
|
constructor(config) {
|
|
@@ -39,14 +41,46 @@ class VidNavigatorClient {
|
|
|
39
41
|
});
|
|
40
42
|
}
|
|
41
43
|
async request(method, url, data, params, extraHeaders) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
44
|
+
try {
|
|
45
|
+
const response = await this.client.request({
|
|
46
|
+
method,
|
|
47
|
+
url,
|
|
48
|
+
data,
|
|
49
|
+
params,
|
|
50
|
+
headers: extraHeaders,
|
|
51
|
+
});
|
|
52
|
+
return response.data;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
56
|
+
const { status, data } = error.response;
|
|
57
|
+
const errorCode = data?.error?.code;
|
|
58
|
+
const errorMessage = data?.error?.message;
|
|
59
|
+
const errorDetails = data?.error?.details;
|
|
60
|
+
const message = `API request failed with status ${status}: ${errorMessage || error.message}`;
|
|
61
|
+
switch (status) {
|
|
62
|
+
case 400:
|
|
63
|
+
throw new errors_1.BadRequestError(message, status, errorCode, errorMessage, errorDetails);
|
|
64
|
+
case 401:
|
|
65
|
+
throw new errors_1.AuthenticationError(message, status, errorCode, errorMessage, errorDetails);
|
|
66
|
+
case 403:
|
|
67
|
+
throw new errors_1.AccessDeniedError(message, status, errorCode, errorMessage, errorDetails);
|
|
68
|
+
case 404:
|
|
69
|
+
throw new errors_1.NotFoundError(message, status, errorCode, errorMessage, errorDetails);
|
|
70
|
+
case 429:
|
|
71
|
+
throw new errors_1.RateLimitExceededError(message, status, errorCode, errorMessage, errorDetails);
|
|
72
|
+
case 402:
|
|
73
|
+
throw new errors_1.PaymentRequiredError(message, status, errorCode, errorMessage, errorDetails);
|
|
74
|
+
default:
|
|
75
|
+
if (status >= 500) {
|
|
76
|
+
throw new errors_1.ServerError(message, status, errorCode, errorMessage, errorDetails);
|
|
77
|
+
}
|
|
78
|
+
throw new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, errorDetails);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Re-throw other errors (e.g., network errors)
|
|
82
|
+
throw new errors_1.VidNavigatorError(error.message);
|
|
83
|
+
}
|
|
50
84
|
}
|
|
51
85
|
//region --- Transcripts ---
|
|
52
86
|
async getTranscript(payload) {
|
|
@@ -90,6 +124,18 @@ class VidNavigatorClient {
|
|
|
90
124
|
const response = await this.request('DELETE', `/file/${file_id}/delete`);
|
|
91
125
|
return response.data;
|
|
92
126
|
}
|
|
127
|
+
async getFileUrl(file_id) {
|
|
128
|
+
const response = await this.request('GET', `/file/${file_id}/url`);
|
|
129
|
+
return response.data;
|
|
130
|
+
}
|
|
131
|
+
async retryFileProcessing(file_id) {
|
|
132
|
+
const response = await this.request('POST', `/file/${file_id}/retry`);
|
|
133
|
+
return response.data;
|
|
134
|
+
}
|
|
135
|
+
async cancelFileUpload(file_id) {
|
|
136
|
+
const response = await this.request('POST', `/file/${file_id}/cancel`);
|
|
137
|
+
return response.data;
|
|
138
|
+
}
|
|
93
139
|
//endregion
|
|
94
140
|
//region --- Analysis ---
|
|
95
141
|
async analyzeVideo(payload) {
|
package/package.json
CHANGED
package/src/errors.ts
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom exception classes for VidNavigator SDK.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Base class for all VidNavigator SDK errors.
|
|
7
|
+
* Contains additional information from the API response when available.
|
|
8
|
+
*/
|
|
9
|
+
export class VidNavigatorError extends Error {
|
|
10
|
+
public readonly status_code?: number;
|
|
11
|
+
public readonly error_code?: string;
|
|
12
|
+
public readonly error_message?: string;
|
|
13
|
+
public readonly details?: any;
|
|
14
|
+
|
|
15
|
+
constructor(
|
|
16
|
+
message: string,
|
|
17
|
+
status_code?: number,
|
|
18
|
+
error_code?: string,
|
|
19
|
+
error_message?: string,
|
|
20
|
+
details?: any
|
|
21
|
+
) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'VidNavigatorError';
|
|
24
|
+
this.status_code = status_code;
|
|
25
|
+
this.error_code = error_code;
|
|
26
|
+
this.error_message = error_message;
|
|
27
|
+
this.details = details;
|
|
28
|
+
Object.setPrototypeOf(this, VidNavigatorError.prototype);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Raised on HTTP 401 errors (e.g., missing/invalid API key).
|
|
34
|
+
*/
|
|
35
|
+
export class AuthenticationError extends VidNavigatorError {
|
|
36
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
37
|
+
super(message, status_code, error_code, error_message, details);
|
|
38
|
+
this.name = 'AuthenticationError';
|
|
39
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Raised on HTTP 400 errors (invalid parameters).
|
|
45
|
+
*/
|
|
46
|
+
export class BadRequestError extends VidNavigatorError {
|
|
47
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
48
|
+
super(message, status_code, error_code, error_message, details);
|
|
49
|
+
this.name = 'BadRequestError';
|
|
50
|
+
Object.setPrototypeOf(this, BadRequestError.prototype);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Raised on HTTP 403 errors (insufficient permissions).
|
|
56
|
+
*/
|
|
57
|
+
export class AccessDeniedError extends VidNavigatorError {
|
|
58
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
59
|
+
super(message, status_code, error_code, error_message, details);
|
|
60
|
+
this.name = 'AccessDeniedError';
|
|
61
|
+
Object.setPrototypeOf(this, AccessDeniedError.prototype);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Raised when a requested resource is not found (HTTP 404).
|
|
67
|
+
*/
|
|
68
|
+
export class NotFoundError extends VidNavigatorError {
|
|
69
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
70
|
+
super(message, status_code, error_code, error_message, details);
|
|
71
|
+
this.name = 'NotFoundError';
|
|
72
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Raised when rate limits are exceeded (HTTP 429).
|
|
78
|
+
*/
|
|
79
|
+
export class RateLimitExceededError extends VidNavigatorError {
|
|
80
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
81
|
+
super(message, status_code, error_code, error_message, details);
|
|
82
|
+
this.name = 'RateLimitExceededError';
|
|
83
|
+
Object.setPrototypeOf(this, RateLimitExceededError.prototype);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Raised when usage limits are exceeded and payment is required (HTTP 402).
|
|
89
|
+
*/
|
|
90
|
+
export class PaymentRequiredError extends VidNavigatorError {
|
|
91
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
92
|
+
super(message, status_code, error_code, error_message, details);
|
|
93
|
+
this.name = 'PaymentRequiredError';
|
|
94
|
+
Object.setPrototypeOf(this, PaymentRequiredError.prototype);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Raised on 5xx server errors.
|
|
100
|
+
*/
|
|
101
|
+
export class ServerError extends VidNavigatorError {
|
|
102
|
+
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
103
|
+
super(message, status_code, error_code, error_message, details);
|
|
104
|
+
this.name = 'ServerError';
|
|
105
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
106
|
+
}
|
|
107
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -15,8 +15,19 @@ import {
|
|
|
15
15
|
FileSearchResult,
|
|
16
16
|
FileSearchResultJSON,
|
|
17
17
|
} from './models';
|
|
18
|
+
import {
|
|
19
|
+
VidNavigatorError,
|
|
20
|
+
AuthenticationError,
|
|
21
|
+
BadRequestError,
|
|
22
|
+
AccessDeniedError,
|
|
23
|
+
NotFoundError,
|
|
24
|
+
RateLimitExceededError,
|
|
25
|
+
PaymentRequiredError,
|
|
26
|
+
ServerError,
|
|
27
|
+
} from './errors';
|
|
18
28
|
|
|
19
29
|
export * from './models';
|
|
30
|
+
export * from './errors';
|
|
20
31
|
|
|
21
32
|
//region --- Interfaces ---
|
|
22
33
|
export interface SDKConfig {
|
|
@@ -50,14 +61,46 @@ export class VidNavigatorClient {
|
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
private async request<T>(method: 'GET' | 'POST' | 'DELETE' | 'PUT', url: string, data?: any, params?: any, extraHeaders?: any): Promise<T> {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
try {
|
|
65
|
+
const response = await this.client.request<T>({
|
|
66
|
+
method,
|
|
67
|
+
url,
|
|
68
|
+
data,
|
|
69
|
+
params,
|
|
70
|
+
headers: extraHeaders,
|
|
71
|
+
});
|
|
72
|
+
return response.data;
|
|
73
|
+
} catch (error: any) {
|
|
74
|
+
if (axios.isAxiosError(error) && error.response) {
|
|
75
|
+
const { status, data } = error.response;
|
|
76
|
+
const errorCode = data?.error?.code;
|
|
77
|
+
const errorMessage = data?.error?.message;
|
|
78
|
+
const errorDetails = data?.error?.details;
|
|
79
|
+
const message = `API request failed with status ${status}: ${errorMessage || error.message}`;
|
|
80
|
+
|
|
81
|
+
switch (status) {
|
|
82
|
+
case 400:
|
|
83
|
+
throw new BadRequestError(message, status, errorCode, errorMessage, errorDetails);
|
|
84
|
+
case 401:
|
|
85
|
+
throw new AuthenticationError(message, status, errorCode, errorMessage, errorDetails);
|
|
86
|
+
case 403:
|
|
87
|
+
throw new AccessDeniedError(message, status, errorCode, errorMessage, errorDetails);
|
|
88
|
+
case 404:
|
|
89
|
+
throw new NotFoundError(message, status, errorCode, errorMessage, errorDetails);
|
|
90
|
+
case 429:
|
|
91
|
+
throw new RateLimitExceededError(message, status, errorCode, errorMessage, errorDetails);
|
|
92
|
+
case 402:
|
|
93
|
+
throw new PaymentRequiredError(message, status, errorCode, errorMessage, errorDetails);
|
|
94
|
+
default:
|
|
95
|
+
if (status >= 500) {
|
|
96
|
+
throw new ServerError(message, status, errorCode, errorMessage, errorDetails);
|
|
97
|
+
}
|
|
98
|
+
throw new VidNavigatorError(message, status, errorCode, errorMessage, errorDetails);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Re-throw other errors (e.g., network errors)
|
|
102
|
+
throw new VidNavigatorError(error.message);
|
|
103
|
+
}
|
|
61
104
|
}
|
|
62
105
|
|
|
63
106
|
//region --- Transcripts ---
|
|
@@ -139,6 +182,30 @@ export class VidNavigatorClient {
|
|
|
139
182
|
);
|
|
140
183
|
return response.data;
|
|
141
184
|
}
|
|
185
|
+
|
|
186
|
+
async getFileUrl(file_id: string): Promise<{ file_id: string; file_url: string }> {
|
|
187
|
+
const response = await this.request<ApiSuccessResponse<{ file_id: string; file_url: string }>>(
|
|
188
|
+
'GET',
|
|
189
|
+
`/file/${file_id}/url`
|
|
190
|
+
);
|
|
191
|
+
return response.data;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async retryFileProcessing(file_id: string): Promise<{ file_id: string; file_name: string; file_status: string; message: string }> {
|
|
195
|
+
const response = await this.request<ApiSuccessResponse<{ file_id: string; file_name: string; file_status: string; message: string }>>(
|
|
196
|
+
'POST',
|
|
197
|
+
`/file/${file_id}/retry`
|
|
198
|
+
);
|
|
199
|
+
return response.data;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async cancelFileUpload(file_id: string): Promise<{ file_id: string; file_name: string; message: string }> {
|
|
203
|
+
const response = await this.request<ApiSuccessResponse<{ file_id: string; file_name: string; message: string }>>(
|
|
204
|
+
'POST',
|
|
205
|
+
`/file/${file_id}/cancel`
|
|
206
|
+
);
|
|
207
|
+
return response.data;
|
|
208
|
+
}
|
|
142
209
|
//endregion
|
|
143
210
|
|
|
144
211
|
//region --- Analysis ---
|