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.
Files changed (38) hide show
  1. package/README.md +375 -77
  2. package/dist/errors.d.ts +19 -0
  3. package/dist/errors.js +35 -1
  4. package/dist/index.d.ts +110 -20
  5. package/dist/index.js +150 -31
  6. package/dist/models/Carousel.d.ts +30 -0
  7. package/dist/models/Carousel.js +21 -0
  8. package/dist/models/CarouselVideoResult.d.ts +28 -0
  9. package/dist/models/CarouselVideoResult.js +21 -0
  10. package/dist/models/Extraction.d.ts +27 -0
  11. package/dist/models/Extraction.js +14 -0
  12. package/dist/models/FileInfo.d.ts +5 -0
  13. package/dist/models/FileInfo.js +3 -0
  14. package/dist/models/Namespace.d.ts +29 -0
  15. package/dist/models/Namespace.js +37 -0
  16. package/dist/models/SearchResult.d.ts +29 -0
  17. package/dist/models/SearchResult.js +12 -0
  18. package/dist/models/TranscriptSegment.d.ts +7 -0
  19. package/dist/models/TranscriptSegment.js +11 -0
  20. package/dist/models/Usage.d.ts +68 -22
  21. package/dist/models/Usage.js +45 -13
  22. package/dist/models/VideoInfo.d.ts +6 -1
  23. package/dist/models/VideoInfo.js +9 -1
  24. package/dist/models/index.d.ts +4 -0
  25. package/dist/models/index.js +4 -0
  26. package/package.json +1 -1
  27. package/src/errors.ts +43 -0
  28. package/src/index.ts +450 -114
  29. package/src/models/Carousel.ts +45 -0
  30. package/src/models/CarouselVideoResult.ts +44 -0
  31. package/src/models/Extraction.ts +47 -0
  32. package/src/models/FileInfo.ts +8 -0
  33. package/src/models/Namespace.ts +60 -0
  34. package/src/models/SearchResult.ts +45 -1
  35. package/src/models/TranscriptSegment.ts +16 -0
  36. package/src/models/Usage.ts +183 -105
  37. package/src/models/VideoInfo.ts +15 -2
  38. package/src/models/index.ts +4 -0
@@ -0,0 +1,29 @@
1
+ export interface NamespaceRefJSON {
2
+ id: string;
3
+ name: string;
4
+ }
5
+ export declare class NamespaceRef {
6
+ id: string;
7
+ name: string;
8
+ constructor(data: NamespaceRefJSON);
9
+ static fromJSON(json: NamespaceRefJSON): NamespaceRef;
10
+ }
11
+ export interface NamespaceJSON {
12
+ id?: string;
13
+ _id?: string;
14
+ user_id?: string;
15
+ name: string;
16
+ created_at?: string;
17
+ updated_at?: string;
18
+ }
19
+ export declare class Namespace {
20
+ id?: string;
21
+ _id?: string;
22
+ user_id?: string;
23
+ name: string;
24
+ created_at?: string;
25
+ updated_at?: string;
26
+ constructor(data: NamespaceJSON);
27
+ static fromJSON(json: NamespaceJSON): Namespace;
28
+ toJSON(): NamespaceJSON;
29
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Namespace = exports.NamespaceRef = void 0;
4
+ class NamespaceRef {
5
+ constructor(data) {
6
+ this.id = data.id;
7
+ this.name = data.name;
8
+ }
9
+ static fromJSON(json) {
10
+ return new NamespaceRef(json);
11
+ }
12
+ }
13
+ exports.NamespaceRef = NamespaceRef;
14
+ class Namespace {
15
+ constructor(data) {
16
+ this.id = data.id;
17
+ this._id = data._id;
18
+ this.user_id = data.user_id;
19
+ this.name = data.name;
20
+ this.created_at = data.created_at;
21
+ this.updated_at = data.updated_at;
22
+ }
23
+ static fromJSON(json) {
24
+ return new Namespace(json);
25
+ }
26
+ toJSON() {
27
+ return {
28
+ id: this.id,
29
+ _id: this._id,
30
+ user_id: this.user_id,
31
+ name: this.name,
32
+ created_at: this.created_at,
33
+ updated_at: this.updated_at,
34
+ };
35
+ }
36
+ }
37
+ exports.Namespace = Namespace;
@@ -1,13 +1,30 @@
1
+ import { NamedEntity } from './AnalysisResult';
1
2
  import { FileInfo, FileInfoJSON } from './FileInfo';
2
3
  import { VideoInfo, VideoInfoJSON } from './VideoInfo';
4
+ export interface SearchKeySubject {
5
+ name?: string;
6
+ description?: string;
7
+ }
3
8
  export interface BaseSearchResult {
4
9
  relevance_score?: number;
5
10
  transcript_summary?: string;
6
11
  }
7
12
  export interface VideoSearchResultJSON extends VideoInfoJSON, BaseSearchResult {
13
+ people?: NamedEntity[];
14
+ places?: NamedEntity[];
15
+ key_subjects?: SearchKeySubject[];
16
+ timestamp?: number;
17
+ relevant_text?: string;
18
+ query_relevance?: string;
8
19
  }
9
20
  export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
10
21
  file_url?: string;
22
+ people?: NamedEntity[];
23
+ places?: NamedEntity[];
24
+ key_subjects?: SearchKeySubject[];
25
+ timestamps?: number[];
26
+ relevant_text?: string;
27
+ query_answer?: string;
11
28
  }
