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