glitchgrab 1.66.2 → 1.68.0
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 +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -5
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +33 -9
- package/dist/server.d.ts +33 -9
- package/dist/server.js +22 -3
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +21 -3
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -250,6 +250,7 @@ function signSession(options) {
|
|
|
250
250
|
}
|
|
251
251
|
var GUIDES_REVALIDATE_SECONDS = 300;
|
|
252
252
|
var SDK_API_TIMEOUT_MS = 5e3;
|
|
253
|
+
var SDK_LINE_REQUEST_TIMEOUT_MS = 4e4;
|
|
253
254
|
async function callSdkApi(path, token, options, init) {
|
|
254
255
|
var _a, _b, _c, _d, _e, _f;
|
|
255
256
|
const baseUrl = ((_c = (_b = (_a = options.baseUrl) != null ? _a : defaults.baseUrl) != null ? _b : readEnv("GLITCHGRAB_BASE_URL")) != null ? _c : DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
@@ -277,7 +278,10 @@ async function callSdkApi(path, token, options, init) {
|
|
|
277
278
|
};
|
|
278
279
|
}
|
|
279
280
|
return { data: (_f = body.data) != null ? _f : null, error: null };
|
|
280
|
-
} catch (
|
|
281
|
+
} catch (err) {
|
|
282
|
+
if ((controller == null ? void 0 : controller.signal.aborted) || err instanceof Error && err.name === "AbortError") {
|
|
283
|
+
return { data: null, error: "Glitchgrab took too long", code: "TIMEOUT" };
|
|
284
|
+
}
|
|
281
285
|
return { data: null, error: "Could not reach Glitchgrab" };
|
|
282
286
|
} finally {
|
|
283
287
|
if (timer) clearTimeout(timer);
|
|
@@ -734,6 +738,9 @@ function readFollowUp(value) {
|
|
|
734
738
|
lastNoteAt: stringOrNull(value.lastNoteAt),
|
|
735
739
|
lastNoteBy: stringOrNull(value.lastNoteBy),
|
|
736
740
|
noteCount: (_a = numberOrNull(value.noteCount)) != null ? _a : 0,
|
|
741
|
+
callCount: numberOrNull(value.callCount),
|
|
742
|
+
talkedCount: numberOrNull(value.talkedCount),
|
|
743
|
+
talkSec: numberOrNull(value.talkSec),
|
|
737
744
|
lastCall: call ? {
|
|
738
745
|
id: call.id,
|
|
739
746
|
status: stringOrNull(call.status),
|
|
@@ -781,7 +788,8 @@ function readFollowUpDetail(value) {
|
|
|
781
788
|
operatorName: stringOrNull(c.operatorName),
|
|
782
789
|
shared: c.shared === true,
|
|
783
790
|
overview: stringOrNull(c.overview),
|
|
784
|
-
recordingUrl: stringOrNull(c.recordingUrl)
|
|
791
|
+
recordingUrl: stringOrNull(c.recordingUrl),
|
|
792
|
+
fromCallNoteAt: stringOrNull(c.fromCallNoteAt)
|
|
785
793
|
};
|
|
786
794
|
}) : []
|
|
787
795
|
};
|
|
@@ -968,10 +976,16 @@ async function getPhoneLine(params = {}, options = {}) {
|
|
|
968
976
|
}
|
|
969
977
|
}
|
|
970
978
|
async function lineRequestCall(path, body, options) {
|
|
979
|
+
var _a;
|
|
971
980
|
try {
|
|
972
981
|
const key = callsKey(options);
|
|
973
982
|
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
974
|
-
const { data, error, code } = await callSdkApi(
|
|
983
|
+
const { data, error, code } = await callSdkApi(
|
|
984
|
+
path,
|
|
985
|
+
key,
|
|
986
|
+
{ ...options, timeoutMs: (_a = options.timeoutMs) != null ? _a : SDK_LINE_REQUEST_TIMEOUT_MS },
|
|
987
|
+
{ method: "POST", body, cache: "no-store" }
|
|
988
|
+
);
|
|
975
989
|
const request = isRecord(data) ? lineRequestOf(data.request) : null;
|
|
976
990
|
if (error !== null || !request) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
977
991
|
return { ok: true, request };
|
|
@@ -994,6 +1008,9 @@ function enableCalling(params, options = {}) {
|
|
|
994
1008
|
function disableCalling(params, options = {}) {
|
|
995
1009
|
return lineRequestCall("/api/v1/sdk/phone-lines/disable", params, options);
|
|
996
1010
|
}
|
|
1011
|
+
function changeLineNumber(params, options = {}) {
|
|
1012
|
+
return lineRequestCall("/api/v1/sdk/phone-lines/change", params, options);
|
|
1013
|
+
}
|
|
997
1014
|
async function registerWebhook(webhook, options = {}) {
|
|
998
1015
|
try {
|
|
999
1016
|
const key = callsKey(options);
|
|
@@ -1130,6 +1147,7 @@ export {
|
|
|
1130
1147
|
addRingNumber,
|
|
1131
1148
|
cancelBooking,
|
|
1132
1149
|
captureServerErrors,
|
|
1150
|
+
changeLineNumber,
|
|
1133
1151
|
configureServerReporter,
|
|
1134
1152
|
createCallIssueSession,
|
|
1135
1153
|
deleteCall,
|