@graph8/sdk 0.7.1 → 0.11.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.mjs CHANGED
@@ -32,6 +32,21 @@ var createFormsClient = (writeKey, apiUrl) => {
32
32
 
33
33
  // src/utils.ts
34
34
  var isServer = typeof window === "undefined";
35
+ var resolveAppBaseUrl = (apiBaseUrl) => {
36
+ try {
37
+ const url = new URL(apiBaseUrl);
38
+ if (url.hostname === "localhost" || url.hostname === "127.0.0.1") {
39
+ url.port = "3000";
40
+ return url.origin;
41
+ }
42
+ if (url.hostname.endsWith("graph8.com")) {
43
+ url.hostname = url.hostname.replace(/^be\./, "app.");
44
+ return url.origin;
45
+ }
46
+ } catch {
47
+ }
48
+ return apiBaseUrl;
49
+ };
35
50
 
36
51
  // src/visitors.ts
37
52
  var DEFAULT_API2 = "https://be.graph8.com";
@@ -144,6 +159,7 @@ var createCopilotClient = (writeKey, apiUrl) => {
144
159
  var DEFAULT_API4 = "https://be.graph8.com";
145
160
  var createChatClient = (writeKey, apiUrl) => {
146
161
  const baseUrl = apiUrl || DEFAULT_API4;
162
+ const appUrl = resolveAppBaseUrl(baseUrl);
147
163
  const listeners = /* @__PURE__ */ new Map();
148
164
  let widgetEl = null;
149
165
  let ws = null;
@@ -158,7 +174,7 @@ var createChatClient = (writeKey, apiUrl) => {
158
174
  const position = config?.position || "bottom-right";
159
175
  const posStyle = position === "bottom-left" ? "left:16px;" : "right:16px;";
160
176
  const iframe = document.createElement("iframe");
161
- iframe.src = `${baseUrl}/webchat/embed?write_key=${writeKey}&theme=${config?.theme || "auto"}`;
177
+ iframe.src = `${appUrl}/webchat/embed?write_key=${writeKey}&theme=${config?.theme || "auto"}`;
162
178
  iframe.style.cssText = `position:fixed;bottom:16px;${posStyle}width:380px;height:560px;border:none;border-radius:12px;box-shadow:0 8px 32px rgba(0,0,0,0.15);z-index:99997;`;
163
179
  iframe.id = "g8-chat-widget";
164
180
  document.body.appendChild(iframe);
@@ -283,6 +299,19 @@ var G8Error = class _G8Error extends Error {
283
299
  function isRetryableStatus(status) {
284
300
  return status === 429 || status >= 500 && status <= 599;
285
301
  }
302
+ function isNonIdempotentMethod(method) {
303
+ const m = method.toUpperCase();
304
+ return m === "POST" || m === "PATCH";
305
+ }
306
+ function newIdempotencyKey() {
307
+ const c = globalThis.crypto;
308
+ if (c?.randomUUID) return c.randomUUID();
309
+ if (c?.getRandomValues) {
310
+ const bytes = c.getRandomValues(new Uint8Array(16));
311
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
312
+ }
313
+ return `g8-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
314
+ }
286
315
  function parseRetryAfter(header, nowMs = Date.now()) {
287
316
  if (!header) return null;
288
317
  const secs = Number(header);
@@ -349,7 +378,8 @@ async function request(baseUrl, path, apiKey, opts = {}) {
349
378
  Authorization: `Bearer ${apiKey}`,
350
379
  ...headers
351
380
  };
352
- if (idempotencyKey) finalHeaders["Idempotency-Key"] = idempotencyKey;
381
+ const effectiveIdempotencyKey = idempotencyKey ?? (maxRetries > 0 && isNonIdempotentMethod(method) ? newIdempotencyKey() : void 0);
382
+ if (effectiveIdempotencyKey) finalHeaders["Idempotency-Key"] = effectiveIdempotencyKey;
353
383
  let attempt = 0;
354
384
  for (; ; ) {
355
385
  let resp;
@@ -427,7 +457,7 @@ var createEnrichClient = (apiKey, apiUrl) => {
427
457
  });
428
458
  return resp.data ?? resp;
429
459
  },
430
- /** Search 300M+ contacts with filters. Credits charged per result. */
460
+ /** Search 700M+ contacts with filters. Credits charged per result. */
431
461
  async search(filters, page = 1, limit = 25) {
432
462
  const resp = await request(baseUrl, "/api/v1/search/contacts", apiKey, {
433
463
  method: "POST",
@@ -468,21 +498,30 @@ var createSequencesClient = (apiKey, apiUrl) => {
468
498
  query: params
469
499
  });
470
500
  },
471
- /** Add contacts to a sequence (V2 queuing). Live or drafted sequences only. */
472
- async add(config) {
501
+ /**
502
+ * Add contacts to a sequence (V2 queuing). Live or drafted sequences only.
503
+ * Pass `idempotencyKey` to make a retry safe — the same key returns the
504
+ * first result instead of re-enrolling on a 5xx-then-success (A6).
505
+ */
506
+ async add(config, idempotencyKey) {
473
507
  const resp = await request(
474
508
  baseUrl,
475
509
  `/api/v1/sequences/${config.sequenceId}/contacts`,
476
510
  apiKey,
477
- { method: "POST", body: { contact_ids: config.contactIds, list_id: config.listId } }
511
+ { method: "POST", body: { contact_ids: config.contactIds, list_id: config.listId }, idempotencyKey }
478
512
  );
479
513
  return resp.data ?? resp;
480
514
  },
481
- /** Create a new sequence with optional steps + channels. */
482
- async create(payload) {
515
+ /**
516
+ * Create a new sequence with optional steps + channels. Pass `idempotencyKey`
517
+ * to make a retry safe — the same key returns the first result instead of
518
+ * creating a duplicate sequence on a 5xx-then-success (A6).
519
+ */
520
+ async create(payload, idempotencyKey) {
483
521
  const resp = await request(baseUrl, "/api/v1/sequences", apiKey, {
484
522
  method: "POST",
485
- body: payload
523
+ body: payload,
524
+ idempotencyKey
486
525
  });
487
526
  return resp.data ?? resp;
488
527
  },
@@ -511,33 +550,43 @@ var createSequencesClient = (apiKey, apiUrl) => {
511
550
  });
512
551
  return resp.data ?? resp;
513
552
  },
514
- /** Run/start a DRAFTED sequence (V2 orchestration). */
515
- async run(sequenceId) {
553
+ /**
554
+ * Run/start a DRAFTED sequence (V2 orchestration). Pass `idempotencyKey` to
555
+ * make a retry safe — the same key won't re-trigger the run on a
556
+ * 5xx-then-success (A6).
557
+ */
558
+ async run(sequenceId, idempotencyKey) {
516
559
  const resp = await request(
517
560
  baseUrl,
518
561
  `/api/v1/sequences/${sequenceId}/run`,
519
562
  apiKey,
520
- { method: "POST" }
563
+ { method: "POST", idempotencyKey }
521
564
  );
522
565
  return resp.data ?? resp;
523
566
  },
524
- /** Pause a live sequence. */
525
- async pause(sequenceId) {
567
+ /**
568
+ * Pause a live sequence. Pass `idempotencyKey` to make a retry safe — the
569
+ * same key won't double-apply on a 5xx-then-success (A6).
570
+ */
571
+ async pause(sequenceId, idempotencyKey) {
526
572
  const resp = await request(
527
573
  baseUrl,
528
574
  `/api/v1/sequences/${sequenceId}/pause`,
529
575
  apiKey,
530
- { method: "POST" }
576
+ { method: "POST", idempotencyKey }
531
577
  );
532
578
  return resp.data ?? resp;
533
579
  },
534
- /** Resume a paused sequence. */
535
- async resume(sequenceId) {
580
+ /**
581
+ * Resume a paused sequence. Pass `idempotencyKey` to make a retry safe — the
582
+ * same key won't double-apply on a 5xx-then-success (A6).
583
+ */
584
+ async resume(sequenceId, idempotencyKey) {
536
585
  const resp = await request(
537
586
  baseUrl,
538
587
  `/api/v1/sequences/${sequenceId}/resume`,
539
588
  apiKey,
540
- { method: "POST" }
589
+ { method: "POST", idempotencyKey }
541
590
  );
542
591
  return resp.data ?? resp;
543
592
  },
@@ -581,45 +630,23 @@ var createCampaignsClient = (apiKey, apiUrl) => {
581
630
  return resp.data ?? resp;
582
631
  },
583
632
  async launch(campaignId) {
584
- await request(baseUrl, `/api/v1/campaigns/${campaignId}/launch`, apiKey, { method: "POST" });
585
- },
586
- async stats(campaignId) {
587
- const resp = await request(baseUrl, `/api/v1/campaigns/${campaignId}/stats`, apiKey);
588
- return resp.data ?? resp;
589
- }
590
- };
591
- };
592
-
593
- // src/integrations.ts
594
- var DEFAULT_API9 = "https://be.graph8.com";
595
- var createIntegrationsClient = (apiKey, apiUrl) => {
596
- const baseUrl = apiUrl || DEFAULT_API9;
597
- return {
598
- async list() {
599
- const resp = await request(baseUrl, "/api/v1/integrations", apiKey);
633
+ const resp = await request(
634
+ baseUrl,
635
+ `/api/v1/campaigns/${campaignId}/launch`,
636
+ apiKey,
637
+ { method: "POST" }
638
+ );
600
639
  return resp.data ?? resp;
601
- },
602
- async connect(provider, config) {
603
- await request(baseUrl, "/api/v1/integrations/connect", apiKey, {
604
- method: "POST",
605
- body: { provider, ...config }
606
- });
607
- },
608
- async sync(provider, config) {
609
- await request(baseUrl, "/api/v1/integrations/sync", apiKey, {
610
- method: "POST",
611
- body: { provider, ...config }
612
- });
613
640
  }
614
641
  };
615
642
  };
616
643
 
617
644
  // src/signals.ts
618
- var DEFAULT_API10 = "https://be.graph8.com";
645
+ var DEFAULT_API9 = "https://be.graph8.com";
619
646
  var createSignalsClient = (key, isApiKey, apiUrl) => {
620
- const baseUrl = apiUrl || DEFAULT_API10;
647
+ const baseUrl = apiUrl || DEFAULT_API9;
621
648
  const headers = () => isApiKey ? { "Content-Type": "application/json", "Authorization": `Bearer ${key}` } : { "Content-Type": "application/json", "X-Write-Key": key };
622
- const endpoint = isApiKey ? "/api/v1/signals/company" : "/api/v1/public/signals/company";
649
+ const endpoint = "/api/v1/public/signals/company";
623
650
  return {
624
651
  /** Get intent signals for a specific company domain. */
625
652
  async company(domain) {
@@ -644,24 +671,10 @@ var createSignalsClient = (key, isApiKey, apiUrl) => {
644
671
  };
645
672
  };
646
673
 
647
- // src/analytics.ts
648
- var DEFAULT_API11 = "https://be.graph8.com";
649
- var createAnalyticsClient = (apiKey, apiUrl) => {
650
- const baseUrl = apiUrl || DEFAULT_API11;
651
- return {
652
- async overview(config) {
653
- const resp = await request(baseUrl, "/api/v1/analytics/overview", apiKey, {
654
- query: { period: config?.period }
655
- });
656
- return resp.data ?? resp;
657
- }
658
- };
659
- };
660
-
661
674
  // src/voice.ts
662
- var DEFAULT_API12 = "https://be.graph8.com";
675
+ var DEFAULT_API10 = "https://be.graph8.com";
663
676
  var createVoiceClient = (apiKey, apiUrl) => {
664
- const baseUrl = apiUrl || DEFAULT_API12;
677
+ const baseUrl = apiUrl || DEFAULT_API10;
665
678
  const listeners = /* @__PURE__ */ new Map();
666
679
  const dialer = {
667
680
  /** List parallel-dialer sessions with filters + pagination. */
@@ -794,31 +807,6 @@ var createVoiceClient = (apiKey, apiUrl) => {
794
807
  }
795
808
  };
796
809
  return {
797
- /**
798
- * Start an AI voice session.
799
- * @deprecated Preview surface — for parallel-dialer flows use `voice.dialer.createSession()`.
800
- */
801
- async start(config) {
802
- const resp = await request(
803
- baseUrl,
804
- "/api/v1/voice/sessions",
805
- apiKey,
806
- { method: "POST", body: config }
807
- );
808
- return resp.data ?? resp;
809
- },
810
- /**
811
- * Get call analysis for a completed session.
812
- * @deprecated Preview surface — for dialer-call grading use `voice.dialer.callGrading(roomName)`.
813
- */
814
- async analysis(sessionId) {
815
- const resp = await request(
816
- baseUrl,
817
- `/api/v1/voice/sessions/${sessionId}/analysis`,
818
- apiKey
819
- );
820
- return resp.data ?? resp;
821
- },
822
810
  /** Listen for voice events. */
823
811
  on(event, callback) {
824
812
  if (!listeners.has(event)) listeners.set(event, []);
@@ -829,43 +817,9 @@ var createVoiceClient = (apiKey, apiUrl) => {
829
817
  };
830
818
  };
831
819
 
832
- // src/pages.ts
833
- var DEFAULT_API13 = "https://be.graph8.com";
834
- var createPagesClient = (apiKey, apiUrl) => {
835
- const baseUrl = apiUrl || DEFAULT_API13;
836
- return {
837
- /** Clone a landing page from any URL. */
838
- async clone(url) {
839
- const resp = await request(baseUrl, "/api/v1/landing-pages/clone-url", apiKey, {
840
- method: "POST",
841
- body: { url }
842
- });
843
- return resp.data ?? resp;
844
- },
845
- /** Create a landing page from a template. */
846
- async create(config) {
847
- const resp = await request(baseUrl, "/api/v1/landing-pages", apiKey, {
848
- method: "POST",
849
- body: config
850
- });
851
- return resp.data ?? resp;
852
- },
853
- /** Publish a landing page to CDN. */
854
- async publish(pageId) {
855
- const data = await request(
856
- baseUrl,
857
- `/api/v1/landing-pages/${pageId}/publish`,
858
- apiKey,
859
- { method: "POST" }
860
- );
861
- return { url: data.published_url || data.data?.published_url || "" };
862
- }
863
- };
864
- };
865
-
866
820
  // src/webhooks.ts
867
821
  import { createHmac, timingSafeEqual } from "crypto";
868
- var DEFAULT_API14 = "https://be.graph8.com";
822
+ var DEFAULT_API11 = "https://be.graph8.com";
869
823
  var KNOWN_WEBHOOK_EVENTS = [
870
824
  "campaign.created",
871
825
  "campaign.updated",
@@ -883,7 +837,7 @@ var KNOWN_WEBHOOK_EVENTS = [
883
837
  "company_intelligence.completed",
884
838
  "audience.ready",
885
839
  "audience.failed",
886
- "sequence.deployed",
840
+ "sequence.draft_created",
887
841
  "sequence.started",
888
842
  "sequence.paused",
889
843
  "sequence.completed",
@@ -946,7 +900,7 @@ function constructEvent(payload, signature, timestamp, secret, opts = {}) {
946
900
  }
947
901
  }
948
902
  var createWebhooksClient = (_apiKey, apiUrl) => {
949
- const baseUrl = apiUrl || DEFAULT_API14;
903
+ const baseUrl = apiUrl || DEFAULT_API11;
950
904
  return {
951
905
  /** Base URL the webhook subscription API lives under. */
952
906
  baseUrl,
@@ -960,9 +914,9 @@ var createWebhooksClient = (_apiKey, apiUrl) => {
960
914
  };
961
915
 
962
916
  // src/contacts.ts
963
- var DEFAULT_API15 = "https://be.graph8.com";
917
+ var DEFAULT_API12 = "https://be.graph8.com";
964
918
  var createContactsClient = (apiKey, apiUrl) => {
965
- const baseUrl = apiUrl || DEFAULT_API15;
919
+ const baseUrl = apiUrl || DEFAULT_API12;
966
920
  return {
967
921
  /** List contacts with optional filters. */
968
922
  async list(params = {}) {
@@ -1021,9 +975,9 @@ var createContactsClient = (apiKey, apiUrl) => {
1021
975
  };
1022
976
 
1023
977
  // src/companies.ts
1024
- var DEFAULT_API16 = "https://be.graph8.com";
978
+ var DEFAULT_API13 = "https://be.graph8.com";
1025
979
  var createCompaniesClient = (apiKey, apiUrl) => {
1026
- const baseUrl = apiUrl || DEFAULT_API16;
980
+ const baseUrl = apiUrl || DEFAULT_API13;
1027
981
  return {
1028
982
  /** List companies with optional filters. */
1029
983
  async list(params = {}) {
@@ -1069,9 +1023,9 @@ var createCompaniesClient = (apiKey, apiUrl) => {
1069
1023
  };
1070
1024
 
1071
1025
  // src/lists.ts
1072
- var DEFAULT_API17 = "https://be.graph8.com";
1026
+ var DEFAULT_API14 = "https://be.graph8.com";
1073
1027
  var createListsClient = (apiKey, apiUrl) => {
1074
- const baseUrl = apiUrl || DEFAULT_API17;
1028
+ const baseUrl = apiUrl || DEFAULT_API14;
1075
1029
  return {
1076
1030
  /** List all lists. */
1077
1031
  async list(page = 1, limit = 50) {
@@ -1111,9 +1065,9 @@ var createListsClient = (apiKey, apiUrl) => {
1111
1065
  };
1112
1066
 
1113
1067
  // src/notes.ts
1114
- var DEFAULT_API18 = "https://be.graph8.com";
1068
+ var DEFAULT_API15 = "https://be.graph8.com";
1115
1069
  var createNotesClient = (apiKey, apiUrl) => {
1116
- const baseUrl = apiUrl || DEFAULT_API18;
1070
+ const baseUrl = apiUrl || DEFAULT_API15;
1117
1071
  return {
1118
1072
  /** List all notes on a contact. */
1119
1073
  async list(contactId) {
@@ -1143,9 +1097,9 @@ var createNotesClient = (apiKey, apiUrl) => {
1143
1097
  };
1144
1098
 
1145
1099
  // src/tasks.ts
1146
- var DEFAULT_API19 = "https://be.graph8.com";
1100
+ var DEFAULT_API16 = "https://be.graph8.com";
1147
1101
  var createTasksClient = (apiKey, apiUrl) => {
1148
- const baseUrl = apiUrl || DEFAULT_API19;
1102
+ const baseUrl = apiUrl || DEFAULT_API16;
1149
1103
  return {
1150
1104
  /** List tasks on a single contact. Optional status filter ("open" | "completed"). */
1151
1105
  async listForContact(contactId, status) {
@@ -1181,9 +1135,9 @@ var createTasksClient = (apiKey, apiUrl) => {
1181
1135
  };
1182
1136
 
1183
1137
  // src/fields.ts
1184
- var DEFAULT_API20 = "https://be.graph8.com";
1138
+ var DEFAULT_API17 = "https://be.graph8.com";
1185
1139
  var createFieldsClient = (apiKey, apiUrl) => {
1186
- const baseUrl = apiUrl || DEFAULT_API20;
1140
+ const baseUrl = apiUrl || DEFAULT_API17;
1187
1141
  return {
1188
1142
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1189
1143
  async listContactFields(listId) {
@@ -1225,9 +1179,9 @@ var createFieldsClient = (apiKey, apiUrl) => {
1225
1179
  };
1226
1180
 
1227
1181
  // src/deals.ts
1228
- var DEFAULT_API21 = "https://be.graph8.com";
1182
+ var DEFAULT_API18 = "https://be.graph8.com";
1229
1183
  var createDealsClient = (apiKey, apiUrl) => {
1230
- const baseUrl = apiUrl || DEFAULT_API21;
1184
+ const baseUrl = apiUrl || DEFAULT_API18;
1231
1185
  return {
1232
1186
  /** List all deal pipelines and their stages. */
1233
1187
  async pipelines() {
@@ -1271,9 +1225,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1271
1225
  };
1272
1226
 
1273
1227
  // src/inbox.ts
1274
- var DEFAULT_API22 = "https://be.graph8.com";
1228
+ var DEFAULT_API19 = "https://be.graph8.com";
1275
1229
  var createInboxClient = (apiKey, apiUrl) => {
1276
- const baseUrl = apiUrl || DEFAULT_API22;
1230
+ const baseUrl = apiUrl || DEFAULT_API19;
1277
1231
  return {
1278
1232
  /** List inbox threads across email, SMS, and LinkedIn. */
1279
1233
  async list(params = {}) {
@@ -1326,9 +1280,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1326
1280
  };
1327
1281
 
1328
1282
  // src/quotes.ts
1329
- var DEFAULT_API23 = "https://be.graph8.com";
1283
+ var DEFAULT_API20 = "https://be.graph8.com";
1330
1284
  var createQuotesClient = (apiKey, apiUrl) => {
1331
- const baseUrl = apiUrl || DEFAULT_API23;
1285
+ const baseUrl = apiUrl || DEFAULT_API20;
1332
1286
  return {
1333
1287
  /** List quotes org-wide with optional filters and pagination. */
1334
1288
  async list(params = {}) {
@@ -1400,9 +1354,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1400
1354
  };
1401
1355
 
1402
1356
  // src/pipelines.ts
1403
- var DEFAULT_API24 = "https://be.graph8.com";
1357
+ var DEFAULT_API21 = "https://be.graph8.com";
1404
1358
  var createPipelinesClient = (apiKey, apiUrl) => {
1405
- const baseUrl = apiUrl || DEFAULT_API24;
1359
+ const baseUrl = apiUrl || DEFAULT_API21;
1406
1360
  return {
1407
1361
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1408
1362
  async list() {
@@ -1484,9 +1438,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1484
1438
  };
1485
1439
 
1486
1440
  // src/workflows.ts
1487
- var DEFAULT_API25 = "https://be.graph8.com";
1441
+ var DEFAULT_API22 = "https://be.graph8.com";
1488
1442
  var createWorkflowsClient = (apiKey, apiUrl) => {
1489
- const baseUrl = apiUrl || DEFAULT_API25;
1443
+ const baseUrl = apiUrl || DEFAULT_API22;
1490
1444
  return {
1491
1445
  /** List workflows org-wide. */
1492
1446
  async list(params = {}) {
@@ -1602,9 +1556,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1602
1556
  };
1603
1557
 
1604
1558
  // src/skills.ts
1605
- var DEFAULT_API26 = "https://be.graph8.com";
1559
+ var DEFAULT_API23 = "https://be.graph8.com";
1606
1560
  var createSkillsClient = (apiKey, apiUrl) => {
1607
- const baseUrl = apiUrl || DEFAULT_API26;
1561
+ const baseUrl = apiUrl || DEFAULT_API23;
1608
1562
  return {
1609
1563
  /** List skills. */
1610
1564
  async list(params = {}) {
@@ -1691,9 +1645,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1691
1645
  };
1692
1646
 
1693
1647
  // src/intent.ts
1694
- var DEFAULT_API27 = "https://be.graph8.com";
1648
+ var DEFAULT_API24 = "https://be.graph8.com";
1695
1649
  var createIntentClient = (apiKey, apiUrl) => {
1696
- const baseUrl = apiUrl || DEFAULT_API27;
1650
+ const baseUrl = apiUrl || DEFAULT_API24;
1697
1651
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1698
1652
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1699
1653
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1762,10 +1716,12 @@ var createIntentClient = (apiKey, apiUrl) => {
1762
1716
  };
1763
1717
 
1764
1718
  // src/studio.ts
1765
- var DEFAULT_API28 = "https://be.graph8.com";
1719
+ var DEFAULT_API25 = "https://be.graph8.com";
1766
1720
  var createStudioClient = (apiKey, apiUrl) => {
1767
- const baseUrl = apiUrl || DEFAULT_API28;
1721
+ const baseUrl = apiUrl || DEFAULT_API25;
1768
1722
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1723
+ const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1724
+ const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
1769
1725
  return {
1770
1726
  /** Org-level Studio documents (brand_brief, value_props, messaging_house, etc.).
1771
1727
  * `include_content` defaults to true server-side, so each document includes
@@ -1788,14 +1744,38 @@ var createStudioClient = (apiKey, apiUrl) => {
1788
1744
  /** AI research reports (buyer psychology, competitive teardown, GTM channel, etc.). */
1789
1745
  async researchReports(params = {}) {
1790
1746
  return get("/research-reports", params);
1747
+ },
1748
+ /** Create an ICP manually (no AI scoring). Requires name + website_url. */
1749
+ async createIcp(body) {
1750
+ return post("/icps", body);
1751
+ },
1752
+ /** Update an ICP (partial - send only fields to change). */
1753
+ async updateIcp(icpId, body) {
1754
+ return patch(`/icps/${icpId}`, body);
1755
+ },
1756
+ /** Archive an ICP (soft delete - sets status to "archived"). */
1757
+ async archiveIcp(icpId) {
1758
+ return post(`/icps/${icpId}/archive`);
1759
+ },
1760
+ /** Create a buyer persona manually (no AI generation). Requires title + website_url. */
1761
+ async createPersona(body) {
1762
+ return post("/personas", body);
1763
+ },
1764
+ /** Update a persona (partial). Passing status "archived" is equivalent to archivePersona. */
1765
+ async updatePersona(personaId, body) {
1766
+ return patch(`/personas/${personaId}`, body);
1767
+ },
1768
+ /** Archive a persona (soft delete - sets status to "archived"). */
1769
+ async archivePersona(personaId) {
1770
+ return post(`/personas/${personaId}/archive`);
1791
1771
  }
1792
1772
  };
1793
1773
  };
1794
1774
 
1795
1775
  // src/meetings.ts
1796
- var DEFAULT_API29 = "https://be.graph8.com";
1776
+ var DEFAULT_API26 = "https://be.graph8.com";
1797
1777
  var createMeetingsClient = (apiKey, apiUrl) => {
1798
- const baseUrl = apiUrl || DEFAULT_API29;
1778
+ const baseUrl = apiUrl || DEFAULT_API26;
1799
1779
  return {
1800
1780
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1801
1781
  async list(params = {}) {
@@ -1810,9 +1790,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1810
1790
  };
1811
1791
 
1812
1792
  // src/audiences.ts
1813
- var DEFAULT_API30 = "https://be.graph8.com";
1793
+ var DEFAULT_API27 = "https://be.graph8.com";
1814
1794
  var createAudiencesClient = (apiKey, apiUrl) => {
1815
- const baseUrl = apiUrl || DEFAULT_API30;
1795
+ const baseUrl = apiUrl || DEFAULT_API27;
1816
1796
  const base = "/api/v1/audience-syncs";
1817
1797
  return {
1818
1798
  /** List all audience syncs for the organization. */
@@ -1860,9 +1840,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1860
1840
  };
1861
1841
 
1862
1842
  // src/search.ts
1863
- var DEFAULT_API31 = "https://be.graph8.com";
1843
+ var DEFAULT_API28 = "https://be.graph8.com";
1864
1844
  var createSearchClient = (apiKey, apiUrl) => {
1865
- const baseUrl = apiUrl || DEFAULT_API31;
1845
+ const baseUrl = apiUrl || DEFAULT_API28;
1866
1846
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1867
1847
  return {
1868
1848
  /** Search open-data contacts by filter. */
@@ -1893,9 +1873,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1893
1873
  };
1894
1874
 
1895
1875
  // src/agency.ts
1896
- var DEFAULT_API32 = "https://be.graph8.com";
1876
+ var DEFAULT_API29 = "https://be.graph8.com";
1897
1877
  var createAgencyClient = (apiKey, apiUrl) => {
1898
- const baseUrl = apiUrl || DEFAULT_API32;
1878
+ const baseUrl = apiUrl || DEFAULT_API29;
1899
1879
  return {
1900
1880
  /** Describe the agency credential: agency org + authorized client count. */
1901
1881
  async me() {
@@ -1910,9 +1890,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1910
1890
  };
1911
1891
 
1912
1892
  // src/marketplace.ts
1913
- var DEFAULT_API33 = "https://be.graph8.com";
1893
+ var DEFAULT_API30 = "https://be.graph8.com";
1914
1894
  var createMarketplaceClient = (apiKey, apiUrl) => {
1915
- const baseUrl = apiUrl || DEFAULT_API33;
1895
+ const baseUrl = apiUrl || DEFAULT_API30;
1916
1896
  const base = "/api/v1/marketplace";
1917
1897
  return {
1918
1898
  /** Your own marketplace SDR profile. */
@@ -1962,9 +1942,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1962
1942
  };
1963
1943
 
1964
1944
  // src/snippet.ts
1965
- var DEFAULT_API34 = "https://be.graph8.com";
1945
+ var DEFAULT_API31 = "https://be.graph8.com";
1966
1946
  var createSnippetClient = (apiKey, apiUrl) => {
1967
- const baseUrl = apiUrl || DEFAULT_API34;
1947
+ const baseUrl = apiUrl || DEFAULT_API31;
1968
1948
  return {
1969
1949
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1970
1950
  async get() {
@@ -1976,7 +1956,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1976
1956
 
1977
1957
  // src/core.ts
1978
1958
  var DEFAULT_HOST = "https://t.graph8.com";
1979
- var DEFAULT_API35 = "https://be.graph8.com";
1959
+ var DEFAULT_API32 = "https://be.graph8.com";
1980
1960
  var G8 = class {
1981
1961
  constructor() {
1982
1962
  /** @internal */
@@ -2000,16 +1980,10 @@ var G8 = class {
2000
1980
  /** @internal */
2001
1981
  this._campaigns = null;
2002
1982
  /** @internal */
2003
- this._integrations = null;
2004
- /** @internal */
2005
1983
  this._signals = null;
2006
1984
  /** @internal */
2007
- this._analytics = null;
2008
- /** @internal */
2009
1985
  this._voice = null;
2010
1986
  /** @internal */
2011
- this._pages = null;
2012
- /** @internal */
2013
1987
  this._webhooks = null;
2014
1988
  /** @internal */
2015
1989
  this._contacts = null;
@@ -2065,7 +2039,7 @@ var G8 = class {
2065
2039
  debug: config.debug
2066
2040
  });
2067
2041
  }
2068
- const apiUrl = config.apiUrl || DEFAULT_API35;
2042
+ const apiUrl = config.apiUrl || DEFAULT_API32;
2069
2043
  const writeKey = config.writeKey || "";
2070
2044
  const apiKey = config.apiKey || "";
2071
2045
  if (writeKey) {
@@ -2080,10 +2054,7 @@ var G8 = class {
2080
2054
  this._enrich = createEnrichClient(apiKey, apiUrl);
2081
2055
  this._sequences = createSequencesClient(apiKey, apiUrl);
2082
2056
  this._campaigns = createCampaignsClient(apiKey, apiUrl);
2083
- this._integrations = createIntegrationsClient(apiKey, apiUrl);
2084
- this._analytics = createAnalyticsClient(apiKey, apiUrl);
2085
2057
  this._voice = createVoiceClient(apiKey, apiUrl);
2086
- this._pages = createPagesClient(apiKey, apiUrl);
2087
2058
  this._webhooks = createWebhooksClient(apiKey, apiUrl);
2088
2059
  this._contacts = createContactsClient(apiKey, apiUrl);
2089
2060
  this._companies = createCompaniesClient(apiKey, apiUrl);
@@ -2166,31 +2137,16 @@ var G8 = class {
2166
2137
  this._assertKey("campaigns");
2167
2138
  return this._campaigns;
2168
2139
  }
2169
- /** CRM integrations (requires API key). */
2170
- get integrations() {
2171
- this._assertKey("integrations");
2172
- return this._integrations;
2173
- }
2174
2140
  /** Intent signals. */
2175
2141
  get signals() {
2176
2142
  this._assertInit();
2177
2143
  return this._signals;
2178
2144
  }
2179
- /** Analytics (requires API key). */
2180
- get analytics() {
2181
- this._assertKey("analytics");
2182
- return this._analytics;
2183
- }
2184
2145
  /** Voice AI (requires API key). */
2185
2146
  get voice() {
2186
2147
  this._assertKey("voice");
2187
2148
  return this._voice;
2188
2149
  }
2189
- /** Landing pages (requires API key). */
2190
- get pages() {
2191
- this._assertKey("pages");
2192
- return this._pages;
2193
- }
2194
2150
  /** Webhook event listeners (requires API key). */
2195
2151
  get webhooks() {
2196
2152
  this._assertKey("webhooks");