@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.mjs CHANGED
@@ -1134,10 +1134,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1134
1134
  };
1135
1135
  };
1136
1136
 
1137
- // src/fields.ts
1137
+ // src/apps.ts
1138
1138
  var DEFAULT_API17 = "https://be.graph8.com";
1139
- var createFieldsClient = (apiKey, apiUrl) => {
1139
+ var createAppsClient = (apiKey, apiUrl) => {
1140
1140
  const baseUrl = apiUrl || DEFAULT_API17;
1141
+ return {
1142
+ /** List your organization's apps, newest first. */
1143
+ async list() {
1144
+ return request(baseUrl, "/api/v1/apps", apiKey);
1145
+ },
1146
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1147
+ async get(appId) {
1148
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1149
+ return resp.data ?? resp;
1150
+ },
1151
+ /**
1152
+ * Create an app. It starts in `draft` and serves no traffic until published.
1153
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1154
+ */
1155
+ async create(params) {
1156
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1157
+ method: "POST",
1158
+ body: {
1159
+ name: params.name,
1160
+ slug: params.slug,
1161
+ registered_origins: params.registered_origins ?? []
1162
+ }
1163
+ });
1164
+ return resp.data ?? resp;
1165
+ },
1166
+ /**
1167
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1168
+ *
1169
+ * `suspended` is excluded from the parameter type on purpose: it is the
1170
+ * platform's kill switch for an abusive app, the backend refuses it with a
1171
+ * 403, and a builder who could set it could also unset it.
1172
+ */
1173
+ async setStatus(appId, status) {
1174
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1175
+ method: "POST",
1176
+ body: { status }
1177
+ });
1178
+ return resp.data ?? resp;
1179
+ },
1180
+ /**
1181
+ * The client organizations that installed this app, and their consent state.
1182
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1183
+ * tenant, this is where you see why.
1184
+ */
1185
+ async listInstalls(appId) {
1186
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1187
+ },
1188
+ /**
1189
+ * Credits this app consumed in a calendar month, broken down per client org.
1190
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1191
+ * 404 — "nothing happened" is an answer.
1192
+ */
1193
+ async usage(appId, period) {
1194
+ const resp = await request(
1195
+ baseUrl,
1196
+ `/api/v1/apps/${appId}/usage`,
1197
+ apiKey,
1198
+ { query: period ? { period } : void 0 }
1199
+ );
1200
+ return resp.data ?? resp;
1201
+ },
1202
+ /**
1203
+ * This app's hard credit cap, or `null` when it is uncapped.
1204
+ *
1205
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1206
+ * sentinel, so an accidental zero can never read as "no limit".
1207
+ */
1208
+ async getLimit(appId) {
1209
+ const resp = await request(
1210
+ baseUrl,
1211
+ `/api/v1/apps/${appId}/limit`,
1212
+ apiKey
1213
+ );
1214
+ return resp.data ?? null;
1215
+ }
1216
+ };
1217
+ };
1218
+
1219
+ // src/fields.ts
1220
+ var DEFAULT_API18 = "https://be.graph8.com";
1221
+ var createFieldsClient = (apiKey, apiUrl) => {
1222
+ const baseUrl = apiUrl || DEFAULT_API18;
1141
1223
  return {
1142
1224
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1143
1225
  async listContactFields(listId) {
@@ -1178,10 +1260,112 @@ var createFieldsClient = (apiKey, apiUrl) => {
1178
1260
  };
1179
1261
  };
1180
1262
 
1263
+ // src/objects.ts
1264
+ var DEFAULT_API19 = "https://be.graph8.com";
1265
+ var createObjectsClient = (apiKey, apiUrl) => {
1266
+ const baseUrl = apiUrl || DEFAULT_API19;
1267
+ const encode = (value) => encodeURIComponent(value);
1268
+ return {
1269
+ /** List the custom object types in your workspace. */
1270
+ async list() {
1271
+ return request(baseUrl, "/api/v1/objects", apiKey);
1272
+ },
1273
+ /** Fetch one object type by slug. */
1274
+ async get(objectSlug) {
1275
+ const resp = await request(
1276
+ baseUrl,
1277
+ `/api/v1/objects/${encode(objectSlug)}`,
1278
+ apiKey
1279
+ );
1280
+ return resp.data ?? resp;
1281
+ },
1282
+ /** The object's attributes — the schema its records must satisfy. */
1283
+ async listAttributes(objectSlug) {
1284
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1285
+ },
1286
+ /** Paginated records with their current values. Archived records are excluded. */
1287
+ async listRecords(objectSlug, params = {}) {
1288
+ const query = {};
1289
+ if (params.page != null) query.page = params.page;
1290
+ if (params.limit != null) query.limit = params.limit;
1291
+ if (params.cursor != null) query.cursor = params.cursor;
1292
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1293
+ query: Object.keys(query).length ? query : void 0
1294
+ });
1295
+ },
1296
+ /**
1297
+ * Create a record. Every field is validated against the object's attributes;
1298
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1299
+ * unique attribute is a 409.
1300
+ */
1301
+ async createRecord(objectSlug, values) {
1302
+ const resp = await request(
1303
+ baseUrl,
1304
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1305
+ apiKey,
1306
+ { method: "POST", body: { values } }
1307
+ );
1308
+ return resp.data ?? resp;
1309
+ },
1310
+ /** Fetch one record with its currently active values. */
1311
+ async getRecord(objectSlug, recordId) {
1312
+ const resp = await request(
1313
+ baseUrl,
1314
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1315
+ apiKey
1316
+ );
1317
+ return resp.data ?? resp;
1318
+ },
1319
+ /**
1320
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1321
+ * required attributes you omit are left alone rather than reported missing.
1322
+ * Sending an explicit `null` CLEARS that attribute.
1323
+ *
1324
+ * Values are versioned rather than overwritten, so the previous value stays
1325
+ * readable through `history`.
1326
+ */
1327
+ async updateRecord(objectSlug, recordId, values) {
1328
+ const resp = await request(
1329
+ baseUrl,
1330
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1331
+ apiKey,
1332
+ { method: "PATCH", body: { values } }
1333
+ );
1334
+ return resp.data ?? resp;
1335
+ },
1336
+ /**
1337
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1338
+ * history and associations. Nothing is destroyed.
1339
+ */
1340
+ async archiveRecord(objectSlug, recordId) {
1341
+ const resp = await request(
1342
+ baseUrl,
1343
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1344
+ apiKey,
1345
+ { method: "DELETE" }
1346
+ );
1347
+ return resp.data ?? resp;
1348
+ },
1349
+ /**
1350
+ * A record's value timeline, newest first. An entry whose `active_until` is
1351
+ * null is the value currently in force.
1352
+ */
1353
+ async history(objectSlug, recordId, limit) {
1354
+ const resp = await request(
1355
+ baseUrl,
1356
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1357
+ apiKey,
1358
+ { query: limit != null ? { limit } : void 0 }
1359
+ );
1360
+ return resp.data ?? resp;
1361
+ }
1362
+ };
1363
+ };
1364
+
1181
1365
  // src/deals.ts
