@boldvideo/bold-js 0.4.1 → 0.4.3

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.
@@ -0,0 +1,9 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(pnpm run lint:*)",
5
+ "Bash(ls:*)"
6
+ ]
7
+ },
8
+ "enableAllProjectMcpServers": false
9
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # @boldvideo/bold-js
2
+
3
+ ## 0.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - New `has_ai` field to settings
package/CLAUDE.md ADDED
@@ -0,0 +1,76 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is the Bold JavaScript SDK (`@boldvideo/bold-js`) - a TypeScript client library for interacting with the Bold Video API. The SDK provides methods for fetching videos, playlists, channel settings, and tracking analytics events.
8
+
9
+ ## Common Development Commands
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ pnpm install
14
+
15
+ # Build the project (outputs to dist/)
16
+ pnpm run build
17
+
18
+ # Run type checking/linting
19
+ pnpm run lint
20
+
21
+ # Publish new version (uses changesets)
22
+ pnpm changeset
23
+ pnpm changeset version
24
+ pnpm changeset publish
25
+ ```
26
+
27
+ ## Architecture & Key Components
28
+
29
+ ### Client Structure
30
+ The SDK uses a factory pattern where `createClient(apiKey)` returns an object with namespaced methods:
31
+ - `bold.settings()` - Fetch channel settings
32
+ - `bold.videos.list()` / `.get(id)` / `.search(query)` - Video operations
33
+ - `bold.playlists.list()` / `.get(id)` - Playlist operations
34
+ - `bold.trackEvent()` / `bold.trackPageView()` - Analytics tracking
35
+
36
+ ### Core Files
37
+ - `/src/index.ts` - Main entry point, exports `createClient` and all types
38
+ - `/src/lib/client.ts` - Client factory that creates the Bold instance with API key auth
39
+ - `/src/lib/fetchers.ts` - Individual API endpoint implementations
40
+ - `/src/lib/tracking.ts` - Analytics event tracking with throttling
41
+ - `/src/lib/types.ts` - TypeScript interfaces for Video, Playlist, Settings, etc.
42
+ - `/src/util/throttle.ts` - Throttling utility for rate-limiting event tracking
43
+
44
+ ### Build Configuration
45
+ - Uses `tsup` for building TypeScript to both ESM and CommonJS formats
46
+ - Outputs to `/dist/` with type declarations
47
+ - TypeScript strict mode enabled
48
+ - Target: ES2016
49
+
50
+ ## Development Workflow
51
+
52
+ 1. The project uses GitHub Actions for CI/CD:
53
+ - All branches run lint and build checks
54
+ - Main branch can publish to npm using changesets
55
+
56
+ 2. When making changes:
57
+ - Ensure TypeScript types are properly defined
58
+ - Run `pnpm run lint` before committing
59
+ - The SDK supports both ESM and CommonJS consumers
60
+
61
+ 3. API Integration:
62
+ - Default base URL: `https://app.boldvideo.io/api/v1/`
63
+ - Authentication via API key in Authorization header
64
+ - All API methods return promises
65
+
66
+ 4. Analytics Tracking:
67
+ - Events are throttled to prevent API rate limiting
68
+ - User IDs are auto-generated for each client instance
69
+ - Debug mode available for development
70
+
71
+ ## Important Notes
72
+
73
+ - No test framework is currently configured
74
+ - The SDK is designed to be lightweight with minimal dependencies (only axios)
75
+ - All API responses follow the type definitions in `/src/lib/types.ts`
76
+ - The tracking system includes automatic throttling to handle high-frequency events like video progress updates
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  <div align="center">
2
- <a href="https://wearebold.af?utm_source=github.com&utm_medium=readme&utm_campaign=bold-js" align="center">
3
- <img src="https://wearebold.af/bold-js-github-header.svg" alt="Bold Logo">
2
+ <a href="https://boldvideo.com?utm_source=github.com&utm_medium=readme&utm_campaign=bold-js" align="center">
3
+ <img src="https://boldvideo.com/bold-js-github-header.svg" alt="Bold Logo">
4
4
  </a>
