glitchgrab 1.64.0 → 1.65.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/dist/server.mjs CHANGED
@@ -832,12 +832,19 @@ function dialFollowUp(externalId, call, options = {}) {
832
832
  ringNumbers: Array.isArray(d.ringNumbers) ? d.ringNumbers.filter((n) => typeof n === "string") : []
833
833
  }));
834
834
  }
835
+ function ownerQuery(options) {
836
+ return options.ownerId ? `?ownerId=${encodeURIComponent(options.ownerId)}` : "";
837
+ }
838
+ function operatorQuery(operator, options) {
839
+ const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
840
+ if (options.ownerId) query.set("ownerId", options.ownerId);
841
+ return query.toString();
842
+ }
835
843
  async function getOperatorRingNumbers(operator, options = {}) {
836
844
  try {
837
845
  const key = callsKey(options);
838
846
  if (!key) return { ok: false, error: NO_KEY_ERROR };
839
- const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
840
- const { data, error, code } = await callSdkApi(`/api/v1/sdk/phone-lines/operator?${query.toString()}`, key, options, {
847
+ const { data, error, code } = await callSdkApi(`/api/v1/sdk/phone-lines/operator?${operatorQuery(operator, options)}`, key, options, {
841
848
  cache: "no-store"
842
849
  });
843
850
  if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
@@ -1012,7 +1019,7 @@ async function removeWebhook(id, options = {}) {
1012
1019
  }
1013
1020
  function removeLineCaller(email, options = {}) {
1014
1021
  return ringNumberWrite(
1015
- `/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
1022
+ `/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}${ownerQuery(options)}`,
1016
1023
  "DELETE",
1017
1024
  void 0,
1018
1025
  options,
@@ -1037,8 +1044,7 @@ async function listRingNumbers(operator, options = {}) {
1037
1044
  try {
1038
1045
  const key = callsKey(options);
1039
1046
  if (!key) return { ok: false, error: NO_KEY_ERROR };
1040
- const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
1041
- const { data, error, code } = await callSdkApi(ringNumbersPath(`?${query.toString()}`), key, options, {
1047
+ const { data, error, code } = await callSdkApi(ringNumbersPath(`?${operatorQuery(operator, options)}`), key, options, {
1042
1048
  cache: "no-store"
1043
1049
  });
1044
1050
  if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
@@ -1066,20 +1072,27 @@ async function listRingNumbers(operator, options = {}) {
1066
1072
  }
1067
1073
  }
1068
1074
  function addRingNumber(operator, number, options = {}) {
1069
- return ringNumberWrite(ringNumbersPath(), "POST", { operator, ...number }, options, (d) => ({
1075
+ const body = { operator, ...number, ...options.ownerId ? { ownerId: options.ownerId } : {} };
1076
+ return ringNumberWrite(ringNumbersPath(), "POST", body, options, (d) => ({
1070
1077
  id: typeof d.id === "string" ? d.id : "",
1071
1078
  testRing: d.testRing === "failed" ? "failed" : "ringing",
1072
1079
  verifyError: stringOrNull(d.verifyError)
1073
1080
  }));
1074
1081
  }
1075
1082
  function updateRingNumber(id, change, options = {}) {
1076
- return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}`), "PATCH", change, options, () => ({}));
1083
+ return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}${ownerQuery(options)}`), "PATCH", change, options, () => ({}));
1077
1084
  }
1078
1085
  function removeRingNumber(id, options = {}) {
1079
- return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}`), "DELETE", void 0, options, () => ({}));
1086
+ return ringNumberWrite(
1087
+ ringNumbersPath(`/${encodeURIComponent(id)}${ownerQuery(options)}`),
1088
+ "DELETE",
1089
+ void 0,
1090
+ options,
1091
+ () => ({})
1092
+ );
1080
1093
  }
1081
1094
  function testRingNumber(id, options = {}) {
1082
- return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}/verify`), "POST", void 0, options, (d) => ({
1095
+ return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}/verify${ownerQuery(options)}`), "POST", void 0, options, (d) => ({
1083
1096
  verified: d.verified === true
1084
1097
  }));
1085
1098
  }