@bbearai/core 0.4.3 → 0.4.5

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.mts CHANGED
@@ -3,7 +3,12 @@
3
3
  */
4
4
  type ReportType = 'bug' | 'feedback' | 'suggestion' | 'test_pass' | 'test_fail';
5
5
  type Severity = 'critical' | 'high' | 'medium' | 'low';
6
- type BugCategory = 'ui_ux' | 'functional' | 'crash' | 'security' | 'other';
6
+ /** Valid bug categories - single source of truth */
7
+ declare const BUG_CATEGORIES: readonly ["ui_ux", "functional", "crash", "security", "other"];
8
+ /** Bug category type derived from BUG_CATEGORIES */
9
+ type BugCategory = typeof BUG_CATEGORIES[number];
10
+ /** Type guard to check if a string is a valid BugCategory */
11
+ declare function isBugCategory(value: unknown): value is BugCategory;
7
12
  type ReportStatus = 'new' | 'triaging' | 'confirmed' | 'in_progress' | 'fixed' | 'ready_to_test' | 'verified' | 'resolved' | 'reviewed' | 'closed' | 'wont_fix' | 'duplicate';
8
13
  interface AppContext {
9
14
  /** Current route/screen path */
@@ -1068,4 +1073,4 @@ declare function captureError(error: Error, errorInfo?: {
1068
1073
  componentStack?: string;
1069
1074
  };
1070
1075
 
1071
- export { type AddFindingOptions, type AppContext, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, type BugCategory, type ChecklistItem, type ChecklistResult, type ConsoleLogEntry, type CoverageGap, type CoverageMatrixCell, type CoverageMatrixRow, type DeployChecklist, type DeviceInfo, type EndSessionOptions, type EnhancedBugContext, type FindingSeverity, type FindingType, type HostUserInfo, type IssueCategory, type IssueCounts, type MessageSenderType, type NetworkRequest, type PriorityFactors, type ProjectRole, type QAFinding, type QAHealthMetrics, type QAHealthScore, type QASession, type QASessionStatus, type QATrack, type RegressionEvent, type ReportStatus, type ReportType, type RoutePriority, type RouteTestStats, type RubricMode, type RubricResult, type Severity, type SkipReason, type StartSessionOptions, type SubmitFeedbackOptions, type TestAssignment, type TestFeedback, type TestGroup, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterIssue, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear };
1076
+ export { type AddFindingOptions, type AppContext, BUG_CATEGORIES, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, type BugCategory, type ChecklistItem, type ChecklistResult, type ConsoleLogEntry, type CoverageGap, type CoverageMatrixCell, type CoverageMatrixRow, type DeployChecklist, type DeviceInfo, type EndSessionOptions, type EnhancedBugContext, type FindingSeverity, type FindingType, type HostUserInfo, type IssueCategory, type IssueCounts, type MessageSenderType, type NetworkRequest, type PriorityFactors, type ProjectRole, type QAFinding, type QAHealthMetrics, type QAHealthScore, type QASession, type QASessionStatus, type QATrack, type RegressionEvent, type ReportStatus, type ReportType, type RoutePriority, type RouteTestStats, type RubricMode, type RubricResult, type Severity, type SkipReason, type StartSessionOptions, type SubmitFeedbackOptions, type TestAssignment, type TestFeedback, type TestGroup, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterIssue, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear, isBugCategory };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,12 @@
3
3
  */
4
4
  type ReportType = 'bug' | 'feedback' | 'suggestion' | 'test_pass' | 'test_fail';
5
5
  type Severity = 'critical' | 'high' | 'medium' | 'low';
6
- type BugCategory = 'ui_ux' | 'functional' | 'crash' | 'security' | 'other';
6
+ /** Valid bug categories - single source of truth */
7
+ declare const BUG_CATEGORIES: readonly ["ui_ux", "functional", "crash", "security", "other"];
8
+ /** Bug category type derived from BUG_CATEGORIES */
9
+ type BugCategory = typeof BUG_CATEGORIES[number];
10
+ /** Type guard to check if a string is a valid BugCategory */
11
+ declare function isBugCategory(value: unknown): value is BugCategory;
7
12
  type ReportStatus = 'new' | 'triaging' | 'confirmed' | 'in_progress' | 'fixed' | 'ready_to_test' | 'verified' | 'resolved' | 'reviewed' | 'closed' | 'wont_fix' | 'duplicate';
8
13
  interface AppContext {
9
14
  /** Current route/screen path */
@@ -1068,4 +1073,4 @@ declare function captureError(error: Error, errorInfo?: {
1068
1073
  componentStack?: string;
1069
1074
  };
1070
1075
 
1071
- export { type AddFindingOptions, type AppContext, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, type BugCategory, type ChecklistItem, type ChecklistResult, type ConsoleLogEntry, type CoverageGap, type CoverageMatrixCell, type CoverageMatrixRow, type DeployChecklist, type DeviceInfo, type EndSessionOptions, type EnhancedBugContext, type FindingSeverity, type FindingType, type HostUserInfo, type IssueCategory, type IssueCounts, type MessageSenderType, type NetworkRequest, type PriorityFactors, type ProjectRole, type QAFinding, type QAHealthMetrics, type QAHealthScore, type QASession, type QASessionStatus, type QATrack, type RegressionEvent, type ReportStatus, type ReportType, type RoutePriority, type RouteTestStats, type RubricMode, type RubricResult, type Severity, type SkipReason, type StartSessionOptions, type SubmitFeedbackOptions, type TestAssignment, type TestFeedback, type TestGroup, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterIssue, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear };
1076
+ export { type AddFindingOptions, type AppContext, BUG_CATEGORIES, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, type BugCategory, type ChecklistItem, type ChecklistResult, type ConsoleLogEntry, type CoverageGap, type CoverageMatrixCell, type CoverageMatrixRow, type DeployChecklist, type DeviceInfo, type EndSessionOptions, type EnhancedBugContext, type FindingSeverity, type FindingType, type HostUserInfo, type IssueCategory, type IssueCounts, type MessageSenderType, type NetworkRequest, type PriorityFactors, type ProjectRole, type QAFinding, type QAHealthMetrics, type QAHealthScore, type QASession, type QASessionStatus, type QATrack, type RegressionEvent, type ReportStatus, type ReportType, type RoutePriority, type RouteTestStats, type RubricMode, type RubricResult, type Severity, type SkipReason, type StartSessionOptions, type SubmitFeedbackOptions, type TestAssignment, type TestFeedback, type TestGroup, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterIssue, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear, isBugCategory };
package/dist/index.js CHANGED
@@ -20,13 +20,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ BUG_CATEGORIES: () => BUG_CATEGORIES,
23
24
  BugBearClient: () => BugBearClient,
24
25
  captureError: () => captureError,
25
26
  contextCapture: () => contextCapture,
26
- createBugBear: () => createBugBear
27
+ createBugBear: () => createBugBear,
28
+ isBugCategory: () => isBugCategory
27
29
  });
28
30
  module.exports = __toCommonJS(index_exports);
29
31
 
32
+ // src/types.ts
33
+ var BUG_CATEGORIES = ["ui_ux", "functional", "crash", "security", "other"];
34
+ function isBugCategory(value) {
35
+ return typeof value === "string" && BUG_CATEGORIES.includes(value);
36
+ }
37
+
30
38
  // src/client.ts
31
39
  var import_supabase_js = require("@supabase/supabase-js");
32
40
 
@@ -975,6 +983,9 @@ var BugBearClient = class {
975
983
  if (report.severity && !validSeverities.includes(report.severity)) {
976
984
  return `Invalid severity: ${report.severity}. Must be one of: ${validSeverities.join(", ")}`;
977
985
  }
986
+ if (report.category && !BUG_CATEGORIES.includes(report.category)) {
987
+ return `Invalid category: ${report.category}. Must be one of: ${BUG_CATEGORIES.join(", ")}`;
988
+ }
978
989
  if (report.title && report.title.length > 500) {
979
990
  return "Title must be 500 characters or less";
980
991
  }
@@ -1047,6 +1058,10 @@ var BugBearClient = class {
1047
1058
  });
1048
1059
  if (error) {
1049
1060
  console.warn("BugBear: Rate limit check failed, allowing request", error.message);
1061
+ this.config.onError?.(new Error(`Rate limit check failed: ${error.message}`), {
1062
+ projectId: this.config.projectId,
1063
+ context: "rate_limit_check_failed_open"
1064
+ });
1050
1065
  return { allowed: true };
1051
1066
  }
1052
1067
  if (!data.allowed) {
@@ -1063,7 +1078,12 @@ var BugBearClient = class {
1063
1078
  resetAt: data.reset_at
1064
1079
  };
1065
1080
  } catch (err) {
1081
+ const message = err instanceof Error ? err.message : "Unknown rate limit error";
1066
1082
  console.warn("BugBear: Rate limit check error", err);
1083
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1084
+ projectId: this.config.projectId,
1085
+ context: "rate_limit_check_failed_open"
1086
+ });
1067
1087
  return { allowed: true };
1068
1088
  }
