@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/index.mjs CHANGED
@@ -1134,10 +1134,92 @@ var createTasksClient = (apiKey, apiUrl) => {
1134
1134
  };
1135
1135
  };
1136
1136
 
1137
- // src/fields.ts
1137
+ // src/apps.ts
1138
1138
  var DEFAULT_API17 = "https://be.graph8.com";
1139
- var createFieldsClient = (apiKey, apiUrl) => {
1139
+ var createAppsClient = (apiKey, apiUrl) => {
1140
1140
  const baseUrl = apiUrl || DEFAULT_API17;
1141
+ return {
1142
+ /** List your organization's apps, newest first. */
1143
+ async list() {
1144
+ return request(baseUrl, "/api/v1/apps", apiKey);
1145
+ },
1146
+ /** Fetch one of your apps. Throws `G8Error` (404) if it is not yours. */
1147
+ async get(appId) {
1148
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}`, apiKey);
1149
+ return resp.data ?? resp;
1150
+ },
1151
+ /**
1152
+ * Create an app. It starts in `draft` and serves no traffic until published.
1153
+ * Throws `G8Error` (409) when the slug is already taken in your org.
1154
+ */
1155
+ async create(params) {
1156
+ const resp = await request(baseUrl, "/api/v1/apps", apiKey, {
1157
+ method: "POST",
1158
+ body: {
1159
+ name: params.name,
1160
+ slug: params.slug,
1161
+ registered_origins: params.registered_origins ?? []
1162
+ }
1163
+ });
1164
+ return resp.data ?? resp;
1165
+ },
1166
+ /**
1167
+ * Move an app through its lifecycle: `draft` → `published` → `archived`.
1168
+ *
1169
+ * `suspended` is excluded from the parameter type on purpose: it is the
1170
+ * platform's kill switch for an abusive app, the backend refuses it with a
1171
+ * 403, and a builder who could set it could also unset it.
1172
+ */
1173
+ async setStatus(appId, status) {
1174
+ const resp = await request(baseUrl, `/api/v1/apps/${appId}/status`, apiKey, {
1175
+ method: "POST",
1176
+ body: { status }
1177
+ });
1178
+ return resp.data ?? resp;
1179
+ },
1180
+ /**
1181
+ * The client organizations that installed this app, and their consent state.
1182
+ * Includes `pending` and `revoked` installs — if your app cannot reach a
1183
+ * tenant, this is where you see why.
1184
+ */
1185
+ async listInstalls(appId) {
1186
+ return request(baseUrl, `/api/v1/apps/${appId}/installs`, apiKey);
1187
+ },
1188
+ /**
1189
+ * Credits this app consumed in a calendar month, broken down per client org.
1190
+ * Defaults to the current month. A month with no usage returns zeroes, not a
1191
+ * 404 — "nothing happened" is an answer.
1192
+ */
1193
+ async usage(appId, period) {
1194
+ const resp = await request(
1195
+ baseUrl,
1196
+ `/api/v1/apps/${appId}/usage`,
1197
+ apiKey,
1198
+ { query: period ? { period } : void 0 }
1199
+ );
1200
+ return resp.data ?? resp;
1201
+ },
1202
+ /**
1203
+ * This app's hard credit cap, or `null` when it is uncapped.
1204
+ *
1205
+ * `null` is the real answer, not an empty object: there is no "unlimited"
1206
+ * sentinel, so an accidental zero can never read as "no limit".
1207
+ */
1208
+ async getLimit(appId) {
1209
+ const resp = await request(
1210
+ baseUrl,
1211
+ `/api/v1/apps/${appId}/limit`,
1212
+ apiKey
1213
+ );
1214
+ return resp.data ?? null;
1215
+ }
1216
+ };
1217
+ };
1218
+
1219
+ // src/fields.ts
1220
+ var DEFAULT_API18 = "https://be.graph8.com";
1221
+ var createFieldsClient = (apiKey, apiUrl) => {
1222
+ const baseUrl = apiUrl || DEFAULT_API18;
1141
1223
  return {
1142
1224
  /** List contact fields (base + custom). Pass listId to include list-specific custom fields. */
1143
1225
  async listContactFields(listId) {
@@ -1178,10 +1260,122 @@ var createFieldsClient = (apiKey, apiUrl) => {
1178
1260
  };
1179
1261
  };
1180
1262
 
1263
+ // src/objects.ts
1264
+ var DEFAULT_API19 = "https://be.graph8.com";
1265
+ var createObjectsClient = (apiKey, apiUrl) => {
1266
+ const baseUrl = apiUrl || DEFAULT_API19;
1267
+ const encode = (value) => encodeURIComponent(value);
1268
+ return {
1269
+ /** List the custom object types in your workspace. */
1270
+ async list() {
1271
+ return request(baseUrl, "/api/v1/objects", apiKey);
1272
+ },
1273
+ /** Fetch one object type by slug. */
1274
+ async get(objectSlug) {
1275
+ const resp = await request(
1276
+ baseUrl,
1277
+ `/api/v1/objects/${encode(objectSlug)}`,
1278
+ apiKey
1279
+ );
1280
+ return resp.data ?? resp;
1281
+ },
1282
+ /** The object's attributes — the schema its records must satisfy. */
1283
+ async listAttributes(objectSlug) {
1284
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/attributes`, apiKey);
1285
+ },
1286
+ /** Paginated records with their current values. Archived records are excluded. */
1287
+ async listRecords(objectSlug, params = {}) {
1288
+ const query = {};
1289
+ if (params.page != null) query.page = params.page;
1290
+ if (params.limit != null) query.limit = params.limit;
1291
+ if (params.cursor != null) query.cursor = params.cursor;
1292
+ return request(baseUrl, `/api/v1/objects/${encode(objectSlug)}/records`, apiKey, {
1293
+ query: Object.keys(query).length ? query : void 0
1294
+ });
1295
+ },
1296
+ /**
1297
+ * Create a record. Every field is validated against the object's attributes;
1298
+ * an unknown one is a 422 listing every problem at once, and a collision on a
1299
+ * unique attribute is a 409.
1300
+ */
1301
+ async createRecord(objectSlug, values) {
1302
+ const resp = await request(
1303
+ baseUrl,
1304
+ `/api/v1/objects/${encode(objectSlug)}/records`,
1305
+ apiKey,
1306
+ { method: "POST", body: { values } }
1307
+ );
1308
+ return resp.data ?? resp;
1309
+ },
1310
+ /** Fetch one record with its currently active values. */
1311
+ async getRecord(objectSlug, recordId) {
1312
+ const resp = await request(
1313
+ baseUrl,
1314
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1315
+ apiKey
1316
+ );
1317
+ return resp.data ?? resp;
1318
+ },
1319
+ /**
1320
+ * Update a record. PARTIAL: only the attributes you send are touched, so
1321
+ * required attributes you omit are left alone rather than reported missing.
1322
+ * Sending an explicit `null` CLEARS that attribute.
1323
+ *
1324
+ * Values are versioned rather than overwritten, so the previous value stays
1325
+ * readable through `history`.
1326
+ */
1327
+ async updateRecord(objectSlug, recordId, values, options) {
1328
+ const resp = await request(
1329
+ baseUrl,
1330
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1331
+ apiKey,
1332
+ { method: "PATCH", body: { values, ...options?.expectedRevision === void 0 ? {} : { expected_revision: options.expectedRevision } } }
1333
+ );
1334
+ return resp.data ?? resp;
1335
+ },
1336
+ /**
1337
+ * Archive a record. It leaves listings, stays readable by id, and keeps its
1338
+ * history and associations. Nothing is destroyed.
1339
+ */
1340
+ async archiveRecord(objectSlug, recordId) {
1341
+ const resp = await request(
1342
+ baseUrl,
1343
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1344
+ apiKey,
1345
+ { method: "DELETE" }
1346
+ );
1347
+ return resp.data ?? resp;
1348
+ },
1349
+ /** Restore archived values under current constraints. Conflicts leave the record archived. */
1350
+ async restoreRecord(objectSlug, recordId) {
1351
+ const resp = await request(
1352
+ baseUrl,
1353
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/restore`,
1354
+ apiKey,
1355
+ { method: "POST" }
1356
+ );
1357
+ return resp.data ?? resp;
1358
+ },
1359
+ /**
1360
+ * A record's value timeline, newest first. An entry whose `active_until` is
1361
+ * null is the value currently in force.
1362
+ */
1363
+ async history(objectSlug, recordId, limit) {
1364
+ const resp = await request(
1365
+ baseUrl,
1366
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1367
+ apiKey,
1368
+ { query: limit != null ? { limit } : void 0 }
1369
+ );
1370
+ return resp.data ?? resp;
1371
+ }
1372
+ };
1373
+ };
1374
+
1181
1375
  // src/deals.ts
1182
- var DEFAULT_API18 = "https://be.graph8.com";
1376
+ var DEFAULT_API20 = "https://be.graph8.com";
1183
1377
  var createDealsClient = (apiKey, apiUrl) => {
1184
- const baseUrl = apiUrl || DEFAULT_API18;
1378
+ const baseUrl = apiUrl || DEFAULT_API20;
1185
1379
  return {
1186
1380
  /** List all deal pipelines and their stages. */
1187
1381
  async pipelines() {
@@ -1225,9 +1419,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1225
1419
  };
1226
1420
 
1227
1421
  // src/inbox.ts
1228
- var DEFAULT_API19 = "https://be.graph8.com";
1422
+ var DEFAULT_API21 = "https://be.graph8.com";
1229
1423
  var createInboxClient = (apiKey, apiUrl) => {
1230
- const baseUrl = apiUrl || DEFAULT_API19;
1424
+ const baseUrl = apiUrl || DEFAULT_API21;
1231
1425
  return {
1232
1426
  /** List inbox threads across email, SMS, and LinkedIn. */
1233
1427
  async list(params = {}) {
@@ -1280,9 +1474,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1280
1474
  };
1281
1475
 
1282
1476
  // src/quotes.ts
1283
- var DEFAULT_API20 = "https://be.graph8.com";
1477
+ var DEFAULT_API22 = "https://be.graph8.com";
1284
1478
  var createQuotesClient = (apiKey, apiUrl) => {
1285
- const baseUrl = apiUrl || DEFAULT_API20;
1479
+ const baseUrl = apiUrl || DEFAULT_API22;
1286
1480
  return {
1287
1481
  /** List quotes org-wide with optional filters and pagination. */
1288
1482
  async list(params = {}) {
@@ -1354,9 +1548,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1354
1548
  };
1355
1549
 
1356
1550
  // src/pipelines.ts
1357
- var DEFAULT_API21 = "https://be.graph8.com";
1551
+ var DEFAULT_API23 = "https://be.graph8.com";
1358
1552
  var createPipelinesClient = (apiKey, apiUrl) => {
1359
- const baseUrl = apiUrl || DEFAULT_API21;
1553
+ const baseUrl = apiUrl || DEFAULT_API23;
1360
1554
  return {
1361
1555
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1362
1556
  async list() {
@@ -1438,9 +1632,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1438
1632
  };
1439
1633
 
1440
1634
  // src/workflows.ts
1441
- var DEFAULT_API22 = "https://be.graph8.com";
1635
+ var DEFAULT_API24 = "https://be.graph8.com";
1442
1636
  var createWorkflowsClient = (apiKey, apiUrl) => {
1443
- const baseUrl = apiUrl || DEFAULT_API22;
1637
+ const baseUrl = apiUrl || DEFAULT_API24;
1444
1638
  return {
1445
1639
  /** List workflows org-wide. */
1446
1640
  async list(params = {}) {
@@ -1556,9 +1750,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1556
1750
  };
1557
1751
 
1558
1752
  // src/skills.ts
1559
- var DEFAULT_API23 = "https://be.graph8.com";
1753
+ var DEFAULT_API25 = "https://be.graph8.com";
1560
1754
  var createSkillsClient = (apiKey, apiUrl) => {
1561
- const baseUrl = apiUrl || DEFAULT_API23;
1755
+ const baseUrl = apiUrl || DEFAULT_API25;
1562
1756
  return {
1563
1757
  /** List skills. */
1564
1758
  async list(params = {}) {
@@ -1645,9 +1839,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1645
1839
  };
1646
1840
 
1647
1841
  // src/intent.ts
1648
- var DEFAULT_API24 = "https://be.graph8.com";
1842
+ var DEFAULT_API26 = "https://be.graph8.com";
1649
1843
  var createIntentClient = (apiKey, apiUrl) => {
1650
- const baseUrl = apiUrl || DEFAULT_API24;
1844
+ const baseUrl = apiUrl || DEFAULT_API26;
1651
1845
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1652
1846
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1653
1847
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1722,9 +1916,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1722
1916
  };
1723
1917
 
1724
1918
  // src/studio.ts
1725
- var DEFAULT_API25 = "https://be.graph8.com";
1919
+ var DEFAULT_API27 = "https://be.graph8.com";
1726
1920
  var createStudioClient = (apiKey, apiUrl) => {
1727
- const baseUrl = apiUrl || DEFAULT_API25;
1921
+ const baseUrl = apiUrl || DEFAULT_API27;
1728
1922
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1729
1923
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1730
1924
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1779,9 +1973,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1779
1973
  };
1780
1974
 
1781
1975
  // src/meetings.ts
1782
- var DEFAULT_API26 = "https://be.graph8.com";
1976
+ var DEFAULT_API28 = "https://be.graph8.com";
1783
1977
  var createMeetingsClient = (apiKey, apiUrl) => {
1784
- const baseUrl = apiUrl || DEFAULT_API26;
1978
+ const baseUrl = apiUrl || DEFAULT_API28;
1785
1979
  return {
1786
1980
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1787
1981
  async list(params = {}) {
@@ -1796,9 +1990,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1796
1990
  };
1797
1991
 
1798
1992
  // src/audiences.ts
1799
- var DEFAULT_API27 = "https://be.graph8.com";
1993
+ var DEFAULT_API29 = "https://be.graph8.com";
1800
1994
  var createAudiencesClient = (apiKey, apiUrl) => {
1801
- const baseUrl = apiUrl || DEFAULT_API27;
1995
+ const baseUrl = apiUrl || DEFAULT_API29;
1802
1996
  const base = "/api/v1/audience-syncs";
1803
1997
  return {
1804
1998
  /** List all audience syncs for the organization. */
@@ -1846,9 +2040,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1846
2040
  };
1847
2041
 
1848
2042
  // src/search.ts
1849
- var DEFAULT_API28 = "https://be.graph8.com";
2043
+ var DEFAULT_API30 = "https://be.graph8.com";
1850
2044
  var createSearchClient = (apiKey, apiUrl) => {
1851
- const baseUrl = apiUrl || DEFAULT_API28;
2045
+ const baseUrl = apiUrl || DEFAULT_API30;
1852
2046
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1853
2047
  return {
1854
2048
  /** Search open-data contacts by filter. */
@@ -1879,9 +2073,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1879
2073
  };
1880
2074
 
1881
2075
  // src/agency.ts
1882
- var DEFAULT_API29 = "https://be.graph8.com";
2076
+ var DEFAULT_API31 = "https://be.graph8.com";
1883
2077
  var createAgencyClient = (apiKey, apiUrl) => {
1884
- const baseUrl = apiUrl || DEFAULT_API29;
2078
+ const baseUrl = apiUrl || DEFAULT_API31;
1885
2079
  return {
1886
2080
  /** Describe the agency credential: agency org + authorized client count. */
1887
2081
  async me() {
@@ -1896,9 +2090,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1896
2090
  };
1897
2091
 
1898
2092
  // src/marketplace.ts
1899
- var DEFAULT_API30 = "https://be.graph8.com";
2093
+ var DEFAULT_API32 = "https://be.graph8.com";
1900
2094
  var createMarketplaceClient = (apiKey, apiUrl) => {
1901
- const baseUrl = apiUrl || DEFAULT_API30;
2095
+ const baseUrl = apiUrl || DEFAULT_API32;
1902
2096
  const base = "/api/v1/marketplace";
1903
2097
  return {
1904
2098
  /** Your own marketplace SDR profile. */
@@ -1948,9 +2142,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1948
2142
  };
1949
2143
 
1950
2144
  // src/snippet.ts
1951
- var DEFAULT_API31 = "https://be.graph8.com";
2145
+ var DEFAULT_API33 = "https://be.graph8.com";
1952
2146
  var createSnippetClient = (apiKey, apiUrl) => {
1953
- const baseUrl = apiUrl || DEFAULT_API31;
2147
+ const baseUrl = apiUrl || DEFAULT_API33;
1954
2148
  return {
1955
2149
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1956
2150
  async get() {
@@ -1962,7 +2156,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1962
2156
 
1963
2157
  // src/core.ts
1964
2158
  var DEFAULT_HOST = "https://t.graph8.com";
1965
- var DEFAULT_API32 = "https://be.graph8.com";
2159
+ var DEFAULT_API34 = "https://be.graph8.com";
1966
2160
  var G8 = class {
1967
2161
  constructor() {
1968
2162
  /** @internal */
@@ -2004,6 +2198,10 @@ var G8 = class {
2004
2198
  /** @internal */
2005
2199
  this._fields = null;
2006
2200
  /** @internal */
2201
+ this._apps = null;
2202
+ /** @internal */
2203
+ this._objects = null;
2204
+ /** @internal */
2007
2205
  this._deals = null;
2008
2206
  /** @internal */
2009
2207
  this._inbox = null;
@@ -2045,7 +2243,7 @@ var G8 = class {
2045
2243
  debug: config.debug
2046
2244
  });
2047
2245
  }
2048
- const apiUrl = config.apiUrl || DEFAULT_API32;
2246
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2049
2247
  const writeKey = config.writeKey || "";
2050
2248
  const apiKey = config.apiKey || "";
2051
2249
  if (writeKey) {
@@ -2068,6 +2266,8 @@ var G8 = class {
2068
2266
  this._notes = createNotesClient(apiKey, apiUrl);
2069
2267
  this._tasks = createTasksClient(apiKey, apiUrl);
2070
2268
  this._fields = createFieldsClient(apiKey, apiUrl);
2269
+ this._apps = createAppsClient(apiKey, apiUrl);
2270
+ this._objects = createObjectsClient(apiKey, apiUrl);
2071
2271
  this._deals = createDealsClient(apiKey, apiUrl);
2072
2272
  this._inbox = createInboxClient(apiKey, apiUrl);
2073
2273
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2188,6 +2388,16 @@ var G8 = class {
2188
2388
  this._assertKey("fields");
2189
2389
  return this._fields;
2190
2390
  }
2391
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2392
+ get apps() {
2393
+ this._assertKey("apps");
2394
+ return this._apps;
2395
+ }
2396
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2397
+ get objects() {
2398
+ this._assertKey("objects");
2399
+ return this._objects;
2400
+ }
2191
2401
  /** Deals and pipelines (requires API key). */
2192
2402
  get deals() {
2193
2403
  this._assertKey("deals");