@getsupervisor/agents-studio-sdk 1.40.0 → 1.41.0-patch.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.js CHANGED
@@ -460,6 +460,56 @@ function attachPaginator(response, fetchPage, options) {
460
460
  });
461
461
  }
462
462
 
463
+ // src/api/agent-schedule.ts
464
+ function createAgentScheduleApi(cfg) {
465
+ const { base, doFetch } = createHttp(cfg);
466
+ const jsonHeaders = { "content-type": "application/json" };
467
+ const fetchSchedulesPage = async (agentId, options = {}) => {
468
+ const query = serializeListOptions({ ...options ?? {} });
469
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
470
+ method: "GET",
471
+ query
472
+ });
473
+ return res.json();
474
+ };
475
+ return {
476
+ async list(agentId, options = {}) {
477
+ const normalized = { ...options ?? {} };
478
+ const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
479
+ const response = await fetchPage(normalized);
480
+ return attachPaginator(response, fetchPage, normalized);
481
+ },
482
+ async get(agentId, scheduleId) {
483
+ const res = await doFetch(
484
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
485
+ {
486
+ method: "GET"
487
+ }
488
+ );
489
+ return res.json();
490
+ },
491
+ async create(agentId, payload) {
492
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
493
+ method: "POST",
494
+ headers: jsonHeaders,
495
+ body: JSON.stringify(payload)
496
+ });
497
+ return res.json();
498
+ },
499
+ async update(agentId, scheduleId, payload) {
500
+ const res = await doFetch(
501
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
502
+ {
503
+ method: "PUT",
504
+ headers: jsonHeaders,
505
+ body: JSON.stringify(payload)
506
+ }
507
+ );
508
+ return res.json();
509
+ }
510
+ };
511
+ }
512
+
463
513
  // src/api/agent-schedule-exceptions.ts
464
514
  function createAgentScheduleExceptionsApi(cfg) {
465
515
  const { base, doFetch } = createHttp(cfg);
@@ -526,56 +576,6 @@ function createAgentScheduleExceptionsApi(cfg) {
526
576
  };
527
577
  }
528
578
 
529
- // src/api/agent-schedule.ts
530
- function createAgentScheduleApi(cfg) {
531
- const { base, doFetch } = createHttp(cfg);
532
- const jsonHeaders = { "content-type": "application/json" };
533
- const fetchSchedulesPage = async (agentId, options = {}) => {
534
- const query = serializeListOptions({ ...options ?? {} });
535
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
536
- method: "GET",
537
- query
538
- });
539
- return res.json();
540
- };
541
- return {
542
- async list(agentId, options = {}) {
543
- const normalized = { ...options ?? {} };
544
- const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
545
- const response = await fetchPage(normalized);
546
- return attachPaginator(response, fetchPage, normalized);
547
- },
548
- async get(agentId, scheduleId) {
549
- const res = await doFetch(
550
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
551
- {
552
- method: "GET"
553
- }
554
- );
555
- return res.json();
556
- },
557
- async create(agentId, payload) {
558
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
559
- method: "POST",
560
- headers: jsonHeaders,
561
- body: JSON.stringify(payload)
562
- });
563
- return res.json();
564
- },
565
- async update(agentId, scheduleId, payload) {
566
- const res = await doFetch(
567
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
568
- {
569
- method: "PUT",
570
- headers: jsonHeaders,
571
- body: JSON.stringify(payload)
572
- }
573
- );
574
- return res.json();
575
- }
576
- };
577
- }
578
-
579
579
  // src/api/agent-stage-triggers.ts
580
580
  function createAgentStageTriggersApi(cfg) {
581
581
  const { base, doFetch } = createHttp(cfg);
@@ -1244,6 +1244,82 @@ function createApiKeysApi(cfg) {
1244
1244
  };
1245
1245
  }
1246
1246
 
