@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.d.mts +1085 -9
- package/dist/index.d.ts +1085 -9
- package/dist/index.js +637 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +637 -8
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +1079 -15
- package/dist/react.d.ts +1079 -15
- package/dist/react.js +637 -8
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +637 -8
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -349,18 +349,133 @@ var DEFAULT_API7 = "https://be.graph8.com";
|
|
|
349
349
|
var createSequencesClient = (apiKey, apiUrl) => {
|
|
350
350
|
const baseUrl = apiUrl || DEFAULT_API7;
|
|
351
351
|
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
352
|
+
const toQuery = (params) => {
|
|
353
|
+
const qs = new URLSearchParams();
|
|
354
|
+
for (const [k, v] of Object.entries(params)) {
|
|
355
|
+
if (v != null) qs.set(k, String(v));
|
|
356
|
+
}
|
|
357
|
+
const s = qs.toString();
|
|
358
|
+
return s ? `?${s}` : "";
|
|
359
|
+
};
|
|
360
|
+
async function list(pageOrParams, limit) {
|
|
361
|
+
let params;
|
|
362
|
+
if (typeof pageOrParams === "number") {
|
|
363
|
+
params = { page: pageOrParams, limit: limit ?? 50 };
|
|
364
|
+
} else {
|
|
365
|
+
params = pageOrParams ?? {};
|
|
366
|
+
}
|
|
367
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences${toQuery(params)}`, { headers: headers() });
|
|
368
|
+
const data = await resp.json();
|
|
369
|
+
return data.data || data;
|
|
370
|
+
}
|
|
352
371
|
return {
|
|
353
|
-
|
|
354
|
-
|
|
372
|
+
/** List sequences with pagination + optional status filter. */
|
|
373
|
+
list,
|
|
374
|
+
/** Get full sequence details by ID. */
|
|
375
|
+
async get(sequenceId) {
|
|
376
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, { headers: headers() });
|
|
355
377
|
const data = await resp.json();
|
|
356
378
|
return data.data || data;
|
|
357
379
|
},
|
|
380
|
+
/** List contacts enrolled in a sequence. Filter by state (e.g. "active", "replied"). */
|
|
381
|
+
async contacts(sequenceId, params = {}) {
|
|
382
|
+
const resp = await fetch(
|
|
383
|
+
`${baseUrl}/api/v1/sequences/${sequenceId}/contacts${toQuery(params)}`,
|
|
384
|
+
{ headers: headers() }
|
|
385
|
+
);
|
|
386
|
+
return resp.json();
|
|
387
|
+
},
|
|
388
|
+
/** Add contacts to a sequence (V2 queuing). Live or drafted sequences only. */
|
|
358
389
|
async add(config) {
|
|
359
|
-
await fetch(`${baseUrl}/api/v1/sequences/${config.sequenceId}/contacts`, {
|
|
390
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${config.sequenceId}/contacts`, {
|
|
360
391
|
method: "POST",
|
|
361
392
|
headers: headers(),
|
|
362
393
|
body: JSON.stringify({ contact_ids: config.contactIds, list_id: config.listId })
|
|
363
394
|
});
|
|
395
|
+
const data = await resp.json();
|
|
396
|
+
return data.data || data;
|
|
397
|
+
},
|
|
398
|
+
/** Create a new sequence with optional steps + channels. */
|
|
399
|
+
async create(payload) {
|
|
400
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences`, {
|
|
401
|
+
method: "POST",
|
|
402
|
+
headers: headers(),
|
|
403
|
+
body: JSON.stringify(payload)
|
|
404
|
+
});
|
|
405
|
+
const data = await resp.json();
|
|
406
|
+
return data.data || data;
|
|
407
|
+
},
|
|
408
|
+
/** Update sequence metadata. Rejected (409) if sequence is in a transitional status. */
|
|
409
|
+
async update(sequenceId, fields) {
|
|
410
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, {
|
|
411
|
+
method: "PATCH",
|
|
412
|
+
headers: headers(),
|
|
413
|
+
body: JSON.stringify(fields)
|
|
414
|
+
});
|
|
415
|
+
const data = await resp.json();
|
|
416
|
+
return data.data || data;
|
|
417
|
+
},
|
|
418
|
+
/** Update a single step within a sequence. */
|
|
419
|
+
async updateStep(sequenceId, stepId, fields) {
|
|
420
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/steps/${stepId}`, {
|
|
421
|
+
method: "PATCH",
|
|
422
|
+
headers: headers(),
|
|
423
|
+
body: JSON.stringify(fields)
|
|
424
|
+
});
|
|
425
|
+
const data = await resp.json();
|
|
426
|
+
return data.data || data;
|
|
427
|
+
},
|
|
428
|
+
/** Soft-delete (archive) a sequence. */
|
|
429
|
+
async delete(sequenceId) {
|
|
430
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}`, {
|
|
431
|
+
method: "DELETE",
|
|
432
|
+
headers: headers()
|
|
433
|
+
});
|
|
434
|
+
const data = await resp.json();
|
|
435
|
+
return data.data || data;
|
|
436
|
+
},
|
|
437
|
+
/** Run/start a DRAFTED sequence (V2 orchestration). */
|
|
438
|
+
async run(sequenceId) {
|
|
439
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/run`, {
|
|
440
|
+
method: "POST",
|
|
441
|
+
headers: headers()
|
|
442
|
+
});
|
|
443
|
+
const data = await resp.json();
|
|
444
|
+
return data.data || data;
|
|
445
|
+
},
|
|
446
|
+
/** Pause a live sequence. */
|
|
447
|
+
async pause(sequenceId) {
|
|
448
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/pause`, {
|
|
449
|
+
method: "POST",
|
|
450
|
+
headers: headers()
|
|
451
|
+
});
|
|
452
|
+
const data = await resp.json();
|
|
453
|
+
return data.data || data;
|
|
454
|
+
},
|
|
455
|
+
/** Resume a paused sequence. */
|
|
456
|
+
async resume(sequenceId) {
|
|
457
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/resume`, {
|
|
458
|
+
method: "POST",
|
|
459
|
+
headers: headers()
|
|
460
|
+
});
|
|
461
|
+
const data = await resp.json();
|
|
462
|
+
return data.data || data;
|
|
463
|
+
},
|
|
464
|
+
/** Read-only sequence preview with all steps + channels (no enrollment). */
|
|
465
|
+
async preview(sequenceId) {
|
|
466
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/preview`, {
|
|
467
|
+
headers: headers()
|
|
468
|
+
});
|
|
469
|
+
const data = await resp.json();
|
|
470
|
+
return data.data || data;
|
|
471
|
+
},
|
|
472
|
+
/** Comprehensive analytics for a sequence. */
|
|
473
|
+
async analytics(sequenceId) {
|
|
474
|
+
const resp = await fetch(`${baseUrl}/api/v1/sequences/${sequenceId}/analytics`, {
|
|
475
|
+
headers: headers()
|
|
476
|
+
});
|
|
477
|
+
const data = await resp.json();
|
|
478
|
+
return data.data || data;
|
|
364
479
|
}
|
|
365
480
|
};
|
|
366
481
|
};
|
|
@@ -485,8 +600,116 @@ var createVoiceClient = (apiKey, apiUrl) => {
|
|
|
485
600
|
const baseUrl = apiUrl || DEFAULT_API12;
|
|
486
601
|
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
487
602
|
const listeners = /* @__PURE__ */ new Map();
|
|
603
|
+
const toQuery = (params) => {
|
|
604
|
+
const qs = new URLSearchParams();
|
|
605
|
+
for (const [k, v] of Object.entries(params)) {
|
|
606
|
+
if (v != null) qs.set(k, String(v));
|
|
607
|
+
}
|
|
608
|
+
const s = qs.toString();
|
|
609
|
+
return s ? `?${s}` : "";
|
|
610
|
+
};
|
|
611
|
+
const dialer = {
|
|
612
|
+
/** List parallel-dialer sessions with filters + pagination. */
|
|
613
|
+
async listSessions(params = {}) {
|
|
614
|
+
const resp = await fetch(
|
|
615
|
+
`${baseUrl}/api/v1/voice/dialer/sessions${toQuery(params)}`,
|
|
616
|
+
{ headers: headers() }
|
|
617
|
+
);
|
|
618
|
+
const data = await resp.json();
|
|
619
|
+
return data.data || data;
|
|
620
|
+
},
|
|
621
|
+
/** Create a parallel-dialer session in PAUSED state. SDR opens UI to start dialing. */
|
|
622
|
+
async createSession(payload) {
|
|
623
|
+
const resp = await fetch(`${baseUrl}/api/v1/voice/dialer/sessions`, {
|
|
624
|
+
method: "POST",
|
|
625
|
+
headers: headers(),
|
|
626
|
+
body: JSON.stringify(payload)
|
|
627
|
+
});
|
|
628
|
+
const data = await resp.json();
|
|
629
|
+
return data.data || data;
|
|
630
|
+
},
|
|
631
|
+
/** Pause / resume / stop a dialer session via status flip. */
|
|
632
|
+
async updateSessionStatus(sessionId, status) {
|
|
633
|
+
const resp = await fetch(
|
|
634
|
+
`${baseUrl}/api/v1/voice/dialer/sessions/${sessionId}/status`,
|
|
635
|
+
{
|
|
636
|
+
method: "PATCH",
|
|
637
|
+
headers: headers(),
|
|
638
|
+
body: JSON.stringify({ status })
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
const data = await resp.json();
|
|
642
|
+
return data.data || data;
|
|
643
|
+
},
|
|
644
|
+
/**
|
|
645
|
+
* Resume a PAUSED dialer session. Auto-fetches the next batch from the source list,
|
|
646
|
+
* filters already-called + phoneless rows, and forwards to voice's start-session.
|
|
647
|
+
* @param maxContacts 1-4 (voice caps parallel dialing at 4). Default 4.
|
|
648
|
+
*/
|
|
649
|
+
async resumeSession(sessionId, maxContacts = 4) {
|
|
650
|
+
const resp = await fetch(
|
|
651
|
+
`${baseUrl}/api/v1/voice/dialer/sessions/${sessionId}/resume`,
|
|
652
|
+
{
|
|
653
|
+
method: "POST",
|
|
654
|
+
headers: headers(),
|
|
655
|
+
body: JSON.stringify({ max_contacts: maxContacts })
|
|
656
|
+
}
|
|
657
|
+
);
|
|
658
|
+
const data = await resp.json();
|
|
659
|
+
return data.data || data;
|
|
660
|
+
},
|
|
661
|
+
/** Aggregated dialer analytics (daily breakdown or total). */
|
|
662
|
+
async stats(params = {}) {
|
|
663
|
+
const resp = await fetch(
|
|
664
|
+
`${baseUrl}/api/v1/voice/dialer/stats${toQuery(params)}`,
|
|
665
|
+
{ headers: headers() }
|
|
666
|
+
);
|
|
667
|
+
const data = await resp.json();
|
|
668
|
+
return data.data || data;
|
|
669
|
+
},
|
|
670
|
+
/** List dialer-eligible phone numbers with 7-day stats + daily limits. */
|
|
671
|
+
async numbers(userEmail) {
|
|
672
|
+
const params = userEmail ? { user_email: userEmail } : {};
|
|
673
|
+
const resp = await fetch(
|
|
674
|
+
`${baseUrl}/api/v1/voice/dialer/numbers${toQuery(params)}`,
|
|
675
|
+
{ headers: headers() }
|
|
676
|
+
);
|
|
677
|
+
const data = await resp.json();
|
|
678
|
+
return data.data || data;
|
|
679
|
+
},
|
|
680
|
+
/** List missed inbound callbacks with caller / contact info. */
|
|
681
|
+
async missedCallbacks(limit = 50) {
|
|
682
|
+
const resp = await fetch(
|
|
683
|
+
`${baseUrl}/api/v1/voice/dialer/missed-callbacks${toQuery({ limit })}`,
|
|
684
|
+
{ headers: headers() }
|
|
685
|
+
);
|
|
686
|
+
const data = await resp.json();
|
|
687
|
+
return data.data || data;
|
|
688
|
+
},
|
|
689
|
+
/** AI grading for a single dialer call (returns "pending" while in progress). */
|
|
690
|
+
async callGrading(roomName) {
|
|
691
|
+
const resp = await fetch(
|
|
692
|
+
`${baseUrl}/api/v1/voice/dialer/calls/${encodeURIComponent(roomName)}/grading`,
|
|
693
|
+
{ headers: headers() }
|
|
694
|
+
);
|
|
695
|
+
const data = await resp.json();
|
|
696
|
+
return data.data || data;
|
|
697
|
+
},
|
|
698
|
+
/** List voice agents available for dialer sessions (capped at 100; no pagination). */
|
|
699
|
+
async agents(params = {}) {
|
|
700
|
+
const resp = await fetch(
|
|
701
|
+
`${baseUrl}/api/v1/voice/dialer/agents${toQuery(params)}`,
|
|
702
|
+
{ headers: headers() }
|
|
703
|
+
);
|
|
704
|
+
const data = await resp.json();
|
|
705
|
+
return data.data || data;
|
|
706
|
+
}
|
|
707
|
+
};
|
|
488
708
|
return {
|
|
489
|
-
/**
|
|
709
|
+
/**
|
|
710
|
+
* Start an AI voice session.
|
|
711
|
+
* @deprecated Preview surface — for parallel-dialer flows use `voice.dialer.createSession()`.
|
|
712
|
+
*/
|
|
490
713
|
async start(config) {
|
|
491
714
|
const resp = await fetch(`${baseUrl}/api/v1/voice/sessions`, {
|
|
492
715
|
method: "POST",
|
|
@@ -496,7 +719,10 @@ var createVoiceClient = (apiKey, apiUrl) => {
|
|
|
496
719
|
const data = await resp.json();
|
|
497
720
|
return data.data || data;
|
|
498
721
|
},
|
|
499
|
-
/**
|
|
722
|
+
/**
|
|
723
|
+
* Get call analysis for a completed session.
|
|
724
|
+
* @deprecated Preview surface — for dialer-call grading use `voice.dialer.callGrading(roomName)`.
|
|
725
|
+
*/
|
|
500
726
|
async analysis(sessionId) {
|
|
501
727
|
const resp = await fetch(`${baseUrl}/api/v1/voice/sessions/${sessionId}/analysis`, { headers: headers() });
|
|
502
728
|
const data = await resp.json();
|
|
@@ -506,7 +732,9 @@ var createVoiceClient = (apiKey, apiUrl) => {
|
|
|
506
732
|
on(event, callback) {
|
|
507
733
|
if (!listeners.has(event)) listeners.set(event, []);
|
|
508
734
|
listeners.get(event).push(callback);
|
|
509
|
-
}
|
|
735
|
+
},
|
|
736
|
+
/** Parallel-dialer session control + analytics. */
|
|
737
|
+
dialer
|
|
510
738
|
};
|
|
511
739
|
};
|
|
512
740
|
|
|
@@ -638,6 +866,28 @@ var createContactsClient = (apiKey, apiUrl) => {
|
|
|
638
866
|
headers: headers()
|
|
639
867
|
});
|
|
640
868
|
return resp.json();
|
|
869
|
+
},
|
|
870
|
+
/** List custom contact columns. Pass listId to include list-specific columns. */
|
|
871
|
+
async listColumns(listId) {
|
|
872
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
873
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns${qs}`, { headers: headers() });
|
|
874
|
+
return resp.json();
|
|
875
|
+
},
|
|
876
|
+
/** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
|
|
877
|
+
async createColumn(params) {
|
|
878
|
+
const body = {
|
|
879
|
+
title: params.title,
|
|
880
|
+
data_type: params.data_type || "text",
|
|
881
|
+
list_id: params.list_id ?? null,
|
|
882
|
+
created_by: params.created_by
|
|
883
|
+
};
|
|
884
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns/create`, {
|
|
885
|
+
method: "POST",
|
|
886
|
+
headers: headers(),
|
|
887
|
+
body: JSON.stringify(body)
|
|
888
|
+
});
|
|
889
|
+
const data = await resp.json();
|
|
890
|
+
return data.data || data;
|
|
641
891
|
}
|
|
642
892
|
};
|
|
643
893
|
};
|
|
@@ -691,6 +941,28 @@ var createCompaniesClient = (apiKey, apiUrl) => {
|
|
|
691
941
|
headers: headers()
|
|
692
942
|
});
|
|
693
943
|
return resp.json();
|
|
944
|
+
},
|
|
945
|
+
/** List custom company columns. Pass listId to include list-specific columns. */
|
|
946
|
+
async listColumns(listId) {
|
|
947
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
948
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns${qs}`, { headers: headers() });
|
|
949
|
+
return resp.json();
|
|
950
|
+
},
|
|
951
|
+
/** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
|
|
952
|
+
async createColumn(params) {
|
|
953
|
+
const body = {
|
|
954
|
+
title: params.title,
|
|
955
|
+
data_type: params.data_type || "text",
|
|
956
|
+
list_id: params.list_id ?? null,
|
|
957
|
+
created_by: params.created_by
|
|
958
|
+
};
|
|
959
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns/create`, {
|
|
960
|
+
method: "POST",
|
|
961
|
+
headers: headers(),
|
|
962
|
+
body: JSON.stringify(body)
|
|
963
|
+
});
|
|
964
|
+
const data = await resp.json();
|
|
965
|
+
return data.data || data;
|
|
694
966
|
}
|
|
695
967
|
};
|
|
696
968
|
};
|
|
@@ -753,9 +1025,326 @@ var createListsClient = (apiKey, apiUrl) => {
|
|
|
753
1025
|
};
|
|
754
1026
|
};
|
|
755
1027
|
|
|
1028
|
+
// src/notes.ts
|
|
1029
|
+
var DEFAULT_API18 = "https://be.graph8.com";
|
|
1030
|
+
var createNotesClient = (apiKey, apiUrl) => {
|
|
1031
|
+
const baseUrl = apiUrl || DEFAULT_API18;
|
|
1032
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
1033
|
+
return {
|
|
1034
|
+
/** List all notes on a contact. */
|
|
1035
|
+
async list(contactId) {
|
|
1036
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, { headers: headers() });
|
|
1037
|
+
return resp.json();
|
|
1038
|
+
},
|
|
1039
|
+
/** Create a note on a contact. */
|
|
1040
|
+
async create(contactId, content) {
|
|
1041
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, {
|
|
1042
|
+
method: "POST",
|
|
1043
|
+
headers: headers(),
|
|
1044
|
+
body: JSON.stringify({ content })
|
|
1045
|
+
});
|
|
1046
|
+
const data = await resp.json();
|
|
1047
|
+
return data.data || data;
|
|
1048
|
+
},
|
|
1049
|
+
/** Update a note's content. */
|
|
1050
|
+
async update(noteId, content) {
|
|
1051
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
1052
|
+
method: "PATCH",
|
|
1053
|
+
headers: headers(),
|
|
1054
|
+
body: JSON.stringify({ content })
|
|
1055
|
+
});
|
|
1056
|
+
const data = await resp.json();
|
|
1057
|
+
return data.data || data;
|
|
1058
|
+
},
|
|
1059
|
+
/** Delete a note. */
|
|
1060
|
+
async delete(noteId) {
|
|
1061
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
1062
|
+
method: "DELETE",
|
|
1063
|
+
headers: headers()
|
|
1064
|
+
});
|
|
1065
|
+
return resp.json();
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
// src/tasks.ts
|
|
1071
|
+
var DEFAULT_API19 = "https://be.graph8.com";
|
|
1072
|
+
var createTasksClient = (apiKey, apiUrl) => {
|
|
1073
|
+
const baseUrl = apiUrl || DEFAULT_API19;
|
|
1074
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
1075
|
+
const toQuery = (params) => {
|
|
1076
|
+
const qs = new URLSearchParams();
|
|
1077
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1078
|
+
if (v != null) qs.set(k, String(v));
|
|
1079
|
+
}
|
|
1080
|
+
const s = qs.toString();
|
|
1081
|
+
return s ? `?${s}` : "";
|
|
1082
|
+
};
|
|
1083
|
+
return {
|
|
1084
|
+
/** List tasks on a single contact. Optional status filter ("open" | "completed"). */
|
|
1085
|
+
async listForContact(contactId, status) {
|
|
1086
|
+
const qs = status ? `?status=${encodeURIComponent(status)}` : "";
|
|
1087
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks${qs}`, { headers: headers() });
|
|
1088
|
+
return resp.json();
|
|
1089
|
+
},
|
|
1090
|
+
/** List all tasks org-wide with optional filters. */
|
|
1091
|
+
async list(params = {}) {
|
|
1092
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks${toQuery(params)}`, { headers: headers() });
|
|
1093
|
+
return resp.json();
|
|
1094
|
+
},
|
|
1095
|
+
/** Create a task on a contact. */
|
|
1096
|
+
async create(contactId, task) {
|
|
1097
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks`, {
|
|
1098
|
+
method: "POST",
|
|
1099
|
+
headers: headers(),
|
|
1100
|
+
body: JSON.stringify(task)
|
|
1101
|
+
});
|
|
1102
|
+
const data = await resp.json();
|
|
1103
|
+
return data.data || data;
|
|
1104
|
+
},
|
|
1105
|
+
/** Update a task (partial). */
|
|
1106
|
+
async update(taskId, fields) {
|
|
1107
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
1108
|
+
method: "PATCH",
|
|
1109
|
+
headers: headers(),
|
|
1110
|
+
body: JSON.stringify(fields)
|
|
1111
|
+
});
|
|
1112
|
+
const data = await resp.json();
|
|
1113
|
+
return data.data || data;
|
|
1114
|
+
},
|
|
1115
|
+
/** Delete a task. */
|
|
1116
|
+
async delete(taskId) {
|
|
1117
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
1118
|
+
method: "DELETE",
|
|
1119
|
+
headers: headers()
|
|
1120
|
+
});
|
|
1121
|
+
return resp.json();
|
|
1122
|
+
}
|
|
1123
|
+
};
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
// src/fields.ts
|
|
1127
|
+
var DEFAULT_API20 = "https://be.graph8.com";
|
|
1128
|
+
var createFieldsClient = (apiKey, apiUrl) => {
|
|
1129
|
+
const baseUrl = apiUrl || DEFAULT_API20;
|
|
1130
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
1131
|
+
const toQuery = (params) => {
|
|
1132
|
+
const qs = new URLSearchParams();
|
|
1133
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1134
|
+
if (v != null) qs.set(k, String(v));
|
|
1135
|
+
}
|
|
1136
|
+
const s = qs.toString();
|
|
1137
|
+
return s ? `?${s}` : "";
|
|
1138
|
+
};
|
|
1139
|
+
return {
|
|
1140
|
+
/** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
1141
|
+
async listContactFields(listId) {
|
|
1142
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
1143
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields${qs}`, { headers: headers() });
|
|
1144
|
+
return resp.json();
|
|
1145
|
+
},
|
|
1146
|
+
/** List company fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
1147
|
+
async listCompanyFields(listId) {
|
|
1148
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
1149
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/companies${qs}`, { headers: headers() });
|
|
1150
|
+
return resp.json();
|
|
1151
|
+
},
|
|
1152
|
+
/** Create a custom field on contacts (default) or companies. */
|
|
1153
|
+
async create(params) {
|
|
1154
|
+
const body = {
|
|
1155
|
+
title: params.title,
|
|
1156
|
+
data_type: params.data_type || "text",
|
|
1157
|
+
list_id: params.list_id ?? null,
|
|
1158
|
+
entity: params.entity || "contacts"
|
|
1159
|
+
};
|
|
1160
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields`, {
|
|
1161
|
+
method: "POST",
|
|
1162
|
+
headers: headers(),
|
|
1163
|
+
body: JSON.stringify(body)
|
|
1164
|
+
});
|
|
1165
|
+
const data = await resp.json();
|
|
1166
|
+
return data.data || data;
|
|
1167
|
+
},
|
|
1168
|
+
/** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
|
|
1169
|
+
async delete(columnId, params = {}) {
|
|
1170
|
+
const queryParams = { entity: params.entity || "contacts" };
|
|
1171
|
+
if (params.list_id != null) queryParams.list_id = params.list_id;
|
|
1172
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}${toQuery(queryParams)}`, {
|
|
1173
|
+
method: "DELETE",
|
|
1174
|
+
headers: headers()
|
|
1175
|
+
});
|
|
1176
|
+
return resp.json();
|
|
1177
|
+
},
|
|
1178
|
+
/** Set a custom field value on a single contact or company row. Pass value=null to clear. */
|
|
1179
|
+
async setValue(columnId, params) {
|
|
1180
|
+
const body = {
|
|
1181
|
+
record_id: params.record_id,
|
|
1182
|
+
value: params.value ?? null,
|
|
1183
|
+
entity: params.entity || "contacts"
|
|
1184
|
+
};
|
|
1185
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}/values`, {
|
|
1186
|
+
method: "PATCH",
|
|
1187
|
+
headers: headers(),
|
|
1188
|
+
body: JSON.stringify(body)
|
|
1189
|
+
});
|
|
1190
|
+
return resp.json();
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
};
|
|
1194
|
+
|
|
1195
|
+
// src/deals.ts
|
|
1196
|
+
var DEFAULT_API21 = "https://be.graph8.com";
|
|
1197
|
+
var createDealsClient = (apiKey, apiUrl) => {
|
|
1198
|
+
const baseUrl = apiUrl || DEFAULT_API21;
|
|
1199
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
1200
|
+
const toQuery = (params) => {
|
|
1201
|
+
const qs = new URLSearchParams();
|
|
1202
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1203
|
+
if (v != null) qs.set(k, String(v));
|
|
1204
|
+
}
|
|
1205
|
+
const s = qs.toString();
|
|
1206
|
+
return s ? `?${s}` : "";
|
|
1207
|
+
};
|
|
1208
|
+
return {
|
|
1209
|
+
/** List all deal pipelines and their stages. */
|
|
1210
|
+
async pipelines() {
|
|
1211
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/pipelines`, { headers: headers() });
|
|
1212
|
+
return resp.json();
|
|
1213
|
+
},
|
|
1214
|
+
/** List deals org-wide with optional filters and pagination. */
|
|
1215
|
+
async list(params = {}) {
|
|
1216
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals${toQuery(params)}`, { headers: headers() });
|
|
1217
|
+
return resp.json();
|
|
1218
|
+
},
|
|
1219
|
+
/** Create a new deal. */
|
|
1220
|
+
async create(deal) {
|
|
1221
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals`, {
|
|
1222
|
+
method: "POST",
|
|
1223
|
+
headers: headers(),
|
|
1224
|
+
body: JSON.stringify(deal)
|
|
1225
|
+
});
|
|
1226
|
+
const data = await resp.json();
|
|
1227
|
+
return data.data || data;
|
|
1228
|
+
},
|
|
1229
|
+
/** Get a single deal by ID. */
|
|
1230
|
+
async get(dealId) {
|
|
1231
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, { headers: headers() });
|
|
1232
|
+
const data = await resp.json();
|
|
1233
|
+
return data.data || data;
|
|
1234
|
+
},
|
|
1235
|
+
/** Update a deal (partial). */
|
|
1236
|
+
async update(dealId, fields) {
|
|
1237
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
1238
|
+
method: "PATCH",
|
|
1239
|
+
headers: headers(),
|
|
1240
|
+
body: JSON.stringify(fields)
|
|
1241
|
+
});
|
|
1242
|
+
const data = await resp.json();
|
|
1243
|
+
return data.data || data;
|
|
1244
|
+
},
|
|
1245
|
+
/** Delete a deal. */
|
|
1246
|
+
async delete(dealId) {
|
|
1247
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
1248
|
+
method: "DELETE",
|
|
1249
|
+
headers: headers()
|
|
1250
|
+
});
|
|
1251
|
+
return resp.json();
|
|
1252
|
+
},
|
|
1253
|
+
/** Get all deals associated with a contact. */
|
|
1254
|
+
async forContact(contactId) {
|
|
1255
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/deals`, { headers: headers() });
|
|
1256
|
+
return resp.json();
|
|
1257
|
+
},
|
|
1258
|
+
/** Get all deals associated with a company. */
|
|
1259
|
+
async forCompany(companyId) {
|
|
1260
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/${companyId}/deals`, { headers: headers() });
|
|
1261
|
+
return resp.json();
|
|
1262
|
+
}
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
|
|
1266
|
+
// src/inbox.ts
|
|
1267
|
+
var DEFAULT_API22 = "https://be.graph8.com";
|
|
1268
|
+
var createInboxClient = (apiKey, apiUrl) => {
|
|
1269
|
+
const baseUrl = apiUrl || DEFAULT_API22;
|
|
1270
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
1271
|
+
const toQuery = (params) => {
|
|
1272
|
+
const qs = new URLSearchParams();
|
|
1273
|
+
for (const [k, v] of Object.entries(params)) {
|
|
1274
|
+
if (v != null) qs.set(k, String(v));
|
|
1275
|
+
}
|
|
1276
|
+
const s = qs.toString();
|
|
1277
|
+
return s ? `?${s}` : "";
|
|
1278
|
+
};
|
|
1279
|
+
return {
|
|
1280
|
+
/** List inbox threads across email, SMS, and LinkedIn. */
|
|
1281
|
+
async list(params = {}) {
|
|
1282
|
+
const resp = await fetch(`${baseUrl}/api/v1/inbox${toQuery(params)}`, { headers: headers() });
|
|
1283
|
+
return resp.json();
|
|
1284
|
+
},
|
|
1285
|
+
/** Get a single inbox thread. Defaults to email channel. */
|
|
1286
|
+
async get(replyId, channel = "email") {
|
|
1287
|
+
const resp = await fetch(
|
|
1288
|
+
`${baseUrl}/api/v1/inbox/${replyId}${toQuery({ channel })}`,
|
|
1289
|
+
{ headers: headers() }
|
|
1290
|
+
);
|
|
1291
|
+
const data = await resp.json();
|
|
1292
|
+
return data.data || data;
|
|
1293
|
+
},
|
|
1294
|
+
/** Assign a user to an inbox thread. */
|
|
1295
|
+
async assign(replyId, assigneeEmail, channel = "email") {
|
|
1296
|
+
const resp = await fetch(
|
|
1297
|
+
`${baseUrl}/api/v1/inbox/${replyId}/assign${toQuery({ channel })}`,
|
|
1298
|
+
{
|
|
1299
|
+
method: "POST",
|
|
1300
|
+
headers: headers(),
|
|
1301
|
+
body: JSON.stringify({ assignee_email: assigneeEmail })
|
|
1302
|
+
}
|
|
1303
|
+
);
|
|
1304
|
+
const data = await resp.json();
|
|
1305
|
+
return data.data || data;
|
|
1306
|
+
},
|
|
1307
|
+
/** Attach tag IDs to an inbox thread. */
|
|
1308
|
+
async tag(replyId, tagIds, channel = "email") {
|
|
1309
|
+
const resp = await fetch(
|
|
1310
|
+
`${baseUrl}/api/v1/inbox/${replyId}/tag${toQuery({ channel })}`,
|
|
1311
|
+
{
|
|
1312
|
+
method: "POST",
|
|
1313
|
+
headers: headers(),
|
|
1314
|
+
body: JSON.stringify({ tag_ids: tagIds })
|
|
1315
|
+
}
|
|
1316
|
+
);
|
|
1317
|
+
const data = await resp.json();
|
|
1318
|
+
return data.data || data;
|
|
1319
|
+
},
|
|
1320
|
+
/**
|
|
1321
|
+
* Generate an AI draft reply for a thread.
|
|
1322
|
+
* Charges credits — server returns 402 if balance is insufficient.
|
|
1323
|
+
*/
|
|
1324
|
+
async draft(replyId, channel = "email") {
|
|
1325
|
+
const resp = await fetch(
|
|
1326
|
+
`${baseUrl}/api/v1/inbox/${replyId}/draft${toQuery({ channel })}`,
|
|
1327
|
+
{ headers: headers() }
|
|
1328
|
+
);
|
|
1329
|
+
const data = await resp.json();
|
|
1330
|
+
return data.data || data;
|
|
1331
|
+
},
|
|
1332
|
+
/** Send a reply through email, SMS, or LinkedIn. */
|
|
1333
|
+
async send(replyId, payload) {
|
|
1334
|
+
const resp = await fetch(`${baseUrl}/api/v1/inbox/${replyId}/send`, {
|
|
1335
|
+
method: "POST",
|
|
1336
|
+
headers: headers(),
|
|
1337
|
+
body: JSON.stringify(payload)
|
|
1338
|
+
});
|
|
1339
|
+
const data = await resp.json();
|
|
1340
|
+
return data.data || data;
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
};
|
|
1344
|
+
|
|
756
1345
|
// src/core.ts
|
|
757
1346
|
var DEFAULT_HOST = "https://t.graph8.com";
|
|
758
|
-
var
|
|
1347
|
+
var DEFAULT_API23 = "https://be.graph8.com";
|
|
759
1348
|
var G8 = class {
|
|
760
1349
|
constructor() {
|
|
761
1350
|
/** @internal */
|
|
@@ -796,6 +1385,16 @@ var G8 = class {
|
|
|
796
1385
|
this._companies = null;
|
|
797
1386
|
/** @internal */
|
|
798
1387
|
this._lists = null;
|
|
1388
|
+
/** @internal */
|
|
1389
|
+
this._notes = null;
|
|
1390
|
+
/** @internal */
|
|
1391
|
+
this._tasks = null;
|
|
1392
|
+
/** @internal */
|
|
1393
|
+
this._fields = null;
|
|
1394
|
+
/** @internal */
|
|
1395
|
+
this._deals = null;
|
|
1396
|
+
/** @internal */
|
|
1397
|
+
this._inbox = null;
|
|
799
1398
|
}
|
|
800
1399
|
/**
|
|
801
1400
|
* Initialize the graph8 SDK. Must be called before any other method.
|
|
@@ -810,7 +1409,7 @@ var G8 = class {
|
|
|
810
1409
|
debug: config.debug
|
|
811
1410
|
});
|
|
812
1411
|
}
|
|
813
|
-
const apiUrl = config.apiUrl ||
|
|
1412
|
+
const apiUrl = config.apiUrl || DEFAULT_API23;
|
|
814
1413
|
const writeKey = config.writeKey || "";
|
|
815
1414
|
const apiKey = config.apiKey || "";
|
|
816
1415
|
if (writeKey) {
|
|
@@ -833,6 +1432,11 @@ var G8 = class {
|
|
|
833
1432
|
this._contacts = createContactsClient(apiKey, apiUrl);
|
|
834
1433
|
this._companies = createCompaniesClient(apiKey, apiUrl);
|
|
835
1434
|
this._lists = createListsClient(apiKey, apiUrl);
|
|
1435
|
+
this._notes = createNotesClient(apiKey, apiUrl);
|
|
1436
|
+
this._tasks = createTasksClient(apiKey, apiUrl);
|
|
1437
|
+
this._fields = createFieldsClient(apiKey, apiUrl);
|
|
1438
|
+
this._deals = createDealsClient(apiKey, apiUrl);
|
|
1439
|
+
this._inbox = createInboxClient(apiKey, apiUrl);
|
|
836
1440
|
this._signals = createSignalsClient(apiKey, true, apiUrl);
|
|
837
1441
|
}
|
|
838
1442
|
}
|
|
@@ -939,6 +1543,31 @@ var G8 = class {
|
|
|
939
1543
|
this._assertKey("lists");
|
|
940
1544
|
return this._lists;
|
|
941
1545
|
}
|
|
1546
|
+
/** Notes on contacts (requires API key). */
|
|
1547
|
+
get notes() {
|
|
1548
|
+
this._assertKey("notes");
|
|
1549
|
+
return this._notes;
|
|
1550
|
+
}
|
|
1551
|
+
/** Tasks on contacts (requires API key). */
|
|
1552
|
+
get tasks() {
|
|
1553
|
+
this._assertKey("tasks");
|
|
1554
|
+
return this._tasks;
|
|
1555
|
+
}
|
|
1556
|
+
/** Custom fields management (requires API key). */
|
|
1557
|
+
get fields() {
|
|
1558
|
+
this._assertKey("fields");
|
|
1559
|
+
return this._fields;
|
|
1560
|
+
}
|
|
1561
|
+
/** Deals and pipelines (requires API key). */
|
|
1562
|
+
get deals() {
|
|
1563
|
+
this._assertKey("deals");
|
|
1564
|
+
return this._deals;
|
|
1565
|
+
}
|
|
1566
|
+
/** Multi-channel inbox — read + reply across email, SMS, LinkedIn (requires API key). */
|
|
1567
|
+
get inbox() {
|
|
1568
|
+
this._assertKey("inbox");
|
|
1569
|
+
return this._inbox;
|
|
1570
|
+
}
|
|
942
1571
|
/** Whether the SDK has been initialized. */
|
|
943
1572
|
get initialized() {
|
|
944
1573
|
return this.config !== null;
|