12
29
  /**
13
30
  * Represents a single video result from a search query.
@@ -15,6 +32,12 @@ export interface FileSearchResultJSON extends FileInfoJSON, BaseSearchResult {
15
32
  export declare class VideoSearchResult extends VideoInfo implements BaseSearchResult {
16
33
  relevance_score?: number;
17
34
  transcript_summary?: string;
35
+ people?: NamedEntity[];
36
+ places?: NamedEntity[];
37
+ key_subjects?: SearchKeySubject[];
38
+ timestamp?: number;
39
+ relevant_text?: string;
40
+ query_relevance?: string;
18
41
  constructor(data: Partial<VideoSearchResultJSON>);
19
42
  static fromJSON(json: VideoSearchResultJSON): VideoSearchResult;
20
43
  }
@@ -25,6 +48,12 @@ export declare class FileSearchResult extends FileInfo implements BaseSearchResu
25
48
  relevance_score?: number;
26
49
  transcript_summary?: string;
27
50
  file_url?: string;
51
+ people?: NamedEntity[];
52
+ places?: NamedEntity[];
53
+ key_subjects?: SearchKeySubject[];
54
+ timestamps?: number[];
55
+ relevant_text?: string;
56
+ query_answer?: string;
28
57
  constructor(data: FileSearchResultJSON);
29
58
  static fromJSON(json: FileSearchResultJSON): FileSearchResult;
30
59
  }
@@ -11,6 +11,12 @@ class VideoSearchResult extends VideoInfo_1.VideoInfo {
11
11
  super(data);
12
12
  this.relevance_score = data.relevance_score;
13
13
  this.transcript_summary = data.transcript_summary;
14
+ this.people = data.people;
15
+ this.places = data.places;
16
+ this.key_subjects = data.key_subjects;
17
+ this.timestamp = data.timestamp;
18
+ this.relevant_text = data.relevant_text;
19
+ this.query_relevance = data.query_relevance;
14
20
  }
15
21
  static fromJSON(json) {
16
22
  return new VideoSearchResult(json);
@@ -26,6 +32,12 @@ class FileSearchResult extends FileInfo_1.FileInfo {
26
32
  this.relevance_score = data.relevance_score;
27
33
  this.transcript_summary = data.transcript_summary;
28
34
  this.file_url = data.file_url;
35
+ this.people = data.people;
36
+ this.places = data.places;
37
+ this.key_subjects = data.key_subjects;
38
+ this.timestamps = data.timestamps;
39
+ this.relevant_text = data.relevant_text;
40
+ this.query_answer = data.query_answer;
29
41
  }
30
42
  static fromJSON(json) {
31
43
  return new FileSearchResult(json);
@@ -3,6 +3,13 @@ export interface TranscriptSegmentJSON {
3
3
  start: number;
4
4
  end: number;
5
5
  }
6
+ /** Transcript from API: segment array (default) or plain string when transcript_text=true */
7
+ export type TranscriptOutput = TranscriptSegment[] | string;
8
+ export type TranscriptOutputJSON = TranscriptSegmentJSON[] | string;
9
+ /**
10
+ * Parse API transcript field (segments or plain text).
11
+ */
12
+ export declare function transcriptFromJSON(raw: TranscriptOutputJSON | undefined): TranscriptOutput | undefined;
6
13
  /**
7
14
  * Represents a single segment of a video or audio transcript.
8
15
  */
