@graph8/sdk 0.12.0 → 0.13.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.js CHANGED
@@ -1176,10 +1176,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1176
1176
  };
1177
1177
  };
1178
1178
 
1179
- // src/fields.ts
1179
+ // src/apps.ts
1180
1180
  var DEFAULT_API17 = "https://be.graph8.com";
1181
- var createFieldsClient = (apiKey, apiUrl) => {
1181
+ var createAppsClient = (apiKey, apiUrl) => {
1182
1182
  const baseUrl = apiUrl || DEFAULT_API17;
1183
+ return {
1184
+ /** List your organization's apps, newest first. */
1185
+ async list() {
1186
+ return request(baseUrl, "/api/v1/apps", apiKey);
1187
+ },
1188
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1189
+ async get(appId) {
1190
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1191
+ return resp.data ?? resp;
1192
+ },
1193
+ /**
1194
+ * Create an app. It starts in `draft` and serves no traffic until published.
1195
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1196
+ */
1197
+ async create(params) {
1198
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1199
+ method: "POST",
1200
+ body: {
1201
+ name: params.name,
1202
+ slug: params.slug,
1203
+ registered_origins: params.registered_origins ?? []
1204
+ }
1205
+ });
1206
+ return resp.data ?? resp;
1207
+ },
1208
+ /**
1209
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1210
+ *
1211
+ * `suspended` is excluded from the parameter type on purpose: it is the
1212
+ * platform's kill switch for an abusive app, the backend refuses it with a
1213
+ * 403, and a builder who could set it could also unset it.
1214
+ */
1215
+ async setStatus(appId, status) {
1216
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1217
+ method: "POST",
1218
+ body: { status }
1219
+ });
1220
+ return resp.data ?? resp;
1221
+ },
1222
+ /**
1223
+ * The client organizations that installed this app, and their consent state.
1224
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1225
+ * tenant, this is where you see why.
1226
+ */
1227
+ async listInstalls(appId) {
1228
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1229
+ },
1230
+ /**
1231
+ * Credits this app consumed in a calendar month, broken down per client org.
1232
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1233
+ * 404 — "nothing happened" is an answer.
1234
+ */
1235
+ async usage(appId, period) {
1236
+ const resp = await request(
1237
+ baseUrl,
1238
+ `/api/v1/apps/${appId}/usage`,
1239
+ apiKey,
1240
+ { query: period ? { period } : void 0 }
1241
+ );
1242
+ return resp.data ?? resp;
1243
+ },
1244
+ /**
1245
+ * This app's hard credit cap, or `null` when it is uncapped.
1246
+ *
1247
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1248
+ * sentinel, so an accidental zero can never read as "no limit".
1249
+ */
1250
+ async getLimit(appId) {
1251
+ const resp = await request(
1252
+ baseUrl,
1253
+ `/api/v1/apps/${appId}/limit`,
1254
+ apiKey
1255
+ );
1256
+ return resp.data ?? null;
1257
+ }
1258
+ };
1259
+ };
1260
+
1261
+ // src/fields.ts
1262
+ var DEFAULT_API18 = "https://be.graph8.com";
1263
+ var createFieldsClient = (apiKey, apiUrl) => {
1264
+ const baseUrl = apiUrl || DEFAULT_API18;
1183
1265
  return {
1184
1266
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1185
1267
  async listContactFields(listId) {
@@ -1220,10 +1302,112 @@ var createFieldsClient = (apiKey, apiUrl) => {
1220
1302
  };
1221
1303
  };
1222
1304
 
1305
+ // src/objects.ts
1306
+ var DEFAULT_API19 = "https://be.graph8.com";
1307
+ var createObjectsClient = (apiKey, apiUrl) => {
1308
+ const baseUrl = apiUrl || DEFAULT_API19;
1309
+ const encode = (value) => encodeURIComponent(value);
1310
+ return {
1311
+ /** List the custom object types in your workspace. */
1312
+ async list() {
1313
+ return request(baseUrl, "/api/v1/objects", apiKey);
1314
+ },
1315
+ /** Fetch one object type by slug. */
1316
+ async get(objectSlug) {
1317
+ const resp = await request(
1318
+ baseUrl,
1319
+ `/api/v1/objects/${encode(objectSlug)}`,
1320
+ apiKey
1321
+ );
1322
+ return resp.data ?? resp;
1323
+ },
1324
+ /** The object's attributes — the schema its records must satisfy. */
1325
+ async listAttributes(objectSlug) {
1326
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1327
+ },
1328
+ /** Paginated records with their current values. Archived records are excluded. */
1329
+ async listRecords(objectSlug, params = {}) {
1330
+ const query = {};
1331
+ if (params.page != null) query.page = params.page;
1332
+ if (params.limit != null) query.limit = params.limit;
1333
+ if (params.cursor != null) query.cursor = params.cursor;
1334
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1335
+ query: Object.keys(query).length ? query : void 0
1336
+ });
1337
+ },
1338
+ /**
1339
+ * Create a record. Every field is validated against the object's attributes;
1340
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1341
+ * unique attribute is a 409.
1342
+ */
1343
+ async createRecord(objectSlug, values) {
1344
+ const resp = await request(
1345
+ baseUrl,
1346
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1347
+ apiKey,
1348
+ { method: "POST", body: { values } }
1349
+ );
1350
+ return resp.data ?? resp;
1351
+ },
1352
+ /** Fetch one record with its currently active values. */
1353
+ async getRecord(objectSlug, recordId) {
1354
+ const resp = await request(
1355
+ baseUrl,
1356
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1357
+ apiKey
1358
+ );
1359
+ return resp.data ?? resp;
1360
+ },
1361
+ /**
1362
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1363
+ * required attributes you omit are left alone rather than reported missing.
1364
+ * Sending an explicit `null` CLEARS that attribute.
1365
+ *
1366
+ * Values are versioned rather than overwritten, so the previous value stays
1367
+ * readable through `history`.
1368
+ */
1369
+ async updateRecord(objectSlug, recordId, values) {
1370
+ const resp = await request(
1371
+ baseUrl,
1372
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1373
+ apiKey,
1374
+ { method: "PATCH", body: { values } }
1375
+ );
1376
+ return resp.data ?? resp;
1377
+ },
1378
+ /**
1379
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1380
+ * history and associations. Nothing is destroyed.
1381
+ */
1382
+ async archiveRecord(objectSlug, recordId) {
1383
+ const resp = await request(
1384
+ baseUrl,
1385
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1386
+ apiKey,
1387
+ { method: "DELETE" }
1388
+ );
1389
+ return resp.data ?? resp;
1390
+ },
1391
+ /**
1392
+ * A record's value timeline, newest first. An entry whose `active_until` is
1393
+ * null is the value currently in force.
1394
+ */
1395
+ async history(objectSlug, recordId, limit) {
1396
+ const resp = await request(
1397
+ baseUrl,
1398
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1399
+ apiKey,
1400
+ { query: limit != null ? { limit } : void 0 }
1401
+ );
1402
+ return resp.data ?? resp;
1403
+ }
1404
+ };
1405
+ };
1406
+
1223
1407
  // src/deals.ts
