glitchgrab 1.62.1 → 1.62.2
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 +15 -0
- package/dist/server.d.mts +40 -1
- package/dist/server.d.ts +40 -1
- package/dist/server.js +44 -14
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +42 -14
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.mjs
CHANGED
|
@@ -815,24 +815,50 @@ async function getOperatorRingNumbers(operator, options = {}) {
|
|
|
815
815
|
cache: "no-store"
|
|
816
816
|
});
|
|
817
817
|
if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
818
|
+
return { ok: true, ...operatorNumbersOf(data) };
|
|
819
|
+
} catch (e) {
|
|
820
|
+
return { ok: false, error: "Could not reach Glitchgrab" };
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
function operatorNumbersOf(data) {
|
|
824
|
+
const op = isRecord(data.operator) ? data.operator : {};
|
|
825
|
+
return {
|
|
826
|
+
operator: { name: stringOrNull(op.name) },
|
|
827
|
+
numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
|
|
828
|
+
var _a;
|
|
829
|
+
return {
|
|
830
|
+
phone: n.phone,
|
|
831
|
+
label: stringOrNull(n.label),
|
|
832
|
+
isDefault: n.isDefault === true,
|
|
833
|
+
order: (_a = numberOrNull(n.order)) != null ? _a : 0
|
|
834
|
+
};
|
|
835
|
+
}) : []
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
async function addLineCaller(caller, options = {}) {
|
|
839
|
+
try {
|
|
840
|
+
const key = callsKey(options);
|
|
841
|
+
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
842
|
+
const { data, error, code } = await callSdkApi("/api/v1/sdk/phone-lines/callers", key, options, {
|
|
843
|
+
method: "POST",
|
|
844
|
+
body: caller,
|
|
845
|
+
cache: "no-store"
|
|
846
|
+
});
|
|
847
|
+
if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
848
|
+
return { ok: true, created: data.created === true, ...operatorNumbersOf(data) };
|
|
832
849
|
} catch (e) {
|
|
833
850
|
return { ok: false, error: "Could not reach Glitchgrab" };
|
|
834
851
|
}
|
|
835
852
|
}
|
|
853
|
+
function removeLineCaller(email, options = {}) {
|
|
854
|
+
return ringNumberWrite(
|
|
855
|
+
`/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
|
|
856
|
+
"DELETE",
|
|
857
|
+
void 0,
|
|
858
|
+
options,
|
|
859
|
+
() => ({})
|
|
860
|
+
);
|
|
861
|
+
}
|
|
836
862
|
function ringNumbersPath(rest = "") {
|
|
837
863
|
return `/api/v1/sdk/phone-lines/operator/numbers${rest}`;
|
|
838
864
|
}
|
|
@@ -899,6 +925,7 @@ function testRingNumber(id, options = {}) {
|
|
|
899
925
|
}
|
|
900
926
|
export {
|
|
901
927
|
addFollowUpNote,
|
|
928
|
+
addLineCaller,
|
|
902
929
|
addRingNumber,
|
|
903
930
|
cancelBooking,
|
|
904
931
|
captureServerErrors,
|
|
@@ -919,6 +946,7 @@ export {
|
|
|
919
946
|
listLeads,
|
|
920
947
|
listRingNumbers,
|
|
921
948
|
publishBookingQuestions,
|
|
949
|
+
removeLineCaller,
|
|
922
950
|
removeRingNumber,
|
|
923
951
|
reportServerError,
|
|
924
952
|
rescheduleBooking,
|