@bbearai/core 0.1.6 → 0.2.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.d.mts CHANGED
@@ -186,6 +186,10 @@ interface TestAssignment {
186
186
  track?: QATrack;
187
187
  };
188
188
  status: 'pending' | 'in_progress' | 'passed' | 'failed' | 'blocked';
189
+ /** When the assignment was started (set to in_progress) */
190
+ startedAt?: string;
191
+ /** Duration in seconds (calculated when completed) */
192
+ durationSeconds?: number;
189
193
  }
190
194
  interface TestStep {
191
195
  stepNumber: number;
@@ -213,6 +217,37 @@ interface TestResult {
213
217
  /** Overall notes */
214
218
  notes?: string;
215
219
  }
220
+ /**
221
+ * Feedback from testers about a test case
222
+ * Helps improve test quality over time
223
+ */
224
+ interface TestFeedback {
225
+ /** Overall rating (1-5 stars) */
226
+ rating: 1 | 2 | 3 | 4 | 5;
227
+ /** Optional detailed ratings */
228
+ clarityRating?: 1 | 2 | 3 | 4 | 5;
229
+ stepsRating?: 1 | 2 | 3 | 4 | 5;
230
+ relevanceRating?: 1 | 2 | 3 | 4 | 5;
231
+ /** Free-form feedback note */
232
+ feedbackNote?: string;
233
+ /** Specific improvement suggestion */
234
+ suggestedImprovement?: string;
235
+ /** Quick feedback flags */
236
+ isOutdated?: boolean;
237
+ needsMoreDetail?: boolean;
238
+ stepsUnclear?: boolean;
239
+ expectedResultUnclear?: boolean;
240
+ }
241
+ /**
242
+ * Options for submitting test feedback
243
+ */
244
+ interface SubmitFeedbackOptions {
245
+ testCaseId: string;
246
+ assignmentId?: string;
247
+ feedback: TestFeedback;
248
+ /** Time taken to complete in seconds */
249
+ timeToCompleteSeconds?: number;
250
+ }
216
251
  interface TesterInfo {
217
252
  id: string;
218
253
  name: string;
@@ -263,6 +298,271 @@ interface TesterMessage {
263
298
  name: string;
264
299
  }>;
265
300
  }
301
+ /** Priority factors breakdown for a route */
302
+ interface PriorityFactors {
303
+ bugFrequency: {
304
+ score: number;
305
+ openBugs: number;
306
+ bugs7d: number;
307
+ };
308
+ criticalSeverity: {
309
+ score: number;
310
+ critical: number;
311
+ high: number;
312
+ };
313
+ staleness: {
314
+ score: number;
315
+ daysSinceTest: number | null;
316
+ };
317
+ coverageGap: {
318
+ score: number;
319
+ testCount: number;
320
+ };
321
+ regressionRisk: {
322
+ score: number;
323
+ regressionCount: number;
324
+ };
325
+ }
326
+ /** Route priority with stats and recommendations */
327
+ interface RoutePriority {
328
+ rank: number;
329
+ route: string;
330
+ priorityScore: number;
331
+ urgency: 'critical' | 'high' | 'medium' | 'low';
332
+ stats: {
333
+ openBugs: number;
334
+ criticalBugs: number;
335
+ highBugs: number;
336
+ testCases: number;
337
+ daysSinceTest: number | null;
338
+ regressions: number;
339
+ recentBugs: number;
340
+ };
341
+ factors?: PriorityFactors;
342
+ recommendation?: string;
343
+ }
344
+ /** Coverage gap identification */
345
+ interface CoverageGap {
346
+ route: string;
347
+ severity: 'critical' | 'high' | 'medium';
348
+ type: 'untested' | 'missing_tracks' | 'stale';
349
+ details: {
350
+ missingTracks?: string[];
351
+ daysSinceTest?: number;
352
+ openBugs?: number;
353
+ criticalBugs?: number;
354
+ };
355
+ recommendation: string;
356
+ }
357
+ /** Regression event tracking */
358
+ interface RegressionEvent {
359
+ id: string;
360
+ route: string;
361
+ severity: 'critical' | 'high' | 'medium';
362
+ originalBug: {
363
+ id: string;
364
+ description: string;
365
+ resolvedAt: string;
366
+ };
367
+ newBugs: Array<{
368
+ id: string;
369
+ description: string;
370
+ severity: string;
371
+ createdAt: string;
372
+ }>;
373
+ daysSinceResolution: number;
374
+ regressionCount: number;
375
+ detectedAt: string;
376
+ }
377
+ /** Deploy checklist item */
378
+ interface ChecklistItem {
379
+ testCaseId?: string;
380
+ testKey?: string;
381
+ title: string;
382
+ route: string;
383
+ reason: string;
384
+ priority: 'P0' | 'P1' | 'P2' | 'P3';
385
+ lastTested?: string;
386
+ hasCriticalBugs?: boolean;
387
+ }
388
+ /** Deploy checklist grouped by urgency */
389
+ interface DeployChecklist {
390
+ critical: ChecklistItem[];
391
+ recommended: ChecklistItem[];
392
+ optional: ChecklistItem[];
393
+ gaps: ChecklistItem[];
394
+ }
395
+ /** QA Health metrics with trends */
396
+ interface QAHealthMetrics {
397
+ velocity: {
398
+ testsPerWeek: number;
399
+ testsCompleted: number;
400
+ trend: 'up' | 'down' | 'stable';
401
+ changePercent?: number;
402
+ };
403
+ bugDiscovery: {
404
+ bugsFound: number;
405
+ bugsPerTest: number;
406
+ criticalBugs: number;
407
+ trend: 'up' | 'down' | 'stable';
408
+ changePercent?: number;
409
+ };
410
+ resolution: {
411
+ bugsResolved: number;
412
+ avgResolutionDays: number;
413
+ trend: 'up' | 'down' | 'stable';
414
+ changePercent?: number;
415
+ };
416
+ coverage: {
417
+ routeCoverage: number;
418
+ routesWithTests: number;
419
+ totalRoutes: number;
420
+ };
421
+ testerHealth: {
422
+ activeTesters: number;
423
+ totalTesters: number;
424
+ utilizationPercent: number;
425
+ };
426
+ }
427
+ /** QA Health score with grade */
428
+ interface QAHealthScore {
429
+ score: number;
430
+ grade: 'A' | 'B' | 'C' | 'D' | 'F';
431
+ breakdown: {
432
+ coverage: number;
433
+ velocity: number;
434
+ resolution: number;
435
+ stability: number;
436
+ };
437
+ }
438
+ /** Aggregated route test statistics */
439
+ interface RouteTestStats {
440
+ id: string;
441
+ projectId: string;
442
+ route: string;
443
+ totalBugs: number;
444
+ openBugs: number;
445
+ criticalBugs: number;
446
+ highBugs: number;
447
+ resolvedBugs: number;
448
+ testCaseCount: number;
449
+ testsByTrack: Record<string, number>;
450
+ lastTestedAt: string | null;
451
+ totalTestExecutions: number;
452
+ passCount: number;
453
+ failCount: number;
454
+ passRate: number | null;
455
+ regressionCount: number;
456
+ lastRegressionAt: string | null;
457
+ bugsLast7Days: number;
458
+ bugsLast30Days: number;
459
+ priorityScore: number;
460
+ calculatedAt: string;
461
+ }
462
+ /** Coverage matrix cell */
463
+ interface CoverageMatrixCell {
464
+ testCount: number;
465
+ passCount: number;
466
+ failCount: number;
467
+ passRate: number | null;
468
+ lastTestedAt: string | null;
469
+ staleDays: number | null;
470
+ }
471
+ /** Coverage matrix row (route × tracks) */
472
+ interface CoverageMatrixRow {
473
+ route: string;
474
+ totalTests: number;
475
+ openBugs: number;
476
+ criticalBugs: number;
477
+ lastTestedAt: string | null;
478
+ tracks: Record<string, CoverageMatrixCell>;
479
+ }
480
+ /** Session status */
481
+ type QASessionStatus = 'active' | 'paused' | 'completed' | 'abandoned';
482
+ /** Finding type - lighter than a bug report */
483
+ type FindingType = 'bug' | 'concern' | 'suggestion' | 'question';
484
+ /** Finding severity - includes observation for non-issues */
485
+ type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'observation';
486
+ /** QA Session - exploratory testing session */
487
+ interface QASession {
488
+ id: string;
489
+ projectId: string;
490
+ testerId: string;
491
+ /** Area being explored */
492
+ focusArea?: string;
493
+ /** QA track focus */
494
+ track?: string;
495
+ /** Platform being tested */
496
+ platform?: string;
497
+ /** Timing */
498
+ startedAt: string;
499
+ endedAt?: string;
500
+ /** Session notes */
501
+ notes?: string;
502
+ /** Routes visited during session */
503
+ routesCovered: string[];
504
+ /** Status */
505
+ status: QASessionStatus;
506
+ /** Metrics */
507
+ durationMinutes?: number;
508
+ findingsCount: number;
509
+ bugsFiled: number;
510
+ createdAt: string;
511
+ updatedAt: string;
512
+ }
513
+ /** QA Finding - quick observation during a session */
514
+ interface QAFinding {
515
+ id: string;
516
+ sessionId: string;
517
+ projectId: string;
518
+ /** Type of finding */
519
+ type: FindingType;
520
+ /** Severity level */
521
+ severity: FindingSeverity;
522
+ /** Content */
523
+ title: string;
524
+ description?: string;
525
+ /** Context (auto-captured) */
526
+ route?: string;
527
+ screenshotUrl?: string;
528
+ consoleLogs?: ConsoleLogEntry[];
529
+ networkSnapshot?: NetworkRequest[];
530
+ deviceInfo?: DeviceInfo;
531
+ appContext?: AppContext;
532
+ /** Conversion tracking */
533
+ convertedToBugId?: string;
534
+ convertedToTestId?: string;
535
+ /** Dismissal */
536
+ dismissed: boolean;
537
+ dismissedReason?: string;
538
+ dismissedAt?: string;
539
+ createdAt: string;
540
+ updatedAt: string;
541
+ }
542
+ /** Options for starting a QA session */
543
+ interface StartSessionOptions {
544
+ focusArea?: string;
545
+ track?: string;
546
+ platform?: string;
547
+ }
548
+ /** Options for ending a QA session */
549
+ interface EndSessionOptions {
550
+ notes?: string;
551
+ routesCovered?: string[];
552
+ }
553
+ /** Options for adding a finding */
554
+ interface AddFindingOptions {
555
+ type: FindingType;
556
+ title: string;
557
+ description?: string;
558
+ severity?: FindingSeverity;
559
+ route?: string;
560
+ screenshotUrl?: string;
561
+ consoleLogs?: ConsoleLogEntry[];
562
+ networkSnapshot?: NetworkRequest[];
563
+ deviceInfo?: DeviceInfo;
564
+ appContext?: AppContext;
565
+ }
266
566
 
267
567
  /**
268
568
  * BugBear Client
@@ -301,11 +601,69 @@ declare class BugBearClient {
301
601
  * First looks up the tester by email, then fetches their assignments
302
602
  */
303
603
  getAssignedTests(): Promise<TestAssignment[]>;
604
+ /**
605
+ * Get assignment by ID with time tracking fields
606
+ */
607
+ getAssignment(assignmentId: string): Promise<(TestAssignment & {
608
+ startedAt?: string;
609
+ durationSeconds?: number;
610
+ }) | null>;
611
+ /**
612
+ * Update assignment status with automatic time tracking
613
+ * - Sets started_at when status changes to 'in_progress'
614
+ * - Calculates duration_seconds when status changes to 'passed'/'failed'/'blocked'
615
+ * - Optionally include feedback when completing a test
616
+ */
617
+ updateAssignmentStatus(assignmentId: string, status: TestAssignment['status'], options?: {
618
+ notes?: string;
619
+ testResult?: TestResult;
620
+ /** Include feedback when completing the test */
621
+ feedback?: TestFeedback;
622
+ }): Promise<{
623
+ success: boolean;
624
+ error?: string;
625
+ durationSeconds?: number;
626
+ }>;
627
+ /**
628
+ * Submit feedback on a test case to help improve test quality
629
+ * This empowers testers to shape better tests over time
630
+ */
631
+ submitTestFeedback(options: SubmitFeedbackOptions): Promise<{
632
+ success: boolean;
633
+ error?: string;
634
+ }>;
635
+ /**
636
+ * Get the currently active (in_progress) assignment for the tester
637
+ */
638
+ getActiveAssignment(): Promise<(TestAssignment & {
639
+ startedAt?: string;
640
+ }) | null>;
304
641
  /**
305
642
  * Get current tester info
306
643
  * Looks up tester by email from the host app's authenticated user
644
+ * Checks both primary email AND additional_emails array
645
+ * Uses parameterized RPC function to prevent SQL injection
307
646
  */
308
647
  getTesterInfo(): Promise<TesterInfo | null>;
648
+ /**
649
+ * Basic email format validation (defense in depth)
650
+ */
651
+ private isValidEmail;
652
+ /**
653
+ * Validate report input before submission
654
+ * Returns error message if invalid, null if valid
655
+ */
656
+ private validateReport;
657
+ /**
658
+ * Validate profile update input
659
+ * Returns error message if invalid, null if valid
660
+ */
661
+ private validateProfileUpdate;
662
+ /**
663
+ * Check rate limit for an action
664
+ * Returns { allowed: boolean, error?: string, remaining?: number }
665
+ */
666
+ private checkRateLimit;
309
667
  /**
310
668
  * Update tester profile
311
669
  * Allows testers to update their name, additional emails, avatar, and platforms
@@ -406,6 +764,69 @@ declare class BugBearClient {
406
764
  threadId?: string;
407
765
  error?: string;
408
766
  }>;
767
+ /**
768
+ * Start a new QA session for exploratory testing
769
+ */
770
+ startSession(options?: StartSessionOptions): Promise<{
771
+ success: boolean;
772
+ session?: QASession;
773
+ error?: string;
774
+ }>;
775
+ /**
776
+ * End the current QA session
777
+ */
778
+ endSession(sessionId: string, options?: EndSessionOptions): Promise<{
779
+ success: boolean;
780
+ session?: QASession;
781
+ error?: string;
782
+ }>;
783
+ /**
784
+ * Get the current active session for the tester
785
+ */
786
+ getActiveSession(): Promise<QASession | null>;
787
+ /**
788
+ * Get a session by ID
789
+ */
790
+ getSession(sessionId: string): Promise<QASession | null>;
791
+ /**
792
+ * Get session history for the tester
793
+ */
794
+ getSessionHistory(limit?: number): Promise<QASession[]>;
795
+ /**
796
+ * Add a finding during a session
797
+ */
798
+ addFinding(sessionId: string, options: AddFindingOptions): Promise<{
799
+ success: boolean;
800
+ finding?: QAFinding;
801
+ error?: string;
802
+ }>;
803
+ /**
804
+ * Get findings for a session
805
+ */
806
+ getSessionFindings(sessionId: string): Promise<QAFinding[]>;
807
+ /**
808
+ * Convert a finding to a bug report
809
+ */
810
+ convertFindingToBug(findingId: string): Promise<{
811
+ success: boolean;
812
+ bugId?: string;
813
+ error?: string;
814
+ }>;
815
+ /**
816
+ * Dismiss a finding
817
+ */
818
+ dismissFinding(findingId: string, reason?: string): Promise<{
819
+ success: boolean;
820
+ error?: string;
821
+ }>;
822
+ /**
823
+ * Transform database session to QASession type
824
+ */
825
+ private transformSession;
826
+ /**
827
+ * Transform database finding to QAFinding type
828
+ */
829
+ private transformFinding;
409
830
  }
410
831
  /**
411
832
  * Create a BugBear client instance
@@ -467,4 +888,4 @@ declare function captureError(error: Error, errorInfo?: {
467
888
  componentStack?: string;
468
889
  };
469
890
 
470
- export { type AppContext, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, type ChecklistResult, type ConsoleLogEntry, type DeviceInfo, type EnhancedBugContext, type HostUserInfo, type MessageSenderType, type NetworkRequest, type QATrack, type ReportStatus, type ReportType, type RubricMode, type RubricResult, type Severity, type TestAssignment, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear };
891
+ export { type AddFindingOptions, type AppContext, BugBearClient, type BugBearConfig, type BugBearReport, type BugBearTheme, 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 MessageSenderType, type NetworkRequest, type PriorityFactors, 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 StartSessionOptions, type SubmitFeedbackOptions, type TestAssignment, type TestFeedback, type TestResult, type TestStep, type TestTemplate, type TesterInfo, type TesterMessage, type TesterProfileUpdate, type TesterThread, type ThreadPriority, type ThreadType, captureError, contextCapture, createBugBear };