@graph8/sdk 0.2.1 → 0.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.
package/dist/index.mjs CHANGED
@@ -323,18 +323,133 @@ var DEFAULT_API7 = "https://be.graph8.com";
323
323
  var createSequencesClient = (apiKey, apiUrl) => {
324
324
  const baseUrl = apiUrl || DEFAULT_API7;
325
325
  const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
326
+ const toQuery = (params) => {
327
+ const qs = new URLSearchParams();
328
+ for (const [k, v] of Object.entries(params)) {
329
+ if (v != null) qs.set(k, String(v));
330
+ }
331
+ const s = qs.toString();
332
+ return s ? `?${s}` : "";
333
+ };
334
+ async function list(pageOrParams, limit) {
335
+ let params;
336
+ if (typeof pageOrParams === "number") {
337
+ params = { page: pageOrParams, limit: limit ?? 50 };
338
+ } else {
339
+ params = pageOrParams ?? {};
340
+ }
341
+ const resp = await fetch(`${baseUrl}/api/v1/sequences${toQuery(params)}`, { headers: headers() });
342
+ const data = await resp.json();
343
+ return data.data || data;
344
+ }
326
345
  return {
327
- async list(page = 1, limit = 50) {
328
- const resp = await fetch(`${baseUrl}/api/v1/sequences?page=${page}&limit=${limit}`, { headers: headers() });
346
+ /** List sequences with pagination + optional status filter. */
347
+ list,
348
+ /** Get full sequence details by ID. */
349
+ async get(sequenceId) {
350
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, { headers: headers() });
329
351
  const data = await resp.json();
330
352
  return data.data || data;
331
353
  },
354
+ /** List contacts enrolled in a sequence. Filter by state (e.g. "active", "replied"). */
355
+ async contacts(sequenceId, params = {}) {
356
+ const resp = await fetch(
357
+ `${baseUrl}/api/v1/sequences/${sequenceId}/contacts${toQuery(params)}`,
358
+ { headers: headers() }
359
+ );
360
+ return resp.json();
361
+ },
362
+ /** Add contacts to a sequence (V2 queuing). Live or drafted sequences only. */
332
363
  async add(config) {
333
- await fetch(`${baseUrl}/api/v1/sequences/${config.sequenceId}/contacts`, {
364
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${config.sequenceId}/contacts`, {
334
365
  method: "POST",
335
366
  headers: headers(),
336
367
  body: JSON.stringify({ contact_ids: config.contactIds, list_id: config.listId })
337
368
  });
369
+ const data = await resp.json();
370
+ return data.data || data;
371
+ },
372
+ /** Create a new sequence with optional steps + channels. */
373
+ async create(payload) {
374
+ const resp = await fetch(`${baseUrl}/api/v1/sequences`, {
375
+ method: "POST",
376
+ headers: headers(),
377
+ body: JSON.stringify(payload)
378
+ });
379
+ const data = await resp.json();
380
+ return data.data || data;
381
+ },
382
+ /** Update sequence metadata. Rejected (409) if sequence is in a transitional status. */
383
+ async update(sequenceId, fields) {
384
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, {
385
+ method: "PATCH",
386
+ headers: headers(),
387
+ body: JSON.stringify(fields)
388
+ });
389
+ const data = await resp.json();
390
+ return data.data || data;
391
+ },
392
+ /** Update a single step within a sequence. */
393
+ async updateStep(sequenceId, stepId, fields) {
394
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/steps/${stepId}`, {
395
+ method: "PATCH",
396
+ headers: headers(),
397
+ body: JSON.stringify(fields)
398
+ });
399
+ const data = await resp.json();
400
+ return data.data || data;
401
+ },
402
+ /** Soft-delete (archive) a sequence. */
403
+ async delete(sequenceId) {
404
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, {
405
+ method: "DELETE",
406
+ headers: headers()
407
+ });
408
+ const data = await resp.json();
409
+ return data.data || data;
410
+ },
411
+ /** Run/start a DRAFTED sequence (V2 orchestration). */
412
+ async run(sequenceId) {
413
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/run`, {
414
+ method: "POST",
415
+ headers: headers()
416
+ });
417
+ const data = await resp.json();
418
+ return data.data || data;
419
+ },
420
+ /** Pause a live sequence. */
421
+ async pause(sequenceId) {
422
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/pause`, {
423
+ method: "POST",
424
+ headers: headers()
425
+ });
426
+ const data = await resp.json();
427
+ return data.data || data;
428
+ },
429
+ /** Resume a paused sequence. */
430
+ async resume(sequenceId) {
431
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/resume`, {
432
+ method: "POST",
433
+ headers: headers()
434
+ });
435
+ const data = await resp.json();
436
+ return data.data || data;
437
+ },
438
+ /** Read-only sequence preview with all steps + channels (no enrollment). */
439
+ async preview(sequenceId) {
440
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/preview`, {
441
+ headers: headers()
442
+ });
443
+ const data = await resp.json();
444
+ return data.data || data;
445
+ },
446
+ /** Comprehensive analytics for a sequence. */
447
+ async analytics(sequenceId) {
448
+ const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/analytics`, {
449
+ headers: headers()
450
+ });
451
+ const data = await resp.json();
452
+ return data.data || data;
338
453
  }
339
454
  };
340
455
  };
@@ -459,8 +574,116 @@ var createVoiceClient = (apiKey, apiUrl) => {
459
574
  const baseUrl = apiUrl || DEFAULT_API12;
460
575
  const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
461
576
  const listeners = /* @__PURE__ */ new Map();
577
+ const toQuery = (params) => {
578
+ const qs = new URLSearchParams();
579
+ for (const [k, v] of Object.entries(params)) {
580
+ if (v != null) qs.set(k, String(v));
581
+ }
582
+ const s = qs.toString();
583
+ return s ? `?${s}` : "";
584
+ };
585
+ const dialer = {
586
+ /** List parallel-dialer sessions with filters + pagination. */
587
+ async listSessions(params = {}) {
588
+ const resp = await fetch(
589
+ `${baseUrl}/api/v1/voice/dialer/sessions${toQuery(params)}`,
590
+ { headers: headers() }
591
+ );
592
+ const data = await resp.json();
593
+ return data.data || data;
594
+ },
595
+ /** Create a parallel-dialer session in PAUSED state. SDR opens UI to start dialing. */
596
+ async createSession(payload) {
597
+ const resp = await fetch(`${baseUrl}/api/v1/voice/dialer/sessions`, {
598
+ method: "POST",
599
+ headers: headers(),
600
+ body: JSON.stringify(payload)
601
+ });
602
+ const data = await resp.json();
603
+ return data.data || data;
604
+ },
605
+ /** Pause / resume / stop a dialer session via status flip. */
606
+ async updateSessionStatus(sessionId, status) {
607
+ const resp = await fetch(
608
+ `${baseUrl}/api/v1/voice/dialer/sessions/${sessionId}/status`,
609
+ {
610
+ method: "PATCH",
611
+ headers: headers(),
612
+ body: JSON.stringify({ status })
613
+ }
614
+ );
615
+ const data = await resp.json();
616
+ return data.data || data;
617
+ },
618
+ /**
619
+ * Resume a PAUSED dialer session. Auto-fetches the next batch from the source list,
620
+ * filters already-called + phoneless rows, and forwards to voice's start-session.
621
+ * @param maxContacts 1-4 (voice caps parallel dialing at 4). Default 4.
622
+ */
623
+ async resumeSession(sessionId, maxContacts = 4) {
624
+ const resp = await fetch(
625
+ `${baseUrl}/api/v1/voice/dialer/sessions/${sessionId}/resume`,
626
+ {
627
+ method: "POST",
628
+ headers: headers(),
629
+ body: JSON.stringify({ max_contacts: maxContacts })
630
+ }
631
+ );
632
+ const data = await resp.json();
633
+ return data.data || data;
634
+ },
635
+ /** Aggregated dialer analytics (daily breakdown or total). */
636
+ async stats(params = {}) {
637
+ const resp = await fetch(
638
+ `${baseUrl}/api/v1/voice/dialer/stats${toQuery(params)}`,
639
+ { headers: headers() }
640
+ );
641
+ const data = await resp.json();
642
+ return data.data || data;
643
+ },
644
+ /** List dialer-eligible phone numbers with 7-day stats + daily limits. */
645
+ async numbers(userEmail) {
646
+ const params = userEmail ? { user_email: userEmail } : {};
647
+ const resp = await fetch(
648
+ `${baseUrl}/api/v1/voice/dialer/numbers${toQuery(params)}`,
649
+ { headers: headers() }
650
+ );
651
+ const data = await resp.json();
652
+ return data.data || data;
653
+ },
654
+ /** List missed inbound callbacks with caller / contact info. */
655
+ async missedCallbacks(limit = 50) {
656
+ const resp = await fetch(
657
+ `${baseUrl}/api/v1/voice/dialer/missed-callbacks${toQuery({ limit })}`,
658
+ { headers: headers() }
659
+ );
660
+ const data = await resp.json();
661
+ return data.data || data;
662
+ },
663
+ /** AI grading for a single dialer call (returns "pending" while in progress). */
664
+ async callGrading(roomName) {
665
+ const resp = await fetch(
666
+ `${baseUrl}/api/v1/voice/dialer/calls/${encodeURIComponent(roomName)}/grading`,
667
+ { headers: headers() }
668
+ );
669
+ const data = await resp.json();
670
+ return data.data || data;
671
+ },
672
+ /** List voice agents available for dialer sessions (capped at 100; no pagination). */
673
+ async agents(params = {}) {
674
+ const resp = await fetch(
675
+ `${baseUrl}/api/v1/voice/dialer/agents${toQuery(params)}`,
676
+ { headers: headers() }
677
+ );
678
+ const data = await resp.json();
679
+ return data.data || data;
680
+ }
681
+ };
462
682
  return {
463
- /** Start an AI voice session. */
683
+ /**
684
+ * Start an AI voice session.
685
+ * @deprecated Preview surface — for parallel-dialer flows use `voice.dialer.createSession()`.
686
+ */
464
687
  async start(config) {
465
688
  const resp = await fetch(`${baseUrl}/api/v1/voice/sessions`, {
466
689
  method: "POST",
@@ -470,7 +693,10 @@ var createVoiceClient = (apiKey, apiUrl) => {
470
693
  const data = await resp.json();
471
694
  return data.data || data;
472
695
  },
473
- /** Get call analysis for a completed session. */
696
+ /**
697
+ * Get call analysis for a completed session.
698
+ * @deprecated Preview surface — for dialer-call grading use `voice.dialer.callGrading(roomName)`.
699
+ */
474
700
  async analysis(sessionId) {
475
701
  const resp = await fetch(`${baseUrl}/api/v1/voice/sessions/${sessionId}/analysis`, { headers: headers() });
476
702
  const data = await resp.json();
@@ -480,7 +706,9 @@ var createVoiceClient = (apiKey, apiUrl) => {
480
706
  on(event, callback) {
481
707
  if (!listeners.has(event)) listeners.set(event, []);
482
708
  listeners.get(event).push(callback);
483
- }
709
+ },
710
+ /** Parallel-dialer session control + analytics. */
711
+ dialer
484
712
  };
485
713
  };
486
714
 
@@ -612,6 +840,28 @@ var createContactsClient = (apiKey, apiUrl) => {
612
840
  headers: headers()
613
841
  });
614
842
  return resp.json();
843
+ },
844
+ /** List custom contact columns. Pass listId to include list-specific columns. */
845
+ async listColumns(listId) {
846
+ const qs = listId != null ? `?list_id=${listId}` : "";
847
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/columns${qs}`, { headers: headers() });
848
+ return resp.json();
849
+ },
850
+ /** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
851
+ async createColumn(params) {
852
+ const body = {
853
+ title: params.title,
854
+ data_type: params.data_type || "text",
855
+ list_id: params.list_id ?? null,
856
+ created_by: params.created_by
857
+ };
858
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/columns/create`, {
859
+ method: "POST",
860
+ headers: headers(),
861
+ body: JSON.stringify(body)
862
+ });
863
+ const data = await resp.json();
864
+ return data.data || data;
615
865
  }
616
866
  };
617
867
  };
@@ -665,6 +915,28 @@ var createCompaniesClient = (apiKey, apiUrl) => {
665
915
  headers: headers()
666
916
  });
667
917
  return resp.json();
918
+ },
919
+ /** List custom company columns. Pass listId to include list-specific columns. */
920
+ async listColumns(listId) {
921
+ const qs = listId != null ? `?list_id=${listId}` : "";
922
+ const resp = await fetch(`${baseUrl}/api/v1/companies/columns${qs}`, { headers: headers() });
923
+ return resp.json();
924
+ },
925
+ /** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
926
+ async createColumn(params) {
927
+ const body = {
928
+ title: params.title,
929
+ data_type: params.data_type || "text",
930
+ list_id: params.list_id ?? null,
931
+ created_by: params.created_by
932
+ };
933
+ const resp = await fetch(`${baseUrl}/api/v1/companies/columns/create`, {
934
+ method: "POST",
935
+ headers: headers(),
936
+ body: JSON.stringify(body)
937
+ });
938
+ const data = await resp.json();
939
+ return data.data || data;
668
940
  }
669
941
  };
670
942
  };
@@ -727,9 +999,326 @@ var createListsClient = (apiKey, apiUrl) => {
727
999
  };
728
1000
  };
729
1001
 
1002
+ // src/notes.ts
1003
+ var DEFAULT_API18 = "https://be.graph8.com";
1004
+ var createNotesClient = (apiKey, apiUrl) => {
1005
+ const baseUrl = apiUrl || DEFAULT_API18;
1006
+ const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
1007
+ return {
1008
+ /** List all notes on a contact. */
1009
+ async list(contactId) {
1010
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, { headers: headers() });
1011
+ return resp.json();
1012
+ },
1013
+ /** Create a note on a contact. */
1014
+ async create(contactId, content) {
1015
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, {
1016
+ method: "POST",
1017
+ headers: headers(),
1018
+ body: JSON.stringify({ content })
1019
+ });
1020
+ const data = await resp.json();
1021
+ return data.data || data;
1022
+ },
1023
+ /** Update a note's content. */
1024
+ async update(noteId, content) {
1025
+ const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
1026
+ method: "PATCH",
1027
+ headers: headers(),
1028
+ body: JSON.stringify({ content })
1029
+ });
1030
+ const data = await resp.json();
1031
+ return data.data || data;
1032
+ },
1033
+ /** Delete a note. */
1034
+ async delete(noteId) {
1035
+ const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
1036
+ method: "DELETE",
1037
+ headers: headers()
1038
+ });
1039
+ return resp.json();
1040
+ }
1041
+ };
1042
+ };
1043
+
1044
+ // src/tasks.ts
1045
+ var DEFAULT_API19 = "https://be.graph8.com";
1046
+ var createTasksClient = (apiKey, apiUrl) => {
1047
+ const baseUrl = apiUrl || DEFAULT_API19;
1048
+ const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
1049
+ const toQuery = (params) => {
1050
+ const qs = new URLSearchParams();
1051
+ for (const [k, v] of Object.entries(params)) {
1052
+ if (v != null) qs.set(k, String(v));
1053
+ }
1054
+ const s = qs.toString();
1055
+ return s ? `?${s}` : "";
1056
+ };
1057
+ return {
1058
+ /** List tasks on a single contact. Optional status filter ("open" | "completed"). */
1059
+ async listForContact(contactId, status) {
1060
+ const qs = status ? `?status=${encodeURIComponent(status)}` : "";
1061
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks${qs}`, { headers: headers() });
1062
+ return resp.json();
1063
+ },
1064
+ /** List all tasks org-wide with optional filters. */
1065
+ async list(params = {}) {
1066
+ const resp = await fetch(`${baseUrl}/api/v1/tasks${toQuery(params)}`, { headers: headers() });
1067
+ return resp.json();
1068
+ },
1069
+ /** Create a task on a contact. */
1070
+ async create(contactId, task) {
1071
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks`, {
1072
+ method: "POST",
1073
+ headers: headers(),
1074
+ body: JSON.stringify(task)
1075
+ });
1076
+ const data = await resp.json();
1077
+ return data.data || data;
1078
+ },
1079
+ /** Update a task (partial). */
1080
+ async update(taskId, fields) {
1081
+ const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
1082
+ method: "PATCH",
1083
+ headers: headers(),
1084
+ body: JSON.stringify(fields)
1085
+ });
1086
+ const data = await resp.json();
1087
+ return data.data || data;
1088
+ },
1089
+ /** Delete a task. */
1090
+ async delete(taskId) {
1091
+ const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
1092
+ method: "DELETE",
1093
+ headers: headers()
1094
+ });
1095
+ return resp.json();
1096
+ }
1097
+ };
1098
+ };
1099
+
1100
+ // src/fields.ts
1101
+ var DEFAULT_API20 = "https://be.graph8.com";
1102
+ var createFieldsClient = (apiKey, apiUrl) => {
1103
+ const baseUrl = apiUrl || DEFAULT_API20;
1104
+ const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
1105
+ const toQuery = (params) => {
1106
+ const qs = new URLSearchParams();
1107
+ for (const [k, v] of Object.entries(params)) {
1108
+ if (v != null) qs.set(k, String(v));
1109
+ }
1110
+ const s = qs.toString();
1111
+ return s ? `?${s}` : "";
1112
+ };
1113
+ return {
1114
+ /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1115
+ async listContactFields(listId) {
1116
+ const qs = listId != null ? `?list_id=${listId}` : "";
1117
+ const resp = await fetch(`${baseUrl}/api/v1/fields${qs}`, { headers: headers() });
1118
+ return resp.json();
1119
+ },
1120
+ /** List company fields (base + custom). Pass listId to include list-specific custom fields. */
1121
+ async listCompanyFields(listId) {
1122
+ const qs = listId != null ? `?list_id=${listId}` : "";
1123
+ const resp = await fetch(`${baseUrl}/api/v1/fields/companies${qs}`, { headers: headers() });
1124
+ return resp.json();
1125
+ },
1126
+ /** Create a custom field on contacts (default) or companies. */
1127
+ async create(params) {
1128
+ const body = {
1129
+ title: params.title,
1130
+ data_type: params.data_type || "text",
1131
+ list_id: params.list_id ?? null,
1132
+ entity: params.entity || "contacts"
1133
+ };
1134
+ const resp = await fetch(`${baseUrl}/api/v1/fields`, {
1135
+ method: "POST",
1136
+ headers: headers(),
1137
+ body: JSON.stringify(body)
1138
+ });
1139
+ const data = await resp.json();
1140
+ return data.data || data;
1141
+ },
1142
+ /** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
1143
+ async delete(columnId, params = {}) {
1144
+ const queryParams = { entity: params.entity || "contacts" };
1145
+ if (params.list_id != null) queryParams.list_id = params.list_id;
1146
+ const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}${toQuery(queryParams)}`, {
1147
+ method: "DELETE",
1148
+ headers: headers()
1149
+ });
1150
+ return resp.json();
1151
+ },
1152
+ /** Set a custom field value on a single contact or company row. Pass value=null to clear. */
1153
+ async setValue(columnId, params) {
1154
+ const body = {
1155
+ record_id: params.record_id,
1156
+ value: params.value ?? null,
1157
+ entity: params.entity || "contacts"
1158
+ };
1159
+ const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}/values`, {
1160
+ method: "PATCH",
1161
+ headers: headers(),
1162
+ body: JSON.stringify(body)
1163
+ });
1164
+ return resp.json();
1165
+ }
1166
+ };
1167
+ };
1168
+
1169
+ // src/deals.ts
1170
+ var DEFAULT_API21 = "https://be.graph8.com";
1171
+ var createDealsClient = (apiKey, apiUrl) => {
1172
+ const baseUrl = apiUrl || DEFAULT_API21;
1173
+ const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
1174
+ const toQuery = (params) => {
1175
+ const qs = new URLSearchParams();
1176
+ for (const [k, v] of Object.entries(params)) {
1177
+ if (v != null) qs.set(k, String(v));
1178
+ }
1179
+ const s = qs.toString();
1180
+ return s ? `?${s}` : "";
1181
+ };
1182
+ return {
1183
+ /** List all deal pipelines and their stages. */
1184
+ async pipelines() {
1185
+ const resp = await fetch(`${baseUrl}/api/v1/deals/pipelines`, { headers: headers() });
1186
+ return resp.json();
1187
+ },
1188
+ /** List deals org-wide with optional filters and pagination. */
1189
+ async list(params = {}) {
1190
+ const resp = await fetch(`${baseUrl}/api/v1/deals${toQuery(params)}`, { headers: headers() });
1191
+ return resp.json();
1192
+ },
1193
+ /** Create a new deal. */
1194
+ async create(deal) {
1195
+ const resp = await fetch(`${baseUrl}/api/v1/deals`, {
1196
+ method: "POST",
1197
+ headers: headers(),
1198
+ body: JSON.stringify(deal)
1199
+ });
1200
+ const data = await resp.json();
1201
+ return data.data || data;
1202
+ },
1203
+ /** Get a single deal by ID. */
1204
+ async get(dealId) {
1205
+ const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, { headers: headers() });
1206
+ const data = await resp.json();
1207
+ return data.data || data;
1208
+ },
1209
+ /** Update a deal (partial). */
1210
+ async update(dealId, fields) {
1211
+ const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
1212
+ method: "PATCH",
1213
+ headers: headers(),
1214
+ body: JSON.stringify(fields)
1215
+ });
1216
+ const data = await resp.json();
1217
+ return data.data || data;
1218
+ },
1219
+ /** Delete a deal. */
1220
+ async delete(dealId) {
1221
+ const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
1222
+ method: "DELETE",
1223
+ headers: headers()
1224
+ });
1225
+ return resp.json();
1226
+ },
1227
+ /** Get all deals associated with a contact. */
1228
+ async forContact(contactId) {
1229
+ const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/deals`, { headers: headers() });
1230
+ return resp.json();
1231
+ },
1232
+ /** Get all deals associated with a company. */
1233
+ async forCompany(companyId) {
1234
+ const resp = await fetch(`${baseUrl}/api/v1/companies/${companyId}/deals`, { headers: headers() });
1235
+ return resp.json();
1236
+ }
1237
+ };
1238
+ };
1239
+
1240
+ // src/inbox.ts
1241
+ var DEFAULT_API22 = "https://be.graph8.com";
1242
+ var createInboxClient = (apiKey, apiUrl) => {
1243
+ const baseUrl = apiUrl || DEFAULT_API22;
1244
+ const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
1245
+ const toQuery = (params) => {
1246
+ const qs = new URLSearchParams();
1247
+ for (const [k, v] of Object.entries(params)) {
1248
+ if (v != null) qs.set(k, String(v));
1249
+ }
1250
+ const s = qs.toString();
1251
+ return s ? `?${s}` : "";
1252
+ };
1253
+ return {
1254
+ /** List inbox threads across email, SMS, and LinkedIn. */
1255
+ async list(params = {}) {
1256
+ const resp = await fetch(`${baseUrl}/api/v1/inbox${toQuery(params)}`, { headers: headers() });
1257
+ return resp.json();
1258
+ },
1259
+ /** Get a single inbox thread. Defaults to email channel. */
1260
+ async get(replyId, channel = "email") {
1261
+ const resp = await fetch(
1262
+ `${baseUrl}/api/v1/inbox/${replyId}${toQuery({ channel })}`,
1263
+ { headers: headers() }
1264
+ );
1265
+ const data = await resp.json();
1266
+ return data.data || data;
1267
+ },
1268
+ /** Assign a user to an inbox thread. */
1269
+ async assign(replyId, assigneeEmail, channel = "email") {
1270
+ const resp = await fetch(
1271
+ `${baseUrl}/api/v1/inbox/${replyId}/assign${toQuery({ channel })}`,
1272
+ {
1273
+ method: "POST",
1274
+ headers: headers(),
1275
+ body: JSON.stringify({ assignee_email: assigneeEmail })
1276
+ }
1277
+ );
1278
+ const data = await resp.json();
1279
+ return data.data || data;
1280
+ },
1281
+ /** Attach tag IDs to an inbox thread. */
1282
+ async tag(replyId, tagIds, channel = "email") {
1283
+ const resp = await fetch(
1284
+ `${baseUrl}/api/v1/inbox/${replyId}/tag${toQuery({ channel })}`,
1285
+ {
1286
+ method: "POST",
1287
+ headers: headers(),
1288
+ body: JSON.stringify({ tag_ids: tagIds })
1289
+ }
1290
+ );
1291
+ const data = await resp.json();
1292
+ return data.data || data;
1293
+ },
1294
+ /**
1295
+ * Generate an AI draft reply for a thread.
1296
+ * Charges credits — server returns 402 if balance is insufficient.
1297
+ */
1298
+ async draft(replyId, channel = "email") {
1299
+ const resp = await fetch(
1300
+ `${baseUrl}/api/v1/inbox/${replyId}/draft${toQuery({ channel })}`,
1301
+ { headers: headers() }
1302
+ );
1303
+ const data = await resp.json();
1304
+ return data.data || data;
1305
+ },
1306
+ /** Send a reply through email, SMS, or LinkedIn. */
1307
+ async send(replyId, payload) {
1308
+ const resp = await fetch(`${baseUrl}/api/v1/inbox/${replyId}/send`, {
1309
+ method: "POST",
1310
+ headers: headers(),
1311
+ body: JSON.stringify(payload)
1312
+ });
1313
+ const data = await resp.json();
1314
+ return data.data || data;
1315
+ }
1316
+ };
1317
+ };
1318
+
730
1319
  // src/core.ts
