vidnavigator 0.1.2 → 0.1.4

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { VideoInfo, TranscriptSegment, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult } from './models';
2
+ import { VideoInfo, TranscriptSegment, FileInfo, AnalysisResult, VideoSearchResult, FileSearchResult, UsageData } from './models';
3
3
  export * from './models';
4
4
  export * from './errors';
5
5
  export interface SDKConfig {
@@ -43,6 +43,21 @@ export declare class VidNavigatorClient {
43
43
  file_id: string;
44
44
  message: string;
45
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
+ }>;
46
61
  analyzeVideo(payload: {
47
62
  video_url: string;
48
63
  query?: string;
@@ -78,6 +93,6 @@ export declare class VidNavigatorClient {
78
93
  total_found: number;
79
94
  explanation?: string;
80
95
  }>;
81
- getUsage(): Promise<any>;
96
+ getUsage(): Promise<UsageData>;
82
97
  healthCheck(): Promise<any>;
83
98
  }
package/dist/index.js CHANGED
@@ -124,6 +124,18 @@ class VidNavigatorClient {
124
124
  const response = await this.request('DELETE', `/file/${file_id}/delete`);
125
125
  return response.data;
126
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
+ }
127
139
  //endregion
128
140
  //region --- Analysis ---
129
141
  async analyzeVideo(payload) {
@@ -164,7 +176,7 @@ class VidNavigatorClient {
164
176
  //region --- System ---
165
177
  async getUsage() {
166
178
  const response = await this.request('GET', '/usage');
167
- return response.data;
179
+ return models_1.UsageData.fromJSON(response.data);
168
180
  }
169
181
  async healthCheck() {
170
182
  const response = await this.client.get('/health');
@@ -0,0 +1,74 @@
1
+ export interface ServiceUsageJSON {
2
+ used: number;
3
+ limit: number | 'unlimited';
4
+ remaining: number | 'unlimited';
5
+ percentage: number;
6
+ unit: string;
7
+ }
8
+ export declare class ServiceUsage {
9
+ used: number;
10
+ limit: number | 'unlimited';
11
+ remaining: number | 'unlimited';
12
+ percentage: number;
13
+ unit: string;
14
+ constructor(data: ServiceUsageJSON);
15
+ static fromJSON(data: ServiceUsageJSON): ServiceUsage;
16
+ }
17
+ export interface StorageUsageJSON {
18
+ used_bytes: number;
19
+ used_formatted: string;
20
+ limit_bytes: number | 'unlimited';
21
+ limit_formatted: string;
22
+ remaining_bytes: number | 'unlimited';
23
+ remaining_formatted: string;
24
+ percentage: number;
25
+ }
26
+ export declare class StorageUsage {
27
+ usedBytes: number;
28
+ usedFormatted: string;
29
+ limitBytes: number | 'unlimited';
30
+ limitFormatted: string;
31
+ remainingBytes: number | 'unlimited';
32
+ remainingFormatted: string;
33
+ percentage: number;
34
+ constructor(data: StorageUsageJSON);
35
+ static fromJSON(data: StorageUsageJSON): StorageUsage;
36
+ }
37
+ export interface UsageDataJSON {
38
+ current_period: {
39
+ start_date: string;
40
+ end_date: string;
41
+ };
42
+ subscription: {
43
+ plan_id: string;
44
+ plan_name: string;
45
+ };
46
+ usage: {
47
+ video_transcripts: ServiceUsageJSON;
48
+ video_searches: ServiceUsageJSON;
49
+ video_analyses: ServiceUsageJSON;
50
+ video_scene_analyses: ServiceUsageJSON;
51
+ video_uploads: ServiceUsageJSON;
52
+ };
53
+ storage: StorageUsageJSON;
54
+ }
55
+ export declare class UsageData {
56
+ currentPeriod: {
57
+ startDate: Date;
58
+ endDate: Date;
59
+ };
60
+ subscription: {
61
+ planId: string;
62
+ planName: string;
63
+ };
64
+ usage: {
65
+ videoTranscripts: ServiceUsage;
66
+ videoSearches: ServiceUsage;
67
+ videoAnalyses: ServiceUsage;
68
+ videoSceneAnalyses: ServiceUsage;
69
+ videoUploads: ServiceUsage;
70
+ };
71
+ storage: StorageUsage;
72
+ constructor(data: UsageDataJSON);
73
+ static fromJSON(data: UsageDataJSON): UsageData;
74
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UsageData = exports.StorageUsage = exports.ServiceUsage = void 0;
4
+ class ServiceUsage {
5
+ constructor(data) {
6
+ this.used = data.used;
7
+ this.limit = data.limit;
8
+ this.remaining = data.remaining;
9
+ this.percentage = data.percentage;
10
+ this.unit = data.unit;
11
+ }
12
+ static fromJSON(data) {
13
+ return new ServiceUsage(data);
14
+ }
15
+ }
16
+ exports.ServiceUsage = ServiceUsage;
17
+ class StorageUsage {
18
+ constructor(data) {
19
+ this.usedBytes = data.used_bytes;
20
+ this.usedFormatted = data.used_formatted;
21
+ this.limitBytes = data.limit_bytes;
22
+ this.limitFormatted = data.limit_formatted;
23
+ this.remainingBytes = data.remaining_bytes;
24
+ this.remainingFormatted = data.remaining_formatted;
25
+ this.percentage = data.percentage;
26
+ }
27
+ static fromJSON(data) {
28
+ return new StorageUsage(data);
29
+ }
30
+ }
31
+ exports.StorageUsage = StorageUsage;
32
+ class UsageData {
33
+ constructor(data) {
34
+ this.currentPeriod = {
35
+ startDate: new Date(data.current_period.start_date),
36
+ endDate: new Date(data.current_period.end_date),
37
+ };
38
+ this.subscription = {
39
+ planId: data.subscription.plan_id,
40
+ planName: data.subscription.plan_name,
41
+ };
42
+ this.usage = {
43
+ videoTranscripts: ServiceUsage.fromJSON(data.usage.video_transcripts),
44
+ videoSearches: ServiceUsage.fromJSON(data.usage.video_searches),
45
+ videoAnalyses: ServiceUsage.fromJSON(data.usage.video_analyses),
46
+ videoSceneAnalyses: ServiceUsage.fromJSON(data.usage.video_scene_analyses),
47
+ videoUploads: ServiceUsage.fromJSON(data.usage.video_uploads),
48
+ };
49
+ this.storage = StorageUsage.fromJSON(data.storage);
50
+ }
51
+ static fromJSON(data) {
52
+ return new UsageData(data);
53
+ }
54
+ }
55
+ exports.UsageData = UsageData;
@@ -1,5 +1,6 @@
1
- export * from './VideoInfo';
2
- export * from './TranscriptSegment';
3
- export * from './FileInfo';
4
1
  export * from './AnalysisResult';
2
+ export * from './FileInfo';
5
3
  export * from './SearchResult';
4
+ export * from './TranscriptSegment';
5
+ export * from './VideoInfo';
6
+ export * from './Usage';
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./VideoInfo"), exports);
18
- __exportStar(require("./TranscriptSegment"), exports);
19
- __exportStar(require("./FileInfo"), exports);
20
17
  __exportStar(require("./AnalysisResult"), exports);
18
+ __exportStar(require("./FileInfo"), exports);
21
19
  __exportStar(require("./SearchResult"), exports);
20
+ __exportStar(require("./TranscriptSegment"), exports);
21
+ __exportStar(require("./VideoInfo"), exports);
22
+ __exportStar(require("./Usage"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidnavigator",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Official JavaScript SDK for the VidNavigator Developer API",
5
5
  "author": "VidNavigator",
6
6
  "license": "Apache-2.0",
package/src/index.ts CHANGED
@@ -14,6 +14,8 @@ import {
14
14
  VideoSearchResultJSON,
15
15
  FileSearchResult,
16
16
  FileSearchResultJSON,
17
+ UsageData,
18
+ UsageDataJSON,
17
19
  } from './models';
18
20
  import {
19
21
  VidNavigatorError,
@@ -182,6 +184,30 @@ export class VidNavigatorClient {
182
184
  );
183
185
  return response.data;
184
186
  }
187
+
188
+ async getFileUrl(file_id: string): Promise<{ file_id: string; file_url: string }> {
189
+ const response = await this.request<ApiSuccessResponse<{ file_id: string; file_url: string }>>(
190
+ 'GET',
191
+ `/file/${file_id}/url`
192
+ );
193
+ return response.data;
194
+ }
195
+
196
+ async retryFileProcessing(file_id: string): Promise<{ file_id: string; file_name: string; file_status: string; message: string }> {
197
+ const response = await this.request<ApiSuccessResponse<{ file_id: string; file_name: string; file_status: string; message: string }>>(
198
+ 'POST',
199
+ `/file/${file_id}/retry`
200
+ );
201
+ return response.data;
202
+ }
203
+
204
+ async cancelFileUpload(file_id: string): Promise<{ file_id: string; file_name: string; message: string }> {
205
+ const response = await this.request<ApiSuccessResponse<{ file_id: string; file_name: string; message: string }>>(
206
+ 'POST',
207
+ `/file/${file_id}/cancel`
208
+ );
209
+ return response.data;
210
+ }
185
211
  //endregion
186
212
 
187
213
  //region --- Analysis ---
@@ -260,9 +286,9 @@ export class VidNavigatorClient {
260
286
  //endregion
261
287
 
262
288
  //region --- System ---
263
- async getUsage(): Promise<any> {
264
- const response = await this.request<ApiSuccessResponse<any>>('GET', '/usage');
265
- return response.data;
289
+ async getUsage(): Promise<UsageData> {
290
+ const response = await this.request<ApiSuccessResponse<UsageDataJSON>>('GET', '/usage');
291
+ return UsageData.fromJSON(response.data);
266
292
  }
267
293
 
268
294
  async healthCheck(): Promise<any> {
@@ -0,0 +1,122 @@
1
+ export interface ServiceUsageJSON {
2
+ used: number;
3
+ limit: number | 'unlimited';
4
+ remaining: number | 'unlimited';
5
+ percentage: number;
6
+ unit: string;
7
+ }
8
+
9
+ export class ServiceUsage {
10
+ public used: number;
11
+ public limit: number | 'unlimited';
12
+ public remaining: number | 'unlimited';
13
+ public percentage: number;
14
+ public unit: string;
15
+
16
+ constructor(data: ServiceUsageJSON) {
17
+ this.used = data.used;
18
+ this.limit = data.limit;
19
+ this.remaining = data.remaining;
20
+ this.percentage = data.percentage;
21
+ this.unit = data.unit;
22
+ }
23
+
24
+ static fromJSON(data: ServiceUsageJSON): ServiceUsage {
25
+ return new ServiceUsage(data);
26
+ }
27
+ }
28
+
29
+ export interface StorageUsageJSON {
30
+ used_bytes: number;
31
+ used_formatted: string;
32
+ limit_bytes: number | 'unlimited';
33
+ limit_formatted: string;
34
+ remaining_bytes: number | 'unlimited';
35
+ remaining_formatted: string;
36
+ percentage: number;
37
+ }
38
+
39
+ export class StorageUsage {
40
+ public usedBytes: number;
41
+ public usedFormatted: string;
42
+ public limitBytes: number | 'unlimited';
43
+ public limitFormatted: string;
44
+ public remainingBytes: number | 'unlimited';
45
+ public remainingFormatted: string;
46
+ public percentage: number;
47
+
48
+ constructor(data: StorageUsageJSON) {
49
+ this.usedBytes = data.used_bytes;
50
+ this.usedFormatted = data.used_formatted;
51
+ this.limitBytes = data.limit_bytes;
52
+ this.limitFormatted = data.limit_formatted;
53
+ this.remainingBytes = data.remaining_bytes;
54
+ this.remainingFormatted = data.remaining_formatted;
55
+ this.percentage = data.percentage;
56
+ }
57
+
58
+ static fromJSON(data: StorageUsageJSON): StorageUsage {
59
+ return new StorageUsage(data);
60
+ }
61
+ }
62
+
63
+ export interface UsageDataJSON {
64
+ current_period: {
65
+ start_date: string;
66
+ end_date: string;
67
+ };
68
+ subscription: {
69
+ plan_id: string;
70
+ plan_name: string;
71
+ };
72
+ usage: {
73
+ video_transcripts: ServiceUsageJSON;
74
+ video_searches: ServiceUsageJSON;
75
+ video_analyses: ServiceUsageJSON;
76
+ video_scene_analyses: ServiceUsageJSON;
77
+ video_uploads: ServiceUsageJSON;
78
+ };
79
+ storage: StorageUsageJSON;
80
+ }
81
+
82
+ export class UsageData {
83
+ public currentPeriod: {
84
+ startDate: Date;
85
+ endDate: Date;
86
+ };
87
+ public subscription: {
88
+ planId: string;
89
+ planName: string;
90
+ };
91
+ public usage: {
92
+ videoTranscripts: ServiceUsage;
93
+ videoSearches: ServiceUsage;
94
+ videoAnalyses: ServiceUsage;
95
+ videoSceneAnalyses: ServiceUsage;
96
+ videoUploads: ServiceUsage;
97
+ };
98
+ public storage: StorageUsage;
99
+
100
+ constructor(data: UsageDataJSON) {
101
+ this.currentPeriod = {
102
+ startDate: new Date(data.current_period.start_date),
103
+ endDate: new Date(data.current_period.end_date),
104
+ };
105
+ this.subscription = {
106
+ planId: data.subscription.plan_id,
107
+ planName: data.subscription.plan_name,
108
+ };
109
+ this.usage = {
110
+ videoTranscripts: ServiceUsage.fromJSON(data.usage.video_transcripts),
111
+ videoSearches: ServiceUsage.fromJSON(data.usage.video_searches),
112
+ videoAnalyses: ServiceUsage.fromJSON(data.usage.video_analyses),
113
+ videoSceneAnalyses: ServiceUsage.fromJSON(data.usage.video_scene_analyses),
114
+ videoUploads: ServiceUsage.fromJSON(data.usage.video_uploads),
115
+ };
116
+ this.storage = StorageUsage.fromJSON(data.storage);
117
+ }
118
+
119
+ static fromJSON(data: UsageDataJSON): UsageData {
120
+ return new UsageData(data);
121
+ }
122
+ }
@@ -1,5 +1,6 @@
1
- export * from './VideoInfo';
2
- export * from './TranscriptSegment';
3
- export * from './FileInfo';
4
1
  export * from './AnalysisResult';
5
- export * from './SearchResult';
2
+ export * from './FileInfo';
3
+ export * from './SearchResult';
4
+ export * from './TranscriptSegment';
5
+ export * from './VideoInfo';
6
+ export * from './Usage';