@bluecopa/core 0.1.44 → 0.1.46

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.
@@ -1,27 +1,31 @@
1
1
  import { EmailConversation } from './getAllConversations';
2
+ import { EmailAttachment } from './types';
2
3
  export interface CreateConversationRequest {
3
- toEmail: string;
4
+ toEmail: string[];
4
5
  subject: string;
5
- bodyText: string;
6
+ bodyText?: string;
6
7
  bodyHtml?: string;
7
8
  accountId: string;
8
9
  senderId: string;
9
- attachments?: {
10
- filename: string;
11
- content: string;
12
- /** snake_case to match backend API contract */
13
- content_type: string;
14
- }[];
10
+ cc?: string[];
11
+ bcc?: string[];
12
+ messagePreview?: string;
13
+ tag?: string;
14
+ attachments?: EmailAttachment[];
15
15
  }
16
16
  /**
17
17
  * Creates a new email conversation
18
18
  * @param params - The conversation data
19
- * @param params.toEmail - Required: Recipient email address
19
+ * @param params.toEmail - Required: Array of recipient email addresses
20
20
  * @param params.subject - Required: Email subject
21
- * @param params.bodyText - Required: Plain text body
21
+ * @param params.bodyText - Optional: Plain text body
22
22
  * @param params.bodyHtml - Optional: HTML body
23
23
  * @param params.accountId - Required: Account ID
24
24
  * @param params.senderId - Required: Sender email address
25
+ * @param params.cc - Optional: Array of CC email addresses
26
+ * @param params.bcc - Optional: Array of BCC email addresses
27
+ * @param params.messagePreview - Optional: Preview text for the email
28
+ * @param params.tag - Optional: Tag for categorizing the email
25
29
  * @param params.attachments - Optional: Array of attachments
26
30
  * @returns Promise<EmailConversation> The created conversation
27
31
  * @throws Error if the request fails
@@ -1,6 +1,6 @@
1
1
  export interface EmailConversation {
2
2
  id?: string;
3
- toEmail: string;
3
+ toEmail: string[];
4
4
  senderId: string;
5
5
  subject: string;
6
6
  bodyText?: string;
@@ -9,6 +9,10 @@ export interface EmailConversation {
9
9
  threadId?: string;
10
10
  lastMessageAt?: string;
11
11
  accountId: string;
12
+ cc?: string[];
13
+ bcc?: string[];
14
+ messagePreview?: string;
15
+ tag?: string;
12
16
  createdBy?: string;
13
17
  createdDate?: string;
14
18
  lastModifiedBy?: string;
@@ -1,3 +1,4 @@
1
+ export * from './types';
1
2
  export * from './getAllConversations';
2
3
  export * from './getConversation';
3
4
  export * from './createConversation';
@@ -1,15 +1,14 @@
1
+ import { EmailAttachment } from './types';
1
2
  export interface ReplyToConversationRequest {
2
3
  conversationId: string;
3
4
  accountId: string;
4
5
  senderId: string;
5
- bodyText: string;
6
+ bodyText?: string;
6
7
  bodyHtml?: string;
7
- attachments?: {
8
- filename: string;
9
- content: string;
10
- /** snake_case to match backend API contract */
11
- content_type: string;
12
- }[];
8
+ toEmail?: string[];
9
+ cc?: string[];
10
+ bcc?: string[];
11
+ attachments?: EmailAttachment[];
13
12
  }
14
13
  /**
15
14
  * Replies to an existing email conversation
@@ -17,8 +16,11 @@ export interface ReplyToConversationRequest {
17
16
  * @param params.conversationId - Required: The conversation ID to reply to
18
17
  * @param params.accountId - Required: Account ID
19
18
  * @param params.senderId - Required: Sender email address
20
- * @param params.bodyText - Required: Plain text body of the reply
19
+ * @param params.bodyText - Optional: Plain text body of the reply
21
20
  * @param params.bodyHtml - Optional: HTML body of the reply
21
+ * @param params.toEmail - Optional: Array of recipient email addresses
22
+ * @param params.cc - Optional: Array of CC email addresses
23
+ * @param params.bcc - Optional: Array of BCC email addresses
22
24
  * @param params.attachments - Optional: Array of attachments
23
25
  * @returns Promise<any> The reply response
24
26
  * @throws Error if the request fails
@@ -0,0 +1,6 @@
1
+ export interface EmailAttachment {
2
+ filename: string;
3
+ content: string;
4
+ /** snake_case to match backend API contract */
5
+ content_type: string;
6
+ }
package/dist/index.es.js CHANGED
@@ -11520,40 +11520,51 @@ async function getConversation(params) {
11520
11520
  }
11521
11521
  }
