@graph8/sdk 0.12.2 → 0.13.1

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,122 @@ 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, options) {
1370
+ const resp = await request(
1371
+ baseUrl,
1372
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1373
+ apiKey,
1374
+ { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
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
+ /** Restore archived values under current constraints. Conflicts leave the record archived. */
1392
+ async restoreRecord(objectSlug, recordId) {
1393
+ const resp = await request(
1394
+ baseUrl,
1395
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/restore`,
1396
+ apiKey,
1397
+ { method: "POST" }
1398
+ );
1399
+ return resp.data ?? resp;
1400
+ },
1401
+ /**
1402
+ * A record's value timeline, newest first. An entry whose `active_until` is
1403
+ * null is the value currently in force.
1404
+ */
1405
+ async history(objectSlug, recordId, limit) {
1406
+ const resp = await request(
1407
+ baseUrl,
1408
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1409
+ apiKey,
1410
+ { query: limit != null ? { limit } : void 0 }
1411
+ );
1412
+ return resp.data ?? resp;
1413
+ }
1414
+ };
1415
+ };
1416
+
1223
1417
  // src/deals.ts
1224
- var DEFAULT_API18 = "https://be.graph8.com";
1418
+ var DEFAULT_API20 = "https://be.graph8.com";
1225
1419
  var createDealsClient = (apiKey, apiUrl) => {
1226
- const baseUrl = apiUrl || DEFAULT_API18;
1420
+ const baseUrl = apiUrl || DEFAULT_API20;
1227
1421
  return {
1228
1422
  /** List all deal pipelines and their stages. */
1229
1423
  async pipelines() {
@@ -1267,9 +1461,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1267
1461
  };
1268
1462
 
1269
1463
  // src/inbox.ts
1270
- var DEFAULT_API19 = "https://be.graph8.com";
1464
+ var DEFAULT_API21 = "https://be.graph8.com";
1271
1465
  var createInboxClient = (apiKey, apiUrl) => {
1272
- const baseUrl = apiUrl || DEFAULT_API19;
1466
+ const baseUrl = apiUrl || DEFAULT_API21;
1273
1467
  return {
1274
1468
  /** List inbox threads across email, SMS, and LinkedIn. */
1275
1469
  async list(params = {}) {
@@ -1322,9 +1516,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1322
1516
  };
1323
1517
 
1324
1518
  // src/quotes.ts
1325
- var DEFAULT_API20 = "https://be.graph8.com";
1519
+ var DEFAULT_API22 = "https://be.graph8.com";
1326
1520
  var createQuotesClient = (apiKey, apiUrl) => {
1327
- const baseUrl = apiUrl || DEFAULT_API20;
1521
+ const baseUrl = apiUrl || DEFAULT_API22;
1328
1522
  return {
1329
1523
  /** List quotes org-wide with optional filters and pagination. */
1330
1524
  async list(params = {}) {
@@ -1396,9 +1590,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1396
1590
  };
1397
1591
 
1398
1592
  // src/pipelines.ts
1399
- var DEFAULT_API21 = "https://be.graph8.com";
1593
+ var DEFAULT_API23 = "https://be.graph8.com";
1400
1594
  var createPipelinesClient = (apiKey, apiUrl) => {
1401
- const baseUrl = apiUrl || DEFAULT_API21;
1595
+ const baseUrl = apiUrl || DEFAULT_API23;
1402
1596
  return {
1403
1597
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1404
1598
  async list() {
@@ -1480,9 +1674,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1480
1674
  };
1481
1675
 
1482
1676
  // src/workflows.ts
1483
- var DEFAULT_API22 = "https://be.graph8.com";
1677
+ var DEFAULT_API24 = "https://be.graph8.com";
1484
1678
  var createWorkflowsClient = (apiKey, apiUrl) => {
1485
- const baseUrl = apiUrl || DEFAULT_API22;
1679
+ const baseUrl = apiUrl || DEFAULT_API24;
1486
1680
  return {
1487
1681
  /** List workflows org-wide. */
1488
1682
  async list(params = {}) {
@@ -1598,9 +1792,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1598
1792
  };
1599
1793
 
1600
1794
  // src/skills.ts
1601
- var DEFAULT_API23 = "https://be.graph8.com";
1795
+ var DEFAULT_API25 = "https://be.graph8.com";
1602
1796
  var createSkillsClient = (apiKey, apiUrl) => {
1603
- const baseUrl = apiUrl || DEFAULT_API23;
1797
+ const baseUrl = apiUrl || DEFAULT_API25;
1604
1798
  return {
1605
1799
  /** List skills. */
1606
1800
  async list(params = {}) {
@@ -1687,9 +1881,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1687
1881
  };
1688
1882
 
1689
1883
  // src/intent.ts
1690
- var DEFAULT_API24 = "https://be.graph8.com";
1884
+ var DEFAULT_API26 = "https://be.graph8.com";
1691
1885
  var createIntentClient = (apiKey, apiUrl) => {
1692
- const baseUrl = apiUrl || DEFAULT_API24;
1886
+ const baseUrl = apiUrl || DEFAULT_API26;
1693
1887
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1694
1888
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1695
1889
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1764,9 +1958,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1764
1958
  };
1765
1959
 
1766
1960
  // src/studio.ts
1767
- var DEFAULT_API25 = "https://be.graph8.com";
1961
+ var DEFAULT_API27 = "https://be.graph8.com";
1768
1962
  var createStudioClient = (apiKey, apiUrl) => {
1769
- const baseUrl = apiUrl || DEFAULT_API25;
1963
+ const baseUrl = apiUrl || DEFAULT_API27;
1770
1964
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1771
1965
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1772
1966
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1821,9 +2015,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1821
2015
  };
1822
2016
 
1823
2017
  // src/meetings.ts
1824
- var DEFAULT_API26 = "https://be.graph8.com";
2018
+ var DEFAULT_API28 = "https://be.graph8.com";
1825
2019
  var createMeetingsClient = (apiKey, apiUrl) => {
1826
- const baseUrl = apiUrl || DEFAULT_API26;
2020
+ const baseUrl = apiUrl || DEFAULT_API28;
1827
2021
  return {
1828
2022
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1829
2023
  async list(params = {}) {
@@ -1838,9 +2032,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1838
2032
  };
1839
2033
 
1840
2034
  // src/audiences.ts
1841
- var DEFAULT_API27 = "https://be.graph8.com";
2035
+ var DEFAULT_API29 = "https://be.graph8.com";
1842
2036
  var createAudiencesClient = (apiKey, apiUrl) => {
1843
- const baseUrl = apiUrl || DEFAULT_API27;
2037
+ const baseUrl = apiUrl || DEFAULT_API29;
1844
2038
  const base = "/api/v1/audience-syncs";
1845
2039
  return {
1846
2040
  /** List all audience syncs for the organization. */
@@ -1888,9 +2082,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1888
2082
  };
1889
2083
 
1890
2084
  // src/search.ts
1891
- var DEFAULT_API28 = "https://be.graph8.com";
2085
+ var DEFAULT_API30 = "https://be.graph8.com";
1892
2086
  var createSearchClient = (apiKey, apiUrl) => {
1893
- const baseUrl = apiUrl || DEFAULT_API28;
2087
+ const baseUrl = apiUrl || DEFAULT_API30;
1894
2088
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1895
2089
  return {
1896
2090
  /** Search open-data contacts by filter. */
@@ -1921,9 +2115,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1921
2115
  };
1922
2116
 
1923
2117
  // src/agency.ts
1924
- var DEFAULT_API29 = "https://be.graph8.com";
2118
+ var DEFAULT_API31 = "https://be.graph8.com";
1925
2119
  var createAgencyClient = (apiKey, apiUrl) => {
1926
- const baseUrl = apiUrl || DEFAULT_API29;
2120
+ const baseUrl = apiUrl || DEFAULT_API31;
1927
2121
  return {
1928
2122
  /** Describe the agency credential: agency org + authorized client count. */
1929
2123
  async me() {
@@ -1938,9 +2132,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1938
2132
  };
1939
2133
 
1940
2134
  // src/marketplace.ts
1941
- var DEFAULT_API30 = "https://be.graph8.com";
2135
+ var DEFAULT_API32 = "https://be.graph8.com";
1942
2136
  var createMarketplaceClient = (apiKey, apiUrl) => {
1943
- const baseUrl = apiUrl || DEFAULT_API30;
2137
+ const baseUrl = apiUrl || DEFAULT_API32;
1944
2138
  const base = "/api/v1/marketplace";
1945
2139
  return {
1946
2140
  /** Your own marketplace SDR profile. */
@@ -1990,9 +2184,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1990
2184
  };
1991
2185
 
1992
2186
  // src/snippet.ts
1993
- var DEFAULT_API31 = "https://be.graph8.com";
2187
+ var DEFAULT_API33 = "https://be.graph8.com";
1994
2188
  var createSnippetClient = (apiKey, apiUrl) => {
1995
- const baseUrl = apiUrl || DEFAULT_API31;
2189
+ const baseUrl = apiUrl || DEFAULT_API33;
1996
2190
  return {
1997
2191
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1998
2192
  async get() {
@@ -2004,7 +2198,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
2004
2198
 
2005
2199
  // src/core.ts
2006
2200
  var DEFAULT_HOST = "https://t.graph8.com";
2007
- var DEFAULT_API32 = "https://be.graph8.com";
2201
+ var DEFAULT_API34 = "https://be.graph8.com";
2008
2202
  var G8 = class {
2009
2203
  constructor() {
2010
2204
  /** @internal */
@@ -2046,6 +2240,10 @@ var G8 = class {
2046
2240
  /** @internal */
2047
2241
  this._fields = null;
2048
2242
  /** @internal */
2243
+ this._apps = null;
2244
+ /** @internal */
2245
+ this._objects = null;
2246
+ /** @internal */
2049
2247
  this._deals = null;
2050
2248
  /** @internal */
2051
2249
  this._inbox = null;
@@ -2087,7 +2285,7 @@ var G8 = class {
2087
2285
  debug: config.debug
2088
2286
  });
2089
2287
  }
2090
- const apiUrl = config.apiUrl || DEFAULT_API32;
2288
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2091
2289
  const writeKey = config.writeKey || "";
2092
2290
  const apiKey = config.apiKey || "";
2093
2291
  if (writeKey) {
@@ -2110,6 +2308,8 @@ var G8 = class {
2110
2308
  this._notes = createNotesClient(apiKey, apiUrl);
2111
2309
  this._tasks = createTasksClient(apiKey, apiUrl);
2112
2310
  this._fields = createFieldsClient(apiKey, apiUrl);
2311
+ this._apps = createAppsClient(apiKey, apiUrl);
2312
+ this._objects = createObjectsClient(apiKey, apiUrl);
2113
2313
  this._deals = createDealsClient(apiKey, apiUrl);
2114
2314
  this._inbox = createInboxClient(apiKey, apiUrl);
2115
2315
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2230,6 +2430,16 @@ var G8 = class {
2230
2430
  this._assertKey("fields");
2231
2431
  return this._fields;
2232
2432
  }
2433
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2434
+ get apps() {
2435
+ this._assertKey("apps");
2436
+ return this._apps;
2437
+ }
2438
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2439
+ get objects() {
2440
+ this._assertKey("objects");
2441
+ return this._objects;
2442
+ }
2233
2443
  /** Deals and pipelines (requires API key). */
2234
2444
  get deals() {
2235
2445
  this._assertKey("deals");