glitchgrab 1.61.2 → 1.62.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/README.md +20 -0
- package/dist/index.js +30 -26
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -26
- package/dist/index.mjs.map +1 -1
- package/dist/server.d.mts +124 -1
- package/dist/server.d.ts +124 -1
- package/dist/server.js +132 -0
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +127 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/dist/server.d.mts
CHANGED
|
@@ -634,5 +634,128 @@ interface ListLeadsOptions extends CallsOptions {
|
|
|
634
634
|
* ```
|
|
635
635
|
*/
|
|
636
636
|
declare function listLeads(options?: ListLeadsOptions): Promise<Lead[]>;
|
|
637
|
+
/** How a next call reads on a list: grey, amber, red. */
|
|
638
|
+
type FollowUpDue = "none" | "upcoming" | "today" | "overdue";
|
|
639
|
+
interface FollowUp {
|
|
640
|
+
/** Glitchgrab's id; null for an externalId Glitchgrab has never seen. */
|
|
641
|
+
id: string | null;
|
|
642
|
+
externalId: string | null;
|
|
643
|
+
/** Digits, `91` + 10. */
|
|
644
|
+
phone: string | null;
|
|
645
|
+
name: string | null;
|
|
646
|
+
/** ISO. The booked next call. */
|
|
647
|
+
nextCallAt: string | null;
|
|
648
|
+
nextCallBookedBy: string | null;
|
|
649
|
+
due: FollowUpDue;
|
|
650
|
+
/** ISO. Read from the last call's transcript — shown as a suggestion, never booked by itself. */
|
|
651
|
+
suggestedNextCallAt: string | null;
|
|
652
|
+
suggestedNextCallReason: string | null;
|
|
653
|
+
lastNote: string | null;
|
|
654
|
+
lastNoteAt: string | null;
|
|
655
|
+
lastNoteBy: string | null;
|
|
656
|
+
noteCount: number;
|
|
657
|
+
lastCall: {
|
|
658
|
+
id: string;
|
|
659
|
+
status: string | null;
|
|
660
|
+
at: string;
|
|
661
|
+
durationSec: number | null;
|
|
662
|
+
} | null;
|
|
663
|
+
}
|
|
664
|
+
interface FollowUpNote {
|
|
665
|
+
id: string;
|
|
666
|
+
body: string;
|
|
667
|
+
/** "manual" (Glitchgrab), "api" (your app), "auto" (written from a call). */
|
|
668
|
+
source: string;
|
|
669
|
+
author: string | null;
|
|
670
|
+
callId: string | null;
|
|
671
|
+
editedAt: string | null;
|
|
672
|
+
createdAt: string;
|
|
673
|
+
}
|
|
674
|
+
interface FollowUpCall {
|
|
675
|
+
id: string;
|
|
676
|
+
status: string | null;
|
|
677
|
+
direction: string | null;
|
|
678
|
+
at: string;
|
|
679
|
+
durationSec: number | null;
|
|
680
|
+
/** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
|
|
681
|
+
shared: boolean;
|
|
682
|
+
overview: string | null;
|
|
683
|
+
/** Presigned; expires after `linksExpireInSeconds`. Null when not shared. */
|
|
684
|
+
recordingUrl: string | null;
|
|
685
|
+
}
|
|
686
|
+
interface FollowUpDetail extends FollowUp {
|
|
687
|
+
notes: FollowUpNote[];
|
|
688
|
+
calls: FollowUpCall[];
|
|
689
|
+
linksExpireInSeconds: number;
|
|
690
|
+
}
|
|
691
|
+
/** Someone on the project's Glitchgrab phone line — rung first on a dial, reminded on a booking. */
|
|
692
|
+
type FollowUpOperator = {
|
|
693
|
+
email: string;
|
|
694
|
+
} | {
|
|
695
|
+
phone: string;
|
|
696
|
+
};
|
|
697
|
+
type FollowUpWriteResult<T = Record<string, never>> = ({
|
|
698
|
+
ok: true;
|
|
699
|
+
followUpId: string;
|
|
700
|
+
} & T) | {
|
|
701
|
+
ok: false;
|
|
702
|
+
error: string;
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* Follow-ups for a whole list page in one request — one entry per id, in the
|
|
706
|
+
* order asked (≤500). An id Glitchgrab has never seen comes back empty, so
|
|
707
|
+
* every row can render.
|
|
708
|
+
*
|
|
709
|
+
* ```ts
|
|
710
|
+
* const followUps = await listFollowUps(owners.map((o) => o.id)); // GLITCHGRAB_CALLS_KEY=ggc_…
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
713
|
+
* Returns `[]` on any failure. Never throws.
|
|
714
|
+
*/
|
|
715
|
+
declare function listFollowUps(externalIds: string[], options?: CallsOptions): Promise<FollowUp[]>;
|
|
716
|
+
/**
|
|
717
|
+
* One customer's follow-up: booking, every note, their calls (recording links
|
|
718
|
+
* for shared calls only, presigned). Null on failure. Never throws.
|
|
719
|
+
*/
|
|
720
|
+
declare function getFollowUp(externalId: string, options?: CallsOptions): Promise<FollowUpDetail | null>;
|
|
721
|
+
/**
|
|
722
|
+
* Add a note from your own screen. `phone` is needed the first time Glitchgrab
|
|
723
|
+
* sees this externalId. Never throws.
|
|
724
|
+
*/
|
|
725
|
+
declare function addFollowUpNote(externalId: string, note: {
|
|
726
|
+
body: string;
|
|
727
|
+
author?: string;
|
|
728
|
+
phone?: string;
|
|
729
|
+
name?: string;
|
|
730
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
731
|
+
id: string;
|
|
732
|
+
}>>;
|
|
733
|
+
/**
|
|
734
|
+
* Book, move (`Date`/ISO) or clear (`null`) the next call. The reminder
|
|
735
|
+
* WhatsApp goes to `operator`, else the project owner. Never throws.
|
|
736
|
+
*/
|
|
737
|
+
declare function setFollowUpBooking(externalId: string, booking: {
|
|
738
|
+
nextCallAt: Date | string | null;
|
|
739
|
+
operator?: FollowUpOperator;
|
|
740
|
+
author?: string;
|
|
741
|
+
phone?: string;
|
|
742
|
+
name?: string;
|
|
743
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
744
|
+
nextCallAt: string | null;
|
|
745
|
+
}>>;
|
|
746
|
+
/**
|
|
747
|
+
* Start a recorded call: Glitchgrab rings `operator`'s mobile, then the
|
|
748
|
+
* customer, from the project's line. The operator must be on that line. A note
|
|
749
|
+
* and a suggested next call follow once the call is transcribed. Never throws.
|
|
750
|
+
*/
|
|
751
|
+
declare function dialFollowUp(externalId: string, call: {
|
|
752
|
+
operator: FollowUpOperator;
|
|
753
|
+
phone?: string;
|
|
754
|
+
name?: string;
|
|
755
|
+
lineId?: string;
|
|
756
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
757
|
+
callId: string;
|
|
758
|
+
ringing: string;
|
|
759
|
+
}>>;
|
|
637
760
|
|
|
638
|
-
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 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, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getGuide, listBookings, listCalls, listGuides, listLeads, publishBookingQuestions, reportServerError, rescheduleBooking, resetServerReporter, signSession, updateBookingSettings };
|
|
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 };
|
package/dist/server.d.ts
CHANGED
|
@@ -634,5 +634,128 @@ interface ListLeadsOptions extends CallsOptions {
|
|
|
634
634
|
* ```
|
|
635
635
|
*/
|
|
636
636
|
declare function listLeads(options?: ListLeadsOptions): Promise<Lead[]>;
|
|
637
|
+
/** How a next call reads on a list: grey, amber, red. */
|
|
638
|
+
type FollowUpDue = "none" | "upcoming" | "today" | "overdue";
|
|
639
|
+
interface FollowUp {
|
|
640
|
+
/** Glitchgrab's id; null for an externalId Glitchgrab has never seen. */
|
|
641
|
+
id: string | null;
|
|
642
|
+
externalId: string | null;
|
|
643
|
+
/** Digits, `91` + 10. */
|
|
644
|
+
phone: string | null;
|
|
645
|
+
name: string | null;
|
|
646
|
+
/** ISO. The booked next call. */
|
|
647
|
+
nextCallAt: string | null;
|
|
648
|
+
nextCallBookedBy: string | null;
|
|
649
|
+
due: FollowUpDue;
|
|
650
|
+
/** ISO. Read from the last call's transcript — shown as a suggestion, never booked by itself. */
|
|
651
|
+
suggestedNextCallAt: string | null;
|
|
652
|
+
suggestedNextCallReason: string | null;
|
|
653
|
+
lastNote: string | null;
|
|
654
|
+
lastNoteAt: string | null;
|
|
655
|
+
lastNoteBy: string | null;
|
|
656
|
+
noteCount: number;
|
|
657
|
+
lastCall: {
|
|
658
|
+
id: string;
|
|
659
|
+
status: string | null;
|
|
660
|
+
at: string;
|
|
661
|
+
durationSec: number | null;
|
|
662
|
+
} | null;
|
|
663
|
+
}
|
|
664
|
+
interface FollowUpNote {
|
|
665
|
+
id: string;
|
|
666
|
+
body: string;
|
|
667
|
+
/** "manual" (Glitchgrab), "api" (your app), "auto" (written from a call). */
|
|
668
|
+
source: string;
|
|
669
|
+
author: string | null;
|
|
670
|
+
callId: string | null;
|
|
671
|
+
editedAt: string | null;
|
|
672
|
+
createdAt: string;
|
|
673
|
+
}
|
|
674
|
+
interface FollowUpCall {
|
|
675
|
+
id: string;
|
|
676
|
+
status: string | null;
|
|
677
|
+
direction: string | null;
|
|
678
|
+
at: string;
|
|
679
|
+
durationSec: number | null;
|
|
680
|
+
/** Shared with you — calls dialled from a follow-up are; an inbound call is once the owner shares it. */
|
|
681
|
+
shared: boolean;
|
|
682
|
+
overview: string | null;
|
|
683
|
+
/** Presigned; expires after `linksExpireInSeconds`. Null when not shared. */
|
|
684
|
+
recordingUrl: string | null;
|
|
685
|
+
}
|
|
686
|
+
interface FollowUpDetail extends FollowUp {
|
|
687
|
+
notes: FollowUpNote[];
|
|
688
|
+
calls: FollowUpCall[];
|
|
689
|
+
linksExpireInSeconds: number;
|
|
690
|
+
}
|
|
691
|
+
/** Someone on the project's Glitchgrab phone line — rung first on a dial, reminded on a booking. */
|
|
692
|
+
type FollowUpOperator = {
|
|
693
|
+
email: string;
|
|
694
|
+
} | {
|
|
695
|
+
phone: string;
|
|
696
|
+
};
|
|
697
|
+
type FollowUpWriteResult<T = Record<string, never>> = ({
|
|
698
|
+
ok: true;
|
|
699
|
+
followUpId: string;
|
|
700
|
+
} & T) | {
|
|
701
|
+
ok: false;
|
|
702
|
+
error: string;
|
|
703
|
+
};
|
|
704
|
+
/**
|
|
705
|
+
* Follow-ups for a whole list page in one request — one entry per id, in the
|
|
706
|
+
* order asked (≤500). An id Glitchgrab has never seen comes back empty, so
|
|
707
|
+
* every row can render.
|
|
708
|
+
*
|
|
709
|
+
* ```ts
|
|
710
|
+
* const followUps = await listFollowUps(owners.map((o) => o.id)); // GLITCHGRAB_CALLS_KEY=ggc_…
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
713
|
+
* Returns `[]` on any failure. Never throws.
|
|
714
|
+
*/
|
|
715
|
+
declare function listFollowUps(externalIds: string[], options?: CallsOptions): Promise<FollowUp[]>;
|
|
716
|
+
/**
|
|
717
|
+
* One customer's follow-up: booking, every note, their calls (recording links
|
|
718
|
+
* for shared calls only, presigned). Null on failure. Never throws.
|
|
719
|
+
*/
|
|
720
|
+
declare function getFollowUp(externalId: string, options?: CallsOptions): Promise<FollowUpDetail | null>;
|
|
721
|
+
/**
|
|
722
|
+
* Add a note from your own screen. `phone` is needed the first time Glitchgrab
|
|
723
|
+
* sees this externalId. Never throws.
|
|
724
|
+
*/
|
|
725
|
+
declare function addFollowUpNote(externalId: string, note: {
|
|
726
|
+
body: string;
|
|
727
|
+
author?: string;
|
|
728
|
+
phone?: string;
|
|
729
|
+
name?: string;
|
|
730
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
731
|
+
id: string;
|
|
732
|
+
}>>;
|
|
733
|
+
/**
|
|
734
|
+
* Book, move (`Date`/ISO) or clear (`null`) the next call. The reminder
|
|
735
|
+
* WhatsApp goes to `operator`, else the project owner. Never throws.
|
|
736
|
+
*/
|
|
737
|
+
declare function setFollowUpBooking(externalId: string, booking: {
|
|
738
|
+
nextCallAt: Date | string | null;
|
|
739
|
+
operator?: FollowUpOperator;
|
|
740
|
+
author?: string;
|
|
741
|
+
phone?: string;
|
|
742
|
+
name?: string;
|
|
743
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
744
|
+
nextCallAt: string | null;
|
|
745
|
+
}>>;
|
|
746
|
+
/**
|
|
747
|
+
* Start a recorded call: Glitchgrab rings `operator`'s mobile, then the
|
|
748
|
+
* customer, from the project's line. The operator must be on that line. A note
|
|
749
|
+
* and a suggested next call follow once the call is transcribed. Never throws.
|
|
750
|
+
*/
|
|
751
|
+
declare function dialFollowUp(externalId: string, call: {
|
|
752
|
+
operator: FollowUpOperator;
|
|
753
|
+
phone?: string;
|
|
754
|
+
name?: string;
|
|
755
|
+
lineId?: string;
|
|
756
|
+
}, options?: CallsOptions): Promise<FollowUpWriteResult<{
|
|
757
|
+
callId: string;
|
|
758
|
+
ringing: string;
|
|
759
|
+
}>>;
|
|
637
760
|
|
|
638
|
-
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 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, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, discardBookingQuestionsDraft, escapeJsonForScript, getBookingSettings, getCall, getGuide, listBookings, listCalls, listGuides, listLeads, publishBookingQuestions, reportServerError, rescheduleBooking, resetServerReporter, signSession, updateBookingSettings };
|
|
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 };
|
package/dist/server.js
CHANGED
|
@@ -20,23 +20,28 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/server.ts
|
|
21
21
|
var server_exports = {};
|
|
22
22
|
__export(server_exports, {
|
|
23
|
+
addFollowUpNote: () => addFollowUpNote,
|
|
23
24
|
cancelBooking: () => cancelBooking,
|
|
24
25
|
captureServerErrors: () => captureServerErrors,
|
|
25
26
|
configureServerReporter: () => configureServerReporter,
|
|
26
27
|
deleteCall: () => deleteCall,
|
|
28
|
+
dialFollowUp: () => dialFollowUp,
|
|
27
29
|
discardBookingQuestionsDraft: () => discardBookingQuestionsDraft,
|
|
28
30
|
escapeJsonForScript: () => escapeJsonForScript,
|
|
29
31
|
getBookingSettings: () => getBookingSettings,
|
|
30
32
|
getCall: () => getCall,
|
|
33
|
+
getFollowUp: () => getFollowUp,
|
|
31
34
|
getGuide: () => getGuide,
|
|
32
35
|
listBookings: () => listBookings,
|
|
33
36
|
listCalls: () => listCalls,
|
|
37
|
+
listFollowUps: () => listFollowUps,
|
|
34
38
|
listGuides: () => listGuides,
|
|
35
39
|
listLeads: () => listLeads,
|
|
36
40
|
publishBookingQuestions: () => publishBookingQuestions,
|
|
37
41
|
reportServerError: () => reportServerError,
|
|
38
42
|
rescheduleBooking: () => rescheduleBooking,
|
|
39
43
|
resetServerReporter: () => resetServerReporter,
|
|
44
|
+
setFollowUpBooking: () => setFollowUpBooking,
|
|
40
45
|
signSession: () => signSession,
|
|
41
46
|
updateBookingSettings: () => updateBookingSettings
|
|
42
47
|
});
|
|
@@ -717,25 +722,152 @@ async function listLeads(options = {}) {
|
|
|
717
722
|
return [];
|
|
718
723
|
}
|
|
719
724
|
}
|
|
725
|
+
var DUES = /* @__PURE__ */ new Set(["none", "upcoming", "today", "overdue"]);
|
|
726
|
+
function readFollowUp(value) {
|
|
727
|
+
var _a, _b;
|
|
728
|
+
if (!isRecord(value)) return null;
|
|
729
|
+
const call = isRecord(value.lastCall) && typeof value.lastCall.id === "string" ? value.lastCall : null;
|
|
730
|
+
return {
|
|
731
|
+
id: stringOrNull(value.id),
|
|
732
|
+
externalId: stringOrNull(value.externalId),
|
|
733
|
+
phone: stringOrNull(value.phone),
|
|
734
|
+
name: stringOrNull(value.name),
|
|
735
|
+
nextCallAt: stringOrNull(value.nextCallAt),
|
|
736
|
+
nextCallBookedBy: stringOrNull(value.nextCallBookedBy),
|
|
737
|
+
due: typeof value.due === "string" && DUES.has(value.due) ? value.due : "none",
|
|
738
|
+
suggestedNextCallAt: stringOrNull(value.suggestedNextCallAt),
|
|
739
|
+
suggestedNextCallReason: stringOrNull(value.suggestedNextCallReason),
|
|
740
|
+
lastNote: stringOrNull(value.lastNote),
|
|
741
|
+
lastNoteAt: stringOrNull(value.lastNoteAt),
|
|
742
|
+
lastNoteBy: stringOrNull(value.lastNoteBy),
|
|
743
|
+
noteCount: (_a = numberOrNull(value.noteCount)) != null ? _a : 0,
|
|
744
|
+
lastCall: call ? {
|
|
745
|
+
id: call.id,
|
|
746
|
+
status: stringOrNull(call.status),
|
|
747
|
+
at: (_b = stringOrNull(call.at)) != null ? _b : "",
|
|
748
|
+
durationSec: numberOrNull(call.durationSec)
|
|
749
|
+
} : null
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
function readFollowUpDetail(value) {
|
|
753
|
+
var _a;
|
|
754
|
+
const base = readFollowUp(value);
|
|
755
|
+
if (!base || !isRecord(value)) return null;
|
|
756
|
+
return {
|
|
757
|
+
...base,
|
|
758
|
+
linksExpireInSeconds: (_a = numberOrNull(value.linksExpireInSeconds)) != null ? _a : 0,
|
|
759
|
+
notes: Array.isArray(value.notes) ? value.notes.filter(isRecord).filter((n) => typeof n.id === "string" && typeof n.body === "string").map((n) => {
|
|
760
|
+
var _a2, _b;
|
|
761
|
+
return {
|
|
762
|
+
id: n.id,
|
|
763
|
+
body: n.body,
|
|
764
|
+
source: (_a2 = stringOrNull(n.source)) != null ? _a2 : "manual",
|
|
765
|
+
author: stringOrNull(n.author),
|
|
766
|
+
callId: stringOrNull(n.callId),
|
|
767
|
+
editedAt: stringOrNull(n.editedAt),
|
|
768
|
+
createdAt: (_b = stringOrNull(n.createdAt)) != null ? _b : ""
|
|
769
|
+
};
|
|
770
|
+
}) : [],
|
|
771
|
+
calls: Array.isArray(value.calls) ? value.calls.filter(isRecord).filter((c) => typeof c.id === "string").map((c) => {
|
|
772
|
+
var _a2;
|
|
773
|
+
return {
|
|
774
|
+
id: c.id,
|
|
775
|
+
status: stringOrNull(c.status),
|
|
776
|
+
direction: stringOrNull(c.direction),
|
|
777
|
+
at: (_a2 = stringOrNull(c.at)) != null ? _a2 : "",
|
|
778
|
+
durationSec: numberOrNull(c.durationSec),
|
|
779
|
+
shared: c.shared === true,
|
|
780
|
+
overview: stringOrNull(c.overview),
|
|
781
|
+
recordingUrl: stringOrNull(c.recordingUrl)
|
|
782
|
+
};
|
|
783
|
+
}) : []
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
function followUpPath(externalId, rest = "") {
|
|
787
|
+
const id = typeof externalId === "string" ? externalId.trim() : "";
|
|
788
|
+
return id ? `/api/v1/sdk/follow-ups/${encodeURIComponent(id)}${rest}` : null;
|
|
789
|
+
}
|
|
790
|
+
async function writeFollowUp(path, method, body, options, pick) {
|
|
791
|
+
try {
|
|
792
|
+
if (!path) return { ok: false, error: "No externalId" };
|
|
793
|
+
const key = callsKey(options);
|
|
794
|
+
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
795
|
+
const { data, error } = await callSdkApi(path, key, options, { method, body, cache: "no-store" });
|
|
796
|
+
if (error !== null || !isRecord(data) || typeof data.followUpId !== "string") {
|
|
797
|
+
return { ok: false, error: error != null ? error : "Unexpected response" };
|
|
798
|
+
}
|
|
799
|
+
return { ok: true, followUpId: data.followUpId, ...pick(data) };
|
|
800
|
+
} catch (e) {
|
|
801
|
+
return { ok: false, error: "Could not reach Glitchgrab" };
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
async function listFollowUps(externalIds, options = {}) {
|
|
805
|
+
try {
|
|
806
|
+
const key = callsKey(options);
|
|
807
|
+
const ids = Array.isArray(externalIds) ? externalIds.filter((id) => typeof id === "string" && id.trim()) : [];
|
|
808
|
+
if (!key || ids.length === 0) return [];
|
|
809
|
+
const query = new URLSearchParams({ externalIds: ids.join(",") });
|
|
810
|
+
const { data } = await callSdkApi(`/api/v1/sdk/follow-ups?${query.toString()}`, key, options, {
|
|
811
|
+
cache: "no-store"
|
|
812
|
+
});
|
|
813
|
+
if (!Array.isArray(data)) return [];
|
|
814
|
+
return data.map(readFollowUp).filter((f) => f !== null);
|
|
815
|
+
} catch (e) {
|
|
816
|
+
return [];
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async function getFollowUp(externalId, options = {}) {
|
|
820
|
+
try {
|
|
821
|
+
const path = followUpPath(externalId);
|
|
822
|
+
const key = callsKey(options);
|
|
823
|
+
if (!path || !key) return null;
|
|
824
|
+
const { data } = await callSdkApi(path, key, options, { cache: "no-store" });
|
|
825
|
+
return readFollowUpDetail(data);
|
|
826
|
+
} catch (e) {
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
function addFollowUpNote(externalId, note, options = {}) {
|
|
831
|
+
return writeFollowUp(followUpPath(externalId, "/notes"), "POST", note, options, (d) => ({
|
|
832
|
+
id: typeof d.id === "string" ? d.id : ""
|
|
833
|
+
}));
|
|
834
|
+
}
|
|
835
|
+
function setFollowUpBooking(externalId, booking, options = {}) {
|
|
836
|
+
const at = booking.nextCallAt instanceof Date ? booking.nextCallAt.toISOString() : booking.nextCallAt;
|
|
837
|
+
return writeFollowUp(followUpPath(externalId, "/booking"), "PUT", { ...booking, nextCallAt: at }, options, (d) => ({
|
|
838
|
+
nextCallAt: stringOrNull(d.nextCallAt)
|
|
839
|
+
}));
|
|
840
|
+
}
|
|
841
|
+
function dialFollowUp(externalId, call, options = {}) {
|
|
842
|
+
return writeFollowUp(followUpPath(externalId, "/dial"), "POST", call, options, (d) => ({
|
|
843
|
+
callId: typeof d.callId === "string" ? d.callId : "",
|
|
844
|
+
ringing: typeof d.ringing === "string" ? d.ringing : ""
|
|
845
|
+
}));
|
|
846
|
+
}
|
|
720
847
|
// Annotate the CommonJS export names for ESM import in node:
|
|
721
848
|
0 && (module.exports = {
|
|
849
|
+
addFollowUpNote,
|
|
722
850
|
cancelBooking,
|
|
723
851
|
captureServerErrors,
|
|
724
852
|
configureServerReporter,
|
|
725
853
|
deleteCall,
|
|
854
|
+
dialFollowUp,
|
|
726
855
|
discardBookingQuestionsDraft,
|
|
727
856
|
escapeJsonForScript,
|
|
728
857
|
getBookingSettings,
|
|
729
858
|
getCall,
|
|
859
|
+
getFollowUp,
|
|
730
860
|
getGuide,
|
|
731
861
|
listBookings,
|
|
732
862
|
listCalls,
|
|
863
|
+
listFollowUps,
|
|
733
864
|
listGuides,
|
|
734
865
|
listLeads,
|
|
735
866
|
publishBookingQuestions,
|
|
736
867
|
reportServerError,
|
|
737
868
|
rescheduleBooking,
|
|
738
869
|
resetServerReporter,
|
|
870
|
+
setFollowUpBooking,
|
|
739
871
|
signSession,
|
|
740
872
|
updateBookingSettings
|
|
741
873
|
});
|