@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.js
CHANGED
|
@@ -890,102 +890,6 @@ function createAgentVersionsApi(cfg) {
|
|
|
890
890
|
};
|
|
891
891
|
}
|
|
892
892
|
|
|
893
|
-
// src/utils/sse-stream.ts
|
|
894
|
-
function extractField(line, prefix) {
|
|
895
|
-
if (!line.startsWith(prefix)) {
|
|
896
|
-
return null;
|
|
897
|
-
}
|
|
898
|
-
return line.slice(prefix.length);
|
|
899
|
-
}
|
|
900
|
-
function parseSseMessage(raw) {
|
|
901
|
-
let type = "";
|
|
902
|
-
let data = "";
|
|
903
|
-
for (const line of raw.split("\n")) {
|
|
904
|
-
type = extractField(line, "event: ") ?? type;
|
|
905
|
-
data = extractField(line, "data: ") ?? data;
|
|
906
|
-
}
|
|
907
|
-
if (!type || !data) {
|
|
908
|
-
return null;
|
|
909
|
-
}
|
|
910
|
-
return { type, data };
|
|
911
|
-
}
|
|
912
|
-
function dispatchSseEvent(event, handlers) {
|
|
913
|
-
const handler = handlers[event.type];
|
|
914
|
-
if (!handler) {
|
|
915
|
-
return void 0;
|
|
916
|
-
}
|
|
917
|
-
try {
|
|
918
|
-
const parsed = JSON.parse(event.data);
|
|
919
|
-
handler(parsed);
|
|
920
|
-
return parsed;
|
|
921
|
-
} catch {
|
|
922
|
-
return void 0;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
function processRawPart(raw, handlers, resolveEvent) {
|
|
926
|
-
const trimmed = raw.trim();
|
|
927
|
-
if (!trimmed) {
|
|
928
|
-
return void 0;
|
|
929
|
-
}
|
|
930
|
-
const event = parseSseMessage(trimmed);
|
|
931
|
-
if (!event) {
|
|
932
|
-
return void 0;
|
|
933
|
-
}
|
|
934
|
-
const result = dispatchSseEvent(event, handlers);
|
|
935
|
-
if (event.type !== resolveEvent) {
|
|
936
|
-
return void 0;
|
|
937
|
-
}
|
|
938
|
-
return result;
|
|
939
|
-
}
|
|
940
|
-
function flushRemainingBuffer(buffer) {
|
|
941
|
-
if (!buffer.trim()) {
|
|
942
|
-
return "";
|
|
943
|
-
}
|
|
944
|
-
return buffer + "\n\n";
|
|
945
|
-
}
|
|
946
|
-
function consumeSseStream(response, handlers, resolveEvent) {
|
|
947
|
-
if (!response.body) {
|
|
948
|
-
throw new Error("No response body for SSE stream");
|
|
949
|
-
}
|
|
950
|
-
return new Promise((resolve, reject) => {
|
|
951
|
-
let resolved;
|
|
952
|
-
let buffer = "";
|
|
953
|
-
const reader = response.body.getReader();
|
|
954
|
-
const decoder = new TextDecoder();
|
|
955
|
-
const processBuffer = () => {
|
|
956
|
-
const parts = buffer.split("\n\n");
|
|
957
|
-
buffer = parts.pop() ?? "";
|
|
958
|
-
for (const part of parts) {
|
|
959
|
-
const result = processRawPart(part, handlers, resolveEvent);
|
|
960
|
-
if (result) {
|
|
961
|
-
resolved = result;
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
const finalize = () => {
|
|
966
|
-
buffer = flushRemainingBuffer(buffer);
|
|
967
|
-
processBuffer();
|
|
968
|
-
if (resolved) {
|
|
969
|
-
resolve(resolved);
|
|
970
|
-
return;
|
|
971
|
-
}
|
|
972
|
-
reject(new Error(`SSE stream ended without '${resolveEvent}' event`));
|
|
973
|
-
};
|
|
974
|
-
const read = () => {
|
|
975
|
-
reader.read().then(({ done, value }) => {
|
|
976
|
-
if (done) {
|
|
977
|
-
finalize();
|
|
978
|
-
return;
|
|
979
|
-
}
|
|
980
|
-
buffer += decoder.decode(value, { stream: true });
|
|
981
|
-
processBuffer();
|
|
982
|
-
read();
|
|
983
|
-
}).catch(reject);
|
|
984
|
-
};
|
|
985
|
-
read();
|
|
986
|
-
});
|
|
987
|
-
}
|
|
988
|
-
|
|
989
893
|
// src/entities/agent.ts
|
|
990
894
|
var bindAgentStageTriggers = (api, agentId, blueprintId, stageId) => ({
|
|
991
895
|
list(opts) {
|
|
@@ -1206,36 +1110,8 @@ var createAgentEntity = (dto, options) => {
|
|
|
1206
1110
|
};
|
|
1207
1111
|
|
|
1208
1112
|
// src/api/agents.ts
|
|
1209
|
-
function normalizeCloneSelection(selection) {
|
|
1210
|
-
if (!selection) {
|
|
1211
|
-
return [];
|
|
1212
|
-
}
|
|
1213
|
-
if (Array.isArray(selection)) {
|
|
1214
|
-
return selection;
|
|
1215
|
-
}
|
|
1216
|
-
return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
|
|
1217
|
-
}
|
|
1218
|
-
function buildCloneRequest(payload) {
|
|
1219
|
-
const { clone, ...rest } = payload;
|
|
1220
|
-
return { ...rest, clone: normalizeCloneSelection(clone) };
|
|
1221
|
-
}
|
|
1222
|
-
function buildSseHandlers(callbacks) {
|
|
1223
|
-
return {
|
|
1224
|
-
"agent-created": (data) => callbacks.onAgentCreated?.(data),
|
|
1225
|
-
"runtime-progress": (data) => callbacks.onProgress?.(data),
|
|
1226
|
-
"runtime-complete": (data) => callbacks.onComplete?.(data),
|
|
1227
|
-
"runtime-error": (data) => callbacks.onError?.(data)
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
function resolveAgentId(agent) {
|
|
1231
|
-
if (typeof agent === "string") {
|
|
1232
|
-
return agent;
|
|
1233
|
-
}
|
|
1234
|
-
return agent.agentId;
|
|
1235
|
-
}
|
|
1236
1113
|
function createAgentsApi(cfg, relatedApis) {
|
|
1237
|
-
const { base, doFetch,
|
|
1238
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
1114
|
+
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1239
1115
|
const requireWorkspace = () => {
|
|
1240
1116
|
const workspaceId = resolveWorkspaceId();
|
|
1241
1117
|
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
@@ -1247,169 +1123,167 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1247
1123
|
}
|
|
1248
1124
|
throw new WorkspaceNotSelectedError();
|
|
1249
1125
|
};
|
|
1250
|
-
const
|
|
1126
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
1127
|
+
const normalizeCloneSelection = (selection) => {
|
|
1128
|
+
if (!selection) {
|
|
1129
|
+
return [];
|
|
1130
|
+
}
|
|
1131
|
+
if (Array.isArray(selection)) {
|
|
1132
|
+
return selection;
|
|
1133
|
+
}
|
|
1134
|
+
return Object.entries(selection).filter(([, enabled]) => enabled).map(([component]) => component);
|
|
1135
|
+
};
|
|
1136
|
+
const buildCloneAgentRequest = (payload) => {
|
|
1137
|
+
const { clone, ...rest } = payload;
|
|
1138
|
+
return {
|
|
1139
|
+
...rest,
|
|
1140
|
+
clone: normalizeCloneSelection(clone)
|
|
1141
|
+
};
|
|
1142
|
+
};
|
|
1143
|
+
const fetchAgentsPage = async (options = {}) => {
|
|
1251
1144
|
requireWorkspace();
|
|
1252
|
-
const
|
|
1145
|
+
const sanitizedOptions = {
|
|
1146
|
+
page: options.page,
|
|
1147
|
+
limit: options.limit,
|
|
1148
|
+
filter: options.filter
|
|
1149
|
+
};
|
|
1150
|
+
const query = serializeListOptions(sanitizedOptions);
|
|
1151
|
+
const res = await doFetch(`${base}/agents`, {
|
|
1152
|
+
method: "GET",
|
|
1153
|
+
query
|
|
1154
|
+
});
|
|
1155
|
+
return res.json();
|
|
1156
|
+
};
|
|
1157
|
+
const listAgents = async (options = {}) => {
|
|
1158
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1159
|
+
const response = await fetchAgentsPage(normalizedOptions);
|
|
1160
|
+
return attachPaginator(response, fetchAgentsPage, normalizedOptions);
|
|
1161
|
+
};
|
|
1162
|
+
const getAgentDetail = async (agentId) => {
|
|
1163
|
+
requireWorkspace();
|
|
1164
|
+
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1165
|
+
method: "GET"
|
|
1166
|
+
});
|
|
1167
|
+
return res.json();
|
|
1168
|
+
};
|
|
1169
|
+
const createAgent = async (payload) => {
|
|
1170
|
+
requireWorkspace();
|
|
1171
|
+
const res = await doFetch(`${base}/agents`, {
|
|
1253
1172
|
method: "POST",
|
|
1254
1173
|
body: JSON.stringify(payload),
|
|
1255
1174
|
headers: jsonHeaders
|
|
1256
1175
|
});
|
|
1257
1176
|
return res.json();
|
|
1258
1177
|
};
|
|
1259
|
-
const
|
|
1178
|
+
const forkAgentFromTemplate = async (payload) => {
|
|
1260
1179
|
requireWorkspace();
|
|
1261
|
-
const
|
|
1262
|
-
const fx = cfg.fetchImpl ?? fetch;
|
|
1263
|
-
const res = await fx(url, {
|
|
1180
|
+
const res = await doFetch(`${base}/agents/from-template`, {
|
|
1264
1181
|
method: "POST",
|
|
1265
1182
|
body: JSON.stringify(payload),
|
|
1266
|
-
headers
|
|
1183
|
+
headers: jsonHeaders
|
|
1267
1184
|
});
|
|
1268
|
-
|
|
1269
|
-
const body = await res.text();
|
|
1270
|
-
throw new Error(`POST ${url} failed with status ${res.status}: ${body}`);
|
|
1271
|
-
}
|
|
1272
|
-
const contentType = res.headers.get("content-type") ?? "";
|
|
1273
|
-
if (contentType.includes("application/json")) {
|
|
1274
|
-
const agent = await res.json();
|
|
1275
|
-
callbacks.onAgentCreated?.(agent);
|
|
1276
|
-
return agent;
|
|
1277
|
-
}
|
|
1278
|
-
return consumeSseStream(
|
|
1279
|
-
res,
|
|
1280
|
-
buildSseHandlers(callbacks),
|
|
1281
|
-
"agent-created"
|
|
1282
|
-
);
|
|
1185
|
+
return res.json();
|
|
1283
1186
|
};
|
|
1284
|
-
const
|
|
1187
|
+
const cloneAgent = async (agentId, payload) => {
|
|
1285
1188
|
requireWorkspace();
|
|
1286
|
-
const
|
|
1287
|
-
const
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
const contentType = res.headers.get("content-type") ?? "";
|
|
1294
|
-
if (contentType.includes("application/json")) {
|
|
1295
|
-
const agent = await res.json();
|
|
1296
|
-
callbacks.onAgentCreated?.(agent);
|
|
1297
|
-
return agent;
|
|
1298
|
-
}
|
|
1299
|
-
return consumeSseStream(
|
|
1300
|
-
res,
|
|
1301
|
-
buildSseHandlers(callbacks),
|
|
1302
|
-
"agent-created"
|
|
1303
|
-
);
|
|
1189
|
+
const requestPayload = buildCloneAgentRequest(payload);
|
|
1190
|
+
const res = await doFetch(`${base}/agents/${agentId}/clone`, {
|
|
1191
|
+
method: "POST",
|
|
1192
|
+
body: JSON.stringify(requestPayload),
|
|
1193
|
+
headers: jsonHeaders
|
|
1194
|
+
});
|
|
1195
|
+
return res.json();
|
|
1304
1196
|
};
|
|
1305
|
-
const
|
|
1197
|
+
const updateAgent = async (agentId, payload) => {
|
|
1306
1198
|
requireWorkspace();
|
|
1307
|
-
const
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1199
|
+
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1200
|
+
method: "PATCH",
|
|
1201
|
+
body: JSON.stringify(payload),
|
|
1202
|
+
headers: jsonHeaders
|
|
1311
1203
|
});
|
|
1312
|
-
const res = await doFetch(`${base}/agents`, { method: "GET", query });
|
|
1313
1204
|
return res.json();
|
|
1314
1205
|
};
|
|
1206
|
+
const resolveAgentId = (agent) => {
|
|
1207
|
+
return typeof agent === "string" ? agent : agent.agentId;
|
|
1208
|
+
};
|
|
1209
|
+
const deleteAgent = async (agent) => {
|
|
1210
|
+
requireWorkspace();
|
|
1211
|
+
const agentId = resolveAgentId(agent);
|
|
1212
|
+
await doFetch(`${base}/agents/${agentId}`, {
|
|
1213
|
+
method: "DELETE"
|
|
1214
|
+
});
|
|
1215
|
+
};
|
|
1315
1216
|
const baseApi = {
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
return getWithSse(`${base}/agents/${agentId}`, callbacks);
|
|
1324
|
-
}
|
|
1325
|
-
requireWorkspace();
|
|
1326
|
-
const res = await doFetch(`${base}/agents/${agentId}`, { method: "GET" });
|
|
1327
|
-
return res.json();
|
|
1328
|
-
},
|
|
1329
|
-
async create(payload, callbacks) {
|
|
1330
|
-
if (callbacks) {
|
|
1331
|
-
return postWithSse(`${base}/agents`, payload, callbacks);
|
|
1332
|
-
}
|
|
1333
|
-
return postJson(`${base}/agents`, payload);
|
|
1334
|
-
},
|
|
1335
|
-
async clone(agentId, payload) {
|
|
1336
|
-
return postJson(
|
|
1337
|
-
`${base}/agents/${agentId}/clone`,
|
|
1338
|
-
buildCloneRequest(payload)
|
|
1339
|
-
);
|
|
1340
|
-
},
|
|
1341
|
-
async forkFromTemplate(payload, callbacks) {
|
|
1342
|
-
if (callbacks) {
|
|
1343
|
-
return postWithSse(`${base}/agents/from-template`, payload, callbacks);
|
|
1344
|
-
}
|
|
1345
|
-
return postJson(`${base}/agents/from-template`, payload);
|
|
1346
|
-
},
|
|
1347
|
-
async update(agentId, payload) {
|
|
1348
|
-
requireWorkspace();
|
|
1349
|
-
const res = await doFetch(`${base}/agents/${agentId}`, {
|
|
1350
|
-
method: "PATCH",
|
|
1351
|
-
body: JSON.stringify(payload),
|
|
1352
|
-
headers: jsonHeaders
|
|
1353
|
-
});
|
|
1354
|
-
return res.json();
|
|
1355
|
-
},
|
|
1356
|
-
async delete(agent) {
|
|
1357
|
-
requireWorkspace();
|
|
1358
|
-
await doFetch(`${base}/agents/${resolveAgentId(agent)}`, {
|
|
1359
|
-
method: "DELETE"
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1217
|
+
list: listAgents,
|
|
1218
|
+
get: getAgentDetail,
|
|
1219
|
+
create: createAgent,
|
|
1220
|
+
clone: cloneAgent,
|
|
1221
|
+
forkFromTemplate: forkAgentFromTemplate,
|
|
1222
|
+
update: updateAgent,
|
|
1223
|
+
delete: deleteAgent
|
|
1362
1224
|
};
|
|
1363
1225
|
if (!relatedApis) {
|
|
1364
1226
|
return baseApi;
|
|
1365
1227
|
}
|
|
1366
|
-
return withEntityWrapping(baseApi, fetchPage, relatedApis);
|
|
1367
|
-
}
|
|
1368
|
-
function withEntityWrapping(api, fetchPage, deps) {
|
|
1369
1228
|
const wrapAgent = (detail) => createAgentEntity(detail, {
|
|
1370
|
-
|
|
1229
|
+
tagsApi: relatedApis.tagsApi,
|
|
1230
|
+
phonesApi: relatedApis.phonesApi,
|
|
1231
|
+
scheduleApi: relatedApis.scheduleApi,
|
|
1232
|
+
scheduleExceptionsApi: relatedApis.scheduleExceptionsApi,
|
|
1233
|
+
versionsApi: relatedApis.versionsApi,
|
|
1234
|
+
blueprintsApi: relatedApis.blueprintsApi,
|
|
1235
|
+
stagesApi: relatedApis.stagesApi,
|
|
1236
|
+
stageTriggersApi: relatedApis.stageTriggersApi,
|
|
1371
1237
|
reload: async (agentId) => {
|
|
1372
|
-
const latest = await
|
|
1238
|
+
const latest = await getAgentDetail(agentId);
|
|
1373
1239
|
return wrapAgent(latest);
|
|
1374
1240
|
},
|
|
1375
1241
|
updateAgent: async (agentId, payload) => {
|
|
1376
|
-
const updated = await
|
|
1242
|
+
const updated = await updateAgent(agentId, payload);
|
|
1377
1243
|
return wrapAgent(updated);
|
|
1378
1244
|
},
|
|
1379
1245
|
deleteAgent: async (agentId) => {
|
|
1380
|
-
await
|
|
1246
|
+
await deleteAgent(agentId);
|
|
1381
1247
|
},
|
|
1382
1248
|
cloneAgent: async (agentId, payload) => {
|
|
1383
|
-
const cloned = await
|
|
1249
|
+
const cloned = await cloneAgent(agentId, payload);
|
|
1384
1250
|
return wrapAgent(cloned);
|
|
1385
1251
|
}
|
|
1386
1252
|
});
|
|
1387
|
-
const wrapList = async (opts) => {
|
|
1388
|
-
const result = await fetchPage(opts);
|
|
1389
|
-
const items = Array.isArray(result.data) ? result.data : [];
|
|
1390
|
-
return { ...result, data: items.map(wrapAgent) };
|
|
1391
|
-
};
|
|
1392
1253
|
return {
|
|
1393
|
-
...
|
|
1254
|
+
...baseApi,
|
|
1394
1255
|
async list(options = {}) {
|
|
1395
|
-
const
|
|
1396
|
-
const
|
|
1397
|
-
|
|
1256
|
+
const normalizedOptions = { ...options ?? {} };
|
|
1257
|
+
const applyWrap = async (opts) => {
|
|
1258
|
+
const result = await fetchAgentsPage(opts);
|
|
1259
|
+
const items = Array.isArray(result.data) ? result.data : [];
|
|
1260
|
+
return {
|
|
1261
|
+
...result,
|
|
1262
|
+
data: items.map((summary) => wrapAgent(summary))
|
|
1263
|
+
};
|
|
1264
|
+
};
|
|
1265
|
+
const initial = await applyWrap(normalizedOptions);
|
|
1266
|
+
return attachPaginator(initial, applyWrap, normalizedOptions);
|
|
1398
1267
|
},
|
|
1399
|
-
async get(agentId
|
|
1400
|
-
|
|
1268
|
+
async get(agentId) {
|
|
1269
|
+
const detail = await getAgentDetail(agentId);
|
|
1270
|
+
return wrapAgent(detail);
|
|
1401
1271
|
},
|
|
1402
|
-
async create(payload
|
|
1403
|
-
|
|
1272
|
+
async create(payload) {
|
|
1273
|
+
const detail = await createAgent(payload);
|
|
1274
|
+
return wrapAgent(detail);
|
|
1404
1275
|
},
|
|
1405
1276
|
async clone(agentId, payload) {
|
|
1406
|
-
|
|
1277
|
+
const detail = await cloneAgent(agentId, payload);
|
|
1278
|
+
return wrapAgent(detail);
|
|
1407
1279
|
},
|
|
1408
|
-
async forkFromTemplate(payload
|
|
1409
|
-
|
|
1280
|
+
async forkFromTemplate(payload) {
|
|
1281
|
+
const detail = await forkAgentFromTemplate(payload);
|
|
1282
|
+
return wrapAgent(detail);
|
|
1410
1283
|
},
|
|
1411
1284
|
async update(agentId, payload) {
|
|
1412
|
-
|
|
1285
|
+
const detail = await updateAgent(agentId, payload);
|
|
1286
|
+
return wrapAgent(detail);
|
|
1413
1287
|
}
|
|
1414
1288
|
};
|
|
1415
1289
|
}
|
|
@@ -1536,10 +1410,7 @@ function createCampaignsApi(cfg) {
|
|
|
1536
1410
|
return res.json();
|
|
1537
1411
|
};
|
|
1538
1412
|
const fetchExecutionsPage = async (campaignId, options = {}) => {
|
|
1539
|
-
const query = serializeListOptions({
|
|
1540
|
-
page: options.page,
|
|
1541
|
-
limit: options.limit
|
|
1542
|
-
});
|
|
1413
|
+
const query = serializeListOptions(options ?? {});
|
|
1543
1414
|
const res = await doFetch(`${base}/campaigns/${campaignId}/executions`, {
|
|
1544
1415
|
method: "GET",
|
|
1545
1416
|
query
|
|
@@ -1593,6 +1464,51 @@ function createCampaignsApi(cfg) {
|
|
|
1593
1464
|
const response = await fetchExecutionsPage(campaignId, normalizedOptions);
|
|
1594
1465
|
const fetchPage = (opts) => fetchExecutionsPage(campaignId, opts);
|
|
1595
1466
|
return attachPaginator(response, fetchPage, normalizedOptions);
|
|
1467
|
+
},
|
|
1468
|
+
/**
|
|
1469
|
+
* Pausa una campaña en curso. Los reintentos ya programados se
|
|
1470
|
+
* reagendan al ejecutarse (sin consumir intentos) hasta `resume()`.
|
|
1471
|
+
*/
|
|
1472
|
+
async pause(campaignId) {
|
|
1473
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/pause`, {
|
|
1474
|
+
method: "POST"
|
|
1475
|
+
});
|
|
1476
|
+
return res.json();
|
|
1477
|
+
},
|
|
1478
|
+
/**
|
|
1479
|
+
* Reanuda una campaña pausada. Re-encola los reintentos pendientes
|
|
1480
|
+
* según su `nextRetryAt`.
|
|
1481
|
+
*/
|
|
1482
|
+
async resume(campaignId) {
|
|
1483
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/resume`, {
|
|
1484
|
+
method: "POST"
|
|
1485
|
+
});
|
|
1486
|
+
return res.json();
|
|
1487
|
+
},
|
|
1488
|
+
/**
|
|
1489
|
+
* Cancela definitivamente una campaña no terminal. Los reintentos
|
|
1490
|
+
* pendientes se descartan — operación destructiva.
|
|
1491
|
+
*/
|
|
1492
|
+
async cancel(campaignId) {
|
|
1493
|
+
const res = await doFetch(`${base}/campaigns/${campaignId}/cancel`, {
|
|
1494
|
+
method: "POST"
|
|
1495
|
+
});
|
|
1496
|
+
return res.json();
|
|
1497
|
+
},
|
|
1498
|
+
/**
|
|
1499
|
+
* Descarga el CSV con todas las ejecuciones de la campaña. Devuelve un
|
|
1500
|
+
* `Blob` con `text/csv; charset=utf-8` (BOM UTF-8 incluido). Para
|
|
1501
|
+
* campañas > 20,000 filas la API responde 413.
|
|
1502
|
+
*/
|
|
1503
|
+
async exportExecutions(campaignId) {
|
|
1504
|
+
const res = await doFetch(
|
|
1505
|
+
`${base}/campaigns/${campaignId}/executions/export`,
|
|
1506
|
+
{
|
|
1507
|
+
method: "GET",
|
|
1508
|
+
headers: { Accept: "text/csv" }
|
|
1509
|
+
}
|
|
1510
|
+
);
|
|
1511
|
+
return res.blob();
|
|
1596
1512
|
}
|
|
1597
1513
|
};
|
|
1598
1514
|
}
|
|
@@ -1673,34 +1589,6 @@ function createCatalogsApi(cfg) {
|
|
|
1673
1589
|
};
|
|
1674
1590
|
}
|
|
1675
1591
|
|
|
1676
|
-
// src/api/documents.ts
|
|
1677
|
-
function createDocumentsApi(cfg) {
|
|
1678
|
-
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1679
|
-
const jsonHeaders = { "content-type": "application/json" };
|
|
1680
|
-
const requireWorkspace = () => {
|
|
1681
|
-
const workspaceId = resolveWorkspaceId();
|
|
1682
|
-
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
1683
|
-
return;
|
|
1684
|
-
}
|
|
1685
|
-
const apiKey = resolveApiKey();
|
|
1686
|
-
if (typeof apiKey === "string" && apiKey.trim().length > 0) {
|
|
1687
|
-
return;
|
|
1688
|
-
}
|
|
1689
|
-
throw new WorkspaceNotSelectedError();
|
|
1690
|
-
};
|
|
1691
|
-
return {
|
|
1692
|
-
async create(files) {
|
|
1693
|
-
requireWorkspace();
|
|
1694
|
-
const res = await doFetch(`${base}/documents`, {
|
|
1695
|
-
method: "POST",
|
|
1696
|
-
body: JSON.stringify({ files }),
|
|
1697
|
-
headers: jsonHeaders
|
|
1698
|
-
});
|
|
1699
|
-
return res.json();
|
|
1700
|
-
}
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
1592
|
// src/api/sip-trunks.ts
|
|
1705
1593
|
function createSipTrunksApi(cfg) {
|
|
1706
1594
|
const { base, doFetch } = createHttp(cfg);
|
|
@@ -2498,7 +2386,6 @@ function createClient(initialCfg) {
|
|
|
2498
2386
|
...catalogsApi,
|
|
2499
2387
|
templates: catalogTemplatesApi
|
|
2500
2388
|
},
|
|
2501
|
-
documents: createDocumentsApi(runtimeCfg),
|
|
2502
2389
|
campaigns: createCampaignsApi(runtimeCfg),
|
|
2503
2390
|
voices: voicesApi,
|
|
2504
2391
|
apiKeys: apiKeysApi,
|
|
@@ -2594,7 +2481,6 @@ export {
|
|
|
2594
2481
|
createCatalogTemplatesApi,
|
|
2595
2482
|
createCatalogsApi,
|
|
2596
2483
|
createClient,
|
|
2597
|
-
createDocumentsApi,
|
|
2598
2484
|
createHttp,
|
|
2599
2485
|
createSipTrunksApi,
|
|
2600
2486
|
createToolsApi,
|