@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/react.mjs CHANGED
@@ -1129,10 +1129,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1129
1129
  };
1130
1130
  };
1131
1131
 
1132
- // src/fields.ts
1132
+ // src/apps.ts
1133
1133
  var DEFAULT_API17 = "https://be.graph8.com";
1134
- var createFieldsClient = (apiKey, apiUrl) => {
1134
+ var createAppsClient = (apiKey, apiUrl) => {
1135
1135
  const baseUrl = apiUrl || DEFAULT_API17;
1136
+ return {
1137
+ /** List your organization's apps, newest first. */
1138
+ async list() {
1139
+ return request(baseUrl, "/api/v1/apps", apiKey);
1140
+ },
1141
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1142
+ async get(appId) {
1143
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1144
+ return resp.data ?? resp;
1145
+ },
1146
+ /**
1147
+ * Create an app. It starts in `draft` and serves no traffic until published.
1148
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1149
+ */
1150
+ async create(params) {
1151
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1152
+ method: "POST",
1153
+ body: {
1154
+ name: params.name,
1155
+ slug: params.slug,
1156
+ registered_origins: params.registered_origins ?? []
1157
+ }
1158
+ });
1159
+ return resp.data ?? resp;
1160
+ },
1161
+ /**
1162
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1163
+ *
1164
+ * `suspended` is excluded from the parameter type on purpose: it is the
1165
+ * platform's kill switch for an abusive app, the backend refuses it with a
1166
+ * 403, and a builder who could set it could also unset it.
1167
+ */
1168
+ async setStatus(appId, status) {
1169
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1170
+ method: "POST",
1171
+ body: { status }
1172
+ });
1173
+ return resp.data ?? resp;
1174
+ },
1175
+ /**
1176
+ * The client organizations that installed this app, and their consent state.
1177
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1178
+ * tenant, this is where you see why.
1179
+ */
1180
+ async listInstalls(appId) {
1181
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1182
+ },
1183
+ /**
1184
+ * Credits this app consumed in a calendar month, broken down per client org.
1185
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1186
+ * 404 — "nothing happened" is an answer.
1187
+ */
1188
+ async usage(appId, period) {
1189
+ const resp = await request(
1190
+ baseUrl,
1191
+ `/api/v1/apps/${appId}/usage`,
1192
+ apiKey,
1193
+ { query: period ? { period } : void 0 }
1194
+ );
1195
+ return resp.data ?? resp;
1196
+ },
1197
+ /**
1198
+ * This app's hard credit cap, or `null` when it is uncapped.
1199
+ *
1200
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1201
+ * sentinel, so an accidental zero can never read as "no limit".
1202
+ */
1203
+ async getLimit(appId) {
1204
+ const resp = await request(
1205
+ baseUrl,
1206
+ `/api/v1/apps/${appId}/limit`,
1207
+ apiKey
1208
+ );
1209
+ return resp.data ?? null;
1210
+ }
1211
+ };
1212
+ };
1213
+
1214
+ // src/fields.ts
1215
+ var DEFAULT_API18 = "https://be.graph8.com";
1216
+ var createFieldsClient = (apiKey, apiUrl) => {
1217
+ const baseUrl = apiUrl || DEFAULT_API18;
1136
1218
  return {
1137
1219
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1138
1220
  async listContactFields(listId) {
@@ -1173,10 +1255,112 @@ var createFieldsClient = (apiKey, apiUrl) => {
1173
1255
  };
1174
1256
  };
1175
1257
 
1258
+ // src/objects.ts
1259
+ var DEFAULT_API19 = "https://be.graph8.com";
1260
+ var createObjectsClient = (apiKey, apiUrl) => {
1261
+ const baseUrl = apiUrl || DEFAULT_API19;
1262
+ const encode = (value) => encodeURIComponent(value);
1263
+ return {
1264
+ /** List the custom object types in your workspace. */
1265
+ async list() {
1266
+ return request(baseUrl, "/api/v1/objects", apiKey);
1267
+ },
1268
+ /** Fetch one object type by slug. */
1269
+ async get(objectSlug) {
1270
+ const resp = await request(
1271
+ baseUrl,
1272
+ `/api/v1/objects/${encode(objectSlug)}`,
1273
+ apiKey
1274
+ );
1275
+ return resp.data ?? resp;
1276
+ },
1277
+ /** The object's attributes — the schema its records must satisfy. */
1278
+ async listAttributes(objectSlug) {
1279
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1280
+ },
1281
+ /** Paginated records with their current values. Archived records are excluded. */
1282
+ async listRecords(objectSlug, params = {}) {
1283
+ const query = {};
1284
+ if (params.page != null) query.page = params.page;
1285
+ if (params.limit != null) query.limit = params.limit;
1286
+ if (params.cursor != null) query.cursor = params.cursor;
1287
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1288
+ query: Object.keys(query).length ? query : void 0
1289
+ });
1290
+ },
1291
+ /**
1292
+ * Create a record. Every field is validated against the object's attributes;
1293
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1294
+ * unique attribute is a 409.
1295
+ */
1296
+ async createRecord(objectSlug, values) {
1297
+ const resp = await request(
1298
+ baseUrl,
1299
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1300
+ apiKey,
1301
+ { method: "POST", body: { values } }
1302
+ );
1303
+ return resp.data ?? resp;
1304
+ },
1305
+ /** Fetch one record with its currently active values. */
1306
+ async getRecord(objectSlug, recordId) {
1307
+ const resp = await request(
1308
+ baseUrl,
1309
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1310
+ apiKey
1311
+ );
1312
+ return resp.data ?? resp;
1313
+ },
1314
+ /**
1315
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1316
+ * required attributes you omit are left alone rather than reported missing.
1317
+ * Sending an explicit `null` CLEARS that attribute.
1318
+ *
1319
+ * Values are versioned rather than overwritten, so the previous value stays
1320
+ * readable through `history`.
1321
+ */
1322
+ async updateRecord(objectSlug, recordId, values) {
1323
+ const resp = await request(
1324
+ baseUrl,
1325
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1326
+ apiKey,
1327
+ { method: "PATCH", body: { values } }
1328
+ );
1329
+ return resp.data ?? resp;
1330
+ },
1331
+ /**
1332
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1333
+ * history and associations. Nothing is destroyed.
1334
+ */
1335
+ async archiveRecord(objectSlug, recordId) {
1336
+ const resp = await request(
1337
+ baseUrl,
1338
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1339
+ apiKey,
1340
+ { method: "DELETE" }
1341
+ );
1342
+ return resp.data ?? resp;
1343
+ },
1344
+ /**
1345
+ * A record's value timeline, newest first. An entry whose `active_until` is
1346
+ * null is the value currently in force.
1347
+ */
1348
+ async history(objectSlug, recordId, limit) {
1349
+ const resp = await request(
1350
+ baseUrl,
1351
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1352
+ apiKey,
1353
+ { query: limit != null ? { limit } : void 0 }
1354
+ );
1355
+ return resp.data ?? resp;
1356
+ }
1357
+ };
1358
+ };
1359
+
1176
1360
  // src/deals.ts