5
5
  <h1 align="center rainbow">@boldvideo/bold-js</h1>
6
6
  <p align="center">
7
- The JavaScript SDK for interacting with the <a href="http://wearebold.af?utm_source=github.com&utm_medium=readme&utm_campaign=bold-js" target="_blank">Bold API</a>, to power your own business video platform.
7
+ The JavaScript SDK for interacting with the <a href="https://boldvideo.com?utm_source=github.com&utm_medium=readme&utm_campaign=bold-js" target="_blank">Bold API</a>, to power your own business video platform.
8
8
  </p>
9
9
  </div>
10
10
 
package/dist/index.cjs CHANGED
@@ -72,11 +72,9 @@ __export(src_exports, {
72
72
  module.exports = __toCommonJS(src_exports);
73
73
 
74
74
  // src/lib/client.ts
75
- var import_axios2 = __toESM(require("axios"), 1);
76
- var import_js_cookie = __toESM(require("js-cookie"), 1);
75
+ var import_axios = __toESM(require("axios"), 1);
77
76
 
78
77
  // src/lib/fetchers.ts
79
- var import_axios = __toESM(require("axios"), 1);
80
78
  function get(client, url) {
81
79
  return __async(this, null, function* () {
82
80
  try {
@@ -86,16 +84,7 @@ function get(client, url) {
86
84
  }
87
85
  return res.data;
88
86
  } catch (error) {
89
- if (import_axios.default.isAxiosError(error)) {
90
- console.error("fetching error details:", {
91
- message: error.message,
92
- code: error.code,
93
- config: error.config,
94
- response: error.response
95
- });
96
- } else {
97
- console.error(`Error fetching data from URL: ${url}`, error);
98
- }
87
+ console.error(`Error fetching data from URL: ${url}`, error);
99
88
  throw error;
100
89
  }
101
90
  });
@@ -269,39 +258,26 @@ function basicInfos() {
269
258
  }
270
259
 
271
260
  // src/lib/client.ts
272
- var generateUserId = () => {
273
- return [...Array(30)].map(() => Math.random().toString(36)[2]).join("");
274
- };
275
- var getUserId = () => {
276
- const localStorageKey = "boldvideo_user_id";
277
- let userId = import_js_cookie.default.get(localStorageKey);
278
- if (!userId) {
279
- userId = generateUserId();
280
- import_js_cookie.default.set(localStorageKey, userId, { expires: 365 });
281
- }
282
- return userId;
283
- };
284
261
  function createClient(apiKey, options = { debug: false }) {
285
262
  var _a;
286
263
  if (!apiKey || typeof apiKey !== "string") {
287
264
  throw new Error("API key is missing or invalid");
288
265
  }
289
- const userId = getUserId();
290
266
  const { debug } = options;
291
267
  const apiClientOptions = {
292
268
  baseURL: (_a = options.baseURL) != null ? _a : "https://app.boldvideo.io/api/v1/",
293
269
  headers: {
294
- Authorization: apiKey,
295
- "X-User-Id": userId
270
+ Authorization: apiKey
296
271
  }
297
272
  };
298
273
  let apiClient;
299
274
  try {
300
- apiClient = import_axios2.default.create(apiClientOptions);
275
+ apiClient = import_axios.default.create(apiClientOptions);
301
276
  } catch (error) {
302
277
  console.error("Error creating API client", error);
303
278
  throw error;
304
279
  }
280
+ const userId = [...Array(30)].map(() => Math.random().toString(36)[2]).join("");
305
281
  return {
306
282
  settings: fetchSettings(apiClient),
307
283
  videos: {
package/dist/index.d.ts CHANGED
@@ -34,6 +34,9 @@ type MenuItem = {
34
34
  type Settings = {
35
35
  featured_playlists: Playlist[];
36
36
  menu_items: MenuItem[];
37
+ ai_avatar: string;
38
+ ai_name: string;
39
+ has_ai: boolean;
37
40
  meta_data: {
38
41
  channel_name: string;
39
42
  description: string;
package/dist/index.js CHANGED
@@ -39,11 +39,9 @@ var __async = (__this, __arguments, generator) => {
39
39
  };
40
40
 
41
41
  // src/lib/client.ts
42
- import axios2 from "axios";
43
- import Cookies from "js-cookie";
42
+ import axios from "axios";
44
43
 
45
44
  // src/lib/fetchers.ts
46
- import axios from "axios";
47
45
  function get(client, url) {
48
46
  return __async(this, null, function* () {
49
47
  try {
@@ -53,16 +51,7 @@ function get(client, url) {
53
51
  }
54
52
  return res.data;
55
53
  } catch (error) {
56
- if (axios.isAxiosError(error)) {
57
- console.error("fetching error details:", {
58
- message: error.message,
59
- code: error.code,
60
- config: error.config,
61
- response: error.response
62
- });
63
- } else {
64
- console.error(`Error fetching data from URL: ${url}`, error);
65
- }
54
+ console.error(`Error fetching data from URL: ${url}`, error);
66
55
  throw error;
67
56
  }
68
57
  });
@@ -236,39 +225,26 @@ function basicInfos() {
236
225
  }
237
226
 
238
227
  // src/lib/client.ts
239
- var generateUserId = () => {
240
- return [...Array(30)].map(() => Math.random().toString(36)[2]).join("");
241
- };
242
- var getUserId = () => {
243
- const localStorageKey = "boldvideo_user_id";
244
- let userId = Cookies.get(localStorageKey);
245
- if (!userId) {
246
- userId = generateUserId();
247
- Cookies.set(localStorageKey, userId, { expires: 365 });
248
- }
249
- return userId;
250
- };
251
228
  function createClient(apiKey, options = { debug: false }) {
252
229
  var _a;
253
230
  if (!apiKey || typeof apiKey !== "string") {
254
231
  throw new Error("API key is missing or invalid");
255
232
  }
256
- const userId = getUserId();
257
233
  const { debug } = options;
258
234
  const apiClientOptions = {
259
235
  baseURL: (_a = options.baseURL) != null ? _a : "https://app.boldvideo.io/api/v1/",
260
236
  headers: {
261
- Authorization: apiKey,
262
- "X-User-Id": userId
237
+ Authorization: apiKey
263
238
  }
264
239
  };
265
240
  let apiClient;
266
241
  try {
267
- apiClient = axios2.create(apiClientOptions);
242
+ apiClient = axios.create(apiClientOptions);
268
243
  } catch (error) {
269
244
  console.error("Error creating API client", error);
270
245
  throw error;
271
246
  }
247
+ const userId = [...Array(30)].map(() => Math.random().toString(36)[2]).join("");
272
248
  return {
273
249
  settings: fetchSettings(apiClient),
274
250
  videos: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@boldvideo/bold-js",
3
3
  "license": "MIT",
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,5 +17,6 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "axios": "^1.3.6"
20
- }
20
+ },
21
+ "packageManager": "pnpm@10.12.2+sha512.a32540185b964ee30bb4e979e405adc6af59226b438ee4cc19f9e8773667a66d302f5bfee60a39d3cac69e35e4b96e708a71dd002b7e9359c4112a1722ac323f"
21
22
  }
package/src/lib/types.ts CHANGED
@@ -39,6 +39,7 @@ export type Settings = {
39
39
  menu_items: MenuItem[];
40
40
  ai_avatar: string;
41
41
  ai_name: string;
42
+ has_ai: boolean;
42
43
  meta_data: {
43
44
  channel_name: string;
44
45
  description: string;