1182
- var DEFAULT_API18 = "https://be.graph8.com";
1366
+ var DEFAULT_API20 = "https://be.graph8.com";
1183
1367
  var createDealsClient = (apiKey, apiUrl) => {
1184
- const baseUrl = apiUrl || DEFAULT_API18;
1368
+ const baseUrl = apiUrl || DEFAULT_API20;
1185
1369
  return {
1186
1370
  /** List all deal pipelines and their stages. */
1187
1371
  async pipelines() {
@@ -1225,9 +1409,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1225
1409
  };
1226
1410
 
1227
1411
  // src/inbox.ts
1228
- var DEFAULT_API19 = "https://be.graph8.com";
1412
+ var DEFAULT_API21 = "https://be.graph8.com";
1229
1413
  var createInboxClient = (apiKey, apiUrl) => {
1230
- const baseUrl = apiUrl || DEFAULT_API19;
1414
+ const baseUrl = apiUrl || DEFAULT_API21;
1231
1415
  return {
1232
1416
  /** List inbox threads across email, SMS, and LinkedIn. */
1233
1417
  async list(params = {}) {
@@ -1280,9 +1464,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1280
1464
  };
1281
1465
 
1282
1466
  // src/quotes.ts
1283
- var DEFAULT_API20 = "https://be.graph8.com";
1467
+ var DEFAULT_API22 = "https://be.graph8.com";
1284
1468
  var createQuotesClient = (apiKey, apiUrl) => {
1285
- const baseUrl = apiUrl || DEFAULT_API20;
1469
+ const baseUrl = apiUrl || DEFAULT_API22;
1286
1470
  return {
1287
1471
  /** List quotes org-wide with optional filters and pagination. */
1288
1472
  async list(params = {}) {
@@ -1354,9 +1538,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1354
1538
  };
1355
1539
 
1356
1540
  // src/pipelines.ts
1357
- var DEFAULT_API21 = "https://be.graph8.com";
1541
+ var DEFAULT_API23 = "https://be.graph8.com";
1358
1542
  var createPipelinesClient = (apiKey, apiUrl) => {
1359
- const baseUrl = apiUrl || DEFAULT_API21;
1543
+ const baseUrl = apiUrl || DEFAULT_API23;
1360
1544
  return {
1361
1545
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1362
1546
  async list() {
@@ -1438,9 +1622,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1438
1622
  };
1439
1623
 
1440
1624
  // src/workflows.ts
1441
- var DEFAULT_API22 = "https://be.graph8.com";
1625
+ var DEFAULT_API24 = "https://be.graph8.com";
1442
1626
  var createWorkflowsClient = (apiKey, apiUrl) => {
1443
- const baseUrl = apiUrl || DEFAULT_API22;
1627
+ const baseUrl = apiUrl || DEFAULT_API24;
1444
1628
  return {
1445
1629
  /** List workflows org-wide. */
1446
1630
  async list(params = {}) {
@@ -1556,9 +1740,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1556
1740
  };
1557
1741
 
1558
1742
  // src/skills.ts
1559
- var DEFAULT_API23 = "https://be.graph8.com";
1743
+ var DEFAULT_API25 = "https://be.graph8.com";
1560
1744
  var createSkillsClient = (apiKey, apiUrl) => {
1561
- const baseUrl = apiUrl || DEFAULT_API23;
1745
+ const baseUrl = apiUrl || DEFAULT_API25;
1562
1746
  return {
1563
1747
  /** List skills. */
1564
1748
  async list(params = {}) {
@@ -1645,9 +1829,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1645
1829
  };
1646
1830
 
1647
1831
  // src/intent.ts
1648
- var DEFAULT_API24 = "https://be.graph8.com";
1832
+ var DEFAULT_API26 = "https://be.graph8.com";
1649
1833
  var createIntentClient = (apiKey, apiUrl) => {
1650
- const baseUrl = apiUrl || DEFAULT_API24;
1834
+ const baseUrl = apiUrl || DEFAULT_API26;
1651
1835
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1652
1836
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1653
1837
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1703,22 +1887,28 @@ var createIntentClient = (apiKey, apiUrl) => {
1703
1887
  /**
1704
1888
  * Find companies whose users visited a specific URL (intent search).
1705
1889
  *
1706
- * Note: this endpoint lives at the bare host (no `/api/v1` prefix), unlike the rest
1707
- * of the intent surface we call it directly here instead of through the shared `post()` helper.
1890
+ * Previously posted to the bare-host `/intent-search/url-companies`, bypassing
1891
+ * the shared `post()` helper. That route is JWT-only, so this method could
1892
+ * never actually work with an API key. It now goes through
1893
+ * `/api/v1/intent/url-companies` like the rest of the intent surface (g8 issue
1894
+ * #16536).
1895
+ *
1896
+ * Returns a bare aggregate, NOT the `{ data }` envelope — the previous
1897
+ * `{ data: IntentCompany[] }` signature never matched what the API sends.
1898
+ *
1899
+ * `date_from` / `date_to` are accepted for backwards compatibility but have
1900
+ * never been read by this endpoint; use `days` to set the lookback window.
1708
1901
  */
1709
1902
  async urlCompanies(url, params = {}) {
1710
- return request(baseUrl, "/intent-search/url-companies", apiKey, {
1711
- method: "POST",
1712
- body: { url, ...params }
1713
- });
1903
+ return post("/intent/url-companies", { url, ...params });
1714
1904
  }
1715
1905
  };
1716
1906
  };
1717
1907
 
1718
1908
  // src/studio.ts
1719
- var DEFAULT_API25 = "https://be.graph8.com";
1909
+ var DEFAULT_API27 = "https://be.graph8.com";
1720
1910
  var createStudioClient = (apiKey, apiUrl) => {
1721
- const baseUrl = apiUrl || DEFAULT_API25;
1911
+ const baseUrl = apiUrl || DEFAULT_API27;
1722
1912
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1723
1913
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1724
1914
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1773,9 +1963,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1773
1963
  };
1774
1964
 
1775
1965
  // src/meetings.ts
1776
- var DEFAULT_API26 = "https://be.graph8.com";
1966
+ var DEFAULT_API28 = "https://be.graph8.com";
1777
1967
  var createMeetingsClient = (apiKey, apiUrl) => {
1778
- const baseUrl = apiUrl || DEFAULT_API26;
1968
+ const baseUrl = apiUrl || DEFAULT_API28;
1779
1969
  return {
1780
1970
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1781
1971
  async list(params = {}) {
@@ -1790,9 +1980,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1790
1980
  };
1791
1981
 
1792
1982
  // src/audiences.ts
1793
- var DEFAULT_API27 = "https://be.graph8.com";
1983
+ var DEFAULT_API29 = "https://be.graph8.com";
1794
1984
  var createAudiencesClient = (apiKey, apiUrl) => {
1795
- const baseUrl = apiUrl || DEFAULT_API27;
1985
+ const baseUrl = apiUrl || DEFAULT_API29;
1796
1986
  const base = "/api/v1/audience-syncs";
1797
1987
  return {
1798
1988
  /** List all audience syncs for the organization. */
@@ -1840,9 +2030,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1840
2030
  };
1841
2031
 
1842
2032
  // src/search.ts
1843
- var DEFAULT_API28 = "https://be.graph8.com";
2033
+ var DEFAULT_API30 = "https://be.graph8.com";
1844
2034
  var createSearchClient = (apiKey, apiUrl) => {
1845
- const baseUrl = apiUrl || DEFAULT_API28;
2035
+ const baseUrl = apiUrl || DEFAULT_API30;
1846
2036
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1847
2037
  return {
1848
2038
  /** Search open-data contacts by filter. */
@@ -1873,9 +2063,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1873
2063
  };
1874
2064
 
1875
2065
  // src/agency.ts
1876
- var DEFAULT_API29 = "https://be.graph8.com";
2066
+ var DEFAULT_API31 = "https://be.graph8.com";
1877
2067
  var createAgencyClient = (apiKey, apiUrl) => {
1878
- const baseUrl = apiUrl || DEFAULT_API29;
2068
+ const baseUrl = apiUrl || DEFAULT_API31;
1879
2069
  return {
1880
2070
  /** Describe the agency credential: agency org + authorized client count. */
1881
2071
  async me() {
@@ -1890,9 +2080,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1890
2080
  };
1891
2081
 
1892
2082
  // src/marketplace.ts
1893
- var DEFAULT_API30 = "https://be.graph8.com";
2083
+ var DEFAULT_API32 = "https://be.graph8.com";
1894
2084
  var createMarketplaceClient = (apiKey, apiUrl) => {
1895
- const baseUrl = apiUrl || DEFAULT_API30;
2085
+ const baseUrl = apiUrl || DEFAULT_API32;
1896
2086
  const base = "/api/v1/marketplace";
1897
2087
  return {
1898
2088
  /** Your own marketplace SDR profile. */
@@ -1942,9 +2132,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1942
2132
  };
1943
2133
 
1944
2134
  // src/snippet.ts
1945
- var DEFAULT_API31 = "https://be.graph8.com";
2135
+ var DEFAULT_API33 = "https://be.graph8.com";
1946
2136
  var createSnippetClient = (apiKey, apiUrl) => {
1947
- const baseUrl = apiUrl || DEFAULT_API31;
2137
+ const baseUrl = apiUrl || DEFAULT_API33;
1948
2138
  return {
1949
2139
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1950
2140
  async get() {
@@ -1956,7 +2146,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1956
2146
 
1957
2147
  // src/core.ts
1958
2148
  var DEFAULT_HOST = "https://t.graph8.com";
1959
- var DEFAULT_API32 = "https://be.graph8.com";
2149
+ var DEFAULT_API34 = "https://be.graph8.com";
1960
2150
  var G8 = class {
1961
2151
  constructor() {
1962
2152
  /** @internal */
@@ -1998,6 +2188,10 @@ var G8 = class {
1998
2188
  /** @internal */
1999
2189
  this._fields = null;
2000
2190
  /** @internal */
2191
+ this._apps = null;
2192
+ /** @internal */
2193
+ this._objects = null;
2194
+ /** @internal */
2001
2195
  this._deals = null;
2002
2196
  /** @internal */
2003
2197
  this._inbox = null;
@@ -2039,7 +2233,7 @@ var G8 = class {
2039
2233
  debug: config.debug
2040
2234
  });
2041
2235
  }
2042
- const apiUrl = config.apiUrl || DEFAULT_API32;
2236
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2043
2237
  const writeKey = config.writeKey || "";
2044
2238
  const apiKey = config.apiKey || "";
2045
2239
  if (writeKey) {
@@ -2062,6 +2256,8 @@ var G8 = class {
2062
2256
  this._notes = createNotesClient(apiKey, apiUrl);
2063
2257
  this._tasks = createTasksClient(apiKey, apiUrl);
2064
2258
  this._fields = createFieldsClient(apiKey, apiUrl);
2259
+ this._apps = createAppsClient(apiKey, apiUrl);
2260
+ this._objects = createObjectsClient(apiKey, apiUrl);
2065
2261
  this._deals = createDealsClient(apiKey, apiUrl);
2066
2262
  this._inbox = createInboxClient(apiKey, apiUrl);
2067
2263
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2182,6 +2378,16 @@ var G8 = class {
2182
2378
  this._assertKey("fields");
2183
2379
  return this._fields;
2184
2380
  }
2381
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2382
+ get apps() {
2383
+ this._assertKey("apps");
2384
+ return this._apps;
2385
+ }
2386
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2387
+ get objects() {
2388
+ this._assertKey("objects");
2389
+ return this._objects;
2390
+ }
2185
2391
  /** Deals and pipelines (requires API key). */
2186
2392
  get deals() {
2187
2393
  this._assertKey("deals");