1224
- var DEFAULT_API18 = "https://be.graph8.com";
1408
+ var DEFAULT_API20 = "https://be.graph8.com";
1225
1409
  var createDealsClient = (apiKey, apiUrl) => {
1226
- const baseUrl = apiUrl || DEFAULT_API18;
1410
+ const baseUrl = apiUrl || DEFAULT_API20;
1227
1411
  return {
1228
1412
  /** List all deal pipelines and their stages. */
1229
1413
  async pipelines() {
@@ -1267,9 +1451,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1267
1451
  };
1268
1452
 
1269
1453
  // src/inbox.ts
1270
- var DEFAULT_API19 = "https://be.graph8.com";
1454
+ var DEFAULT_API21 = "https://be.graph8.com";
1271
1455
  var createInboxClient = (apiKey, apiUrl) => {
1272
- const baseUrl = apiUrl || DEFAULT_API19;
1456
+ const baseUrl = apiUrl || DEFAULT_API21;
1273
1457
  return {
1274
1458
  /** List inbox threads across email, SMS, and LinkedIn. */
1275
1459
  async list(params = {}) {
@@ -1322,9 +1506,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1322
1506
  };
1323
1507
 
1324
1508
  // src/quotes.ts
1325
- var DEFAULT_API20 = "https://be.graph8.com";
1509
+ var DEFAULT_API22 = "https://be.graph8.com";
1326
1510
  var createQuotesClient = (apiKey, apiUrl) => {
1327
- const baseUrl = apiUrl || DEFAULT_API20;
1511
+ const baseUrl = apiUrl || DEFAULT_API22;
1328
1512
  return {
1329
1513
  /** List quotes org-wide with optional filters and pagination. */
1330
1514
  async list(params = {}) {
@@ -1396,9 +1580,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1396
1580
  };
1397
1581
 
1398
1582
  // src/pipelines.ts
1399
- var DEFAULT_API21 = "https://be.graph8.com";
1583
+ var DEFAULT_API23 = "https://be.graph8.com";
1400
1584
  var createPipelinesClient = (apiKey, apiUrl) => {
1401
- const baseUrl = apiUrl || DEFAULT_API21;
1585
+ const baseUrl = apiUrl || DEFAULT_API23;
1402
1586
  return {
1403
1587
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1404
1588
  async list() {
@@ -1480,9 +1664,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1480
1664
  };
1481
1665
 
1482
1666
  // src/workflows.ts
1483
- var DEFAULT_API22 = "https://be.graph8.com";
1667
+ var DEFAULT_API24 = "https://be.graph8.com";
1484
1668
  var createWorkflowsClient = (apiKey, apiUrl) => {
1485
- const baseUrl = apiUrl || DEFAULT_API22;
1669
+ const baseUrl = apiUrl || DEFAULT_API24;
1486
1670
  return {
1487
1671
  /** List workflows org-wide. */
1488
1672
  async list(params = {}) {
@@ -1598,9 +1782,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1598
1782
  };
1599
1783
 
1600
1784
  // src/skills.ts
1601
- var DEFAULT_API23 = "https://be.graph8.com";
1785
+ var DEFAULT_API25 = "https://be.graph8.com";
1602
1786
  var createSkillsClient = (apiKey, apiUrl) => {
1603
- const baseUrl = apiUrl || DEFAULT_API23;
1787
+ const baseUrl = apiUrl || DEFAULT_API25;
1604
1788
  return {
1605
1789
  /** List skills. */
1606
1790
  async list(params = {}) {
@@ -1687,9 +1871,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1687
1871
  };
1688
1872
 
1689
1873
  // src/intent.ts
1690
- var DEFAULT_API24 = "https://be.graph8.com";
1874
+ var DEFAULT_API26 = "https://be.graph8.com";
1691
1875
  var createIntentClient = (apiKey, apiUrl) => {
1692
- const baseUrl = apiUrl || DEFAULT_API24;
1876
+ const baseUrl = apiUrl || DEFAULT_API26;
1693
1877
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1694
1878
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1695
1879
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1745,22 +1929,28 @@ var createIntentClient = (apiKey, apiUrl) => {
1745
1929
  /**
1746
1930
  * Find companies whose users visited a specific URL (intent search).
1747
1931
  *
1748
- * Note: this endpoint lives at the bare host (no `/api/v1` prefix), unlike the rest
1749
- * of the intent surface we call it directly here instead of through the shared `post()` helper.
1932
+ * Previously posted to the bare-host `/intent-search/url-companies`, bypassing
1933
+ * the shared `post()` helper. That route is JWT-only, so this method could
1934
+ * never actually work with an API key. It now goes through
1935
+ * `/api/v1/intent/url-companies` like the rest of the intent surface (g8 issue
1936
+ * #16536).
1937
+ *
1938
+ * Returns a bare aggregate, NOT the `{ data }` envelope — the previous
1939
+ * `{ data: IntentCompany[] }` signature never matched what the API sends.
1940
+ *
1941
+ * `date_from` / `date_to` are accepted for backwards compatibility but have
1942
+ * never been read by this endpoint; use `days` to set the lookback window.
1750
1943
  */
1751
1944
  async urlCompanies(url, params = {}) {
1752
- return request(baseUrl, "/intent-search/url-companies", apiKey, {
1753
- method: "POST",
1754
- body: { url, ...params }
1755
- });
1945
+ return post("/intent/url-companies", { url, ...params });
1756
1946
  }
1757
1947
  };
1758
1948
  };
1759
1949
 
1760
1950
  // src/studio.ts
1761
- var DEFAULT_API25 = "https://be.graph8.com";
1951
+ var DEFAULT_API27 = "https://be.graph8.com";
1762
1952
  var createStudioClient = (apiKey, apiUrl) => {
1763
- const baseUrl = apiUrl || DEFAULT_API25;
1953
+ const baseUrl = apiUrl || DEFAULT_API27;
1764
1954
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1765
1955
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1766
1956
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1815,9 +2005,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1815
2005
  };
1816
2006
 
1817
2007
  // src/meetings.ts
1818
- var DEFAULT_API26 = "https://be.graph8.com";
2008
+ var DEFAULT_API28 = "https://be.graph8.com";
1819
2009
  var createMeetingsClient = (apiKey, apiUrl) => {
1820
- const baseUrl = apiUrl || DEFAULT_API26;
2010
+ const baseUrl = apiUrl || DEFAULT_API28;
1821
2011
  return {
1822
2012
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1823
2013
  async list(params = {}) {
@@ -1832,9 +2022,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1832
2022
  };
1833
2023
 
1834
2024
  // src/audiences.ts
1835
- var DEFAULT_API27 = "https://be.graph8.com";
2025
+ var DEFAULT_API29 = "https://be.graph8.com";
1836
2026
  var createAudiencesClient = (apiKey, apiUrl) => {
1837
- const baseUrl = apiUrl || DEFAULT_API27;
2027
+ const baseUrl = apiUrl || DEFAULT_API29;
1838
2028
  const base = "/api/v1/audience-syncs";
1839
2029
  return {
1840
2030
  /** List all audience syncs for the organization. */
@@ -1882,9 +2072,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1882
2072
  };
1883
2073
 
1884
2074
  // src/search.ts
1885
- var DEFAULT_API28 = "https://be.graph8.com";
2075
+ var DEFAULT_API30 = "https://be.graph8.com";
1886
2076
  var createSearchClient = (apiKey, apiUrl) => {
1887
- const baseUrl = apiUrl || DEFAULT_API28;
2077
+ const baseUrl = apiUrl || DEFAULT_API30;
1888
2078
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1889
2079
  return {
1890
2080
  /** Search open-data contacts by filter. */
@@ -1915,9 +2105,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1915
2105
  };
1916
2106
 
1917
2107
  // src/agency.ts
1918
- var DEFAULT_API29 = "https://be.graph8.com";
2108
+ var DEFAULT_API31 = "https://be.graph8.com";
1919
2109
  var createAgencyClient = (apiKey, apiUrl) => {
1920
- const baseUrl = apiUrl || DEFAULT_API29;
2110
+ const baseUrl = apiUrl || DEFAULT_API31;
1921
2111
  return {
1922
2112
  /** Describe the agency credential: agency org + authorized client count. */
1923
2113
  async me() {
@@ -1932,9 +2122,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1932
2122
  };
1933
2123
 
1934
2124
  // src/marketplace.ts
1935
- var DEFAULT_API30 = "https://be.graph8.com";
2125
+ var DEFAULT_API32 = "https://be.graph8.com";
1936
2126
  var createMarketplaceClient = (apiKey, apiUrl) => {
1937
- const baseUrl = apiUrl || DEFAULT_API30;
2127
+ const baseUrl = apiUrl || DEFAULT_API32;
1938
2128
  const base = "/api/v1/marketplace";
1939
2129
  return {
1940
2130
  /** Your own marketplace SDR profile. */
@@ -1984,9 +2174,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1984
2174
  };
1985
2175
 
1986
2176
  // src/snippet.ts
1987
- var DEFAULT_API31 = "https://be.graph8.com";
2177
+ var DEFAULT_API33 = "https://be.graph8.com";
1988
2178
  var createSnippetClient = (apiKey, apiUrl) => {
1989
- const baseUrl = apiUrl || DEFAULT_API31;
2179
+ const baseUrl = apiUrl || DEFAULT_API33;
1990
2180
  return {
1991
2181
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1992
2182
  async get() {
@@ -1998,7 +2188,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1998
2188
 
1999
2189
  // src/core.ts
2000
2190
  var DEFAULT_HOST = "https://t.graph8.com";
2001
- var DEFAULT_API32 = "https://be.graph8.com";
2191
+ var DEFAULT_API34 = "https://be.graph8.com";
2002
2192
  var G8 = class {
2003
2193
  constructor() {
2004
2194
  /** @internal */
@@ -2040,6 +2230,10 @@ var G8 = class {
2040
2230
  /** @internal */
2041
2231
  this._fields = null;
2042
2232
  /** @internal */
2233
+ this._apps = null;
2234
+ /** @internal */
2235
+ this._objects = null;
2236
+ /** @internal */
2043
2237
  this._deals = null;
2044
2238
  /** @internal */
2045
2239
  this._inbox = null;
@@ -2081,7 +2275,7 @@ var G8 = class {
2081
2275
  debug: config.debug
2082
2276
  });
2083
2277
  }
2084
- const apiUrl = config.apiUrl || DEFAULT_API32;
2278
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2085
2279
  const writeKey = config.writeKey || "";
2086
2280
  const apiKey = config.apiKey || "";
2087
2281
  if (writeKey) {
@@ -2104,6 +2298,8 @@ var G8 = class {
2104
2298
  this._notes = createNotesClient(apiKey, apiUrl);
2105
2299
  this._tasks = createTasksClient(apiKey, apiUrl);
2106
2300
  this._fields = createFieldsClient(apiKey, apiUrl);
2301
+ this._apps = createAppsClient(apiKey, apiUrl);
2302
+ this._objects = createObjectsClient(apiKey, apiUrl);
2107
2303
  this._deals = createDealsClient(apiKey, apiUrl);
2108
2304
  this._inbox = createInboxClient(apiKey, apiUrl);
2109
2305
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2224,6 +2420,16 @@ var G8 = class {
2224
2420
  this._assertKey("fields");
2225
2421
  return this._fields;
2226
2422
  }
2423
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2424
+ get apps() {
2425
+ this._assertKey("apps");
2426
+ return this._apps;
2427
+ }
2428
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2429
+ get objects() {
2430
+ this._assertKey("objects");
2431
+ return this._objects;
2432
+ }
2227
2433
  /** Deals and pipelines (requires API key). */
2228
2434
  get deals() {
2229
2435
  this._assertKey("deals");