1069
1089
  }
@@ -1127,6 +1147,9 @@ var BugBearClient = class {
1127
1147
  }
1128
1148
  return data ?? true;
1129
1149
  } catch (err) {
1150
+ const message = err instanceof Error ? err.message : "Unknown error checking QA status";
1151
+ console.error("BugBear: Error checking QA status", err);
1152
+ this.config.onError?.(err instanceof Error ? err : new Error(message), { projectId: this.config.projectId });
1130
1153
  return true;
1131
1154
  }
1132
1155
  }
@@ -1155,13 +1178,24 @@ var BugBearClient = class {
1155
1178
  upsert: false
1156
1179
  });
1157
1180
  if (error) {
1158
- console.error("BugBear: Failed to upload screenshot", formatPgError(error));
1181
+ const formattedError = formatPgError(error);
1182
+ const errorMessage = formattedError.message || "Failed to upload screenshot";
1183
+ console.error("BugBear: Failed to upload screenshot", formattedError);
1184
+ this.config.onError?.(new Error(errorMessage), {
1185
+ projectId: this.config.projectId,
1186
+ context: "screenshot_upload_failed"
1187
+ });
1159
1188
  return null;
1160
1189
  }
1161
1190
  const { data: { publicUrl } } = this.supabase.storage.from(bucket).getPublicUrl(path);
