@graph8/sdk 0.12.2 → 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" });
@@ -1764,9 +1948,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1764
1948
  };
1765
1949
 
1766
1950
  // src/studio.ts
1767
- var DEFAULT_API25 = "https://be.graph8.com";
1951
+ var DEFAULT_API27 = "https://be.graph8.com";
1768
1952
  var createStudioClient = (apiKey, apiUrl) => {
1769
- const baseUrl = apiUrl || DEFAULT_API25;
1953
+ const baseUrl = apiUrl || DEFAULT_API27;
1770
1954
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1771
1955
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1772
1956
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1821,9 +2005,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1821
2005
  };
1822
2006
 
1823
2007
  // src/meetings.ts
1824
- var DEFAULT_API26 = "https://be.graph8.com";
2008
+ var DEFAULT_API28 = "https://be.graph8.com";
1825
2009
  var createMeetingsClient = (apiKey, apiUrl) => {
1826
- const baseUrl = apiUrl || DEFAULT_API26;
2010
+ const baseUrl = apiUrl || DEFAULT_API28;
1827
2011
  return {
1828
2012
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1829
2013
  async list(params = {}) {
@@ -1838,9 +2022,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1838
2022
  };
1839
2023
 
1840
2024
  // src/audiences.ts
1841
- var DEFAULT_API27 = "https://be.graph8.com";
2025
+ var DEFAULT_API29 = "https://be.graph8.com";
1842
2026
  var createAudiencesClient = (apiKey, apiUrl) => {
1843
- const baseUrl = apiUrl || DEFAULT_API27;
2027
+ const baseUrl = apiUrl || DEFAULT_API29;
1844
2028
  const base = "/api/v1/audience-syncs";
1845
2029
  return {
1846
2030
  /** List all audience syncs for the organization. */
@@ -1888,9 +2072,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1888
2072
  };
1889
2073
 
1890
2074
  // src/search.ts
1891
- var DEFAULT_API28 = "https://be.graph8.com";
2075
+ var DEFAULT_API30 = "https://be.graph8.com";
1892
2076
  var createSearchClient = (apiKey, apiUrl) => {
1893
- const baseUrl = apiUrl || DEFAULT_API28;
2077
+ const baseUrl = apiUrl || DEFAULT_API30;
1894
2078
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1895
2079
  return {
1896
2080
  /** Search open-data contacts by filter. */
@@ -1921,9 +2105,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1921
2105
  };
1922
2106
 
1923
2107
  // src/agency.ts
1924
- var DEFAULT_API29 = "https://be.graph8.com";
2108
+ var DEFAULT_API31 = "https://be.graph8.com";
1925
2109
  var createAgencyClient = (apiKey, apiUrl) => {
1926
- const baseUrl = apiUrl || DEFAULT_API29;
2110
+ const baseUrl = apiUrl || DEFAULT_API31;
1927
2111
  return {
1928
2112
  /** Describe the agency credential: agency org + authorized client count. */
1929
2113
  async me() {
@@ -1938,9 +2122,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1938
2122
  };
1939
2123
 
1940
2124
  // src/marketplace.ts
1941
- var DEFAULT_API30 = "https://be.graph8.com";
2125
+ var DEFAULT_API32 = "https://be.graph8.com";
1942
2126
  var createMarketplaceClient = (apiKey, apiUrl) => {
1943
- const baseUrl = apiUrl || DEFAULT_API30;
2127
+ const baseUrl = apiUrl || DEFAULT_API32;
1944
2128
  const base = "/api/v1/marketplace";
1945
2129
  return {
1946
2130
  /** Your own marketplace SDR profile. */
@@ -1990,9 +2174,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1990
2174
  };
1991
2175
 
1992
2176
  // src/snippet.ts
1993
- var DEFAULT_API31 = "https://be.graph8.com";
2177
+ var DEFAULT_API33 = "https://be.graph8.com";
1994
2178
  var createSnippetClient = (apiKey, apiUrl) => {
1995
- const baseUrl = apiUrl || DEFAULT_API31;
2179
+ const baseUrl = apiUrl || DEFAULT_API33;
1996
2180
  return {
1997
2181
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1998
2182
  async get() {
@@ -2004,7 +2188,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
2004
2188
 
2005
2189
  // src/core.ts
2006
2190
  var DEFAULT_HOST = "https://t.graph8.com";
2007
- var DEFAULT_API32 = "https://be.graph8.com";
2191
+ var DEFAULT_API34 = "https://be.graph8.com";
2008
2192
  var G8 = class {
2009
2193
  constructor() {
2010
2194
  /** @internal */
@@ -2046,6 +2230,10 @@ var G8 = class {
2046
2230
  /** @internal */
2047
2231
  this._fields = null;
2048
2232
  /** @internal */
2233
+ this._apps = null;
2234
+ /** @internal */
2235
+ this._objects = null;
2236
+ /** @internal */
2049
2237
  this._deals = null;
2050
2238
  /** @internal */
2051
2239
  this._inbox = null;
@@ -2087,7 +2275,7 @@ var G8 = class {
2087
2275
  debug: config.debug
2088
2276
  });
2089
2277
  }
2090
- const apiUrl = config.apiUrl || DEFAULT_API32;
2278
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2091
2279
  const writeKey = config.writeKey || "";
2092
2280
  const apiKey = config.apiKey || "";
2093
2281
  if (writeKey) {
@@ -2110,6 +2298,8 @@ var G8 = class {
2110
2298
  this._notes = createNotesClient(apiKey, apiUrl);
2111
2299
  this._tasks = createTasksClient(apiKey, apiUrl);
2112
2300
  this._fields = createFieldsClient(apiKey, apiUrl);
2301
+ this._apps = createAppsClient(apiKey, apiUrl);
2302
+ this._objects = createObjectsClient(apiKey, apiUrl);
2113
2303
  this._deals = createDealsClient(apiKey, apiUrl);
2114
2304
  this._inbox = createInboxClient(apiKey, apiUrl);
2115
2305
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2230,6 +2420,16 @@ var G8 = class {
2230
2420
  this._assertKey("fields");
2231
2421
  return this._fields;
2232
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
+ }
2233
2433
  /** Deals and pipelines (requires API key). */
2234
2434
  get deals() {
2235
2435
  this._assertKey("deals");