glitchgrab 1.62.1 → 1.62.3

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/server.mjs CHANGED
@@ -737,6 +737,9 @@ function readFollowUpDetail(value) {
737
737
  durationSec: numberOrNull(c.durationSec),
738
738
  ringingIndex: numberOrNull(c.ringingIndex),
739
739
  ringingPhone: stringOrNull(c.ringingPhone),
740
+ to: stringOrNull(c.to),
741
+ missedBy: c.missedBy === "operator" || c.missedBy === "customer" ? c.missedBy : null,
742
+ operatorName: stringOrNull(c.operatorName),
740
743
  shared: c.shared === true,
741
744
  overview: stringOrNull(c.overview),
742
745
  recordingUrl: stringOrNull(c.recordingUrl)
@@ -815,24 +818,50 @@ async function getOperatorRingNumbers(operator, options = {}) {
815
818
  cache: "no-store"
816
819
  });
817
820
  if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
818
- const op = isRecord(data.operator) ? data.operator : {};
819
- return {
820
- ok: true,
821
- operator: { name: stringOrNull(op.name) },
822
- numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
823
- var _a;
824
- return {
825
- phone: n.phone,
826
- label: stringOrNull(n.label),
827
- isDefault: n.isDefault === true,
828
- order: (_a = numberOrNull(n.order)) != null ? _a : 0
829
- };
830
- }) : []
831
- };
821
+ return { ok: true, ...operatorNumbersOf(data) };
822
+ } catch (e) {
823
+ return { ok: false, error: "Could not reach Glitchgrab" };
824
+ }
825
+ }
826
+ function operatorNumbersOf(data) {
827
+ const op = isRecord(data.operator) ? data.operator : {};
828
+ return {
829
+ operator: { name: stringOrNull(op.name) },
830
+ numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
831
+ var _a;
832
+ return {
833
+ phone: n.phone,
834
+ label: stringOrNull(n.label),
835
+ isDefault: n.isDefault === true,
836
+ order: (_a = numberOrNull(n.order)) != null ? _a : 0
837
+ };
838
+ }) : []
839
+ };
840
+ }
841
+ async function addLineCaller(caller, options = {}) {
842
+ try {
843
+ const key = callsKey(options);
844
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
845
+ const { data, error, code } = await callSdkApi("/api/v1/sdk/phone-lines/callers", key, options, {
846
+ method: "POST",
847
+ body: caller,
848
+ cache: "no-store"
849
+ });
850
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
851
+ return { ok: true, created: data.created === true, ...operatorNumbersOf(data) };
832
852
  } catch (e) {
833
853
  return { ok: false, error: "Could not reach Glitchgrab" };
834
854
  }
835
855
  }
856
+ function removeLineCaller(email, options = {}) {
857
+ return ringNumberWrite(
858
+ `/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
859
+ "DELETE",
860
+ void 0,
861
+ options,
862
+ () => ({})
863
+ );
864
+ }
836
865
  function ringNumbersPath(rest = "") {
837
866
  return `/api/v1/sdk/phone-lines/operator/numbers${rest}`;
838
867
  }
@@ -899,6 +928,7 @@ function testRingNumber(id, options = {}) {
899
928
  }
900
929
  export {
901
930
  addFollowUpNote,
931
+ addLineCaller,
902
932
  addRingNumber,
903
933
  cancelBooking,
904
934
  captureServerErrors,
@@ -919,6 +949,7 @@ export {
919
949
  listLeads,
920
950
  listRingNumbers,
921
951
  publishBookingQuestions,
952
+ removeLineCaller,
922
953
  removeRingNumber,
923
954
  reportServerError,
924
955
  rescheduleBooking,