@blazeo.com/calendar-client 1.0.34 → 1.0.36
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/index.d.ts +53 -4
- package/dist/index.js +231 -107
- package/dist/index.mjs +208 -86
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -76,9 +76,40 @@ export const CalendarModel: {
|
|
|
76
76
|
create(snapshot: object, options?: { env?: object }): unknown;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
/** Event fields returned by the API (camelCase). */
|
|
80
|
+
export type EventSnapshot = {
|
|
81
|
+
eventId: string;
|
|
82
|
+
calendarId?: string;
|
|
83
|
+
participantId?: string | null;
|
|
84
|
+
title?: string | null;
|
|
85
|
+
description?: string | null;
|
|
86
|
+
calendarLocationId?: string | null;
|
|
87
|
+
/** From CalendarLocation.Value when event search endpoints enrich the row. */
|
|
88
|
+
calendarLocationValue?: string | null;
|
|
89
|
+
customLocation?: string | null;
|
|
90
|
+
visitorName?: string | null;
|
|
91
|
+
visitorEmail?: string | null;
|
|
92
|
+
visitorPhone?: string | null;
|
|
93
|
+
startDate?: string;
|
|
94
|
+
endDate?: string;
|
|
95
|
+
[key: string]: unknown;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type EventSearchResult = {
|
|
99
|
+
events: unknown[];
|
|
100
|
+
totalCount: number;
|
|
101
|
+
};
|
|
102
|
+
|
|
79
103
|
export const EventModel: {
|
|
80
104
|
get(eventId: string): Promise<unknown>;
|
|
81
105
|
getByExternalId(externalEventId: string): Promise<unknown>;
|
|
106
|
+
getByDateRangeWithFilters(
|
|
107
|
+
companyKey: string,
|
|
108
|
+
startDateFrom: string,
|
|
109
|
+
startDateTo: string,
|
|
110
|
+
opts?: Record<string, unknown>
|
|
111
|
+
): Promise<EventSearchResult>;
|
|
112
|
+
getByFilters(companyKey: string, opts?: Record<string, unknown>): Promise<EventSearchResult>;
|
|
82
113
|
getRoundRobinParticipant(calendarId: string): Promise<unknown>;
|
|
83
114
|
getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
|
|
84
115
|
getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
|
|
@@ -100,7 +131,23 @@ export const EventModel: {
|
|
|
100
131
|
getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
|
|
101
132
|
setReminder(eventId: string): Promise<unknown>;
|
|
102
133
|
setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
|
|
103
|
-
|
|
134
|
+
setEventStatus(eventId: string, status: number | string): Promise<unknown>;
|
|
135
|
+
create(snapshot: EventSnapshot | object, options?: { env?: object }): unknown;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export type ExternalEventSnapshot = {
|
|
139
|
+
title?: string | null;
|
|
140
|
+
startDate?: string;
|
|
141
|
+
endDate?: string;
|
|
142
|
+
startHour?: number;
|
|
143
|
+
startMinute?: number;
|
|
144
|
+
endHour?: number;
|
|
145
|
+
endMinute?: number;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const ExternalEventModel: {
|
|
149
|
+
getByParticipant(participantId: string, opts?: { offset?: number }): Promise<unknown[]>;
|
|
150
|
+
create(snapshot: ExternalEventSnapshot | object, options?: { env?: object }): unknown;
|
|
104
151
|
};
|
|
105
152
|
|
|
106
153
|
export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
@@ -241,15 +288,16 @@ export const LeadModel: {
|
|
|
241
288
|
data?: { userId?: string; columns?: string[]; isDefault?: boolean };
|
|
242
289
|
message?: string;
|
|
243
290
|
}>;
|
|
291
|
+
/** Requires companyKey and at least one of email or phone. */
|
|
244
292
|
createLead(payload: {
|
|
245
|
-
email: string;
|
|
246
293
|
companyKey: string;
|
|
247
|
-
|
|
294
|
+
email?: string;
|
|
248
295
|
phone?: string;
|
|
296
|
+
name?: string;
|
|
249
297
|
source?: string;
|
|
250
298
|
leadType?: 'sales' | 'service' | 'others' | number;
|
|
251
299
|
referrerLink?: string;
|
|
252
|
-
}): Promise<unknown>;
|
|
300
|
+
}): Promise<{ status: string; data?: unknown; message?: string } | null>;
|
|
253
301
|
updateLead(payload: {
|
|
254
302
|
leadId: string;
|
|
255
303
|
email?: string;
|
|
@@ -419,6 +467,7 @@ export function createRootStore(initialState?: object): unknown;
|
|
|
419
467
|
export const Unit: Record<string, number>;
|
|
420
468
|
export const AssignmentMethod: Record<string, number>;
|
|
421
469
|
export const AttendeeStatus: Record<string, number>;
|
|
470
|
+
export const EventStatus: Record<string, number>;
|
|
422
471
|
export const RecurringFrequency: Record<string, number>;
|
|
423
472
|
export const DayOfWeek: Record<string, number>;
|
|
424
473
|
export const LocationType: Record<string, number>;
|
package/dist/index.js
CHANGED
|
@@ -39,6 +39,8 @@ __export(index_exports, {
|
|
|
39
39
|
EmailProvider: () => EmailProvider,
|
|
40
40
|
EventModel: () => Event_default,
|
|
41
41
|
EventSource: () => EventSource,
|
|
42
|
+
EventStatus: () => EventStatus,
|
|
43
|
+
ExternalEventModel: () => ExternalEvent_default,
|
|
42
44
|
FlowModel: () => Flow_default,
|
|
43
45
|
LeadModel: () => Lead_default,
|
|
44
46
|
LocationType: () => LocationType,
|
|
@@ -338,6 +340,12 @@ var AttendeeStatus = {
|
|
|
338
340
|
NeedsAction: 4,
|
|
339
341
|
Canceled: 5
|
|
340
342
|
};
|
|
343
|
+
var EventStatus = {
|
|
344
|
+
Scheduled: 1,
|
|
345
|
+
ReScheduled: 2,
|
|
346
|
+
Completed: 3,
|
|
347
|
+
Canceled: 4
|
|
348
|
+
};
|
|
341
349
|
var RecurringFrequency = {
|
|
342
350
|
None: 0,
|
|
343
351
|
Daily: 1,
|
|
@@ -482,16 +490,24 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
482
490
|
modifiedOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
483
491
|
externalEventId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
484
492
|
calendarLocationId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
493
|
+
/** Resolved location text from CalendarLocation when returned by search APIs. */
|
|
494
|
+
calendarLocationValue: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
485
495
|
customLocation: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
486
496
|
flowId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
487
497
|
flowPath: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
488
498
|
attendeeStatus: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, AttendeeStatus.Tentative),
|
|
499
|
+
status: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.number), null),
|
|
489
500
|
rescheduleLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
490
501
|
cancelLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
491
502
|
timeZone: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
492
503
|
offset: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
493
504
|
eventSource: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, EventSource.AppointmentType)
|
|
494
|
-
}).
|
|
505
|
+
}).views((self) => ({
|
|
506
|
+
/** calendarLocationValue, else customLocation (one-off / typed location). */
|
|
507
|
+
get displayLocation() {
|
|
508
|
+
return self.calendarLocationValue ?? self.customLocation ?? null;
|
|
509
|
+
}
|
|
510
|
+
})).actions((self) => {
|
|
495
511
|
const { req, reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree4.getEnv);
|
|
496
512
|
const getOffset = () => {
|
|
497
513
|
var _a, _b;
|
|
@@ -619,6 +635,18 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
619
635
|
async setAttendeeStatus(status) {
|
|
620
636
|
const statusName = typeof status === "number" ? Object.keys(AttendeeStatus).find((k) => AttendeeStatus[k] === status) ?? "None" : status;
|
|
621
637
|
return reqGet(`/event/${encodeURIComponent(self.eventId)}/${encodeURIComponent(statusName)}`);
|
|
638
|
+
},
|
|
639
|
+
/** GET /event/status/update – update event lifecycle status */
|
|
640
|
+
async setEventStatus(status) {
|
|
641
|
+
const statusValue = typeof status === "number" ? status : EventStatus[status] ?? status;
|
|
642
|
+
const res = await reqGet("/event/status/update", {
|
|
643
|
+
event_id: self.eventId,
|
|
644
|
+
status: statusValue
|
|
645
|
+
});
|
|
646
|
+
if (res.status === "success" && res.data) {
|
|
647
|
+
(0, import_mobx_state_tree4.applySnapshot)(self, { ...mapEventFromApi(res.data), eventId: self.eventId });
|
|
648
|
+
}
|
|
649
|
+
return res;
|
|
622
650
|
}
|
|
623
651
|
};
|
|
624
652
|
});
|
|
@@ -646,10 +674,12 @@ function mapEventFromApi(d) {
|
|
|
646
674
|
visitorPhone: pick2("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
647
675
|
externalEventId: pick2("externalEventId", "ExternalEventId", "externalEventId", "external_event_id"),
|
|
648
676
|
calendarLocationId: pick2("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
677
|
+
calendarLocationValue: pick2("calendarLocationValue", "CalendarLocationValue", "calendar_location_value"),
|
|
649
678
|
customLocation: pick2("customLocation", "CustomLocation", "custom_location"),
|
|
650
679
|
flowId: pick2("flowId", "FlowId", "flow_id"),
|
|
651
680
|
flowPath: pick2("flowPath", "FlowPath", "flow_path"),
|
|
652
681
|
attendeeStatus: n(pick2("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
682
|
+
status: n(pick2("status", "Status")),
|
|
653
683
|
eventSource: n(pick2("eventSource", "EventSource", "event_source")),
|
|
654
684
|
rescheduleLink: pick2("rescheduleLink", "RescheduleLink", "reschedule_link"),
|
|
655
685
|
cancelLink: pick2("cancelLink", "CancelLink", "cancel_link"),
|
|
@@ -881,6 +911,11 @@ EventModel.setAttendeeStatus = async (eventId, attendeeStatus) => {
|
|
|
881
911
|
const statusName = typeof attendeeStatus === "number" ? Object.keys(AttendeeStatus).find((k) => AttendeeStatus[k] === attendeeStatus) ?? "None" : attendeeStatus;
|
|
882
912
|
return reqGet(`/event/${encodeURIComponent(eventId)}/${encodeURIComponent(statusName)}`);
|
|
883
913
|
};
|
|
914
|
+
EventModel.setEventStatus = async (eventId, status) => {
|
|
915
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
916
|
+
const statusValue = typeof status === "number" ? status : EventStatus[status] ?? status;
|
|
917
|
+
return reqGet("/event/status/update", { event_id: eventId, status: statusValue });
|
|
918
|
+
};
|
|
884
919
|
var Event_default = EventModel;
|
|
885
920
|
|
|
886
921
|
// src/models/appointment/CalendarParticipant.js
|
|
@@ -1678,30 +1713,96 @@ var OpeningHourModel = import_mobx_state_tree12.types.model("OpeningHour", {
|
|
|
1678
1713
|
});
|
|
1679
1714
|
var OpeningHour_default = OpeningHourModel;
|
|
1680
1715
|
|
|
1681
|
-
// src/models/appointment/
|
|
1716
|
+
// src/models/appointment/ExternalEvent.js
|
|
1682
1717
|
var import_mobx_state_tree13 = require("mobx-state-tree");
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1718
|
+
function getDefaultOffset2() {
|
|
1719
|
+
var _a;
|
|
1720
|
+
const cfg = getConfig();
|
|
1721
|
+
return ((_a = cfg == null ? void 0 : cfg.getDefaultOffset) == null ? void 0 : _a.call(cfg)) ?? -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
1722
|
+
}
|
|
1723
|
+
function pickStr(obj, ...keys) {
|
|
1724
|
+
for (const k of keys) {
|
|
1725
|
+
const v = obj[k];
|
|
1726
|
+
if (v != null && typeof v === "string") return v;
|
|
1727
|
+
}
|
|
1728
|
+
return void 0;
|
|
1729
|
+
}
|
|
1730
|
+
function pickNum(obj, ...keys) {
|
|
1731
|
+
for (const k of keys) {
|
|
1732
|
+
const v = obj[k];
|
|
1733
|
+
if (v != null) {
|
|
1734
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
1735
|
+
if (!Number.isNaN(n)) return n;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
return void 0;
|
|
1739
|
+
}
|
|
1740
|
+
function toIsoDate(value) {
|
|
1741
|
+
if (value == null || value === "") return "";
|
|
1742
|
+
if (typeof value === "string") return value;
|
|
1743
|
+
if (value instanceof Date) return value.toISOString();
|
|
1744
|
+
return String(value);
|
|
1745
|
+
}
|
|
1746
|
+
var ExternalEventModel = import_mobx_state_tree13.types.model("ExternalEvent", {
|
|
1747
|
+
title: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.maybeNull(import_mobx_state_tree13.types.string), null),
|
|
1748
|
+
startDate: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.string, ""),
|
|
1749
|
+
endDate: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.string, ""),
|
|
1750
|
+
startHour: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.number, 0),
|
|
1751
|
+
startMinute: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.number, 0),
|
|
1752
|
+
endHour: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.number, 0),
|
|
1753
|
+
endMinute: import_mobx_state_tree13.types.optional(import_mobx_state_tree13.types.number, 0)
|
|
1754
|
+
});
|
|
1755
|
+
function mapApiRow(row) {
|
|
1756
|
+
return ExternalEventModel.create({
|
|
1757
|
+
title: pickStr(row, "title", "Title") ?? null,
|
|
1758
|
+
startDate: toIsoDate(row.startDate ?? row.StartDate),
|
|
1759
|
+
endDate: toIsoDate(row.endDate ?? row.EndDate),
|
|
1760
|
+
startHour: pickNum(row, "startHour", "StartHour") ?? 0,
|
|
1761
|
+
startMinute: pickNum(row, "startMinute", "StartMinute") ?? 0,
|
|
1762
|
+
endHour: pickNum(row, "endHour", "EndHour") ?? 0,
|
|
1763
|
+
endMinute: pickNum(row, "endMinute", "EndMinute") ?? 0
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
ExternalEventModel.getByParticipant = async (participantId, opts = {}) => {
|
|
1767
|
+
if (!participantId) throw new Error("participantId required");
|
|
1768
|
+
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
1769
|
+
const offset = opts.offset ?? getDefaultOffset2();
|
|
1770
|
+
const res = await req("/externalcalendar/events/get", {
|
|
1771
|
+
method: "GET",
|
|
1772
|
+
query: { participant_id: participantId },
|
|
1773
|
+
headers: { offset: String(offset) }
|
|
1774
|
+
});
|
|
1775
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1776
|
+
return res.data.map(mapApiRow);
|
|
1777
|
+
}
|
|
1778
|
+
return [];
|
|
1779
|
+
};
|
|
1780
|
+
var ExternalEvent_default = ExternalEventModel;
|
|
1781
|
+
|
|
1782
|
+
// src/models/appointment/Setting.js
|
|
1783
|
+
var import_mobx_state_tree14 = require("mobx-state-tree");
|
|
1784
|
+
var SettingModel = import_mobx_state_tree14.types.model("Setting", {
|
|
1785
|
+
id: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.maybeNull(import_mobx_state_tree14.types.number), null),
|
|
1786
|
+
settingsId: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.string, ""),
|
|
1787
|
+
calendarId: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.string, ""),
|
|
1788
|
+
logo: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.maybeNull(import_mobx_state_tree14.types.string), null),
|
|
1789
|
+
theme: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.maybeNull(import_mobx_state_tree14.types.string), null),
|
|
1790
|
+
schedulingButtonText: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.maybeNull(import_mobx_state_tree14.types.string), null),
|
|
1791
|
+
scheduledMessage: import_mobx_state_tree14.types.optional(import_mobx_state_tree14.types.maybeNull(import_mobx_state_tree14.types.string), null)
|
|
1691
1792
|
}).actions((self) => {
|
|
1692
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1793
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree14.getEnv);
|
|
1693
1794
|
return {
|
|
1694
1795
|
/** GET setting/get – fetch setting for this calendar */
|
|
1695
1796
|
async get() {
|
|
1696
1797
|
const res = await reqGet("/setting/get", { calendar_id: self.calendarId });
|
|
1697
|
-
if (res.status === "success" && res.data) (0,
|
|
1798
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree14.applySnapshot)(self, mapFromApi3(res.data));
|
|
1698
1799
|
return res;
|
|
1699
1800
|
},
|
|
1700
1801
|
/** POST setting/save – save this setting */
|
|
1701
1802
|
async save() {
|
|
1702
1803
|
const payload = toPayload2(self);
|
|
1703
1804
|
const res = await reqPost("/setting/save", payload);
|
|
1704
|
-
if (res.status === "success" && res.data) (0,
|
|
1805
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree14.applySnapshot)(self, mapFromApi3(res.data));
|
|
1705
1806
|
return res;
|
|
1706
1807
|
},
|
|
1707
1808
|
/** POST setting/logo/upload – upload logo file for this calendar */
|
|
@@ -1776,27 +1877,27 @@ SettingModel.uploadLogo = async (calendarId, file) => {
|
|
|
1776
1877
|
var Setting_default = SettingModel;
|
|
1777
1878
|
|
|
1778
1879
|
// src/models/appointment/Company.js
|
|
1779
|
-
var
|
|
1780
|
-
var CompanyModel =
|
|
1781
|
-
id:
|
|
1782
|
-
companyKey:
|
|
1783
|
-
companyName:
|
|
1784
|
-
createdOn:
|
|
1785
|
-
modifiedOn:
|
|
1880
|
+
var import_mobx_state_tree15 = require("mobx-state-tree");
|
|
1881
|
+
var CompanyModel = import_mobx_state_tree15.types.model("Company", {
|
|
1882
|
+
id: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.number), null),
|
|
1883
|
+
companyKey: import_mobx_state_tree15.types.identifier,
|
|
1884
|
+
companyName: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.string, ""),
|
|
1885
|
+
createdOn: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1886
|
+
modifiedOn: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null)
|
|
1786
1887
|
}).actions((self) => {
|
|
1787
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1888
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree15.getEnv);
|
|
1788
1889
|
return {
|
|
1789
1890
|
/** GET Company/Get – fetch this company */
|
|
1790
1891
|
async get() {
|
|
1791
1892
|
const res = await reqGet("/Company/Get", { company_key: self.companyKey });
|
|
1792
|
-
if (res.status === "success" && res.data) (0,
|
|
1893
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree15.applySnapshot)(self, mapFromApi4(res.data));
|
|
1793
1894
|
return res;
|
|
1794
1895
|
},
|
|
1795
1896
|
/** POST Company/Save – save this company */
|
|
1796
1897
|
async save() {
|
|
1797
1898
|
const payload = toPayload3(self);
|
|
1798
1899
|
const res = await reqPost("/Company/Save", payload);
|
|
1799
|
-
if (res.status === "success" && res.data) (0,
|
|
1900
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree15.applySnapshot)(self, mapFromApi4(res.data));
|
|
1800
1901
|
return res;
|
|
1801
1902
|
}
|
|
1802
1903
|
};
|
|
@@ -1844,13 +1945,13 @@ CompanyModel.save = async (payload) => {
|
|
|
1844
1945
|
var Company_default = CompanyModel;
|
|
1845
1946
|
|
|
1846
1947
|
// src/models/appointment/Asset.js
|
|
1847
|
-
var
|
|
1848
|
-
var AssetModel =
|
|
1849
|
-
url:
|
|
1850
|
-
blobPath:
|
|
1851
|
-
category:
|
|
1852
|
-
contentType:
|
|
1853
|
-
size:
|
|
1948
|
+
var import_mobx_state_tree16 = require("mobx-state-tree");
|
|
1949
|
+
var AssetModel = import_mobx_state_tree16.types.model("Asset", {
|
|
1950
|
+
url: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1951
|
+
blobPath: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1952
|
+
category: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1953
|
+
contentType: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1954
|
+
size: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.number), null)
|
|
1854
1955
|
}).actions((self) => ({
|
|
1855
1956
|
/** POST /asset/upload – upload file using model category. */
|
|
1856
1957
|
async upload(file, opts = {}) {
|
|
@@ -1924,7 +2025,7 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1924
2025
|
var Asset_default = AssetModel;
|
|
1925
2026
|
|
|
1926
2027
|
// src/models/appointment/CalendarLocation.js
|
|
1927
|
-
var
|
|
2028
|
+
var import_mobx_state_tree17 = require("mobx-state-tree");
|
|
1928
2029
|
function mapCalendarLocationFromApi(d) {
|
|
1929
2030
|
if (!d) return d;
|
|
1930
2031
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1954,19 +2055,19 @@ function toPayload4(self) {
|
|
|
1954
2055
|
sortOrder: self.sortOrder
|
|
1955
2056
|
};
|
|
1956
2057
|
}
|
|
1957
|
-
var CalendarLocationModel =
|
|
1958
|
-
id:
|
|
1959
|
-
calendarLocationId:
|
|
1960
|
-
calendarId:
|
|
1961
|
-
locationType:
|
|
1962
|
-
name:
|
|
1963
|
-
value:
|
|
1964
|
-
isDefault:
|
|
1965
|
-
sortOrder:
|
|
1966
|
-
createdOn:
|
|
1967
|
-
modifiedOn:
|
|
2058
|
+
var CalendarLocationModel = import_mobx_state_tree17.types.model("CalendarLocation", {
|
|
2059
|
+
id: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number), null),
|
|
2060
|
+
calendarLocationId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
2061
|
+
calendarId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
2062
|
+
locationType: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.number, LocationType.Physical),
|
|
2063
|
+
name: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
2064
|
+
value: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
2065
|
+
isDefault: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.boolean, false),
|
|
2066
|
+
sortOrder: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.number, 0),
|
|
2067
|
+
createdOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
2068
|
+
modifiedOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null)
|
|
1968
2069
|
}).actions((self) => {
|
|
1969
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2070
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree17.getEnv);
|
|
1970
2071
|
return {
|
|
1971
2072
|
/** GET Calendar/Location/Get – list locations by calendar id */
|
|
1972
2073
|
async getByCalendar(calendarId) {
|
|
@@ -1984,7 +2085,7 @@ var CalendarLocationModel = import_mobx_state_tree16.types.model("CalendarLocati
|
|
|
1984
2085
|
async save() {
|
|
1985
2086
|
const res = await reqPost("/Calendar/Location/Save", toPayload4(self));
|
|
1986
2087
|
if (res.status === "success" && res.data) {
|
|
1987
|
-
(0,
|
|
2088
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapCalendarLocationFromApi(res.data));
|
|
1988
2089
|
}
|
|
1989
2090
|
return res;
|
|
1990
2091
|
},
|
|
@@ -2046,7 +2147,7 @@ CalendarLocationModel.setDefault = async (calendarId, calendarLocationId) => {
|
|
|
2046
2147
|
var CalendarLocation_default = CalendarLocationModel;
|
|
2047
2148
|
|
|
2048
2149
|
// src/models/appointment/Preference.js
|
|
2049
|
-
var
|
|
2150
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
2050
2151
|
var PreferenceScope = {
|
|
2051
2152
|
Global: 0,
|
|
2052
2153
|
Consumer: 1,
|
|
@@ -2057,13 +2158,13 @@ var PreferenceScope = {
|
|
|
2057
2158
|
User: 6
|
|
2058
2159
|
};
|
|
2059
2160
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event", "Participant", "User"];
|
|
2060
|
-
var PreferenceModel =
|
|
2061
|
-
id:
|
|
2062
|
-
preferenceId:
|
|
2063
|
-
level:
|
|
2064
|
-
primaryKey:
|
|
2065
|
-
preferenceOption:
|
|
2066
|
-
optionsJson:
|
|
2161
|
+
var PreferenceModel = import_mobx_state_tree18.types.model("Preference", {
|
|
2162
|
+
id: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.number), null),
|
|
2163
|
+
preferenceId: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
2164
|
+
level: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.number, 0),
|
|
2165
|
+
primaryKey: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2166
|
+
preferenceOption: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2167
|
+
optionsJson: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null)
|
|
2067
2168
|
}).actions((self) => ({
|
|
2068
2169
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
2069
2170
|
async save() {
|
|
@@ -2111,7 +2212,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
2111
2212
|
var Preference_default = PreferenceModel;
|
|
2112
2213
|
|
|
2113
2214
|
// src/models/appointment/Flow.js
|
|
2114
|
-
var
|
|
2215
|
+
var import_mobx_state_tree19 = require("mobx-state-tree");
|
|
2115
2216
|
function mapFlowFromApi(d) {
|
|
2116
2217
|
if (!d) return d;
|
|
2117
2218
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2130,27 +2231,27 @@ function mapFlowFromApi(d) {
|
|
|
2130
2231
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2131
2232
|
};
|
|
2132
2233
|
}
|
|
2133
|
-
var FlowModel =
|
|
2134
|
-
id:
|
|
2135
|
-
flowId:
|
|
2136
|
-
companyKey:
|
|
2137
|
-
calendarId:
|
|
2138
|
-
name:
|
|
2139
|
-
description:
|
|
2140
|
-
flowJson:
|
|
2141
|
-
isActive:
|
|
2142
|
-
isDeleted:
|
|
2143
|
-
createdOn:
|
|
2144
|
-
modifiedOn:
|
|
2234
|
+
var FlowModel = import_mobx_state_tree19.types.model("Flow", {
|
|
2235
|
+
id: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.number), null),
|
|
2236
|
+
flowId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.identifier, "new"),
|
|
2237
|
+
companyKey: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2238
|
+
calendarId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2239
|
+
name: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2240
|
+
description: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2241
|
+
flowJson: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2242
|
+
isActive: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, true),
|
|
2243
|
+
isDeleted: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, false),
|
|
2244
|
+
createdOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2245
|
+
modifiedOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null)
|
|
2145
2246
|
}).actions((self) => {
|
|
2146
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2247
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree19.getEnv);
|
|
2147
2248
|
return {
|
|
2148
2249
|
/** GET flow/get – fetch this flow by flowId */
|
|
2149
2250
|
async get() {
|
|
2150
2251
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
2151
2252
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
2152
2253
|
if (res.status === "success" && res.data) {
|
|
2153
|
-
(0,
|
|
2254
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
2154
2255
|
}
|
|
2155
2256
|
return res;
|
|
2156
2257
|
},
|
|
@@ -2166,7 +2267,7 @@ var FlowModel = import_mobx_state_tree18.types.model("Flow", {
|
|
|
2166
2267
|
};
|
|
2167
2268
|
const res = await reqPost("/flow/create", payload);
|
|
2168
2269
|
if (res.status === "success" && res.data) {
|
|
2169
|
-
(0,
|
|
2270
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
2170
2271
|
}
|
|
2171
2272
|
return res;
|
|
2172
2273
|
},
|
|
@@ -2183,7 +2284,7 @@ var FlowModel = import_mobx_state_tree18.types.model("Flow", {
|
|
|
2183
2284
|
};
|
|
2184
2285
|
const res = await reqPost("/flow/update", payload);
|
|
2185
2286
|
if (res.status === "success" && res.data) {
|
|
2186
|
-
(0,
|
|
2287
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
2187
2288
|
}
|
|
2188
2289
|
return res;
|
|
2189
2290
|
},
|
|
@@ -2197,7 +2298,7 @@ var FlowModel = import_mobx_state_tree18.types.model("Flow", {
|
|
|
2197
2298
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
2198
2299
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
2199
2300
|
if (res.status === "success" && res.data) {
|
|
2200
|
-
(0,
|
|
2301
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
2201
2302
|
}
|
|
2202
2303
|
return res;
|
|
2203
2304
|
},
|
|
@@ -2374,7 +2475,20 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2374
2475
|
var Flow_default = FlowModel;
|
|
2375
2476
|
|
|
2376
2477
|
// src/models/appointment/Lead.js
|
|
2377
|
-
var
|
|
2478
|
+
var import_mobx_state_tree20 = require("mobx-state-tree");
|
|
2479
|
+
function pickLeadCreateContact(payload) {
|
|
2480
|
+
const p = payload ?? {};
|
|
2481
|
+
const email = String(p.email ?? p.Email ?? "").trim();
|
|
2482
|
+
const phone = String(p.phone ?? p.Phone ?? "").trim();
|
|
2483
|
+
const companyKey = String(p.companyKey ?? p.company_key ?? p.CompanyKey ?? "").trim();
|
|
2484
|
+
return { email, phone, companyKey };
|
|
2485
|
+
}
|
|
2486
|
+
function validateLeadCreatePayload(payload) {
|
|
2487
|
+
const { email, phone, companyKey } = pickLeadCreateContact(payload);
|
|
2488
|
+
if (!companyKey) return { ok: false, message: "companyKey is required" };
|
|
2489
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2490
|
+
return { ok: true };
|
|
2491
|
+
}
|
|
2378
2492
|
function mapLeadFromApi(d) {
|
|
2379
2493
|
if (!d) return d;
|
|
2380
2494
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2403,27 +2517,27 @@ function mapLeadFromApi(d) {
|
|
|
2403
2517
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2404
2518
|
};
|
|
2405
2519
|
}
|
|
2406
|
-
var LeadModel =
|
|
2407
|
-
id:
|
|
2408
|
-
leadId:
|
|
2409
|
-
email:
|
|
2410
|
-
name:
|
|
2411
|
-
phone:
|
|
2412
|
-
companyKey:
|
|
2413
|
-
source:
|
|
2414
|
-
leadType:
|
|
2415
|
-
referrerLink:
|
|
2416
|
-
createdOn:
|
|
2417
|
-
modifiedOn:
|
|
2520
|
+
var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
2521
|
+
id: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.number), null),
|
|
2522
|
+
leadId: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.identifier, "new"),
|
|
2523
|
+
email: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2524
|
+
name: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2525
|
+
phone: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2526
|
+
companyKey: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2527
|
+
source: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2528
|
+
leadType: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.number, 2),
|
|
2529
|
+
referrerLink: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2530
|
+
createdOn: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2531
|
+
modifiedOn: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null)
|
|
2418
2532
|
}).actions((self) => {
|
|
2419
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2533
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree20.getEnv);
|
|
2420
2534
|
return {
|
|
2421
2535
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2422
2536
|
async get() {
|
|
2423
2537
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2424
2538
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2425
2539
|
if (res.status === "success" && res.data) {
|
|
2426
|
-
(0,
|
|
2540
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2427
2541
|
}
|
|
2428
2542
|
return res;
|
|
2429
2543
|
},
|
|
@@ -2434,7 +2548,7 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2434
2548
|
}
|
|
2435
2549
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2436
2550
|
if (lead) {
|
|
2437
|
-
(0,
|
|
2551
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, (0, import_mobx_state_tree20.getSnapshot)(lead));
|
|
2438
2552
|
}
|
|
2439
2553
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2440
2554
|
},
|
|
@@ -2445,7 +2559,7 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2445
2559
|
}
|
|
2446
2560
|
const lead = await LeadModel.getByPhone(self.phone, self.companyKey);
|
|
2447
2561
|
if (lead) {
|
|
2448
|
-
(0,
|
|
2562
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, (0, import_mobx_state_tree20.getSnapshot)(lead));
|
|
2449
2563
|
}
|
|
2450
2564
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2451
2565
|
},
|
|
@@ -2462,8 +2576,14 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2462
2576
|
async getColumnSelection(userId) {
|
|
2463
2577
|
return LeadModel.getColumnSelection(userId);
|
|
2464
2578
|
},
|
|
2465
|
-
/** POST /lead/create – create this lead */
|
|
2579
|
+
/** POST /lead/create – create this lead (requires companyKey and email or phone) */
|
|
2466
2580
|
async createLead() {
|
|
2581
|
+
const validation = validateLeadCreatePayload({
|
|
2582
|
+
email: self.email,
|
|
2583
|
+
phone: self.phone,
|
|
2584
|
+
companyKey: self.companyKey
|
|
2585
|
+
});
|
|
2586
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2467
2587
|
const payload = {
|
|
2468
2588
|
email: self.email,
|
|
2469
2589
|
name: self.name,
|
|
@@ -2475,7 +2595,7 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2475
2595
|
};
|
|
2476
2596
|
const res = await reqPost("/lead/create", payload);
|
|
2477
2597
|
if (res.status === "success" && res.data) {
|
|
2478
|
-
(0,
|
|
2598
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2479
2599
|
}
|
|
2480
2600
|
return res;
|
|
2481
2601
|
},
|
|
@@ -2496,7 +2616,7 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2496
2616
|
};
|
|
2497
2617
|
const res = await reqPost("/lead/update", payload);
|
|
2498
2618
|
if (res.status === "success" && res.data) {
|
|
2499
|
-
(0,
|
|
2619
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2500
2620
|
}
|
|
2501
2621
|
return res;
|
|
2502
2622
|
},
|
|
@@ -2613,6 +2733,8 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2613
2733
|
return null;
|
|
2614
2734
|
};
|
|
2615
2735
|
LeadModel.createLead = async (payload) => {
|
|
2736
|
+
const validation = validateLeadCreatePayload(payload);
|
|
2737
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2616
2738
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2617
2739
|
const res = await reqPost("/lead/create", payload);
|
|
2618
2740
|
if (res.status === "success" && res.data) {
|
|
@@ -2668,19 +2790,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2668
2790
|
var Lead_default = LeadModel;
|
|
2669
2791
|
|
|
2670
2792
|
// src/models/appointment/CustomField.js
|
|
2671
|
-
var
|
|
2672
|
-
var CustomFieldModel =
|
|
2673
|
-
id:
|
|
2674
|
-
customFieldId:
|
|
2675
|
-
calendarId:
|
|
2676
|
-
label:
|
|
2677
|
-
type:
|
|
2678
|
-
isRequired:
|
|
2679
|
-
createdOn:
|
|
2680
|
-
modifiedOn:
|
|
2681
|
-
isDeleted:
|
|
2793
|
+
var import_mobx_state_tree21 = require("mobx-state-tree");
|
|
2794
|
+
var CustomFieldModel = import_mobx_state_tree21.types.model("CustomField", {
|
|
2795
|
+
id: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.number), null),
|
|
2796
|
+
customFieldId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2797
|
+
calendarId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2798
|
+
label: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2799
|
+
type: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
|
|
2800
|
+
isRequired: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false),
|
|
2801
|
+
createdOn: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2802
|
+
modifiedOn: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2803
|
+
isDeleted: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false)
|
|
2682
2804
|
}).actions((self) => {
|
|
2683
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2805
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree21.getEnv);
|
|
2684
2806
|
return {
|
|
2685
2807
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2686
2808
|
async getAll(calendarId) {
|
|
@@ -2701,7 +2823,7 @@ var CustomFieldModel = import_mobx_state_tree20.types.model("CustomField", {
|
|
|
2701
2823
|
const body = payload ?? toPayload5(self);
|
|
2702
2824
|
const res = await reqPost("/CustomField/Add", body);
|
|
2703
2825
|
if (res.status === "success" && res.data) {
|
|
2704
|
-
(0,
|
|
2826
|
+
(0, import_mobx_state_tree21.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
2705
2827
|
}
|
|
2706
2828
|
return res;
|
|
2707
2829
|
},
|
|
@@ -3008,10 +3130,10 @@ var AuthModel = {
|
|
|
3008
3130
|
var Auth_default = AuthModel;
|
|
3009
3131
|
|
|
3010
3132
|
// src/models/appointment/index.js
|
|
3011
|
-
var
|
|
3012
|
-
var RootStore =
|
|
3013
|
-
calendars:
|
|
3014
|
-
events:
|
|
3133
|
+
var import_mobx_state_tree22 = require("mobx-state-tree");
|
|
3134
|
+
var RootStore = import_mobx_state_tree22.types.model("RootStore", {
|
|
3135
|
+
calendars: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.map(Calendar_default), {}),
|
|
3136
|
+
events: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.map(Event_default), {})
|
|
3015
3137
|
}).actions((self) => ({
|
|
3016
3138
|
addCalendar(snapshot) {
|
|
3017
3139
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -3051,6 +3173,8 @@ function createRootStore(initialState = {}) {
|
|
|
3051
3173
|
EmailProvider,
|
|
3052
3174
|
EventModel,
|
|
3053
3175
|
EventSource,
|
|
3176
|
+
EventStatus,
|
|
3177
|
+
ExternalEventModel,
|
|
3054
3178
|
FlowModel,
|
|
3055
3179
|
LeadModel,
|
|
3056
3180
|
LocationType,
|
package/dist/index.mjs
CHANGED
|
@@ -266,6 +266,12 @@ var AttendeeStatus = {
|
|
|
266
266
|
NeedsAction: 4,
|
|
267
267
|
Canceled: 5
|
|
268
268
|
};
|
|
269
|
+
var EventStatus = {
|
|
270
|
+
Scheduled: 1,
|
|
271
|
+
ReScheduled: 2,
|
|
272
|
+
Completed: 3,
|
|
273
|
+
Canceled: 4
|
|
274
|
+
};
|
|
269
275
|
var RecurringFrequency = {
|
|
270
276
|
None: 0,
|
|
271
277
|
Daily: 1,
|
|
@@ -410,16 +416,24 @@ var EventModel = types4.model("Event", {
|
|
|
410
416
|
modifiedOn: types4.optional(types4.maybeNull(types4.string), null),
|
|
411
417
|
externalEventId: types4.optional(types4.maybeNull(types4.string), null),
|
|
412
418
|
calendarLocationId: types4.optional(types4.maybeNull(types4.string), null),
|
|
419
|
+
/** Resolved location text from CalendarLocation when returned by search APIs. */
|
|
420
|
+
calendarLocationValue: types4.optional(types4.maybeNull(types4.string), null),
|
|
413
421
|
customLocation: types4.optional(types4.maybeNull(types4.string), null),
|
|
414
422
|
flowId: types4.optional(types4.maybeNull(types4.string), null),
|
|
415
423
|
flowPath: types4.optional(types4.maybeNull(types4.string), null),
|
|
416
424
|
attendeeStatus: types4.optional(types4.number, AttendeeStatus.Tentative),
|
|
425
|
+
status: types4.optional(types4.maybeNull(types4.number), null),
|
|
417
426
|
rescheduleLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
418
427
|
cancelLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
419
428
|
timeZone: types4.optional(types4.maybeNull(types4.string), null),
|
|
420
429
|
offset: types4.optional(types4.number, 0),
|
|
421
430
|
eventSource: types4.optional(types4.number, EventSource.AppointmentType)
|
|
422
|
-
}).
|
|
431
|
+
}).views((self) => ({
|
|
432
|
+
/** calendarLocationValue, else customLocation (one-off / typed location). */
|
|
433
|
+
get displayLocation() {
|
|
434
|
+
return self.calendarLocationValue ?? self.customLocation ?? null;
|
|
435
|
+
}
|
|
436
|
+
})).actions((self) => {
|
|
423
437
|
const { req, reqGet, reqPost } = createRequestHelpers(self, getEnv);
|
|
424
438
|
const getOffset = () => {
|
|
425
439
|
var _a, _b;
|
|
@@ -547,6 +561,18 @@ var EventModel = types4.model("Event", {
|
|
|
547
561
|
async setAttendeeStatus(status) {
|
|
548
562
|
const statusName = typeof status === "number" ? Object.keys(AttendeeStatus).find((k) => AttendeeStatus[k] === status) ?? "None" : status;
|
|
549
563
|
return reqGet(`/event/${encodeURIComponent(self.eventId)}/${encodeURIComponent(statusName)}`);
|
|
564
|
+
},
|
|
565
|
+
/** GET /event/status/update – update event lifecycle status */
|
|
566
|
+
async setEventStatus(status) {
|
|
567
|
+
const statusValue = typeof status === "number" ? status : EventStatus[status] ?? status;
|
|
568
|
+
const res = await reqGet("/event/status/update", {
|
|
569
|
+
event_id: self.eventId,
|
|
570
|
+
status: statusValue
|
|
571
|
+
});
|
|
572
|
+
if (res.status === "success" && res.data) {
|
|
573
|
+
applySnapshot(self, { ...mapEventFromApi(res.data), eventId: self.eventId });
|
|
574
|
+
}
|
|
575
|
+
return res;
|
|
550
576
|
}
|
|
551
577
|
};
|
|
552
578
|
});
|
|
@@ -574,10 +600,12 @@ function mapEventFromApi(d) {
|
|
|
574
600
|
visitorPhone: pick2("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
575
601
|
externalEventId: pick2("externalEventId", "ExternalEventId", "externalEventId", "external_event_id"),
|
|
576
602
|
calendarLocationId: pick2("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
603
|
+
calendarLocationValue: pick2("calendarLocationValue", "CalendarLocationValue", "calendar_location_value"),
|
|
577
604
|
customLocation: pick2("customLocation", "CustomLocation", "custom_location"),
|
|
578
605
|
flowId: pick2("flowId", "FlowId", "flow_id"),
|
|
579
606
|
flowPath: pick2("flowPath", "FlowPath", "flow_path"),
|
|
580
607
|
attendeeStatus: n(pick2("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
608
|
+
status: n(pick2("status", "Status")),
|
|
581
609
|
eventSource: n(pick2("eventSource", "EventSource", "event_source")),
|
|
582
610
|
rescheduleLink: pick2("rescheduleLink", "RescheduleLink", "reschedule_link"),
|
|
583
611
|
cancelLink: pick2("cancelLink", "CancelLink", "cancel_link"),
|
|
@@ -809,6 +837,11 @@ EventModel.setAttendeeStatus = async (eventId, attendeeStatus) => {
|
|
|
809
837
|
const statusName = typeof attendeeStatus === "number" ? Object.keys(AttendeeStatus).find((k) => AttendeeStatus[k] === attendeeStatus) ?? "None" : attendeeStatus;
|
|
810
838
|
return reqGet(`/event/${encodeURIComponent(eventId)}/${encodeURIComponent(statusName)}`);
|
|
811
839
|
};
|
|
840
|
+
EventModel.setEventStatus = async (eventId, status) => {
|
|
841
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
842
|
+
const statusValue = typeof status === "number" ? status : EventStatus[status] ?? status;
|
|
843
|
+
return reqGet("/event/status/update", { event_id: eventId, status: statusValue });
|
|
844
|
+
};
|
|
812
845
|
var Event_default = EventModel;
|
|
813
846
|
|
|
814
847
|
// src/models/appointment/CalendarParticipant.js
|
|
@@ -1606,16 +1639,82 @@ var OpeningHourModel = types12.model("OpeningHour", {
|
|
|
1606
1639
|
});
|
|
1607
1640
|
var OpeningHour_default = OpeningHourModel;
|
|
1608
1641
|
|
|
1642
|
+
// src/models/appointment/ExternalEvent.js
|
|
1643
|
+
import { types as types13 } from "mobx-state-tree";
|
|
1644
|
+
function getDefaultOffset2() {
|
|
1645
|
+
var _a;
|
|
1646
|
+
const cfg = getConfig();
|
|
1647
|
+
return ((_a = cfg == null ? void 0 : cfg.getDefaultOffset) == null ? void 0 : _a.call(cfg)) ?? -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
1648
|
+
}
|
|
1649
|
+
function pickStr(obj, ...keys) {
|
|
1650
|
+
for (const k of keys) {
|
|
1651
|
+
const v = obj[k];
|
|
1652
|
+
if (v != null && typeof v === "string") return v;
|
|
1653
|
+
}
|
|
1654
|
+
return void 0;
|
|
1655
|
+
}
|
|
1656
|
+
function pickNum(obj, ...keys) {
|
|
1657
|
+
for (const k of keys) {
|
|
1658
|
+
const v = obj[k];
|
|
1659
|
+
if (v != null) {
|
|
1660
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
1661
|
+
if (!Number.isNaN(n)) return n;
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
return void 0;
|
|
1665
|
+
}
|
|
1666
|
+
function toIsoDate(value) {
|
|
1667
|
+
if (value == null || value === "") return "";
|
|
1668
|
+
if (typeof value === "string") return value;
|
|
1669
|
+
if (value instanceof Date) return value.toISOString();
|
|
1670
|
+
return String(value);
|
|
1671
|
+
}
|
|
1672
|
+
var ExternalEventModel = types13.model("ExternalEvent", {
|
|
1673
|
+
title: types13.optional(types13.maybeNull(types13.string), null),
|
|
1674
|
+
startDate: types13.optional(types13.string, ""),
|
|
1675
|
+
endDate: types13.optional(types13.string, ""),
|
|
1676
|
+
startHour: types13.optional(types13.number, 0),
|
|
1677
|
+
startMinute: types13.optional(types13.number, 0),
|
|
1678
|
+
endHour: types13.optional(types13.number, 0),
|
|
1679
|
+
endMinute: types13.optional(types13.number, 0)
|
|
1680
|
+
});
|
|
1681
|
+
function mapApiRow(row) {
|
|
1682
|
+
return ExternalEventModel.create({
|
|
1683
|
+
title: pickStr(row, "title", "Title") ?? null,
|
|
1684
|
+
startDate: toIsoDate(row.startDate ?? row.StartDate),
|
|
1685
|
+
endDate: toIsoDate(row.endDate ?? row.EndDate),
|
|
1686
|
+
startHour: pickNum(row, "startHour", "StartHour") ?? 0,
|
|
1687
|
+
startMinute: pickNum(row, "startMinute", "StartMinute") ?? 0,
|
|
1688
|
+
endHour: pickNum(row, "endHour", "EndHour") ?? 0,
|
|
1689
|
+
endMinute: pickNum(row, "endMinute", "EndMinute") ?? 0
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
ExternalEventModel.getByParticipant = async (participantId, opts = {}) => {
|
|
1693
|
+
if (!participantId) throw new Error("participantId required");
|
|
1694
|
+
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
1695
|
+
const offset = opts.offset ?? getDefaultOffset2();
|
|
1696
|
+
const res = await req("/externalcalendar/events/get", {
|
|
1697
|
+
method: "GET",
|
|
1698
|
+
query: { participant_id: participantId },
|
|
1699
|
+
headers: { offset: String(offset) }
|
|
1700
|
+
});
|
|
1701
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1702
|
+
return res.data.map(mapApiRow);
|
|
1703
|
+
}
|
|
1704
|
+
return [];
|
|
1705
|
+
};
|
|
1706
|
+
var ExternalEvent_default = ExternalEventModel;
|
|
1707
|
+
|
|
1609
1708
|
// src/models/appointment/Setting.js
|
|
1610
|
-
import { types as
|
|
1611
|
-
var SettingModel =
|
|
1612
|
-
id:
|
|
1613
|
-
settingsId:
|
|
1614
|
-
calendarId:
|
|
1615
|
-
logo:
|
|
1616
|
-
theme:
|
|
1617
|
-
schedulingButtonText:
|
|
1618
|
-
scheduledMessage:
|
|
1709
|
+
import { types as types14, getEnv as getEnv4, applySnapshot as applySnapshot4 } from "mobx-state-tree";
|
|
1710
|
+
var SettingModel = types14.model("Setting", {
|
|
1711
|
+
id: types14.optional(types14.maybeNull(types14.number), null),
|
|
1712
|
+
settingsId: types14.optional(types14.string, ""),
|
|
1713
|
+
calendarId: types14.optional(types14.string, ""),
|
|
1714
|
+
logo: types14.optional(types14.maybeNull(types14.string), null),
|
|
1715
|
+
theme: types14.optional(types14.maybeNull(types14.string), null),
|
|
1716
|
+
schedulingButtonText: types14.optional(types14.maybeNull(types14.string), null),
|
|
1717
|
+
scheduledMessage: types14.optional(types14.maybeNull(types14.string), null)
|
|
1619
1718
|
}).actions((self) => {
|
|
1620
1719
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv4);
|
|
1621
1720
|
return {
|
|
@@ -1704,13 +1803,13 @@ SettingModel.uploadLogo = async (calendarId, file) => {
|
|
|
1704
1803
|
var Setting_default = SettingModel;
|
|
1705
1804
|
|
|
1706
1805
|
// src/models/appointment/Company.js
|
|
1707
|
-
import { types as
|
|
1708
|
-
var CompanyModel =
|
|
1709
|
-
id:
|
|
1710
|
-
companyKey:
|
|
1711
|
-
companyName:
|
|
1712
|
-
createdOn:
|
|
1713
|
-
modifiedOn:
|
|
1806
|
+
import { types as types15, getEnv as getEnv5, applySnapshot as applySnapshot5 } from "mobx-state-tree";
|
|
1807
|
+
var CompanyModel = types15.model("Company", {
|
|
1808
|
+
id: types15.optional(types15.maybeNull(types15.number), null),
|
|
1809
|
+
companyKey: types15.identifier,
|
|
1810
|
+
companyName: types15.optional(types15.string, ""),
|
|
1811
|
+
createdOn: types15.optional(types15.maybeNull(types15.string), null),
|
|
1812
|
+
modifiedOn: types15.optional(types15.maybeNull(types15.string), null)
|
|
1714
1813
|
}).actions((self) => {
|
|
1715
1814
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv5);
|
|
1716
1815
|
return {
|
|
@@ -1772,13 +1871,13 @@ CompanyModel.save = async (payload) => {
|
|
|
1772
1871
|
var Company_default = CompanyModel;
|
|
1773
1872
|
|
|
1774
1873
|
// src/models/appointment/Asset.js
|
|
1775
|
-
import { types as
|
|
1776
|
-
var AssetModel =
|
|
1777
|
-
url:
|
|
1778
|
-
blobPath:
|
|
1779
|
-
category:
|
|
1780
|
-
contentType:
|
|
1781
|
-
size:
|
|
1874
|
+
import { types as types16, getEnv as getEnv6 } from "mobx-state-tree";
|
|
1875
|
+
var AssetModel = types16.model("Asset", {
|
|
1876
|
+
url: types16.optional(types16.maybeNull(types16.string), null),
|
|
1877
|
+
blobPath: types16.optional(types16.maybeNull(types16.string), null),
|
|
1878
|
+
category: types16.optional(types16.maybeNull(types16.string), null),
|
|
1879
|
+
contentType: types16.optional(types16.maybeNull(types16.string), null),
|
|
1880
|
+
size: types16.optional(types16.maybeNull(types16.number), null)
|
|
1782
1881
|
}).actions((self) => ({
|
|
1783
1882
|
/** POST /asset/upload – upload file using model category. */
|
|
1784
1883
|
async upload(file, opts = {}) {
|
|
@@ -1852,7 +1951,7 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1852
1951
|
var Asset_default = AssetModel;
|
|
1853
1952
|
|
|
1854
1953
|
// src/models/appointment/CalendarLocation.js
|
|
1855
|
-
import { types as
|
|
1954
|
+
import { types as types17, getEnv as getEnv7, applySnapshot as applySnapshot6 } from "mobx-state-tree";
|
|
1856
1955
|
function mapCalendarLocationFromApi(d) {
|
|
1857
1956
|
if (!d) return d;
|
|
1858
1957
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1882,17 +1981,17 @@ function toPayload4(self) {
|
|
|
1882
1981
|
sortOrder: self.sortOrder
|
|
1883
1982
|
};
|
|
1884
1983
|
}
|
|
1885
|
-
var CalendarLocationModel =
|
|
1886
|
-
id:
|
|
1887
|
-
calendarLocationId:
|
|
1888
|
-
calendarId:
|
|
1889
|
-
locationType:
|
|
1890
|
-
name:
|
|
1891
|
-
value:
|
|
1892
|
-
isDefault:
|
|
1893
|
-
sortOrder:
|
|
1894
|
-
createdOn:
|
|
1895
|
-
modifiedOn:
|
|
1984
|
+
var CalendarLocationModel = types17.model("CalendarLocation", {
|
|
1985
|
+
id: types17.optional(types17.maybeNull(types17.number), null),
|
|
1986
|
+
calendarLocationId: types17.optional(types17.maybeNull(types17.string), null),
|
|
1987
|
+
calendarId: types17.optional(types17.maybeNull(types17.string), null),
|
|
1988
|
+
locationType: types17.optional(types17.number, LocationType.Physical),
|
|
1989
|
+
name: types17.optional(types17.string, ""),
|
|
1990
|
+
value: types17.optional(types17.string, ""),
|
|
1991
|
+
isDefault: types17.optional(types17.boolean, false),
|
|
1992
|
+
sortOrder: types17.optional(types17.number, 0),
|
|
1993
|
+
createdOn: types17.optional(types17.maybeNull(types17.string), null),
|
|
1994
|
+
modifiedOn: types17.optional(types17.maybeNull(types17.string), null)
|
|
1896
1995
|
}).actions((self) => {
|
|
1897
1996
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv7);
|
|
1898
1997
|
return {
|
|
@@ -1974,7 +2073,7 @@ CalendarLocationModel.setDefault = async (calendarId, calendarLocationId) => {
|
|
|
1974
2073
|
var CalendarLocation_default = CalendarLocationModel;
|
|
1975
2074
|
|
|
1976
2075
|
// src/models/appointment/Preference.js
|
|
1977
|
-
import { types as
|
|
2076
|
+
import { types as types18 } from "mobx-state-tree";
|
|
1978
2077
|
var PreferenceScope = {
|
|
1979
2078
|
Global: 0,
|
|
1980
2079
|
Consumer: 1,
|
|
@@ -1985,13 +2084,13 @@ var PreferenceScope = {
|
|
|
1985
2084
|
User: 6
|
|
1986
2085
|
};
|
|
1987
2086
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event", "Participant", "User"];
|
|
1988
|
-
var PreferenceModel =
|
|
1989
|
-
id:
|
|
1990
|
-
preferenceId:
|
|
1991
|
-
level:
|
|
1992
|
-
primaryKey:
|
|
1993
|
-
preferenceOption:
|
|
1994
|
-
optionsJson:
|
|
2087
|
+
var PreferenceModel = types18.model("Preference", {
|
|
2088
|
+
id: types18.optional(types18.maybeNull(types18.number), null),
|
|
2089
|
+
preferenceId: types18.optional(types18.maybeNull(types18.string), null),
|
|
2090
|
+
level: types18.optional(types18.number, 0),
|
|
2091
|
+
primaryKey: types18.optional(types18.string, ""),
|
|
2092
|
+
preferenceOption: types18.optional(types18.string, ""),
|
|
2093
|
+
optionsJson: types18.optional(types18.maybeNull(types18.string), null)
|
|
1995
2094
|
}).actions((self) => ({
|
|
1996
2095
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1997
2096
|
async save() {
|
|
@@ -2039,7 +2138,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
2039
2138
|
var Preference_default = PreferenceModel;
|
|
2040
2139
|
|
|
2041
2140
|
// src/models/appointment/Flow.js
|
|
2042
|
-
import { types as
|
|
2141
|
+
import { types as types19, getEnv as getEnv8, applySnapshot as applySnapshot7 } from "mobx-state-tree";
|
|
2043
2142
|
function mapFlowFromApi(d) {
|
|
2044
2143
|
if (!d) return d;
|
|
2045
2144
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2058,18 +2157,18 @@ function mapFlowFromApi(d) {
|
|
|
2058
2157
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2059
2158
|
};
|
|
2060
2159
|
}
|
|
2061
|
-
var FlowModel =
|
|
2062
|
-
id:
|
|
2063
|
-
flowId:
|
|
2064
|
-
companyKey:
|
|
2065
|
-
calendarId:
|
|
2066
|
-
name:
|
|
2067
|
-
description:
|
|
2068
|
-
flowJson:
|
|
2069
|
-
isActive:
|
|
2070
|
-
isDeleted:
|
|
2071
|
-
createdOn:
|
|
2072
|
-
modifiedOn:
|
|
2160
|
+
var FlowModel = types19.model("Flow", {
|
|
2161
|
+
id: types19.optional(types19.maybeNull(types19.number), null),
|
|
2162
|
+
flowId: types19.optional(types19.identifier, "new"),
|
|
2163
|
+
companyKey: types19.optional(types19.maybeNull(types19.string), null),
|
|
2164
|
+
calendarId: types19.optional(types19.maybeNull(types19.string), null),
|
|
2165
|
+
name: types19.optional(types19.maybeNull(types19.string), null),
|
|
2166
|
+
description: types19.optional(types19.maybeNull(types19.string), null),
|
|
2167
|
+
flowJson: types19.optional(types19.string, ""),
|
|
2168
|
+
isActive: types19.optional(types19.boolean, true),
|
|
2169
|
+
isDeleted: types19.optional(types19.boolean, false),
|
|
2170
|
+
createdOn: types19.optional(types19.maybeNull(types19.string), null),
|
|
2171
|
+
modifiedOn: types19.optional(types19.maybeNull(types19.string), null)
|
|
2073
2172
|
}).actions((self) => {
|
|
2074
2173
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv8);
|
|
2075
2174
|
return {
|
|
@@ -2302,7 +2401,20 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2302
2401
|
var Flow_default = FlowModel;
|
|
2303
2402
|
|
|
2304
2403
|
// src/models/appointment/Lead.js
|
|
2305
|
-
import { types as
|
|
2404
|
+
import { types as types20, getEnv as getEnv9, applySnapshot as applySnapshot8, getSnapshot } from "mobx-state-tree";
|
|
2405
|
+
function pickLeadCreateContact(payload) {
|
|
2406
|
+
const p = payload ?? {};
|
|
2407
|
+
const email = String(p.email ?? p.Email ?? "").trim();
|
|
2408
|
+
const phone = String(p.phone ?? p.Phone ?? "").trim();
|
|
2409
|
+
const companyKey = String(p.companyKey ?? p.company_key ?? p.CompanyKey ?? "").trim();
|
|
2410
|
+
return { email, phone, companyKey };
|
|
2411
|
+
}
|
|
2412
|
+
function validateLeadCreatePayload(payload) {
|
|
2413
|
+
const { email, phone, companyKey } = pickLeadCreateContact(payload);
|
|
2414
|
+
if (!companyKey) return { ok: false, message: "companyKey is required" };
|
|
2415
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2416
|
+
return { ok: true };
|
|
2417
|
+
}
|
|
2306
2418
|
function mapLeadFromApi(d) {
|
|
2307
2419
|
if (!d) return d;
|
|
2308
2420
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2331,18 +2443,18 @@ function mapLeadFromApi(d) {
|
|
|
2331
2443
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2332
2444
|
};
|
|
2333
2445
|
}
|
|
2334
|
-
var LeadModel =
|
|
2335
|
-
id:
|
|
2336
|
-
leadId:
|
|
2337
|
-
email:
|
|
2338
|
-
name:
|
|
2339
|
-
phone:
|
|
2340
|
-
companyKey:
|
|
2341
|
-
source:
|
|
2342
|
-
leadType:
|
|
2343
|
-
referrerLink:
|
|
2344
|
-
createdOn:
|
|
2345
|
-
modifiedOn:
|
|
2446
|
+
var LeadModel = types20.model("Lead", {
|
|
2447
|
+
id: types20.optional(types20.maybeNull(types20.number), null),
|
|
2448
|
+
leadId: types20.optional(types20.identifier, "new"),
|
|
2449
|
+
email: types20.optional(types20.string, ""),
|
|
2450
|
+
name: types20.optional(types20.string, ""),
|
|
2451
|
+
phone: types20.optional(types20.string, ""),
|
|
2452
|
+
companyKey: types20.optional(types20.string, ""),
|
|
2453
|
+
source: types20.optional(types20.string, ""),
|
|
2454
|
+
leadType: types20.optional(types20.number, 2),
|
|
2455
|
+
referrerLink: types20.optional(types20.string, ""),
|
|
2456
|
+
createdOn: types20.optional(types20.maybeNull(types20.string), null),
|
|
2457
|
+
modifiedOn: types20.optional(types20.maybeNull(types20.string), null)
|
|
2346
2458
|
}).actions((self) => {
|
|
2347
2459
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv9);
|
|
2348
2460
|
return {
|
|
@@ -2390,8 +2502,14 @@ var LeadModel = types19.model("Lead", {
|
|
|
2390
2502
|
async getColumnSelection(userId) {
|
|
2391
2503
|
return LeadModel.getColumnSelection(userId);
|
|
2392
2504
|
},
|
|
2393
|
-
/** POST /lead/create – create this lead */
|
|
2505
|
+
/** POST /lead/create – create this lead (requires companyKey and email or phone) */
|
|
2394
2506
|
async createLead() {
|
|
2507
|
+
const validation = validateLeadCreatePayload({
|
|
2508
|
+
email: self.email,
|
|
2509
|
+
phone: self.phone,
|
|
2510
|
+
companyKey: self.companyKey
|
|
2511
|
+
});
|
|
2512
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2395
2513
|
const payload = {
|
|
2396
2514
|
email: self.email,
|
|
2397
2515
|
name: self.name,
|
|
@@ -2541,6 +2659,8 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2541
2659
|
return null;
|
|
2542
2660
|
};
|
|
2543
2661
|
LeadModel.createLead = async (payload) => {
|
|
2662
|
+
const validation = validateLeadCreatePayload(payload);
|
|
2663
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2544
2664
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2545
2665
|
const res = await reqPost("/lead/create", payload);
|
|
2546
2666
|
if (res.status === "success" && res.data) {
|
|
@@ -2596,17 +2716,17 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2596
2716
|
var Lead_default = LeadModel;
|
|
2597
2717
|
|
|
2598
2718
|
// src/models/appointment/CustomField.js
|
|
2599
|
-
import { types as
|
|
2600
|
-
var CustomFieldModel =
|
|
2601
|
-
id:
|
|
2602
|
-
customFieldId:
|
|
2603
|
-
calendarId:
|
|
2604
|
-
label:
|
|
2605
|
-
type:
|
|
2606
|
-
isRequired:
|
|
2607
|
-
createdOn:
|
|
2608
|
-
modifiedOn:
|
|
2609
|
-
isDeleted:
|
|
2719
|
+
import { types as types21, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
|
|
2720
|
+
var CustomFieldModel = types21.model("CustomField", {
|
|
2721
|
+
id: types21.optional(types21.maybeNull(types21.number), null),
|
|
2722
|
+
customFieldId: types21.optional(types21.maybeNull(types21.string), null),
|
|
2723
|
+
calendarId: types21.optional(types21.maybeNull(types21.string), null),
|
|
2724
|
+
label: types21.optional(types21.maybeNull(types21.string), null),
|
|
2725
|
+
type: types21.optional(types21.string, ""),
|
|
2726
|
+
isRequired: types21.optional(types21.boolean, false),
|
|
2727
|
+
createdOn: types21.optional(types21.maybeNull(types21.string), null),
|
|
2728
|
+
modifiedOn: types21.optional(types21.maybeNull(types21.string), null),
|
|
2729
|
+
isDeleted: types21.optional(types21.boolean, false)
|
|
2610
2730
|
}).actions((self) => {
|
|
2611
2731
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
|
|
2612
2732
|
return {
|
|
@@ -2936,10 +3056,10 @@ var AuthModel = {
|
|
|
2936
3056
|
var Auth_default = AuthModel;
|
|
2937
3057
|
|
|
2938
3058
|
// src/models/appointment/index.js
|
|
2939
|
-
import { types as
|
|
2940
|
-
var RootStore =
|
|
2941
|
-
calendars:
|
|
2942
|
-
events:
|
|
3059
|
+
import { types as types22, getEnv as getEnv11 } from "mobx-state-tree";
|
|
3060
|
+
var RootStore = types22.model("RootStore", {
|
|
3061
|
+
calendars: types22.optional(types22.map(Calendar_default), {}),
|
|
3062
|
+
events: types22.optional(types22.map(Event_default), {})
|
|
2943
3063
|
}).actions((self) => ({
|
|
2944
3064
|
addCalendar(snapshot) {
|
|
2945
3065
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2978,6 +3098,8 @@ export {
|
|
|
2978
3098
|
EmailProvider,
|
|
2979
3099
|
Event_default as EventModel,
|
|
2980
3100
|
EventSource,
|
|
3101
|
+
EventStatus,
|
|
3102
|
+
ExternalEvent_default as ExternalEventModel,
|
|
2981
3103
|
Flow_default as FlowModel,
|
|
2982
3104
|
Lead_default as LeadModel,
|
|
2983
3105
|
LocationType,
|