@@ -1,6 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TranscriptSegment = void 0;
4
+ exports.transcriptFromJSON = transcriptFromJSON;
5
+ /**
6
+ * Parse API transcript field (segments or plain text).
7
+ */
8
+ function transcriptFromJSON(raw) {
9
+ if (raw === undefined)
10
+ return undefined;
11
+ if (typeof raw === 'string')
12
+ return raw;
13
+ return raw.map((s) => TranscriptSegment.fromJSON(s));
14
+ }
4
15
  /**
5
16
  * Represents a single segment of a video or audio transcript.
6
17
  */
@@ -1,18 +1,39 @@
1
- export interface ServiceUsageJSON {
1
+ export type UnlimitedOrNumber = number | 'unlimited';
2
+ export interface CreditsInfoJSON {
3
+ monthly_total: UnlimitedOrNumber;
4
+ monthly_remaining: UnlimitedOrNumber;
5
+ purchased: number;
6
+ }
7
+ export declare class CreditsInfo {
8
+ monthly_total: UnlimitedOrNumber;
9
+ monthly_remaining: UnlimitedOrNumber;
10
+ purchased: number;
11
+ constructor(data: CreditsInfoJSON);
12
+ static fromJSON(data: CreditsInfoJSON): CreditsInfo;
13
+ }
14
+ export interface ActivityCountJSON {
15
+ used: number;
16
+ unit?: string;
17
+ }
18
+ export declare class ActivityCount {
19
+ used: number;
20
+ unit?: string;
21
+ constructor(data: ActivityCountJSON);
22
+ static fromJSON(data: ActivityCountJSON): ActivityCount;
23
+ }
24
+ export interface CapacityMetricJSON {
2
25
  used: number;
3
26
  limit: number | 'unlimited';
4
27
  remaining: number | 'unlimited';
5
28
  percentage: number;
6
- unit: string;
7
29
  }
8
- export declare class ServiceUsage {
30
+ export declare class CapacityMetric {
9
31
  used: number;
10
32
  limit: number | 'unlimited';
11
33
  remaining: number | 'unlimited';
12
34
  percentage: number;
13
- unit: string;
14
- constructor(data: ServiceUsageJSON);
15
- static fromJSON(data: ServiceUsageJSON): ServiceUsage;
35
+ constructor(data: CapacityMetricJSON);
36
+ static fromJSON(data: CapacityMetricJSON): CapacityMetric;
16
37
  }
17
38
  export interface StorageUsageJSON {
18
39
  used_bytes: number;
@@ -34,41 +55,66 @@ export declare class StorageUsage {
34
55
  constructor(data: StorageUsageJSON);
35
56
  static fromJSON(data: StorageUsageJSON): StorageUsage;
36
57
  }
58
+ export type PlanInterval = 'month' | 'year';
37
59
  export interface UsageDataJSON {
38
- current_period: {
39
- start_date: string;
40
- end_date: string;
60
+ usage_period: {
61
+ start: string;
62
+ end: string;
63
+ };
64
+ billing_period: {
65
+ start: string;
66
+ end: string;
67
+ interval: PlanInterval;
41
68
  };
42
69
  subscription: {
43
70
  plan_id: string;
44
71
  plan_name: string;
72
+ interval: PlanInterval;
73
+ status: string;
74
+ cancel_at_period_end: boolean;
45
75
  };
76
+ credits: CreditsInfoJSON;
46
77
  usage: {
47
- video_transcripts: ServiceUsageJSON;
48
- video_searches: ServiceUsageJSON;
49
- video_analyses: ServiceUsageJSON;
50
- video_scene_analyses: ServiceUsageJSON;
51
- video_uploads: ServiceUsageJSON;
78
+ video_transcripts: ActivityCountJSON;
79
+ youtube_transcripts: ActivityCountJSON;
80
+ video_searches: ActivityCountJSON;
81
+ video_analyses: ActivityCountJSON;
82
+ video_scene_analyses: ActivityCountJSON;
83
+ video_uploads: ActivityCountJSON;
52
84
  };
85
+ channels_indexed: CapacityMetricJSON;
53
86
  storage: StorageUsageJSON;
87
+ generated_at: string;
54
88
  }
55
89
  export declare class UsageData {
56
- currentPeriod: {
57
- startDate: Date;
58
- endDate: Date;
90
+ usagePeriod: {
91
+ start: Date;
92
+ end: Date;
93
+ };
94
+ billingPeriod: {
95
+ start: Date;
96
+ end: Date;
97
+ interval: PlanInterval;
59
98
  };
60
99
  subscription: {
61
100
  planId: string;
62
101
  planName: string;
102
+ interval: PlanInterval;
103
+ status: string;
104
+ cancelAtPeriodEnd: boolean;
63
105
  };
106
+ credits: CreditsInfo;
64
107
  usage: {
65
- videoTranscripts: ServiceUsage;
66
- videoSearches: ServiceUsage;
67
- videoAnalyses: ServiceUsage;
68
- videoSceneAnalyses: ServiceUsage;
69
- videoUploads: ServiceUsage;
108
+ videoTranscripts: ActivityCount;
109
+ youtubeTranscripts: ActivityCount;
110
+ videoSearches: ActivityCount;
111
+ videoAnalyses: ActivityCount;
112
+ videoSceneAnalyses: ActivityCount;
113
+ videoUploads: ActivityCount;
70
114
  };
115
+ channelsIndexed: CapacityMetric;
71
116
  storage: StorageUsage;
117
+ generatedAt: Date;
72
118
  constructor(data: UsageDataJSON);
73
119
  static fromJSON(data: UsageDataJSON): UsageData;
74
120
  }
@@ -1,19 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsageData = exports.StorageUsage = exports.ServiceUsage = void 0;
4
- class ServiceUsage {
3
+ exports.UsageData = exports.StorageUsage = exports.CapacityMetric = exports.ActivityCount = exports.CreditsInfo = void 0;
4
+ class CreditsInfo {
5
+ constructor(data) {
6
+ this.monthly_total = data.monthly_total;
7
+ this.monthly_remaining = data.monthly_remaining;
8
+ this.purchased = data.purchased;
9
+ }
10
+ static fromJSON(data) {
11
+ return new CreditsInfo(data);
12
+ }
13
+ }
14
+ exports.CreditsInfo = CreditsInfo;
15
+ class ActivityCount {
16
+ constructor(data) {
17
+ this.used = data.used;
18
+ this.unit = data.unit;
19
+ }
20
+ static fromJSON(data) {
21
+ return new ActivityCount(data);
22
+ }
23
+ }
24
+ exports.ActivityCount = ActivityCount;
25
+ class CapacityMetric {
5
26
  constructor(data) {
6
27
  this.used = data.used;
7
28
  this.limit = data.limit;
8
29
  this.remaining = data.remaining;
9
30
  this.percentage = data.percentage;
10
- this.unit = data.unit;
11
31
  }
12
32
  static fromJSON(data) {
13
- return new ServiceUsage(data);
33
+ return new CapacityMetric(data);
14
34
  }
15
35
  }
16
- exports.ServiceUsage = ServiceUsage;
36
+ exports.CapacityMetric = CapacityMetric;
17
37
  class StorageUsage {
18
38
  constructor(data) {
19
39
  this.usedBytes = data.used_bytes;
@@ -31,22 +51,34 @@ class StorageUsage {
31
51
  exports.StorageUsage = StorageUsage;
32
52
  class UsageData {
33
53
  constructor(data) {
34
- this.currentPeriod = {
35
- startDate: new Date(data.current_period.start_date),
36
- endDate: new Date(data.current_period.end_date),
54
+ this.usagePeriod = {
55
+ start: new Date(data.usage_period.start),
56
+ end: new Date(data.usage_period.end),
57
+ };
58
+ this.billingPeriod = {
59
+ start: new Date(data.billing_period.start),
60
+ end: new Date(data.billing_period.end),
61
+ interval: data.billing_period.interval,
37
62
  };
38
63
  this.subscription = {
39
64
  planId: data.subscription.plan_id,
40
65
  planName: data.subscription.plan_name,
66
+ interval: data.subscription.interval,
67
+ status: data.subscription.status,
68
+ cancelAtPeriodEnd: data.subscription.cancel_at_period_end,
41
69
  };
70
+ this.credits = CreditsInfo.fromJSON(data.credits);
42
71
  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),
72
+ videoTranscripts: ActivityCount.fromJSON(data.usage.video_transcripts),
73
+ youtubeTranscripts: ActivityCount.fromJSON(data.usage.youtube_transcripts),
74
+ videoSearches: ActivityCount.fromJSON(data.usage.video_searches),
75
+ videoAnalyses: ActivityCount.fromJSON(data.usage.video_analyses),
76
+ videoSceneAnalyses: ActivityCount.fromJSON(data.usage.video_scene_analyses),
77
+ videoUploads: ActivityCount.fromJSON(data.usage.video_uploads),
48
78
  };
79
+ this.channelsIndexed = CapacityMetric.fromJSON(data.channels_indexed);
49
80
  this.storage = StorageUsage.fromJSON(data.storage);
81
+ this.generatedAt = new Date(data.generated_at);
50
82
  }
51
83
  static fromJSON(data) {
52
84
  return new UsageData(data);
@@ -1,3 +1,4 @@
1
+ import { VideoCarouselInfo, VideoCarouselInfoJSON } from './Carousel';
1
2
  export interface VideoInfoJSON {
2
3
  title?: string;
3
4
  description?: string;
@@ -13,6 +14,7 @@ export interface VideoInfoJSON {
13
14
  category?: string;
14
15
  available_languages?: string[];
15
16
  selected_language?: string;
17
+ carousel_info?: VideoCarouselInfoJSON;
16
18
  }
17
19
  /**
18
20
  * Represents detailed information about a video, typically from an online source like YouTube.
@@ -32,7 +34,10 @@ export declare class VideoInfo {
32
34
  category?: string;
33
35
  available_languages?: string[];
34
36
  selected_language?: string;
35
- constructor(data: Partial<VideoInfoJSON>);
37
+ carousel_info?: VideoCarouselInfo;
38
+ constructor(data: Partial<VideoInfoJSON> & {
39
+ carousel_info?: VideoCarouselInfo | VideoCarouselInfoJSON;
40
+ });
36
41
  /**
37
42
  * Creates a VideoInfo instance from a JSON object.
38
43
  * @param json - The raw JSON object from the API.
@@ -1,12 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VideoInfo = void 0;
4
+ const Carousel_1 = require("./Carousel");
4
5
  /**
5
6
  * Represents detailed information about a video, typically from an online source like YouTube.
6
7
  */
7
8
  class VideoInfo {
8
9
  constructor(data) {
9
- Object.assign(this, data);
10
+ const { carousel_info, ...rest } = data;
11
+ Object.assign(this, rest);
12
+ if (carousel_info !== undefined) {
13
+ this.carousel_info =
14
+ carousel_info instanceof Carousel_1.VideoCarouselInfo
15
+ ? carousel_info
16
+ : Carousel_1.VideoCarouselInfo.fromJSON(carousel_info);
17
+ }
10
18
  }
11
19
  /**
12
20
  * Creates a VideoInfo instance from a JSON object.
@@ -1,5 +1,9 @@
1
1
  export * from './AnalysisResult';
2
+ export * from './Carousel';
3
+ export * from './CarouselVideoResult';
4
+ export * from './Extraction';
2
5
  export * from './FileInfo';
6
+ export * from './Namespace';
3
7
  export * from './SearchResult';
4
8
  export * from './TranscriptSegment';
5
9
  export * from './VideoInfo';
@@ -15,7 +15,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./AnalysisResult"), exports);
18
+ __exportStar(require("./Carousel"), exports);
19
+ __exportStar(require("./CarouselVideoResult"), exports);
20
+ __exportStar(require("./Extraction"), exports);
18
21
  __exportStar(require("./FileInfo"), exports);
22
+ __exportStar(require("./Namespace"), exports);
19
23
  __exportStar(require("./SearchResult"), exports);
20
24
  __exportStar(require("./TranscriptSegment"), exports);
21
25
  __exportStar(require("./VideoInfo"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vidnavigator",
3
- "version": "0.1.5",
3
+ "version": "1.0.0",
4
4
  "description": "Official JavaScript SDK for the VidNavigator Developer API",
5
5
  "author": "VidNavigator",
6
6
  "license": "Apache-2.0",
package/src/errors.ts CHANGED
@@ -104,4 +104,47 @@ export class ServerError extends VidNavigatorError {
104
104
  this.name = 'ServerError';
105
105
  Object.setPrototypeOf(this, ServerError.prototype);
106
106
  }
107
+ }
108
+
109
+ /**
110
+ * Raised when storage quota is exceeded (HTTP 413).
111
+ */
112
+ export class StorageQuotaExceededError extends VidNavigatorError {
113
+ constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
114
+ super(message, status_code, error_code, error_message, details);
115
+ this.name = 'StorageQuotaExceededError';
116
+ Object.setPrototypeOf(this, StorageQuotaExceededError.prototype);
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Raised when content is not available in the user's region (HTTP 451).
122
+ */
123
+ export class GeoRestrictedError extends VidNavigatorError {
124
+ constructor(message: string, status_code?: number, error_code?: string, error_message?: string, details?: any) {
125
+ super(message, status_code, error_code, error_message, details);
126
+ this.name = 'GeoRestrictedError';
127
+ Object.setPrototypeOf(this, GeoRestrictedError.prototype);
128
+ }
129
+ }
130
+
131
+ /**
132
+ * Raised when the system is temporarily overloaded (HTTP 503), e.g. extraction overload.
133
+ */
134
+ export class SystemOverloadError extends VidNavigatorError {
135
+ public readonly retry_after_seconds?: number;
136
+
137
+ constructor(
138
+ message: string,
139
+ status_code?: number,
140
+ error_code?: string,
141
+ error_message?: string,
142
+ details?: any,
143
+ retry_after_seconds?: number
144
+ ) {
145
+ super(message, status_code, error_code, error_message, details);
146
+ this.name = 'SystemOverloadError';
147
+ this.retry_after_seconds = retry_after_seconds;
148
+ Object.setPrototypeOf(this, SystemOverloadError.prototype);
149
+ }
107
150
  }