@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.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,112 @@ 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) {
1323
+ const resp = await request(
1324
+ baseUrl,
1325
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1326
+ apiKey,
1327
+ { method: "PATCH", body: { values } }
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
+ /**
1345
+ * A record's value timeline, newest first. An entry whose `active_until` is
1346
+ * null is the value currently in force.
1347
+ */
1348
+ async history(objectSlug, recordId, limit) {
1349
+ const resp = await request(
1350
+ baseUrl,
1351
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1352
+ apiKey,
1353
+ { query: limit != null ? { limit } : void 0 }
1354
+ );
1355
+ return resp.data ?? resp;
1356
+ }
1357
+ };
1358
+ };
1359
+
1176
1360
  // src/deals.ts
1177
- var DEFAULT_API18 = "https://be.graph8.com";
1361
+ var DEFAULT_API20 = "https://be.graph8.com";
1178
1362
  var createDealsClient = (apiKey, apiUrl) => {
1179
- const baseUrl = apiUrl || DEFAULT_API18;
1363
+ const baseUrl = apiUrl || DEFAULT_API20;
1180
1364
  return {
1181
1365
  /** List all deal pipelines and their stages. */
1182
1366
  async pipelines() {
@@ -1220,9 +1404,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1220
1404
  };
1221
1405
 
1222
1406
  // src/inbox.ts
1223
- var DEFAULT_API19 = "https://be.graph8.com";
1407
+ var DEFAULT_API21 = "https://be.graph8.com";
1224
1408
  var createInboxClient = (apiKey, apiUrl) => {
1225
- const baseUrl = apiUrl || DEFAULT_API19;
1409
+ const baseUrl = apiUrl || DEFAULT_API21;
1226
1410
  return {
1227
1411
  /** List inbox threads across email, SMS, and LinkedIn. */
1228
1412
  async list(params = {}) {
@@ -1275,9 +1459,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1275
1459
  };
1276
1460
 
1277
1461
  // src/quotes.ts
1278
- var DEFAULT_API20 = "https://be.graph8.com";
1462
+ var DEFAULT_API22 = "https://be.graph8.com";
1279
1463
  var createQuotesClient = (apiKey, apiUrl) => {
1280
- const baseUrl = apiUrl || DEFAULT_API20;
1464
+ const baseUrl = apiUrl || DEFAULT_API22;
1281
1465
  return {
1282
1466
  /** List quotes org-wide with optional filters and pagination. */
1283
1467
  async list(params = {}) {
@@ -1349,9 +1533,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1349
1533
  };
1350
1534
 
1351
1535
  // src/pipelines.ts
1352
- var DEFAULT_API21 = "https://be.graph8.com";
1536
+ var DEFAULT_API23 = "https://be.graph8.com";
1353
1537
  var createPipelinesClient = (apiKey, apiUrl) => {
1354
- const baseUrl = apiUrl || DEFAULT_API21;
1538
+ const baseUrl = apiUrl || DEFAULT_API23;
1355
1539
  return {
1356
1540
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1357
1541
  async list() {
@@ -1433,9 +1617,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1433
1617
  };
1434
1618
 
1435
1619
  // src/workflows.ts
1436
- var DEFAULT_API22 = "https://be.graph8.com";
1620
+ var DEFAULT_API24 = "https://be.graph8.com";
1437
1621
  var createWorkflowsClient = (apiKey, apiUrl) => {
1438
- const baseUrl = apiUrl || DEFAULT_API22;
1622
+ const baseUrl = apiUrl || DEFAULT_API24;
1439
1623
  return {
1440
1624
  /** List workflows org-wide. */
1441
1625
  async list(params = {}) {
@@ -1551,9 +1735,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1551
1735
  };
1552
1736
 
1553
1737
  // src/skills.ts
1554
- var DEFAULT_API23 = "https://be.graph8.com";
1738
+ var DEFAULT_API25 = "https://be.graph8.com";
1555
1739
  var createSkillsClient = (apiKey, apiUrl) => {
1556
- const baseUrl = apiUrl || DEFAULT_API23;
1740
+ const baseUrl = apiUrl || DEFAULT_API25;
1557
1741
  return {
1558
1742
  /** List skills. */
1559
1743
  async list(params = {}) {
@@ -1640,9 +1824,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1640
1824
  };
1641
1825
 
1642
1826
  // src/intent.ts
1643
- var DEFAULT_API24 = "https://be.graph8.com";
1827
+ var DEFAULT_API26 = "https://be.graph8.com";
1644
1828
  var createIntentClient = (apiKey, apiUrl) => {
1645
- const baseUrl = apiUrl || DEFAULT_API24;
1829
+ const baseUrl = apiUrl || DEFAULT_API26;
1646
1830
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1647
1831
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1648
1832
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1717,9 +1901,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1717
1901
  };
1718
1902
 
1719
1903
  // src/studio.ts
1720
- var DEFAULT_API25 = "https://be.graph8.com";
1904
+ var DEFAULT_API27 = "https://be.graph8.com";
1721
1905
  var createStudioClient = (apiKey, apiUrl) => {
1722
- const baseUrl = apiUrl || DEFAULT_API25;
1906
+ const baseUrl = apiUrl || DEFAULT_API27;
1723
1907
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1724
1908
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1725
1909
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1774,9 +1958,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1774
1958
  };
1775
1959
 
1776
1960
  // src/meetings.ts
1777
- var DEFAULT_API26 = "https://be.graph8.com";
1961
+ var DEFAULT_API28 = "https://be.graph8.com";
1778
1962
  var createMeetingsClient = (apiKey, apiUrl) => {
1779
- const baseUrl = apiUrl || DEFAULT_API26;
1963
+ const baseUrl = apiUrl || DEFAULT_API28;
1780
1964
  return {
1781
1965
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1782
1966
  async list(params = {}) {
@@ -1791,9 +1975,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1791
1975
  };
1792
1976
 
1793
1977
  // src/audiences.ts
1794
- var DEFAULT_API27 = "https://be.graph8.com";
1978
+ var DEFAULT_API29 = "https://be.graph8.com";
1795
1979
  var createAudiencesClient = (apiKey, apiUrl) => {
1796
- const baseUrl = apiUrl || DEFAULT_API27;
1980
+ const baseUrl = apiUrl || DEFAULT_API29;
1797
1981
  const base = "/api/v1/audience-syncs";
1798
1982
  return {
1799
1983
  /** List all audience syncs for the organization. */
@@ -1841,9 +2025,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1841
2025
  };
1842
2026
 
1843
2027
  // src/search.ts
1844
- var DEFAULT_API28 = "https://be.graph8.com";
2028
+ var DEFAULT_API30 = "https://be.graph8.com";
1845
2029
  var createSearchClient = (apiKey, apiUrl) => {
1846
- const baseUrl = apiUrl || DEFAULT_API28;
2030
+ const baseUrl = apiUrl || DEFAULT_API30;
1847
2031
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1848
2032
  return {
1849
2033
  /** Search open-data contacts by filter. */
@@ -1874,9 +2058,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1874
2058
  };
1875
2059
 
1876
2060
  // src/agency.ts
1877
- var DEFAULT_API29 = "https://be.graph8.com";
2061
+ var DEFAULT_API31 = "https://be.graph8.com";
1878
2062
  var createAgencyClient = (apiKey, apiUrl) => {
1879
- const baseUrl = apiUrl || DEFAULT_API29;
2063
+ const baseUrl = apiUrl || DEFAULT_API31;
1880
2064
  return {
1881
2065
  /** Describe the agency credential: agency org + authorized client count. */
1882
2066
  async me() {
@@ -1891,9 +2075,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1891
2075
  };
1892
2076
 
1893
2077
  // src/marketplace.ts
1894
- var DEFAULT_API30 = "https://be.graph8.com";
2078
+ var DEFAULT_API32 = "https://be.graph8.com";
1895
2079
  var createMarketplaceClient = (apiKey, apiUrl) => {
1896
- const baseUrl = apiUrl || DEFAULT_API30;
2080
+ const baseUrl = apiUrl || DEFAULT_API32;
1897
2081
  const base = "/api/v1/marketplace";
1898
2082
  return {
1899
2083
  /** Your own marketplace SDR profile. */
@@ -1943,9 +2127,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1943
2127
  };
1944
2128
 
1945
2129
  // src/snippet.ts
1946
- var DEFAULT_API31 = "https://be.graph8.com";
2130
+ var DEFAULT_API33 = "https://be.graph8.com";
1947
2131
  var createSnippetClient = (apiKey, apiUrl) => {
1948
- const baseUrl = apiUrl || DEFAULT_API31;
2132
+ const baseUrl = apiUrl || DEFAULT_API33;
1949
2133
  return {
1950
2134
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1951
2135
  async get() {
@@ -1957,7 +2141,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1957
2141
 
1958
2142
  // src/core.ts
1959
2143
  var DEFAULT_HOST = "https://t.graph8.com";
1960
- var DEFAULT_API32 = "https://be.graph8.com";
2144
+ var DEFAULT_API34 = "https://be.graph8.com";
1961
2145
  var G8 = class {
1962
2146
  constructor() {
1963
2147
  /** @internal */
@@ -1999,6 +2183,10 @@ var G8 = class {
1999
2183
  /** @internal */
2000
2184
  this._fields = null;
2001
2185
  /** @internal */
2186
+ this._apps = null;
2187
+ /** @internal */
2188
+ this._objects = null;
2189
+ /** @internal */
2002
2190
  this._deals = null;
2003
2191
  /** @internal */
2004
2192
  this._inbox = null;
@@ -2040,7 +2228,7 @@ var G8 = class {
2040
2228
  debug: config.debug
2041
2229
  });
2042
2230
  }
2043
- const apiUrl = config.apiUrl || DEFAULT_API32;
2231
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2044
2232
  const writeKey = config.writeKey || "";
2045
2233
  const apiKey = config.apiKey || "";
2046
2234
  if (writeKey) {
@@ -2063,6 +2251,8 @@ var G8 = class {
2063
2251
  this._notes = createNotesClient(apiKey, apiUrl);
2064
2252
  this._tasks = createTasksClient(apiKey, apiUrl);
2065
2253
  this._fields = createFieldsClient(apiKey, apiUrl);
2254
+ this._apps = createAppsClient(apiKey, apiUrl);
2255
+ this._objects = createObjectsClient(apiKey, apiUrl);
2066
2256
  this._deals = createDealsClient(apiKey, apiUrl);
2067
2257
  this._inbox = createInboxClient(apiKey, apiUrl);
2068
2258
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2183,6 +2373,16 @@ var G8 = class {
2183
2373
  this._assertKey("fields");
2184
2374
  return this._fields;
2185
2375
  }
2376
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2377
+ get apps() {
2378
+ this._assertKey("apps");
2379
+ return this._apps;
2380
+ }
2381
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2382
+ get objects() {
2383
+ this._assertKey("objects");
2384
+ return this._objects;
2385
+ }
2186
2386
  /** Deals and pipelines (requires API key). */
2187
2387
  get deals() {
2188
2388
  this._assertKey("deals");