@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/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,112 @@ 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) {
1328
+ const resp = await request(
1329
+ baseUrl,
1330
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}`,
1331
+ apiKey,
1332
+ { method: "PATCH", body: { values } }
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
+ /**
1350
+ * A record's value timeline, newest first. An entry whose `active_until` is
1351
+ * null is the value currently in force.
1352
+ */
1353
+ async history(objectSlug, recordId, limit) {
1354
+ const resp = await request(
1355
+ baseUrl,
1356
+ `/api/v1/objects/${encode(objectSlug)}/records/${encode(recordId)}/history`,
1357
+ apiKey,
1358
+ { query: limit != null ? { limit } : void 0 }
1359
+ );
1360
+ return resp.data ?? resp;
1361
+ }
1362
+ };
1363
+ };
1364
+
1181
1365
  // src/deals.ts
1182
- var DEFAULT_API18 = "https://be.graph8.com";
1366
+ var DEFAULT_API20 = "https://be.graph8.com";
1183
1367
  var createDealsClient = (apiKey, apiUrl) => {
1184
- const baseUrl = apiUrl || DEFAULT_API18;
1368
+ const baseUrl = apiUrl || DEFAULT_API20;
1185
1369
  return {
1186
1370
  /** List all deal pipelines and their stages. */
1187
1371
  async pipelines() {
@@ -1225,9 +1409,9 @@ var createDealsClient = (apiKey, apiUrl) => {
1225
1409
  };
1226
1410
 
1227
1411
  // src/inbox.ts
1228
- var DEFAULT_API19 = "https://be.graph8.com";
1412
+ var DEFAULT_API21 = "https://be.graph8.com";
1229
1413
  var createInboxClient = (apiKey, apiUrl) => {
1230
- const baseUrl = apiUrl || DEFAULT_API19;
1414
+ const baseUrl = apiUrl || DEFAULT_API21;
1231
1415
  return {
1232
1416
  /** List inbox threads across email, SMS, and LinkedIn. */
1233
1417
  async list(params = {}) {
@@ -1280,9 +1464,9 @@ var createInboxClient = (apiKey, apiUrl) => {
1280
1464
  };
1281
1465
 
1282
1466
  // src/quotes.ts
1283
- var DEFAULT_API20 = "https://be.graph8.com";
1467
+ var DEFAULT_API22 = "https://be.graph8.com";
1284
1468
  var createQuotesClient = (apiKey, apiUrl) => {
1285
- const baseUrl = apiUrl || DEFAULT_API20;
1469
+ const baseUrl = apiUrl || DEFAULT_API22;
1286
1470
  return {
1287
1471
  /** List quotes org-wide with optional filters and pagination. */
1288
1472
  async list(params = {}) {
@@ -1354,9 +1538,9 @@ var createQuotesClient = (apiKey, apiUrl) => {
1354
1538
  };
1355
1539
 
1356
1540
  // src/pipelines.ts
1357
- var DEFAULT_API21 = "https://be.graph8.com";
1541
+ var DEFAULT_API23 = "https://be.graph8.com";
1358
1542
  var createPipelinesClient = (apiKey, apiUrl) => {
1359
- const baseUrl = apiUrl || DEFAULT_API21;
1543
+ const baseUrl = apiUrl || DEFAULT_API23;
1360
1544
  return {
1361
1545
  /** List all stage-checklist pipelines with stages, evidence, scripts. */
1362
1546
  async list() {
@@ -1438,9 +1622,9 @@ var createPipelinesClient = (apiKey, apiUrl) => {
1438
1622
  };
1439
1623
 
1440
1624
  // src/workflows.ts
1441
- var DEFAULT_API22 = "https://be.graph8.com";
1625
+ var DEFAULT_API24 = "https://be.graph8.com";
1442
1626
  var createWorkflowsClient = (apiKey, apiUrl) => {
1443
- const baseUrl = apiUrl || DEFAULT_API22;
1627
+ const baseUrl = apiUrl || DEFAULT_API24;
1444
1628
  return {
1445
1629
  /** List workflows org-wide. */
1446
1630
  async list(params = {}) {
@@ -1556,9 +1740,9 @@ var createWorkflowsClient = (apiKey, apiUrl) => {
1556
1740
  };
1557
1741
 
1558
1742
  // src/skills.ts
1559
- var DEFAULT_API23 = "https://be.graph8.com";
1743
+ var DEFAULT_API25 = "https://be.graph8.com";
1560
1744
  var createSkillsClient = (apiKey, apiUrl) => {
1561
- const baseUrl = apiUrl || DEFAULT_API23;
1745
+ const baseUrl = apiUrl || DEFAULT_API25;
1562
1746
  return {
1563
1747
  /** List skills. */
1564
1748
  async list(params = {}) {
@@ -1645,9 +1829,9 @@ var createSkillsClient = (apiKey, apiUrl) => {
1645
1829
  };
1646
1830
 
1647
1831
  // src/intent.ts
1648
- var DEFAULT_API24 = "https://be.graph8.com";
1832
+ var DEFAULT_API26 = "https://be.graph8.com";
1649
1833
  var createIntentClient = (apiKey, apiUrl) => {
1650
- const baseUrl = apiUrl || DEFAULT_API24;
1834
+ const baseUrl = apiUrl || DEFAULT_API26;
1651
1835
  const get = (path) => request(baseUrl, `/api/v1${path}`, apiKey);
1652
1836
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1653
1837
  const del = (path) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "DELETE" });
@@ -1722,9 +1906,9 @@ var createIntentClient = (apiKey, apiUrl) => {
1722
1906
  };
1723
1907
 
1724
1908
  // src/studio.ts
1725
- var DEFAULT_API25 = "https://be.graph8.com";
1909
+ var DEFAULT_API27 = "https://be.graph8.com";
1726
1910
  var createStudioClient = (apiKey, apiUrl) => {
1727
- const baseUrl = apiUrl || DEFAULT_API25;
1911
+ const baseUrl = apiUrl || DEFAULT_API27;
1728
1912
  const get = (path, params = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { query: params });
1729
1913
  const post = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "POST", body });
1730
1914
  const patch = (path, body = {}) => request(baseUrl, `/api/v1${path}`, apiKey, { method: "PATCH", body });
@@ -1779,9 +1963,9 @@ var createStudioClient = (apiKey, apiUrl) => {
1779
1963
  };
1780
1964
 
1781
1965
  // src/meetings.ts
1782
- var DEFAULT_API26 = "https://be.graph8.com";
1966
+ var DEFAULT_API28 = "https://be.graph8.com";
1783
1967
  var createMeetingsClient = (apiKey, apiUrl) => {
1784
- const baseUrl = apiUrl || DEFAULT_API26;
1968
+ const baseUrl = apiUrl || DEFAULT_API28;
1785
1969
  return {
1786
1970
  /** List meetings with optional filters. Returns summary rows without transcript / analysis. */
1787
1971
  async list(params = {}) {
@@ -1796,9 +1980,9 @@ var createMeetingsClient = (apiKey, apiUrl) => {
1796
1980
  };
1797
1981
 
1798
1982
  // src/audiences.ts
1799
- var DEFAULT_API27 = "https://be.graph8.com";
1983
+ var DEFAULT_API29 = "https://be.graph8.com";
1800
1984
  var createAudiencesClient = (apiKey, apiUrl) => {
1801
- const baseUrl = apiUrl || DEFAULT_API27;
1985
+ const baseUrl = apiUrl || DEFAULT_API29;
1802
1986
  const base = "/api/v1/audience-syncs";
1803
1987
  return {
1804
1988
  /** List all audience syncs for the organization. */
@@ -1846,9 +2030,9 @@ var createAudiencesClient = (apiKey, apiUrl) => {
1846
2030
  };
1847
2031
 
1848
2032
  // src/search.ts
1849
- var DEFAULT_API28 = "https://be.graph8.com";
2033
+ var DEFAULT_API30 = "https://be.graph8.com";
1850
2034
  var createSearchClient = (apiKey, apiUrl) => {
1851
- const baseUrl = apiUrl || DEFAULT_API28;
2035
+ const baseUrl = apiUrl || DEFAULT_API30;
1852
2036
  const body = (p) => ({ filters: [], page: 1, limit: 25, ...p });
1853
2037
  return {
1854
2038
  /** Search open-data contacts by filter. */
@@ -1879,9 +2063,9 @@ var createSearchClient = (apiKey, apiUrl) => {
1879
2063
  };
1880
2064
 
1881
2065
  // src/agency.ts
1882
- var DEFAULT_API29 = "https://be.graph8.com";
2066
+ var DEFAULT_API31 = "https://be.graph8.com";
1883
2067
  var createAgencyClient = (apiKey, apiUrl) => {
1884
- const baseUrl = apiUrl || DEFAULT_API29;
2068
+ const baseUrl = apiUrl || DEFAULT_API31;
1885
2069
  return {
1886
2070
  /** Describe the agency credential: agency org + authorized client count. */
1887
2071
  async me() {
@@ -1896,9 +2080,9 @@ var createAgencyClient = (apiKey, apiUrl) => {
1896
2080
  };
1897
2081
 
1898
2082
  // src/marketplace.ts
1899
- var DEFAULT_API30 = "https://be.graph8.com";
2083
+ var DEFAULT_API32 = "https://be.graph8.com";
1900
2084
  var createMarketplaceClient = (apiKey, apiUrl) => {
1901
- const baseUrl = apiUrl || DEFAULT_API30;
2085
+ const baseUrl = apiUrl || DEFAULT_API32;
1902
2086
  const base = "/api/v1/marketplace";
1903
2087
  return {
1904
2088
  /** Your own marketplace SDR profile. */
@@ -1948,9 +2132,9 @@ var createMarketplaceClient = (apiKey, apiUrl) => {
1948
2132
  };
1949
2133
 
1950
2134
  // src/snippet.ts
1951
- var DEFAULT_API31 = "https://be.graph8.com";
2135
+ var DEFAULT_API33 = "https://be.graph8.com";
1952
2136
  var createSnippetClient = (apiKey, apiUrl) => {
1953
- const baseUrl = apiUrl || DEFAULT_API31;
2137
+ const baseUrl = apiUrl || DEFAULT_API33;
1954
2138
  return {
1955
2139
  /** Get your org's tracking snippet (write key + React/script-tag embeds + config). */
1956
2140
  async get() {
@@ -1962,7 +2146,7 @@ var createSnippetClient = (apiKey, apiUrl) => {
1962
2146
 
1963
2147
  // src/core.ts
1964
2148
  var DEFAULT_HOST = "https://t.graph8.com";
1965
- var DEFAULT_API32 = "https://be.graph8.com";
2149
+ var DEFAULT_API34 = "https://be.graph8.com";
1966
2150
  var G8 = class {
1967
2151
  constructor() {
1968
2152
  /** @internal */
@@ -2004,6 +2188,10 @@ var G8 = class {
2004
2188
  /** @internal */
2005
2189
  this._fields = null;
2006
2190
  /** @internal */
2191
+ this._apps = null;
2192
+ /** @internal */
2193
+ this._objects = null;
2194
+ /** @internal */
2007
2195
  this._deals = null;
2008
2196
  /** @internal */
2009
2197
  this._inbox = null;
@@ -2045,7 +2233,7 @@ var G8 = class {
2045
2233
  debug: config.debug
2046
2234
  });
2047
2235
  }
2048
- const apiUrl = config.apiUrl || DEFAULT_API32;
2236
+ const apiUrl = config.apiUrl || DEFAULT_API34;
2049
2237
  const writeKey = config.writeKey || "";
2050
2238
  const apiKey = config.apiKey || "";
2051
2239
  if (writeKey) {
@@ -2068,6 +2256,8 @@ var G8 = class {
2068
2256
  this._notes = createNotesClient(apiKey, apiUrl);
2069
2257
  this._tasks = createTasksClient(apiKey, apiUrl);
2070
2258
  this._fields = createFieldsClient(apiKey, apiUrl);
2259
+ this._apps = createAppsClient(apiKey, apiUrl);
2260
+ this._objects = createObjectsClient(apiKey, apiUrl);
2071
2261
  this._deals = createDealsClient(apiKey, apiUrl);
2072
2262
  this._inbox = createInboxClient(apiKey, apiUrl);
2073
2263
  this._quotes = createQuotesClient(apiKey, apiUrl);
@@ -2188,6 +2378,16 @@ var G8 = class {
2188
2378
  this._assertKey("fields");
2189
2379
  return this._fields;
2190
2380
  }
2381
+ /** Apps you build on graph8 — lifecycle, installs, usage, limits (requires API key). PREVIEW. */
2382
+ get apps() {
2383
+ this._assertKey("apps");
2384
+ return this._apps;
2385
+ }
2386
+ /** Custom object types, their schema, and their records (requires API key). PREVIEW. */
2387
+ get objects() {
2388
+ this._assertKey("objects");
2389
+ return this._objects;
2390
+ }
2191
2391
  /** Deals and pipelines (requires API key). */
2192
2392
  get deals() {
2193
2393
  this._assertKey("deals");