@getsupervisor/agents-studio-sdk 1.41.2-patch.14 → 1.41.2-patch.16
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/README.md +39 -0
- package/dist/index.cjs +313 -117
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +180 -18
- package/dist/index.d.ts +180 -18
- package/dist/index.js +311 -117
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -890,6 +890,102 @@ 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
|
+
|
|
893
989
|
// src/entities/agent.ts
|
|
894
990
|
var bindAgentStageTriggers = (api, agentId, blueprintId, stageId) => ({
|
|
895
991
|
list(opts) {
|
|
@@ -1110,8 +1206,36 @@ var createAgentEntity = (dto, options) => {
|
|
|
1110
1206
|
};
|
|
1111
1207
|
|
|
1112
1208
|
// 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
|
+
}
|
|
1113
1236
|
function createAgentsApi(cfg, relatedApis) {
|
|
1114
|
-
const { base, doFetch, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1237
|
+
const { base, doFetch, buildHeaders, resolveWorkspaceId, resolveApiKey } = createHttp(cfg);
|
|
1238
|
+
const jsonHeaders = { "content-type": "application/json" };
|
|
1115
1239
|
const requireWorkspace = () => {
|
|
1116
1240
|
const workspaceId = resolveWorkspaceId();
|
|
1117
1241
|
if (typeof workspaceId === "string" && workspaceId.trim().length > 0) {
|
|
@@ -1123,167 +1247,169 @@ function createAgentsApi(cfg, relatedApis) {
|
|
|
1123
1247
|
}
|
|
1124
1248
|
throw new WorkspaceNotSelectedError();
|
|
1125
1249
|
};
|
|
1126
|
-
const
|
|
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 = {}) => {
|
|
1144
|
-
requireWorkspace();
|
|
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) => {
|
|
1250
|
+
const postJson = async (url, payload) => {
|
|
1170
1251
|
requireWorkspace();
|
|
1171
|
-
const res = await doFetch(
|
|
1252
|
+
const res = await doFetch(url, {
|
|
1172
1253
|
method: "POST",
|
|
1173
1254
|
body: JSON.stringify(payload),
|
|
1174
1255
|
headers: jsonHeaders
|
|
1175
1256
|
});
|
|
1176
1257
|
return res.json();
|
|
1177
1258
|
};
|
|
1178
|
-
const
|
|
1259
|
+
const postWithSse = async (url, payload, callbacks) => {
|
|
1179
1260
|
requireWorkspace();
|
|
1180
|
-
const
|
|
1261
|
+
const headers = buildHeaders({ "content-type": "application/json" });
|
|
1262
|
+
const fx = cfg.fetchImpl ?? fetch;
|
|
1263
|
+
const res = await fx(url, {
|
|
1181
1264
|
method: "POST",
|
|
1182
1265
|
body: JSON.stringify(payload),
|
|
1183
|
-
headers
|
|
1266
|
+
headers
|
|
1184
1267
|
});
|
|
1185
|
-
|
|
1268
|
+
if (!res.ok) {
|
|
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
|
+
);
|
|
1186
1283
|
};
|
|
1187
|
-
const
|
|
1284
|
+
const getWithSse = async (url, callbacks) => {
|
|
1188
1285
|
requireWorkspace();
|
|
1189
|
-
const
|
|
1190
|
-
const
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1286
|
+
const headers = buildHeaders({});
|
|
1287
|
+
const fx = cfg.fetchImpl ?? fetch;
|
|
1288
|
+
const res = await fx(url, { method: "GET", headers });
|
|
1289
|
+
if (!res.ok) {
|
|
1290
|
+
const body = await res.text();
|
|
1291
|
+
throw new Error(`GET ${url} failed with status ${res.status}: ${body}`);
|
|
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
|
+
);
|
|
1196
1304
|
};
|
|
1197
|
-
const
|
|
1305
|
+
const fetchPage = async (options = {}) => {
|
|
1198
1306
|
requireWorkspace();
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1307
|
+
const query = serializeListOptions({
|
|
1308
|
+
page: options.page,
|
|
1309
|
+
limit: options.limit,
|
|
1310
|
+
filter: options.filter
|
|
1203
1311
|
});
|
|
1312
|
+
const res = await doFetch(`${base}/agents`, { method: "GET", query });
|
|
1204
1313
|
return res.json();
|
|
1205
1314
|
};
|
|
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
|
-
};
|
|
1216
1315
|
const baseApi = {
|
|
1217
|
-
list
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1316
|
+
async list(options = {}) {
|
|
1317
|
+
const opts = { ...options ?? {} };
|
|
1318
|
+
const response = await fetchPage(opts);
|
|
1319
|
+
return attachPaginator(response, fetchPage, opts);
|
|
1320
|
+
},
|
|
1321
|
+
async get(agentId, callbacks) {
|
|
1322
|
+
if (callbacks) {
|
|
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
|
+
}
|
|
1224
1362
|
};
|
|
1225
1363
|
if (!relatedApis) {
|
|
1226
1364
|
return baseApi;
|
|
1227
1365
|
}
|
|
1366
|
+
return withEntityWrapping(baseApi, fetchPage, relatedApis);
|
|
1367
|
+
}
|
|
1368
|
+
function withEntityWrapping(api, fetchPage, deps) {
|
|
1228
1369
|
const wrapAgent = (detail) => createAgentEntity(detail, {
|
|
1229
|
-
|
|
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,
|
|
1370
|
+
...deps,
|
|
1237
1371
|
reload: async (agentId) => {
|
|
1238
|
-
const latest = await
|
|
1372
|
+
const latest = await api.get(agentId);
|
|
1239
1373
|
return wrapAgent(latest);
|
|
1240
1374
|
},
|
|
1241
1375
|
updateAgent: async (agentId, payload) => {
|
|
1242
|
-
const updated = await
|
|
1376
|
+
const updated = await api.update(agentId, payload);
|
|
1243
1377
|
return wrapAgent(updated);
|
|
1244
1378
|
},
|
|
1245
1379
|
deleteAgent: async (agentId) => {
|
|
1246
|
-
await
|
|
1380
|
+
await api.delete(agentId);
|
|
1247
1381
|
},
|
|
1248
1382
|
cloneAgent: async (agentId, payload) => {
|
|
1249
|
-
const cloned = await
|
|
1383
|
+
const cloned = await api.clone(agentId, payload);
|
|
1250
1384
|
return wrapAgent(cloned);
|
|
1251
1385
|
}
|
|
1252
1386
|
});
|
|
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
|
+
};
|
|
1253
1392
|
return {
|
|
1254
|
-
...
|
|
1393
|
+
...api,
|
|
1255
1394
|
async list(options = {}) {
|
|
1256
|
-
const
|
|
1257
|
-
const
|
|
1258
|
-
|
|
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);
|
|
1395
|
+
const opts = { ...options ?? {} };
|
|
1396
|
+
const initial = await wrapList(opts);
|
|
1397
|
+
return attachPaginator(initial, wrapList, opts);
|
|
1267
1398
|
},
|
|
1268
|
-
async get(agentId) {
|
|
1269
|
-
|
|
1270
|
-
return wrapAgent(detail);
|
|
1399
|
+
async get(agentId, callbacks) {
|
|
1400
|
+
return wrapAgent(await api.get(agentId, callbacks));
|
|
1271
1401
|
},
|
|
1272
|
-
async create(payload) {
|
|
1273
|
-
|
|
1274
|
-
return wrapAgent(detail);
|
|
1402
|
+
async create(payload, callbacks) {
|
|
1403
|
+
return wrapAgent(await api.create(payload, callbacks));
|
|
1275
1404
|
},
|
|
1276
1405
|
async clone(agentId, payload) {
|
|
1277
|
-
|
|
1278
|
-
return wrapAgent(detail);
|
|
1406
|
+
return wrapAgent(await api.clone(agentId, payload));
|
|
1279
1407
|
},
|
|
1280
|
-
async forkFromTemplate(payload) {
|
|
1281
|
-
|
|
1282
|
-
return wrapAgent(detail);
|
|
1408
|
+
async forkFromTemplate(payload, callbacks) {
|
|
1409
|
+
return wrapAgent(await api.forkFromTemplate(payload, callbacks));
|
|
1283
1410
|
},
|
|
1284
1411
|
async update(agentId, payload) {
|
|
1285
|
-
|
|
1286
|
-
return wrapAgent(detail);
|
|
1412
|
+
return wrapAgent(await api.update(agentId, payload));
|
|
1287
1413
|
}
|
|
1288
1414
|
};
|
|
1289
1415
|
}
|
|
@@ -1547,6 +1673,70 @@ function createCatalogsApi(cfg) {
|
|
|
1547
1673
|
};
|
|
1548
1674
|
}
|
|
1549
1675
|
|
|
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
|
+
// src/api/sip-trunks.ts
|
|
1705
|
+
function createSipTrunksApi(cfg) {
|
|
1706
|
+
const { base, doFetch } = createHttp(cfg);
|
|
1707
|
+
return {
|
|
1708
|
+
async list() {
|
|
1709
|
+
const res = await doFetch(`${base}/sip/trunks`, { method: "GET" });
|
|
1710
|
+
return res.json();
|
|
1711
|
+
},
|
|
1712
|
+
async get(trunkId) {
|
|
1713
|
+
const res = await doFetch(`${base}/sip/trunks/${trunkId}`, {
|
|
1714
|
+
method: "GET"
|
|
1715
|
+
});
|
|
1716
|
+
return res.json();
|
|
1717
|
+
},
|
|
1718
|
+
async create(body) {
|
|
1719
|
+
const res = await doFetch(`${base}/sip/trunks`, {
|
|
1720
|
+
method: "POST",
|
|
1721
|
+
headers: { "Content-Type": "application/json" },
|
|
1722
|
+
body: JSON.stringify(body)
|
|
1723
|
+
});
|
|
1724
|
+
return res.json();
|
|
1725
|
+
},
|
|
1726
|
+
async update(trunkId, body) {
|
|
1727
|
+
const res = await doFetch(`${base}/sip/trunks/${trunkId}`, {
|
|
1728
|
+
method: "PATCH",
|
|
1729
|
+
headers: { "Content-Type": "application/json" },
|
|
1730
|
+
body: JSON.stringify(body)
|
|
1731
|
+
});
|
|
1732
|
+
return res.json();
|
|
1733
|
+
},
|
|
1734
|
+
async delete(trunkId) {
|
|
1735
|
+
await doFetch(`${base}/sip/trunks/${trunkId}`, { method: "DELETE" });
|
|
1736
|
+
}
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1550
1740
|
// src/api/tools.ts
|
|
1551
1741
|
var IDEMPOTENCY_HEADER = "Idempotency-Key";
|
|
1552
1742
|
var generateIdempotencyKey = (explicit) => {
|
|
@@ -2308,12 +2498,14 @@ function createClient(initialCfg) {
|
|
|
2308
2498
|
...catalogsApi,
|
|
2309
2499
|
templates: catalogTemplatesApi
|
|
2310
2500
|
},
|
|
2501
|
+
documents: createDocumentsApi(runtimeCfg),
|
|
2311
2502
|
campaigns: createCampaignsApi(runtimeCfg),
|
|
2312
2503
|
voices: voicesApi,
|
|
2313
2504
|
apiKeys: apiKeysApi,
|
|
2314
2505
|
billing: createBillingApi(runtimeCfg),
|
|
2315
2506
|
calls: callsApi,
|
|
2316
2507
|
usage: createUsageApi(runtimeCfg),
|
|
2508
|
+
sip: createSipTrunksApi(runtimeCfg),
|
|
2317
2509
|
webhooks: webhooksApi
|
|
2318
2510
|
};
|
|
2319
2511
|
return {
|
|
@@ -2402,7 +2594,9 @@ export {
|
|
|
2402
2594
|
createCatalogTemplatesApi,
|
|
2403
2595
|
createCatalogsApi,
|
|
2404
2596
|
createClient,
|
|
2597
|
+
createDocumentsApi,
|
|
2405
2598
|
createHttp,
|
|
2599
|
+
createSipTrunksApi,
|
|
2406
2600
|
createToolsApi,
|
|
2407
2601
|
createUsageApi,
|
|
2408
2602
|
createVoicesApi,
|