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