@workhive/api 1.3.4 → 1.4.0

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.
Files changed (105) hide show
  1. package/dist/client.d.ts +141 -6
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +228 -12
  4. package/dist/context.d.ts +103 -3
  5. package/dist/context.d.ts.map +1 -1
  6. package/dist/hooks/index.d.ts +24 -1
  7. package/dist/hooks/index.d.ts.map +1 -1
  8. package/dist/hooks/index.js +20 -1
  9. package/dist/hooks/use-billing-status.d.ts +7 -0
  10. package/dist/hooks/use-billing-status.d.ts.map +1 -0
  11. package/dist/hooks/use-billing-status.js +17 -0
  12. package/dist/hooks/use-card.d.ts +2 -0
  13. package/dist/hooks/use-card.d.ts.map +1 -0
  14. package/dist/hooks/use-card.js +12 -0
  15. package/dist/hooks/use-cards.d.ts +5 -0
  16. package/dist/hooks/use-cards.d.ts.map +1 -0
  17. package/dist/hooks/use-cards.js +12 -0
  18. package/dist/hooks/use-create-card.d.ts +10 -0
  19. package/dist/hooks/use-create-card.d.ts.map +1 -0
  20. package/dist/hooks/use-create-card.js +13 -0
  21. package/dist/hooks/use-delete-card.d.ts +15 -0
  22. package/dist/hooks/use-delete-card.d.ts.map +1 -0
  23. package/dist/hooks/use-delete-card.js +38 -0
  24. package/dist/hooks/use-email-drafts.d.ts +32 -0
  25. package/dist/hooks/use-email-drafts.d.ts.map +1 -0
  26. package/dist/hooks/use-email-drafts.js +98 -0
  27. package/dist/hooks/use-gmail-connection-members.d.ts +2 -0
  28. package/dist/hooks/use-gmail-connection-members.d.ts.map +1 -0
  29. package/dist/hooks/use-gmail-connection-members.js +13 -0
  30. package/dist/hooks/use-gmail-connections.d.ts +5 -0
  31. package/dist/hooks/use-gmail-connections.d.ts.map +1 -0
  32. package/dist/hooks/use-gmail-connections.js +21 -0
  33. package/dist/hooks/use-gmail-messages.d.ts +2 -0
  34. package/dist/hooks/use-gmail-messages.d.ts.map +1 -0
  35. package/dist/hooks/use-gmail-messages.js +13 -0
  36. package/dist/hooks/use-gmail-signature.d.ts +2 -0
  37. package/dist/hooks/use-gmail-signature.d.ts.map +1 -0
  38. package/dist/hooks/use-gmail-signature.js +12 -0
  39. package/dist/hooks/use-gmail-thread-search-infinite.d.ts +2 -0
  40. package/dist/hooks/use-gmail-thread-search-infinite.d.ts.map +1 -0
  41. package/dist/hooks/use-gmail-thread-search-infinite.js +21 -0
  42. package/dist/hooks/use-gmail-thread-search.d.ts +2 -0
  43. package/dist/hooks/use-gmail-thread-search.d.ts.map +1 -0
  44. package/dist/hooks/use-gmail-thread-search.js +12 -0
  45. package/dist/hooks/use-gmail-threads-infinite.d.ts +5 -0
  46. package/dist/hooks/use-gmail-threads-infinite.d.ts.map +1 -0
  47. package/dist/hooks/use-gmail-threads-infinite.js +24 -0
  48. package/dist/hooks/use-gmail-threads.d.ts +7 -0
  49. package/dist/hooks/use-gmail-threads.d.ts.map +1 -0
  50. package/dist/hooks/use-gmail-threads.js +23 -0
  51. package/dist/hooks/use-inbox-badge-count.d.ts +6 -0
  52. package/dist/hooks/use-inbox-badge-count.d.ts.map +1 -0
  53. package/dist/hooks/use-inbox-badge-count.js +17 -0
  54. package/dist/hooks/use-inbox-thread-search.d.ts +2 -0
  55. package/dist/hooks/use-inbox-thread-search.d.ts.map +1 -0
  56. package/dist/hooks/use-inbox-thread-search.js +12 -0
  57. package/dist/hooks/use-inbox-threads-infinite.d.ts.map +1 -1
  58. package/dist/hooks/use-inbox-threads-infinite.js +1 -0
  59. package/dist/hooks/use-link-gmail-thread-contact.d.ts +7 -0
  60. package/dist/hooks/use-link-gmail-thread-contact.d.ts.map +1 -0
  61. package/dist/hooks/use-link-gmail-thread-contact.js +15 -0
  62. package/dist/hooks/use-manage-gmail-connection-members.d.ts +13 -0
  63. package/dist/hooks/use-manage-gmail-connection-members.d.ts.map +1 -0
  64. package/dist/hooks/use-manage-gmail-connection-members.js +25 -0
  65. package/dist/hooks/use-mark-inbox-thread-read.d.ts +3 -1
  66. package/dist/hooks/use-mark-inbox-thread-read.d.ts.map +1 -1
  67. package/dist/hooks/use-mark-inbox-thread-read.js +36 -14
  68. package/dist/hooks/use-mark-inbox-thread-unread.d.ts +3 -1
  69. package/dist/hooks/use-mark-inbox-thread-unread.d.ts.map +1 -1
  70. package/dist/hooks/use-mark-inbox-thread-unread.js +37 -14
  71. package/dist/hooks/use-me.d.ts.map +1 -1
  72. package/dist/hooks/use-me.js +2 -1
  73. package/dist/hooks/use-message-snippets.d.ts +1 -1
  74. package/dist/hooks/use-message-snippets.d.ts.map +1 -1
  75. package/dist/hooks/use-message-snippets.js +4 -3
  76. package/dist/hooks/use-missed-unseen-count.d.ts +8 -0
  77. package/dist/hooks/use-missed-unseen-count.d.ts.map +1 -0
  78. package/dist/hooks/use-missed-unseen-count.js +19 -0
  79. package/dist/hooks/use-patch-card.d.ts +15 -0
  80. package/dist/hooks/use-patch-card.d.ts.map +1 -0
  81. package/dist/hooks/use-patch-card.js +48 -0
  82. package/dist/hooks/use-phone-number.d.ts.map +1 -1
  83. package/dist/hooks/use-phone-number.js +2 -1
  84. package/dist/hooks/use-phone-numbers.d.ts.map +1 -1
  85. package/dist/hooks/use-phone-numbers.js +2 -1
  86. package/dist/hooks/use-send-gmail-message.d.ts +6 -0
  87. package/dist/hooks/use-send-gmail-message.d.ts.map +1 -0
  88. package/dist/hooks/use-send-gmail-message.js +21 -0
  89. package/dist/hooks/use-send-inbox-message.d.ts.map +1 -1
  90. package/dist/hooks/use-send-inbox-message.js +16 -13
  91. package/dist/hooks/use-tasks.d.ts +4 -0
  92. package/dist/hooks/use-tasks.d.ts.map +1 -1
  93. package/dist/hooks/use-tasks.js +14 -2
  94. package/dist/hooks/use-update-inbox-thread-status.d.ts +3 -1
  95. package/dist/hooks/use-update-inbox-thread-status.d.ts.map +1 -1
  96. package/dist/hooks/use-update-inbox-thread-status.js +36 -14
  97. package/dist/index.d.ts +5 -5
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +3 -3
  100. package/dist/query-keys.d.ts +58 -0
  101. package/dist/query-keys.d.ts.map +1 -1
  102. package/dist/query-keys.js +50 -0
  103. package/dist/types.d.ts +370 -14
  104. package/dist/types.d.ts.map +1 -1
  105. package/package.json +1 -1
