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 CHANGED
@@ -365,6 +365,21 @@ await testRingNumber(id); // ring again if they missed it
365
365
 
366
366
  A number is never rung for a call until whoever holds it presses 1 on the test ring, and the project owner is emailed every time one is verified — so a leaked server key adding its own phone does not go unnoticed.
367
367
 
368
+ ### Add a caller from your product
369
+
370
+ Someone not on the line yet (a new super admin) can be put on it by your key, so nobody opens Glitchgrab. Repeating it with the same email returns the same caller (`created: false`).
371
+
372
+ ```ts
373
+ import { addLineCaller, removeLineCaller, addRingNumber } from "glitchgrab/server";
374
+
375
+ const r = await addLineCaller({ email: "admin@you.in", name: "Vivek" });
376
+ if (!r.ok) showError(r.code); // NO_LINE | CALLERS_OFF | CALLER_CAP
377
+ await addRingNumber({ email: "admin@you.in" }, { phone: "98765 43210" }); // they press 1, then they can call
378
+ await removeLineCaller("admin@you.in"); // when they leave your admin team
379
+ ```
380
+
381
+ A caller your key added is rung only on phones they confirmed with press 1 — never an account number — so `dialFollowUp` answers `NO_VERIFIED_NUMBER` until they do. At most 10 per line; the line's owner is emailed for each one and can switch this off on the line in Glitchgrab (`CALLERS_OFF`).
382
+
368
383
  `ringPhone` omitted = their Default. While a call is still `DIALING`, `lastCall.ringingPhone` is the phone ringing now; `ringingIndex` above 0 means a backup.
369
384
 
370
385
  ## What keyboard shortcuts are available?
