@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.cjs CHANGED
@@ -42,6 +42,7 @@ __export(index_exports, {
42
42
  createAgentVersionsApi: () => createAgentVersionsApi,
43
43
  createAgentsApi: () => createAgentsApi,
44
44
  createApiKeysApi: () => createApiKeysApi,
45
+ createCampaignsApi: () => createCampaignsApi,
45
46
  createCatalogTemplatesApi: () => createCatalogTemplatesApi,
46
47
  createCatalogsApi: () => createCatalogsApi,
47
48
  createClient: () => createClient,
@@ -515,6 +516,56 @@ function attachPaginator(response, fetchPage, options) {
515
516
  });
516
517
  }
517
518
 
519
+ // src/api/agent-schedule.ts
520
+ function createAgentScheduleApi(cfg) {
521
+ const { base, doFetch } = createHttp(cfg);
522
+ const jsonHeaders = { "content-type": "application/json" };
523
+ const fetchSchedulesPage = async (agentId, options = {}) => {
524
+ const query = serializeListOptions({ ...options ?? {} });
525
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
526
+ method: "GET",
527
+ query
528
+ });
529
+ return res.json();
530
+ };
531
+ return {
532
+ async list(agentId, options = {}) {
533
+ const normalized = { ...options ?? {} };
534
+ const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
535
+ const response = await fetchPage(normalized);
536
+ return attachPaginator(response, fetchPage, normalized);
537
+ },
538
+ async get(agentId, scheduleId) {
539
+ const res = await doFetch(
540
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
541
+ {
542
+ method: "GET"
543
+ }
544
+ );
545
+ return res.json();
546
+ },
547
+ async create(agentId, payload) {
548
+ const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
549
+ method: "POST",
550
+ headers: jsonHeaders,
551
+ body: JSON.stringify(payload)
552
+ });
553
+ return res.json();
554
+ },
555
+ async update(agentId, scheduleId, payload) {
556
+ const res = await doFetch(
557
+ `${base}/agents/${agentId}/schedules/${scheduleId}`,
558
+ {
559
+ method: "PUT",
560
+ headers: jsonHeaders,
561
+ body: JSON.stringify(payload)
562
+ }
563
+ );
564
+ return res.json();
565
+ }
566
+ };
567
+ }
568
+
518
569
  // src/api/agent-schedule-exceptions.ts
519
570
  function createAgentScheduleExceptionsApi(cfg) {
520
571
  const { base, doFetch } = createHttp(cfg);
@@ -581,56 +632,6 @@ function createAgentScheduleExceptionsApi(cfg) {
581
632
  };
582
633
  }
583
634
 
584
- // src/api/agent-schedule.ts
585
- function createAgentScheduleApi(cfg) {
586
- const { base, doFetch } = createHttp(cfg);
587
- const jsonHeaders = { "content-type": "application/json" };
588
- const fetchSchedulesPage = async (agentId, options = {}) => {
589
- const query = serializeListOptions({ ...options ?? {} });
590
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
591
- method: "GET",
592
- query
593
- });
594
- return res.json();
595
- };
596
- return {
597
- async list(agentId, options = {}) {
598
- const normalized = { ...options ?? {} };
599
- const fetchPage = (pageOptions) => fetchSchedulesPage(agentId, pageOptions);
600
- const response = await fetchPage(normalized);
601
- return attachPaginator(response, fetchPage, normalized);
602
- },
603
- async get(agentId, scheduleId) {
604
- const res = await doFetch(
605
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
606
- {
607
- method: "GET"
608
- }
609
- );
610
- return res.json();
611
- },
612
- async create(agentId, payload) {
613
- const res = await doFetch(`${base}/agents/${agentId}/schedules`, {
614
- method: "POST",
615
- headers: jsonHeaders,
616
- body: JSON.stringify(payload)
617
- });
618
- return res.json();
619
- },
620
- async update(agentId, scheduleId, payload) {
621
- const res = await doFetch(
622
- `${base}/agents/${agentId}/schedules/${scheduleId}`,
623
- {
624
- method: "PUT",
625
- headers: jsonHeaders,
626
- body: JSON.stringify(payload)
627
- }
628
- );
629
- return res.json();
630
- }
631
- };
632
- }
633
-
634
635
  // src/api/agent-stage-triggers.ts
635
636
  function createAgentStageTriggersApi(cfg) {
636
637
  const { base, doFetch } = createHttp(cfg);
@@ -1299,6 +1300,82 @@ function createApiKeysApi(cfg) {
1299
1300
  };
1300
1301
  }
1301
1302
 
