@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/index.d.ts CHANGED
@@ -1,5 +1,331 @@
1
1
  import { AnalyticsInterface } from '@jitsu/js';
2
2
 
3
+ interface Deal {
4
+ id: string | null;
5
+ name: string | null;
6
+ description: string | null;
7
+ amount: number | null;
8
+ currency: string | null;
9
+ stage_id: string | null;
10
+ stage_name: string | null;
11
+ pipeline_id: string | null;
12
+ /** Linked company ID (mashup_company_id), if any. */
13
+ company_id: number | string | null;
14
+ owner_id: string | null;
15
+ /** ISO 8601 date. */
16
+ close_date: string | null;
17
+ created_at: string | null;
18
+ updated_at: string | null;
19
+ }
20
+ interface DealCreateParams {
21
+ name: string;
22
+ /** Linked company ID. */
23
+ company_id?: number;
24
+ description?: string;
25
+ amount?: number;
26
+ /** Default: "USD". */
27
+ currency?: string;
28
+ /** Stage ID from the org's pipelines. Defaults to first stage of default pipeline if omitted. */
29
+ stage_id?: string;
30
+ /** Pipeline ID. Defaults to org's default pipeline if omitted. */
31
+ pipeline_id?: string;
32
+ /** ISO 8601 close date. */
33
+ close_date?: string;
34
+ }
35
+ interface DealUpdateParams {
36
+ name?: string;
37
+ description?: string;
38
+ amount?: number;
39
+ currency?: string;
40
+ stage_id?: string;
41
+ /** ISO 8601 close date. */
42
+ close_date?: string;
43
+ }
44
+ interface DealListParams {
45
+ page?: number;
46
+ limit?: number;
47
+ stage_id?: string;
48
+ pipeline_id?: string;
49
+ /** Substring search on deal name. */
50
+ search?: string;
51
+ }
52
+ interface PipelineStage {
53
+ id: string;
54
+ name: string;
55
+ probability: number | null;
56
+ position: number | null;
57
+ stage_type: string | null;
58
+ color: string | null;
59
+ required_elements: string[];
60
+ recommended_elements: string[];
61
+ channel_scripts: Record<string, string>;
62
+ }
63
+ interface Pipeline {
64
+ id: string;
65
+ name: string;
66
+ is_default: boolean;
67
+ stages: PipelineStage[];
68
+ }
69
+ /** Trimmed deal shape returned by /contacts/{id}/deals and /companies/{id}/deals. */
70
+ interface ContactDeal {
71
+ deal_id: string | null;
72
+ name: string | null;
73
+ stage: string | null;
74
+ value: number | null;
75
+ currency: string | null;
76
+ role: string | null;
77
+ pipeline_id: string | null;
78
+ close_date: string | null;
79
+ owner_id: string | null;
80
+ created_at: string | null;
81
+ }
82
+ interface PaginationMeta {
83
+ page: number;
84
+ limit: number;
85
+ total: number;
86
+ has_next: boolean;
87
+ }
88
+ /**
89
+ * Deals API - CRUD for deals + pipelines. Requires API key (server-side).
90
+ *
91
+ * Backed by:
92
+ * GET /api/v1/deals/pipelines
93
+ * GET /api/v1/deals
94
+ * POST /api/v1/deals
95
+ * GET /api/v1/deals/{deal_id}
96
+ * PATCH /api/v1/deals/{deal_id}
97
+ * DELETE /api/v1/deals/{deal_id}
98
+ * GET /api/v1/contacts/{contact_id}/deals
99
+ * GET /api/v1/companies/{company_id}/deals
100
+ */
101
+ declare const createDealsClient: (apiKey: string, apiUrl?: string) => {
102
+ /** List all deal pipelines and their stages. */
103
+ pipelines(): Promise<{
104
+ data: Pipeline[];
105
+ }>;
106
+ /** List deals org-wide with optional filters and pagination. */
107
+ list(params?: DealListParams): Promise<{
108
+ data: Deal[];
109
+ pagination?: PaginationMeta;
110
+ }>;
111
+ /** Create a new deal. */
112
+ create(deal: DealCreateParams): Promise<Deal>;
113
+ /** Get a single deal by ID. */
114
+ get(dealId: string): Promise<Deal>;
115
+ /** Update a deal (partial). */
116
+ update(dealId: string, fields: DealUpdateParams): Promise<Deal>;
117
+ /** Delete a deal. */
118
+ delete(dealId: string): Promise<{
119
+ data: {
120
+ deleted: boolean;
121
+ };
122
+ }>;
123
+ /** Get all deals associated with a contact. */
124
+ forContact(contactId: number): Promise<{
125
+ data: ContactDeal[];
126
+ }>;
127
+ /** Get all deals associated with a company. */
128
+ forCompany(companyId: number): Promise<{
129
+ data: ContactDeal[];
130
+ }>;
131
+ };
132
+
133
+ /** A field (column) definition on contacts or companies — base or custom. */
134
+ interface Field {
135
+ id: number | null;
136
+ title: string;
137
+ /** Internal column name (slug). */
138
+ name: string | null;
139
+ /** Currently only "text" is supported; other types may be added later. */
140
+ data_type: string;
141
+ /** True if available org-wide, false if list-specific. */
142
+ is_global: boolean;
143
+ }
144
+ /** Created custom field (column). */
145
+ interface CreatedField {
146
+ id: number;
147
+ title: string;
148
+ data_type: string;
149
+ name: string;
150
+ list_id: number | null;
151
+ is_global: boolean;
152
+ }
153
+ interface FieldCreateParams {
154
+ title: string;
155
+ /** "contacts" or "companies". Defaults to "contacts" on the backend. */
156
+ entity?: "contacts" | "companies";
157
+ /** "text" (default) — additional types may be added later. */
158
+ data_type?: string;
159
+ /** If set, the field is list-specific. Omit for org-wide global field. */
160
+ list_id?: number;
161
+ }
162
+ interface FieldDeleteParams {
163
+ entity?: "contacts" | "companies";
164
+ /**
165
+ * Optional list scope guard. If provided, the column must belong to this
166
+ * list or the request returns 404. Use this to prevent accidentally
167
+ * deleting a column on a different list in the same org.
168
+ */
169
+ list_id?: number;
170
+ }
171
+ interface SetFieldValueParams {
172
+ /** Contact ID (entity='contacts') or company ID (entity='companies'). */
173
+ record_id: number;
174
+ /** Value to write. Pass null/undefined to clear the field. */
175
+ value?: string | null;
176
+ entity?: "contacts" | "companies";
177
+ }
178
+ /**
179
+ * Fields API - manage custom fields (columns) on contacts and companies.
180
+ * Requires API key (server-side).
181
+ *
182
+ * Backed by:
183
+ * GET /api/v1/fields — list contact fields
184
+ * GET /api/v1/fields/companies — list company fields
185
+ * POST /api/v1/fields — create a custom field
186
+ * DELETE /api/v1/fields/{column_id} — delete a custom field
187
+ * PATCH /api/v1/fields/{column_id}/values — set value on a single record
188
+ */
189
+ declare const createFieldsClient: (apiKey: string, apiUrl?: string) => {
190
+ /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
191
+ listContactFields(listId?: number): Promise<{
192
+ data: Field[];
193
+ }>;
194
+ /** List company fields (base + custom). Pass listId to include list-specific custom fields. */
195
+ listCompanyFields(listId?: number): Promise<{
196
+ data: Field[];
197
+ }>;
198
+ /** Create a custom field on contacts (default) or companies. */
199
+ create(params: FieldCreateParams): Promise<CreatedField>;
200
+ /** Delete a custom field (soft-delete). Pass list_id to scope-guard against cross-list deletion. */
201
+ delete(columnId: number, params?: FieldDeleteParams): Promise<{
202
+ data: {
203
+ column_id: number;
204
+ deleted: boolean;
205
+ };
206
+ }>;
207
+ /** Set a custom field value on a single contact or company row. Pass value=null to clear. */
208
+ setValue(columnId: number, params: SetFieldValueParams): Promise<{
209
+ data: {
210
+ column_id: number;
211
+ record_id: number;
212
+ updated: boolean;
213
+ };
214
+ }>;
215
+ };
216
+
217
+ interface Task {
218
+ id: string;
219
+ entity_type: string | null;
220
+ entity_id: string | null;
221
+ title: string;
222
+ description: string | null;
223
+ due_date: string | null;
224
+ assignee_id: string | null;
225
+ assignee_name: string | null;
226
+ /** "open" | "completed" (other values may appear if the backend adds states later) */
227
+ status: string | null;
228
+ /** 0=none, 1=urgent, 2=high, 3=normal, 4=low */
229
+ priority: number | null;
230
+ task_type: string | null;
231
+ created_by: string | null;
232
+ created_at: string | null;
233
+ updated_at: string | null;
234
+ }
235
+ interface TaskCreateParams {
236
+ title: string;
237
+ description?: string;
238
+ /** ISO 8601 date string. */
239
+ due_date?: string;
240
+ assignee_id?: string;
241
+ /** 0=none, 1=urgent, 2=high, 3=normal, 4=low */
242
+ priority?: number;
243
+ }
244
+ interface TaskUpdateParams {
245
+ title?: string;
246
+ description?: string;
247
+ due_date?: string;
248
+ assignee_id?: string;
249
+ /** "open" | "completed" */
250
+ status?: string;
251
+ priority?: number;
252
+ }
253
+ interface TaskListParams {
254
+ /** "open" | "completed" */
255
+ status?: string;
256
+ /** 0-4 */
257
+ priority?: number;
258
+ assignee_id?: string;
259
+ /** Substring search on title. */
260
+ search?: string;
261
+ }
262
+ /**
263
+ * Tasks API - CRUD for tasks attached to contacts. Requires API key (server-side).
264
+ *
265
+ * Backed by:
266
+ * GET /api/v1/contacts/{contact_id}/tasks
267
+ * GET /api/v1/tasks
268
+ * POST /api/v1/contacts/{contact_id}/tasks
269
+ * PATCH /api/v1/tasks/{task_id}
270
+ * DELETE /api/v1/tasks/{task_id}
271
+ */
272
+ declare const createTasksClient: (apiKey: string, apiUrl?: string) => {
273
+ /** List tasks on a single contact. Optional status filter ("open" | "completed"). */
274
+ listForContact(contactId: number, status?: string): Promise<{
275
+ data: Task[];
276
+ }>;
277
+ /** List all tasks org-wide with optional filters. */
278
+ list(params?: TaskListParams): Promise<{
279
+ data: Task[];
280
+ }>;
281
+ /** Create a task on a contact. */
282
+ create(contactId: number, task: TaskCreateParams): Promise<Task>;
283
+ /** Update a task (partial). */
284
+ update(taskId: string, fields: TaskUpdateParams): Promise<Task>;
285
+ /** Delete a task. */
286
+ delete(taskId: string): Promise<{
287
+ data: {
288
+ deleted: boolean;
289
+ };
290
+ }>;
291
+ };
292
+
293
+ interface Note {
294
+ id: string;
295
+ entity_type: string;
296
+ entity_id: string;
297
+ content: string;
298
+ created_by: string | null;
299
+ created_by_name: string | null;
300
+ created_at: string | null;
301
+ updated_at: string | null;
302
+ }
303
+ /**
304
+ * Notes API - CRUD for notes attached to contacts. Requires API key (server-side).
305
+ *
306
+ * Backed by:
307
+ * GET /api/v1/contacts/{contact_id}/notes
308
+ * POST /api/v1/contacts/{contact_id}/notes
309
+ * PATCH /api/v1/notes/{note_id}
310
+ * DELETE /api/v1/notes/{note_id}
311
+ */
312
+ declare const createNotesClient: (apiKey: string, apiUrl?: string) => {
313
+ /** List all notes on a contact. */
314
+ list(contactId: number): Promise<{
315
+ data: Note[];
316
+ }>;
317
+ /** Create a note on a contact. */
318
+ create(contactId: number, content: string): Promise<Note>;
319
+ /** Update a note's content. */
320
+ update(noteId: string, content: string): Promise<Note>;
321
+ /** Delete a note. */
322
+ delete(noteId: string): Promise<{
323
+ data: {
324
+ deleted: boolean;
325
+ };
326
+ }>;
327
+ };
328
+
3
329
  interface ContactList {
4
330
  id: number;
5
331
  title: string;
@@ -84,6 +410,25 @@ interface CompanyContact {
84
410
  work_email: string | null;
85
411
  job_title: string | null;
86
412
  }
413
+ /** A column definition on companies (base or custom). */
414
+ interface CompanyColumn {
415
+ id: number | null;
416
+ title: string;
417
+ data_type: string;
418
+ name: string | null;
419
+ /** Stringified list_id when list-scoped, otherwise null/empty for global. */
420
+ object_id: string | null;
421
+ is_global: boolean;
422
+ }
423
+ interface CompanyColumnCreateParams {
424
+ title: string;
425
+ /** Email of the user creating the column. Required by the backend (audit). */
426
+ created_by: string;
427
+ /** "text" (default) — additional types may be added later. */
428
+ data_type?: string;
429
+ /** If set, the column is list-specific. Omit for org-wide global column. */
430
+ list_id?: number;
431
+ }
87
432
  /**
88
433
  * Companies API - search and manage CRM companies. Requires API key (server-side).
89
434
  */
@@ -108,6 +453,12 @@ declare const createCompaniesClient: (apiKey: string, apiUrl?: string) => {
108
453
  delete(companyId: number): Promise<{
109
454
  deleted: boolean;
110
455
  }>;
456
+ /** List custom company columns. Pass listId to include list-specific columns. */
457
+ listColumns(listId?: number): Promise<{
458
+ data: CompanyColumn[];
459
+ }>;
460
+ /** Create a custom company column. Global if list_id is omitted, list-scoped otherwise. */
461
+ createColumn(params: CompanyColumnCreateParams): Promise<CompanyColumn>;
111
462
  };
112
463
 
113
464
  interface Contact {
@@ -164,6 +515,25 @@ interface ContactUpdateParams {
164
515
  state?: string;
165
516
  country?: string;
166
517
  }
518
+ /** A column definition on contacts (base or custom). */
519
+ interface ContactColumn {
520
+ id: number | null;
521
+ title: string;
522
+ data_type: string;
523
+ name: string | null;
524
+ /** Stringified list_id when list-scoped, otherwise null/empty for global. */
525
+ object_id: string | null;
526
+ is_global: boolean;
527
+ }
528
+ interface ContactColumnCreateParams {
529
+ title: string;
530
+ /** Email of the user creating the column. Required by the backend (audit). */
531
+ created_by: string;
532
+ /** "text" (default) — additional types may be added later. */
533
+ data_type?: string;
534
+ /** If set, the column is list-specific. Omit for org-wide global column. */
535
+ list_id?: number;
536
+ }
167
537
  /**
168
538
  * Contacts API - full CRUD for CRM contacts. Requires API key (server-side).
169
539
  */
@@ -185,6 +555,12 @@ declare const createContactsClient: (apiKey: string, apiUrl?: string) => {
185
555
  delete(contactId: number): Promise<{
186
556
  deleted: boolean;
187
557
  }>;
558
+ /** List custom contact columns. Pass listId to include list-specific columns. */
559
+ listColumns(listId?: number): Promise<{
560
+ data: ContactColumn[];
561
+ }>;
562
+ /** Create a custom contact column. Global if list_id is omitted, list-scoped otherwise. */
563
+ createColumn(params: ContactColumnCreateParams): Promise<ContactColumn>;
188
564
  };
189
565
 
190
566
  type WebhookEvent = "reply_received" | "meeting_booked" | "contact_enriched" | "contact_created" | "sequence_completed" | "sequence_replied" | "campaign_launched" | "form_submitted" | "visitor_identified";
@@ -664,6 +1040,10 @@ declare class G8 {
664
1040
  /** @internal */ _contacts: ReturnType<typeof createContactsClient> | null;
665
1041
  /** @internal */ _companies: ReturnType<typeof createCompaniesClient> | null;
666
1042
  /** @internal */ _lists: ReturnType<typeof createListsClient> | null;
1043
+ /** @internal */ _notes: ReturnType<typeof createNotesClient> | null;
1044
+ /** @internal */ _tasks: ReturnType<typeof createTasksClient> | null;
1045
+ /** @internal */ _fields: ReturnType<typeof createFieldsClient> | null;
1046
+ /** @internal */ _deals: ReturnType<typeof createDealsClient> | null;
667
1047
  /**
668
1048
  * Initialize the graph8 SDK. Must be called before any other method.
669
1049
  * Safe to call on the server (SSR) - becomes a no-op for tracking.
@@ -804,6 +1184,10 @@ declare class G8 {
804
1184
  delete(contactId: number): Promise<{
805
1185
  deleted: boolean;
806
1186
  }>;
1187
+ listColumns(listId?: number): Promise<{
1188
+ data: ContactColumn[];
1189
+ }>;
1190
+ createColumn(params: ContactColumnCreateParams): Promise<ContactColumn>;
807
1191
  };
808
1192
  /** Companies CRUD (requires API key). */
809
1193
  get companies(): {
@@ -822,6 +1206,10 @@ declare class G8 {
822
1206
  delete(companyId: number): Promise<{
823
1207
  deleted: boolean;
824
1208
  }>;
1209
+ listColumns(listId?: number): Promise<{
1210
+ data: CompanyColumn[];
1211
+ }>;
1212
+ createColumn(params: CompanyColumnCreateParams): Promise<CompanyColumn>;
825
1213
  };
826
1214
  /** Lists management (requires API key). */
827
1215
  get lists(): {
@@ -844,6 +1232,82 @@ declare class G8 {
844
1232
  removed: number;
845
1233
  }>;
846
1234
  };
1235
+ /** Notes on contacts (requires API key). */
1236
+ get notes(): {
1237
+ list(contactId: number): Promise<{
1238
+ data: Note[];
1239
+ }>;
1240
+ create(contactId: number, content: string): Promise<Note>;
1241
+ update(noteId: string, content: string): Promise<Note>;
1242
+ delete(noteId: string): Promise<{
1243
+ data: {
1244
+ deleted: boolean;
1245
+ };
1246
+ }>;
1247
+ };
1248
+ /** Tasks on contacts (requires API key). */
1249
+ get tasks(): {
1250
+ listForContact(contactId: number, status?: string): Promise<{
1251
+ data: Task[];
1252
+ }>;
1253
+ list(params?: TaskListParams): Promise<{
1254
+ data: Task[];
1255
+ }>;
1256
+ create(contactId: number, task: TaskCreateParams): Promise<Task>;
1257
+ update(taskId: string, fields: TaskUpdateParams): Promise<Task>;
1258
+ delete(taskId: string): Promise<{
1259
+ data: {
1260
+ deleted: boolean;
1261
+ };
1262
+ }>;
1263
+ };
1264
+ /** Custom fields management (requires API key). */
1265
+ get fields(): {
1266
+ listContactFields(listId?: number): Promise<{
1267
+ data: Field[];
1268
+ }>;
1269
+ listCompanyFields(listId?: number): Promise<{
1270
+ data: Field[];
1271
+ }>;
1272
+ create(params: FieldCreateParams): Promise<CreatedField>;
1273
+ delete(columnId: number, params?: FieldDeleteParams): Promise<{
1274
+ data: {
1275
+ column_id: number;
1276
+ deleted: boolean;
1277
+ };
1278
+ }>;
1279
+ setValue(columnId: number, params: SetFieldValueParams): Promise<{
1280
+ data: {
1281
+ column_id: number;
1282
+ record_id: number;
1283
+ updated: boolean;
1284
+ };
1285
+ }>;
1286
+ };
1287
+ /** Deals and pipelines (requires API key). */
1288
+ get deals(): {
1289
+ pipelines(): Promise<{
1290
+ data: Pipeline[];
1291
+ }>;
1292
+ list(params?: DealListParams): Promise<{
1293
+ data: Deal[];
1294
+ pagination?: PaginationMeta;
1295
+ }>;
1296
+ create(deal: DealCreateParams): Promise<Deal>;
1297
+ get(dealId: string): Promise<Deal>;
1298
+ update(dealId: string, fields: DealUpdateParams): Promise<Deal>;
1299
+ delete(dealId: string): Promise<{
1300
+ data: {
1301
+ deleted: boolean;
1302
+ };
1303
+ }>;
1304
+ forContact(contactId: number): Promise<{
1305
+ data: ContactDeal[];
1306
+ }>;
1307
+ forCompany(companyId: number): Promise<{
1308
+ data: ContactDeal[];
1309
+ }>;
1310
+ };
847
1311
  /** Whether the SDK has been initialized. */
848
1312
  get initialized(): boolean;
849
1313
  /** @internal */
@@ -854,4 +1318,4 @@ declare class G8 {
854
1318
  /** Singleton g8 client instance. */
855
1319
  declare const g8: G8;
856
1320
 
857
- export { type AddToSequenceConfig, type AnalyticsOverview, type Booking, type BookingRequest, type CalendarConfig, type CallAnalysis, type Campaign, type CampaignCreateConfig, type CampaignStats, type ChatConfig, type Company, type CompanyContact, type CompanyEnrichment, type CompanyListParams, type CompanyUpdateParams, type Contact, type ContactCreateParams, type ContactList, type ContactListParams, type ContactUpdateParams, type CopilotConfig, type EmailVerification, type EnrichLookupResult, type G8Config, type G8PrivacyConfig, type IdentifyProperties, type Integration, type IntentSignals, type LandingPage, type ListContact, type PersonEnrichment, type SearchFilter, type SearchResults, type Sequence, type TimeSlot, type TrackProperties, type VisitorCompany, type VisitorScore, type VoiceSession, type WebhookEvent, g8 };
1321
+ export { type AddToSequenceConfig, type AnalyticsOverview, type Booking, type BookingRequest, type CalendarConfig, type CallAnalysis, type Campaign, type CampaignCreateConfig, type CampaignStats, type ChatConfig, type Company, type CompanyColumn, type CompanyColumnCreateParams, type CompanyContact, type CompanyEnrichment, type CompanyListParams, type CompanyUpdateParams, type Contact, type ContactColumn, type ContactColumnCreateParams, type ContactCreateParams, type ContactDeal, type ContactList, type ContactListParams, type ContactUpdateParams, type CopilotConfig, type CreatedField, type Deal, type DealCreateParams, type DealListParams, type DealUpdateParams, type EmailVerification, type EnrichLookupResult, type Field, type FieldCreateParams, type FieldDeleteParams, type G8Config, type G8PrivacyConfig, type IdentifyProperties, type Integration, type IntentSignals, type LandingPage, type ListContact, type Note, type PaginationMeta, type PersonEnrichment, type Pipeline, type PipelineStage, type SearchFilter, type SearchResults, type Sequence, type SetFieldValueParams, type Task, type TaskCreateParams, type TaskListParams, type TaskUpdateParams, type TimeSlot, type TrackProperties, type VisitorCompany, type VisitorScore, type VoiceSession, type WebhookEvent, g8 };