@getsupervisor/agents-studio-sdk 1.41.2-patch.16 → 1.41.2-patch.17
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 +163 -278
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +69 -117
- package/dist/index.d.ts +69 -117
- package/dist/index.js +163 -277
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,6 @@ __export(index_exports, {
|
|
|
49
49
|
createCatalogTemplatesApi: () => createCatalogTemplatesApi,
|
|
50
50
|
createCatalogsApi: () => createCatalogsApi,
|
|
51
51
|
createClient: () => createClient,
|
|
52
|
-
createDocumentsApi: () => createDocumentsApi,
|
|
53
52
|
createHttp: () => createHttp,
|
|
54
53
|
createSipTrunksApi: () => createSipTrunksApi,
|
|
55
54
|
createToolsApi: () => createToolsApi,
|
|
@@ -954,102 +953,6 @@ function createAgentVersionsApi(cfg) {
|
|
|
954
953
|
};
|
|
955
954
|
}
|
|
956
955
|
|
|
957
|
-
// src/utils/sse-stream.ts
|
|
958
|
-
function extractField(line, prefix) {
|
|
959
|
-
if (!line.startsWith(prefix)) {
|
|
960
|
-
return null;
|
|
961
|
-
}
|
|
962
|
-
return line.slice(prefix.length);
|
|
963
|
-
}
|
|
964
|
-
function parseSseMessage(raw) {
|
|
965
|
-
let type = "";
|
|
966
|
-
let data = "";
|
|
967
|
-
for (const line of raw.split("\n")) {
|
|
968
|
-
type = extractField(line, "event: ") ?? type;
|
|
969
|
-
data = extractField(line, "data: ") ?? data;
|
|
970
|
-
}
|
|
971
|
-
if (!type || !data) {
|
|
972
|
-
return null;
|
|
973
|
-
}
|
|
974
|
-
return { type, data };
|
|
975
|
-
}
|
|
976
|
-
function dispatchSseEvent(event, handlers) {
|
|
977
|
-
const handler = handlers[event.type];
|
|
978
|
-
if (!handler) {
|
|
979
|
-
return void 0;
|
|
980
|
-
}
|
|
981
|
-
try {
|
|
982
|
-
const parsed = JSON.parse(event.data);
|
|
983
|
-
handler(parsed);
|
|
984
|
-
return parsed;
|
|
985
|
-
} catch {
|
|
986
|
-
return void 0;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
function processRawPart(raw, handlers, resolveEvent) {
|
|
990
|
-
const trimmed = raw.trim();
|
|
991
|
-
if (!trimmed) {
|
|
992
|
-
return void 0;
|
|
993
|
-
}
|
|
994
|
-
const event = parseSseMessage(trimmed);
|
|
995
|
-
if (!event) {
|
|
996
|
-
return void 0;
|
|
997
|
-
}
|
|
998
|
-
const result = dispatchSseEvent(event, handlers);
|
|
999
|
-
if (event.type !== resolveEvent) {
|
|
1000
|
-
return void 0;
|
|
1001
|
-
}
|
|
1002
|
-
return result;
|
|
1003
|
-
}
|
|
1004
|
-
function flushRemainingBuffer(buffer) {
|
|
1005
|
-
if (!buffer.trim()) {
|
|
1006
|
-
return "";
|
|
1007
|
-
}
|
|
1008
|
-
return buffer + "\n\n";
|
|
1009
|
-
}
|
|
1010
|
-
function consumeSseStream(response, handlers, resolveEvent) {
|
|
1011
|
-
if (!response.body) {
|
|
1012
|
-
throw new Error("No response body for SSE stream");
|
|
1013
|
-
}
|
|
1014
|
-
return new Promise((resolve, reject) => {
|
|
1015
|
-
let resolved;
|
|
1016
|
-
let buffer = "";
|
|
1017
|
-
const reader = response.body.getReader();
|
|
1018
|
-
const decoder = new TextDecoder();
|
|
1019
|
-
const processBuffer = () => {
|
|
1020
|
-
const parts = buffer.split("\n\n");
|
|
1021
|
-
buffer = parts.pop() ?? "";
|
|
1022
|
-
for (const part of parts) {
|
|
1023
|
-
const result = processRawPart(part, handlers, resolveEvent);
|
|
1024
|
-
if (result) {
|
|
1025
|
-
resolved = result;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
};
|
|
1029
|
-
const finalize = () => {
|
|
1030
|
-
buffer = flushRemainingBuffer(buffer);
|
|
1031
|
-
processBuffer();
|
|
1032
|
-
if (resolved) {
|
|
1033
|
-
resolve(resolved);
|
|
1034
|
-
return;
|
|
1035
|
-
}
|
|
1036
|
-
reject(new Error(`SSE stream ended without '${resolveEvent}' event`));
|
|
1037
|
-
};
|
|
1038
|
-
const read = () => {
|
|
1039
|
-
reader.read().then(({ done, value }) => {
|
|
1040
|
-
if (done) {
|
|
1041
|
-
finalize();
|
|
1042
|
-
return;
|
|
1043
|
-
}
|
|
1044
|
-
buffer += decoder.decode(value, { stream: true });
|
|
1045
|
-
processBuffer();
|
|
1046
|
-
read();
|
|
1047
|
-
}).catch(reject);
|
|
1048
|
-
};
|
|
1049
|
-
read();
|
|
1050
|
-
});
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
956
|
// src/entities/agent.ts
|
|
1054
957
|
var bindAgentStageTriggers = (api, agentId, blueprintId, stageId) => ({
|
|
1055
958
|
list(opts) {
|
|
@@ -1270,36 +1173,8 @@ var createAgentEntity = (dto, options) => {
|
|
|
1270
1173
|
};
|
|
1271
1174
|
|
|
1272
1175
|
// src/api/agents.ts
|
|
1273
|
-
function normalizeCloneSelection(selection) {
|
|
1274
|
-
if (!selection) {
|
|
1275
|
-
return [];
|
|
1276
|
-
}
|
|
1277
|
-
if (Array.isArray(selection)) {
|
|
1278
|
-
return selection;
|
|
1279
|
-
}
|
|
1280
|
-
return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
|
|
1281
|
-
}
|
|
1282
|
-
function buildCloneRequest(payload) {
|
|
1283
|
-
const { clone, ...rest } = payload;
|
|
1284
|
-
return { ...rest, clone: normalizeCloneSelection(clone) };
|
|
1285
|
-
}
|
|
1286
|
-
function buildSseHandlers(callbacks) {
|
|
1287
|
-
return {
|
|
1288
|
-
"agent-created": (data) => callbacks.onAgentCreated?.(data),
|
|
1289
|
-
"runtime-progress": (data) => callbacks.onProgress?.(data),
|
|
1290
|
-
"runtime-complete": (data) => callbacks.onComplete?.(data),
|
|
1291
|
-
"runtime-error": (data) => callbacks.onError?.(data)
|
|
1292
|
-
};
|
|
1293
|
-
}
|
|
1294
|
-
function resolveAgentId(agent) {
|
|
1295
|
-
if (typeof agent === "string") {
|
|
1296
|
-
return agent;
|
|
1297
|
-
}
|
|
1298
|
-
return agent.agentId;
|
|
1299
|
-
}
|
|
1300
1176
|
function createAgentsApi(cfg, relatedApis) {
|
|
1301
|
-
const { base, doFetch,
|
|
1302
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
1177
|
+
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1303
1178
|
const requireWorkspace = () => {
|
|
1304
1179
|
const workspaceId = resolveWorkspaceId();
|
|
1305
1180
|
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
@@ -1311,169 +1186,167 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1311
1186
|
}
|
|
1312
1187
|
throw new WorkspaceNotSelectedError();
|
|
1313
1188
|
};
|
|
1314
|
-
const
|
|
1189
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
1190
|
+
const normalizeCloneSelection = (selection) => {
|
|
1191
|
+
if (!selection) {
|
|
1192
|
+
return [];
|
|
1193
|
+
}
|
|
1194
|
+
if (Array.isArray(selection)) {
|
|
1195
|
+
return selection;
|
|
1196
|
+
}
|
|
1197
|
+
return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
|
|
1198
|
+
};
|
|
1199
|
+
const buildCloneAgentRequest = (payload) => {
|
|
1200
|
+
const { clone, ...rest } = payload;
|
|
1201
|
+
return {
|
|
1202
|
+
...rest,
|
|
1203
|
+
clone: normalizeCloneSelection(clone)
|
|
1204
|
+
};
|
|
1205
|
+
};
|
|
1206
|
+
const fetchAgentsPage = async (options = {}) => {
|
|
1315
1207
|
requireWorkspace();
|
|
1316
|
-
const
|
|
1208
|
+
const sanitizedOptions = {
|
|
1209
|
+
page: options.page,
|
|
1210
|
+
limit: options.limit,
|
|
1211
|
+
filter: options.filter
|
|
1212
|
+
};
|
|
1213
|
+
const query = serializeListOptions(sanitizedOptions);
|
|
1214
|
+
const res = await doFetch(`${base}/agents`, {
|
|
1215
|
+
method: "GET",
|
|
1216
|
+
query
|
|
1217
|
+
});
|
|
1218
|
+
return res.json();
|
|
1219
|
+
};
|
|
1220
|
+
const listAgents = async (options = {}) => {
|
|
1221
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1222
|
+
const response = await fetchAgentsPage(normalizedOptions);
|
|
1223
|
+
return attachPaginator(response, fetchAgentsPage, normalizedOptions);
|
|
1224
|
+
};
|
|
1225
|
+
const getAgentDetail = async (agentId) => {
|
|
1226
|
+
requireWorkspace();
|
|
1227
|
+
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1228
|
+
method: "GET"
|
|
1229
|
+
});
|
|
1230
|
+
return res.json();
|
|
1231
|
+
};
|
|
1232
|
+
const createAgent = async (payload) => {
|
|
1233
|
+
requireWorkspace();
|
|
1234
|
+
const res = await doFetch(`${base}/agents`, {
|
|
1317
1235
|
method: "POST",
|
|
1318
1236
|
body: JSON.stringify(payload),
|
|
1319
1237
|
headers: jsonHeaders
|
|
1320
1238
|
});
|
|
1321
1239
|
return res.json();
|
|
1322
1240
|
};
|
|
1323
|
-
const
|
|
1241
|
+
const forkAgentFromTemplate = async (payload) => {
|
|
1324
1242
|
requireWorkspace();
|
|
1325
|
-
const
|
|
1326
|
-
const fx = cfg.fetchImpl ?? fetch;
|
|
1327
|
-
const res = await fx(url, {
|
|
1243
|
+
const res = await doFetch(`${base}/agents/from-template`, {
|
|
1328
1244
|
method: "POST",
|
|
1329
1245
|
body: JSON.stringify(payload),
|
|
1330
|
-
headers
|
|
1246
|
+
headers: jsonHeaders
|
|
1331
1247
|
});
|
|
1332
|
-
|
|
1333
|
-
const body = await res.text();
|
|
1334
|
-
throw new Error(`POST ${url} failed with status ${res.status}: ${body}`);
|
|
1335
|
-
}
|
|
1336
|
-
const contentType = res.headers.get("content-type") ?? "";
|
|
1337
|
-
if (contentType.includes("application/json")) {
|
|
1338
|
-
const agent = await res.json();
|
|
1339
|
-
callbacks.onAgentCreated?.(agent);
|
|
1340
|
-
return agent;
|
|
1341
|
-
}
|
|
1342
|
-
return consumeSseStream(
|
|
1343
|
-
res,
|
|
1344
|
-
buildSseHandlers(callbacks),
|
|
1345
|
-
"agent-created"
|
|
1346
|
-
);
|
|
1248
|
+
return res.json();
|
|
1347
1249
|
};
|
|
1348
|
-
const
|
|
1250
|
+
const cloneAgent = async (agentId, payload) => {
|
|
1349
1251
|
requireWorkspace();
|
|
1350
|
-
const
|
|
1351
|
-
const
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
const contentType = res.headers.get("content-type") ?? "";
|
|
1358
|
-
if (contentType.includes("application/json")) {
|
|
1359
|
-
const agent = await res.json();
|
|
1360
|
-
callbacks.onAgentCreated?.(agent);
|
|
1361
|
-
return agent;
|
|
1362
|
-
}
|
|
1363
|
-
return consumeSseStream(
|
|
1364
|
-
res,
|
|
1365
|
-
buildSseHandlers(callbacks),
|
|
1366
|
-
"agent-created"
|
|
1367
|
-
);
|
|
1252
|
+
const requestPayload = buildCloneAgentRequest(payload);
|
|
1253
|
+
const res = await doFetch(`${base}/agents/${agentId}/clone`, {
|
|
1254
|
+
method: "POST",
|
|
1255
|
+
body: JSON.stringify(requestPayload),
|
|
1256
|
+
headers: jsonHeaders
|
|
1257
|
+
});
|
|
1258
|
+
return res.json();
|
|
1368
1259
|
};
|
|
1369
|
-
const
|
|
1260
|
+
const updateAgent = async (agentId, payload) => {
|
|
1370
1261
|
requireWorkspace();
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1262
|
+
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1263
|
+
method: "PATCH",
|
|
1264
|
+
body: JSON.stringify(payload),
|
|
1265
|
+
headers: jsonHeaders
|
|
1375
1266
|
});
|
|
1376
|
-
const res = await doFetch(`${base}/agents`, { method: "GET", query });
|
|
1377
1267
|
return res.json();
|
|
1378
1268
|
};
|
|
1269
|
+
const resolveAgentId = (agent) => {
|
|
1270
|
+
return typeof agent === "string" ? agent : agent.agentId;
|
|
1271
|
+
};
|
|
1272
|
+
const deleteAgent = async (agent) => {
|
|
1273
|
+
requireWorkspace();
|
|
1274
|
+
const agentId = resolveAgentId(agent);
|
|
1275
|
+
await doFetch(`${base}/agents/${agentId}`, {
|
|
1276
|
+
method: "DELETE"
|
|
1277
|
+
});
|
|
1278
|
+
};
|
|
1379
1279
|
const baseApi = {
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
return getWithSse(`${base}/agents/${agentId}`, callbacks);
|
|
1388
|
-
}
|
|
1389
|
-
requireWorkspace();
|
|
1390
|
-
const res = await doFetch(`${base}/agents/${agentId}`, { method: "GET" });
|
|
1391
|
-
return res.json();
|
|
1392
|
-
},
|
|
1393
|
-
async create(payload, callbacks) {
|
|
1394
|
-
if (callbacks) {
|
|
1395
|
-
return postWithSse(`${base}/agents`, payload, callbacks);
|
|
1396
|
-
}
|
|
1397
|
-
return postJson(`${base}/agents`, payload);
|
|
1398
|
-
},
|
|
1399
|
-
async clone(agentId, payload) {
|
|
1400
|
-
return postJson(
|
|
1401
|
-
`${base}/agents/${agentId}/clone`,
|
|
1402
|
-
buildCloneRequest(payload)
|
|
1403
|
-
);
|
|
1404
|
-
},
|
|
1405
|
-
async forkFromTemplate(payload, callbacks) {
|
|
1406
|
-
if (callbacks) {
|
|
1407
|
-
return postWithSse(`${base}/agents/from-template`, payload, callbacks);
|
|
1408
|
-
}
|
|
1409
|
-
return postJson(`${base}/agents/from-template`, payload);
|
|
1410
|
-
},
|
|
1411
|
-
async update(agentId, payload) {
|
|
1412
|
-
requireWorkspace();
|
|
1413
|
-
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1414
|
-
method: "PATCH",
|
|
1415
|
-
body: JSON.stringify(payload),
|
|
1416
|
-
headers: jsonHeaders
|
|
1417
|
-
});
|
|
1418
|
-
return res.json();
|
|
1419
|
-
},
|
|
1420
|
-
async delete(agent) {
|
|
1421
|
-
requireWorkspace();
|
|
1422
|
-
await doFetch(`${base}/agents/${resolveAgentId(agent)}`, {
|
|
1423
|
-
method: "DELETE"
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1280
|
+
list: listAgents,
|
|
1281
|
+
get: getAgentDetail,
|
|
1282
|
+
create: createAgent,
|
|
1283
|
+
clone: cloneAgent,
|
|
1284
|
+
forkFromTemplate: forkAgentFromTemplate,
|
|
1285
|
+
update: updateAgent,
|
|
1286
|
+
delete: deleteAgent
|
|
1426
1287
|
};
|
|
1427
1288
|
if (!relatedApis) {
|
|
1428
1289
|
return baseApi;
|
|
1429
1290
|
}
|
|
1430
|
-
return withEntityWrapping(baseApi, fetchPage, relatedApis);
|
|
1431
|
-
}
|
|
1432
|
-
function withEntityWrapping(api, fetchPage, deps) {
|
|
1433
1291
|
const wrapAgent = (detail) => createAgentEntity(detail, {
|
|
1434
|
-
|
|
1292
|
+
tagsApi: relatedApis.tagsApi,
|
|
1293
|
+
phonesApi: relatedApis.phonesApi,
|
|
1294
|
+
scheduleApi: relatedApis.scheduleApi,
|
|
1295
|
+
scheduleExceptionsApi: relatedApis.scheduleExceptionsApi,
|
|
1296
|
+
versionsApi: relatedApis.versionsApi,
|
|
1297
|
+
blueprintsApi: relatedApis.blueprintsApi,
|
|
1298
|
+
stagesApi: relatedApis.stagesApi,
|
|
1299
|
+
stageTriggersApi: relatedApis.stageTriggersApi,
|
|
1435
1300
|
reload: async (agentId) => {
|
|
1436
|
-
const latest = await
|
|
1301
|
+
const latest = await getAgentDetail(agentId);
|
|
1437
1302
|
return wrapAgent(latest);
|
|
1438
1303
|
},
|
|
1439
1304
|
updateAgent: async (agentId, payload) => {
|
|
1440
|
-
const updated = await
|
|
1305
|
+
const updated = await updateAgent(agentId, payload);
|
|
1441
1306
|
return wrapAgent(updated);
|
|
1442
1307
|
},
|
|
1443
1308
|
deleteAgent: async (agentId) => {
|
|
1444
|
-
await
|
|
1309
|
+
await deleteAgent(agentId);
|
|
1445
1310
|
},
|
|
1446
1311
|
cloneAgent: async (agentId, payload) => {
|
|
1447
|
-
const cloned = await
|
|
1312
|
+
const cloned = await cloneAgent(agentId, payload);
|
|
1448
1313
|
return wrapAgent(cloned);
|
|
1449
1314
|
}
|
|
1450
1315
|
});
|
|
1451
|
-
const wrapList = async (opts) => {
|
|
1452
|
-
const result = await fetchPage(opts);
|
|
1453
|
-
const items = Array.isArray(result.data) ? result.data : [];
|
|
1454
|
-
return { ...result, data: items.map(wrapAgent) };
|
|
1455
|
-
};
|
|
1456
1316
|
return {
|
|
1457
|
-
...
|
|
1317
|
+
...baseApi,
|
|
1458
1318
|
async list(options = {}) {
|
|
1459
|
-
const
|
|
1460
|
-
const
|
|
1461
|
-
|
|
1319
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1320
|
+
const applyWrap = async (opts) => {
|
|
1321
|
+
const result = await fetchAgentsPage(opts);
|
|
1322
|
+
const items = Array.isArray(result.data) ? result.data : [];
|
|
1323
|
+
return {
|
|
1324
|
+
...result,
|
|
1325
|
+
data: items.map((summary) => wrapAgent(summary))
|
|
1326
|
+
};
|
|
1327
|
+
};
|
|
1328
|
+
const initial = await applyWrap(normalizedOptions);
|
|
1329
|
+
return attachPaginator(initial, applyWrap, normalizedOptions);
|
|
1462
1330
|
},
|
|
1463
|
-
async get(agentId
|
|
1464
|
-
|
|
1331
|
+
async get(agentId) {
|
|
1332
|
+
const detail = await getAgentDetail(agentId);
|
|
1333
|
+
return wrapAgent(detail);
|
|
1465
1334
|
},
|
|
1466
|
-
async create(payload
|
|
1467
|
-
|
|
1335
|
+
async create(payload) {
|
|
1336
|
+
const detail = await createAgent(payload);
|
|
1337
|
+
return wrapAgent(detail);
|
|
1468
1338
|
},
|
|
1469
1339
|
async clone(agentId, payload) {
|
|
1470
|
-
|
|
1340
|
+
const detail = await cloneAgent(agentId, payload);
|
|
1341
|
+
return wrapAgent(detail);
|
|
1471
1342
|
},
|
|
1472
|
-
async forkFromTemplate(payload
|
|
1473
|
-
|
|
1343
|
+
async forkFromTemplate(payload) {
|
|
1344
|
+
const detail = await forkAgentFromTemplate(payload);
|
|
1345
|
+
return wrapAgent(detail);
|
|
1474
1346
|
},
|
|
1475
1347
|
async update(agentId, payload) {
|
|
1476
|
-
|
|
1348
|
+
const detail = await updateAgent(agentId, payload);
|
|
1349
|
+
return wrapAgent(detail);
|
|
1477
1350
|
}
|
|
1478
1351
|
};
|
|
1479
1352
|
}
|
|
@@ -1600,10 +1473,7 @@ function createCampaignsApi(cfg) {
|
|
|
1600
1473
|
return res.json();
|
|
1601
1474
|
};
|
|
1602
1475
|
const fetchExecutionsPage = async (campaignId, options = {}) => {
|
|
1603
|
-
const query = serializeListOptions({
|
|
1604
|
-
page: options.page,
|
|
1605
|
-
limit: options.limit
|
|
1606
|
-
});
|
|
1476
|
+
const query = serializeListOptions(options ?? {});
|
|
1607
1477
|
const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
|
|
1608
1478
|
method: "GET",
|
|
1609
1479
|
query
|
|
@@ -1657,6 +1527,51 @@ function createCampaignsApi(cfg) {
|
|
|
1657
1527
|
const response = await fetchExecutionsPage(campaignId, normalizedOptions);
|
|
1658
1528
|
const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
|
|
1659
1529
|
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
1530
|
+
},
|
|
1531
|
+
/**
|
|
1532
|
+
* Pausa una campaña en curso. Los reintentos ya programados se
|
|
1533
|
+
* reagendan al ejecutarse (sin consumir intentos) hasta `resume()`.
|
|
1534
|
+
*/
|
|
1535
|
+
async pause(campaignId) {
|
|
1536
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/pause`, {
|
|
1537
|
+
method: "POST"
|
|
1538
|
+
});
|
|
1539
|
+
return res.json();
|
|
1540
|
+
},
|
|
1541
|
+
/**
|
|
1542
|
+
* Reanuda una campaña pausada. Re-encola los reintentos pendientes
|
|
1543
|
+
* según su `nextRetryAt`.
|
|
1544
|
+
*/
|
|
1545
|
+
async resume(campaignId) {
|
|
1546
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/resume`, {
|
|
1547
|
+
method: "POST"
|
|
1548
|
+
});
|
|
1549
|
+
return res.json();
|
|
1550
|
+
},
|
|
1551
|
+
/**
|
|
1552
|
+
* Cancela definitivamente una campaña no terminal. Los reintentos
|
|
1553
|
+
* pendientes se descartan — operación destructiva.
|
|
1554
|
+
*/
|
|
1555
|
+
async cancel(campaignId) {
|
|
1556
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/cancel`, {
|
|
1557
|
+
method: "POST"
|
|
1558
|
+
});
|
|
1559
|
+
return res.json();
|
|
1560
|
+
},
|
|
1561
|
+
/**
|
|
1562
|
+
* Descarga el CSV con todas las ejecuciones de la campaña. Devuelve un
|
|
1563
|
+
* `Blob` con `text/csv; charset=utf-8` (BOM UTF-8 incluido). Para
|
|
1564
|
+
* campañas > 20,000 filas la API responde 413.
|
|
1565
|
+
*/
|
|
1566
|
+
async exportExecutions(campaignId) {
|
|
1567
|
+
const res = await doFetch(
|
|
1568
|
+
`${base}/campaigns/${campaignId}/executions/export`,
|
|
1569
|
+
{
|
|
1570
|
+
method: "GET",
|
|
1571
|
+
headers: { Accept: "text/csv" }
|
|
1572
|
+
}
|
|
1573
|
+
);
|
|
1574
|
+
return res.blob();
|
|
1660
1575
|
}
|
|
1661
1576
|
};
|
|
1662
1577
|
}
|
|
@@ -1737,34 +1652,6 @@ function createCatalogsApi(cfg) {
|
|
|
1737
1652
|
};
|
|
1738
1653
|
}
|
|
1739
1654
|
|
|
1740
|
-
// src/api/documents.ts
|
|
1741
|
-
function createDocumentsApi(cfg) {
|
|
1742
|
-
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1743
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
1744
|
-
const requireWorkspace = () => {
|
|
1745
|
-
const workspaceId = resolveWorkspaceId();
|
|
1746
|
-
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
1747
|
-
return;
|
|
1748
|
-
}
|
|
1749
|
-
const apiKey = resolveApiKey();
|
|
1750
|
-
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
1751
|
-
return;
|
|
1752
|
-
}
|
|
1753
|
-
throw new WorkspaceNotSelectedError();
|
|
1754
|
-
};
|
|
1755
|
-
return {
|
|
1756
|
-
async create(files) {
|
|
1757
|
-
requireWorkspace();
|
|
1758
|
-
const res = await doFetch(`${base}/documents`, {
|
|
1759
|
-
method: "POST",
|
|
1760
|
-
body: JSON.stringify({ files }),
|
|
1761
|
-
headers: jsonHeaders
|
|
1762
|
-
});
|
|
1763
|
-
return res.json();
|
|
1764
|
-
}
|
|
1765
|
-
};
|
|
1766
|
-
}
|
|
1767
|
-
|
|
1768
1655
|
// src/api/sip-trunks.ts
|
|
1769
1656
|
function createSipTrunksApi(cfg) {
|
|
1770
1657
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -2562,7 +2449,6 @@ function createClient(initialCfg) {
|
|
|
2562
2449
|
...catalogsApi,
|
|
2563
2450
|
templates: catalogTemplatesApi
|
|
2564
2451
|
},
|
|
2565
|
-
documents: createDocumentsApi(runtimeCfg),
|
|
2566
2452
|
campaigns: createCampaignsApi(runtimeCfg),
|
|
2567
2453
|
voices: voicesApi,
|
|
2568
2454
|
apiKeys: apiKeysApi,
|
|
@@ -2659,7 +2545,6 @@ function createClient(initialCfg) {
|
|
|
2659
2545
|
createCatalogTemplatesApi,
|
|
2660
2546
|
createCatalogsApi,
|
|
2661
2547
|
createClient,
|
|
2662
|
-
createDocumentsApi,
|
|
2663
2548
|
createHttp,
|
|
2664
2549
|
createSipTrunksApi,
|
|
2665
2550
|
createToolsApi,
|