vidnavigator 0.1.6 → 1.0.1
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 +43 -18
- package/dist/models/Usage.js +33 -11
- 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 +180 -134
- package/src/models/VideoInfo.ts +15 -2
- package/src/models/index.ts +4 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface VideoCarouselInfoJSON {
|
|
2
|
+
total_items?: number;
|
|
3
|
+
video_count?: number;
|
|
4
|
+
image_count?: number;
|
|
5
|
+
selected_index?: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class VideoCarouselInfo {
|
|
9
|
+
total_items?: number;
|
|
10
|
+
video_count?: number;
|
|
11
|
+
image_count?: number;
|
|
12
|
+
selected_index?: number;
|
|
13
|
+
|
|
14
|
+
constructor(data: Partial<VideoCarouselInfoJSON>) {
|
|
15
|
+
Object.assign(this, data);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static fromJSON(json: VideoCarouselInfoJSON): VideoCarouselInfo {
|
|
19
|
+
return new VideoCarouselInfo(json);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CarouselInfoJSON {
|
|
24
|
+
total_items?: number;
|
|
25
|
+
video_count?: number;
|
|
26
|
+
image_count?: number;
|
|
27
|
+
transcribed_count?: number;
|
|
28
|
+
total_duration?: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class CarouselInfo {
|
|
32
|
+
total_items?: number;
|
|
33
|
+
video_count?: number;
|
|
34
|
+
image_count?: number;
|
|
35
|
+
transcribed_count?: number;
|
|
36
|
+
total_duration?: number;
|
|
37
|
+
|
|
38
|
+
constructor(data: Partial<CarouselInfoJSON>) {
|
|
39
|
+
Object.assign(this, data);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
static fromJSON(json: CarouselInfoJSON): CarouselInfo {
|
|
43
|
+
return new CarouselInfo(json);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
2
|
+
import { transcriptFromJSON, TranscriptOutput, TranscriptOutputJSON } from './TranscriptSegment';
|
|
3
|
+
|
|
4
|
+
export type { TranscriptOutputJSON };
|
|
5
|
+
|
|
6
|
+
export interface CarouselVideoResultJSON {
|
|
7
|
+
index?: number;
|
|
8
|
+
status?: 'success' | 'error';
|
|
9
|
+
video_info?: VideoInfoJSON;
|
|
10
|
+
transcript?: TranscriptOutputJSON;
|
|
11
|
+
error?: string;
|
|
12
|
+
message?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class CarouselVideoResult {
|
|
16
|
+
index?: number;
|
|
17
|
+
status?: 'success' | 'error';
|
|
18
|
+
video_info?: VideoInfo;
|
|
19
|
+
transcript?: TranscriptOutput;
|
|
20
|
+
error?: string;
|
|
21
|
+
message?: string;
|
|
22
|
+
|
|
23
|
+
constructor(data: Partial<{
|
|
24
|
+
index?: number;
|
|
25
|
+
status?: 'success' | 'error';
|
|
26
|
+
video_info?: VideoInfo;
|
|
27
|
+
transcript?: TranscriptOutput;
|
|
28
|
+
error?: string;
|
|
29
|
+
message?: string;
|
|
30
|
+
}>) {
|
|
31
|
+
Object.assign(this, data);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromJSON(json: CarouselVideoResultJSON): CarouselVideoResult {
|
|
35
|
+
return new CarouselVideoResult({
|
|
36
|
+
index: json.index,
|
|
37
|
+
status: json.status,
|
|
38
|
+
video_info: json.video_info ? VideoInfo.fromJSON(json.video_info) : undefined,
|
|
39
|
+
transcript: transcriptFromJSON(json.transcript),
|
|
40
|
+
error: json.error,
|
|
41
|
+
message: json.message,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export type ExtractionFieldType =
|
|
2
|
+
| 'String'
|
|
3
|
+
| 'Number'
|
|
4
|
+
| 'Boolean'
|
|
5
|
+
| 'Integer'
|
|
6
|
+
| 'Object'
|
|
7
|
+
| 'Array'
|
|
8
|
+
| 'Enum';
|
|
9
|
+
|
|
10
|
+
export interface ExtractionField {
|
|
11
|
+
type: ExtractionFieldType;
|
|
12
|
+
description: string;
|
|
13
|
+
properties?: Record<string, ExtractionField>;
|
|
14
|
+
items?: ExtractionField;
|
|
15
|
+
enum?: string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Custom schema: field name -> field definition */
|
|
19
|
+
export type ExtractionSchema = Record<string, ExtractionField>;
|
|
20
|
+
|
|
21
|
+
export interface ExtractionTokenUsageJSON {
|
|
22
|
+
prompt_tokens?: number;
|
|
23
|
+
completion_tokens?: number;
|
|
24
|
+
total_tokens?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ExtractionResponseJSON {
|
|
28
|
+
status: 'success';
|
|
29
|
+
data: Record<string, unknown>;
|
|
30
|
+
usage?: ExtractionTokenUsageJSON;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class ExtractionTokenUsage {
|
|
34
|
+
prompt_tokens?: number;
|
|
35
|
+
completion_tokens?: number;
|
|
36
|
+
total_tokens?: number;
|
|
37
|
+
|
|
38
|
+
constructor(data: ExtractionTokenUsageJSON) {
|
|
39
|
+
this.prompt_tokens = data.prompt_tokens;
|
|
40
|
+
this.completion_tokens = data.completion_tokens;
|
|
41
|
+
this.total_tokens = data.total_tokens;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static fromJSON(json: ExtractionTokenUsageJSON): ExtractionTokenUsage {
|
|
45
|
+
return new ExtractionTokenUsage(json);
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/models/FileInfo.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { NamespaceRef, NamespaceRefJSON } from './Namespace';
|
|
2
|
+
|
|
1
3
|
export type FileStatus = 'pending' | 'processing' | 'completed' | 'failed' | 'cancelled';
|
|
2
4
|
|
|
3
5
|
export interface FileInfoJSON {
|
|
@@ -12,6 +14,8 @@ export interface FileInfoJSON {
|
|
|
12
14
|
original_file_date?: string;
|
|
13
15
|
has_transcript?: boolean;
|
|
14
16
|
error_message?: string;
|
|
17
|
+
namespace_ids?: string[];
|
|
18
|
+
namespaces?: NamespaceRefJSON[];
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
/**
|
|
@@ -29,6 +33,8 @@ export class FileInfo {
|
|
|
29
33
|
original_file_date?: string;
|
|
30
34
|
has_transcript?: boolean;
|
|
31
35
|
error_message?: string;
|
|
36
|
+
namespace_ids?: string[];
|
|
37
|
+
namespaces?: NamespaceRef[];
|
|
32
38
|
|
|
33
39
|
constructor(data: FileInfoJSON) {
|
|
34
40
|
this.id = data.id;
|
|
@@ -42,6 +48,8 @@ export class FileInfo {
|
|
|
42
48
|
this.original_file_date = data.original_file_date;
|
|
43
49
|
this.has_transcript = data.has_transcript;
|
|
44
50
|
this.error_message = data.error_message;
|
|
51
|
+
this.namespace_ids = data.namespace_ids;
|
|
52
|
+
this.namespaces = data.namespaces?.map(NamespaceRef.fromJSON);
|
|
45
53
|
}
|
|
46
54
|
|
|
47
55
|
static fromJSON(json: FileInfoJSON): FileInfo {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface NamespaceRefJSON {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class NamespaceRef {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
|
|
10
|
+
constructor(data: NamespaceRefJSON) {
|
|
11
|
+
this.id = data.id;
|
|
12
|
+
this.name = data.name;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
static fromJSON(json: NamespaceRefJSON): NamespaceRef {
|
|
16
|
+
return new NamespaceRef(json);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface NamespaceJSON {
|
|
21
|
+
id?: string;
|
|
22
|
+
_id?: string;
|
|
23
|
+
user_id?: string;
|
|
24
|
+
name: string;
|
|
25
|
+
created_at?: string;
|
|
26
|
+
updated_at?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class Namespace {
|
|
30
|
+
id?: string;
|
|
31
|
+
_id?: string;
|
|
32
|
+
user_id?: string;
|
|
33
|
+
name: string;
|
|
34
|
+
created_at?: string;
|
|
35
|
+
updated_at?: string;
|
|
36
|
+
|
|
37
|
+
constructor(data: NamespaceJSON) {
|
|
38
|
+
this.id = data.id;
|
|
39
|
+
this._id = data._id;
|
|
40
|
+
this.user_id = data.user_id;
|
|
41
|
+
this.name = data.name;
|
|
42
|
+
this.created_at = data.created_at;
|
|
43
|
+
this.updated_at = data.updated_at;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromJSON(json: NamespaceJSON): Namespace {
|
|
47
|
+
return new Namespace(json);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
toJSON(): NamespaceJSON {
|
|
51
|
+
return {
|
|
52
|
+
id: this.id,
|
|
53
|
+
_id: this._id,
|
|
54
|
+
user_id: this.user_id,
|
|
55
|
+
name: this.name,
|
|
56
|
+
created_at: this.created_at,
|
|
57
|
+
updated_at: this.updated_at,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,14 +1,34 @@
|
|
|
1
|
+
import { NamedEntity } from './AnalysisResult';
|
|
1
2
|
import { FileInfo, FileInfoJSON } from './FileInfo';
|
|
2
3
|
import { VideoInfo, VideoInfoJSON } from './VideoInfo';
|
|
3
4
|
|
|
5
|
+
export interface SearchKeySubject {
|
|
6
|
+
name?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
export interface BaseSearchResult {
|
|
5
11
|
relevance_score?: number;
|
|
6
12
|
transcript_summary?: string;
|
|
7
13
|
}
|
|
8
14
|
|
|
9
|
-
export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
|
|
15
|
+
export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
|
|
16
|
+
people?: NamedEntity[];
|
|
17
|
+
places?: NamedEntity[];
|
|
18
|
+
key_subjects?: SearchKeySubject[];
|
|
19
|
+
timestamp?: number;
|
|
20
|
+
relevant_text?: string;
|
|
21
|
+
query_relevance?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
10
24
|
export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
|
|
11
25
|
file_url?: string;
|
|
26
|
+
people?: NamedEntity[];
|
|
27
|
+
places?: NamedEntity[];
|
|
28
|
+
key_subjects?: SearchKeySubject[];
|
|
29
|
+
timestamps?: number[];
|
|
30
|
+
relevant_text?: string;
|
|
31
|
+
query_answer?: string;
|
|
12
32
|
}
|
|
13
33
|
|
|
14
34
|
/**
|
|
@@ -17,11 +37,23 @@ export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
|
|
|
17
37
|
export class VideoSearchResult extends VideoInfo implements BaseSearchResult {
|
|
18
38
|
relevance_score?: number;
|
|
19
39
|
transcript_summary?: string;
|
|
40
|
+
people?: NamedEntity[];
|
|
41
|
+
places?: NamedEntity[];
|
|
42
|
+
key_subjects?: SearchKeySubject[];
|
|
43
|
+
timestamp?: number;
|
|
44
|
+
relevant_text?: string;
|
|
45
|
+
query_relevance?: string;
|
|
20
46
|
|
|
21
47
|
constructor(data: Partial<VideoSearchResultJSON>) {
|
|
22
48
|
super(data);
|
|
23
49
|
this.relevance_score = data.relevance_score;
|
|
24
50
|
this.transcript_summary = data.transcript_summary;
|
|
51
|
+
this.people = data.people;
|
|
52
|
+
this.places = data.places;
|
|
53
|
+
this.key_subjects = data.key_subjects;
|
|
54
|
+
this.timestamp = data.timestamp;
|
|
55
|
+
this.relevant_text = data.relevant_text;
|
|
56
|
+
this.query_relevance = data.query_relevance;
|
|
25
57
|
}
|
|
26
58
|
|
|
27
59
|
static fromJSON(json: VideoSearchResultJSON): VideoSearchResult {
|
|
@@ -36,12 +68,24 @@ export class FileSearchResult extends FileInfo implements BaseSearchResult {
|
|
|
36
68
|
relevance_score?: number;
|
|
37
69
|
transcript_summary?: string;
|
|
38
70
|
file_url?: string;
|
|
71
|
+
people?: NamedEntity[];
|
|
72
|
+
places?: NamedEntity[];
|
|
73
|
+
key_subjects?: SearchKeySubject[];
|
|
74
|
+
timestamps?: number[];
|
|
75
|
+
relevant_text?: string;
|
|
76
|
+
query_answer?: string;
|
|
39
77
|
|
|
40
78
|
constructor(data: FileSearchResultJSON) {
|
|
41
79
|
super(data);
|
|
42
80
|
this.relevance_score = data.relevance_score;
|
|
43
81
|
this.transcript_summary = data.transcript_summary;
|
|
44
82
|
this.file_url = data.file_url;
|
|
83
|
+
this.people = data.people;
|
|
84
|
+
this.places = data.places;
|
|
85
|
+
this.key_subjects = data.key_subjects;
|
|
86
|
+
this.timestamps = data.timestamps;
|
|
87
|
+
this.relevant_text = data.relevant_text;
|
|
88
|
+
this.query_answer = data.query_answer;
|
|
45
89
|
}
|
|
46
90
|
|
|
47
91
|
static fromJSON(json: FileSearchResultJSON): FileSearchResult {
|
|
@@ -4,6 +4,22 @@ export interface TranscriptSegmentJSON {
|
|
|
4
4
|
end: number;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/** Transcript from API: segment array (default) or plain string when transcript_text=true */
|
|
8
|
+
export type TranscriptOutput = TranscriptSegment[] | string;
|
|
9
|
+
|
|
10
|
+
export type TranscriptOutputJSON = TranscriptSegmentJSON[] | string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Parse API transcript field (segments or plain text).
|
|
14
|
+
*/
|
|
15
|
+
export function transcriptFromJSON(
|
|
16
|
+
raw: TranscriptOutputJSON | undefined
|
|
17
|
+
): TranscriptOutput | undefined {
|
|
18
|
+
if (raw === undefined) return undefined;
|
|
19
|
+
if (typeof raw === 'string') return raw;
|
|
20
|
+
return raw.map((s) => TranscriptSegment.fromJSON(s));
|
|
21
|
+
}
|
|
22
|
+
|
|
7
23
|
/**
|
|
8
24
|
* Represents a single segment of a video or audio transcript.
|
|
9
25
|
*/
|
package/src/models/Usage.ts
CHANGED
|
@@ -1,154 +1,200 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
export type UnlimitedOrNumber = number | 'unlimited';
|
|
2
|
+
|
|
3
|
+
export interface CreditsInfoJSON {
|
|
4
|
+
monthly_total: UnlimitedOrNumber;
|
|
5
|
+
monthly_remaining: UnlimitedOrNumber;
|
|
6
|
+
purchased: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export class CreditsInfo {
|
|
10
|
+
monthly_total: UnlimitedOrNumber;
|
|
11
|
+
monthly_remaining: UnlimitedOrNumber;
|
|
12
|
+
purchased: number;
|
|
13
|
+
|
|
14
|
+
constructor(data: CreditsInfoJSON) {
|
|
15
|
+
this.monthly_total = data.monthly_total;
|
|
16
|
+
this.monthly_remaining = data.monthly_remaining;
|
|
17
|
+
this.purchased = data.purchased;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static fromJSON(data: CreditsInfoJSON): CreditsInfo {
|
|
21
|
+
return new CreditsInfo(data);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ActivityCountJSON {
|
|
26
|
+
used: number;
|
|
27
|
+
unit?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class ActivityCount {
|
|
31
|
+
used: number;
|
|
32
|
+
unit?: string;
|
|
33
|
+
|
|
34
|
+
constructor(data: ActivityCountJSON) {
|
|
35
|
+
this.used = data.used;
|
|
36
|
+
this.unit = data.unit;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static fromJSON(data: ActivityCountJSON): ActivityCount {
|
|
40
|
+
return new ActivityCount(data);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface CapacityMetricJSON {
|
|
45
|
+
used: number;
|
|
46
|
+
limit: number | 'unlimited';
|
|
47
|
+
remaining: number | 'unlimited';
|
|
48
|
+
percentage: number;
|
|
7
49
|
}
|
|
8
50
|
|
|
9
|
-
export class
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return new ServiceUsage(data);
|
|
26
|
-
}
|
|
51
|
+
export class CapacityMetric {
|
|
52
|
+
used: number;
|
|
53
|
+
limit: number | 'unlimited';
|
|
54
|
+
remaining: number | 'unlimited';
|
|
55
|
+
percentage: number;
|
|
56
|
+
|
|
57
|
+
constructor(data: CapacityMetricJSON) {
|
|
58
|
+
this.used = data.used;
|
|
59
|
+
this.limit = data.limit;
|
|
60
|
+
this.remaining = data.remaining;
|
|
61
|
+
this.percentage = data.percentage;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static fromJSON(data: CapacityMetricJSON): CapacityMetric {
|
|
65
|
+
return new CapacityMetric(data);
|
|
66
|
+
}
|
|
27
67
|
}
|
|
28
68
|
|
|
29
69
|
export interface StorageUsageJSON {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
70
|
+
used_bytes: number;
|
|
71
|
+
used_formatted: string;
|
|
72
|
+
limit_bytes: number | 'unlimited';
|
|
73
|
+
limit_formatted: string;
|
|
74
|
+
remaining_bytes: number | 'unlimited';
|
|
75
|
+
remaining_formatted: string;
|
|
76
|
+
percentage: number;
|
|
37
77
|
}
|
|
38
78
|
|
|
39
79
|
export class StorageUsage {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
80
|
+
public usedBytes: number;
|
|
81
|
+
public usedFormatted: string;
|
|
82
|
+
public limitBytes: number | 'unlimited';
|
|
83
|
+
public limitFormatted: string;
|
|
84
|
+
public remainingBytes: number | 'unlimited';
|
|
85
|
+
public remainingFormatted: string;
|
|
86
|
+
public percentage: number;
|
|
87
|
+
|
|
88
|
+
constructor(data: StorageUsageJSON) {
|
|
89
|
+
this.usedBytes = data.used_bytes;
|
|
90
|
+
this.usedFormatted = data.used_formatted;
|
|
91
|
+
this.limitBytes = data.limit_bytes;
|
|
92
|
+
this.limitFormatted = data.limit_formatted;
|
|
93
|
+
this.remainingBytes = data.remaining_bytes;
|
|
94
|
+
this.remainingFormatted = data.remaining_formatted;
|
|
95
|
+
this.percentage = data.percentage;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static fromJSON(data: StorageUsageJSON): StorageUsage {
|
|
99
|
+
return new StorageUsage(data);
|
|
100
|
+
}
|
|
61
101
|
}
|
|
62
102
|
|
|
63
103
|
export type PlanInterval = 'month' | 'year';
|
|
64
104
|
|
|
65
105
|
export interface UsageDataJSON {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
usage_period: {
|
|
107
|
+
start: string;
|
|
108
|
+
end: string;
|
|
109
|
+
};
|
|
110
|
+
billing_period: {
|
|
111
|
+
start: string;
|
|
112
|
+
end: string;
|
|
113
|
+
interval: PlanInterval;
|
|
114
|
+
};
|
|
115
|
+
subscription: {
|
|
116
|
+
plan_id: string;
|
|
117
|
+
plan_name: string;
|
|
118
|
+
interval: PlanInterval;
|
|
119
|
+
status: string;
|
|
120
|
+
cancel_at_period_end: boolean;
|
|
121
|
+
};
|
|
122
|
+
credits: CreditsInfoJSON;
|
|
123
|
+
usage: {
|
|
124
|
+
video_transcripts: ActivityCountJSON;
|
|
125
|
+
youtube_transcripts: ActivityCountJSON;
|
|
126
|
+
video_searches: ActivityCountJSON;
|
|
127
|
+
video_analyses: ActivityCountJSON;
|
|
128
|
+
video_scene_analyses: ActivityCountJSON;
|
|
129
|
+
video_uploads: ActivityCountJSON;
|
|
130
|
+
};
|
|
131
|
+
channels_indexed: CapacityMetricJSON;
|
|
132
|
+
storage: StorageUsageJSON;
|
|
133
|
+
generated_at: string;
|
|
92
134
|
}
|
|
93
135
|
|
|
94
136
|
export class UsageData {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
137
|
+
public usagePeriod: {
|
|
138
|
+
start: Date;
|
|
139
|
+
end: Date;
|
|
140
|
+
};
|
|
141
|
+
public billingPeriod: {
|
|
142
|
+
start: Date;
|
|
143
|
+
end: Date;
|
|
144
|
+
interval: PlanInterval;
|
|
145
|
+
};
|
|
146
|
+
public subscription: {
|
|
147
|
+
planId: string;
|
|
148
|
+
planName: string;
|
|
149
|
+
interval: PlanInterval;
|
|
150
|
+
status: string;
|
|
151
|
+
cancelAtPeriodEnd: boolean;
|
|
152
|
+
};
|
|
153
|
+
public credits: CreditsInfo;
|
|
154
|
+
public usage: {
|
|
155
|
+
videoTranscripts: ActivityCount;
|
|
156
|
+
youtubeTranscripts: ActivityCount;
|
|
157
|
+
videoSearches: ActivityCount;
|
|
158
|
+
videoAnalyses: ActivityCount;
|
|
159
|
+
videoSceneAnalyses: ActivityCount;
|
|
160
|
+
videoUploads: ActivityCount;
|
|
161
|
+
};
|
|
162
|
+
public channelsIndexed: CapacityMetric;
|
|
163
|
+
public storage: StorageUsage;
|
|
164
|
+
public generatedAt: Date;
|
|
165
|
+
|
|
166
|
+
constructor(data: UsageDataJSON) {
|
|
167
|
+
this.usagePeriod = {
|
|
168
|
+
start: new Date(data.usage_period.start),
|
|
169
|
+
end: new Date(data.usage_period.end),
|
|
98
170
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
171
|
+
this.billingPeriod = {
|
|
172
|
+
start: new Date(data.billing_period.start),
|
|
173
|
+
end: new Date(data.billing_period.end),
|
|
174
|
+
interval: data.billing_period.interval,
|
|
103
175
|
};
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
176
|
+
this.subscription = {
|
|
177
|
+
planId: data.subscription.plan_id,
|
|
178
|
+
planName: data.subscription.plan_name,
|
|
179
|
+
interval: data.subscription.interval,
|
|
180
|
+
status: data.subscription.status,
|
|
181
|
+
cancelAtPeriodEnd: data.subscription.cancel_at_period_end,
|
|
110
182
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
183
|
+
this.credits = CreditsInfo.fromJSON(data.credits);
|
|
184
|
+
this.usage = {
|
|
185
|
+
videoTranscripts: ActivityCount.fromJSON(data.usage.video_transcripts),
|
|
186
|
+
youtubeTranscripts: ActivityCount.fromJSON(data.usage.youtube_transcripts),
|
|
187
|
+
videoSearches: ActivityCount.fromJSON(data.usage.video_searches),
|
|
188
|
+
videoAnalyses: ActivityCount.fromJSON(data.usage.video_analyses),
|
|
189
|
+
videoSceneAnalyses: ActivityCount.fromJSON(data.usage.video_scene_analyses),
|
|
190
|
+
videoUploads: ActivityCount.fromJSON(data.usage.video_uploads),
|
|
118
191
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
start: new Date(data.billing_period.start),
|
|
129
|
-
end: new Date(data.billing_period.end),
|
|
130
|
-
interval: data.billing_period.interval,
|
|
131
|
-
};
|
|
132
|
-
this.subscription = {
|
|
133
|
-
planId: data.subscription.plan_id,
|
|
134
|
-
planName: data.subscription.plan_name,
|
|
135
|
-
interval: data.subscription.interval,
|
|
136
|
-
status: data.subscription.status,
|
|
137
|
-
cancelAtPeriodEnd: data.subscription.cancel_at_period_end,
|
|
138
|
-
};
|
|
139
|
-
this.usage = {
|
|
140
|
-
videoTranscripts: ServiceUsage.fromJSON(data.usage.video_transcripts),
|
|
141
|
-
videoSearches: ServiceUsage.fromJSON(data.usage.video_searches),
|
|
142
|
-
videoAnalyses: ServiceUsage.fromJSON(data.usage.video_analyses),
|
|
143
|
-
videoSceneAnalyses: ServiceUsage.fromJSON(data.usage.video_scene_analyses),
|
|
144
|
-
youtubeChannelsScans: ServiceUsage.fromJSON(data.usage.youtube_channels_scans),
|
|
145
|
-
videoUploads: ServiceUsage.fromJSON(data.usage.video_uploads),
|
|
146
|
-
};
|
|
147
|
-
this.storage = StorageUsage.fromJSON(data.storage);
|
|
148
|
-
this.generatedAt = new Date(data.generated_at);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
static fromJSON(data: UsageDataJSON): UsageData {
|
|
152
|
-
return new UsageData(data);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
192
|
+
this.channelsIndexed = CapacityMetric.fromJSON(data.channels_indexed);
|
|
193
|
+
this.storage = StorageUsage.fromJSON(data.storage);
|
|
194
|
+
this.generatedAt = new Date(data.generated_at);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
static fromJSON(data: UsageDataJSON): UsageData {
|
|
198
|
+
return new UsageData(data);
|
|
199
|
+
}
|
|
200
|
+
}
|