vidnavigator 3.0.2 → 3.1.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/README.md +9 -4
- package/dist/errors.d.ts +6 -5
- package/dist/errors.js +6 -5
- package/dist/http.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/errors.ts +6 -5
- package/src/http.ts +4 -1
- package/src/index.ts +1 -1
package/README.md
CHANGED
|
@@ -310,7 +310,7 @@ try {
|
|
|
310
310
|
**When a job fails**, `result()` and the one-liners throw an error built from the job's `error` details (`error`, `message`, `http_status`), using the same error class as any other API error, for example `NotFoundError` for a missing video. The error also carries the `task_id`. `wait()` returns the failed task instead, with `task.error` set.
|
|
311
311
|
|
|
312
312
|
**When a job can't start**, submitting throws right away and no job is created:
|
|
313
|
-
- `InsufficientCreditsError` (402): not enough credits (for transcription, less than 60 seconds left). A job can also be accepted and then run out of credits while it runs; `result()` then throws the same `InsufficientCreditsError`, so handle it in both places.
|
|
313
|
+
- `InsufficientCreditsError` (402, `insufficient_credits`): not enough credits (for transcription, less than 60 seconds left). A job can also be accepted and then run out of credits while it runs; `result()` then throws the same `InsufficientCreditsError`, so handle it in both places.
|
|
314
314
|
- `TooManyActiveJobsError` (429): too many of your jobs are already running. Wait for some to finish and retry.
|
|
315
315
|
|
|
316
316
|
**Large batches.** Your account can only have a limited number of jobs running at once, so `Promise.all` over hundreds of URLs will hit `TooManyActiveJobsError`. Keep a fixed number in flight and retry when the limit is reached:
|
|
@@ -1107,13 +1107,13 @@ try {
|
|
|
1107
1107
|
|-------------|:----:|------|
|
|
1108
1108
|
| `BadRequestError` | 400 | Invalid parameters |
|
|
1109
1109
|
| `AuthenticationError` | 401 | Invalid or missing API key |
|
|
1110
|
-
| `PaymentRequiredError` | 402 |
|
|
1111
|
-
| `InsufficientCreditsError` | 402 |
|
|
1110
|
+
| `PaymentRequiredError` | 402 | Any 402. Its two subclasses, `InsufficientCreditsError` and `StorageQuotaExceededError`, say which one |
|
|
1111
|
+
| `InsufficientCreditsError` | 402 | Not enough credits (`insufficient_credits`), at job submit or while a job runs. Extends `PaymentRequiredError` |
|
|
1112
1112
|
| `AccessDeniedError` | 403 | Insufficient permissions |
|
|
1113
1113
|
| `NotFoundError` | 404 | Resource does not exist, or a job's `task_id` is unknown or expired (`task_not_found`) |
|
|
1114
1114
|
| `ScenesNotAvailableError` | 409 | `include_scenes` was asked on an uploaded file that has no scenes to read (`scenes_not_available`). Has `scenes_status` (`'none'`, `'processing'` or `'failed'`) and, when failed, `scenes_error` |
|
|
1115
1115
|
| `StorageQuotaExceededError` | 402 | The storage of the plan is full (`storage_quota_exceeded`, on upload). A `PaymentRequiredError`, from 3.0.2 |
|
|
1116
|
-
| `RateLimitExceededError` | 429 | Too many requests |
|
|
1116
|
+
| `RateLimitExceededError` | 429 | Too many requests (`rate_limit_exceeded`); wait `Retry-After` seconds |
|
|
1117
1117
|
| `TooManyActiveJobsError` | 429 | A job could not start: too many of your jobs are already running (`too_many_active_jobs`). Extends `RateLimitExceededError` |
|
|
1118
1118
|
| `GeoRestrictedError` | 451 | Content unavailable in your region |
|
|
1119
1119
|
| `ServerError` | 5xx | Unexpected server error |
|
|
@@ -1158,6 +1158,11 @@ All API responses are parsed into typed classes with static `fromJSON()` constru
|
|
|
1158
1158
|
| `TikTokLiveRoomDetail` | A `TikTokLiveRoom` from `getTikTokLiveRoom`: `status` / `isLive`, `ended_at`, `stats.new_followers`, `author.bio`, `share_url`, `chat_enabled`, `subscribers_only`, `products` |
|
|
1159
1159
|
| `TweetStatement` | Structured X/Twitter claim analysis, topics, entities, tone, intent, and source text; with `include_scenes`, `frames_analyzed` and `scenes_error` |
|
|
1160
1160
|
|
|
1161
|
+
## What's new in 3.1.0
|
|
1162
|
+
|
|
1163
|
+
- **The API's code for "not enough credits" is now `insufficient_credits`** (it was `limit_exceeded`). Both codes throw `InsufficientCreditsError`, a `PaymentRequiredError`; `error_code` carries the code the API sent.
|
|
1164
|
+
- **The same error classes as the Python SDK** (3.1.0): `PaymentRequiredError`, `InsufficientCreditsError`, `StorageQuotaExceededError`, `RateLimitExceededError`, `TooManyActiveJobsError`, `TaskTimeoutError`.
|
|
1165
|
+
|
|
1161
1166
|
## What's new in 3.0.2
|
|
1162
1167
|
|
|
1163
1168
|
- **`getUsage()` keeps every counter:** `usage.frameAnalysis` and `usage.sceneAnalysisHour` were dropped; they are now there with the other counters. The legacy `videoTranscripts`, `youtubeTranscripts`, `videoSearches`, `videoAnalyses`, `videoSceneAnalyses` and `videoUploads` counters, which the API no longer sends, are marked deprecated.
|
package/dist/errors.d.ts
CHANGED
|
@@ -44,13 +44,14 @@ export declare class NotFoundError extends VidNavigatorError {
|
|
|
44
44
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* Raised
|
|
47
|
+
* Raised on HTTP 429: too many requests (`rate_limit_exceeded`). Wait `Retry-After` seconds.
|
|
48
48
|
*/
|
|
49
49
|
export declare class RateLimitExceededError extends VidNavigatorError {
|
|
50
50
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Raised
|
|
53
|
+
* Raised on HTTP 402. Catch it for any 402, or one of its subclasses to know which:
|
|
54
|
+
* `InsufficientCreditsError` (not enough credits) or `StorageQuotaExceededError` (the storage of the plan is full).
|
|
54
55
|
*/
|
|
55
56
|
export declare class PaymentRequiredError extends VidNavigatorError {
|
|
56
57
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
|
@@ -83,9 +84,9 @@ export declare class SystemOverloadError extends VidNavigatorError {
|
|
|
83
84
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any, retry_after_seconds?: number);
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
86
|
-
* Raised when
|
|
87
|
-
* (
|
|
88
|
-
*
|
|
87
|
+
* Raised when the account does not have enough credits: HTTP 402 `insufficient_credits`.
|
|
88
|
+
* Thrown at job submit time (no task is created; e.g. less than 60 seconds of transcription
|
|
89
|
+
* credit left) and by `result()` when a job runs out of credits. Extends `PaymentRequiredError`.
|
|
89
90
|
*/
|
|
90
91
|
export declare class InsufficientCreditsError extends PaymentRequiredError {
|
|
91
92
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any);
|
package/dist/errors.js
CHANGED
|
@@ -62,7 +62,7 @@ class NotFoundError extends VidNavigatorError {
|
|
|
62
62
|
}
|
|
63
63
|
exports.NotFoundError = NotFoundError;
|
|
64
64
|
/**
|
|
65
|
-
* Raised
|
|
65
|
+
* Raised on HTTP 429: too many requests (`rate_limit_exceeded`). Wait `Retry-After` seconds.
|
|
66
66
|
*/
|
|
67
67
|
class RateLimitExceededError extends VidNavigatorError {
|
|
68
68
|
constructor(message, status_code, error_code, error_message, details) {
|
|
@@ -73,7 +73,8 @@ class RateLimitExceededError extends VidNavigatorError {
|
|
|
73
73
|
}
|
|
74
74
|
exports.RateLimitExceededError = RateLimitExceededError;
|
|
75
75
|
/**
|
|
76
|
-
* Raised
|
|
76
|
+
* Raised on HTTP 402. Catch it for any 402, or one of its subclasses to know which:
|
|
77
|
+
* `InsufficientCreditsError` (not enough credits) or `StorageQuotaExceededError` (the storage of the plan is full).
|
|
77
78
|
*/
|
|
78
79
|
class PaymentRequiredError extends VidNavigatorError {
|
|
79
80
|
constructor(message, status_code, error_code, error_message, details) {
|
|
@@ -131,9 +132,9 @@ class SystemOverloadError extends VidNavigatorError {
|
|
|
131
132
|
}
|
|
132
133
|
exports.SystemOverloadError = SystemOverloadError;
|
|
133
134
|
/**
|
|
134
|
-
* Raised when
|
|
135
|
-
* (
|
|
136
|
-
*
|
|
135
|
+
* Raised when the account does not have enough credits: HTTP 402 `insufficient_credits`.
|
|
136
|
+
* Thrown at job submit time (no task is created; e.g. less than 60 seconds of transcription
|
|
137
|
+
* credit left) and by `result()` when a job runs out of credits. Extends `PaymentRequiredError`.
|
|
137
138
|
*/
|
|
138
139
|
class InsufficientCreditsError extends PaymentRequiredError {
|
|
139
140
|
constructor(message, status_code, error_code, error_message, details) {
|
package/dist/http.js
CHANGED
|
@@ -6,6 +6,8 @@ exports.buildApiError = buildApiError;
|
|
|
6
6
|
* Internal: maps API error responses to SDK error classes. Not re-exported from the package.
|
|
7
7
|
*/
|
|
8
8
|
const errors_1 = require("./errors");
|
|
9
|
+
/** The codes of a 402 for "not enough credits"; `limit_exceeded` is the API's code for it before November 2026. */
|
|
10
|
+
const INSUFFICIENT_CREDITS_CODES = new Set(['insufficient_credits', 'insufficient_credits_video_search', 'limit_exceeded']);
|
|
9
11
|
function parseApiErrorPayload(data) {
|
|
10
12
|
const errorField = data?.error;
|
|
11
13
|
const errorCode = (typeof errorField === 'string' ? errorField : errorField?.code) ?? data?.error_code;
|
|
@@ -26,7 +28,7 @@ function buildApiError(status, data, fallbackMessage) {
|
|
|
26
28
|
if (errorCode === 'storage_quota_exceeded') {
|
|
27
29
|
return new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
28
30
|
}
|
|
29
|
-
if (errorCode
|
|
31
|
+
if (errorCode && INSUFFICIENT_CREDITS_CODES.has(errorCode)) {
|
|
30
32
|
return new errors_1.InsufficientCreditsError(message, status, errorCode, errorMessage, details);
|
|
31
33
|
}
|
|
32
34
|
return new errors_1.PaymentRequiredError(message, status, errorCode, errorMessage, details);
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export * from './webhooks';
|
|
|
7
7
|
export { Job } from './jobs';
|
|
8
8
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
9
9
|
/** SDK version (keep in sync with package.json) */
|
|
10
|
-
export declare const SDK_VERSION = "3.0
|
|
10
|
+
export declare const SDK_VERSION = "3.1.0";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __exportStar(require("./webhooks"), exports);
|
|
|
31
31
|
var jobs_2 = require("./jobs");
|
|
32
32
|
Object.defineProperty(exports, "Job", { enumerable: true, get: function () { return jobs_2.Job; } });
|
|
33
33
|
/** SDK version (keep in sync with package.json) */
|
|
34
|
-
exports.SDK_VERSION = '3.0
|
|
34
|
+
exports.SDK_VERSION = '3.1.0';
|
|
35
35
|
/**
|
|
36
36
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|
|
37
37
|
* minutes at worst. A shorter configured axios timeout is raised to this for that call only.
|
package/package.json
CHANGED
package/src/errors.ts
CHANGED
|
@@ -81,7 +81,7 @@ export class NotFoundError extends VidNavigatorError {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* Raised
|
|
84
|
+
* Raised on HTTP 429: too many requests (`rate_limit_exceeded`). Wait `Retry-After` seconds.
|
|
85
85
|
*/
|
|
86
86
|
export class RateLimitExceededError extends VidNavigatorError {
|
|
87
87
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
@@ -92,7 +92,8 @@ export class RateLimitExceededError extends VidNavigatorError {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Raised
|
|
95
|
+
* Raised on HTTP 402. Catch it for any 402, or one of its subclasses to know which:
|
|
96
|
+
* `InsufficientCreditsError` (not enough credits) or `StorageQuotaExceededError` (the storage of the plan is full).
|
|
96
97
|
*/
|
|
97
98
|
export class PaymentRequiredError extends VidNavigatorError {
|
|
98
99
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
|
@@ -159,9 +160,9 @@ export class SystemOverloadError extends VidNavigatorError {
|
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
/**
|
|
162
|
-
* Raised when
|
|
163
|
-
* (
|
|
164
|
-
*
|
|
163
|
+
* Raised when the account does not have enough credits: HTTP 402 `insufficient_credits`.
|
|
164
|
+
* Thrown at job submit time (no task is created; e.g. less than 60 seconds of transcription
|
|
165
|
+
* credit left) and by `result()` when a job runs out of credits. Extends `PaymentRequiredError`.
|
|
165
166
|
*/
|
|
166
167
|
export class InsufficientCreditsError extends PaymentRequiredError {
|
|
167
168
|
constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
|
package/src/http.ts
CHANGED
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
ScenesNotAvailableError,
|
|
19
19
|
} from './errors';
|
|
20
20
|
|
|
21
|
+
/** The codes of a 402 for "not enough credits"; `limit_exceeded` is the API's code for it before November 2026. */
|
|
22
|
+
const INSUFFICIENT_CREDITS_CODES = new Set(['insufficient_credits', 'insufficient_credits_video_search', 'limit_exceeded']);
|
|
23
|
+
|
|
21
24
|
export function parseApiErrorPayload(data: any): {
|
|
22
25
|
errorCode?: string;
|
|
23
26
|
errorMessage?: string;
|
|
@@ -46,7 +49,7 @@ export function buildApiError(status: number, data: any, fallbackMessage?: strin
|
|
|
46
49
|
if (errorCode === 'storage_quota_exceeded') {
|
|
47
50
|
return new StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
48
51
|
}
|
|
49
|
-
if (errorCode
|
|
52
|
+
if (errorCode && INSUFFICIENT_CREDITS_CODES.has(errorCode)) {
|
|
50
53
|
return new InsufficientCreditsError(message, status, errorCode, errorMessage, details);
|
|
51
54
|
}
|
|
52
55
|
return new PaymentRequiredError(message, status, errorCode, errorMessage, details);
|
package/src/index.ts
CHANGED
|
@@ -71,7 +71,7 @@ export { Job } from './jobs';
|
|
|
71
71
|
export type { TaskStatus, PollableTask, PollOptions, JobOperation, SubmitOptions, RunOptions, JobInfo } from './jobs';
|
|
72
72
|
|
|
73
73
|
/** SDK version (keep in sync with package.json) */
|
|
74
|
-
export const SDK_VERSION = '3.0
|
|
74
|
+
export const SDK_VERSION = '3.1.0';
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
77
|
* A LIVE room usually answers in 1-5 s, up to ~30 s when the API has to open a TikTok page, and two
|