1303
+ // src/api/campaigns.ts
1304
+ function createCampaignsApi(cfg) {
1305
+ const { base, doFetch } = createHttp(cfg);
1306
+ const isFormData2 = (value) => {
1307
+ return typeof FormData !== "undefined" && value instanceof FormData;
1308
+ };
1309
+ const fetchCampaignsPage = async (options = {}) => {
1310
+ const query = serializeListOptions(options ?? {});
1311
+ const res = await doFetch(`${base}/campaigns`, {
1312
+ method: "GET",
1313
+ query
1314
+ });
1315
+ return res.json();
1316
+ };
1317
+ const fetchExecutionsPage = async (campaignId, options = {}) => {
1318
+ const query = serializeListOptions({
1319
+ page: options.page,
1320
+ limit: options.limit
1321
+ });
1322
+ const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
1323
+ method: "GET",
1324
+ query
1325
+ });
1326
+ return res.json();
1327
+ };
1328
+ const buildMultipart = (payload) => {
1329
+ if (isFormData2(payload)) {
1330
+ return payload;
1331
+ }
1332
+ if (typeof FormData === "undefined") {
1333
+ throw new TypeError(
1334
+ "FormData is not available in this environment. Pass a FormData instance instead."
1335
+ );
1336
+ }
1337
+ const form = new FormData();
1338
+ form.append("name", payload.name);
1339
+ if (payload.objective !== void 0 && payload.objective !== null) {
1340
+ form.append("objective", payload.objective);
1341
+ }
1342
+ form.append("file", payload.file);
1343
+ return form;
1344
+ };
1345
+ return {
1346
+ async list(options = {}) {
1347
+ const normalizedOptions = { ...options ?? {} };
1348
+ const response = await fetchCampaignsPage(normalizedOptions);
1349
+ return attachPaginator(response, fetchCampaignsPage, normalizedOptions);
1350
+ },
1351
+ async get(campaignId) {
1352
+ const res = await doFetch(`${base}/campaigns/${campaignId}`, {
1353
+ method: "GET"
1354
+ });
1355
+ return res.json();
1356
+ },
1357
+ async create(agentId, versionId, payload) {
1358
+ const body = buildMultipart(payload);
1359
+ const res = await doFetch(
1360
+ `${base}/agents/${agentId}/versions/${versionId}/campaigns`,
1361
+ {
1362
+ method: "POST",
1363
+ body
1364
+ }
1365
+ );
1366
+ return res.json();
1367
+ },
1368
+ async listExecutions(campaignId, options = {}) {
1369
+ const normalizedOptions = {
1370
+ ...options ?? {}
1371
+ };
1372
+ const response = await fetchExecutionsPage(campaignId, normalizedOptions);
1373
+ const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
1374
+ return attachPaginator(response, fetchPage, normalizedOptions);
1375
+ }
1376
+ };
1377
+ }
1378
+
1302
1379
  // src/api/catalog-templates.ts
1303
1380
  function createCatalogTemplatesApi(cfg) {
1304
1381
  const { base, doFetch } = createHttp(cfg);
@@ -1810,6 +1887,26 @@ function createWebhooksApi(cfg) {
1810
1887
  function createWorkspacesApi(cfg) {
1811
1888
  const { base, doFetch } = createHttp(cfg);
1812
1889
  const jsonHeaders = { "content-type": "application/json" };
1890
+ const fetchWorkspacesPage = async (options = {}) => {
1891
+ const normalized = { ...options ?? {} };
1892
+ const query = serializeListOptions({
1893
+ page: normalized.page,
1894
+ limit: normalized.limit,
1895
+ sort: normalized.sort,
1896
+ fields: normalized.fields,
1897
+ include: normalized.include,
1898
+ search: normalized.search,
1899
+ filter: normalized.filter,
1900
+ or: normalized.or
1901
+ });
1902
+ const headers = normalized.refreshCache ? { "X-Cache-Refresh": "true" } : void 0;
1903
+ const res = await doFetch(`${base}/workspaces`, {
1904
+ method: "GET",
1905
+ query,
1906
+ headers
1907
+ });
1908
+ return res.json();
1909
+ };
1813
1910
  const fetchPhonesPage = async (workspaceId, opts = {}) => {
1814
1911
  const { channel } = opts ?? {};
1815
1912
  const query = serializeListOptions(
@@ -1832,6 +1929,11 @@ function createWorkspacesApi(cfg) {
1832
1929
  return res.json();
1833
1930
  };
1834
1931
  return {
1932
+ async list(options = {}) {
1933
+ const normalizedOptions = { ...options ?? {} };
1934
+ const response = await fetchWorkspacesPage(normalizedOptions);
1935
+ return attachPaginator(response, fetchWorkspacesPage, normalizedOptions);
1936
+ },
1835
1937
  async listPhones(workspaceId, opts = {}) {
1836
1938
  const normalizedOptions = {
1837
1939
  ...opts ?? {}
@@ -1955,6 +2057,7 @@ function createClient(initialCfg) {
1955
2057
  ...catalogsApi,
1956
2058
  templates: catalogTemplatesApi
1957
2059
  },
2060
+ campaigns: createCampaignsApi(runtimeCfg),
1958
2061
  voices: voicesApi,
1959
2062
  apiKeys: apiKeysApi,
1960
2063
  webhooks: webhooksApi
@@ -2039,6 +2142,7 @@ function createClient(initialCfg) {
2039
2142
  createAgentVersionsApi,
2040
2143
  createAgentsApi,
2041
2144
  createApiKeysApi,
2145
+ createCampaignsApi,
2042
2146
  createCatalogTemplatesApi,
2043
2147
  createCatalogsApi,
2044
2148
  createClient,