731
1320
  var DEFAULT_HOST = "https://t.graph8.com";
732
- var DEFAULT_API18 = "https://be.graph8.com";
1321
+ var DEFAULT_API23 = "https://be.graph8.com";
733
1322
  var G8 = class {
734
1323
  constructor() {
735
1324
  /** @internal */
@@ -770,6 +1359,16 @@ var G8 = class {
770
1359
  this._companies = null;
771
1360
  /** @internal */
772
1361
  this._lists = null;
1362
+ /** @internal */
1363
+ this._notes = null;
1364
+ /** @internal */
1365
+ this._tasks = null;
1366
+ /** @internal */
1367
+ this._fields = null;
1368
+ /** @internal */
1369
+ this._deals = null;
1370
+ /** @internal */
1371
+ this._inbox = null;
773
1372
  }
774
1373
  /**
775
1374
  * Initialize the graph8 SDK. Must be called before any other method.
@@ -784,7 +1383,7 @@ var G8 = class {
784
1383
  debug: config.debug
785
1384
  });
786
1385
  }
787
- const apiUrl = config.apiUrl || DEFAULT_API18;
1386
+ const apiUrl = config.apiUrl || DEFAULT_API23;
788
1387
  const writeKey = config.writeKey || "";
789
1388
  const apiKey = config.apiKey || "";
790
1389
  if (writeKey) {
@@ -807,6 +1406,11 @@ var G8 = class {
807
1406
  this._contacts = createContactsClient(apiKey, apiUrl);
808
1407
  this._companies = createCompaniesClient(apiKey, apiUrl);
809
1408
  this._lists = createListsClient(apiKey, apiUrl);
1409
+ this._notes = createNotesClient(apiKey, apiUrl);
1410
+ this._tasks = createTasksClient(apiKey, apiUrl);
1411
+ this._fields = createFieldsClient(apiKey, apiUrl);
1412
+ this._deals = createDealsClient(apiKey, apiUrl);
1413
+ this._inbox = createInboxClient(apiKey, apiUrl);
810
1414
  this._signals = createSignalsClient(apiKey, true, apiUrl);
811
1415
  }
812
1416
  }
@@ -913,6 +1517,31 @@ var G8 = class {
913
1517
  this._assertKey("lists");
914
1518
  return this._lists;
915
1519
  }
1520
+ /** Notes on contacts (requires API key). */
1521
+ get notes() {
1522
+ this._assertKey("notes");
1523
+ return this._notes;
1524
+ }
1525
+ /** Tasks on contacts (requires API key). */
1526
+ get tasks() {
1527
+ this._assertKey("tasks");
1528
+ return this._tasks;
1529
+ }
1530
+ /** Custom fields management (requires API key). */
1531
+ get fields() {
1532
+ this._assertKey("fields");
1533
+ return this._fields;
1534
+ }
1535
+ /** Deals and pipelines (requires API key). */
1536
+ get deals() {
1537
+ this._assertKey("deals");
1538
+ return this._deals;
1539
+ }
1540
+ /** Multi-channel inbox — read + reply across email, SMS, LinkedIn (requires API key). */
1541
+ get inbox() {
1542
+ this._assertKey("inbox");
1543
+ return this._inbox;
1544
+ }
916
1545
  /** Whether the SDK has been initialized. */
917
1546
  get initialized() {
918
1547
  return this.config !== null;