@bbearai/core 0.1.2 → 0.1.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.
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +44 -0
- package/dist/index.mjs +44 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -370,6 +370,19 @@ declare class BugBearClient {
|
|
|
370
370
|
* Get total unread message count across all threads
|
|
371
371
|
*/
|
|
372
372
|
getUnreadCount(): Promise<number>;
|
|
373
|
+
/**
|
|
374
|
+
* Create a new thread initiated by a tester
|
|
375
|
+
* Returns the thread ID if successful
|
|
376
|
+
*/
|
|
377
|
+
createThread(options: {
|
|
378
|
+
subject: string;
|
|
379
|
+
message: string;
|
|
380
|
+
threadType?: 'direct' | 'general_note';
|
|
381
|
+
}): Promise<{
|
|
382
|
+
success: boolean;
|
|
383
|
+
threadId?: string;
|
|
384
|
+
error?: string;
|
|
385
|
+
}>;
|
|
373
386
|
}
|
|
374
387
|
/**
|
|
375
388
|
* Create a BugBear client instance
|
package/dist/index.d.ts
CHANGED
|
@@ -370,6 +370,19 @@ declare class BugBearClient {
|
|
|
370
370
|
* Get total unread message count across all threads
|
|
371
371
|
*/
|
|
372
372
|
getUnreadCount(): Promise<number>;
|
|
373
|
+
/**
|
|
374
|
+
* Create a new thread initiated by a tester
|
|
375
|
+
* Returns the thread ID if successful
|
|
376
|
+
*/
|
|
377
|
+
createThread(options: {
|
|
378
|
+
subject: string;
|
|
379
|
+
message: string;
|
|
380
|
+
threadType?: 'direct' | 'general_note';
|
|
381
|
+
}): Promise<{
|
|
382
|
+
success: boolean;
|
|
383
|
+
threadId?: string;
|
|
384
|
+
error?: string;
|
|
385
|
+
}>;
|
|
373
386
|
}
|
|
374
387
|
/**
|
|
375
388
|
* Create a BugBear client instance
|
package/dist/index.js
CHANGED
|
@@ -526,6 +526,50 @@ var BugBearClient = class {
|
|
|
526
526
|
return 0;
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
|
+
/**
|
|
530
|
+
* Create a new thread initiated by a tester
|
|
531
|
+
* Returns the thread ID if successful
|
|
532
|
+
*/
|
|
533
|
+
async createThread(options) {
|
|
534
|
+
try {
|
|
535
|
+
const testerInfo = await this.getTesterInfo();
|
|
536
|
+
if (!testerInfo) {
|
|
537
|
+
return { success: false, error: "Not authenticated as a tester" };
|
|
538
|
+
}
|
|
539
|
+
const { data: thread, error: threadError } = await this.supabase.from("discussion_threads").insert({
|
|
540
|
+
project_id: this.config.projectId,
|
|
541
|
+
subject: options.subject,
|
|
542
|
+
thread_type: options.threadType || "direct",
|
|
543
|
+
priority: "normal",
|
|
544
|
+
audience: "selected",
|
|
545
|
+
// Tester-initiated threads go to admins
|
|
546
|
+
audience_tester_ids: [testerInfo.id],
|
|
547
|
+
// Include the tester so they can see it
|
|
548
|
+
created_by_tester_id: testerInfo.id,
|
|
549
|
+
last_message_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
550
|
+
}).select("id").single();
|
|
551
|
+
if (threadError) {
|
|
552
|
+
console.error("BugBear: Failed to create thread", threadError);
|
|
553
|
+
return { success: false, error: threadError.message };
|
|
554
|
+
}
|
|
555
|
+
const { error: messageError } = await this.supabase.from("discussion_messages").insert({
|
|
556
|
+
thread_id: thread.id,
|
|
557
|
+
sender_type: "tester",
|
|
558
|
+
sender_id: testerInfo.id,
|
|
559
|
+
sender_name: testerInfo.name,
|
|
560
|
+
content: options.message
|
|
561
|
+
});
|
|
562
|
+
if (messageError) {
|
|
563
|
+
console.error("BugBear: Failed to add initial message", messageError);
|
|
564
|
+
return { success: true, threadId: thread.id };
|
|
565
|
+
}
|
|
566
|
+
return { success: true, threadId: thread.id };
|
|
567
|
+
} catch (err) {
|
|
568
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
569
|
+
console.error("BugBear: Error creating thread", err);
|
|
570
|
+
return { success: false, error: message };
|
|
571
|
+
}
|
|
572
|
+
}
|
|
529
573
|
};
|
|
530
574
|
function createBugBear(config) {
|
|
531
575
|
return new BugBearClient(config);
|
package/dist/index.mjs
CHANGED
|
@@ -497,6 +497,50 @@ var BugBearClient = class {
|
|
|
497
497
|
return 0;
|
|
498
498
|
}
|
|
499
499
|
}
|
|
500
|
+
/**
|
|
501
|
+
* Create a new thread initiated by a tester
|
|
502
|
+
* Returns the thread ID if successful
|
|
503
|
+
*/
|
|
504
|
+
async createThread(options) {
|
|
505
|
+
try {
|
|
506
|
+
const testerInfo = await this.getTesterInfo();
|
|
507
|
+
if (!testerInfo) {
|
|
508
|
+
return { success: false, error: "Not authenticated as a tester" };
|
|
509
|
+
}
|
|
510
|
+
const { data: thread, error: threadError } = await this.supabase.from("discussion_threads").insert({
|
|
511
|
+
project_id: this.config.projectId,
|
|
512
|
+
subject: options.subject,
|
|
513
|
+
thread_type: options.threadType || "direct",
|
|
514
|
+
priority: "normal",
|
|
515
|
+
audience: "selected",
|
|
516
|
+
// Tester-initiated threads go to admins
|
|
517
|
+
audience_tester_ids: [testerInfo.id],
|
|
518
|
+
// Include the tester so they can see it
|
|
519
|
+
created_by_tester_id: testerInfo.id,
|
|
520
|
+
last_message_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
521
|
+
}).select("id").single();
|
|
522
|
+
if (threadError) {
|
|
523
|
+
console.error("BugBear: Failed to create thread", threadError);
|
|
524
|
+
return { success: false, error: threadError.message };
|
|
525
|
+
}
|
|
526
|
+
const { error: messageError } = await this.supabase.from("discussion_messages").insert({
|
|
527
|
+
thread_id: thread.id,
|
|
528
|
+
sender_type: "tester",
|
|
529
|
+
sender_id: testerInfo.id,
|
|
530
|
+
sender_name: testerInfo.name,
|
|
531
|
+
content: options.message
|
|
532
|
+
});
|
|
533
|
+
if (messageError) {
|
|
534
|
+
console.error("BugBear: Failed to add initial message", messageError);
|
|
535
|
+
return { success: true, threadId: thread.id };
|
|
536
|
+
}
|
|
537
|
+
return { success: true, threadId: thread.id };
|
|
538
|
+
} catch (err) {
|
|
539
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
540
|
+
console.error("BugBear: Error creating thread", err);
|
|
541
|
+
return { success: false, error: message };
|
|
542
|
+
}
|
|
543
|
+
}
|
|
500
544
|
};
|
|
501
545
|
function createBugBear(config) {
|
|
502
546
|
return new BugBearClient(config);
|