1177
- var DEFAULT_API18 = "https://be.graph8.com";
1361
+ var DEFAULT_API20 = "https://be.graph8.com";
1178
1362
  var createDealsClient = (apiKey, apiUrl) => {
1179
- const baseUrl = apiUrl || DEFAULT_API18;
1363
+ const baseUrl = apiUrl || DEFAULT_API20;
1180
1364
  return {
1181
1365
  /** List all deal pipelines and their stages. */
1182
1366
  async pipelines() {
@@ -1220,9 +1404,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1220
1404
  };
1221
1405
 
1222
1406
  // src/inbox.ts
1223
- var DEFAULT_API19 = "https://be.graph8.com";
1407
+ var DEFAULT_API21 = "https://be.graph8.com";
1224
1408
  var createInboxClient = (apiKey, apiUrl) => {
1225
- const baseUrl = apiUrl || DEFAULT_API19;
1409
+ const baseUrl = apiUrl || DEFAULT_API21;
1226
1410
  return {
1227
1411
  /** List inbox threads across email, SMS, and LinkedIn. */
1228
1412
  async list(params = {}) {
@@ -1275,9 +1459,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1275
1459
  };
1276
1460
 
1277
1461
  // src/quotes.ts
1278
- var DEFAULT_API20 = "https://be.graph8.com";
1462
+ var DEFAULT_API22 = "https://be.graph8.com";
1279
1463
  var createQuotesClient = (apiKey, apiUrl) => {
1280
- const baseUrl = apiUrl || DEFAULT_API20;
1464
+ const baseUrl = apiUrl || DEFAULT_API22;
1281
1465
  return {
1282
1466
  /** List quotes org-wide with optional filters and pagination. */
1283
1467
  async list(params = {}) {
@@ -1349,9 +1533,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1349
1533
  };
1350
1534
 
1351
1535
  // src/pipelines.ts
1352
- var DEFAULT_API21 = "https://be.graph8.com";
1536
+ var DEFAULT_API23 = "https://be.graph8.com";
1353
1537
  var createPipelinesClient = (apiKey, apiUrl) => {
1354
- const baseUrl = apiUrl || DEFAULT_API21;
1538
+ const baseUrl = apiUrl || DEFAULT_API23;
1355
1539
  return {
1356
1540
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1357
1541
  async list() {
@@ -1433,9 +1617,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1433
1617
  };
1434
1618
 
1435
1619
  // src/workflows.ts
1436
- var DEFAULT_API22 = "https://be.graph8.com";
1620
+ var DEFAULT_API24 = "https://be.graph8.com";
1437
1621
  var createWorkflowsClient = (apiKey, apiUrl) => {
1438
- const baseUrl = apiUrl || DEFAULT_API22;
1622
+ const baseUrl = apiUrl || DEFAULT_API24;
1439
1623
  return {
1440
1624
  /** List workflows org-wide. */
1441
1625
  async list(params = {}) {
@@ -1551,9 +1735,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1551
1735
  };
1552
1736
 
1553
1737
  // src/skills.ts
1554
- var DEFAULT_API23 = "https://be.graph8.com";
1738
+ var DEFAULT_API25 = "https://be.graph8.com";
1555
1739
  var createSkillsClient = (apiKey, apiUrl) => {
1556
- const baseUrl = apiUrl || DEFAULT_API23;
1740
+ const baseUrl = apiUrl || DEFAULT_API25;
1557
1741
  return {
1558
1742
  /** List skills. */
1559
1743
  async list(params = {}) {
@@ -1640,9 +1824,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1640
1824
  };
1641
1825
 
1642
1826
  // src/intent.ts
1643
- var DEFAULT_API24 = "https://be.graph8.com";
1827
+ var DEFAULT_API26 = "https://be.graph8.com";
1644
1828
  var createIntentClient = (apiKey, apiUrl) => {
1645
- const baseUrl = apiUrl || DEFAULT_API24;
1829
+ const baseUrl = apiUrl || DEFAULT_API26;
1646
1830
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1647
1831
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1648
1832
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1698,22 +1882,28 @@ var createIntentClient = (apiKey, apiUrl) => {
1698
1882
  /**
1699
1883
  * Find companies whose users visited a specific URL (intent search).
1700
1884
  *
1701
- * Note: this endpoint lives at the bare host (no `/api/v1` prefix), unlike the rest
1702
- * of the intent surface we call it directly here instead of through the shared `post()` helper.
1885
+ * Previously posted to the bare-host `/intent-search/url-companies`, bypassing
1886
+ * the shared `post()` helper. That route is JWT-only, so this method could
1887
+ * never actually work with an API key. It now goes through
1888
+ * `/api/v1/intent/url-companies` like the rest of the intent surface (g8 issue
1889
+ * #16536).
1890
+ *
1891
+ * Returns a bare aggregate, NOT the `{ data }` envelope — the previous
1892
+ * `{ data: IntentCompany[] }` signature never matched what the API sends.
1893
+ *
1894
+ * `date_from` / `date_to` are accepted for backwards compatibility but have
1895
+ * never been read by this endpoint; use `days` to set the lookback window.
1703
1896
  */
1704
1897
  async urlCompanies(url, params = {}) {
1705
- return request(baseUrl, "/intent-search/url-companies", apiKey, {
1706
- method: "POST",
1707
- body: { url, ...params }
1708
- });
1898
+ return post("/intent/url-companies", { url, ...params });
1709
1899
  }
1710
1900
  };
1711
1901
  };
1712
1902
 
1713
1903
  // src/studio.ts
1714
- var DEFAULT_API25 = "https://be.graph8.com";
1904
+ var DEFAULT_API27 = "https://be.graph8.com";
1715
1905
  var createStudioClient = (apiKey, apiUrl) => {
1716
- const baseUrl = apiUrl || DEFAULT_API25;
1906
+ const baseUrl = apiUrl || DEFAULT_API27;
1717
1907
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1718
1908
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1719
1909
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1768,9 +1958,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1768
1958
  };
1769
1959
 
1770
1960
  // src/meetings.ts
1771
- var DEFAULT_API26 = "https://be.graph8.com";
1961
+ var DEFAULT_API28 = "https://be.graph8.com";
1772
1962
  var createMeetingsClient = (apiKey, apiUrl) => {
1773
- const baseUrl = apiUrl || DEFAULT_API26;
1963
+ const baseUrl = apiUrl || DEFAULT_API28;
1774
1964
  return {
1775
1965
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1776
1966
  async list(params = {}) {
@@ -1785,9 +1975,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1785
1975
  };
1786
1976
 
1787
1977
  // src/audiences.ts
1788
- var DEFAULT_API27 = "https://be.graph8.com";
1978
+ var DEFAULT_API29 = "https://be.graph8.com";
1789
1979
  var createAudiencesClient = (apiKey, apiUrl) => {
1790
- const baseUrl = apiUrl || DEFAULT_API27;
1980
+ const baseUrl = apiUrl || DEFAULT_API29;
1791
1981
  const base = "/api/v1/audience-syncs";
1792
1982
  return {
1793
1983
  /** List all audience syncs for the organization. */
@@ -1835,9 +2025,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1835
2025
  };
1836
2026
 
1837
2027
  // src/search.ts
1838
- var DEFAULT_API28 = "https://be.graph8.com";
2028
+ var DEFAULT_API30 = "https://be.graph8.com";
1839
2029
  var createSearchClient = (apiKey, apiUrl) => {
1840
- const baseUrl = apiUrl || DEFAULT_API28;
2030
+ const baseUrl = apiUrl || DEFAULT_API30;
1841
2031
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1842
2032
  return {
1843
2033
  /** Search open-data contacts by filter. */
@@ -1868,9 +2058,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1868
2058
  };
1869
2059
 
1870
2060
  // src/agency.ts
1871
- var DEFAULT_API29 = "https://be.graph8.com";
2061
+ var DEFAULT_API31 = "https://be.graph8.com";
1872
2062
  var createAgencyClient = (apiKey, apiUrl) => {
1873
- const baseUrl = apiUrl || DEFAULT_API29;
2063
+ const baseUrl = apiUrl || DEFAULT_API31;
1874
2064
  return {
1875
2065
  /** Describe the agency credential: agency org + authorized client count. */
1876
2066
  async me() {
@@ -1885,9 +2075,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1885
2075
  };
1886
2076
 
1887
2077
  // src/marketplace.ts
1888
- var DEFAULT_API30 = "https://be.graph8.com";
2078
+ var DEFAULT_API32 = "https://be.graph8.com";
1889
2079
  var createMarketplaceClient = (apiKey, apiUrl) => {
1890
- const baseUrl = apiUrl || DEFAULT_API30;
2080
+ const baseUrl = apiUrl || DEFAULT_API32;
1891
2081
  const base = "/api/v1/marketplace";
1892
2082
  return {
1893
2083
  /** Your own marketplace SDR profile. */
@@ -1937,9 +2127,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1937
2127
  };
1938
2128
 
1939
2129
  // src/snippet.ts
1940
- var DEFAULT_API31 = "https://be.graph8.com";
2130
+ var DEFAULT_API33 = "https://be.graph8.com";
1941
2131
  var createSnippetClient = (apiKey, apiUrl) => {
1942
- const baseUrl = apiUrl || DEFAULT_API31;
2132
+ const baseUrl = apiUrl || DEFAULT_API33;
1943
2133
  return {
1944
2134
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1945
2135
  async get() {
@@ -1951,7 +2141,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1951
2141
 
1952
2142
  // src/core.ts
1953
2143
  var DEFAULT_HOST = "https://t.graph8.com";
1954
- var DEFAULT_API32 = "https://be.graph8.com";
2144
+ var DEFAULT_API34 = "https://be.graph8.com";
1955
2145
  var G8 = class {
1956
2146
  constructor() {
1957
2147
  /** @internal */
@@ -1993,6 +2183,10 @@ var G8 = class {
1993
2183
  /** @internal */
1994
2184
  this._fields = null;
1995
2185
  /** @internal */
2186
+ this._apps = null;
2187
+ /** @internal */
2188
+ this._objects = null;
2189
+ /** @internal */
1996
2190
  this._deals = null;
1997
2191
  /** @internal */
1998
2192
  this._inbox = null;
@@ -2034,7 +2228,7 @@ var G8 = class {
2034
2228
  debug: config.debug
2035
2229
  });
2036
2230
  }
2037
- const apiUrl = config.apiUrl || DEFAULT_API32;
2231
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2038
2232
  const writeKey = config.writeKey || "";
2039
2233
  const apiKey = config.apiKey || "";
2040
2234
  if (writeKey) {
@@ -2057,6 +2251,8 @@ var G8 = class {
2057
2251
  this._notes = createNotesClient(apiKey, apiUrl);
2058
2252
  this._tasks = createTasksClient(apiKey, apiUrl);
2059
2253
  this._fields = createFieldsClient(apiKey, apiUrl);
2254
+ this._apps = createAppsClient(apiKey, apiUrl);
2255
+ this._objects = createObjectsClient(apiKey, apiUrl);
2060
2256
  this._deals = createDealsClient(apiKey, apiUrl);
2061
2257
  this._inbox = createInboxClient(apiKey, apiUrl);
2062
2258
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2177,6 +2373,16 @@ var G8 = class {
2177
2373
  this._assertKey("fields");
2178
2374
  return this._fields;
2179
2375
  }
2376
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2377
+ get apps() {
2378
+ this._assertKey("apps");
2379
+ return this._apps;
2380
+ }
2381
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2382
+ get objects() {
2383
+ this._assertKey("objects");
2384
+ return this._objects;
2385
+ }
2180
2386
  /** Deals and pipelines (requires API key). */
2181
2387
  get deals() {
2182
2388
  this._assertKey("deals");