vidnavigator 0.1.5 → 1.0.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 +375 -77
- package/dist/errors.d.ts +19 -0
- package/dist/errors.js +35 -1
- package/dist/index.d.ts +110 -20
- package/dist/index.js +150 -31
- package/dist/models/Carousel.d.ts +30 -0
- package/dist/models/Carousel.js +21 -0
- package/dist/models/CarouselVideoResult.d.ts +28 -0
- package/dist/models/CarouselVideoResult.js +21 -0
- package/dist/models/Extraction.d.ts +27 -0
- package/dist/models/Extraction.js +14 -0
- package/dist/models/FileInfo.d.ts +5 -0
- package/dist/models/FileInfo.js +3 -0
- package/dist/models/Namespace.d.ts +29 -0
- package/dist/models/Namespace.js +37 -0
- package/dist/models/SearchResult.d.ts +29 -0
- package/dist/models/SearchResult.js +12 -0
- package/dist/models/TranscriptSegment.d.ts +7 -0
- package/dist/models/TranscriptSegment.js +11 -0
- package/dist/models/Usage.d.ts +68 -22
- package/dist/models/Usage.js +45 -13
- package/dist/models/VideoInfo.d.ts +6 -1
- package/dist/models/VideoInfo.js +9 -1
- package/dist/models/index.d.ts +4 -0
- package/dist/models/index.js +4 -0
- package/package.json +1 -1
- package/src/errors.ts +43 -0
- package/src/index.ts +450 -114
- package/src/models/Carousel.ts +45 -0
- package/src/models/CarouselVideoResult.ts +44 -0
- package/src/models/Extraction.ts +47 -0
- package/src/models/FileInfo.ts +8 -0
- package/src/models/Namespace.ts +60 -0
- package/src/models/SearchResult.ts +45 -1
- package/src/models/TranscriptSegment.ts +16 -0
- package/src/models/Usage.ts +183 -105
- package/src/models/VideoInfo.ts +15 -2
- package/src/models/index.ts +4 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,96 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { VideoInfo,
|
|
2
|
+
import { VideoInfo, TranscriptOutput, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData, Namespace, NamespaceRef, ExtractionSchema, ExtractionTokenUsage, CarouselInfo, CarouselVideoResult } from './models';
|
|
3
3
|
export * from './models';
|
|
4
4
|
export * from './errors';
|
|
5
|
+
/** SDK version (keep in sync with package.json) */
|
|
6
|
+
export declare const SDK_VERSION = "1.0.0";
|
|
5
7
|
export interface SDKConfig {
|
|
6
8
|
apiKey: string;
|
|
7
9
|
baseURL?: string;
|
|
8
10
|
axiosConfig?: AxiosRequestConfig;
|
|
9
11
|
}
|
|
12
|
+
export type TranscriptRequestPayload = {
|
|
13
|
+
video_url: string;
|
|
14
|
+
language?: string;
|
|
15
|
+
metadata_only?: boolean;
|
|
16
|
+
fallback_to_metadata?: boolean;
|
|
17
|
+
transcript_text?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type TranscribeVideoPayload = {
|
|
20
|
+
video_url: string;
|
|
21
|
+
transcript_text?: boolean;
|
|
22
|
+
all_videos?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type TranscribeVideoSingleResult = {
|
|
25
|
+
video_info: VideoInfo;
|
|
26
|
+
transcript: TranscriptOutput;
|
|
27
|
+
};
|
|
28
|
+
export type TranscribeVideoCarouselResult = {
|
|
29
|
+
carousel_info: CarouselInfo;
|
|
30
|
+
videos: CarouselVideoResult[];
|
|
31
|
+
};
|
|
32
|
+
export type TranscribeVideoResult = TranscribeVideoSingleResult | TranscribeVideoCarouselResult;
|
|
33
|
+
export type UploadFileSuccessResult = {
|
|
34
|
+
status: 'success';
|
|
35
|
+
file_id: string;
|
|
36
|
+
file_name: string;
|
|
37
|
+
file_status: 'processing' | 'completed';
|
|
38
|
+
message: string;
|
|
39
|
+
file_info: FileInfo;
|
|
40
|
+
};
|
|
41
|
+
export type UploadFileAcceptedResult = {
|
|
42
|
+
status: 'accepted';
|
|
43
|
+
file_id: string;
|
|
44
|
+
file_name: string;
|
|
45
|
+
file_status: 'processing';
|
|
46
|
+
message: string;
|
|
47
|
+
note?: string;
|
|
48
|
+
file_info?: FileInfo;
|
|
49
|
+
};
|
|
50
|
+
export type UploadFileResult = UploadFileSuccessResult | UploadFileAcceptedResult;
|
|
51
|
+
export interface ExtractDataResult {
|
|
52
|
+
data: Record<string, unknown>;
|
|
53
|
+
usage?: ExtractionTokenUsage;
|
|
54
|
+
}
|
|
10
55
|
export declare class VidNavigatorClient {
|
|
11
56
|
private client;
|
|
12
57
|
constructor(config: SDKConfig);
|
|
13
58
|
private request;
|
|
14
|
-
getTranscript(payload: {
|
|
15
|
-
video_url: string;
|
|
16
|
-
language?: string;
|
|
17
|
-
}): Promise<{
|
|
59
|
+
getTranscript(payload: TranscriptRequestPayload): Promise<{
|
|
18
60
|
video_info: VideoInfo;
|
|
19
|
-
transcript:
|
|
61
|
+
transcript: TranscriptOutput;
|
|
20
62
|
}>;
|
|
21
|
-
|
|
22
|
-
video_url: string;
|
|
23
|
-
}): Promise<{
|
|
63
|
+
getYouTubeTranscript(payload: TranscriptRequestPayload): Promise<{
|
|
24
64
|
video_info: VideoInfo;
|
|
25
|
-
transcript:
|
|
65
|
+
transcript: TranscriptOutput;
|
|
26
66
|
}>;
|
|
67
|
+
transcribeVideo(payload: TranscribeVideoPayload): Promise<TranscribeVideoResult>;
|
|
27
68
|
getFiles(query?: {
|
|
28
69
|
limit?: number;
|
|
29
70
|
offset?: number;
|
|
30
71
|
status?: 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
72
|
+
namespace_id?: string;
|
|
31
73
|
}): Promise<{
|
|
32
74
|
files: FileInfo[];
|
|
33
75
|
total_count: number;
|
|
76
|
+
limit: number;
|
|
77
|
+
offset: number;
|
|
34
78
|
has_more: boolean;
|
|
35
79
|
}>;
|
|
36
|
-
getFile(file_id: string
|
|
80
|
+
getFile(file_id: string, query?: {
|
|
81
|
+
transcript_text?: boolean;
|
|
82
|
+
}): Promise<{
|
|
37
83
|
file_info: FileInfo;
|
|
38
|
-
transcript?:
|
|
84
|
+
transcript?: TranscriptOutput;
|
|
39
85
|
}>;
|
|
40
86
|
uploadFile(options: {
|
|
41
87
|
filePath: string;
|
|
42
88
|
wait_for_completion?: boolean;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
file_info: FileInfo;
|
|
46
|
-
transcript?: TranscriptSegment[];
|
|
47
|
-
}>;
|
|
89
|
+
namespace_ids?: string[];
|
|
90
|
+
}): Promise<UploadFileResult>;
|
|
48
91
|
deleteFile(file_id: string): Promise<{
|
|
49
92
|
file_id: string;
|
|
93
|
+
file_name: string;
|
|
50
94
|
message: string;
|
|
51
95
|
}>;
|
|
52
96
|
getFileUrl(file_id: string): Promise<{
|
|
@@ -64,22 +108,55 @@ export declare class VidNavigatorClient {
|
|
|
64
108
|
file_name: string;
|
|
65
109
|
message: string;
|
|
66
110
|
}>;
|
|
111
|
+
getNamespaces(): Promise<Namespace[]>;
|
|
112
|
+
createNamespace(payload: {
|
|
113
|
+
name: string;
|
|
114
|
+
}): Promise<Namespace>;
|
|
115
|
+
updateNamespace(namespace_id: string, payload: {
|
|
116
|
+
name: string;
|
|
117
|
+
}): Promise<{
|
|
118
|
+
message: string;
|
|
119
|
+
}>;
|
|
120
|
+
deleteNamespace(namespace_id: string): Promise<{
|
|
121
|
+
message: string;
|
|
122
|
+
}>;
|
|
123
|
+
updateFileNamespaces(file_id: string, payload: {
|
|
124
|
+
namespace_ids: string[];
|
|
125
|
+
}): Promise<{
|
|
126
|
+
message: string;
|
|
127
|
+
namespace_ids: string[];
|
|
128
|
+
namespaces: NamespaceRef[];
|
|
129
|
+
}>;
|
|
67
130
|
analyzeVideo(payload: {
|
|
68
131
|
video_url: string;
|
|
69
132
|
query?: string;
|
|
133
|
+
transcript_text?: boolean;
|
|
70
134
|
}): Promise<{
|
|
71
135
|
video_info: VideoInfo;
|
|
72
|
-
transcript:
|
|
136
|
+
transcript: TranscriptOutput;
|
|
73
137
|
transcript_analysis: AnalysisResult;
|
|
74
138
|
}>;
|
|
75
139
|
analyzeFile(payload: {
|
|
76
140
|
file_id: string;
|
|
77
141
|
query?: string;
|
|
142
|
+
transcript_text?: boolean;
|
|
78
143
|
}): Promise<{
|
|
79
144
|
file_info: FileInfo;
|
|
80
|
-
transcript:
|
|
145
|
+
transcript: TranscriptOutput;
|
|
81
146
|
transcript_analysis: AnalysisResult;
|
|
82
147
|
}>;
|
|
148
|
+
extractVideoData(payload: {
|
|
149
|
+
video_url: string;
|
|
150
|
+
schema: ExtractionSchema;
|
|
151
|
+
what_to_extract?: string;
|
|
152
|
+
include_usage?: boolean;
|
|
153
|
+
}): Promise<ExtractDataResult>;
|
|
154
|
+
extractFileData(payload: {
|
|
155
|
+
file_id: string;
|
|
156
|
+
schema: ExtractionSchema;
|
|
157
|
+
what_to_extract?: string;
|
|
158
|
+
include_usage?: boolean;
|
|
159
|
+
}): Promise<ExtractDataResult>;
|
|
83
160
|
searchVideos(payload: {
|
|
84
161
|
query: string;
|
|
85
162
|
use_enhanced_search?: boolean;
|
|
@@ -89,16 +166,29 @@ export declare class VidNavigatorClient {
|
|
|
89
166
|
duration?: number;
|
|
90
167
|
}): Promise<{
|
|
91
168
|
results: VideoSearchResult[];
|
|
169
|
+
query: string;
|
|
92
170
|
total_found: number;
|
|
93
171
|
explanation?: string;
|
|
94
172
|
}>;
|
|
95
173
|
searchFiles(payload: {
|
|
96
174
|
query: string;
|
|
175
|
+
namespace_ids?: string[];
|
|
97
176
|
}): Promise<{
|
|
98
177
|
results: FileSearchResult[];
|
|
178
|
+
query: string;
|
|
99
179
|
total_found: number;
|
|
100
180
|
explanation?: string;
|
|
101
181
|
}>;
|
|
102
182
|
getUsage(): Promise<UsageData>;
|
|
103
|
-
healthCheck(): Promise<
|
|
183
|
+
healthCheck(): Promise<{
|
|
184
|
+
status?: string;
|
|
185
|
+
message?: string;
|
|
186
|
+
version?: string;
|
|
187
|
+
endpoints?: Array<{
|
|
188
|
+
path?: string;
|
|
189
|
+
method?: string;
|
|
190
|
+
description?: string;
|
|
191
|
+
auth_required?: boolean;
|
|
192
|
+
}>;
|
|
193
|
+
}>;
|
|
104
194
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.VidNavigatorClient = void 0;
|
|
20
|
+
exports.VidNavigatorClient = exports.SDK_VERSION = void 0;
|
|
21
21
|
const axios_1 = __importDefault(require("axios"));
|
|
22
22
|
const form_data_1 = __importDefault(require("form-data"));
|
|
23
23
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -25,7 +25,16 @@ const models_1 = require("./models");
|
|
|
25
25
|
const errors_1 = require("./errors");
|
|
26
26
|
__exportStar(require("./models"), exports);
|
|
27
27
|
__exportStar(require("./errors"), exports);
|
|
28
|
+
/** SDK version (keep in sync with package.json) */
|
|
29
|
+
exports.SDK_VERSION = '1.0.0';
|
|
28
30
|
//endregion
|
|
31
|
+
function parseApiErrorPayload(data) {
|
|
32
|
+
const errorField = data?.error;
|
|
33
|
+
const errorCode = typeof errorField === 'string' ? errorField : errorField?.code;
|
|
34
|
+
const errorMessage = data?.message ??
|
|
35
|
+
(typeof errorField === 'object' ? errorField?.message : undefined);
|
|
36
|
+
return { errorCode, errorMessage, details: data };
|
|
37
|
+
}
|
|
29
38
|
class VidNavigatorClient {
|
|
30
39
|
constructor(config) {
|
|
31
40
|
if (!config?.apiKey) {
|
|
@@ -35,7 +44,7 @@ class VidNavigatorClient {
|
|
|
35
44
|
baseURL: config.baseURL ?? 'https://api.vidnavigator.com/v1',
|
|
36
45
|
headers: {
|
|
37
46
|
'X-API-Key': config.apiKey,
|
|
38
|
-
'User-Agent': `vidnavigator-js
|
|
47
|
+
'User-Agent': `vidnavigator-js/${exports.SDK_VERSION}`,
|
|
39
48
|
},
|
|
40
49
|
...config.axiosConfig,
|
|
41
50
|
});
|
|
@@ -54,31 +63,34 @@ class VidNavigatorClient {
|
|
|
54
63
|
catch (error) {
|
|
55
64
|
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
56
65
|
const { status, data } = error.response;
|
|
57
|
-
const errorCode = data
|
|
58
|
-
const errorMessage = data?.error?.message;
|
|
59
|
-
const errorDetails = data?.error?.details;
|
|
66
|
+
const { errorCode, errorMessage, details } = parseApiErrorPayload(data);
|
|
60
67
|
const message = `API request failed with status ${status}: ${errorMessage || error.message}`;
|
|
61
68
|
switch (status) {
|
|
62
69
|
case 400:
|
|
63
|
-
throw new errors_1.BadRequestError(message, status, errorCode, errorMessage,
|
|
70
|
+
throw new errors_1.BadRequestError(message, status, errorCode, errorMessage, details);
|
|
64
71
|
case 401:
|
|
65
|
-
throw new errors_1.AuthenticationError(message, status, errorCode, errorMessage,
|
|
72
|
+
throw new errors_1.AuthenticationError(message, status, errorCode, errorMessage, details);
|
|
73
|
+
case 402:
|
|
74
|
+
throw new errors_1.PaymentRequiredError(message, status, errorCode, errorMessage, details);
|
|
66
75
|
case 403:
|
|
67
|
-
throw new errors_1.AccessDeniedError(message, status, errorCode, errorMessage,
|
|
76
|
+
throw new errors_1.AccessDeniedError(message, status, errorCode, errorMessage, details);
|
|
68
77
|
case 404:
|
|
69
|
-
throw new errors_1.NotFoundError(message, status, errorCode, errorMessage,
|
|
78
|
+
throw new errors_1.NotFoundError(message, status, errorCode, errorMessage, details);
|
|
79
|
+
case 413:
|
|
80
|
+
throw new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
70
81
|
case 429:
|
|
71
|
-
throw new errors_1.RateLimitExceededError(message, status, errorCode, errorMessage,
|
|
72
|
-
case
|
|
73
|
-
throw new errors_1.
|
|
82
|
+
throw new errors_1.RateLimitExceededError(message, status, errorCode, errorMessage, details);
|
|
83
|
+
case 451:
|
|
84
|
+
throw new errors_1.GeoRestrictedError(message, status, errorCode, errorMessage, details);
|
|
85
|
+
case 503:
|
|
86
|
+
throw new errors_1.SystemOverloadError(message, status, errorCode, errorMessage, details, data?.retry_after_seconds);
|
|
74
87
|
default:
|
|
75
88
|
if (status >= 500) {
|
|
76
|
-
throw new errors_1.ServerError(message, status, errorCode, errorMessage,
|
|
89
|
+
throw new errors_1.ServerError(message, status, errorCode, errorMessage, details);
|
|
77
90
|
}
|
|
78
|
-
throw new errors_1.VidNavigatorError(message, status, errorCode, errorMessage,
|
|
91
|
+
throw new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, details);
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
|
-
// Re-throw other errors (e.g., network errors)
|
|
82
94
|
throw new errors_1.VidNavigatorError(error.message);
|
|
83
95
|
}
|
|
84
96
|
}
|
|
@@ -87,14 +99,29 @@ class VidNavigatorClient {
|
|
|
87
99
|
const response = await this.request('POST', '/transcript', payload);
|
|
88
100
|
return {
|
|
89
101
|
video_info: models_1.VideoInfo.fromJSON(response.data.video_info),
|
|
90
|
-
transcript: response.data.transcript
|
|
102
|
+
transcript: (0, models_1.transcriptFromJSON)(response.data.transcript),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async getYouTubeTranscript(payload) {
|
|
106
|
+
const response = await this.request('POST', '/transcript/youtube', payload);
|
|
107
|
+
return {
|
|
108
|
+
video_info: models_1.VideoInfo.fromJSON(response.data.video_info),
|
|
109
|
+
transcript: (0, models_1.transcriptFromJSON)(response.data.transcript),
|
|
91
110
|
};
|
|
92
111
|
}
|
|
93
112
|
async transcribeVideo(payload) {
|
|
94
113
|
const response = await this.request('POST', '/transcribe', payload);
|
|
114
|
+
const inner = response.data;
|
|
115
|
+
if ('videos' in inner && 'carousel_info' in inner) {
|
|
116
|
+
return {
|
|
117
|
+
carousel_info: models_1.CarouselInfo.fromJSON(inner.carousel_info),
|
|
118
|
+
videos: inner.videos.map((v) => models_1.CarouselVideoResult.fromJSON(v)),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const single = inner;
|
|
95
122
|
return {
|
|
96
|
-
video_info: models_1.VideoInfo.fromJSON(
|
|
97
|
-
transcript:
|
|
123
|
+
video_info: models_1.VideoInfo.fromJSON(single.video_info),
|
|
124
|
+
transcript: (0, models_1.transcriptFromJSON)(single.transcript),
|
|
98
125
|
};
|
|
99
126
|
}
|
|
100
127
|
//endregion
|
|
@@ -104,14 +131,16 @@ class VidNavigatorClient {
|
|
|
104
131
|
return {
|
|
105
132
|
files: response.data.files.map(models_1.FileInfo.fromJSON),
|
|
106
133
|
total_count: response.data.total_count,
|
|
134
|
+
limit: response.data.limit,
|
|
135
|
+
offset: response.data.offset,
|
|
107
136
|
has_more: response.data.has_more,
|
|
108
137
|
};
|
|
109
138
|
}
|
|
110
|
-
async getFile(file_id) {
|
|
111
|
-
const response = await this.request('GET', `/file/${file_id}
|
|
139
|
+
async getFile(file_id, query) {
|
|
140
|
+
const response = await this.request('GET', `/file/${file_id}`, undefined, query);
|
|
112
141
|
return {
|
|
113
142
|
file_info: models_1.FileInfo.fromJSON(response.data.file_info),
|
|
114
|
-
transcript: response.data.transcript
|
|
143
|
+
transcript: (0, models_1.transcriptFromJSON)(response.data.transcript),
|
|
115
144
|
};
|
|
116
145
|
}
|
|
117
146
|
async uploadFile(options) {
|
|
@@ -120,12 +149,58 @@ class VidNavigatorClient {
|
|
|
120
149
|
if (options.wait_for_completion) {
|
|
121
150
|
form.append('wait_for_completion', 'true');
|
|
122
151
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
if (options.namespace_ids?.length) {
|
|
153
|
+
form.append('namespace_ids', JSON.stringify(options.namespace_ids));
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const response = await this.client.post('/upload/file', form, { headers: form.getHeaders() });
|
|
157
|
+
const body = response.data;
|
|
158
|
+
const fileInfo = body.data?.file_info ? models_1.FileInfo.fromJSON(body.data.file_info) : undefined;
|
|
159
|
+
if (body.status === 'accepted') {
|
|
160
|
+
return {
|
|
161
|
+
status: 'accepted',
|
|
162
|
+
file_id: body.file_id,
|
|
163
|
+
file_name: body.file_name,
|
|
164
|
+
file_status: body.file_status,
|
|
165
|
+
message: body.message,
|
|
166
|
+
note: body.note,
|
|
167
|
+
file_info: fileInfo,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
status: 'success',
|
|
172
|
+
file_id: body.file_id,
|
|
173
|
+
file_name: body.file_name,
|
|
174
|
+
file_status: body.file_status,
|
|
175
|
+
message: body.message,
|
|
176
|
+
file_info: fileInfo,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
if (axios_1.default.isAxiosError(error) && error.response) {
|
|
181
|
+
const { status, data } = error.response;
|
|
182
|
+
const { errorCode, errorMessage, details } = parseApiErrorPayload(data);
|
|
183
|
+
const message = `API request failed with status ${status}: ${errorMessage || error.message}`;
|
|
184
|
+
switch (status) {
|
|
185
|
+
case 400:
|
|
186
|
+
throw new errors_1.BadRequestError(message, status, errorCode, errorMessage, details);
|
|
187
|
+
case 401:
|
|
188
|
+
throw new errors_1.AuthenticationError(message, status, errorCode, errorMessage, details);
|
|
189
|
+
case 402:
|
|
190
|
+
throw new errors_1.PaymentRequiredError(message, status, errorCode, errorMessage, details);
|
|
191
|
+
case 413:
|
|
192
|
+
throw new errors_1.StorageQuotaExceededError(message, status, errorCode, errorMessage, details);
|
|
193
|
+
case 503:
|
|
194
|
+
throw new errors_1.SystemOverloadError(message, status, errorCode, errorMessage, details, data?.retry_after_seconds);
|
|
195
|
+
default:
|
|
196
|
+
if (status >= 500) {
|
|
197
|
+
throw new errors_1.ServerError(message, status, errorCode, errorMessage, details);
|
|
198
|
+
}
|
|
199
|
+
throw new errors_1.VidNavigatorError(message, status, errorCode, errorMessage, details);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
throw new errors_1.VidNavigatorError(error.message);
|
|
203
|
+
}
|
|
129
204
|
}
|
|
130
205
|
async deleteFile(file_id) {
|
|
131
206
|
const response = await this.request('DELETE', `/file/${file_id}/delete`);
|
|
@@ -144,12 +219,38 @@ class VidNavigatorClient {
|
|
|
144
219
|
return response.data;
|
|
145
220
|
}
|
|
146
221
|
//endregion
|
|
222
|
+
//region --- Namespaces ---
|
|
223
|
+
async getNamespaces() {
|
|
224
|
+
const response = await this.request('GET', '/namespaces');
|
|
225
|
+
return response.data.map((n) => models_1.Namespace.fromJSON(n));
|
|
226
|
+
}
|
|
227
|
+
async createNamespace(payload) {
|
|
228
|
+
const response = await this.request('POST', '/namespaces', payload);
|
|
229
|
+
return models_1.Namespace.fromJSON(response.data);
|
|
230
|
+
}
|
|
231
|
+
async updateNamespace(namespace_id, payload) {
|
|
232
|
+
const body = await this.request('PUT', `/namespaces/${namespace_id}`, payload);
|
|
233
|
+
return { message: body.message };
|
|
234
|
+
}
|
|
235
|
+
async deleteNamespace(namespace_id) {
|
|
236
|
+
const body = await this.request('DELETE', `/namespaces/${namespace_id}`);
|
|
237
|
+
return { message: body.message };
|
|
238
|
+
}
|
|
239
|
+
async updateFileNamespaces(file_id, payload) {
|
|
240
|
+
const body = await this.request('PUT', `/file/${file_id}/namespaces`, payload);
|
|
241
|
+
return {
|
|
242
|
+
message: body.message,
|
|
243
|
+
namespace_ids: body.data.namespace_ids,
|
|
244
|
+
namespaces: body.data.namespaces.map(models_1.NamespaceRef.fromJSON),
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
//endregion
|
|
147
248
|
//region --- Analysis ---
|
|
148
249
|
async analyzeVideo(payload) {
|
|
149
250
|
const response = await this.request('POST', '/analyze/video', payload);
|
|
150
251
|
return {
|
|
151
252
|
video_info: models_1.VideoInfo.fromJSON(response.data.video_info),
|
|
152
|
-
transcript: response.data.transcript
|
|
253
|
+
transcript: (0, models_1.transcriptFromJSON)(response.data.transcript),
|
|
153
254
|
transcript_analysis: models_1.AnalysisResult.fromJSON(response.data.transcript_analysis),
|
|
154
255
|
};
|
|
155
256
|
}
|
|
@@ -157,26 +258,44 @@ class VidNavigatorClient {
|
|
|
157
258
|
const response = await this.request('POST', '/analyze/file', payload);
|
|
158
259
|
return {
|
|
159
260
|
file_info: models_1.FileInfo.fromJSON(response.data.file_info),
|
|
160
|
-
transcript: response.data.transcript
|
|
261
|
+
transcript: (0, models_1.transcriptFromJSON)(response.data.transcript),
|
|
161
262
|
transcript_analysis: models_1.AnalysisResult.fromJSON(response.data.transcript_analysis),
|
|
162
263
|
};
|
|
163
264
|
}
|
|
164
265
|
//endregion
|
|
266
|
+
//region --- Extraction ---
|
|
267
|
+
async extractVideoData(payload) {
|
|
268
|
+
const body = await this.request('POST', '/extract/video', payload);
|
|
269
|
+
return {
|
|
270
|
+
data: body.data,
|
|
271
|
+
usage: body.usage ? models_1.ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
async extractFileData(payload) {
|
|
275
|
+
const body = await this.request('POST', '/extract/file', payload);
|
|
276
|
+
return {
|
|
277
|
+
data: body.data,
|
|
278
|
+
usage: body.usage ? models_1.ExtractionTokenUsage.fromJSON(body.usage) : undefined,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
//endregion
|
|
165
282
|
//region --- Search ---
|
|
166
283
|
async searchVideos(payload) {
|
|
167
284
|
const response = await this.request('POST', '/search/video', payload);
|
|
168
285
|
return {
|
|
169
286
|
results: response.data.results.map(models_1.VideoSearchResult.fromJSON),
|
|
287
|
+
query: response.data.query,
|
|
170
288
|
total_found: response.data.total_found,
|
|
171
|
-
explanation: response.data.explanation
|
|
289
|
+
explanation: response.data.explanation,
|
|
172
290
|
};
|
|
173
291
|
}
|
|
174
292
|
async searchFiles(payload) {
|
|
175
293
|
const response = await this.request('POST', '/search/file', payload);
|
|
176
294
|
return {
|
|
177
295
|
results: response.data.results.map(models_1.FileSearchResult.fromJSON),
|
|
296
|
+
query: response.data.query,
|
|
178
297
|
total_found: response.data.total_found,
|
|
179
|
-
explanation: response.data.explanation
|
|
298
|
+
explanation: response.data.explanation,
|
|
180
299
|
};
|
|
181
300
|
}
|
|
182
301
|
//endregion
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface VideoCarouselInfoJSON {
|
|
2
|
+
total_items?: number;
|
|
3
|
+
video_count?: number;
|
|
4
|
+
image_count?: number;
|
|
5
|
+
selected_index?: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class VideoCarouselInfo {
|
|
8
|
+
total_items?: number;
|
|
9
|
+
video_count?: number;
|
|
10
|
+
image_count?: number;
|
|
11
|
+
selected_index?: number;
|
|
12
|
+
constructor(data: Partial<VideoCarouselInfoJSON>);
|
|
13
|
+
static fromJSON(json: VideoCarouselInfoJSON): VideoCarouselInfo;
|
|
14
|
+
}
|
|
15
|
+
export interface CarouselInfoJSON {
|
|
16
|
+
total_items?: number;
|
|
17
|
+
video_count?: number;
|
|
18
|
+
image_count?: number;
|
|
19
|
+
transcribed_count?: number;
|
|
20
|
+
total_duration?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class CarouselInfo {
|
|
23
|
+
total_items?: number;
|
|
24
|
+
video_count?: number;
|
|
25
|
+
image_count?: number;
|
|
26
|
+
transcribed_count?: number;
|
|
27
|
+
total_duration?: number;
|
|
28
|
+
constructor(data: Partial<CarouselInfoJSON>);
|
|
29
|
+
static fromJSON(json: CarouselInfoJSON): CarouselInfo;
|
|
30
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarouselInfo = exports.VideoCarouselInfo = void 0;
|
|
4
|
+
class VideoCarouselInfo {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
Object.assign(this, data);
|
|
7
|
+
}
|
|
8
|
+
static fromJSON(json) {
|
|
9
|
+
return new VideoCarouselInfo(json);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.VideoCarouselInfo = VideoCarouselInfo;
|
|
13
|
+
class CarouselInfo {
|
|
14
|
+
constructor(data) {
|
|
15
|
+
Object.assign(this, data);
|
|
16
|
+
}
|
|
17
|
+
static fromJSON(json) {
|
|
18
|
+
return new CarouselInfo(json);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CarouselInfo = CarouselInfo;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
2
|
+
import { TranscriptOutput, TranscriptOutputJSON } from './TranscriptSegment';
|
|
3
|
+
export type { TranscriptOutputJSON };
|
|
4
|
+
export interface CarouselVideoResultJSON {
|
|
5
|
+
index?: number;
|
|
6
|
+
status?: 'success' | 'error';
|
|
7
|
+
video_info?: VideoInfoJSON;
|
|
8
|
+
transcript?: TranscriptOutputJSON;
|
|
9
|
+
error?: string;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare class CarouselVideoResult {
|
|
13
|
+
index?: number;
|
|
14
|
+
status?: 'success' | 'error';
|
|
15
|
+
video_info?: VideoInfo;
|
|
16
|
+
transcript?: TranscriptOutput;
|
|
17
|
+
error?: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
constructor(data: Partial<{
|
|
20
|
+
index?: number;
|
|
21
|
+
status?: 'success' | 'error';
|
|
22
|
+
video_info?: VideoInfo;
|
|
23
|
+
transcript?: TranscriptOutput;
|
|
24
|
+
error?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
}>);
|
|
27
|
+
static fromJSON(json: CarouselVideoResultJSON): CarouselVideoResult;
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CarouselVideoResult = void 0;
|
|
4
|
+
const VideoInfo_1 = require("./VideoInfo");
|
|
5
|
+
const TranscriptSegment_1 = require("./TranscriptSegment");
|
|
6
|
+
class CarouselVideoResult {
|
|
7
|
+
constructor(data) {
|
|
8
|
+
Object.assign(this, data);
|
|
9
|
+
}
|
|
10
|
+
static fromJSON(json) {
|
|
11
|
+
return new CarouselVideoResult({
|
|
12
|
+
index: json.index,
|
|
13
|
+
status: json.status,
|
|
14
|
+
video_info: json.video_info ? VideoInfo_1.VideoInfo.fromJSON(json.video_info) : undefined,
|
|
15
|
+
transcript: (0, TranscriptSegment_1.transcriptFromJSON)(json.transcript),
|
|
16
|
+
error: json.error,
|
|
17
|
+
message: json.message,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CarouselVideoResult = CarouselVideoResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type ExtractionFieldType = 'String' | 'Number' | 'Boolean' | 'Integer' | 'Object' | 'Array' | 'Enum';
|
|
2
|
+
export interface ExtractionField {
|
|
3
|
+
type: ExtractionFieldType;
|
|
4
|
+
description: string;
|
|
5
|
+
properties?: Record<string, ExtractionField>;
|
|
6
|
+
items?: ExtractionField;
|
|
7
|
+
enum?: string[];
|
|
8
|
+
}
|
|
9
|
+
/** Custom schema: field name -> field definition */
|
|
10
|
+
export type ExtractionSchema = Record<string, ExtractionField>;
|
|
11
|
+
export interface ExtractionTokenUsageJSON {
|
|
12
|
+
prompt_tokens?: number;
|
|
13
|
+
completion_tokens?: number;
|
|
14
|
+
total_tokens?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ExtractionResponseJSON {
|
|
17
|
+
status: 'success';
|
|
18
|
+
data: Record<string, unknown>;
|
|
19
|
+
usage?: ExtractionTokenUsageJSON;
|
|
20
|
+
}
|
|
21
|
+
export declare class ExtractionTokenUsage {
|
|
22
|
+
prompt_tokens?: number;
|
|
23
|
+
completion_tokens?: number;
|
|
24
|
+
total_tokens?: number;
|
|
25
|
+
constructor(data: ExtractionTokenUsageJSON);
|
|
26
|
+
static fromJSON(json: ExtractionTokenUsageJSON): ExtractionTokenUsage;
|
|
27
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtractionTokenUsage = void 0;
|
|
4
|
+
class ExtractionTokenUsage {
|
|
5
|
+
constructor(data) {
|
|
6
|
+
this.prompt_tokens = data.prompt_tokens;
|
|
7
|
+
this.completion_tokens = data.completion_tokens;
|
|
8
|
+
this.total_tokens = data.total_tokens;
|
|
9
|
+
}
|
|
10
|
+
static fromJSON(json) {
|
|
11
|
+
return new ExtractionTokenUsage(json);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ExtractionTokenUsage = ExtractionTokenUsage;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { NamespaceRef, NamespaceRefJSON } from './Namespace';
|
|
1
2
|
export type FileStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
2
3
|
export interface FileInfoJSON {
|
|
3
4
|
id: string;
|
|
@@ -11,6 +12,8 @@ export interface FileInfoJSON {
|
|
|
11
12
|
original_file_date?: string;
|
|
12
13
|
has_transcript?: boolean;
|
|
13
14
|
error_message?: string;
|
|
15
|
+
namespace_ids?: string[];
|
|
16
|
+
namespaces?: NamespaceRefJSON[];
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Represents the complete metadata for a file uploaded to VidNavigator.
|
|
@@ -27,6 +30,8 @@ export declare class FileInfo {
|
|
|
27
30
|
original_file_date?: string;
|
|
28
31
|
has_transcript?: boolean;
|
|
29
32
|
error_message?: string;
|
|
33
|
+
namespace_ids?: string[];
|
|
34
|
+
namespaces?: NamespaceRef[];
|
|
30
35
|
constructor(data: FileInfoJSON);
|
|
31
36
|
static fromJSON(json: FileInfoJSON): FileInfo;
|
|
32
37
|
toJSON(): FileInfoJSON;
|
package/dist/models/FileInfo.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FileInfo = void 0;
|
|
4
|
+
const Namespace_1 = require("./Namespace");
|
|
4
5
|
/**
|
|
5
6
|
* Represents the complete metadata for a file uploaded to VidNavigator.
|
|
6
7
|
*/
|
|
@@ -17,6 +18,8 @@ class FileInfo {
|
|
|
17
18
|
this.original_file_date = data.original_file_date;
|
|
18
19
|
this.has_transcript = data.has_transcript;
|
|
19
20
|
this.error_message = data.error_message;
|
|
21
|
+
this.namespace_ids = data.namespace_ids;
|
|
22
|
+
this.namespaces = data.namespaces?.map(Namespace_1.NamespaceRef.fromJSON);
|
|
20
23
|
}
|
|
21
24
|
static fromJSON(json) {
|
|
22
25
|
return new FileInfo(json);
|