glitchgrab 1.62.0 → 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/dist/server.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { n as ReportType, m as ReportSeverity, l as ReportResult } from './types-BlMF6wzX.mjs';
1
+ import { n as ReportType, m as ReportSeverity, l as ReportResult } from './types-Dp5Sh_hd.mjs';
2
2
  import 'react';
3
3
 
4
4
  /** Who to attribute the report to. A server has no signed-in user, so this is the job or service. */
@@ -659,6 +659,10 @@ interface FollowUp {
659
659
  status: string | null;
660
660
  at: string;
661
661
  durationSec: number | null;
662
+ /** Which of the operator's phones the call is on: 0 = the one picked, 1+ = a backup (#654). */
663
+ ringingIndex: number | null;
664
+ /** That phone. While `status` is "DIALING" it is the one ringing right now. */
665
+ ringingPhone: string | null;
662
666
  } | null;
663
667
  }
664
668
  interface FollowUpNote {
@@ -677,6 +681,10 @@ interface FollowUpCall {
677
681
  direction: string | null;
678
682
  at: string;
679
683
  durationSec: number | null;
684
+ /** Which of the operator's phones the call is on: 0 = the one picked, 1+ = a backup (#654). */
685
+ ringingIndex: number | null;
686
+ /** That phone. While `status` is "DIALING" it is the one ringing right now. */
687
+ ringingPhone: string | null;
680
688
  /** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
681
689
  shared: boolean;
682
690
  overview: string | null;
@@ -694,12 +702,20 @@ type FollowUpOperator = {
694
702
  } | {
695
703
  phone: string;
696
704
  };
705
+ /**
706
+ * Why a dial was refused, so your screen can say exactly what is missing (#654):
707
+ * - `NOT_ON_LINE` — the operator isn't one of the people on the project's phone line.
708
+ * - `NO_VERIFIED_NUMBER` — they are, but have no phone Glitchgrab may ring.
709
+ * - `RING_PHONE_NOT_YOURS` — `ringPhone` isn't one of their verified numbers.
710
+ */
711
+ type RingErrorCode = "NOT_ON_LINE" | "NO_VERIFIED_NUMBER" | "RING_PHONE_NOT_YOURS";
697
712
  type FollowUpWriteResult<T = Record<string, never>> = ({
698
713
  ok: true;
699
714
  followUpId: string;
700
715
  } & T) | {
701
716
  ok: false;
702
717
  error: string;
718
+ code?: string;
703
719
  };
704
720
  /**
705
721
  * Follow-ups for a whole list page in one request — one entry per id, in the
@@ -744,18 +760,159 @@ declare function setFollowUpBooking(externalId: string, booking: {
744
760
  nextCallAt: string | null;
745
761
  }>>;
746
762
  /**
747
- * Start a recorded call: Glitchgrab rings `operator`'s mobile, then the
763
+ * Start a recorded call: Glitchgrab rings `operator`'s phone, then the
748
764
  * customer, from the project's line. The operator must be on that line. A note
749
765
  * and a suggested next call follow once the call is transcribed. Never throws.
766
+ *
767
+ * `ringPhone` picks which of the operator's verified phones rings first (list
768
+ * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
769
+ * phone isn't picked up, their backups ring in order (`ringNumbers`). A
770
+ * refusal carries `code` — see {@link RingErrorCode}.
750
771
  */
751
772
  declare function dialFollowUp(externalId: string, call: {
752
773
  operator: FollowUpOperator;
753
774
  phone?: string;
754
775
  name?: string;
755
776
  lineId?: string;
777
+ ringPhone?: string;
756
778
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
757
779
  callId: string;
758
780
  ringing: string;
781
+ ringNumbers: string[];
782
+ }>>;
783
+ /** One phone Glitchgrab may ring for an operator — what `ringPhone` accepts (#654). */
784
+ interface OperatorRingNumber {
785
+ /** E.164, `+91…`. Pass it back as `ringPhone`. */
786
+ phone: string;
787
+ label: string | null;
788
+ isDefault: boolean;
789
+ /** 0 = Default, then backups in the order they ring. */
790
+ order: number;
791
+ }
792
+ type OperatorRingNumbersResult = {
793
+ ok: true;
794
+ operator: {
795
+ name: string | null;
796
+ };
797
+ numbers: OperatorRingNumber[];
798
+ } | {
799
+ ok: false;
800
+ error: string;
801
+ code?: string;
802
+ };
803
+ /**
804
+ * The phones Glitchgrab can ring for one person on the project's phone line —
805
+ * for a "Ring me on: [Default ▾]" picker beside your Call button. Verified
806
+ * numbers only. `numbers: []` = dial will refuse with `NO_VERIFIED_NUMBER`;
807
+ * not on the line = `{ ok: false, code: "NOT_ON_LINE" }`. Never throws.
808
+ *
809
+ * ```ts
810
+ * const r = await getOperatorRingNumbers({ email: admin.email }); // GLITCHGRAB_CALLS_KEY=ggc_…
811
+ * if (r.ok) render(r.numbers); // pass the chosen phone to dialFollowUp(…, { ringPhone })
812
+ * ```
813
+ */
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>;
854
+ /** One saved ring number, verified or not — the management view (#654). */
855
+ interface RingNumber {
856
+ id: string;
857
+ /** E.164, `+91…`. */
858
+ phone: string;
859
+ label: string | null;
860
+ position: number;
861
+ /** Only verified numbers are ever rung. */
862
+ verified: boolean;
863
+ /** A test ring is out right now — poll until `verified`. */
864
+ verifying: boolean;
865
+ isDefault: boolean;
866
+ }
867
+ interface RingNumberList {
868
+ operator: {
869
+ name: string | null;
870
+ };
871
+ /** Their account mobile — still what rings while nothing here is verified. */
872
+ accountPhone: string | null;
873
+ usingAccount: boolean;
874
+ numbers: RingNumber[];
875
+ }
876
+ type RingNumberWriteResult<T = object> = ({
877
+ ok: true;
878
+ } & T) | {
879
+ ok: false;
880
+ error: string;
881
+ code?: string;
882
+ };
883
+ /**
884
+ * Every phone saved for one person on the project's line, unverified included
885
+ * — for your "manage my phones" screen. Ring numbers are managed only from
886
+ * your product; Glitchgrab shows them read-only. A refusal carries `code`
887
+ * (`NOT_ON_LINE`), so "not on the line" reads differently from "network down".
888
+ * Never throws.
889
+ */
890
+ declare function listRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<RingNumberWriteResult<RingNumberList>>;
891
+ /**
892
+ * Save a phone for `operator` and place its test ring at once: the project's
893
+ * line calls it and whoever holds it presses 1. Never rung for a call until
894
+ * then; the line's owner is alerted when it is verified. Max 5 per person.
895
+ * `testRing: "failed"` = saved but not rung — retry with {@link testRingNumber}.
896
+ */
897
+ declare function addRingNumber(operator: FollowUpOperator, number: {
898
+ phone: string;
899
+ label?: string;
900
+ }, options?: CallsOptions): Promise<RingNumberWriteResult<{
901
+ id: string;
902
+ testRing: "ringing" | "failed";
903
+ verifyError: string | null;
904
+ }>>;
905
+ /** Rename, make Default (verified only) or move one place up/down. Never throws. */
906
+ declare function updateRingNumber(id: string, change: {
907
+ label?: string | null;
908
+ makeDefault?: true;
909
+ move?: "up" | "down";
910
+ }, options?: CallsOptions): Promise<RingNumberWriteResult>;
911
+ /** Remove one; the next verified number becomes Default. Never throws. */
912
+ declare function removeRingNumber(id: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
913
+ /** Place the test ring again (6 per person, 30 per project an hour). Never throws. */
914
+ declare function testRingNumber(id: string, options?: CallsOptions): Promise<RingNumberWriteResult<{
915
+ verified: boolean;
759
916
  }>>;
760
917
 
761
- 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, ReportResult, ReportSeverity, ReportType, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, listBookings, listCalls, listFollowUps, listGuides, listLeads, publishBookingQuestions, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, updateBookingSettings };
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
@@ -1,4 +1,4 @@
1
- import { n as ReportType, m as ReportSeverity, l as ReportResult } from './types-BlMF6wzX.js';
1
+ import { n as ReportType, m as ReportSeverity, l as ReportResult } from './types-Dp5Sh_hd.js';
2
2
  import 'react';
3
3
 
4
4
  /** Who to attribute the report to. A server has no signed-in user, so this is the job or service. */
@@ -659,6 +659,10 @@ interface FollowUp {
659
659
  status: string | null;
660
660
  at: string;
661
661
  durationSec: number | null;
662
+ /** Which of the operator's phones the call is on: 0 = the one picked, 1+ = a backup (#654). */
663
+ ringingIndex: number | null;
664
+ /** That phone. While `status` is "DIALING" it is the one ringing right now. */
665
+ ringingPhone: string | null;
662
666
  } | null;
663
667
  }
664
668
  interface FollowUpNote {
@@ -677,6 +681,10 @@ interface FollowUpCall {
677
681
  direction: string | null;
678
682
  at: string;
679
683
  durationSec: number | null;
684
+ /** Which of the operator's phones the call is on: 0 = the one picked, 1+ = a backup (#654). */
685
+ ringingIndex: number | null;
686
+ /** That phone. While `status` is "DIALING" it is the one ringing right now. */
687
+ ringingPhone: string | null;
680
688
  /** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
681
689
  shared: boolean;
682
690
  overview: string | null;
@@ -694,12 +702,20 @@ type FollowUpOperator = {
694
702
  } | {
695
703
  phone: string;
696
704
  };
705
+ /**
706
+ * Why a dial was refused, so your screen can say exactly what is missing (#654):
707
+ * - `NOT_ON_LINE` — the operator isn't one of the people on the project's phone line.
708
+ * - `NO_VERIFIED_NUMBER` — they are, but have no phone Glitchgrab may ring.
709
+ * - `RING_PHONE_NOT_YOURS` — `ringPhone` isn't one of their verified numbers.
710
+ */
711
+ type RingErrorCode = "NOT_ON_LINE" | "NO_VERIFIED_NUMBER" | "RING_PHONE_NOT_YOURS";
697
712
  type FollowUpWriteResult<T = Record<string, never>> = ({
698
713
  ok: true;
699
714
  followUpId: string;
700
715
  } & T) | {
701
716
  ok: false;
702
717
  error: string;
718
+ code?: string;
703
719
  };
704
720
  /**
705
721
  * Follow-ups for a whole list page in one request — one entry per id, in the
@@ -744,18 +760,159 @@ declare function setFollowUpBooking(externalId: string, booking: {
744
760
  nextCallAt: string | null;
745
761
  }>>;
746
762
  /**
747
- * Start a recorded call: Glitchgrab rings `operator`'s mobile, then the
763
+ * Start a recorded call: Glitchgrab rings `operator`'s phone, then the
748
764
  * customer, from the project's line. The operator must be on that line. A note
749
765
  * and a suggested next call follow once the call is transcribed. Never throws.
766
+ *
767
+ * `ringPhone` picks which of the operator's verified phones rings first (list
768
+ * them with {@link getOperatorRingNumbers}); omitted = their Default. If that
769
+ * phone isn't picked up, their backups ring in order (`ringNumbers`). A
770
+ * refusal carries `code` — see {@link RingErrorCode}.
750
771
  */
751
772
  declare function dialFollowUp(externalId: string, call: {
752
773
  operator: FollowUpOperator;
753
774
  phone?: string;
754
775
  name?: string;
755
776
  lineId?: string;
777
+ ringPhone?: string;
756
778
  }, options?: CallsOptions): Promise<FollowUpWriteResult<{
757
779
  callId: string;
758
780
  ringing: string;
781
+ ringNumbers: string[];
782
+ }>>;
783
+ /** One phone Glitchgrab may ring for an operator — what `ringPhone` accepts (#654). */
784
+ interface OperatorRingNumber {
785
+ /** E.164, `+91…`. Pass it back as `ringPhone`. */
786
+ phone: string;
787
+ label: string | null;
788
+ isDefault: boolean;
789
+ /** 0 = Default, then backups in the order they ring. */
790
+ order: number;
791
+ }
792
+ type OperatorRingNumbersResult = {
793
+ ok: true;
794
+ operator: {
795
+ name: string | null;
796
+ };
797
+ numbers: OperatorRingNumber[];
798
+ } | {
799
+ ok: false;
800
+ error: string;
801
+ code?: string;
802
+ };
803
+ /**
804
+ * The phones Glitchgrab can ring for one person on the project's phone line —
805
+ * for a "Ring me on: [Default ▾]" picker beside your Call button. Verified
806
+ * numbers only. `numbers: []` = dial will refuse with `NO_VERIFIED_NUMBER`;
807
+ * not on the line = `{ ok: false, code: "NOT_ON_LINE" }`. Never throws.
808
+ *
809
+ * ```ts
810
+ * const r = await getOperatorRingNumbers({ email: admin.email }); // GLITCHGRAB_CALLS_KEY=ggc_…
811
+ * if (r.ok) render(r.numbers); // pass the chosen phone to dialFollowUp(…, { ringPhone })
812
+ * ```
813
+ */
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>;
854
+ /** One saved ring number, verified or not — the management view (#654). */
855
+ interface RingNumber {
856
+ id: string;
857
+ /** E.164, `+91…`. */
858
+ phone: string;
859
+ label: string | null;
860
+ position: number;
861
+ /** Only verified numbers are ever rung. */
862
+ verified: boolean;
863
+ /** A test ring is out right now — poll until `verified`. */
864
+ verifying: boolean;
865
+ isDefault: boolean;
866
+ }
867
+ interface RingNumberList {
868
+ operator: {
869
+ name: string | null;
870
+ };
871
+ /** Their account mobile — still what rings while nothing here is verified. */
872
+ accountPhone: string | null;
873
+ usingAccount: boolean;
874
+ numbers: RingNumber[];
875
+ }
876
+ type RingNumberWriteResult<T = object> = ({
877
+ ok: true;
878
+ } & T) | {
879
+ ok: false;
880
+ error: string;
881
+ code?: string;
882
+ };
883
+ /**
884
+ * Every phone saved for one person on the project's line, unverified included
885
+ * — for your "manage my phones" screen. Ring numbers are managed only from
886
+ * your product; Glitchgrab shows them read-only. A refusal carries `code`
887
+ * (`NOT_ON_LINE`), so "not on the line" reads differently from "network down".
888
+ * Never throws.
889
+ */
890
+ declare function listRingNumbers(operator: FollowUpOperator, options?: CallsOptions): Promise<RingNumberWriteResult<RingNumberList>>;
891
+ /**
892
+ * Save a phone for `operator` and place its test ring at once: the project's
893
+ * line calls it and whoever holds it presses 1. Never rung for a call until
894
+ * then; the line's owner is alerted when it is verified. Max 5 per person.
895
+ * `testRing: "failed"` = saved but not rung — retry with {@link testRingNumber}.
896
+ */
897
+ declare function addRingNumber(operator: FollowUpOperator, number: {
898
+ phone: string;
899
+ label?: string;
900
+ }, options?: CallsOptions): Promise<RingNumberWriteResult<{
901
+ id: string;
902
+ testRing: "ringing" | "failed";
903
+ verifyError: string | null;
904
+ }>>;
905
+ /** Rename, make Default (verified only) or move one place up/down. Never throws. */
906
+ declare function updateRingNumber(id: string, change: {
907
+ label?: string | null;
908
+ makeDefault?: true;
909
+ move?: "up" | "down";
910
+ }, options?: CallsOptions): Promise<RingNumberWriteResult>;
911
+ /** Remove one; the next verified number becomes Default. Never throws. */
912
+ declare function removeRingNumber(id: string, options?: CallsOptions): Promise<RingNumberWriteResult>;
913
+ /** Place the test ring again (6 per person, 30 per project an hour). Never throws. */
914
+ declare function testRingNumber(id: string, options?: CallsOptions): Promise<RingNumberWriteResult<{
915
+ verified: boolean;
759
916
  }>>;
760
917
 
761
- 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, ReportResult, ReportSeverity, ReportType, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, listBookings, listCalls, listFollowUps, listGuides, listLeads, publishBookingQuestions, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, updateBookingSettings };
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,8 @@ 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,
25
+ addRingNumber: () => addRingNumber,
24
26
  cancelBooking: () => cancelBooking,
25
27
  captureServerErrors: () => captureServerErrors,
26
28
  configureServerReporter: () => configureServerReporter,
@@ -32,18 +34,24 @@ __export(server_exports, {
32
34
  getCall: () => getCall,
33
35
  getFollowUp: () => getFollowUp,
34
36
  getGuide: () => getGuide,
37
+ getOperatorRingNumbers: () => getOperatorRingNumbers,
35
38
  listBookings: () => listBookings,
36
39
  listCalls: () => listCalls,
37
40
  listFollowUps: () => listFollowUps,
38
41
  listGuides: () => listGuides,
39
42
  listLeads: () => listLeads,
43
+ listRingNumbers: () => listRingNumbers,
40
44
  publishBookingQuestions: () => publishBookingQuestions,
45
+ removeLineCaller: () => removeLineCaller,
46
+ removeRingNumber: () => removeRingNumber,
41
47
  reportServerError: () => reportServerError,
42
48
  rescheduleBooking: () => rescheduleBooking,
43
49
  resetServerReporter: () => resetServerReporter,
44
50
  setFollowUpBooking: () => setFollowUpBooking,
45
51
  signSession: () => signSession,
46
- updateBookingSettings: () => updateBookingSettings
52
+ testRingNumber: () => testRingNumber,
53
+ updateBookingSettings: () => updateBookingSettings,
54
+ updateRingNumber: () => updateRingNumber
47
55
  });
48
56
  module.exports = __toCommonJS(server_exports);
49
57
  var import_node_crypto = require("crypto");
@@ -316,7 +324,11 @@ async function callSdkApi(path, token, options, init) {
316
324
  const response = await fetch(`${baseUrl}${path}`, request);
317
325
  const body = await response.json().catch(() => null);
318
326
  if (!response.ok || (body == null ? void 0 : body.success) !== true) {
319
- return { data: null, error: typeof (body == null ? void 0 : body.error) === "string" ? body.error : `HTTP ${response.status}` };
327
+ return {
328
+ data: null,
329
+ error: typeof (body == null ? void 0 : body.error) === "string" ? body.error : `HTTP ${response.status}`,
330
+ ...typeof (body == null ? void 0 : body.code) === "string" ? { code: body.code } : {}
331
+ };
320
332
  }
321
333
  return { data: (_f = body.data) != null ? _f : null, error: null };
322
334
  } catch (e) {
@@ -745,7 +757,9 @@ function readFollowUp(value) {
745
757
  id: call.id,
746
758
  status: stringOrNull(call.status),
747
759
  at: (_b = stringOrNull(call.at)) != null ? _b : "",
748
- durationSec: numberOrNull(call.durationSec)
760
+ durationSec: numberOrNull(call.durationSec),
761
+ ringingIndex: numberOrNull(call.ringingIndex),
762
+ ringingPhone: stringOrNull(call.ringingPhone)
749
763
  } : null
750
764
  };
751
765
  }
@@ -776,6 +790,8 @@ function readFollowUpDetail(value) {
776
790
  direction: stringOrNull(c.direction),
777
791
  at: (_a2 = stringOrNull(c.at)) != null ? _a2 : "",
778
792
  durationSec: numberOrNull(c.durationSec),
793
+ ringingIndex: numberOrNull(c.ringingIndex),
794
+ ringingPhone: stringOrNull(c.ringingPhone),
779
795
  shared: c.shared === true,
780
796
  overview: stringOrNull(c.overview),
781
797
  recordingUrl: stringOrNull(c.recordingUrl)
@@ -792,9 +808,9 @@ async function writeFollowUp(path, method, body, options, pick) {
792
808
  if (!path) return { ok: false, error: "No externalId" };
793
809
  const key = callsKey(options);
794
810
  if (!key) return { ok: false, error: NO_KEY_ERROR };
795
- const { data, error } = await callSdkApi(path, key, options, { method, body, cache: "no-store" });
811
+ const { data, error, code } = await callSdkApi(path, key, options, { method, body, cache: "no-store" });
796
812
  if (error !== null || !isRecord(data) || typeof data.followUpId !== "string") {
797
- return { ok: false, error: error != null ? error : "Unexpected response" };
813
+ return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
798
814
  }
799
815
  return { ok: true, followUpId: data.followUpId, ...pick(data) };
800
816
  } catch (e) {
@@ -841,12 +857,132 @@ function setFollowUpBooking(externalId, booking, options = {}) {
841
857
  function dialFollowUp(externalId, call, options = {}) {
842
858
  return writeFollowUp(followUpPath(externalId, "/dial"), "POST", call, options, (d) => ({
843
859
  callId: typeof d.callId === "string" ? d.callId : "",
844
- ringing: typeof d.ringing === "string" ? d.ringing : ""
860
+ ringing: typeof d.ringing === "string" ? d.ringing : "",
861
+ ringNumbers: Array.isArray(d.ringNumbers) ? d.ringNumbers.filter((n) => typeof n === "string") : []
862
+ }));
863
+ }
864
+ async function getOperatorRingNumbers(operator, options = {}) {
865
+ try {
866
+ const key = callsKey(options);
867
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
868
+ const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
869
+ const { data, error, code } = await callSdkApi(`/api/v1/sdk/phone-lines/operator?${query.toString()}`, key, options, {
870
+ cache: "no-store"
871
+ });
872
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
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) };
904
+ } catch (e) {
905
+ return { ok: false, error: "Could not reach Glitchgrab" };
906
+ }
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
+ }
917
+ function ringNumbersPath(rest = "") {
918
+ return `/api/v1/sdk/phone-lines/operator/numbers${rest}`;
919
+ }
920
+ async function ringNumberWrite(path, method, body, options, pick) {
921
+ try {
922
+ const key = callsKey(options);
923
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
924
+ const { data, error, code } = await callSdkApi(path, key, options, { method, body, cache: "no-store" });
925
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
926
+ return { ok: true, ...pick(data) };
927
+ } catch (e) {
928
+ return { ok: false, error: "Could not reach Glitchgrab" };
929
+ }
930
+ }
931
+ async function listRingNumbers(operator, options = {}) {
932
+ try {
933
+ const key = callsKey(options);
934
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
935
+ const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
936
+ const { data, error, code } = await callSdkApi(ringNumbersPath(`?${query.toString()}`), key, options, {
937
+ cache: "no-store"
938
+ });
939
+ if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
940
+ const op = isRecord(data.operator) ? data.operator : {};
941
+ return {
942
+ ok: true,
943
+ operator: { name: stringOrNull(op.name) },
944
+ accountPhone: stringOrNull(data.accountPhone),
945
+ usingAccount: data.usingAccount === true,
946
+ numbers: Array.isArray(data.numbers) ? data.numbers.filter(isRecord).filter((n) => typeof n.id === "string" && typeof n.phone === "string").map((n) => {
947
+ var _a;
948
+ return {
949
+ id: n.id,
950
+ phone: n.phone,
951
+ label: stringOrNull(n.label),
952
+ position: (_a = numberOrNull(n.position)) != null ? _a : 0,
953
+ verified: n.verified === true,
954
+ verifying: n.verifying === true,
955
+ isDefault: n.isDefault === true
956
+ };
957
+ }) : []
958
+ };
959
+ } catch (e) {
960
+ return { ok: false, error: "Could not reach Glitchgrab" };
961
+ }
962
+ }
963
+ function addRingNumber(operator, number, options = {}) {
964
+ return ringNumberWrite(ringNumbersPath(), "POST", { operator, ...number }, options, (d) => ({
965
+ id: typeof d.id === "string" ? d.id : "",
966
+ testRing: d.testRing === "failed" ? "failed" : "ringing",
967
+ verifyError: stringOrNull(d.verifyError)
968
+ }));
969
+ }
970
+ function updateRingNumber(id, change, options = {}) {
971
+ return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}`), "PATCH", change, options, () => ({}));
972
+ }
973
+ function removeRingNumber(id, options = {}) {
974
+ return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}`), "DELETE", void 0, options, () => ({}));
975
+ }
976
+ function testRingNumber(id, options = {}) {
977
+ return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}/verify`), "POST", void 0, options, (d) => ({
978
+ verified: d.verified === true
845
979
  }));
846
980
  }
847
981
  // Annotate the CommonJS export names for ESM import in node:
848
982
  0 && (module.exports = {
849
983
  addFollowUpNote,
984
+ addLineCaller,
985
+ addRingNumber,
850
986
  cancelBooking,
851
987
  captureServerErrors,
852
988
  configureServerReporter,
@@ -858,17 +994,23 @@ function dialFollowUp(externalId, call, options = {}) {
858
994
  getCall,
859
995
  getFollowUp,
860
996
  getGuide,
997
+ getOperatorRingNumbers,
861
998
  listBookings,
862
999
  listCalls,
863
1000
  listFollowUps,
864
1001
  listGuides,
865
1002
  listLeads,
1003
+ listRingNumbers,
866
1004
  publishBookingQuestions,
1005
+ removeLineCaller,
1006
+ removeRingNumber,
867
1007
  reportServerError,
868
1008
  rescheduleBooking,
869
1009
  resetServerReporter,
870
1010
  setFollowUpBooking,
871
1011
  signSession,
872
- updateBookingSettings
1012
+ testRingNumber,
1013
+ updateBookingSettings,
1014
+ updateRingNumber
873
1015
  });
874
1016
  //# sourceMappingURL=server.js.map