1162
1191
  return publicUrl;
1163
1192
  } catch (err) {
1193
+ const message = err instanceof Error ? err.message : "Unknown error uploading screenshot";
1164
1194
  console.error("BugBear: Error uploading screenshot", err);
1195
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1196
+ projectId: this.config.projectId,
1197
+ context: "screenshot_upload_failed"
1198
+ });
1165
1199
  return null;
1166
1200
  }
1167
1201
  }
@@ -1186,13 +1220,24 @@ var BugBearClient = class {
1186
1220
  upsert: false
1187
1221
  });
1188
1222
  if (error) {
1189
- console.error("BugBear: Failed to upload image from URI", formatPgError(error));
1223
+ const formattedError = formatPgError(error);
1224
+ const errorMessage = formattedError.message || "Failed to upload image";
1225
+ console.error("BugBear: Failed to upload image from URI", formattedError);
1226
+ this.config.onError?.(new Error(errorMessage), {
1227
+ projectId: this.config.projectId,
1228
+ context: "image_upload_failed"
1229
+ });
1190
1230
  return null;
1191
1231
  }
1192
1232
  const { data: { publicUrl } } = this.supabase.storage.from(bucket).getPublicUrl(path);
1193
1233
  return publicUrl;
1194
1234
  } catch (err) {
1235
+ const message = err instanceof Error ? err.message : "Unknown error uploading image";
1195
1236
  console.error("BugBear: Error uploading image from URI", err);
1237
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1238
+ projectId: this.config.projectId,
1239
+ context: "image_upload_failed"
1240
+ });
1196
1241
  return null;
1197
1242
  }
1198
1243
  }
@@ -1723,8 +1768,10 @@ function createBugBear(config) {
1723
1768
  }
1724
1769
  // Annotate the CommonJS export names for ESM import in node:
1725
1770
  0 && (module.exports = {
1771
+ BUG_CATEGORIES,
1726
1772
  BugBearClient,
1727
1773
  captureError,
1728
1774
  contextCapture,
1729
- createBugBear
1775
+ createBugBear,
1776
+ isBugCategory
1730
1777
  });
package/dist/index.mjs CHANGED
@@ -1,3 +1,9 @@
1
+ // src/types.ts
2
+ var BUG_CATEGORIES = ["ui_ux", "functional", "crash", "security", "other"];
3
+ function isBugCategory(value) {
4
+ return typeof value === "string" && BUG_CATEGORIES.includes(value);
5
+ }
6
+
1
7
  // src/client.ts
2
8
  import { createClient } from "@supabase/supabase-js";
3
9
 
@@ -946,6 +952,9 @@ var BugBearClient = class {
946
952
  if (report.severity && !validSeverities.includes(report.severity)) {
947
953
  return `Invalid severity: ${report.severity}. Must be one of: ${validSeverities.join(", ")}`;
948
954
  }
955
+ if (report.category && !BUG_CATEGORIES.includes(report.category)) {
956
+ return `Invalid category: ${report.category}. Must be one of: ${BUG_CATEGORIES.join(", ")}`;
957
+ }
949
958
  if (report.title && report.title.length > 500) {
950
959
  return "Title must be 500 characters or less";
951
960
  }
@@ -1018,6 +1027,10 @@ var BugBearClient = class {
1018
1027
  });