package/dist/client.d.ts CHANGED
@@ -2,11 +2,17 @@
2
2
  * WorkHive API client – base URL + auth, methods for each route.
3
3
  * Used by both SaaS and mobile; mobile passes EXPO_PUBLIC_API_URL and Supabase getToken.
4
4
  */
5
- import type { LeadSubmissionsResponse, ContactLeadSubmissionsResponse, TaskListItem, Meeting, MeetingAttachment, MeetingCallOutcome, CreateMeetingPayload, MeetingOutcomePayload, PipelineCard, PostMeetingBookedPromptResponse, Pipeline, PipelineStage, TeamMembersResponse, MeResponse, RescheduleMeetingPayload, GetAvailabilitySlotsParams, GetAvailabilitySlotsResponse, EventType, PhoneNumberRecord, PhoneNumbersResponse, UpdatePhoneNumberBody, InboxThreadsResponse, InboxMessagesResponse, InboxCallsResponse, InboxCallEvent, CreateInboxCallPayload, VoiceTokenResponse, UploadInboxMediaResponse, SendInboxMessagePayload, SendInboxMessageResponse, MessageSnippet, MessageSnippetsResponse, CreateMessageSnippetPayload, UpdateMessageSnippetPayload, InboxGifsResponse } from './types';
5
+ import type { LeadSubmissionsResponse, ContactLeadSubmissionsResponse, TaskListItem, CreateTaskInput, Meeting, MeetingAttachment, MeetingCallOutcome, CreateMeetingPayload, MeetingOutcomePayload, PipelineCard, PipelineCardsResponse, CreateCardPayload, PostMeetingBookedPromptResponse, Pipeline, PipelineStage, TeamMembersResponse, MeResponse, RescheduleMeetingPayload, GetAvailabilitySlotsParams, GetAvailabilitySlotsResponse, EventType, PhoneNumberRecord, PhoneNumbersResponse, UpdatePhoneNumberBody, InboxThreadsResponse, InboxMessagesResponse, InboxCallsResponse, InboxCallEvent, CreateInboxCallPayload, MissedUnseenCountResponse, InboxBadgeCountResponse, VoiceTokenResponse, UploadInboxMediaResponse, SendInboxMessagePayload, SendInboxMessageResponse, MessageSnippet, MessageSnippetsResponse, CreateMessageSnippetPayload, UpdateMessageSnippetPayload, InboxGifsResponse, MeOrganizationBilling, SeatUpdateResponse, RegisterPushTokenPayload, RegisterPushTokenResponse, UnregisterPushTokenResponse, GmailConnectionsResponse, GmailConnectionMember, GmailThreadsPageResponse, InboxMessagesResponse as GmailMessagesResponse, SendGmailMessagePayload, SendGmailMessageResponse, GmailSignatureResponse, LinkGmailThreadContactPayload, LinkGmailThreadContactResponse, GmailThreadSearchResponse, InboxThreadSearchResponse, CreateEmailDraftPayload, UpdateEmailDraftPayload, CreateEmailDraftResponse, EmailDraftsListResponse } from './types';
6
6
  export type ApiClientConfig = {
7
7
  baseURL: string;
8
8
  getToken: () => Promise<string | null>;
9
9
  };
