@boldvideo/bold-js 0.2.0 → 0.3.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/dist/index.cjs +12 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +12 -1
- package/package.json +1 -1
- package/src/index.ts +2 -3
- package/src/lib/client.ts +2 -1
- package/src/lib/fetchers.ts +11 -0
- package/tsconfig.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -115,6 +115,16 @@ function fetchVideos(client) {
|
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
|
+
function searchVideos(client) {
|
|
119
|
+
return (term) => __async(this, null, function* () {
|
|
120
|
+
try {
|
|
121
|
+
return yield get(client, `videos?query=${term}`);
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error(`Error searching for videos with term: ${term}`, error);
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
118
128
|
function fetchVideo(client) {
|
|
119
129
|
return (id) => __async(this, null, function* () {
|
|
120
130
|
try {
|
|
@@ -270,7 +280,8 @@ function createClient(apiKey, options = { debug: false }) {
|
|
|
270
280
|
settings: fetchSettings(apiClient),
|
|
271
281
|
videos: {
|
|
272
282
|
list: fetchVideos(apiClient),
|
|
273
|
-
get: fetchVideo(apiClient)
|
|
283
|
+
get: fetchVideo(apiClient),
|
|
284
|
+
search: searchVideos(apiClient)
|
|
274
285
|
},
|
|
275
286
|
playlists: {
|
|
276
287
|
list: fetchPlaylists(apiClient),
|
package/dist/index.d.ts
CHANGED
|
@@ -59,6 +59,9 @@ declare function createClient(apiKey: string, options?: ClientOptions): {
|
|
|
59
59
|
get: (id: string) => Promise<{
|
|
60
60
|
data: Video;
|
|
61
61
|
}>;
|
|
62
|
+
search: (term: string) => Promise<{
|
|
63
|
+
data: Video[];
|
|
64
|
+
}>;
|
|
62
65
|
};
|
|
63
66
|
playlists: {
|
|
64
67
|
list: () => Promise<{
|
|
@@ -72,4 +75,4 @@ declare function createClient(apiKey: string, options?: ClientOptions): {
|
|
|
72
75
|
trackPageView: (title: string) => void;
|
|
73
76
|
};
|
|
74
77
|
|
|
75
|
-
export { createClient };
|
|
78
|
+
export { MenuItem, Playlist, Settings, Video, createClient };
|
package/dist/index.js
CHANGED
|
@@ -82,6 +82,16 @@ function fetchVideos(client) {
|
|
|
82
82
|
}
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
|
+
function searchVideos(client) {
|
|
86
|
+
return (term) => __async(this, null, function* () {
|
|
87
|
+
try {
|
|
88
|
+
return yield get(client, `videos?query=${term}`);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error(`Error searching for videos with term: ${term}`, error);
|
|
91
|
+
throw error;
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
85
95
|
function fetchVideo(client) {
|
|
86
96
|
return (id) => __async(this, null, function* () {
|
|
87
97
|
try {
|
|
@@ -237,7 +247,8 @@ function createClient(apiKey, options = { debug: false }) {
|
|
|
237
247
|
settings: fetchSettings(apiClient),
|
|
238
248
|
videos: {
|
|
239
249
|
list: fetchVideos(apiClient),
|
|
240
|
-
get: fetchVideo(apiClient)
|
|
250
|
+
get: fetchVideo(apiClient),
|
|
251
|
+
search: searchVideos(apiClient)
|
|
241
252
|
},
|
|
242
253
|
playlists: {
|
|
243
254
|
list: fetchPlaylists(apiClient),
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export { createClient } from
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { createClient } from "lib/client";
|
|
2
|
+
export * from "lib/types";
|
package/src/lib/client.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import axios, { AxiosInstance } from "axios";
|
|
2
2
|
|
|
3
|
-
import { fetchVideo, fetchVideos, fetchSettings, fetchPlaylist, fetchPlaylists } from './fetchers'
|
|
3
|
+
import { fetchVideo, fetchVideos, searchVideos, fetchSettings, fetchPlaylist, fetchPlaylists } from './fetchers'
|
|
4
4
|
import { trackEvent, trackPageView } from './tracking'
|
|
5
5
|
|
|
6
6
|
type ClientOptions = {
|
|
@@ -39,6 +39,7 @@ function createClient(apiKey: string, options: ClientOptions = {debug: false}) {
|
|
|
39
39
|
videos: {
|
|
40
40
|
list: fetchVideos(apiClient),
|
|
41
41
|
get: fetchVideo(apiClient),
|
|
42
|
+
search: searchVideos(apiClient),
|
|
42
43
|
},
|
|
43
44
|
playlists: {
|
|
44
45
|
list: fetchPlaylists(apiClient),
|
package/src/lib/fetchers.ts
CHANGED
|
@@ -51,6 +51,17 @@ export function fetchVideos(client: ApiClient) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
export function searchVideos(client: ApiClient) {
|
|
55
|
+
return async (term: string) => {
|
|
56
|
+
try {
|
|
57
|
+
return await get<Response<Video[]>>(client, `videos?query=${term}`);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(`Error searching for videos with term: ${term}`, error);
|
|
60
|
+
throw error;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
export function fetchVideo(client: ApiClient) {
|
|
55
66
|
return async (id: string) => {
|
|
56
67
|
try {
|