@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/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,112 @@ 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) {
1347
+ const resp = await request(
1348
+ baseUrl,
1349
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1350
+ apiKey,
1351
+ { method: "PATCH", body: { values } }
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
+ /**
1369
+ * A record's value timeline, newest first. An entry whose `active_until` is
1370
+ * null is the value currently in force.
1371
+ */
1372
+ async history(objectSlug, recordId, limit) {
1373
+ const resp = await request(
1374
+ baseUrl,
1375
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1376
+ apiKey,
1377
+ { query: limit != null ? { limit } : void 0 }
1378
+ );
1379
+ return resp.data ?? resp;
1380
+ }
1381
+ };
1382
+ };
1383
+
1200
1384
  // src/deals.ts
1201
- var DEFAULT_API18 = "https://be.graph8.com";
1385
+ var DEFAULT_API20 = "https://be.graph8.com";
1202
1386
  var createDealsClient = (apiKey, apiUrl) => {
1203
- const baseUrl = apiUrl || DEFAULT_API18;
1387
+ const baseUrl = apiUrl || DEFAULT_API20;
1204
1388
  return {
1205
1389
  /** List all deal pipelines and their stages. */
1206
1390
  async pipelines() {
@@ -1244,9 +1428,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1244
1428
  };
1245
1429
 
1246
1430
  // src/inbox.ts
1247
- var DEFAULT_API19 = "https://be.graph8.com";
1431
+ var DEFAULT_API21 = "https://be.graph8.com";
1248
1432
  var createInboxClient = (apiKey, apiUrl) => {
1249
- const baseUrl = apiUrl || DEFAULT_API19;
1433
+ const baseUrl = apiUrl || DEFAULT_API21;
1250
1434
  return {
1251
1435
  /** List inbox threads across email, SMS, and LinkedIn. */
1252
1436
  async list(params = {}) {
@@ -1299,9 +1483,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1299
1483
  };
1300
1484
 
1301
1485
  // src/quotes.ts
1302
- var DEFAULT_API20 = "https://be.graph8.com";
1486
+ var DEFAULT_API22 = "https://be.graph8.com";
1303
1487
  var createQuotesClient = (apiKey, apiUrl) => {
1304
- const baseUrl = apiUrl || DEFAULT_API20;
1488
+ const baseUrl = apiUrl || DEFAULT_API22;
1305
1489
  return {
1306
1490
  /** List quotes org-wide with optional filters and pagination. */
1307
1491
  async list(params = {}) {
@@ -1373,9 +1557,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1373
1557
  };
1374
1558
 
1375
1559
  // src/pipelines.ts
1376
- var DEFAULT_API21 = "https://be.graph8.com";
1560
+ var DEFAULT_API23 = "https://be.graph8.com";
1377
1561
  var createPipelinesClient = (apiKey, apiUrl) => {
1378
- const baseUrl = apiUrl || DEFAULT_API21;
1562
+ const baseUrl = apiUrl || DEFAULT_API23;
1379
1563
  return {
1380
1564
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1381
1565
  async list() {
@@ -1457,9 +1641,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1457
1641
  };
1458
1642
 
1459
1643
  // src/workflows.ts
1460
- var DEFAULT_API22 = "https://be.graph8.com";
1644
+ var DEFAULT_API24 = "https://be.graph8.com";
1461
1645
  var createWorkflowsClient = (apiKey, apiUrl) => {
1462
- const baseUrl = apiUrl || DEFAULT_API22;
1646
+ const baseUrl = apiUrl || DEFAULT_API24;
1463
1647
  return {
1464
1648
  /** List workflows org-wide. */
1465
1649
  async list(params = {}) {
@@ -1575,9 +1759,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1575
1759
  };
1576
1760
 
1577
1761
  // src/skills.ts
1578
- var DEFAULT_API23 = "https://be.graph8.com";
1762
+ var DEFAULT_API25 = "https://be.graph8.com";
1579
1763
  var createSkillsClient = (apiKey, apiUrl) => {
1580
- const baseUrl = apiUrl || DEFAULT_API23;
1764
+ const baseUrl = apiUrl || DEFAULT_API25;
1581
1765
  return {
1582
1766
  /** List skills. */
1583
1767
  async list(params = {}) {
@@ -1664,9 +1848,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1664
1848
  };
1665
1849
 
1666
1850
  // src/intent.ts
1667
- var DEFAULT_API24 = "https://be.graph8.com";
1851
+ var DEFAULT_API26 = "https://be.graph8.com";
1668
1852
  var createIntentClient = (apiKey, apiUrl) => {
1669
- const baseUrl = apiUrl || DEFAULT_API24;
1853
+ const baseUrl = apiUrl || DEFAULT_API26;
1670
1854
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1671
1855
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1672
1856
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1741,9 +1925,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1741
1925
  };
1742
1926
 
1743
1927
  // src/studio.ts
1744
- var DEFAULT_API25 = "https://be.graph8.com";
1928
+ var DEFAULT_API27 = "https://be.graph8.com";
1745
1929
  var createStudioClient = (apiKey, apiUrl) => {
1746
- const baseUrl = apiUrl || DEFAULT_API25;
1930
+ const baseUrl = apiUrl || DEFAULT_API27;
1747
1931
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1748
1932
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1749
1933
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1798,9 +1982,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1798
1982
  };
1799
1983
 
1800
1984
  // src/meetings.ts
1801
- var DEFAULT_API26 = "https://be.graph8.com";
1985
+ var DEFAULT_API28 = "https://be.graph8.com";
1802
1986
  var createMeetingsClient = (apiKey, apiUrl) => {
1803
- const baseUrl = apiUrl || DEFAULT_API26;
1987
+ const baseUrl = apiUrl || DEFAULT_API28;
1804
1988
  return {
1805
1989
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1806
1990
  async list(params = {}) {
@@ -1815,9 +1999,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1815
1999
  };
1816
2000
 
1817
2001
  // src/audiences.ts
1818
- var DEFAULT_API27 = "https://be.graph8.com";
2002
+ var DEFAULT_API29 = "https://be.graph8.com";
1819
2003
  var createAudiencesClient = (apiKey, apiUrl) => {
1820
- const baseUrl = apiUrl || DEFAULT_API27;
2004
+ const baseUrl = apiUrl || DEFAULT_API29;
1821
2005
  const base = "/api/v1/audience-syncs";
1822
2006
  return {
1823
2007
  /** List all audience syncs for the organization. */
@@ -1865,9 +2049,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1865
2049
  };
1866
2050
 
1867
2051
  // src/search.ts
1868
- var DEFAULT_API28 = "https://be.graph8.com";
2052
+ var DEFAULT_API30 = "https://be.graph8.com";
1869
2053
  var createSearchClient = (apiKey, apiUrl) => {
1870
- const baseUrl = apiUrl || DEFAULT_API28;
2054
+ const baseUrl = apiUrl || DEFAULT_API30;
1871
2055
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1872
2056
  return {
1873
2057
  /** Search open-data contacts by filter. */
@@ -1898,9 +2082,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1898
2082
  };
1899
2083
 
1900
2084
  // src/agency.ts
1901
- var DEFAULT_API29 = "https://be.graph8.com";
2085
+ var DEFAULT_API31 = "https://be.graph8.com";
1902
2086
  var createAgencyClient = (apiKey, apiUrl) => {
1903
- const baseUrl = apiUrl || DEFAULT_API29;
2087
+ const baseUrl = apiUrl || DEFAULT_API31;
1904
2088
  return {
1905
2089
  /** Describe the agency credential: agency org + authorized client count. */
1906
2090
  async me() {
@@ -1915,9 +2099,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1915
2099
  };
1916
2100
 
1917
2101
  // src/marketplace.ts
1918
- var DEFAULT_API30 = "https://be.graph8.com";
2102
+ var DEFAULT_API32 = "https://be.graph8.com";
1919
2103
  var createMarketplaceClient = (apiKey, apiUrl) => {
1920
- const baseUrl = apiUrl || DEFAULT_API30;
2104
+ const baseUrl = apiUrl || DEFAULT_API32;
1921
2105
  const base = "/api/v1/marketplace";
1922
2106
  return {
1923
2107
  /** Your own marketplace SDR profile. */
@@ -1967,9 +2151,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1967
2151
  };
1968
2152
 
1969
2153
  // src/snippet.ts
1970
- var DEFAULT_API31 = "https://be.graph8.com";
2154
+ var DEFAULT_API33 = "https://be.graph8.com";
1971
2155
  var createSnippetClient = (apiKey, apiUrl) => {
1972
- const baseUrl = apiUrl || DEFAULT_API31;
2156
+ const baseUrl = apiUrl || DEFAULT_API33;
1973
2157
  return {
1974
2158
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1975
2159
  async get() {
@@ -1981,7 +2165,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1981
2165
 
1982
2166
  // src/core.ts
1983
2167
  var DEFAULT_HOST = "https://t.graph8.com";
1984
- var DEFAULT_API32 = "https://be.graph8.com";
2168
+ var DEFAULT_API34 = "https://be.graph8.com";
1985
2169
  var G8 = class {
1986
2170
  constructor() {
1987
2171
  /** @internal */
@@ -2023,6 +2207,10 @@ var G8 = class {
2023
2207
  /** @internal */
2024
2208
  this._fields = null;
2025
2209
  /** @internal */
2210
+ this._apps = null;
2211
+ /** @internal */
2212
+ this._objects = null;
2213
+ /** @internal */
2026
2214
  this._deals = null;
2027
2215
  /** @internal */
2028
2216
  this._inbox = null;
@@ -2064,7 +2252,7 @@ var G8 = class {
2064
2252
  debug: config.debug
2065
2253
  });
2066
2254
  }
2067
- const apiUrl = config.apiUrl || DEFAULT_API32;
2255
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2068
2256
  const writeKey = config.writeKey || "";
2069
2257
  const apiKey = config.apiKey || "";
2070
2258
  if (writeKey) {
@@ -2087,6 +2275,8 @@ var G8 = class {
2087
2275
  this._notes = createNotesClient(apiKey, apiUrl);
2088
2276
  this._tasks = createTasksClient(apiKey, apiUrl);
2089
2277
  this._fields = createFieldsClient(apiKey, apiUrl);
2278
+ this._apps = createAppsClient(apiKey, apiUrl);
2279
+ this._objects = createObjectsClient(apiKey, apiUrl);
2090
2280
  this._deals = createDealsClient(apiKey, apiUrl);
2091
2281
  this._inbox = createInboxClient(apiKey, apiUrl);
2092
2282
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2207,6 +2397,16 @@ var G8 = class {
2207
2397
  this._assertKey("fields");
2208
2398
  return this._fields;
2209
2399
  }
2400
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2401
+ get apps() {
2402
+ this._assertKey("apps");
2403
+ return this._apps;
2404
+ }
2405
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2406
+ get objects() {
2407
+ this._assertKey("objects");
2408
+ return this._objects;
2409
+ }
2210
2410
  /** Deals and pipelines (requires API key). */
2211
2411
  get deals() {
2212
2412
  this._assertKey("deals");