@graph8/sdk 0.2.1 → 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/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 +1 -1
package/dist/react.js
CHANGED
|
@@ -641,6 +641,28 @@ var createContactsClient = (apiKey, apiUrl) => {
|
|
|
641
641
|
headers: headers()
|
|
642
642
|
});
|
|
643
643
|
return resp.json();
|
|
644
|
+
},
|
|
645
|
+
/** List custom contact columns. Pass listId to include list-specific columns. */
|
|
646
|
+
async listColumns(listId) {
|
|
647
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
648
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns${qs}`, { headers: headers() });
|
|
649
|
+
return resp.json();
|
|
650
|
+
},
|
|
651
|
+
/** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
|
|
652
|
+
async createColumn(params) {
|
|
653
|
+
const body = {
|
|
654
|
+
title: params.title,
|
|
655
|
+
data_type: params.data_type || "text",
|
|
656
|
+
list_id: params.list_id ?? null,
|
|
657
|
+
created_by: params.created_by
|
|
658
|
+
};
|
|
659
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/columns/create`, {
|
|
660
|
+
method: "POST",
|
|
661
|
+
headers: headers(),
|
|
662
|
+
body: JSON.stringify(body)
|
|
663
|
+
});
|
|
664
|
+
const data = await resp.json();
|
|
665
|
+
return data.data || data;
|
|
644
666
|
}
|
|
645
667
|
};
|
|
646
668
|
};
|
|
@@ -694,6 +716,28 @@ var createCompaniesClient = (apiKey, apiUrl) => {
|
|
|
694
716
|
headers: headers()
|
|
695
717
|
});
|
|
696
718
|
return resp.json();
|
|
719
|
+
},
|
|
720
|
+
/** List custom company columns. Pass listId to include list-specific columns. */
|
|
721
|
+
async listColumns(listId) {
|
|
722
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
723
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns${qs}`, { headers: headers() });
|
|
724
|
+
return resp.json();
|
|
725
|
+
},
|
|
726
|
+
/** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
|
|
727
|
+
async createColumn(params) {
|
|
728
|
+
const body = {
|
|
729
|
+
title: params.title,
|
|
730
|
+
data_type: params.data_type || "text",
|
|
731
|
+
list_id: params.list_id ?? null,
|
|
732
|
+
created_by: params.created_by
|
|
733
|
+
};
|
|
734
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/columns/create`, {
|
|
735
|
+
method: "POST",
|
|
736
|
+
headers: headers(),
|
|
737
|
+
body: JSON.stringify(body)
|
|
738
|
+
});
|
|
739
|
+
const data = await resp.json();
|
|
740
|
+
return data.data || data;
|
|
697
741
|
}
|
|
698
742
|
};
|
|
699
743
|
};
|
|
@@ -756,9 +800,247 @@ var createListsClient = (apiKey, apiUrl) => {
|
|
|
756
800
|
};
|
|
757
801
|
};
|
|
758
802
|
|
|
803
|
+
// src/notes.ts
|
|
804
|
+
var DEFAULT_API18 = "https://be.graph8.com";
|
|
805
|
+
var createNotesClient = (apiKey, apiUrl) => {
|
|
806
|
+
const baseUrl = apiUrl || DEFAULT_API18;
|
|
807
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
808
|
+
return {
|
|
809
|
+
/** List all notes on a contact. */
|
|
810
|
+
async list(contactId) {
|
|
811
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, { headers: headers() });
|
|
812
|
+
return resp.json();
|
|
813
|
+
},
|
|
814
|
+
/** Create a note on a contact. */
|
|
815
|
+
async create(contactId, content) {
|
|
816
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/notes`, {
|
|
817
|
+
method: "POST",
|
|
818
|
+
headers: headers(),
|
|
819
|
+
body: JSON.stringify({ content })
|
|
820
|
+
});
|
|
821
|
+
const data = await resp.json();
|
|
822
|
+
return data.data || data;
|
|
823
|
+
},
|
|
824
|
+
/** Update a note's content. */
|
|
825
|
+
async update(noteId, content) {
|
|
826
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
827
|
+
method: "PATCH",
|
|
828
|
+
headers: headers(),
|
|
829
|
+
body: JSON.stringify({ content })
|
|
830
|
+
});
|
|
831
|
+
const data = await resp.json();
|
|
832
|
+
return data.data || data;
|
|
833
|
+
},
|
|
834
|
+
/** Delete a note. */
|
|
835
|
+
async delete(noteId) {
|
|
836
|
+
const resp = await fetch(`${baseUrl}/api/v1/notes/${noteId}`, {
|
|
837
|
+
method: "DELETE",
|
|
838
|
+
headers: headers()
|
|
839
|
+
});
|
|
840
|
+
return resp.json();
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
};
|
|
844
|
+
|
|
845
|
+
// src/tasks.ts
|
|
846
|
+
var DEFAULT_API19 = "https://be.graph8.com";
|
|
847
|
+
var createTasksClient = (apiKey, apiUrl) => {
|
|
848
|
+
const baseUrl = apiUrl || DEFAULT_API19;
|
|
849
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
850
|
+
const toQuery = (params) => {
|
|
851
|
+
const qs = new URLSearchParams();
|
|
852
|
+
for (const [k, v] of Object.entries(params)) {
|
|
853
|
+
if (v != null) qs.set(k, String(v));
|
|
854
|
+
}
|
|
855
|
+
const s = qs.toString();
|
|
856
|
+
return s ? `?${s}` : "";
|
|
857
|
+
};
|
|
858
|
+
return {
|
|
859
|
+
/** List tasks on a single contact. Optional status filter ("open" | "completed"). */
|
|
860
|
+
async listForContact(contactId, status) {
|
|
861
|
+
const qs = status ? `?status=${encodeURIComponent(status)}` : "";
|
|
862
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks${qs}`, { headers: headers() });
|
|
863
|
+
return resp.json();
|
|
864
|
+
},
|
|
865
|
+
/** List all tasks org-wide with optional filters. */
|
|
866
|
+
async list(params = {}) {
|
|
867
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks${toQuery(params)}`, { headers: headers() });
|
|
868
|
+
return resp.json();
|
|
869
|
+
},
|
|
870
|
+
/** Create a task on a contact. */
|
|
871
|
+
async create(contactId, task) {
|
|
872
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/tasks`, {
|
|
873
|
+
method: "POST",
|
|
874
|
+
headers: headers(),
|
|
875
|
+
body: JSON.stringify(task)
|
|
876
|
+
});
|
|
877
|
+
const data = await resp.json();
|
|
878
|
+
return data.data || data;
|
|
879
|
+
},
|
|
880
|
+
/** Update a task (partial). */
|
|
881
|
+
async update(taskId, fields) {
|
|
882
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
883
|
+
method: "PATCH",
|
|
884
|
+
headers: headers(),
|
|
885
|
+
body: JSON.stringify(fields)
|
|
886
|
+
});
|
|
887
|
+
const data = await resp.json();
|
|
888
|
+
return data.data || data;
|
|
889
|
+
},
|
|
890
|
+
/** Delete a task. */
|
|
891
|
+
async delete(taskId) {
|
|
892
|
+
const resp = await fetch(`${baseUrl}/api/v1/tasks/${taskId}`, {
|
|
893
|
+
method: "DELETE",
|
|
894
|
+
headers: headers()
|
|
895
|
+
});
|
|
896
|
+
return resp.json();
|
|
897
|
+
}
|
|
898
|
+
};
|
|
899
|
+
};
|
|
900
|
+
|
|
901
|
+
// src/fields.ts
|
|
902
|
+
var DEFAULT_API20 = "https://be.graph8.com";
|
|
903
|
+
var createFieldsClient = (apiKey, apiUrl) => {
|
|
904
|
+
const baseUrl = apiUrl || DEFAULT_API20;
|
|
905
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
906
|
+
const toQuery = (params) => {
|
|
907
|
+
const qs = new URLSearchParams();
|
|
908
|
+
for (const [k, v] of Object.entries(params)) {
|
|
909
|
+
if (v != null) qs.set(k, String(v));
|
|
910
|
+
}
|
|
911
|
+
const s = qs.toString();
|
|
912
|
+
return s ? `?${s}` : "";
|
|
913
|
+
};
|
|
914
|
+
return {
|
|
915
|
+
/** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
916
|
+
async listContactFields(listId) {
|
|
917
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
918
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields${qs}`, { headers: headers() });
|
|
919
|
+
return resp.json();
|
|
920
|
+
},
|
|
921
|
+
/** List company fields (base + custom). Pass listId to include list-specific custom fields. */
|
|
922
|
+
async listCompanyFields(listId) {
|
|
923
|
+
const qs = listId != null ? `?list_id=${listId}` : "";
|
|
924
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/companies${qs}`, { headers: headers() });
|
|
925
|
+
return resp.json();
|
|
926
|
+
},
|
|
927
|
+
/** Create a custom field on contacts (default) or companies. */
|
|
928
|
+
async create(params) {
|
|
929
|
+
const body = {
|
|
930
|
+
title: params.title,
|
|
931
|
+
data_type: params.data_type || "text",
|
|
932
|
+
list_id: params.list_id ?? null,
|
|
933
|
+
entity: params.entity || "contacts"
|
|
934
|
+
};
|
|
935
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields`, {
|
|
936
|
+
method: "POST",
|
|
937
|
+
headers: headers(),
|
|
938
|
+
body: JSON.stringify(body)
|
|
939
|
+
});
|
|
940
|
+
const data = await resp.json();
|
|
941
|
+
return data.data || data;
|
|
942
|
+
},
|
|
943
|
+
/** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
|
|
944
|
+
async delete(columnId, params = {}) {
|
|
945
|
+
const queryParams = { entity: params.entity || "contacts" };
|
|
946
|
+
if (params.list_id != null) queryParams.list_id = params.list_id;
|
|
947
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}${toQuery(queryParams)}`, {
|
|
948
|
+
method: "DELETE",
|
|
949
|
+
headers: headers()
|
|
950
|
+
});
|
|
951
|
+
return resp.json();
|
|
952
|
+
},
|
|
953
|
+
/** Set a custom field value on a single contact or company row. Pass value=null to clear. */
|
|
954
|
+
async setValue(columnId, params) {
|
|
955
|
+
const body = {
|
|
956
|
+
record_id: params.record_id,
|
|
957
|
+
value: params.value ?? null,
|
|
958
|
+
entity: params.entity || "contacts"
|
|
959
|
+
};
|
|
960
|
+
const resp = await fetch(`${baseUrl}/api/v1/fields/${columnId}/values`, {
|
|
961
|
+
method: "PATCH",
|
|
962
|
+
headers: headers(),
|
|
963
|
+
body: JSON.stringify(body)
|
|
964
|
+
});
|
|
965
|
+
return resp.json();
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
// src/deals.ts
|
|
971
|
+
var DEFAULT_API21 = "https://be.graph8.com";
|
|
972
|
+
var createDealsClient = (apiKey, apiUrl) => {
|
|
973
|
+
const baseUrl = apiUrl || DEFAULT_API21;
|
|
974
|
+
const headers = () => ({ "Content-Type": "application/json", Authorization: `Bearer ${apiKey}` });
|
|
975
|
+
const toQuery = (params) => {
|
|
976
|
+
const qs = new URLSearchParams();
|
|
977
|
+
for (const [k, v] of Object.entries(params)) {
|
|
978
|
+
if (v != null) qs.set(k, String(v));
|
|
979
|
+
}
|
|
980
|
+
const s = qs.toString();
|
|
981
|
+
return s ? `?${s}` : "";
|
|
982
|
+
};
|
|
983
|
+
return {
|
|
984
|
+
/** List all deal pipelines and their stages. */
|
|
985
|
+
async pipelines() {
|
|
986
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/pipelines`, { headers: headers() });
|
|
987
|
+
return resp.json();
|
|
988
|
+
},
|
|
989
|
+
/** List deals org-wide with optional filters and pagination. */
|
|
990
|
+
async list(params = {}) {
|
|
991
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals${toQuery(params)}`, { headers: headers() });
|
|
992
|
+
return resp.json();
|
|
993
|
+
},
|
|
994
|
+
/** Create a new deal. */
|
|
995
|
+
async create(deal) {
|
|
996
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals`, {
|
|
997
|
+
method: "POST",
|
|
998
|
+
headers: headers(),
|
|
999
|
+
body: JSON.stringify(deal)
|
|
1000
|
+
});
|
|
1001
|
+
const data = await resp.json();
|
|
1002
|
+
return data.data || data;
|
|
1003
|
+
},
|
|
1004
|
+
/** Get a single deal by ID. */
|
|
1005
|
+
async get(dealId) {
|
|
1006
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, { headers: headers() });
|
|
1007
|
+
const data = await resp.json();
|
|
1008
|
+
return data.data || data;
|
|
1009
|
+
},
|
|
1010
|
+
/** Update a deal (partial). */
|
|
1011
|
+
async update(dealId, fields) {
|
|
1012
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
1013
|
+
method: "PATCH",
|
|
1014
|
+
headers: headers(),
|
|
1015
|
+
body: JSON.stringify(fields)
|
|
1016
|
+
});
|
|
1017
|
+
const data = await resp.json();
|
|
1018
|
+
return data.data || data;
|
|
1019
|
+
},
|
|
1020
|
+
/** Delete a deal. */
|
|
1021
|
+
async delete(dealId) {
|
|
1022
|
+
const resp = await fetch(`${baseUrl}/api/v1/deals/${dealId}`, {
|
|
1023
|
+
method: "DELETE",
|
|
1024
|
+
headers: headers()
|
|
1025
|
+
});
|
|
1026
|
+
return resp.json();
|
|
1027
|
+
},
|
|
1028
|
+
/** Get all deals associated with a contact. */
|
|
1029
|
+
async forContact(contactId) {
|
|
1030
|
+
const resp = await fetch(`${baseUrl}/api/v1/contacts/${contactId}/deals`, { headers: headers() });
|
|
1031
|
+
return resp.json();
|
|
1032
|
+
},
|
|
1033
|
+
/** Get all deals associated with a company. */
|
|
1034
|
+
async forCompany(companyId) {
|
|
1035
|
+
const resp = await fetch(`${baseUrl}/api/v1/companies/${companyId}/deals`, { headers: headers() });
|
|
1036
|
+
return resp.json();
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
};
|
|
1040
|
+
|
|
759
1041
|
// src/core.ts
|
|
760
1042
|
var DEFAULT_HOST = "https://t.graph8.com";
|
|
761
|
-
var
|
|
1043
|
+
var DEFAULT_API22 = "https://be.graph8.com";
|
|
762
1044
|
var G8 = class {
|
|
763
1045
|
constructor() {
|
|
764
1046
|
/** @internal */
|
|
@@ -799,6 +1081,14 @@ var G8 = class {
|
|
|
799
1081
|
this._companies = null;
|
|
800
1082
|
/** @internal */
|
|
801
1083
|
this._lists = null;
|
|
1084
|
+
/** @internal */
|
|
1085
|
+
this._notes = null;
|
|
1086
|
+
/** @internal */
|
|
1087
|
+
this._tasks = null;
|
|
1088
|
+
/** @internal */
|
|
1089
|
+
this._fields = null;
|
|
1090
|
+
/** @internal */
|
|
1091
|
+
this._deals = null;
|
|
802
1092
|
}
|
|
803
1093
|
/**
|
|
804
1094
|
* Initialize the graph8 SDK. Must be called before any other method.
|
|
@@ -813,7 +1103,7 @@ var G8 = class {
|
|
|
813
1103
|
debug: config.debug
|
|
814
1104
|
});
|
|
815
1105
|
}
|
|
816
|
-
const apiUrl = config.apiUrl ||
|
|
1106
|
+
const apiUrl = config.apiUrl || DEFAULT_API22;
|
|
817
1107
|
const writeKey = config.writeKey || "";
|
|
818
1108
|
const apiKey = config.apiKey || "";
|
|
819
1109
|
if (writeKey) {
|
|
@@ -836,6 +1126,10 @@ var G8 = class {
|
|
|
836
1126
|
this._contacts = createContactsClient(apiKey, apiUrl);
|
|
837
1127
|
this._companies = createCompaniesClient(apiKey, apiUrl);
|
|
838
1128
|
this._lists = createListsClient(apiKey, apiUrl);
|
|
1129
|
+
this._notes = createNotesClient(apiKey, apiUrl);
|
|
1130
|
+
this._tasks = createTasksClient(apiKey, apiUrl);
|
|
1131
|
+
this._fields = createFieldsClient(apiKey, apiUrl);
|
|
1132
|
+
this._deals = createDealsClient(apiKey, apiUrl);
|
|
839
1133
|
this._signals = createSignalsClient(apiKey, true, apiUrl);
|
|
840
1134
|
}
|
|
841
1135
|
}
|
|
@@ -942,6 +1236,26 @@ var G8 = class {
|
|
|
942
1236
|
this._assertKey("lists");
|
|
943
1237
|
return this._lists;
|
|
944
1238
|
}
|
|
1239
|
+
/** Notes on contacts (requires API key). */
|
|
1240
|
+
get notes() {
|
|
1241
|
+
this._assertKey("notes");
|
|
1242
|
+
return this._notes;
|
|
1243
|
+
}
|
|
1244
|
+
/** Tasks on contacts (requires API key). */
|
|
1245
|
+
get tasks() {
|
|
1246
|
+
this._assertKey("tasks");
|
|
1247
|
+
return this._tasks;
|
|
1248
|
+
}
|
|
1249
|
+
/** Custom fields management (requires API key). */
|
|
1250
|
+
get fields() {
|
|
1251
|
+
this._assertKey("fields");
|
|
1252
|
+
return this._fields;
|
|
1253
|
+
}
|
|
1254
|
+
/** Deals and pipelines (requires API key). */
|
|
1255
|
+
get deals() {
|
|
1256
|
+
this._assertKey("deals");
|
|
1257
|
+
return this._deals;
|
|
1258
|
+
}
|
|
945
1259
|
/** Whether the SDK has been initialized. */
|
|
946
1260
|
get initialized() {
|
|
947
1261
|
return this.config !== null;
|