1247
+ // src/api/campaigns.ts
1248
+ function createCampaignsApi(cfg) {
1249
+ const { base, doFetch } = createHttp(cfg);
1250
+ const isFormData2 = (value) => {
1251
+ return typeof FormData !== "undefined" && value instanceof FormData;
1252
+ };
1253
+ const fetchCampaignsPage = async (options = {}) => {
1254
+ const query = serializeListOptions(options ?? {});
1255
+ const res = await doFetch(`${base}/campaigns`, {
1256
+ method: "GET",
1257
+ query
1258
+ });
1259
+ return res.json();
1260
+ };
1261
+ const fetchExecutionsPage = async (campaignId, options = {}) => {
1262
+ const query = serializeListOptions({
1263
+ page: options.page,
1264
+ limit: options.limit
1265
+ });
1266
+ const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
1267
+ method: "GET",
1268
+ query
1269
+ });
1270
+ return res.json();
1271
+ };
1272
+ const buildMultipart = (payload) => {
1273
+ if (isFormData2(payload)) {
1274
+ return payload;
1275
+ }
1276
+ if (typeof FormData === "undefined") {
1277
+ throw new TypeError(
1278
+ "FormData is not available in this environment. Pass a FormData instance instead."
1279
+ );
1280
+ }
1281
+ const form = new FormData();
1282
+ form.append("name", payload.name);
1283
+ if (payload.objective !== void 0 && payload.objective !== null) {
1284
+ form.append("objective", payload.objective);
1285
+ }
1286
+ form.append("file", payload.file);
1287
+ return form;
1288
+ };
1289
+ return {
1290
+ async list(options = {}) {
1291
+ const normalizedOptions = { ...options ?? {} };
1292
+ const response = await fetchCampaignsPage(normalizedOptions);
1293
+ return attachPaginator(response, fetchCampaignsPage, normalizedOptions);
1294
+ },
1295
+ async get(campaignId) {
1296
+ const res = await doFetch(`${base}/campaigns/${campaignId}`, {
1297
+ method: "GET"
1298
+ });
1299
+ return res.json();
1300
+ },
1301
+ async create(agentId, versionId, payload) {
1302
+ const body = buildMultipart(payload);
1303
+ const res = await doFetch(
1304
+ `${base}/agents/${agentId}/versions/${versionId}/campaigns`,
1305
+ {
1306
+ method: "POST",
1307
+ body
1308
+ }
1309
+ );
1310
+ return res.json();
1311
+ },
1312
+ async listExecutions(campaignId, options = {}) {
1313
+ const normalizedOptions = {
1314
+ ...options ?? {}
1315
+ };
1316
+ const response = await fetchExecutionsPage(campaignId, normalizedOptions);
1317
+ const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
1318
+ return attachPaginator(response, fetchPage, normalizedOptions);
1319
+ }
1320
+ };
1321
+ }
1322
+
1247
1323
  // src/api/catalog-templates.ts
1248
1324
  function createCatalogTemplatesApi(cfg) {
1249
1325
  const { base, doFetch } = createHttp(cfg);
@@ -1755,6 +1831,26 @@ function createWebhooksApi(cfg) {
1755
1831
  function createWorkspacesApi(cfg) {
1756
1832
  const { base, doFetch } = createHttp(cfg);
1757
1833
  const jsonHeaders = { "content-type": "application/json" };
1834
+ const fetchWorkspacesPage = async (options = {}) => {
1835
+ const normalized = { ...options ?? {} };
1836
+ const query = serializeListOptions({
1837
+ page: normalized.page,
1838
+ limit: normalized.limit,
1839
+ sort: normalized.sort,
1840
+ fields: normalized.fields,
1841
+ include: normalized.include,
1842
+ search: normalized.search,
1843
+ filter: normalized.filter,
1844
+ or: normalized.or
1845
+ });
1846
+ const headers = normalized.refreshCache ? { "X-Cache-Refresh": "true" } : void 0;
1847
+ const res = await doFetch(`${base}/workspaces`, {
1848
+ method: "GET",
1849
+ query,
1850
+ headers
1851
+ });
1852
+ return res.json();
1853
+ };
1758
1854
  const fetchPhonesPage = async (workspaceId, opts = {}) => {
1759
1855
  const { channel } = opts ?? {};
1760
1856
  const query = serializeListOptions(
@@ -1777,6 +1873,11 @@ function createWorkspacesApi(cfg) {
1777
1873
  return res.json();
1778
1874
  };
1779
1875
  return {
1876
+ async list(options = {}) {
1877
+ const normalizedOptions = { ...options ?? {} };
1878
+ const response = await fetchWorkspacesPage(normalizedOptions);
1879
+ return attachPaginator(response, fetchWorkspacesPage, normalizedOptions);
1880
+ },
1780
1881
  async listPhones(workspaceId, opts = {}) {
1781
1882
  const normalizedOptions = {
1782
1883
  ...opts ?? {}
@@ -1900,6 +2001,7 @@ function createClient(initialCfg) {
1900
2001
  ...catalogsApi,
1901
2002
  templates: catalogTemplatesApi
1902
2003
  },
2004
+ campaigns: createCampaignsApi(runtimeCfg),
1903
2005
  voices: voicesApi,
1904
2006
  apiKeys: apiKeysApi,
1905
2007
  webhooks: webhooksApi
@@ -1983,6 +2085,7 @@ export {
1983
2085
  createAgentVersionsApi,
1984
2086
  createAgentsApi,
1985
2087
  createApiKeysApi,
2088
+ createCampaignsApi,
1986
2089
  createCatalogTemplatesApi,
1987
2090
  createCatalogsApi,
1988
2091
  createClient,