package/dist/server.d.mts CHANGED
@@ -812,6 +812,45 @@ type OperatorRingNumbersResult = {
812
812
  * ```
813
813
  */
814
814
  declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<OperatorRingNumbersResult>;
815
+ type LineCallerResult = {
816
+ ok: true;
817
+ created: boolean;
818
+ operator: {
819
+ name: string | null;
820
+ };
821
+ numbers: OperatorRingNumber[];
822
+ } | {
823
+ ok: false;
824
+ error: string;
825
+ code?: string;
826
+ };
827
+ /**
828
+ * Put someone on the project's phone line from your product (#662), so nobody
829
+ * opens Glitchgrab to let a new admin call. Idempotent on email: someone
830
+ * already on the line comes back with `created: false`.
831
+ *
832
+ * They ring only phones confirmed with press 1 — add one with
833
+ * {@link addRingNumber} right after (`numbers: []` until then, and a dial
834
+ * answers `NO_VERIFIED_NUMBER`). Refusals carry `code`: `NO_LINE`,
835
+ * `CALLERS_OFF` (the line's owner switched it off), `CALLER_CAP` (10 per line).
836
+ * Never throws.
837
+ *
838
+ * ```ts
839
+ * const r = await addLineCaller({ email: admin.email, name: admin.name });
840
+ * if (r.ok) openMyPhones(r.numbers);
841
+ * ```
842
+ */
843
+ declare function addLineCaller(caller: {
844
+ email: string;
845
+ name: string;
846
+ phone?: string;
847
+ }, options?: CallsOptions): Promise<LineCallerResult>;
848
+ /**
849
+ * Take a caller your key added off the line, with the phones kept for them —
850
+ * e.g. when they leave your admin team. Someone the line's owner added →
851
+ * `code: "NOT_KEY_CALLER"`. Never throws.
852
+ */
853
+ declare function removeLineCaller(email: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
815
854
  /** One saved ring number, verified or not — the management view (#654). */
816
855
  interface RingNumber {
817
856
  id: string;
@@ -876,4 +915,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
876
915
  verified: boolean;
877
916
  }>>;
878
917
 
879
- export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
918
+ export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
package/dist/server.d.ts CHANGED
@@ -812,6 +812,45 @@ type OperatorRingNumbersResult = {
812
812
  * ```
813
813
  */
814
814
  declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<OperatorRingNumbersResult>;
815
+ type LineCallerResult = {
816
+ ok: true;
817
+ created: boolean;
818
+ operator: {
819
+ name: string | null;
820
+ };
821
+ numbers: OperatorRingNumber[];
822
+ } | {
823
+ ok: false;
824
+ error: string;
825
+ code?: string;
826
+ };
827
+ /**
828
+ * Put someone on the project's phone line from your product (#662), so nobody
829
+ * opens Glitchgrab to let a new admin call. Idempotent on email: someone
830
+ * already on the line comes back with `created: false`.
831
+ *
832
+ * They ring only phones confirmed with press 1 — add one with
833
+ * {@link addRingNumber} right after (`numbers: []` until then, and a dial
834
+ * answers `NO_VERIFIED_NUMBER`). Refusals carry `code`: `NO_LINE`,
835
+ * `CALLERS_OFF` (the line's owner switched it off), `CALLER_CAP` (10 per line).
836
+ * Never throws.
837
+ *
838
+ * ```ts
839
+ * const r = await addLineCaller({ email: admin.email, name: admin.name });
840
+ * if (r.ok) openMyPhones(r.numbers);
841
+ * ```
842
+ */
843
+ declare function addLineCaller(caller: {
844
+ email: string;
845
+ name: string;
846
+ phone?: string;
847
+ }, options?: CallsOptions): Promise<LineCallerResult>;
848
+ /**
849
+ * Take a caller your key added off the line, with the phones kept for them —
850
+ * e.g. when they leave your admin team. Someone the line's owner added →
851
+ * `code: "NOT_KEY_CALLER"`. Never throws.
852
+ */
853
+ declare function removeLineCaller(email: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
815
854
  /** One saved ring number, verified or not — the management view (#654). */
816
855
  interface RingNumber {
817
856
  id: string;
@@ -876,4 +915,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
876
915
  verified: boolean;
877
916
  }>>;
878
917
 
879
- export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
918
+ export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, publishBookingQuestions, removeLineCaller, removeRingNumber, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, testRingNumber, updateBookingSettings, updateRingNumber };
package/dist/server.js CHANGED
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var server_exports = {};
22
22
  __export(server_exports, {
23
23
  addFollowUpNote: () => addFollowUpNote,
24
+ addLineCaller: () => addLineCaller,
24
25
  addRingNumber: () => addRingNumber,
25
26
  cancelBooking: () => cancelBooking,
26
27
  captureServerErrors: () => captureServerErrors,
@@ -41,6 +42,7 @@ __export(server_exports, {
41
42
  listLeads: () => listLeads,
42
43
  listRingNumbers: () => listRingNumbers,
43
44
  publishBookingQuestions: () => publishBookingQuestions,
45
+ removeLineCaller: () => removeLineCaller,
44
46
  removeRingNumber: () => removeRingNumber,
45
47
  reportServerError: () => reportServerError,
46
48
  rescheduleBooking: () => rescheduleBooking,
@@ -868,24 +870,50 @@ async function getOperatorRingNumbers(operator, options = {}) {
868
870
  cache: "no-store"
869
871
  });
870
872
  if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
871
- const op = isRecord(data.operator) ? data.operator : {};
872
- return {
873
- ok: true,
874
- operator: { name: stringOrNull(op.name) },
875
- numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
876
- var _a;
877
- return {
878
- phone: n.phone,
879
- label: stringOrNull(n.label),
880
- isDefault: n.isDefault === true,
881
- order: (_a = numberOrNull(n.order)) != null ? _a : 0
882
- };
883
- }) : []
884
- };
873
+ return { ok: true, ...operatorNumbersOf(data) };
874
+ } catch (e) {
875
+ return { ok: false, error: "Could not reach Glitchgrab" };
876
+ }
877
+ }
878
+ function operatorNumbersOf(data) {
879
+ const op = isRecord(data.operator) ? data.operator : {};
880
+ return {
881
+ operator: { name: stringOrNull(op.name) },
882
+ numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
883
+ var _a;
884
+ return {
885
+ phone: n.phone,
886
+ label: stringOrNull(n.label),
887
+ isDefault: n.isDefault === true,
888
+ order: (_a = numberOrNull(n.order)) != null ? _a : 0
889
+ };
890
+ }) : []
891
+ };
892
+ }
893
+ async function addLineCaller(caller, options = {}) {
894
+ try {
895
+ const key = callsKey(options);
896
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
897
+ const { data, error, code } = await callSdkApi("/api/v1/sdk/phone-lines/callers", key, options, {
898
+ method: "POST",
899
+ body: caller,
900
+ cache: "no-store"
901
+ });
902
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
903
+ return { ok: true, created: data.created === true, ...operatorNumbersOf(data) };
885
904
  } catch (e) {
886
905
  return { ok: false, error: "Could not reach Glitchgrab" };
887
906
  }
888
907
  }
908
+ function removeLineCaller(email, options = {}) {
909
+ return ringNumberWrite(
910
+ `/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
911
+ "DELETE",
912
+ void 0,
913
+ options,
914
+ () => ({})
915
+ );
916
+ }
889
917
  function ringNumbersPath(rest = "") {
890
918
  return `/api/v1/sdk/phone-lines/operator/numbers${rest}`;
891
919
  }
@@ -953,6 +981,7 @@ function testRingNumber(id, options = {}) {
953
981
  // Annotate the CommonJS export names for ESM import in node:
954
982
  0 && (module.exports = {
955
983
  addFollowUpNote,
984
+ addLineCaller,
956
985
  addRingNumber,
957
986
  cancelBooking,
958
987
  captureServerErrors,
@@ -973,6 +1002,7 @@ function testRingNumber(id, options = {}) {
973
1002
  listLeads,
974
1003
  listRingNumbers,
975
1004
  publishBookingQuestions,
1005
+ removeLineCaller,
976
1006
  removeRingNumber,
977
1007
  reportServerError,
978
1008
  rescheduleBooking,