1019
1028
  if (error) {
1020
1029
  console.warn("BugBear: Rate limit check failed, allowing request", error.message);
1030
+ this.config.onError?.(new Error(`Rate limit check failed: ${error.message}`), {
1031
+ projectId: this.config.projectId,
1032
+ context: "rate_limit_check_failed_open"
1033
+ });
1021
1034
  return { allowed: true };
1022
1035
  }
1023
1036
  if (!data.allowed) {
@@ -1034,7 +1047,12 @@ var BugBearClient = class {
1034
1047
  resetAt: data.reset_at
1035
1048
  };
1036
1049
  } catch (err) {
1050
+ const message = err instanceof Error ? err.message : "Unknown rate limit error";
1037
1051
  console.warn("BugBear: Rate limit check error", err);
1052
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1053
+ projectId: this.config.projectId,
1054
+ context: "rate_limit_check_failed_open"
1055
+ });
1038
1056
  return { allowed: true };
1039
1057
  }
1040
1058
  }
@@ -1098,6 +1116,9 @@ var BugBearClient = class {
1098
1116
  }
1099
1117
  return data ?? true;
1100
1118
  } catch (err) {
1119
+ const message = err instanceof Error ? err.message : "Unknown error checking QA status";
1120
+ console.error("BugBear: Error checking QA status", err);
1121
+ this.config.onError?.(err instanceof Error ? err : new Error(message), { projectId: this.config.projectId });
1101
1122
  return true;
1102
1123
  }
1103
1124
  }
@@ -1126,13 +1147,24 @@ var BugBearClient = class {
1126
1147
  upsert: false
1127
1148
  });
1128
1149
  if (error) {
1129
- console.error("BugBear: Failed to upload screenshot", formatPgError(error));
1150
+ const formattedError = formatPgError(error);
1151
+ const errorMessage = formattedError.message || "Failed to upload screenshot";
1152
+ console.error("BugBear: Failed to upload screenshot", formattedError);
1153
+ this.config.onError?.(new Error(errorMessage), {
1154
+ projectId: this.config.projectId,
1155
+ context: "screenshot_upload_failed"
1156
+ });
1130
1157
  return null;
1131
1158
  }
1132
1159
  const { data: { publicUrl } } = this.supabase.storage.from(bucket).getPublicUrl(path);
1133
1160
  return publicUrl;
1134
1161
  } catch (err) {
1162
+ const message = err instanceof Error ? err.message : "Unknown error uploading screenshot";
1135
1163
  console.error("BugBear: Error uploading screenshot", err);
1164
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1165
+ projectId: this.config.projectId,
1166
+ context: "screenshot_upload_failed"
1167
+ });
1136
1168
  return null;
1137
1169
  }
1138
1170
  }
@@ -1157,13 +1189,24 @@ var BugBearClient = class {
1157
1189
  upsert: false
1158
1190
  });
1159
1191
  if (error) {
1160
- console.error("BugBear: Failed to upload image from URI", formatPgError(error));
1192
+ const formattedError = formatPgError(error);
1193
+ const errorMessage = formattedError.message || "Failed to upload image";
1194
+ console.error("BugBear: Failed to upload image from URI", formattedError);
1195
+ this.config.onError?.(new Error(errorMessage), {
1196
+ projectId: this.config.projectId,
1197
+ context: "image_upload_failed"
1198
+ });
1161
1199
  return null;
1162
1200
  }
1163
1201
  const { data: { publicUrl } } = this.supabase.storage.from(bucket).getPublicUrl(path);
1164
1202
  return publicUrl;
1165
1203
  } catch (err) {
1204
+ const message = err instanceof Error ? err.message : "Unknown error uploading image";
1166
1205
  console.error("BugBear: Error uploading image from URI", err);
1206
+ this.config.onError?.(err instanceof Error ? err : new Error(message), {
1207
+ projectId: this.config.projectId,
1208
+ context: "image_upload_failed"
1209
+ });
1167
1210
  return null;
1168
1211
  }
1169
1212
  }
@@ -1693,8 +1736,10 @@ function createBugBear(config) {
1693
1736
  return new BugBearClient(config);
1694
1737
  }
1695
1738
  export {
1739
+ BUG_CATEGORIES,
1696
1740
  BugBearClient,
1697
1741
  captureError,
1698
1742
  contextCapture,
1699
- createBugBear
1743
+ createBugBear,
1744
+ isBugCategory
1700
1745
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbearai/core",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Core utilities and types for BugBear QA platform",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",