11522
11522
  async function createConversation(params) {
11523
- var _a, _b, _c, _d, _e, _f, _g, _h, _i;
11523
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
11524
11524
  try {
11525
11525
  const trimmed = {
11526
11526
  ...params,
11527
- toEmail: (_a = params.toEmail) == null ? void 0 : _a.trim(),
11527
+ toEmail: (_a = params.toEmail) == null ? void 0 : _a.map((e) => e.trim()).filter(Boolean),
11528
11528
  subject: (_b = params.subject) == null ? void 0 : _b.trim(),
11529
11529
  bodyText: (_c = params.bodyText) == null ? void 0 : _c.trim(),
11530
11530
  accountId: (_d = params.accountId) == null ? void 0 : _d.trim(),
11531
- senderId: (_e = params.senderId) == null ? void 0 : _e.trim()
11531
+ senderId: (_e = params.senderId) == null ? void 0 : _e.trim(),
11532
+ cc: (_f = params.cc) == null ? void 0 : _f.map((e) => e.trim()).filter(Boolean),
11533
+ bcc: (_g = params.bcc) == null ? void 0 : _g.map((e) => e.trim()).filter(Boolean),
11534
+ messagePreview: (_h = params.messagePreview) == null ? void 0 : _h.trim(),
11535
+ tag: (_i = params.tag) == null ? void 0 : _i.trim()
11532
11536
  };
11533
- if (!trimmed.toEmail || !trimmed.subject || !trimmed.accountId || !trimmed.senderId || !trimmed.bodyText) {
11537
+ if (!((_j = trimmed.toEmail) == null ? void 0 : _j.length) || !trimmed.subject || !trimmed.accountId || !trimmed.senderId) {
11534
11538
  throw {
11535
- message: "toEmail, subject, bodyText, accountId, and senderId are required",
11539
+ message: "toEmail (non-empty array), subject, accountId, and senderId are required",
11536
11540
  status: 400
11537
11541
  };
11538
11542
  }
11539
11543
  const response = await apiClient.post("/email/conversations", trimmed);
11540
- return ((_f = response.data) == null ? void 0 : _f.data) ?? response.data;
11544
+ return ((_k = response.data) == null ? void 0 : _k.data) ?? response.data;
11541
11545
  } catch (error) {
11542
- const message = ((_h = (_g = error.response) == null ? void 0 : _g.data) == null ? void 0 : _h.message) || error.message || "An unexpected error occurred while creating conversation";
11543
- const status = ((_i = error.response) == null ? void 0 : _i.status) || 500;
11546
+ const message = ((_m = (_l = error.response) == null ? void 0 : _l.data) == null ? void 0 : _m.message) || error.message || "An unexpected error occurred while creating conversation";
11547
+ const status = ((_n = error.response) == null ? void 0 : _n.status) || 500;
11544
11548
  throw { message, status };
11545
11549
  }
11546
11550
  }
11547
11551
  async function replyToConversation(params) {
11548
- var _a, _b, _c, _d, _e, _f, _g, _h;
11552
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
11549
11553
  try {
11550
11554
  const trimmedId = (_a = params.conversationId) == null ? void 0 : _a.trim();
11551
11555
  const trimmedAccountId = (_b = params.accountId) == null ? void 0 : _b.trim();
11552
11556
  const trimmedSenderId = (_c = params.senderId) == null ? void 0 : _c.trim();
11553
11557
  const trimmedBodyText = (_d = params.bodyText) == null ? void 0 : _d.trim();
11554
- if (!trimmedId || !trimmedAccountId || !trimmedSenderId || !trimmedBodyText) {
11558
+ const trimmedBodyHtml = (_e = params.bodyHtml) == null ? void 0 : _e.trim();
11559
+ if (!trimmedId || !trimmedAccountId || !trimmedSenderId) {
11560
+ throw {
11561
+ message: "conversationId, accountId, and senderId are required",
11562
+ status: 400
11563
+ };
11564
+ }
11565
+ if (!trimmedBodyText && !trimmedBodyHtml && !((_f = params.attachments) == null ? void 0 : _f.length)) {
11555
11566
  throw {
11556
- message: "conversationId, accountId, senderId, and bodyText are required",
11567
+ message: "At least one of bodyText, bodyHtml, or attachments is required",
11557
11568
  status: 400
11558
11569
  };
11559
11570
  }
@@ -11562,16 +11573,20 @@ async function replyToConversation(params) {
11562
11573
  conversationId: trimmedId,
11563
11574
  accountId: trimmedAccountId,
11564
11575
  senderId: trimmedSenderId,
11565
- bodyText: trimmedBodyText
11576
+ bodyText: trimmedBodyText,
11577
+ bodyHtml: trimmedBodyHtml,
11578
+ toEmail: (_g = params.toEmail) == null ? void 0 : _g.map((e) => e.trim()).filter(Boolean),
11579
+ cc: (_h = params.cc) == null ? void 0 : _h.map((e) => e.trim()).filter(Boolean),
11580
+ bcc: (_i = params.bcc) == null ? void 0 : _i.map((e) => e.trim()).filter(Boolean)
11566
11581
  };
11567
11582
  const response = await apiClient.post(
11568
11583
  `/email/conversations/${conversationId}/reply`,
11569
11584
  body
11570
11585
  );
11571
- return ((_e = response.data) == null ? void 0 : _e.data) ?? response.data;
11586
+ return ((_j = response.data) == null ? void 0 : _j.data) ?? response.data;
11572
11587
  } catch (error) {
11573
- const message = ((_g = (_f = error.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) || error.message || "An unexpected error occurred while replying to conversation";
11574
- const status = ((_h = error.response) == null ? void 0 : _h.status) || 500;
11588
+ const message = ((_l = (_k = error.response) == null ? void 0 : _k.data) == null ? void 0 : _l.message) || error.message || "An unexpected error occurred while replying to conversation";
11589
+ const status = ((_m = error.response) == null ? void 0 : _m.status) || 500;
11575
11590
  throw { message, status };
11576
11591
  }
11577
11592
  }