@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.mjs CHANGED
@@ -1129,10 +1129,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1129
1129
  };
1130
1130
  };
1131
1131
 
1132
- // src/fields.ts
1132
+ // src/apps.ts
1133
1133
  var DEFAULT_API17 = "https://be.graph8.com";
1134
- var createFieldsClient = (apiKey, apiUrl) => {
1134
+ var createAppsClient = (apiKey, apiUrl) => {
1135
1135
  const baseUrl = apiUrl || DEFAULT_API17;
1136
+ return {
1137
+ /** List your organization's apps, newest first. */
1138
+ async list() {
1139
+ return request(baseUrl, "/api/v1/apps", apiKey);
1140
+ },
1141
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1142
+ async get(appId) {
1143
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1144
+ return resp.data ?? resp;
1145
+ },
1146
+ /**
1147
+ * Create an app. It starts in `draft` and serves no traffic until published.
1148
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1149
+ */
1150
+ async create(params) {
1151
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1152
+ method: "POST",
1153
+ body: {
1154
+ name: params.name,
1155
+ slug: params.slug,
1156
+ registered_origins: params.registered_origins ?? []
1157
+ }
1158
+ });
1159
+ return resp.data ?? resp;
1160
+ },
1161
+ /**
1162
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1163
+ *
1164
+ * `suspended` is excluded from the parameter type on purpose: it is the
1165
+ * platform's kill switch for an abusive app, the backend refuses it with a
1166
+ * 403, and a builder who could set it could also unset it.
1167
+ */
1168
+ async setStatus(appId, status) {
1169
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1170
+ method: "POST",
1171
+ body: { status }
1172
+ });
1173
+ return resp.data ?? resp;
1174
+ },
1175
+ /**
1176
+ * The client organizations that installed this app, and their consent state.
1177
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1178
+ * tenant, this is where you see why.
1179
+ */
1180
+ async listInstalls(appId) {
1181
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1182
+ },
1183
+ /**
1184
+ * Credits this app consumed in a calendar month, broken down per client org.
1185
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1186
+ * 404 — "nothing happened" is an answer.
1187
+ */
1188
+ async usage(appId, period) {
1189
+ const resp = await request(
1190
+ baseUrl,
1191
+ `/api/v1/apps/${appId}/usage`,
1192
+ apiKey,
1193
+ { query: period ? { period } : void 0 }
1194
+ );
1195
+ return resp.data ?? resp;
1196
+ },
1197
+ /**
1198
+ * This app's hard credit cap, or `null` when it is uncapped.
1199
+ *
1200
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1201
+ * sentinel, so an accidental zero can never read as "no limit".
1202
+ */
1203
+ async getLimit(appId) {
1204
+ const resp = await request(
1205
+ baseUrl,
1206
+ `/api/v1/apps/${appId}/limit`,
1207
+ apiKey
1208
+ );
1209
+ return resp.data ?? null;
1210
+ }
1211
+ };
1212
+ };
1213
+
1214
+ // src/fields.ts
1215
+ var DEFAULT_API18 = "https://be.graph8.com";
1216
+ var createFieldsClient = (apiKey, apiUrl) => {
1217
+ const baseUrl = apiUrl || DEFAULT_API18;
1136
1218
  return {
1137
1219
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1138
1220
  async listContactFields(listId) {
@@ -1173,10 +1255,122 @@ var createFieldsClient = (apiKey, apiUrl) => {
1173
1255
  };
1174
1256
  };
1175
1257
 
1258
+ // src/objects.ts
1259
+ var DEFAULT_API19 = "https://be.graph8.com";
1260
+ var createObjectsClient = (apiKey, apiUrl) => {
1261
+ const baseUrl = apiUrl || DEFAULT_API19;
1262
+ const encode = (value) => encodeURIComponent(value);
1263
+ return {
1264
+ /** List the custom object types in your workspace. */
1265
+ async list() {
1266
+ return request(baseUrl, "/api/v1/objects", apiKey);
1267
+ },
1268
+ /** Fetch one object type by slug. */
1269
+ async get(objectSlug) {
1270
+ const resp = await request(
1271
+ baseUrl,
1272
+ `/api/v1/objects/${encode(objectSlug)}`,
1273
+ apiKey
1274
+ );
1275
+ return resp.data ?? resp;
1276
+ },
1277
+ /** The object's attributes — the schema its records must satisfy. */
1278
+ async listAttributes(objectSlug) {
1279
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1280
+ },
1281
+ /** Paginated records with their current values. Archived records are excluded. */
1282
+ async listRecords(objectSlug, params = {}) {
1283
+ const query = {};
1284
+ if (params.page != null) query.page = params.page;
1285
+ if (params.limit != null) query.limit = params.limit;
1286
+ if (params.cursor != null) query.cursor = params.cursor;
1287
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1288
+ query: Object.keys(query).length ? query : void 0
1289
+ });
1290
+ },
1291
+ /**
1292
+ * Create a record. Every field is validated against the object's attributes;
1293
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1294
+ * unique attribute is a 409.
1295
+ */
1296
+ async createRecord(objectSlug, values) {
1297
+ const resp = await request(
1298
+ baseUrl,
1299
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1300
+ apiKey,
1301
+ { method: "POST", body: { values } }
1302
+ );
1303
+ return resp.data ?? resp;
1304
+ },
1305
+ /** Fetch one record with its currently active values. */
1306
+ async getRecord(objectSlug, recordId) {
1307
+ const resp = await request(
1308
+ baseUrl,
1309
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1310
+ apiKey
1311
+ );
1312
+ return resp.data ?? resp;
1313
+ },
1314
+ /**
1315
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1316
+ * required attributes you omit are left alone rather than reported missing.
1317
+ * Sending an explicit `null` CLEARS that attribute.
1318
+ *
1319
+ * Values are versioned rather than overwritten, so the previous value stays
1320
+ * readable through `history`.
1321
+ */
1322
+ async updateRecord(objectSlug, recordId, values, options) {
1323
+ const resp = await request(
1324
+ baseUrl,
1325
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1326
+ apiKey,
1327
+ { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
1328
+ );
1329
+ return resp.data ?? resp;
1330
+ },
1331
+ /**
1332
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1333
+ * history and associations. Nothing is destroyed.
1334
+ */
1335
+ async archiveRecord(objectSlug, recordId) {
1336
+ const resp = await request(
1337
+ baseUrl,
1338
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1339
+ apiKey,
1340
+ { method: "DELETE" }
1341
+ );
1342
+ return resp.data ?? resp;
1343
+ },
1344
+ /** Restore archived values under current constraints. Conflicts leave the record archived. */
1345
+ async restoreRecord(objectSlug, recordId) {
1346
+ const resp = await request(
1347
+ baseUrl,
1348
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/restore`,
1349
+ apiKey,
1350
+ { method: "POST" }
1351
+ );
1352
+ return resp.data ?? resp;
1353
+ },
1354
+ /**
1355
+ * A record's value timeline, newest first. An entry whose `active_until` is
1356
+ * null is the value currently in force.
1357
+ */
1358
+ async history(objectSlug, recordId, limit) {
1359
+ const resp = await request(
1360
+ baseUrl,
1361
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1362
+ apiKey,
1363
+ { query: limit != null ? { limit } : void 0 }
1364
+ );
1365
+ return resp.data ?? resp;
1366
+ }
1367
+ };
1368
+ };
1369
+
1176
1370
  // src/deals.ts
1177
- var DEFAULT_API18 = "https://be.graph8.com";
1371
+ var DEFAULT_API20 = "https://be.graph8.com";
1178
1372
  var createDealsClient = (apiKey, apiUrl) => {
1179
- const baseUrl = apiUrl || DEFAULT_API18;
1373
+ const baseUrl = apiUrl || DEFAULT_API20;
1180
1374
  return {
1181
1375
  /** List all deal pipelines and their stages. */
1182
1376
  async pipelines() {
@@ -1220,9 +1414,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1220
1414
  };
1221
1415
 
1222
1416
  // src/inbox.ts
1223
- var DEFAULT_API19 = "https://be.graph8.com";
1417
+ var DEFAULT_API21 = "https://be.graph8.com";
1224
1418
  var createInboxClient = (apiKey, apiUrl) => {
1225
- const baseUrl = apiUrl || DEFAULT_API19;
1419
+ const baseUrl = apiUrl || DEFAULT_API21;
1226
1420
  return {
1227
1421
  /** List inbox threads across email, SMS, and LinkedIn. */
1228
1422
  async list(params = {}) {
@@ -1275,9 +1469,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1275
1469
  };
1276
1470
 
1277
1471
  // src/quotes.ts
1278
- var DEFAULT_API20 = "https://be.graph8.com";
1472
+ var DEFAULT_API22 = "https://be.graph8.com";
1279
1473
  var createQuotesClient = (apiKey, apiUrl) => {
1280
- const baseUrl = apiUrl || DEFAULT_API20;
1474
+ const baseUrl = apiUrl || DEFAULT_API22;
1281
1475
  return {
1282
1476
  /** List quotes org-wide with optional filters and pagination. */
1283
1477
  async list(params = {}) {
@@ -1349,9 +1543,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1349
1543
  };
1350
1544
 
1351
1545
  // src/pipelines.ts
1352
- var DEFAULT_API21 = "https://be.graph8.com";
1546
+ var DEFAULT_API23 = "https://be.graph8.com";
1353
1547
  var createPipelinesClient = (apiKey, apiUrl) => {
1354
- const baseUrl = apiUrl || DEFAULT_API21;
1548
+ const baseUrl = apiUrl || DEFAULT_API23;
1355
1549
  return {
1356
1550
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1357
1551
  async list() {
@@ -1433,9 +1627,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1433
1627
  };
1434
1628
 
1435
1629
  // src/workflows.ts
1436
- var DEFAULT_API22 = "https://be.graph8.com";
1630
+ var DEFAULT_API24 = "https://be.graph8.com";
1437
1631
  var createWorkflowsClient = (apiKey, apiUrl) => {
1438
- const baseUrl = apiUrl || DEFAULT_API22;
1632
+ const baseUrl = apiUrl || DEFAULT_API24;
1439
1633
  return {
1440
1634
  /** List workflows org-wide. */
1441
1635
  async list(params = {}) {
@@ -1551,9 +1745,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1551
1745
  };
1552
1746
 
1553
1747
  // src/skills.ts
1554
- var DEFAULT_API23 = "https://be.graph8.com";
1748
+ var DEFAULT_API25 = "https://be.graph8.com";
1555
1749
  var createSkillsClient = (apiKey, apiUrl) => {
1556
- const baseUrl = apiUrl || DEFAULT_API23;
1750
+ const baseUrl = apiUrl || DEFAULT_API25;
1557
1751
  return {
1558
1752
  /** List skills. */
1559
1753
  async list(params = {}) {
@@ -1640,9 +1834,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1640
1834
  };
1641
1835
 
1642
1836
  // src/intent.ts
1643
- var DEFAULT_API24 = "https://be.graph8.com";
1837
+ var DEFAULT_API26 = "https://be.graph8.com";
1644
1838
  var createIntentClient = (apiKey, apiUrl) => {
1645
- const baseUrl = apiUrl || DEFAULT_API24;
1839
+ const baseUrl = apiUrl || DEFAULT_API26;
1646
1840
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1647
1841
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1648
1842
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1717,9 +1911,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1717
1911
  };
1718
1912
 
1719
1913
  // src/studio.ts
1720
- var DEFAULT_API25 = "https://be.graph8.com";
1914
+ var DEFAULT_API27 = "https://be.graph8.com";
1721
1915
  var createStudioClient = (apiKey, apiUrl) => {
1722
- const baseUrl = apiUrl || DEFAULT_API25;
1916
+ const baseUrl = apiUrl || DEFAULT_API27;
1723
1917
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1724
1918
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1725
1919
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1774,9 +1968,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1774
1968
  };
1775
1969
 
1776
1970
  // src/meetings.ts
1777
- var DEFAULT_API26 = "https://be.graph8.com";
1971
+ var DEFAULT_API28 = "https://be.graph8.com";
1778
1972
  var createMeetingsClient = (apiKey, apiUrl) => {
1779
- const baseUrl = apiUrl || DEFAULT_API26;
1973
+ const baseUrl = apiUrl || DEFAULT_API28;
1780
1974
  return {
1781
1975
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1782
1976
  async list(params = {}) {
@@ -1791,9 +1985,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1791
1985
  };
1792
1986
 
1793
1987
  // src/audiences.ts
1794
- var DEFAULT_API27 = "https://be.graph8.com";
1988
+ var DEFAULT_API29 = "https://be.graph8.com";
1795
1989
  var createAudiencesClient = (apiKey, apiUrl) => {
1796
- const baseUrl = apiUrl || DEFAULT_API27;
1990
+ const baseUrl = apiUrl || DEFAULT_API29;
1797
1991
  const base = "/api/v1/audience-syncs";
1798
1992
  return {
1799
1993
  /** List all audience syncs for the organization. */
@@ -1841,9 +2035,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1841
2035
  };
1842
2036
 
1843
2037
  // src/search.ts
1844
- var DEFAULT_API28 = "https://be.graph8.com";
2038
+ var DEFAULT_API30 = "https://be.graph8.com";
1845
2039
  var createSearchClient = (apiKey, apiUrl) => {
1846
- const baseUrl = apiUrl || DEFAULT_API28;
2040
+ const baseUrl = apiUrl || DEFAULT_API30;
1847
2041
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1848
2042
  return {
1849
2043
  /** Search open-data contacts by filter. */
@@ -1874,9 +2068,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1874
2068
  };
1875
2069
 
1876
2070
  // src/agency.ts
1877
- var DEFAULT_API29 = "https://be.graph8.com";
2071
+ var DEFAULT_API31 = "https://be.graph8.com";
1878
2072
  var createAgencyClient = (apiKey, apiUrl) => {
1879
- const baseUrl = apiUrl || DEFAULT_API29;
2073
+ const baseUrl = apiUrl || DEFAULT_API31;
1880
2074
  return {
1881
2075
  /** Describe the agency credential: agency org + authorized client count. */
1882
2076
  async me() {
@@ -1891,9 +2085,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1891
2085
  };
1892
2086
 
1893
2087
  // src/marketplace.ts
1894
- var DEFAULT_API30 = "https://be.graph8.com";
2088
+ var DEFAULT_API32 = "https://be.graph8.com";
1895
2089
  var createMarketplaceClient = (apiKey, apiUrl) => {
1896
- const baseUrl = apiUrl || DEFAULT_API30;
2090
+ const baseUrl = apiUrl || DEFAULT_API32;
1897
2091
  const base = "/api/v1/marketplace";
1898
2092
  return {
1899
2093
  /** Your own marketplace SDR profile. */
@@ -1943,9 +2137,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1943
2137
  };
1944
2138
 
1945
2139
  // src/snippet.ts
1946
- var DEFAULT_API31 = "https://be.graph8.com";
2140
+ var DEFAULT_API33 = "https://be.graph8.com";
1947
2141
  var createSnippetClient = (apiKey, apiUrl) => {
1948
- const baseUrl = apiUrl || DEFAULT_API31;
2142
+ const baseUrl = apiUrl || DEFAULT_API33;
1949
2143
  return {
1950
2144
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1951
2145
  async get() {
@@ -1957,7 +2151,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1957
2151
 
1958
2152
  // src/core.ts
1959
2153
  var DEFAULT_HOST = "https://t.graph8.com";
1960
- var DEFAULT_API32 = "https://be.graph8.com";
2154
+ var DEFAULT_API34 = "https://be.graph8.com";
1961
2155
  var G8 = class {
1962
2156
  constructor() {
1963
2157
  /** @internal */
@@ -1999,6 +2193,10 @@ var G8 = class {
1999
2193
  /** @internal */
2000
2194
  this._fields = null;
2001
2195
  /** @internal */
2196
+ this._apps = null;
2197
+ /** @internal */
2198
+ this._objects = null;
2199
+ /** @internal */
2002
2200
  this._deals = null;
2003
2201
  /** @internal */
2004
2202
  this._inbox = null;
@@ -2040,7 +2238,7 @@ var G8 = class {
2040
2238
  debug: config.debug
2041
2239
  });
2042
2240
  }
2043
- const apiUrl = config.apiUrl || DEFAULT_API32;
2241
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2044
2242
  const writeKey = config.writeKey || "";
2045
2243
  const apiKey = config.apiKey || "";
2046
2244
  if (writeKey) {
@@ -2063,6 +2261,8 @@ var G8 = class {
2063
2261
  this._notes = createNotesClient(apiKey, apiUrl);
2064
2262
  this._tasks = createTasksClient(apiKey, apiUrl);
2065
2263
  this._fields = createFieldsClient(apiKey, apiUrl);
2264
+ this._apps = createAppsClient(apiKey, apiUrl);
2265
+ this._objects = createObjectsClient(apiKey, apiUrl);
2066
2266
  this._deals = createDealsClient(apiKey, apiUrl);
2067
2267
  this._inbox = createInboxClient(apiKey, apiUrl);
2068
2268
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2183,6 +2383,16 @@ var G8 = class {
2183
2383
  this._assertKey("fields");
2184
2384
  return this._fields;
2185
2385
  }
2386
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2387
+ get apps() {
2388
+ this._assertKey("apps");
2389
+ return this._apps;
2390
+ }
2391
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2392
+ get objects() {
2393
+ this._assertKey("objects");
2394
+ return this._objects;
2395
+ }
2186
2396
  /** Deals and pipelines (requires API key). */
2187
2397
  get deals() {
2188
2398
  this._assertKey("deals");