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/README.md CHANGED
@@ -365,8 +365,36 @@ 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
 
385
+ ### Call another number, and see who missed it
386
+
387
+ `toPhone` rings a different number for one call — the follow-up's saved `phone` stays as it is, and it isn't checked against other follow-ups. (`phone` still rewrites the saved number.)
388
+
389
+ ```ts
390
+ await dialFollowUp(owner.id, { operator: { email: "admin@you.in" }, toPhone: "98200 00000" });
391
+
392
+ const detail = await getFollowUp(owner.id);
393
+ // detail.calls[i].to → "+919820000000", the number rung
394
+ // detail.calls[i].missedBy → "operator" (none of your phones picked up) | "customer" | null
395
+ // detail.calls[i].operatorName → who placed it
396
+ ```
397
+
370
398
  ## What keyboard shortcuts are available?
371
399
 
372
400
  Once `GlitchgrabProvider` is mounted, these shortcuts work globally:
package/dist/server.d.mts CHANGED
@@ -685,6 +685,16 @@ interface FollowUpCall {
685
685
  ringingIndex: number | null;
686
686
  /** That phone. While `status` is "DIALING" it is the one ringing right now. */
687
687
  ringingPhone: string | null;
688
+ /** E.164 number the call rang — `toPhone` when the dial sent one, else the follow-up's phone (#666). */
689
+ to: string | null;
690
+ /**
691
+ * Who didn't pick up a NO_ANSWER outbound call (#666): "operator" = none of
692
+ * the operator's phones (backups included), "customer" = the operator
693
+ * answered and the customer didn't. Null otherwise, and on older calls.
694
+ */
695
+ missedBy: "operator" | "customer" | null;
696
+ /** Who placed it. Null on inbound calls. */
697
+ operatorName: string | null;
688
698
  /** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
689
699
  shared: boolean;
690
700
  overview: string | null;
@@ -768,10 +778,14 @@ declare function setFollowUpBooking(externalId: string, booking: {
768
778
  * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
769
779
  * phone isn't picked up, their backups ring in order (`ringNumbers`). A
770
780
  * refusal carries `code` — see {@link RingErrorCode}.
781
+ *
782
+ * `toPhone` dials another number for this one call and leaves the follow-up's
783
+ * saved `phone` alone (#666); `phone` rewrites the saved number.
771
784
  */
772
785
  declare function dialFollowUp(externalId: string, call: {
773
786
  operator: FollowUpOperator;
774
787
  phone?: string;
788
+ toPhone?: string;
775
789
  name?: string;
776
790
  lineId?: string;
777
791
  ringPhone?: string;
@@ -812,6 +826,45 @@ type OperatorRingNumbersResult = {
812
826
  * ```
813
827
  */
814
828
  declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<OperatorRingNumbersResult>;
829
+ type LineCallerResult = {
830
+ ok: true;
831
+ created: boolean;
832
+ operator: {
833
+ name: string | null;
834
+ };
835
+ numbers: OperatorRingNumber[];
836
+ } | {
837
+ ok: false;
838
+ error: string;
839
+ code?: string;
840
+ };
841
+ /**
842
+ * Put someone on the project's phone line from your product (#662), so nobody
843
+ * opens Glitchgrab to let a new admin call. Idempotent on email: someone
844
+ * already on the line comes back with `created: false`.
845
+ *
846
+ * They ring only phones confirmed with press 1 — add one with
847
+ * {@link addRingNumber} right after (`numbers: []` until then, and a dial
848
+ * answers `NO_VERIFIED_NUMBER`). Refusals carry `code`: `NO_LINE`,
849
+ * `CALLERS_OFF` (the line's owner switched it off), `CALLER_CAP` (10 per line).
850
+ * Never throws.
851
+ *
852
+ * ```ts
853
+ * const r = await addLineCaller({ email: admin.email, name: admin.name });
854
+ * if (r.ok) openMyPhones(r.numbers);
855
+ * ```
856
+ */
857
+ declare function addLineCaller(caller: {
858
+ email: string;
859
+ name: string;
860
+ phone?: string;
861
+ }, options?: CallsOptions): Promise<LineCallerResult>;
862
+ /**
863
+ * Take a caller your key added off the line, with the phones kept for them —
864
+ * e.g. when they leave your admin team. Someone the line's owner added →
865
+ * `code: "NOT_KEY_CALLER"`. Never throws.
866
+ */
867
+ declare function removeLineCaller(email: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
815
868
  /** One saved ring number, verified or not — the management view (#654). */
816
869
  interface RingNumber {
817
870
  id: string;
@@ -876,4 +929,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
876
929
  verified: boolean;
877
930
  }>>;
878
931
 
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 };
932
+ 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
@@ -685,6 +685,16 @@ interface FollowUpCall {
685
685
  ringingIndex: number | null;
686
686
  /** That phone. While `status` is "DIALING" it is the one ringing right now. */
687
687
  ringingPhone: string | null;
688
+ /** E.164 number the call rang — `toPhone` when the dial sent one, else the follow-up's phone (#666). */
689
+ to: string | null;
690
+ /**
691
+ * Who didn't pick up a NO_ANSWER outbound call (#666): "operator" = none of
692
+ * the operator's phones (backups included), "customer" = the operator
693
+ * answered and the customer didn't. Null otherwise, and on older calls.
694
+ */
695
+ missedBy: "operator" | "customer" | null;
696
+ /** Who placed it. Null on inbound calls. */
697
+ operatorName: string | null;
688
698
  /** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
689
699
  shared: boolean;
690
700
  overview: string | null;
@@ -768,10 +778,14 @@ declare function setFollowUpBooking(externalId: string, booking: {
768
778
  * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
769
779
  * phone isn't picked up, their backups ring in order (`ringNumbers`). A
770
780
  * refusal carries `code` — see {@link RingErrorCode}.
781
+ *
782
+ * `toPhone` dials another number for this one call and leaves the follow-up's
783
+ * saved `phone` alone (#666); `phone` rewrites the saved number.
771
784
  */
772
785
  declare function dialFollowUp(externalId: string, call: {
773
786
  operator: FollowUpOperator;
774
787
  phone?: string;
788
+ toPhone?: string;
775
789
  name?: string;
776
790
  lineId?: string;
777
791
  ringPhone?: string;
@@ -812,6 +826,45 @@ type OperatorRingNumbersResult = {
812
826
  * ```
813
827
  */
814
828
  declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<OperatorRingNumbersResult>;
829
+ type LineCallerResult = {
830
+ ok: true;
831
+ created: boolean;
832
+ operator: {
833
+ name: string | null;
834
+ };
835
+ numbers: OperatorRingNumber[];
836
+ } | {
837
+ ok: false;
838
+ error: string;
839
+ code?: string;
840
+ };
841
+ /**
842
+ * Put someone on the project's phone line from your product (#662), so nobody
843
+ * opens Glitchgrab to let a new admin call. Idempotent on email: someone
844
+ * already on the line comes back with `created: false`.
845
+ *
846
+ * They ring only phones confirmed with press 1 — add one with
847
+ * {@link addRingNumber} right after (`numbers: []` until then, and a dial
848
+ * answers `NO_VERIFIED_NUMBER`). Refusals carry `code`: `NO_LINE`,
849
+ * `CALLERS_OFF` (the line's owner switched it off), `CALLER_CAP` (10 per line).
850
+ * Never throws.
851
+ *
852
+ * ```ts
853
+ * const r = await addLineCaller({ email: admin.email, name: admin.name });
854
+ * if (r.ok) openMyPhones(r.numbers);
855
+ * ```
856
+ */
857
+ declare function addLineCaller(caller: {
858
+ email: string;
859
+ name: string;
860
+ phone?: string;
861
+ }, options?: CallsOptions): Promise<LineCallerResult>;
862
+ /**
863
+ * Take a caller your key added off the line, with the phones kept for them —
864
+ * e.g. when they leave your admin team. Someone the line's owner added →
865
+ * `code: "NOT_KEY_CALLER"`. Never throws.
866
+ */
867
+ declare function removeLineCaller(email: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
815
868
  /** One saved ring number, verified or not — the management view (#654). */
816
869
  interface RingNumber {
817
870
  id: string;
@@ -876,4 +929,4 @@ declare function testRingNumber(id: string, options?: CallsOptions): Promise<Rin
876
929
  verified: boolean;
877
930
  }>>;
878
931
 
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 };
932
+ 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,
@@ -790,6 +792,9 @@ function readFollowUpDetail(value) {
790
792
  durationSec: numberOrNull(c.durationSec),
791
793
  ringingIndex: numberOrNull(c.ringingIndex),
792
794
  ringingPhone: stringOrNull(c.ringingPhone),
795
+ to: stringOrNull(c.to),
796
+ missedBy: c.missedBy === "operator" || c.missedBy === "customer" ? c.missedBy : null,
797
+ operatorName: stringOrNull(c.operatorName),
793
798
  shared: c.shared === true,
794
799
  overview: stringOrNull(c.overview),
795
800
  recordingUrl: stringOrNull(c.recordingUrl)
@@ -868,24 +873,50 @@ async function getOperatorRingNumbers(operator, options = {}) {
868
873
  cache: "no-store"
869
874
  });
870
875
  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
- };
876
+ return { ok: true, ...operatorNumbersOf(data) };
877
+ } catch (e) {
878
+ return { ok: false, error: "Could not reach Glitchgrab" };
879
+ }
880
+ }
881
+ function operatorNumbersOf(data) {
882
+ const op = isRecord(data.operator) ? data.operator : {};
883
+ return {
884
+ operator: { name: stringOrNull(op.name) },
885
+ numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.phone === "string").map((n) => {
886
+ var _a;
887
+ return {
888
+ phone: n.phone,
889
+ label: stringOrNull(n.label),
890
+ isDefault: n.isDefault === true,
891
+ order: (_a = numberOrNull(n.order)) != null ? _a : 0
892
+ };
893
+ }) : []
894
+ };
895
+ }
896
+ async function addLineCaller(caller, options = {}) {
897
+ try {
898
+ const key = callsKey(options);
899
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
900
+ const { data, error, code } = await callSdkApi("/api/v1/sdk/phone-lines/callers", key, options, {
901
+ method: "POST",
902
+ body: caller,
903
+ cache: "no-store"
904
+ });
905
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
906
+ return { ok: true, created: data.created === true, ...operatorNumbersOf(data) };
885
907
  } catch (e) {
886
908
  return { ok: false, error: "Could not reach Glitchgrab" };
887
909
  }
888
910
  }
911
+ function removeLineCaller(email, options = {}) {
912
+ return ringNumberWrite(
913
+ `/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
914
+ "DELETE",
915
+ void 0,
916
+ options,
917
+ () => ({})
918
+ );
919
+ }
889
920
  function ringNumbersPath(rest = "") {
890
921
  return `/api/v1/sdk/phone-lines/operator/numbers${rest}`;
891
922
  }
@@ -953,6 +984,7 @@ function testRingNumber(id, options = {}) {
953
984
  // Annotate the CommonJS export names for ESM import in node:
954
985
  0 && (module.exports = {
955
986
  addFollowUpNote,
987
+ addLineCaller,
956
988
  addRingNumber,
957
989
  cancelBooking,
958
990
  captureServerErrors,
@@ -973,6 +1005,7 @@ function testRingNumber(id, options = {}) {
973
1005
  listLeads,
974
1006
  listRingNumbers,
975
1007
  publishBookingQuestions,
1008
+ removeLineCaller,
976
1009
  removeRingNumber,
977
1010
  reportServerError,
978
1011
  rescheduleBooking,