@graph8/sdk 0.2.0 → 0.3.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/README.md +4 -4
- package/dist/index.d.mts +465 -1
- package/dist/index.d.ts +465 -1
- package/dist/index.js +316 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +316 -2
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +460 -0
- package/dist/react.d.ts +460 -0
- package/dist/react.js +316 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +316 -2
- package/dist/react.mjs.map +1 -1
- package/package.json +11 -6
package/dist/index.mjs
CHANGED
|
@@ -612,6 +612,28 @@ var createContactsClient = (apiKey, apiUrl) => {
|
|
|
612
612
|
headers: headers()
|
|
613
613
|
});
|
|
614
614
|
return resp.json();
|
|
615
|
+
},
|
|
616
|
+
/** List custom contact columns. Pass listId to include list-specific columns. */
|
|
617
|
+
async listColumns(listId) {
|
|
618
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
619
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns${qs}`, { headers: headers() });
|
|
620
|
+
return resp.json();
|
|
621
|
+
},
|
|
622
|
+
/** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
|
|
623
|
+
async createColumn(params) {
|
|
624
|
+
const body = {
|
|
625
|
+
title: params.title,
|
|
626
|
+
data_type: params.data_type || "text",
|
|
627
|
+
list_id: params.list_id ?? null,
|
|
628
|
+
created_by: params.created_by
|
|
629
|
+
};
|
|
630
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns/create`, {
|
|
631
|
+
method: "POST",
|
|
632
|
+
headers: headers(),
|
|
633
|
+
body: JSON.stringify(body)
|
|
634
|
+
});
|
|
635
|
+
const data = await resp.json();
|
|
636
|
+
return data.data || data;
|
|
615
637
|
}
|
|
616
638
|
};
|
|
617
639
|
};
|
|
@@ -665,6 +687,28 @@ var createCompaniesClient = (apiKey, apiUrl) => {
|
|
|
665
687
|
headers: headers()
|
|
666
688
|
});
|
|
667
689
|
return resp.json();
|
|
690
|
+
},
|
|
691
|
+
/** List custom company columns. Pass listId to include list-specific columns. */
|
|
692
|
+
async listColumns(listId) {
|
|
693
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
694
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns${qs}`, { headers: headers() });
|
|
695
|
+
return resp.json();
|
|
696
|
+
},
|
|
697
|
+
/** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
|
|
698
|
+
async createColumn(params) {
|
|
699
|
+
const body = {
|
|
700
|
+
title: params.title,
|
|
701
|
+
data_type: params.data_type || "text",
|
|
702
|
+
list_id: params.list_id ?? null,
|
|
703
|
+
created_by: params.created_by
|
|
704
|
+
};
|
|
705
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns/create`, {
|
|
706
|
+
method: "POST",
|
|
707
|
+
headers: headers(),
|
|
708
|
+
body: JSON.stringify(body)
|
|
709
|
+
});
|
|
710
|
+
const data = await resp.json();
|
|
711
|
+
return data.data || data;
|
|
668
712
|
}
|
|
669
713
|
};
|
|
670
714
|
};
|
|
@@ -727,9 +771,247 @@ var createListsClient = (apiKey, apiUrl) => {
|
|
|
727
771
|
};
|
|
728
772
|
};
|
|
729
773
|
|
|
774
|
+
// src/notes.ts
|
|
775
|
+
var DEFAULT_API18 = "https://be.graph8.com";
|
|
776
|
+
var createNotesClient = (apiKey, apiUrl) => {
|
|
777
|
+
const baseUrl = apiUrl || DEFAULT_API18;
|
|
778
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
779
|
+
return {
|
|
780
|
+
/** List all notes on a contact. */
|
|
781
|
+
async list(contactId) {
|
|
782
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, { headers: headers() });
|
|
783
|
+
return resp.json();
|
|
784
|
+
},
|
|
785
|
+
/** Create a note on a contact. */
|
|
786
|
+
async create(contactId, content) {
|
|
787
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, {
|
|
788
|
+
method: "POST",
|
|
789
|
+
headers: headers(),
|
|
790
|
+
body: JSON.stringify({ content })
|
|
791
|
+
});
|
|
792
|
+
const data = await resp.json();
|
|
793
|
+
return data.data || data;
|
|
794
|
+
},
|
|
795
|
+
/** Update a note's content. */
|
|
796
|
+
async update(noteId, content) {
|
|
797
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
798
|
+
method: "PATCH",
|
|
799
|
+
headers: headers(),
|
|
800
|
+
body: JSON.stringify({ content })
|
|
801
|
+
});
|
|
802
|
+
const data = await resp.json();
|
|
803
|
+
return data.data || data;
|
|
804
|
+
},
|
|
805
|
+
/** Delete a note. */
|
|
806
|
+
async delete(noteId) {
|
|
807
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
808
|
+
method: "DELETE",
|
|
809
|
+
headers: headers()
|
|
810
|
+
});
|
|
811
|
+
return resp.json();
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
// src/tasks.ts
|
|
817
|
+
var DEFAULT_API19 = "https://be.graph8.com";
|
|
818
|
+
var createTasksClient = (apiKey, apiUrl) => {
|
|
819
|
+
const baseUrl = apiUrl || DEFAULT_API19;
|
|
820
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
821
|
+
const toQuery = (params) => {
|
|
822
|
+
const qs = new URLSearchParams();
|
|
823
|
+
for (const [k, v] of Object.entries(params)) {
|
|
824
|
+
if (v != null) qs.set(k, String(v));
|
|
825
|
+
}
|
|
826
|
+
const s = qs.toString();
|
|
827
|
+
return s ? `?${s}` : "";
|
|
828
|
+
};
|
|
829
|
+
return {
|
|
830
|
+
/** List tasks on a single contact. Optional status filter ("open" | "completed"). */
|
|
831
|
+
async listForContact(contactId, status) {
|
|
832
|
+
const qs = status ? `?status=${encodeURIComponent(status)}` : "";
|
|
833
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks${qs}`, { headers: headers() });
|
|
834
|
+
return resp.json();
|
|
835
|
+
},
|
|
836
|
+
/** List all tasks org-wide with optional filters. */
|
|
837
|
+
async list(params = {}) {
|
|
838
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks${toQuery(params)}`, { headers: headers() });
|
|
839
|
+
return resp.json();
|
|
840
|
+
},
|
|
841
|
+
/** Create a task on a contact. */
|
|
842
|
+
async create(contactId, task) {
|
|
843
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks`, {
|
|
844
|
+
method: "POST",
|
|
845
|
+
headers: headers(),
|
|
846
|
+
body: JSON.stringify(task)
|
|
847
|
+
});
|
|
848
|
+
const data = await resp.json();
|
|
849
|
+
return data.data || data;
|
|
850
|
+
},
|
|
851
|
+
/** Update a task (partial). */
|
|
852
|
+
async update(taskId, fields) {
|
|
853
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
854
|
+
method: "PATCH",
|
|
855
|
+
headers: headers(),
|
|
856
|
+
body: JSON.stringify(fields)
|
|
857
|
+
});
|
|
858
|
+
const data = await resp.json();
|
|
859
|
+
return data.data || data;
|
|
860
|
+
},
|
|
861
|
+
/** Delete a task. */
|
|
862
|
+
async delete(taskId) {
|
|
863
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
864
|
+
method: "DELETE",
|
|
865
|
+
headers: headers()
|
|
866
|
+
});
|
|
867
|
+
return resp.json();
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// src/fields.ts
|
|
873
|
+
var DEFAULT_API20 = "https://be.graph8.com";
|
|
874
|
+
var createFieldsClient = (apiKey, apiUrl) => {
|
|
875
|
+
const baseUrl = apiUrl || DEFAULT_API20;
|
|
876
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
877
|
+
const toQuery = (params) => {
|
|
878
|
+
const qs = new URLSearchParams();
|
|
879
|
+
for (const [k, v] of Object.entries(params)) {
|
|
880
|
+
if (v != null) qs.set(k, String(v));
|
|
881
|
+
}
|
|
882
|
+
const s = qs.toString();
|
|
883
|
+
return s ? `?${s}` : "";
|
|
884
|
+
};
|
|
885
|
+
return {
|
|
886
|
+
/** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
887
|
+
async listContactFields(listId) {
|
|
888
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
889
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields${qs}`, { headers: headers() });
|
|
890
|
+
return resp.json();
|
|
891
|
+
},
|
|
892
|
+
/** List company fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
893
|
+
async listCompanyFields(listId) {
|
|
894
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
895
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/companies${qs}`, { headers: headers() });
|
|
896
|
+
return resp.json();
|
|
897
|
+
},
|
|
898
|
+
/** Create a custom field on contacts (default) or companies. */
|
|
899
|
+
async create(params) {
|
|
900
|
+
const body = {
|
|
901
|
+
title: params.title,
|
|
902
|
+
data_type: params.data_type || "text",
|
|
903
|
+
list_id: params.list_id ?? null,
|
|
904
|
+
entity: params.entity || "contacts"
|
|
905
|
+
};
|
|
906
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields`, {
|
|
907
|
+
method: "POST",
|
|
908
|
+
headers: headers(),
|
|
909
|
+
body: JSON.stringify(body)
|
|
910
|
+
});
|
|
911
|
+
const data = await resp.json();
|
|
912
|
+
return data.data || data;
|
|
913
|
+
},
|
|
914
|
+
/** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
|
|
915
|
+
async delete(columnId, params = {}) {
|
|
916
|
+
const queryParams = { entity: params.entity || "contacts" };
|
|
917
|
+
if (params.list_id != null) queryParams.list_id = params.list_id;
|
|
918
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}${toQuery(queryParams)}`, {
|
|
919
|
+
method: "DELETE",
|
|
920
|
+
headers: headers()
|
|
921
|
+
});
|
|
922
|
+
return resp.json();
|
|
923
|
+
},
|
|
924
|
+
/** Set a custom field value on a single contact or company row. Pass value=null to clear. */
|
|
925
|
+
async setValue(columnId, params) {
|
|
926
|
+
const body = {
|
|
927
|
+
record_id: params.record_id,
|
|
928
|
+
value: params.value ?? null,
|
|
929
|
+
entity: params.entity || "contacts"
|
|
930
|
+
};
|
|
931
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}/values`, {
|
|
932
|
+
method: "PATCH",
|
|
933
|
+
headers: headers(),
|
|
934
|
+
body: JSON.stringify(body)
|
|
935
|
+
});
|
|
936
|
+
return resp.json();
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// src/deals.ts
|
|
942
|
+
var DEFAULT_API21 = "https://be.graph8.com";
|
|
943
|
+
var createDealsClient = (apiKey, apiUrl) => {
|
|
944
|
+
const baseUrl = apiUrl || DEFAULT_API21;
|
|
945
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
946
|
+
const toQuery = (params) => {
|
|
947
|
+
const qs = new URLSearchParams();
|
|
948
|
+
for (const [k, v] of Object.entries(params)) {
|
|
949
|
+
if (v != null) qs.set(k, String(v));
|
|
950
|
+
}
|
|
951
|
+
const s = qs.toString();
|
|
952
|
+
return s ? `?${s}` : "";
|
|
953
|
+
};
|
|
954
|
+
return {
|
|
955
|
+
/** List all deal pipelines and their stages. */
|
|
956
|
+
async pipelines() {
|
|
957
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/pipelines`, { headers: headers() });
|
|
958
|
+
return resp.json();
|
|
959
|
+
},
|
|
960
|
+
/** List deals org-wide with optional filters and pagination. */
|
|
961
|
+
async list(params = {}) {
|
|
962
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals${toQuery(params)}`, { headers: headers() });
|
|
963
|
+
return resp.json();
|
|
964
|
+
},
|
|
965
|
+
/** Create a new deal. */
|
|
966
|
+
async create(deal) {
|
|
967
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals`, {
|
|
968
|
+
method: "POST",
|
|
969
|
+
headers: headers(),
|
|
970
|
+
body: JSON.stringify(deal)
|
|
971
|
+
});
|
|
972
|
+
const data = await resp.json();
|
|
973
|
+
return data.data || data;
|
|
974
|
+
},
|
|
975
|
+
/** Get a single deal by ID. */
|
|
976
|
+
async get(dealId) {
|
|
977
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, { headers: headers() });
|
|
978
|
+
const data = await resp.json();
|
|
979
|
+
return data.data || data;
|
|
980
|
+
},
|
|
981
|
+
/** Update a deal (partial). */
|
|
982
|
+
async update(dealId, fields) {
|
|
983
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
984
|
+
method: "PATCH",
|
|
985
|
+
headers: headers(),
|
|
986
|
+
body: JSON.stringify(fields)
|
|
987
|
+
});
|
|
988
|
+
const data = await resp.json();
|
|
989
|
+
return data.data || data;
|
|
990
|
+
},
|
|
991
|
+
/** Delete a deal. */
|
|
992
|
+
async delete(dealId) {
|
|
993
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
994
|
+
method: "DELETE",
|
|
995
|
+
headers: headers()
|
|
996
|
+
});
|
|
997
|
+
return resp.json();
|
|
998
|
+
},
|
|
999
|
+
/** Get all deals associated with a contact. */
|
|
1000
|
+
async forContact(contactId) {
|
|
1001
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/deals`, { headers: headers() });
|
|
1002
|
+
return resp.json();
|
|
1003
|
+
},
|
|
1004
|
+
/** Get all deals associated with a company. */
|
|
1005
|
+
async forCompany(companyId) {
|
|
1006
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/${companyId}/deals`, { headers: headers() });
|
|
1007
|
+
return resp.json();
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
};
|
|
1011
|
+
|
|
730
1012
|
// src/core.ts
|
|
731
1013
|
var DEFAULT_HOST = "https://t.graph8.com";
|
|
732
|
-
var
|
|
1014
|
+
var DEFAULT_API22 = "https://be.graph8.com";
|
|
733
1015
|
var G8 = class {
|
|
734
1016
|
constructor() {
|
|
735
1017
|
/** @internal */
|
|
@@ -770,6 +1052,14 @@ var G8 = class {
|
|
|
770
1052
|
this._companies = null;
|
|
771
1053
|
/** @internal */
|
|
772
1054
|
this._lists = null;
|
|
1055
|
+
/** @internal */
|
|
1056
|
+
this._notes = null;
|
|
1057
|
+
/** @internal */
|
|
1058
|
+
this._tasks = null;
|
|
1059
|
+
/** @internal */
|
|
1060
|
+
this._fields = null;
|
|
1061
|
+
/** @internal */
|
|
1062
|
+
this._deals = null;
|
|
773
1063
|
}
|
|
774
1064
|
/**
|
|
775
1065
|
* Initialize the graph8 SDK. Must be called before any other method.
|
|
@@ -784,7 +1074,7 @@ var G8 = class {
|
|
|
784
1074
|
debug: config.debug
|
|
785
1075
|
});
|
|
786
1076
|
}
|
|
787
|
-
const apiUrl = config.apiUrl ||
|
|
1077
|
+
const apiUrl = config.apiUrl || DEFAULT_API22;
|
|
788
1078
|
const writeKey = config.writeKey || "";
|
|
789
1079
|
const apiKey = config.apiKey || "";
|
|
790
1080
|
if (writeKey) {
|
|
@@ -807,6 +1097,10 @@ var G8 = class {
|
|
|
807
1097
|
this._contacts = createContactsClient(apiKey, apiUrl);
|
|
808
1098
|
this._companies = createCompaniesClient(apiKey, apiUrl);
|
|
809
1099
|
this._lists = createListsClient(apiKey, apiUrl);
|
|
1100
|
+
this._notes = createNotesClient(apiKey, apiUrl);
|
|
1101
|
+
this._tasks = createTasksClient(apiKey, apiUrl);
|
|
1102
|
+
this._fields = createFieldsClient(apiKey, apiUrl);
|
|
1103
|
+
this._deals = createDealsClient(apiKey, apiUrl);
|
|
810
1104
|
this._signals = createSignalsClient(apiKey, true, apiUrl);
|
|
811
1105
|
}
|
|
812
1106
|
}
|
|
@@ -913,6 +1207,26 @@ var G8 = class {
|
|
|
913
1207
|
this._assertKey("lists");
|
|
914
1208
|
return this._lists;
|
|
915
1209
|
}
|
|
1210
|
+
/** Notes on contacts (requires API key). */
|
|
1211
|
+
get notes() {
|
|
1212
|
+
this._assertKey("notes");
|
|
1213
|
+
return this._notes;
|
|
1214
|
+
}
|
|
1215
|
+
/** Tasks on contacts (requires API key). */
|
|
1216
|
+
get tasks() {
|
|
1217
|
+
this._assertKey("tasks");
|
|
1218
|
+
return this._tasks;
|
|
1219
|
+
}
|
|
1220
|
+
/** Custom fields management (requires API key). */
|
|
1221
|
+
get fields() {
|
|
1222
|
+
this._assertKey("fields");
|
|
1223
|
+
return this._fields;
|
|
1224
|
+
}
|
|
1225
|
+
/** Deals and pipelines (requires API key). */
|
|
1226
|
+
get deals() {
|
|
1227
|
+
this._assertKey("deals");
|
|
1228
|
+
return this._deals;
|
|
1229
|
+
}
|
|
916
1230
|
/** Whether the SDK has been initialized. */
|
|
917
1231
|
get initialized() {
|
|
918
1232
|
return this.config !== null;
|