@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/react.js CHANGED
@@ -1153,10 +1153,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1153
1153
  };
1154
1154
  };
1155
1155
 
1156
- // src/fields.ts
1156
+ // src/apps.ts
1157
1157
  var DEFAULT_API17 = "https://be.graph8.com";
1158
- var createFieldsClient = (apiKey, apiUrl) => {
1158
+ var createAppsClient = (apiKey, apiUrl) => {
1159
1159
  const baseUrl = apiUrl || DEFAULT_API17;
1160
+ return {
1161
+ /** List your organization's apps, newest first. */
1162
+ async list() {
1163
+ return request(baseUrl, "/api/v1/apps", apiKey);
1164
+ },
1165
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1166
+ async get(appId) {
1167
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1168
+ return resp.data ?? resp;
1169
+ },
1170
+ /**
1171
+ * Create an app. It starts in `draft` and serves no traffic until published.
1172
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1173
+ */
1174
+ async create(params) {
1175
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1176
+ method: "POST",
1177
+ body: {
1178
+ name: params.name,
1179
+ slug: params.slug,
1180
+ registered_origins: params.registered_origins ?? []
1181
+ }
1182
+ });
1183
+ return resp.data ?? resp;
1184
+ },
1185
+ /**
1186
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1187
+ *
1188
+ * `suspended` is excluded from the parameter type on purpose: it is the
1189
+ * platform's kill switch for an abusive app, the backend refuses it with a
1190
+ * 403, and a builder who could set it could also unset it.
1191
+ */
1192
+ async setStatus(appId, status) {
1193
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1194
+ method: "POST",
1195
+ body: { status }
1196
+ });
1197
+ return resp.data ?? resp;
1198
+ },
1199
+ /**
1200
+ * The client organizations that installed this app, and their consent state.
1201
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1202
+ * tenant, this is where you see why.
1203
+ */
1204
+ async listInstalls(appId) {
1205
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1206
+ },
1207
+ /**
1208
+ * Credits this app consumed in a calendar month, broken down per client org.
1209
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1210
+ * 404 — "nothing happened" is an answer.
1211
+ */
1212
+ async usage(appId, period) {
1213
+ const resp = await request(
1214
+ baseUrl,
1215
+ `/api/v1/apps/${appId}/usage`,
1216
+ apiKey,
1217
+ { query: period ? { period } : void 0 }
1218
+ );
1219
+ return resp.data ?? resp;
1220
+ },
1221
+ /**
1222
+ * This app's hard credit cap, or `null` when it is uncapped.
1223
+ *
1224
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1225
+ * sentinel, so an accidental zero can never read as "no limit".
1226
+ */
1227
+ async getLimit(appId) {
1228
+ const resp = await request(
1229
+ baseUrl,
1230
+ `/api/v1/apps/${appId}/limit`,
1231
+ apiKey
1232
+ );
1233
+ return resp.data ?? null;
1234
+ }
1235
+ };
1236
+ };
1237
+
1238
+ // src/fields.ts
1239
+ var DEFAULT_API18 = "https://be.graph8.com";
1240
+ var createFieldsClient = (apiKey, apiUrl) => {
1241
+ const baseUrl = apiUrl || DEFAULT_API18;
1160
1242
  return {
1161
1243
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1162
1244
  async listContactFields(listId) {
@@ -1197,10 +1279,122 @@ var createFieldsClient = (apiKey, apiUrl) => {
1197
1279
  };
1198
1280
  };
1199
1281
 
1282
+ // src/objects.ts
1283
+ var DEFAULT_API19 = "https://be.graph8.com";
1284
+ var createObjectsClient = (apiKey, apiUrl) => {
1285
+ const baseUrl = apiUrl || DEFAULT_API19;
1286
+ const encode = (value) => encodeURIComponent(value);
1287
+ return {
1288
+ /** List the custom object types in your workspace. */
1289
+ async list() {
1290
+ return request(baseUrl, "/api/v1/objects", apiKey);
1291
+ },
1292
+ /** Fetch one object type by slug. */
1293
+ async get(objectSlug) {
1294
+ const resp = await request(
1295
+ baseUrl,
1296
+ `/api/v1/objects/${encode(objectSlug)}`,
1297
+ apiKey
1298
+ );
1299
+ return resp.data ?? resp;
1300
+ },
1301
+ /** The object's attributes — the schema its records must satisfy. */
1302
+ async listAttributes(objectSlug) {
1303
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1304
+ },
1305
+ /** Paginated records with their current values. Archived records are excluded. */
1306
+ async listRecords(objectSlug, params = {}) {
1307
+ const query = {};
1308
+ if (params.page != null) query.page = params.page;
1309
+ if (params.limit != null) query.limit = params.limit;
1310
+ if (params.cursor != null) query.cursor = params.cursor;
1311
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1312
+ query: Object.keys(query).length ? query : void 0
1313
+ });
1314
+ },
1315
+ /**
1316
+ * Create a record. Every field is validated against the object's attributes;
1317
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1318
+ * unique attribute is a 409.
1319
+ */
1320
+ async createRecord(objectSlug, values) {
1321
+ const resp = await request(
1322
+ baseUrl,
1323
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1324
+ apiKey,
1325
+ { method: "POST", body: { values } }
1326
+ );
1327
+ return resp.data ?? resp;
1328
+ },
1329
+ /** Fetch one record with its currently active values. */
1330
+ async getRecord(objectSlug, recordId) {
1331
+ const resp = await request(
1332
+ baseUrl,
1333
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1334
+ apiKey
1335
+ );
1336
+ return resp.data ?? resp;
1337
+ },
1338
+ /**
1339
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1340
+ * required attributes you omit are left alone rather than reported missing.
1341
+ * Sending an explicit `null` CLEARS that attribute.
1342
+ *
1343
+ * Values are versioned rather than overwritten, so the previous value stays
1344
+ * readable through `history`.
1345
+ */
1346
+ async updateRecord(objectSlug, recordId, values, options) {
1347
+ const resp = await request(
1348
+ baseUrl,
1349
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1350
+ apiKey,
1351
+ { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
1352
+ );
1353
+ return resp.data ?? resp;
1354
+ },
1355
+ /**
1356
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1357
+ * history and associations. Nothing is destroyed.
1358
+ */
1359
+ async archiveRecord(objectSlug, recordId) {
1360
+ const resp = await request(
1361
+ baseUrl,
1362
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1363
+ apiKey,
1364
+ { method: "DELETE" }
1365
+ );
1366
+ return resp.data ?? resp;
1367
+ },
1368
+ /** Restore archived values under current constraints. Conflicts leave the record archived. */
1369
+ async restoreRecord(objectSlug, recordId) {
1370
+ const resp = await request(
1371
+ baseUrl,
1372
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/restore`,
1373
+ apiKey,
1374
+ { method: "POST" }
1375
+ );
1376
+ return resp.data ?? resp;
1377
+ },
1378
+ /**
1379
+ * A record's value timeline, newest first. An entry whose `active_until` is
1380
+ * null is the value currently in force.
1381
+ */
1382
+ async history(objectSlug, recordId, limit) {
1383
+ const resp = await request(
1384
+ baseUrl,
1385
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1386
+ apiKey,
1387
+ { query: limit != null ? { limit } : void 0 }
1388
+ );
1389
+ return resp.data ?? resp;
1390
+ }
1391
+ };
1392
+ };
1393
+
1200
1394
  // src/deals.ts
1201
- var DEFAULT_API18 = "https://be.graph8.com";
1395
+ var DEFAULT_API20 = "https://be.graph8.com";
1202
1396
  var createDealsClient = (apiKey, apiUrl) => {
1203
- const baseUrl = apiUrl || DEFAULT_API18;
1397
+ const baseUrl = apiUrl || DEFAULT_API20;
1204
1398
  return {
1205
1399
  /** List all deal pipelines and their stages. */
1206
1400
  async pipelines() {
@@ -1244,9 +1438,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1244
1438
  };
1245
1439
 
1246
1440
  // src/inbox.ts
1247
- var DEFAULT_API19 = "https://be.graph8.com";
1441
+ var DEFAULT_API21 = "https://be.graph8.com";
1248
1442
  var createInboxClient = (apiKey, apiUrl) => {
1249
- const baseUrl = apiUrl || DEFAULT_API19;
1443
+ const baseUrl = apiUrl || DEFAULT_API21;
1250
1444
  return {
1251
1445
  /** List inbox threads across email, SMS, and LinkedIn. */
1252
1446
  async list(params = {}) {
@@ -1299,9 +1493,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1299
1493
  };
1300
1494
 
1301
1495
  // src/quotes.ts
1302
- var DEFAULT_API20 = "https://be.graph8.com";
1496
+ var DEFAULT_API22 = "https://be.graph8.com";
1303
1497
  var createQuotesClient = (apiKey, apiUrl) => {
1304
- const baseUrl = apiUrl || DEFAULT_API20;
1498
+ const baseUrl = apiUrl || DEFAULT_API22;
1305
1499
  return {
1306
1500
  /** List quotes org-wide with optional filters and pagination. */
1307
1501
  async list(params = {}) {
@@ -1373,9 +1567,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1373
1567
  };
1374
1568
 
1375
1569
  // src/pipelines.ts
1376
- var DEFAULT_API21 = "https://be.graph8.com";
1570
+ var DEFAULT_API23 = "https://be.graph8.com";
1377
1571
  var createPipelinesClient = (apiKey, apiUrl) => {
1378
- const baseUrl = apiUrl || DEFAULT_API21;
1572
+ const baseUrl = apiUrl || DEFAULT_API23;
1379
1573
  return {
1380
1574
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1381
1575
  async list() {
@@ -1457,9 +1651,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1457
1651
  };
1458
1652
 
1459
1653
  // src/workflows.ts
1460
- var DEFAULT_API22 = "https://be.graph8.com";
1654
+ var DEFAULT_API24 = "https://be.graph8.com";
1461
1655
  var createWorkflowsClient = (apiKey, apiUrl) => {
1462
- const baseUrl = apiUrl || DEFAULT_API22;
1656
+ const baseUrl = apiUrl || DEFAULT_API24;
1463
1657
  return {
1464
1658
  /** List workflows org-wide. */
1465
1659
  async list(params = {}) {
@@ -1575,9 +1769,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1575
1769
  };
1576
1770
 
1577
1771
  // src/skills.ts
1578
- var DEFAULT_API23 = "https://be.graph8.com";
1772
+ var DEFAULT_API25 = "https://be.graph8.com";
1579
1773
  var createSkillsClient = (apiKey, apiUrl) => {
1580
- const baseUrl = apiUrl || DEFAULT_API23;
1774
+ const baseUrl = apiUrl || DEFAULT_API25;
1581
1775
  return {
1582
1776
  /** List skills. */
1583
1777
  async list(params = {}) {
@@ -1664,9 +1858,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1664
1858
  };
1665
1859
 
1666
1860
  // src/intent.ts
1667
- var DEFAULT_API24 = "https://be.graph8.com";
1861
+ var DEFAULT_API26 = "https://be.graph8.com";
1668
1862
  var createIntentClient = (apiKey, apiUrl) => {
1669
- const baseUrl = apiUrl || DEFAULT_API24;
1863
+ const baseUrl = apiUrl || DEFAULT_API26;
1670
1864
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1671
1865
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1672
1866
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1741,9 +1935,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1741
1935
  };
1742
1936
 
1743
1937
  // src/studio.ts
1744
- var DEFAULT_API25 = "https://be.graph8.com";
1938
+ var DEFAULT_API27 = "https://be.graph8.com";
1745
1939
  var createStudioClient = (apiKey, apiUrl) => {
1746
- const baseUrl = apiUrl || DEFAULT_API25;
1940
+ const baseUrl = apiUrl || DEFAULT_API27;
1747
1941
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1748
1942
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1749
1943
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1798,9 +1992,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1798
1992
  };
1799
1993
 
1800
1994
  // src/meetings.ts
1801
- var DEFAULT_API26 = "https://be.graph8.com";
1995
+ var DEFAULT_API28 = "https://be.graph8.com";
1802
1996
  var createMeetingsClient = (apiKey, apiUrl) => {
1803
- const baseUrl = apiUrl || DEFAULT_API26;
1997
+ const baseUrl = apiUrl || DEFAULT_API28;
1804
1998
  return {
1805
1999
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1806
2000
  async list(params = {}) {
@@ -1815,9 +2009,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1815
2009
  };
1816
2010
 
1817
2011
  // src/audiences.ts
1818
- var DEFAULT_API27 = "https://be.graph8.com";
2012
+ var DEFAULT_API29 = "https://be.graph8.com";
1819
2013
  var createAudiencesClient = (apiKey, apiUrl) => {
1820
- const baseUrl = apiUrl || DEFAULT_API27;
2014
+ const baseUrl = apiUrl || DEFAULT_API29;
1821
2015
  const base = "/api/v1/audience-syncs";
1822
2016
  return {
1823
2017
  /** List all audience syncs for the organization. */
@@ -1865,9 +2059,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1865
2059
  };
1866
2060
 
1867
2061
  // src/search.ts
1868
- var DEFAULT_API28 = "https://be.graph8.com";
2062
+ var DEFAULT_API30 = "https://be.graph8.com";
1869
2063
  var createSearchClient = (apiKey, apiUrl) => {
1870
- const baseUrl = apiUrl || DEFAULT_API28;
2064
+ const baseUrl = apiUrl || DEFAULT_API30;
1871
2065
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1872
2066
  return {
1873
2067
  /** Search open-data contacts by filter. */
@@ -1898,9 +2092,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1898
2092
  };
1899
2093
 
1900
2094
  // src/agency.ts
1901
- var DEFAULT_API29 = "https://be.graph8.com";
2095
+ var DEFAULT_API31 = "https://be.graph8.com";
1902
2096
  var createAgencyClient = (apiKey, apiUrl) => {
1903
- const baseUrl = apiUrl || DEFAULT_API29;
2097
+ const baseUrl = apiUrl || DEFAULT_API31;
1904
2098
  return {
1905
2099
  /** Describe the agency credential: agency org + authorized client count. */
1906
2100
  async me() {
@@ -1915,9 +2109,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1915
2109
  };
1916
2110
 
1917
2111
  // src/marketplace.ts
1918
- var DEFAULT_API30 = "https://be.graph8.com";
2112
+ var DEFAULT_API32 = "https://be.graph8.com";
1919
2113
  var createMarketplaceClient = (apiKey, apiUrl) => {
1920
- const baseUrl = apiUrl || DEFAULT_API30;
2114
+ const baseUrl = apiUrl || DEFAULT_API32;
1921
2115
  const base = "/api/v1/marketplace";
1922
2116
  return {
1923
2117
  /** Your own marketplace SDR profile. */
@@ -1967,9 +2161,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1967
2161
  };
1968
2162
 
1969
2163
  // src/snippet.ts
1970
- var DEFAULT_API31 = "https://be.graph8.com";
2164
+ var DEFAULT_API33 = "https://be.graph8.com";
1971
2165
  var createSnippetClient = (apiKey, apiUrl) => {
1972
- const baseUrl = apiUrl || DEFAULT_API31;
2166
+ const baseUrl = apiUrl || DEFAULT_API33;
1973
2167
  return {
1974
2168
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1975
2169
  async get() {
@@ -1981,7 +2175,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1981
2175
 
1982
2176
  // src/core.ts
1983
2177
  var DEFAULT_HOST = "https://t.graph8.com";
1984
- var DEFAULT_API32 = "https://be.graph8.com";
2178
+ var DEFAULT_API34 = "https://be.graph8.com";
1985
2179
  var G8 = class {
1986
2180
  constructor() {
1987
2181
  /** @internal */
@@ -2023,6 +2217,10 @@ var G8 = class {
2023
2217
  /** @internal */
2024
2218
  this._fields = null;
2025
2219
  /** @internal */
2220
+ this._apps = null;
2221
+ /** @internal */
2222
+ this._objects = null;
2223
+ /** @internal */
2026
2224
  this._deals = null;
2027
2225
  /** @internal */
2028
2226
  this._inbox = null;
@@ -2064,7 +2262,7 @@ var G8 = class {
2064
2262
  debug: config.debug
2065
2263
  });
2066
2264
  }
2067
- const apiUrl = config.apiUrl || DEFAULT_API32;
2265
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2068
2266
  const writeKey = config.writeKey || "";
2069
2267
  const apiKey = config.apiKey || "";
2070
2268
  if (writeKey) {
@@ -2087,6 +2285,8 @@ var G8 = class {
2087
2285
  this._notes = createNotesClient(apiKey, apiUrl);
2088
2286
  this._tasks = createTasksClient(apiKey, apiUrl);
2089
2287
  this._fields = createFieldsClient(apiKey, apiUrl);
2288
+ this._apps = createAppsClient(apiKey, apiUrl);
2289
+ this._objects = createObjectsClient(apiKey, apiUrl);
2090
2290
  this._deals = createDealsClient(apiKey, apiUrl);
2091
2291
  this._inbox = createInboxClient(apiKey, apiUrl);
2092
2292
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2207,6 +2407,16 @@ var G8 = class {
2207
2407
  this._assertKey("fields");
2208
2408
  return this._fields;
2209
2409
  }
2410
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2411
+ get apps() {
2412
+ this._assertKey("apps");
2413
+ return this._apps;
2414
+ }
2415
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2416
+ get objects() {
2417
+ this._assertKey("objects");
2418
+ return this._objects;
2419
+ }
2210
2420
  /** Deals and pipelines (requires API key). */
2211
2421
  get deals() {
2212
2422
  this._assertKey("deals");