@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/dist/react.d.ts CHANGED
@@ -2,6 +2,332 @@ import * as _jitsu_js from '@jitsu/js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { ReactNode } from 'react';
4
4
 
5
+ interface Deal {
6
+ id: string | null;
7
+ name: string | null;
8
+ description: string | null;
9
+ amount: number | null;
10
+ currency: string | null;
11
+ stage_id: string | null;
12
+ stage_name: string | null;
13
+ pipeline_id: string | null;
14
+ /** Linked company ID (mashup_company_id), if any. */
15
+ company_id: number | string | null;
16
+ owner_id: string | null;
17
+ /** ISO 8601 date. */
18
+ close_date: string | null;
19
+ created_at: string | null;
20
+ updated_at: string | null;
21
+ }
22
+ interface DealCreateParams {
23
+ name: string;
24
+ /** Linked company ID. */
25
+ company_id?: number;
26
+ description?: string;
27
+ amount?: number;
28
+ /** Default: "USD". */
29
+ currency?: string;
30
+ /** Stage ID from the org's pipelines. Defaults to first stage of default pipeline if omitted. */
31
+ stage_id?: string;
32
+ /** Pipeline ID. Defaults to org's default pipeline if omitted. */
33
+ pipeline_id?: string;
34
+ /** ISO 8601 close date. */
35
+ close_date?: string;
36
+ }
37
+ interface DealUpdateParams {
38
+ name?: string;
39
+ description?: string;
40
+ amount?: number;
41
+ currency?: string;
42
+ stage_id?: string;
43
+ /** ISO 8601 close date. */
44
+ close_date?: string;
45
+ }
46
+ interface DealListParams {
47
+ page?: number;
48
+ limit?: number;
49
+ stage_id?: string;
50
+ pipeline_id?: string;
51
+ /** Substring search on deal name. */
52
+ search?: string;
53
+ }
54
+ interface PipelineStage {
55
+ id: string;
56
+ name: string;
57
+ probability: number | null;
58
+ position: number | null;
59
+ stage_type: string | null;
60
+ color: string | null;
61
+ required_elements: string[];
62
+ recommended_elements: string[];
63
+ channel_scripts: Record<string, string>;
64
+ }
65
+ interface Pipeline {
66
+ id: string;
67
+ name: string;
68
+ is_default: boolean;
69
+ stages: PipelineStage[];
70
+ }
71
+ /** Trimmed deal shape returned by /contacts/{id}/deals and /companies/{id}/deals. */
72
+ interface ContactDeal {
73
+ deal_id: string | null;
74
+ name: string | null;
75
+ stage: string | null;
76
+ value: number | null;
77
+ currency: string | null;
78
+ role: string | null;
79
+ pipeline_id: string | null;
80
+ close_date: string | null;
81
+ owner_id: string | null;
82
+ created_at: string | null;
83
+ }
84
+ interface PaginationMeta {
85
+ page: number;
86
+ limit: number;
87
+ total: number;
88
+ has_next: boolean;
89
+ }
90
+ /**
91
+ * Deals API - CRUD for deals + pipelines. Requires API key (server-side).
92
+ *
93
+ * Backed by:
94
+ * GET /api/v1/deals/pipelines
95
+ * GET /api/v1/deals
96
+ * POST /api/v1/deals
97
+ * GET /api/v1/deals/{deal_id}
98
+ * PATCH /api/v1/deals/{deal_id}
99
+ * DELETE /api/v1/deals/{deal_id}
100
+ * GET /api/v1/contacts/{contact_id}/deals
101
+ * GET /api/v1/companies/{company_id}/deals
102
+ */
103
+ declare const createDealsClient: (apiKey: string, apiUrl?: string) => {
104
+ /** List all deal pipelines and their stages. */
105
+ pipelines(): Promise<{
106
+ data: Pipeline[];
107
+ }>;
108
+ /** List deals org-wide with optional filters and pagination. */
109
+ list(params?: DealListParams): Promise<{
110
+ data: Deal[];
111
+ pagination?: PaginationMeta;
112
+ }>;
113
+ /** Create a new deal. */
114
+ create(deal: DealCreateParams): Promise<Deal>;
115
+ /** Get a single deal by ID. */
116
+ get(dealId: string): Promise<Deal>;
117
+ /** Update a deal (partial). */
118
+ update(dealId: string, fields: DealUpdateParams): Promise<Deal>;
119
+ /** Delete a deal. */
120
+ delete(dealId: string): Promise<{
121
+ data: {
122
+ deleted: boolean;
123
+ };
124
+ }>;
125
+ /** Get all deals associated with a contact. */
126
+ forContact(contactId: number): Promise<{
127
+ data: ContactDeal[];
128
+ }>;
129
+ /** Get all deals associated with a company. */
130
+ forCompany(companyId: number): Promise<{
131
+ data: ContactDeal[];
132
+ }>;
133
+ };
134
+
135
+ /** A field (column) definition on contacts or companies — base or custom. */
136
+ interface Field {
137
+ id: number | null;
138
+ title: string;
139
+ /** Internal column name (slug). */
140
+ name: string | null;
141
+ /** Currently only "text" is supported; other types may be added later. */
142
+ data_type: string;
143
+ /** True if available org-wide, false if list-specific. */
144
+ is_global: boolean;
145
+ }
146
+ /** Created custom field (column). */
147
+ interface CreatedField {
148
+ id: number;
149
+ title: string;
150
+ data_type: string;
151
+ name: string;
152
+ list_id: number | null;
153
+ is_global: boolean;
154
+ }
155
+ interface FieldCreateParams {
156
+ title: string;
157
+ /** "contacts" or "companies". Defaults to "contacts" on the backend. */
158
+ entity?: "contacts" | "companies";
159
+ /** "text" (default) — additional types may be added later. */
160
+ data_type?: string;
161
+ /** If set, the field is list-specific. Omit for org-wide global field. */
162
+ list_id?: number;
163
+ }
164
+ interface FieldDeleteParams {
165
+ entity?: "contacts" | "companies";
166
+ /**
167
+ * Optional list scope guard. If provided, the column must belong to this
168
+ * list or the request returns 404. Use this to prevent accidentally
169
+ * deleting a column on a different list in the same org.
170
+ */
171
+ list_id?: number;
172
+ }
173
+ interface SetFieldValueParams {
174
+ /** Contact ID (entity='contacts') or company ID (entity='companies'). */
175
+ record_id: number;
176
+ /** Value to write. Pass null/undefined to clear the field. */
177
+ value?: string | null;
178
+ entity?: "contacts" | "companies";
179
+ }
180
+ /**
181
+ * Fields API - manage custom fields (columns) on contacts and companies.
182
+ * Requires API key (server-side).
183
+ *
184
+ * Backed by:
185
+ * GET /api/v1/fields — list contact fields
186
+ * GET /api/v1/fields/companies — list company fields
187
+ * POST /api/v1/fields — create a custom field
188
+ * DELETE /api/v1/fields/{column_id} — delete a custom field
189
+ * PATCH /api/v1/fields/{column_id}/values — set value on a single record
190
+ */
191
+ declare const createFieldsClient: (apiKey: string, apiUrl?: string) => {
192
+ /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
193
+ listContactFields(listId?: number): Promise<{
194
+ data: Field[];
195
+ }>;
196
+ /** List company fields (base + custom). Pass listId to include list-specific custom fields. */
197
+ listCompanyFields(listId?: number): Promise<{
198
+ data: Field[];
199
+ }>;
200
+ /** Create a custom field on contacts (default) or companies. */
201
+ create(params: FieldCreateParams): Promise<CreatedField>;
202
+ /** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
203
+ delete(columnId: number, params?: FieldDeleteParams): Promise<{
204
+ data: {
205
+ column_id: number;
206
+ deleted: boolean;
207
+ };
208
+ }>;
209
+ /** Set a custom field value on a single contact or company row. Pass value=null to clear. */
210
+ setValue(columnId: number, params: SetFieldValueParams): Promise<{
211
+ data: {
212
+ column_id: number;
213
+ record_id: number;
214
+ updated: boolean;
215
+ };
216
+ }>;
217
+ };
218
+
219
+ interface Task {
220
+ id: string;
221
+ entity_type: string | null;
222
+ entity_id: string | null;
223
+ title: string;
224
+ description: string | null;
225
+ due_date: string | null;
226
+ assignee_id: string | null;
227
+ assignee_name: string | null;
228
+ /** "open" | "completed" (other values may appear if the backend adds states later) */
229
+ status: string | null;
230
+ /** 0=none, 1=urgent, 2=high, 3=normal, 4=low */
231
+ priority: number | null;
232
+ task_type: string | null;
233
+ created_by: string | null;
234
+ created_at: string | null;
235
+ updated_at: string | null;
236
+ }
237
+ interface TaskCreateParams {
238
+ title: string;
239
+ description?: string;
240
+ /** ISO 8601 date string. */
241
+ due_date?: string;
242
+ assignee_id?: string;
243
+ /** 0=none, 1=urgent, 2=high, 3=normal, 4=low */
244
+ priority?: number;
245
+ }
246
+ interface TaskUpdateParams {
247
+ title?: string;
248
+ description?: string;
249
+ due_date?: string;
250
+ assignee_id?: string;
251
+ /** "open" | "completed" */
252
+ status?: string;
253
+ priority?: number;
254
+ }
255
+ interface TaskListParams {
256
+ /** "open" | "completed" */
257
+ status?: string;
258
+ /** 0-4 */
259
+ priority?: number;
260
+ assignee_id?: string;
261
+ /** Substring search on title. */
262
+ search?: string;
263
+ }
264
+ /**
265
+ * Tasks API - CRUD for tasks attached to contacts. Requires API key (server-side).
266
+ *
267
+ * Backed by:
268
+ * GET /api/v1/contacts/{contact_id}/tasks
269
+ * GET /api/v1/tasks
270
+ * POST /api/v1/contacts/{contact_id}/tasks
271
+ * PATCH /api/v1/tasks/{task_id}
272
+ * DELETE /api/v1/tasks/{task_id}
273
+ */
274
+ declare const createTasksClient: (apiKey: string, apiUrl?: string) => {
275
+ /** List tasks on a single contact. Optional status filter ("open" | "completed"). */
276
+ listForContact(contactId: number, status?: string): Promise<{
277
+ data: Task[];
278
+ }>;
279
+ /** List all tasks org-wide with optional filters. */
280
+ list(params?: TaskListParams): Promise<{
281
+ data: Task[];
282
+ }>;
283
+ /** Create a task on a contact. */
284
+ create(contactId: number, task: TaskCreateParams): Promise<Task>;
285
+ /** Update a task (partial). */
286
+ update(taskId: string, fields: TaskUpdateParams): Promise<Task>;
287
+ /** Delete a task. */
288
+ delete(taskId: string): Promise<{
289
+ data: {
290
+ deleted: boolean;
291
+ };
292
+ }>;
293
+ };
294
+
295
+ interface Note {
296
+ id: string;
297
+ entity_type: string;
298
+ entity_id: string;
299
+ content: string;
300
+ created_by: string | null;
301
+ created_by_name: string | null;
302
+ created_at: string | null;
303
+ updated_at: string | null;
304
+ }
305
+ /**
306
+ * Notes API - CRUD for notes attached to contacts. Requires API key (server-side).
307
+ *
308
+ * Backed by:
309
+ * GET /api/v1/contacts/{contact_id}/notes
310
+ * POST /api/v1/contacts/{contact_id}/notes
311
+ * PATCH /api/v1/notes/{note_id}
312
+ * DELETE /api/v1/notes/{note_id}
313
+ */
314
+ declare const createNotesClient: (apiKey: string, apiUrl?: string) => {
315
+ /** List all notes on a contact. */
316
+ list(contactId: number): Promise<{
317
+ data: Note[];
318
+ }>;
319
+ /** Create a note on a contact. */
320
+ create(contactId: number, content: string): Promise<Note>;
321
+ /** Update a note's content. */
322
+ update(noteId: string, content: string): Promise<Note>;
323
+ /** Delete a note. */
324
+ delete(noteId: string): Promise<{
325
+ data: {
326
+ deleted: boolean;
327
+ };
328
+ }>;
329
+ };
330
+
5
331
  interface ContactList {
6
332
  id: number;
7
333
  title: string;
@@ -86,6 +412,25 @@ interface CompanyContact {
86
412
  work_email: string | null;
87
413
  job_title: string | null;
88
414
  }
415
+ /** A column definition on companies (base or custom). */
416
+ interface CompanyColumn {
417
+ id: number | null;
418
+ title: string;
419
+ data_type: string;
420
+ name: string | null;
421
+ /** Stringified list_id when list-scoped, otherwise null/empty for global. */
422
+ object_id: string | null;
423
+ is_global: boolean;
424
+ }
425
+ interface CompanyColumnCreateParams {
426
+ title: string;
427
+ /** Email of the user creating the column. Required by the backend (audit). */
428
+ created_by: string;
429
+ /** "text" (default) — additional types may be added later. */
430
+ data_type?: string;
431
+ /** If set, the column is list-specific. Omit for org-wide global column. */
432
+ list_id?: number;
433
+ }
89
434
  /**
90
435
  * Companies API - search and manage CRM companies. Requires API key (server-side).
91
436
  */
@@ -110,6 +455,12 @@ declare const createCompaniesClient: (apiKey: string, apiUrl?: string) => {
110
455
  delete(companyId: number): Promise<{
111
456
  deleted: boolean;
112
457
  }>;
458
+ /** List custom company columns. Pass listId to include list-specific columns. */
459
+ listColumns(listId?: number): Promise<{
460
+ data: CompanyColumn[];
461
+ }>;
462
+ /** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
463
+ createColumn(params: CompanyColumnCreateParams): Promise<CompanyColumn>;
113
464
  };
114
465
 
115
466
  interface Contact {
@@ -166,6 +517,25 @@ interface ContactUpdateParams {
166
517
  state?: string;
167
518
  country?: string;
168
519
  }
520
+ /** A column definition on contacts (base or custom). */
521
+ interface ContactColumn {
522
+ id: number | null;
523
+ title: string;
524
+ data_type: string;
525
+ name: string | null;
526
+ /** Stringified list_id when list-scoped, otherwise null/empty for global. */
527
+ object_id: string | null;
528
+ is_global: boolean;
529
+ }
530
+ interface ContactColumnCreateParams {
531
+ title: string;
532
+ /** Email of the user creating the column. Required by the backend (audit). */
533
+ created_by: string;
534
+ /** "text" (default) — additional types may be added later. */
535
+ data_type?: string;
536
+ /** If set, the column is list-specific. Omit for org-wide global column. */
537
+ list_id?: number;
538
+ }
169
539
  /**
170
540
  * Contacts API - full CRUD for CRM contacts. Requires API key (server-side).
171
541
  */
@@ -187,6 +557,12 @@ declare const createContactsClient: (apiKey: string, apiUrl?: string) => {
187
557
  delete(contactId: number): Promise<{
188
558
  deleted: boolean;
189
559
  }>;
560
+ /** List custom contact columns. Pass listId to include list-specific columns. */
561
+ listColumns(listId?: number): Promise<{
562
+ data: ContactColumn[];
563
+ }>;
564
+ /** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
565
+ createColumn(params: ContactColumnCreateParams): Promise<ContactColumn>;
190
566
  };
191
567
 
192
568
  type WebhookEvent = "reply_received" | "meeting_booked" | "contact_enriched" | "contact_created" | "sequence_completed" | "sequence_replied" | "campaign_launched" | "form_submitted" | "visitor_identified";
@@ -696,6 +1072,10 @@ declare const useG8: () => {
696
1072
  _contacts: ReturnType<typeof createContactsClient> | null;
697
1073
  _companies: ReturnType<typeof createCompaniesClient> | null;
698
1074
  _lists: ReturnType<typeof createListsClient> | null;
1075
+ _notes: ReturnType<typeof createNotesClient> | null;
1076
+ _tasks: ReturnType<typeof createTasksClient> | null;
1077
+ _fields: ReturnType<typeof createFieldsClient> | null;
1078
+ _deals: ReturnType<typeof createDealsClient> | null;
699
1079
  init(config: G8Config): void;
700
1080
  track(event: string, properties?: TrackProperties): void;
701
1081
  identify(userId: string, properties?: IdentifyProperties): void;
@@ -813,6 +1193,10 @@ declare const useG8: () => {
813
1193
  delete(contactId: number): Promise<{
814
1194
  deleted: boolean;
815
1195
  }>;
1196
+ listColumns(listId?: number): Promise<{
1197
+ data: ContactColumn[];
1198
+ }>;
1199
+ createColumn(params: ContactColumnCreateParams): Promise<ContactColumn>;
816
1200
  };
817
1201
  get companies(): {
818
1202
  list(params?: CompanyListParams): Promise<{
@@ -830,6 +1214,10 @@ declare const useG8: () => {
830
1214
  delete(companyId: number): Promise<{
831
1215
  deleted: boolean;
832
1216
  }>;
1217
+ listColumns(listId?: number): Promise<{
1218
+ data: CompanyColumn[];
1219
+ }>;
1220
+ createColumn(params: CompanyColumnCreateParams): Promise<CompanyColumn>;
833
1221
  };
834
1222
  get lists(): {
835
1223
  list(page?: number, limit?: number): Promise<{
@@ -851,6 +1239,78 @@ declare const useG8: () => {
851
1239
  removed: number;
852
1240
  }>;
853
1241
  };
1242
+ get notes(): {
1243
+ list(contactId: number): Promise<{
1244
+ data: Note[];
1245
+ }>;
1246
+ create(contactId: number, content: string): Promise<Note>;
1247
+ update(noteId: string, content: string): Promise<Note>;
1248
+ delete(noteId: string): Promise<{
1249
+ data: {
1250
+ deleted: boolean;
1251
+ };
1252
+ }>;
1253
+ };
1254
+ get tasks(): {
1255
+ listForContact(contactId: number, status?: string): Promise<{
1256
+ data: Task[];
1257
+ }>;
1258
+ list(params?: TaskListParams): Promise<{
1259
+ data: Task[];
1260
+ }>;
1261
+ create(contactId: number, task: TaskCreateParams): Promise<Task>;
1262
+ update(taskId: string, fields: TaskUpdateParams): Promise<Task>;
1263
+ delete(taskId: string): Promise<{
1264
+ data: {
1265
+ deleted: boolean;
1266
+ };
1267
+ }>;
1268
+ };
1269
+ get fields(): {
1270
+ listContactFields(listId?: number): Promise<{
1271
+ data: Field[];
1272
+ }>;
1273
+ listCompanyFields(listId?: number): Promise<{
1274
+ data: Field[];
1275
+ }>;
1276
+ create(params: FieldCreateParams): Promise<CreatedField>;
1277
+ delete(columnId: number, params?: FieldDeleteParams): Promise<{
1278
+ data: {
1279
+ column_id: number;
1280
+ deleted: boolean;
1281
+ };
1282
+ }>;
1283
+ setValue(columnId: number, params: SetFieldValueParams): Promise<{
1284
+ data: {
1285
+ column_id: number;
1286
+ record_id: number;
1287
+ updated: boolean;
1288
+ };
1289
+ }>;
1290
+ };
1291
+ get deals(): {
1292
+ pipelines(): Promise<{
1293
+ data: Pipeline[];
1294
+ }>;
1295
+ list(params?: DealListParams): Promise<{
1296
+ data: Deal[];
1297
+ pagination?: PaginationMeta;
1298
+ }>;
1299
+ create(deal: DealCreateParams): Promise<Deal>;
1300
+ get(dealId: string): Promise<Deal>;
1301
+ update(dealId: string, fields: DealUpdateParams): Promise<Deal>;
1302
+ delete(dealId: string): Promise<{
1303
+ data: {
1304
+ deleted: boolean;
1305
+ };
1306
+ }>;
1307
+ forContact(contactId: number): Promise<{
1308
+ data: ContactDeal[];
1309
+ }>;
1310
+ forCompany(companyId: number): Promise<{
1311
+ data: ContactDeal[];
1312
+ }>;
1313
+ };
854
1314
  get initialized(): boolean;
855
1315
  _assertInit(): void;
856
1316
  _assertKey(module: string): void;