10
+ /** Thrown when `fetch` returns a non-OK response; includes HTTP status for callers (e.g. 402 insufficient credits). */
11
+ export declare class ApiRequestError extends Error {
12
+ readonly status: number;
13
+ readonly body: unknown;
14
+ constructor(status: number, message: string, body?: unknown);
15
+ }
10
16
  export declare function createApiClient(config: ApiClientConfig): {
11
17
  getLeadSubmissions(params?: {
12
18
  tab?: "calls" | "texting" | "no-tasks";
@@ -15,12 +21,21 @@ export declare function createApiClient(config: ApiClientConfig): {
15
21
  offset?: number;
16
22
  status?: "potential" | "qualified" | "disqualified";
17
23
  formId?: string;
24
+ /** When set, OR-match any of these form ids (takes precedence over formId). */
25
+ formIds?: string[];
18
26
  ownerIds?: string[];
27
+ setterIds?: string[];
19
28
  pipelineIds?: string[];
20
29
  search?: string;
21
30
  sortBy?: "date" | "status" | "next_task";
22
31
  sortOrder?: "asc" | "desc";
23
32
  showArchivedOnly?: boolean;
33
+ allPipelines?: boolean;
34
+ taskType?: string;
35
+ dueDateFilter?: string;
36
+ /** IANA timezone for calendar-based due filters (`due-today`, `due-this-week`). */
37
+ dueDateTimezone?: string;
38
+ showCompletedOnly?: boolean;
24
39
  }): Promise<LeadSubmissionsResponse>;
25
40
  getContactLeadSubmissions(contactId: string): Promise<ContactLeadSubmissionsResponse>;
26
41
  getContactMeetings(contactId: string): Promise<{
@@ -30,6 +45,7 @@ export declare function createApiClient(config: ApiClientConfig): {
30
45
  getTasks(params?: {
31
46
  status?: string;
32
47
  related_card_id?: string;
48
+ contact_id?: string;
33
49
  limit?: number;
34
50
  offset?: number;
35
51
  sort_by?: string;
@@ -37,6 +53,9 @@ export declare function createApiClient(config: ApiClientConfig): {
37
53
  }): Promise<{
38
54
  tasks: TaskListItem[];
39
55
  }>;
56
+ createTask(body: CreateTaskInput): Promise<{
57
+ task: TaskListItem;
58
+ }>;
40
59
  /** POST /api/tasks/[taskId]/outcome – record call/chat outcome */
41
60
  postTaskOutcome(taskId: string, body: {
42
61
  outcomeType: string;
@@ -59,12 +78,28 @@ export declare function createApiClient(config: ApiClientConfig): {
59
78
  getMeeting(meetingId: string): Promise<{
60
79
  meeting: Meeting;
61
80
  }>;
62
- getCard(pipelineId: string, cardId: string): Promise<{
81
+ getPipelineCards(pipelineId: string, params?: {
82
+ showArchivedOnly?: boolean;
83
+ }, opts?: {
84
+ signal?: AbortSignal;
85
+ }): Promise<PipelineCardsResponse>;
86
+ getCard(pipelineId: string, cardId: string, opts?: {
87
+ signal?: AbortSignal;
88
+ }): Promise<{
63
89
  card: PipelineCard;
64
90
  }>;
65
91
  patchCard(pipelineId: string, cardId: string, body: Record<string, unknown>): Promise<{
66
92
  card: PipelineCard;
67
93
  }>;
94
+ createCard(pipelineId: string, body: CreateCardPayload): Promise<{
95
+ card: PipelineCard;
96
+ message: string;
97
+ }>;
98
+ deleteCard(pipelineId: string, cardId: string, action?: "archive" | "delete"): Promise<{
99
+ success: boolean;
100
+ message: string;
101
+ card?: PipelineCard;
102
+ }>;
68
103
  getPostMeetingBookedPrompt(cardId: string, pipelineId: string): Promise<PostMeetingBookedPromptResponse & {
69
104
  scenario?: string | null;
70
105
  }>;
@@ -157,22 +192,29 @@ export declare function createApiClient(config: ApiClientConfig): {
157
192
  getPhoneNumber(phoneNumberId: string): Promise<{
158
193
  phone_number: PhoneNumberRecord;
159
194
  }>;
160
- /** PATCH /api/phone-numbers/[id] – update phone number (admin/owner only). Includes call_recording_transcribe_enabled. */
195
+ /** PATCH /api/phone-numbers/[id] – update phone number (admin/owner only). Includes call_recording_enabled and call_recording_transcribe_enabled. */
161
196
  patchPhoneNumber(phoneNumberId: string, body: UpdatePhoneNumberBody): Promise<{
162
197
  phone_number: PhoneNumberRecord;
163
198
  }>;
164
199
  /** DELETE /api/phone-numbers/[id] – remove phone number (admin/owner only; no assignments). */
165
200
  deletePhoneNumber(phoneNumberId: string): Promise<void>;
166
201
  /** POST /api/phone-numbers/[id]/voice-token – Twilio Voice Access Token for Device SDK. */
167
- postVoiceToken(phoneNumberId: string): Promise<VoiceTokenResponse>;
202
+ postVoiceToken(phoneNumberId: string, mode?: "incoming" | "outbound"): Promise<VoiceTokenResponse>;
168
203
  /** POST /api/phone-numbers/[id]/upload-media – upload files for outbound MMS; returns signed URLs + attachment metadata. */
169
204
  uploadInboxMedia(phoneNumberId: string, formData: FormData): Promise<UploadInboxMediaResponse>;
170
- /** List conversation threads for an inbox (phone number). Optional status filter: active (Open) or archived (Done). Supports cursor pagination via limit and cursor. */
205
+ /** List conversation threads for an inbox (phone number). Optional status filter: active (Open) or archived (Done). Supports cursor pagination via limit and cursor. When contact_id is set, finds the thread for that contact regardless of status. */
171
206
  getInboxThreads(phoneNumberId: string, params?: {
172
207
  status?: "active" | "archived";
173
208
  limit?: number;
174
209
  cursor?: string;
210
+ contact_id?: string;
211
+ unread_only?: boolean;
175
212
  }): Promise<InboxThreadsResponse>;
213
+ /** Search SMS threads by message body or contact name/phone. */
214
+ searchInboxThreads(phoneNumberId: string, params: {
215
+ q: string;
216
+ limit?: number;
217
+ }): Promise<InboxThreadSearchResponse>;
176
218
  /** List call events for an inbox (phone number). Same auth as getInboxThreads. Supports cursor pagination via limit and cursor. Optional missed_only returns only missed/busy/voicemail calls. */
177
219
  getInboxCalls(phoneNumberId: string, params?: {
178
220
  limit?: number;
@@ -185,6 +227,12 @@ export declare function createApiClient(config: ApiClientConfig): {
185
227
  createInboxCall(payload: CreateInboxCallPayload): Promise<InboxCallEvent>;
186
228
  /** URL for streaming call recording playback. Use with Bearer auth; response is audio stream (e.g. audio/mpeg), not JSON. */
187
229
  getInboxCallRecordingUrl(callEventId: string): string;
230
+ /** Aggregate badge count: unread threads + unseen missed calls across all assigned phone numbers. */
231
+ getInboxBadgeCount(): Promise<InboxBadgeCountResponse>;
232
+ /** Get the count of unseen missed inbound calls since the user last viewed the Calls tab. */
233
+ getMissedUnseenCount(phoneNumberId: string): Promise<MissedUnseenCountResponse>;
234
+ /** Mark calls as seen for the current user (resets badge to 0). Returns void (204). */
235
+ markCallsSeen(phoneNumberId: string): Promise<void>;
188
236
  /** Send an outbound message from an inbox (SMS). */
189
237
  sendInboxMessage(phoneNumberId: string, body: SendInboxMessagePayload): Promise<SendInboxMessageResponse>;
190
238
  /** Mark a thread as read for the current user (e.g. when opening the conversation). */
@@ -223,7 +271,7 @@ export declare function createApiClient(config: ApiClientConfig): {
223
271
  lang?: string;
224
272
  }): Promise<InboxGifsResponse>;
225
273
  /** List message snippets for the current org. */
226
- getMessageSnippets(): Promise<MessageSnippetsResponse>;
274
+ getMessageSnippets(channel?: "sms" | "email"): Promise<MessageSnippetsResponse>;
227
275
  /** Create a message snippet. */
228
276
  createMessageSnippet(body: CreateMessageSnippetPayload): Promise<{
229
277
  snippet: MessageSnippet;
@@ -236,6 +284,93 @@ export declare function createApiClient(config: ApiClientConfig): {
236
284
  deleteMessageSnippet(id: string): Promise<{
237
285
  ok: true;
238
286
  }>;
287
+ /** Create a Stripe Checkout Session and return the redirect URL. */
288
+ createCheckoutSession(body: {
289
+ action: string;
290
+ priceKey?: string;
291
+ quantity?: number;
292
+ }): Promise<{
293
+ url: string;
294
+ }>;
295
+ /** Create a Stripe Customer Portal session and return the redirect URL. */
296
+ createPortalSession(): Promise<{
297
+ url: string;
298
+ }>;
299
+ /** Fetch current billing status for the org. */
300
+ getBillingStatus(): Promise<{
301
+ billing: MeOrganizationBilling;
302
+ }>;
303
+ /** Toggle auto top-up for the org. */
304
+ toggleAutoTopUp(enabled: boolean): Promise<{
305
+ autoTopUpEnabled: boolean;
306
+ }>;
307
+ /** Add or remove an additional seat. */
308
+ updateSeats(action: "add" | "remove"): Promise<SeatUpdateResponse>;
309
+ /** Register (upsert) an APNs push token for the current user. */
310
+ registerPushToken(body: RegisterPushTokenPayload): Promise<RegisterPushTokenResponse>;
311
+ /** Unregister (soft-delete) an APNs push token. */
312
+ unregisterPushToken(apnsToken: string, platform?: "ios"): Promise<UnregisterPushTokenResponse>;
313
+ /** Initiate Gmail OAuth flow. Returns authUrl for redirect. */
314
+ connectGmail(connectionType?: "personal" | "shared"): Promise<{
315
+ authUrl: string;
316
+ }>;
317
+ /** List current user's Gmail connections. */
318
+ getGmailConnections(): Promise<GmailConnectionsResponse>;
319
+ /** Disconnect a Gmail account (soft-delete). */
320
+ disconnectGmail(connectionId: string): Promise<{
321
+ success: boolean;
322
+ }>;
323
+ /** List email threads for a Gmail connection (page-based). */
324
+ getGmailThreads(connectionId: string, params?: {
325
+ status?: string;
326
+ page?: number;
327
+ page_size?: number;
328
+ unread_only?: boolean;
329
+ }): Promise<GmailThreadsPageResponse>;
330
+ /** Get messages for an email thread. */
331
+ getGmailThreadMessages(connectionId: string, threadId: string): Promise<GmailMessagesResponse>;
332
+ /** Send an email via Gmail. */
333
+ sendGmailMessage(connectionId: string, body: SendGmailMessagePayload): Promise<SendGmailMessageResponse>;
334
+ /** Fetch the authenticated user's resolved email signature. */
335
+ getGmailSignature(connectionId: string): Promise<GmailSignatureResponse>;
336
+ /** Save or clear an email draft for a Gmail thread. Empty body = clear. */
337
+ putGmailThreadDraft(connectionId: string, threadId: string, body: string): Promise<{
338
+ ok: true;
339
+ }>;
340
+ linkGmailThreadContact(connectionId: string, threadId: string, body: LinkGmailThreadContactPayload): Promise<LinkGmailThreadContactResponse>;
341
+ searchGmailThreads(connectionId: string, params: {
342
+ q: string;
343
+ limit?: number;
344
+ cursor?: string;
345
+ }): Promise<GmailThreadSearchResponse>;
346
+ /** Trigger a manual Gmail sync for a connection. POST /api/gmail/[connectionId]/sync */
347
+ triggerGmailSync(connectionId: string): Promise<{
348
+ ok: boolean;
349
+ }>;
350
+ /** List members of a shared Gmail connection. */
351
+ getGmailConnectionMembers(connectionId: string): Promise<{
352
+ members: GmailConnectionMember[];
353
+ }>;
354
+ /** Add a member to a shared Gmail connection. */
355
+ addGmailConnectionMember(connectionId: string, userId: string): Promise<{
356
+ member: GmailConnectionMember;
357
+ }>;
358
+ /** Remove a member from a shared Gmail connection. */
359
+ removeGmailConnectionMember(connectionId: string, userId: string): Promise<{
360
+ success: boolean;
361
+ }>;
362
+ /** Create a standalone email draft (new compose, no thread). */
363
+ createEmailDraft(connectionId: string, payload: CreateEmailDraftPayload): Promise<CreateEmailDraftResponse>;
364
+ /** Update a standalone email draft. */
365
+ updateEmailDraft(connectionId: string, draftId: string, payload: UpdateEmailDraftPayload): Promise<{
366
+ ok: true;
367
+ }>;
368
+ /** List standalone email drafts for the current user on a connection. */
369
+ getEmailDrafts(connectionId: string): Promise<EmailDraftsListResponse>;
370
+ /** Delete a standalone email draft. */
371
+ deleteEmailDraft(connectionId: string, draftId: string): Promise<{
372
+ ok: true;
373
+ }>;
239
374
  };
240
375
  export type ApiClient = ReturnType<typeof createApiClient>;
241
376
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAEV,uBAAuB,EACvB,8BAA8B,EAC9B,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,+BAA+B,EAC/B,QAAQ,EACR,aAAa,EACb,mBAAmB,EACnB,UAAU,EACV,wBAAw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ive API client – base URL + auth, methods for each route.
3
3
  * Used by both SaaS and mobile; mobile passes EXPO_PUBLIC_API_URL and Supabase getToken.
4
4
  */
5
+ /** Thrown when `fetch` returns a non-OK response; includes HTTP status for callers (e.g. 402 insufficient credits). */
6
+ export class ApiRequestError extends Error {
7
+ constructor(status, message, body) {
8
+ super(message);
9
+ this.name = 'ApiRequestError';
10
+ this.status = status;
11
+ this.body = body;
12
+ Object.setPrototypeOf(this, new.target.prototype);
13
+ }
14
+ }
5
15
  function buildUrl(baseURL, path) {
6
16
  const base = baseURL.replace(/\/$/, '');
7
17
  const p = path.startsWith('/') ? path : `/${path}`;
@@ -30,7 +40,8 @@ export function createApiClient(config) {
30
40
  catch {
31
41
  // Server returned non-JSON (e.g. HTML error page); avoid "Unexpected token '<'" in Sentry
32
42
  }
33
- throw new Error(err.error || res.statusText || 'Request failed');
43
+ const message = err.error || res.statusText || 'Request failed';
44
+ throw new ApiRequestError(res.status, message, err);
34
45
  }
35
46
  if (res.status === 204)
36
47
  return undefined;
@@ -57,7 +68,8 @@ export function createApiClient(config) {
57
68
  catch {
58
69
  // Server returned non-JSON
59
70
  }
60
- throw new Error(err.error || res.statusText || 'Request failed');
71
+ const message = err.error || res.statusText || 'Request failed';
72
+ throw new ApiRequestError(res.status, message, err);
61
73
  }
62
74
  return res.json();
63
75
  }
@@ -77,10 +89,14 @@ export function createApiClient(config) {
77
89
  search.set('offset', String(params.offset));
78
90
  if (params?.status)
79
91
  search.set('status', params.status);
80
- if (params?.formId)
92
+ if (params?.formIds?.length)
93
+ search.set('formIds', params.formIds.join(','));
94
+ else if (params?.formId)
81
95
  search.set('formId', params.formId);
82
96
  if (params?.ownerIds?.length)
83
97
  search.set('ownerIds', params.ownerIds.join(','));
98
+ if (params?.setterIds?.length)
99
+ search.set('setterIds', params.setterIds.join(','));
84
100
  if (params?.pipelineIds?.length)
85
101
  search.set('pipelineIds', params.pipelineIds.join(','));
86
102
  if (params?.search)
@@ -91,6 +107,16 @@ export function createApiClient(config) {
91
107
  search.set('sortOrder', params.sortOrder);
92
108
  if (params?.showArchivedOnly)
93
109
  search.set('showArchivedOnly', 'true');
110
+ if (params?.allPipelines)
111
+ search.set('allPipelines', 'true');
112
+ if (params?.taskType)
113
+ search.set('taskType', params.taskType);
114
+ if (params?.dueDateFilter)
115
+ search.set('dueDateFilter', params.dueDateFilter);
116
+ if (params?.dueDateTimezone)
117
+ search.set('dueDateTimezone', params.dueDateTimezone);
118
+ if (params?.showCompletedOnly)
119
+ search.set('showCompletedOnly', 'true');
94
120
  return request(`/api/lead-submissions?${search}`);
95
121
  },
96
122
  // -------------------------------------------------------------------------
@@ -114,6 +140,8 @@ export function createApiClient(config) {
114
140
  search.set('status', params.status);
115
141
  if (params?.related_card_id)
116
142
  search.set('related_card_id', params.related_card_id);
143
+ if (params?.contact_id)
144
+ search.set('contact_id', params.contact_id);
117
145
  if (params?.limit != null)
118
146
  search.set('limit', String(params.limit));
119
147
  if (params?.offset != null)
@@ -124,6 +152,12 @@ export function createApiClient(config) {
124
152
  search.set('sort_order', params.sort_order);
125
153
  return request(`/api/tasks?${search}`);
126
154
  },
155
+ createTask(body) {
156
+ return request('/api/tasks', {
157
+ method: 'POST',
158
+ body: JSON.stringify(body),
159
+ });
160
+ },
127
161
  /** POST /api/tasks/[taskId]/outcome – record call/chat outcome */
128
162
  postTaskOutcome(taskId, body) {
129
163
  return request(`/api/tasks/${taskId}/outcome`, {
@@ -159,10 +193,14 @@ export function createApiClient(config) {
159
193
  return request(`/api/meetings/${encodeURIComponent(meetingId)}`);
160
194
  },
161
195
  // -------------------------------------------------------------------------
162
- // Pipeline card (GET /api/pipelines/[id]/cards/[cardId], PATCH)
196
+ // Pipeline cards (GET /api/pipelines/[id]/cards, GET/PATCH .../[cardId])
163
197
  // -------------------------------------------------------------------------
164
- getCard(pipelineId, cardId) {
165
- return request(`/api/pipelines/${pipelineId}/cards/${cardId}`);
198
+ getPipelineCards(pipelineId, params, opts) {
199
+ const qs = params?.showArchivedOnly ? '?showArchivedOnly=true' : '';
200
+ return request(`/api/pipelines/${pipelineId}/cards${qs}`, { signal: opts?.signal });
201
+ },
202
+ getCard(pipelineId, cardId, opts) {
203
+ return request(`/api/pipelines/${pipelineId}/cards/${cardId}`, { signal: opts?.signal });
166
204
  },
167
205
  patchCard(pipelineId, cardId, body) {
168
206
  return request(`/api/pipelines/${pipelineId}/cards/${cardId}`, {
@@ -170,6 +208,15 @@ export function createApiClient(config) {
170
208
  body: JSON.stringify(body),
171
209
  });
172
210
  },
211
+ createCard(pipelineId, body) {
212
+ return request(`/api/pipelines/${pipelineId}/cards`, {
213
+ method: 'POST',
214
+ body: JSON.stringify(body),
215
+ });
216
+ },
217
+ deleteCard(pipelineId, cardId, action = 'archive') {
218
+ return request(`/api/pipelines/${pipelineId}/cards/${cardId}?action=${action}`, { method: 'DELETE' });
219
+ },
173
220
  // -------------------------------------------------------------------------
174
221
  // Post-meeting booked prompt (GET /api/cards/[cardId]/post-meeting-booked-prompt)
175
222
  // -------------------------------------------------------------------------
@@ -327,7 +374,7 @@ export function createApiClient(config) {
327
374
  getPhoneNumber(phoneNumberId) {
328
375
  return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}`);
329
376
  },
330
- /** PATCH /api/phone-numbers/[id] – update phone number (admin/owner only). Includes call_recording_transcribe_enabled. */
377
+ /** PATCH /api/phone-numbers/[id] – update phone number (admin/owner only). Includes call_recording_enabled and call_recording_transcribe_enabled. */
331
378
  patchPhoneNumber(phoneNumberId, body) {
332
379
  return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'PATCH', body: JSON.stringify(body) });
333
380
  },
@@ -336,8 +383,9 @@ export function createApiClient(config) {
336
383
  return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}`, { method: 'DELETE' }).then(() => undefined);
337
384
  },
338
385
  /** POST /api/phone-numbers/[id]/voice-token – Twilio Voice Access Token for Device SDK. */
339
- postVoiceToken(phoneNumberId) {
340
- return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/voice-token`, { method: 'POST' });
386
+ postVoiceToken(phoneNumberId, mode) {
387
+ const modeQuery = mode ? `?mode=${mode}` : '';
388
+ return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/voice-token${modeQuery}`, { method: 'POST' });
341
389
  },
342
390
  /** POST /api/phone-numbers/[id]/upload-media – upload files for outbound MMS; returns signed URLs + attachment metadata. */
343
391
  uploadInboxMedia(phoneNumberId, formData) {
@@ -346,19 +394,31 @@ export function createApiClient(config) {
346
394
  // -------------------------------------------------------------------------
347
395
  // Inbox: threads, messages, send (use shared API; no raw fetch in app)
348
396
  // -------------------------------------------------------------------------
349
- /** List conversation threads for an inbox (phone number). Optional status filter: active (Open) or archived (Done). Supports cursor pagination via limit and cursor. */
397
+ /** List conversation threads for an inbox (phone number). Optional status filter: active (Open) or archived (Done). Supports cursor pagination via limit and cursor. When contact_id is set, finds the thread for that contact regardless of status. */
350
398
  getInboxThreads(phoneNumberId, params) {
351
399
  const search = new URLSearchParams();
400
+ if (params?.contact_id)
401
+ search.set('contact_id', params.contact_id);
352
402
  if (params?.status)
353
403
  search.set('status', params.status);
354
404
  if (params?.limit != null)
355
405
  search.set('limit', String(params.limit));
356
406
  if (params?.cursor)
357
407
  search.set('cursor', params.cursor);
408
+ if (params?.unread_only)
409
+ search.set('unread_only', 'true');
358
410
  const qs = search.toString();
359
411
  const path = `/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/threads` + (qs ? `?${qs}` : '');
360
412
  return request(path);
361
413
  },
414
+ /** Search SMS threads by message body or contact name/phone. */
415
+ searchInboxThreads(phoneNumberId, params) {
416
+ const sp = new URLSearchParams();
417
+ sp.set('q', params.q);
418
+ if (params.limit)
419
+ sp.set('limit', String(params.limit));
420
+ return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/threads/search?${sp.toString()}`);
421
+ },
362
422
  /** List call events for an inbox (phone number). Same auth as getInboxThreads. Supports cursor pagination via limit and cursor. Optional missed_only returns only missed/busy/voicemail calls. */
363
423
  getInboxCalls(phoneNumberId, params) {
364
424
  const search = new URLSearchParams();
@@ -387,6 +447,18 @@ export function createApiClient(config) {
387
447
  getInboxCallRecordingUrl(callEventId) {
388
448
  return buildUrl(baseURL, `/api/inbox/calls/${encodeURIComponent(callEventId)}/recording`);
389
449
  },
450
+ /** Aggregate badge count: unread threads + unseen missed calls across all assigned phone numbers. */
451
+ getInboxBadgeCount() {
452
+ return request('/api/inbox/badge-count');
453
+ },
454
+ /** Get the count of unseen missed inbound calls since the user last viewed the Calls tab. */
455
+ getMissedUnseenCount(phoneNumberId) {
456
+ return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/calls/missed-unseen-count`);
457
+ },
458
+ /** Mark calls as seen for the current user (resets badge to 0). Returns void (204). */
459
+ async markCallsSeen(phoneNumberId) {
460
+ await request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/calls/mark-seen`, { method: 'POST' });
461
+ },
390
462
  /** Send an outbound message from an inbox (SMS). */
391
463
  sendInboxMessage(phoneNumberId, body) {
392
464
  return request(`/api/phone-numbers/${encodeURIComponent(phoneNumberId)}/send`, {
@@ -445,8 +517,9 @@ export function createApiClient(config) {
445
517
  // Message snippets (Settings → Messaging; Inbox picker)
446
518
  // -------------------------------------------------------------------------
447
519
  /** List message snippets for the current org. */
448
- getMessageSnippets() {
449
- return request('/api/settings/messaging/snippets');
520
+ getMessageSnippets(channel) {
521
+ const params = channel ? `?channel=${channel}` : '';
522
+ return request(`/api/settings/messaging/snippets${params}`);
450
523
  },
451
524
  /** Create a message snippet. */
452
525
  createMessageSnippet(body) {
@@ -460,5 +533,148 @@ export function createApiClient(config) {
460
533
  deleteMessageSnippet(id) {
461
534
  return request(`/api/settings/messaging/snippets/${encodeURIComponent(id)}`, { method: 'DELETE' });
462
535
  },
536
+ // -------------------------------------------------------------------------
537
+ // Billing (POST /api/billing/checkout, POST /api/billing/portal, GET /api/billing/status)
538
+ // -------------------------------------------------------------------------
539
+ /** Create a Stripe Checkout Session and return the redirect URL. */
540
+ createCheckoutSession(body) {
541
+ return request('/api/billing/checkout', {
542
+ method: 'POST',
543
+ body: JSON.stringify(body),
544
+ });
545
+ },
546
+ /** Create a Stripe Customer Portal session and return the redirect URL. */
547
+ createPortalSession() {
548
+ return request('/api/billing/portal', {
549
+ method: 'POST',
550
+ });
551
+ },
552
+ /** Fetch current billing status for the org. */
553
+ getBillingStatus() {
554
+ return request('/api/billing/status');
555
+ },
556
+ /** Toggle auto top-up for the org. */
557
+ toggleAutoTopUp(enabled) {
558
+ return request('/api/billing/auto-topup', {
559
+ method: 'POST',
560
+ body: JSON.stringify({ enabled }),
561
+ });
562
+ },
563
+ /** Add or remove an additional seat. */
564
+ updateSeats(action) {
565
+ return request('/api/billing/seats', {
566
+ method: 'POST',
567
+ body: JSON.stringify({ action }),
568
+ });
569
+ },
570
+ // -------------------------------------------------------------------------
571
+ // Mobile Push Tokens (POST /api/mobile/push-tokens, DELETE /api/mobile/push-tokens/[token])
572
+ // -------------------------------------------------------------------------
573
+ /** Register (upsert) an APNs push token for the current user. */
574
+ registerPushToken(body) {
575
+ return request('/api/mobile/push-tokens', {
576
+ method: 'POST',
577
+ body: JSON.stringify(body),
578
+ });
579
+ },
580
+ /** Unregister (soft-delete) an APNs push token. */
581
+ unregisterPushToken(apnsToken, platform = 'ios') {
582
+ return request(`/api/mobile/push-tokens/${encodeURIComponent(apnsToken)}?platform=${platform}`, { method: 'DELETE' });
583
+ },
584
+ // -----------------------------------------------------------------------
585
+ // Gmail
586
+ // -----------------------------------------------------------------------
587
+ /** Initiate Gmail OAuth flow. Returns authUrl for redirect. */
588
+ connectGmail(connectionType) {
589
+ return request('/api/gmail/connect', {
590
+ method: 'POST',
591
+ body: JSON.stringify({ connection_type: connectionType ?? 'personal' }),
592
+ });
593
+ },
594
+ /** List current user's Gmail connections. */
595
+ getGmailConnections() {
596
+ return request('/api/gmail/connections');
597
+ },
598
+ /** Disconnect a Gmail account (soft-delete). */
599
+ disconnectGmail(connectionId) {
600
+ return request(`/api/gmail/disconnect?id=${connectionId}`, { method: 'DELETE' });
601
+ },
602
+ /** List email threads for a Gmail connection (page-based). */
603
+ getGmailThreads(connectionId, params) {
604
+ const sp = new URLSearchParams();
605
+ if (params?.status)
606
+ sp.set('status', params.status);
607
+ if (params?.page)
608
+ sp.set('page', String(params.page));
609
+ if (params?.page_size)
610
+ sp.set('page_size', String(params.page_size));
611
+ if (params?.unread_only)
612
+ sp.set('unread_only', 'true');
613
+ const qs = sp.toString();
614
+ return request(`/api/gmail/${connectionId}/threads${qs ? `?${qs}` : ''}`);
615
+ },
616
+ /** Get messages for an email thread. */
617
+ getGmailThreadMessages(connectionId, threadId) {
618
+ return request(`/api/gmail/${connectionId}/threads/${threadId}/messages`);
619
+ },
620
+ /** Send an email via Gmail. */
621
+ sendGmailMessage(connectionId, body) {
622
+ return request(`/api/gmail/${connectionId}/send`, { method: 'POST', body: JSON.stringify(body) });
623
+ },
624
+ /** Fetch the authenticated user's resolved email signature. */
625
+ getGmailSignature(connectionId) {
626
+ return request(`/api/gmail/${connectionId}/signature`);
627
+ },
628
+ /** Save or clear an email draft for a Gmail thread. Empty body = clear. */
629
+ putGmailThreadDraft(connectionId, threadId, body) {
630
+ return request(`/api/gmail/${encodeURIComponent(connectionId)}/threads/${encodeURIComponent(threadId)}/draft`, { method: 'PUT', body: JSON.stringify({ body }) });
631
+ },
632
+ linkGmailThreadContact(connectionId, threadId, body) {
633
+ return request(`/api/gmail/${connectionId}/threads/${threadId}/link-contact`, { method: 'POST', body: JSON.stringify(body) });
634
+ },
635
+ searchGmailThreads(connectionId, params) {
636
+ const sp = new URLSearchParams();
637
+ sp.set('q', params.q);
638
+ if (params.limit)
639
+ sp.set('limit', String(params.limit));
640
+ if (params.cursor)
641
+ sp.set('cursor', params.cursor);
642
+ return request(`/api/gmail/${connectionId}/threads/search?${sp.toString()}`);
643
+ },
644
+ /** Trigger a manual Gmail sync for a connection. POST /api/gmail/[connectionId]/sync */
645
+ triggerGmailSync(connectionId) {
646
+ return request(`/api/gmail/${connectionId}/sync`, { method: 'POST' });
647
+ },
648
+ /** List members of a shared Gmail connection. */
649
+ getGmailConnectionMembers(connectionId) {
650
+ return request(`/api/gmail/connections/${connectionId}/members`);
651
+ },
652
+ /** Add a member to a shared Gmail connection. */
653
+ addGmailConnectionMember(connectionId, userId) {
654
+ return request(`/api/gmail/connections/${connectionId}/members`, { method: 'POST', body: JSON.stringify({ user_id: userId }) });
655
+ },
656
+ /** Remove a member from a shared Gmail connection. */
657
+ removeGmailConnectionMember(connectionId, userId) {
658
+ return request(`/api/gmail/connections/${connectionId}/members/${userId}`, { method: 'DELETE' });
659
+ },
660
+ // -----------------------------------------------------------------------
661
+ // Standalone Email Drafts
662
+ // -----------------------------------------------------------------------
663
+ /** Create a standalone email draft (new compose, no thread). */
664
+ createEmailDraft(connectionId, payload) {
665
+ return request(`/api/gmail/${encodeURIComponent(connectionId)}/drafts`, { method: 'POST', body: JSON.stringify(payload) });
666
+ },
667
+ /** Update a standalone email draft. */
668
+ updateEmailDraft(connectionId, draftId, payload) {
669
+ return request(`/api/gmail/${encodeURIComponent(connectionId)}/drafts/${encodeURIComponent(draftId)}`, { method: 'PUT', body: JSON.stringify(payload) });
670
+ },
671
+ /** List standalone email drafts for the current user on a connection. */
672
+ getEmailDrafts(connectionId) {
673
+ return request(`/api/gmail/${encodeURIComponent(connectionId)}/drafts`);
674
+ },
675
+ /** Delete a standalone email draft. */
676
+ deleteEmailDraft(connectionId, draftId) {
677
+ return request(`/api/gmail/${encodeURIComponent(connectionId)}/drafts/${encodeURIComponent(draftId)}`, { method: 'DELETE' });
678
+ },
463
679
  };
464
680
  }