vidnavigator 2.0.0 → 2.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 +5 -6
- package/dist/index.d.ts +2 -3
- package/dist/index.js +3 -4
- package/dist/models/AsyncJob.d.ts +5 -0
- package/dist/models/AsyncJob.js +2 -0
- package/dist/webhooks.d.ts +2 -0
- package/package.json +39 -39
- package/src/index.ts +1081 -1082
- package/src/models/AsyncJob.ts +6 -0
- package/src/webhooks.ts +2 -0
package/README.md
CHANGED
|
@@ -90,9 +90,8 @@ const vn = new VidNavigatorClient({
|
|
|
90
90
|
|
|
91
91
|
### Upgrading from 1.x
|
|
92
92
|
|
|
93
|
-
Transcription, structured extraction, and tweet analysis now always run as background jobs, so they work on videos of any length. Your existing calls keep working with the same arguments, with
|
|
93
|
+
Transcription, structured extraction, and tweet analysis now always run as background jobs, so they work on videos of any length. Your existing calls keep working with the same arguments, with one difference:
|
|
94
94
|
|
|
95
|
-
- `extractVideoData()` no longer returns `video_info`. Use `getTranscript({ video_url, metadata_only: true })` if you need the metadata.
|
|
96
95
|
- `getTweetStatement()` no longer returns `statement_query`, which was never part of the documented API.
|
|
97
96
|
|
|
98
97
|
New in 2.0: `vn.transcribe`, `vn.extractVideo`, `vn.tweetStatement`, `vn.tiktokProfile`, and `vn.tiktokSearch`, each with `.submit()` for running many jobs at once (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)), plus webhook signature helpers.
|
|
@@ -304,7 +303,7 @@ function pending(): string[] {
|
|
|
304
303
|
}
|
|
305
304
|
```
|
|
306
305
|
|
|
307
|
-
> The older methods `transcribeVideo()`, `extractVideoData()`, and `getTweetStatement()` still work with the same arguments. They now run as background jobs too, so they handle videos of any length.
|
|
306
|
+
> The older methods `transcribeVideo()`, `extractVideoData()`, and `getTweetStatement()` still work with the same arguments. They now run as background jobs too, so they handle videos of any length.
|
|
308
307
|
|
|
309
308
|
### 4. Webhooks
|
|
310
309
|
|
|
@@ -626,7 +625,7 @@ const { data } = await vn.extractVideoData({
|
|
|
626
625
|
|
|
627
626
|
**Schema rules:** every field needs `type` and `description`. `Array` fields also need `items` (the schema of one element). `Object` fields list their sub-fields in `properties` (up to 10), and `Enum` fields list the allowed values in `enum`. At most 10 top-level fields and 3 levels of nesting. An invalid schema is rejected with a `BadRequestError` before anything runs.
|
|
628
627
|
|
|
629
|
-
> `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` and `usage
|
|
628
|
+
> `extractVideoData()` runs as a background job, so videos of any length work. For many extractions at once, use `vn.extractVideo.submit()` (see [Background jobs](#3-background-jobs-one-call-or-many-at-once)). The result has `data` (the extracted fields), `video_info` (the video's metadata), and `usage` when requested.
|
|
630
629
|
|
|
631
630
|
### 10. Semantic search
|
|
632
631
|
|
|
@@ -759,7 +758,7 @@ All methods return a `Promise`. Responses are automatically parsed into typed mo
|
|
|
759
758
|
| `job.result(options?)` | Wait until finished and return the result. Throws on failure or timeout; every error carries `task_id` |
|
|
760
759
|
| `job.wait(options?)` | Wait until finished and return the final task, without throwing on failure |
|
|
761
760
|
|
|
762
|
-
Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` → `{ data, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` → the completed task with every page of `videos` / `results`.
|
|
761
|
+
Results: `transcribe` → same shape as `transcribeVideo()`; `extractVideo` → `{ data, video_info, usage? }`; `tweetStatement` → `TweetStatement`; `tiktokProfile` / `tiktokSearch` → the completed task with every page of `videos` / `results`.
|
|
763
762
|
|
|
764
763
|
### Webhooks
|
|
765
764
|
|
|
@@ -828,7 +827,7 @@ Returns `transcript_analysis` containing:
|
|
|
828
827
|
|
|
829
828
|
| Method | Description |
|
|
830
829
|
|--------|-------------|
|
|
831
|
-
| `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `webhook_url`. Returns `{ data, usage? }` |
|
|
830
|
+
| `extractVideo(input, options?)` | Structured data from an online video of any length. Input: `video_url`, `schema` or `schemaFilePath`, `what_to_extract`, `transcribe`, `webhook_url`. Returns `{ data, video_info, usage? }` |
|
|
832
831
|
| `extractVideoData(payload, options?)` | Same as `extractVideo()`, with the original payload shape (`include_usage` in the payload) |
|
|
833
832
|
| `extractFileData(payload)` | Extract structured data from an uploaded file transcript |
|
|
834
833
|
|
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 = "2.
|
|
10
|
+
export declare const SDK_VERSION = "2.1.0";
|
|
11
11
|
export interface SDKConfig {
|
|
12
12
|
apiKey: string;
|
|
13
13
|
baseURL?: string;
|
|
@@ -354,8 +354,7 @@ export declare class VidNavigatorClient {
|
|
|
354
354
|
/**
|
|
355
355
|
* Structured-data extraction from an online video. Blocking convenience wrapper around
|
|
356
356
|
* {@link VidNavigatorClient.extractVideo}: submits to `POST /extract/video/async` and polls, so
|
|
357
|
-
* media of any length works. The
|
|
358
|
-
* {@link VidNavigatorClient.getTranscript} with `metadata_only: true` if you need it.
|
|
357
|
+
* media of any length works. The result carries the extracted `data` and the video's `video_info`.
|
|
359
358
|
*/
|
|
360
359
|
extractVideoData(payload: ExtractVideoDataPayload | ExtractVideoDataMultipartPayload, options?: PollOptions<ExtractVideoAsyncJob>): Promise<ExtractDataResult>;
|
|
361
360
|
extractFileData(payload: ExtractFileDataPayload | ExtractFileDataMultipartPayload): Promise<ExtractDataResult>;
|
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 = '2.
|
|
34
|
+
exports.SDK_VERSION = '2.1.0';
|
|
35
35
|
//endregion
|
|
36
36
|
function parseTranscribeData(inner, usage) {
|
|
37
37
|
if ('videos' in inner && 'carousel_info' in inner) {
|
|
@@ -127,7 +127,7 @@ class VidNavigatorClient {
|
|
|
127
127
|
jobType: 'extract_video',
|
|
128
128
|
submit: (input) => this.submitExtractVideo(input),
|
|
129
129
|
fetchTask: (task_id, options) => this.getAsyncJob(`/extract/video/${encodeURIComponent(task_id)}`, options, (raw) => raw),
|
|
130
|
-
toResult: async (task) => ({ data: requireResult(task), usage: task.usage }),
|
|
130
|
+
toResult: async (task) => ({ data: requireResult(task), video_info: task.video_info, usage: task.usage }),
|
|
131
131
|
});
|
|
132
132
|
this.tweetStatement = this.defineOperation({
|
|
133
133
|
jobType: 'tweet_statement',
|
|
@@ -402,8 +402,7 @@ class VidNavigatorClient {
|
|
|
402
402
|
/**
|
|
403
403
|
* Structured-data extraction from an online video. Blocking convenience wrapper around
|
|
404
404
|
* {@link VidNavigatorClient.extractVideo}: submits to `POST /extract/video/async` and polls, so
|
|
405
|
-
* media of any length works. The
|
|
406
|
-
* {@link VidNavigatorClient.getTranscript} with `metadata_only: true` if you need it.
|
|
405
|
+
* media of any length works. The result carries the extracted `data` and the video's `video_info`.
|
|
407
406
|
*/
|
|
408
407
|
async extractVideoData(payload, options) {
|
|
409
408
|
const { include_usage, ...input } = payload;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { UsageBlock } from './Usage';
|
|
2
|
+
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
2
3
|
/** Async job kinds returned by the `/transcribe/async`, `/extract/video/async` and `/tweet/statement/async` endpoints. */
|
|
3
4
|
export type AsyncJobType = 'transcribe' | 'extract_video' | 'tweet_statement';
|
|
4
5
|
/** `processing` = accepted and being worked on. `completed` and `failed` are terminal. */
|
|
@@ -63,6 +64,8 @@ export interface AsyncJobJSON {
|
|
|
63
64
|
check_status_url?: string;
|
|
64
65
|
webhook?: AsyncJobWebhookStatus | null;
|
|
65
66
|
result?: any;
|
|
67
|
+
/** `extract_video` jobs, once completed: the `video_info` the synchronous endpoint returns. */
|
|
68
|
+
video_info?: VideoInfoJSON;
|
|
66
69
|
error?: AsyncJobError | null;
|
|
67
70
|
}
|
|
68
71
|
/**
|
|
@@ -84,6 +87,8 @@ export declare class AsyncJob<TResult> {
|
|
|
84
87
|
check_status_url?: string;
|
|
85
88
|
webhook?: AsyncJobWebhookStatus | null;
|
|
86
89
|
result: TResult | null;
|
|
90
|
+
/** `extract_video` jobs, once completed: metadata of the video the data was extracted from. */
|
|
91
|
+
video_info?: VideoInfo;
|
|
87
92
|
error: AsyncJobError | null;
|
|
88
93
|
/** Per-call usage, populated only when polled with `include_usage: true` and `task_status === 'completed'`. */
|
|
89
94
|
usage?: UsageBlock;
|
package/dist/models/AsyncJob.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AsyncJob = exports.AsyncJobAccepted = void 0;
|
|
4
|
+
const VideoInfo_1 = require("./VideoInfo");
|
|
4
5
|
/** 202 response from an async submit endpoint. Poll with the matching `get...AsyncJob(task_id)` method. */
|
|
5
6
|
class AsyncJobAccepted {
|
|
6
7
|
constructor(data) {
|
|
@@ -36,6 +37,7 @@ class AsyncJob {
|
|
|
36
37
|
this.check_status_url = data.check_status_url;
|
|
37
38
|
this.webhook = data.webhook;
|
|
38
39
|
this.result = data.result !== undefined && data.result !== null ? parseResult(data.result) : null;
|
|
40
|
+
this.video_info = data.video_info ? VideoInfo_1.VideoInfo.fromJSON(data.video_info) : undefined;
|
|
39
41
|
this.error = data.error ?? null;
|
|
40
42
|
}
|
|
41
43
|
static fromJSON(json, parseResult) {
|
package/dist/webhooks.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export interface WebhookEvent {
|
|
|
29
29
|
result?: Record<string, unknown> | TikTokWebhookResult | null;
|
|
30
30
|
/** True when the result exceeded 256 KB; fetch it with `resume(task_id).result()` instead. */
|
|
31
31
|
result_truncated?: boolean;
|
|
32
|
+
/** `extract_video.completed` only: raw `video_info` of the video. Sent even when `result_truncated` is true. */
|
|
33
|
+
video_info?: Record<string, unknown>;
|
|
32
34
|
error?: AsyncJobError | null;
|
|
33
35
|
};
|
|
34
36
|
}
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vidnavigator",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Official JavaScript SDK for the VidNavigator Developer API",
|
|
5
|
-
"author": "VidNavigator",
|
|
6
|
-
"license": "Apache-2.0",
|
|
7
|
-
"homepage": "https://vidnavigator.com",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"files": [
|
|
11
|
-
"dist",
|
|
12
|
-
"src"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"build": "tsc",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
17
|
-
},
|
|
18
|
-
"repository": {
|
|
19
|
-
"type": "git",
|
|
20
|
-
"url": "git+https://github.com/vidnavigator/vidnavigator-js.git"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"vidnavigator",
|
|
24
|
-
"sdk",
|
|
25
|
-
"api",
|
|
26
|
-
"video",
|
|
27
|
-
"transcription",
|
|
28
|
-
"analysis"
|
|
29
|
-
],
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"axios": "^1.6.0",
|
|
32
|
-
"form-data": "^4.0.0"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"@types/node": "^20.4.2",
|
|
36
|
-
"typescript": "^5.1.3",
|
|
37
|
-
"@types/form-data": "^2.5.0"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vidnavigator",
|
|
3
|
+
"version": "2.1.0",
|
|
4
|
+
"description": "Official JavaScript SDK for the VidNavigator Developer API",
|
|
5
|
+
"author": "VidNavigator",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://vidnavigator.com",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"src"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/vidnavigator/vidnavigator-js.git"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"vidnavigator",
|
|
24
|
+
"sdk",
|
|
25
|
+
"api",
|
|
26
|
+
"video",
|
|
27
|
+
"transcription",
|
|
28
|
+
"analysis"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.6.0",
|
|
32
|
+
"form-data": "^4.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.4.2",
|
|
36
|
+
"typescript": "^5.1.3",
|
|
37
|
+
"@types/form-data": "^2.5.0"
|
|
38
|
+
}
|
|
39
|
+
}
|