@blazeo.com/calendar-client 1.0.20 → 1.0.22
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 +22 -0
- package/dist/index.js +205 -67
- package/dist/index.mjs +203 -67
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -127,6 +127,27 @@ export const AssetModel: {
|
|
|
127
127
|
};
|
|
128
128
|
export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
129
129
|
export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
|
|
130
|
+
export const CalendarLocationModel: {
|
|
131
|
+
getByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
132
|
+
save(payload: object): Promise<unknown>;
|
|
133
|
+
remove(calendarLocationId: string): Promise<unknown>;
|
|
134
|
+
setDefault(calendarId: string, calendarLocationId: string): Promise<unknown>;
|
|
135
|
+
create(
|
|
136
|
+
snapshot?: {
|
|
137
|
+
id?: number | null;
|
|
138
|
+
calendarLocationId?: string | null;
|
|
139
|
+
calendarId?: string | null;
|
|
140
|
+
locationType?: number;
|
|
141
|
+
name?: string;
|
|
142
|
+
value?: string;
|
|
143
|
+
isDefault?: boolean;
|
|
144
|
+
sortOrder?: number;
|
|
145
|
+
createdOn?: string | null;
|
|
146
|
+
modifiedOn?: string | null;
|
|
147
|
+
},
|
|
148
|
+
options?: { env?: object }
|
|
149
|
+
): unknown;
|
|
150
|
+
};
|
|
130
151
|
export const PreferenceModel: {
|
|
131
152
|
getScopes(): Promise<string[] | null>;
|
|
132
153
|
getOptions(): Promise<string[] | null>;
|
|
@@ -234,3 +255,4 @@ export const AssignmentMethod: Record<string, number>;
|
|
|
234
255
|
export const AttendeeStatus: Record<string, number>;
|
|
235
256
|
export const RecurringFrequency: Record<string, number>;
|
|
236
257
|
export const DayOfWeek: Record<string, number>;
|
|
258
|
+
export const LocationType: Record<string, number>;
|
package/dist/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(index_exports, {
|
|
|
25
25
|
AvailabilityDetailModel: () => AvailabilityDetail_default,
|
|
26
26
|
AvailabilityModel: () => Availability_default,
|
|
27
27
|
CalendarDayModel: () => CalendarDay_default,
|
|
28
|
+
CalendarLocationModel: () => CalendarLocation_default,
|
|
28
29
|
CalendarModel: () => Calendar_default,
|
|
29
30
|
CalendarParticipantModel: () => CalendarParticipant_default,
|
|
30
31
|
CompanyModel: () => Company_default,
|
|
@@ -34,6 +35,7 @@ __export(index_exports, {
|
|
|
34
35
|
EventModel: () => Event_default,
|
|
35
36
|
FlowModel: () => Flow_default,
|
|
36
37
|
LeadModel: () => Lead_default,
|
|
38
|
+
LocationType: () => LocationType,
|
|
37
39
|
OpeningHourModel: () => OpeningHour_default,
|
|
38
40
|
ParticipantInfoModel: () => ParticipantInfo_default,
|
|
39
41
|
ParticipantModel: () => Participant_default,
|
|
@@ -152,8 +154,8 @@ function mergeConsumerHeader(env, opts) {
|
|
|
152
154
|
if (!headers["Consumer"] && (env == null ? void 0 : env.consumer)) headers["Consumer"] = env.consumer;
|
|
153
155
|
return { ...opts, headers };
|
|
154
156
|
}
|
|
155
|
-
function createRequestHelpers(self,
|
|
156
|
-
const env = () =>
|
|
157
|
+
function createRequestHelpers(self, getEnv12) {
|
|
158
|
+
const env = () => getEnv12(self);
|
|
157
159
|
const baseUrl = () => env().baseUrl;
|
|
158
160
|
const fetchFn = () => env().fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
|
|
159
161
|
throw new Error("fetch not available");
|
|
@@ -226,6 +228,12 @@ var DayOfWeek = {
|
|
|
226
228
|
Friday: 5,
|
|
227
229
|
Saturday: 6
|
|
228
230
|
};
|
|
231
|
+
var LocationType = {
|
|
232
|
+
Physical: 0,
|
|
233
|
+
Video: 1,
|
|
234
|
+
Phone: 2,
|
|
235
|
+
Custom: 3
|
|
236
|
+
};
|
|
229
237
|
|
|
230
238
|
// src/models/appointment/Event.js
|
|
231
239
|
var import_mobx_state_tree4 = require("mobx-state-tree");
|
|
@@ -337,6 +345,10 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
337
345
|
createdOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
338
346
|
modifiedOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
339
347
|
externalEventId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
348
|
+
calendarLocationId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
349
|
+
customLocation: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
350
|
+
flowId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
351
|
+
flowPath: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
340
352
|
attendeeStatus: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, AttendeeStatus.Tentative),
|
|
341
353
|
rescheduleLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
342
354
|
cancelLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
@@ -380,7 +392,11 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
380
392
|
timeZone: self.timeZone,
|
|
381
393
|
visitorName: self.visitorName ?? void 0,
|
|
382
394
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
383
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
395
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
396
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
397
|
+
customLocation: self.customLocation ?? void 0,
|
|
398
|
+
flowId: self.flowId ?? void 0,
|
|
399
|
+
flowPath: self.flowPath ?? void 0
|
|
384
400
|
};
|
|
385
401
|
const res = await reqPost("/event/create", payload, null, { headers: { offset: String(offset) } });
|
|
386
402
|
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
@@ -402,7 +418,11 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
402
418
|
endMinute: self.endMinute,
|
|
403
419
|
visitorName: self.visitorName ?? void 0,
|
|
404
420
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
405
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
421
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
422
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
423
|
+
customLocation: self.customLocation ?? void 0,
|
|
424
|
+
flowId: self.flowId ?? void 0,
|
|
425
|
+
flowPath: self.flowPath ?? void 0
|
|
406
426
|
};
|
|
407
427
|
return reqPost("/event/update", payload);
|
|
408
428
|
},
|
|
@@ -423,7 +443,11 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
423
443
|
endMinute: self.endMinute,
|
|
424
444
|
visitorName: self.visitorName ?? void 0,
|
|
425
445
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
426
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
446
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
447
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
448
|
+
customLocation: self.customLocation ?? void 0,
|
|
449
|
+
flowId: self.flowId ?? void 0,
|
|
450
|
+
flowPath: self.flowPath ?? void 0
|
|
427
451
|
};
|
|
428
452
|
const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
|
|
429
453
|
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
@@ -481,6 +505,10 @@ function mapEventFromApi(d) {
|
|
|
481
505
|
visitorEmail: pick("visitorEmail", "VisitorEmail", "visitor_email"),
|
|
482
506
|
visitorPhone: pick("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
483
507
|
externalEventId: pick("externalEventId", "ExternalEventId", "external_event_id"),
|
|
508
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
509
|
+
customLocation: pick("customLocation", "CustomLocation", "custom_location"),
|
|
510
|
+
flowId: pick("flowId", "FlowId", "flow_id"),
|
|
511
|
+
flowPath: pick("flowPath", "FlowPath", "flow_path"),
|
|
484
512
|
attendeeStatus: n(pick("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
485
513
|
rescheduleLink: pick("rescheduleLink", "RescheduleLink", "reschedule_link"),
|
|
486
514
|
cancelLink: pick("cancelLink", "CancelLink", "cancel_link"),
|
|
@@ -1730,8 +1758,116 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1730
1758
|
};
|
|
1731
1759
|
var Asset_default = AssetModel;
|
|
1732
1760
|
|
|
1733
|
-
// src/models/appointment/
|
|
1761
|
+
// src/models/appointment/CalendarLocation.js
|
|
1734
1762
|
var import_mobx_state_tree16 = require("mobx-state-tree");
|
|
1763
|
+
function mapCalendarLocationFromApi(d) {
|
|
1764
|
+
if (!d) return d;
|
|
1765
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
1766
|
+
const n = (v) => v != null && v !== "" ? Number(v) : void 0;
|
|
1767
|
+
const b = (v) => v === true || v === "true" || v === 1 || v === "1";
|
|
1768
|
+
return {
|
|
1769
|
+
id: n(pick("id", "Id")),
|
|
1770
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id") ?? null,
|
|
1771
|
+
calendarId: pick("calendarId", "CalendarId", "calendar_id") ?? null,
|
|
1772
|
+
locationType: n(pick("locationType", "LocationType", "location_type")),
|
|
1773
|
+
name: pick("name", "Name") ?? "",
|
|
1774
|
+
value: pick("value", "Value") ?? "",
|
|
1775
|
+
isDefault: b(pick("isDefault", "IsDefault", "is_default")),
|
|
1776
|
+
sortOrder: n(pick("sortOrder", "SortOrder", "sort_order")) ?? 0,
|
|
1777
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1778
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1781
|
+
function toPayload4(self) {
|
|
1782
|
+
return {
|
|
1783
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
1784
|
+
calendarId: self.calendarId ?? void 0,
|
|
1785
|
+
locationType: self.locationType,
|
|
1786
|
+
name: self.name ?? "",
|
|
1787
|
+
value: self.value ?? "",
|
|
1788
|
+
isDefault: self.isDefault,
|
|
1789
|
+
sortOrder: self.sortOrder
|
|
1790
|
+
};
|
|
1791
|
+
}
|
|
1792
|
+
var CalendarLocationModel = import_mobx_state_tree16.types.model("CalendarLocation", {
|
|
1793
|
+
id: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.number), null),
|
|
1794
|
+
calendarLocationId: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1795
|
+
calendarId: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1796
|
+
locationType: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.number, LocationType.Physical),
|
|
1797
|
+
name: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1798
|
+
value: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1799
|
+
isDefault: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.boolean, false),
|
|
1800
|
+
sortOrder: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.number, 0),
|
|
1801
|
+
createdOn: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1802
|
+
modifiedOn: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null)
|
|
1803
|
+
}).actions((self) => {
|
|
1804
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree16.getEnv);
|
|
1805
|
+
return {
|
|
1806
|
+
/** GET Calendar/Location/Get – list locations by calendar id */
|
|
1807
|
+
async getByCalendar(calendarId) {
|
|
1808
|
+
const resolvedCalendarId = calendarId ?? self.calendarId;
|
|
1809
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
1810
|
+
return reqGet("/Calendar/Location/Get", { calendar_id: resolvedCalendarId });
|
|
1811
|
+
},
|
|
1812
|
+
/** POST Calendar/Location/Save – create or update location */
|
|
1813
|
+
async save() {
|
|
1814
|
+
const res = await reqPost("/Calendar/Location/Save", toPayload4(self));
|
|
1815
|
+
if (res.status === "success" && res.data) {
|
|
1816
|
+
(0, import_mobx_state_tree16.applySnapshot)(self, mapCalendarLocationFromApi(res.data));
|
|
1817
|
+
}
|
|
1818
|
+
return res;
|
|
1819
|
+
},
|
|
1820
|
+
/** GET Calendar/Location/Remove – remove location by id */
|
|
1821
|
+
async remove(calendarLocationId) {
|
|
1822
|
+
const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
|
|
1823
|
+
if (!resolvedCalendarLocationId) return { status: "failure", message: "calendarLocationId required" };
|
|
1824
|
+
return reqGet("/Calendar/Location/Remove", { calendar_location_id: resolvedCalendarLocationId });
|
|
1825
|
+
},
|
|
1826
|
+
/** POST Calendar/Location/SetDefault – set this location as default for calendar */
|
|
1827
|
+
async setDefault(calendarId, calendarLocationId) {
|
|
1828
|
+
const resolvedCalendarId = calendarId ?? self.calendarId;
|
|
1829
|
+
const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
|
|
1830
|
+
if (!resolvedCalendarId || !resolvedCalendarLocationId) {
|
|
1831
|
+
return { status: "failure", message: "calendarId and calendarLocationId required" };
|
|
1832
|
+
}
|
|
1833
|
+
return reqPost("/Calendar/Location/SetDefault", {
|
|
1834
|
+
calendar_id: resolvedCalendarId,
|
|
1835
|
+
calendar_location_id: resolvedCalendarLocationId
|
|
1836
|
+
});
|
|
1837
|
+
}
|
|
1838
|
+
};
|
|
1839
|
+
});
|
|
1840
|
+
CalendarLocationModel.getByCalendar = async (calendarId) => {
|
|
1841
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1842
|
+
const res = await reqGet("/Calendar/Location/Get", { calendar_id: calendarId });
|
|
1843
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1844
|
+
return res.data.map((row) => CalendarLocationModel.create(mapCalendarLocationFromApi(row), { env: getConfig() }));
|
|
1845
|
+
}
|
|
1846
|
+
return null;
|
|
1847
|
+
};
|
|
1848
|
+
CalendarLocationModel.save = async (payload) => {
|
|
1849
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1850
|
+
const res = await reqPost("/Calendar/Location/Save", payload);
|
|
1851
|
+
if (res.status === "success" && res.data) {
|
|
1852
|
+
return CalendarLocationModel.create(mapCalendarLocationFromApi(res.data), { env: getConfig() });
|
|
1853
|
+
}
|
|
1854
|
+
return null;
|
|
1855
|
+
};
|
|
1856
|
+
CalendarLocationModel.remove = async (calendarLocationId) => {
|
|
1857
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1858
|
+
return reqGet("/Calendar/Location/Remove", { calendar_location_id: calendarLocationId });
|
|
1859
|
+
};
|
|
1860
|
+
CalendarLocationModel.setDefault = async (calendarId, calendarLocationId) => {
|
|
1861
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1862
|
+
return reqPost("/Calendar/Location/SetDefault", {
|
|
1863
|
+
calendar_id: calendarId,
|
|
1864
|
+
calendar_location_id: calendarLocationId
|
|
1865
|
+
});
|
|
1866
|
+
};
|
|
1867
|
+
var CalendarLocation_default = CalendarLocationModel;
|
|
1868
|
+
|
|
1869
|
+
// src/models/appointment/Preference.js
|
|
1870
|
+
var import_mobx_state_tree17 = require("mobx-state-tree");
|
|
1735
1871
|
var PreferenceScope = {
|
|
1736
1872
|
Global: 0,
|
|
1737
1873
|
Consumer: 1,
|
|
@@ -1740,13 +1876,13 @@ var PreferenceScope = {
|
|
|
1740
1876
|
Event: 4
|
|
1741
1877
|
};
|
|
1742
1878
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1743
|
-
var PreferenceModel =
|
|
1744
|
-
id:
|
|
1745
|
-
preferenceId:
|
|
1746
|
-
level:
|
|
1747
|
-
primaryKey:
|
|
1748
|
-
preferenceOption:
|
|
1749
|
-
optionsJson:
|
|
1879
|
+
var PreferenceModel = import_mobx_state_tree17.types.model("Preference", {
|
|
1880
|
+
id: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number), null),
|
|
1881
|
+
preferenceId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1882
|
+
level: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.number, 0),
|
|
1883
|
+
primaryKey: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
1884
|
+
preferenceOption: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
1885
|
+
optionsJson: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null)
|
|
1750
1886
|
}).actions((self) => ({
|
|
1751
1887
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1752
1888
|
async save() {
|
|
@@ -1794,7 +1930,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1794
1930
|
var Preference_default = PreferenceModel;
|
|
1795
1931
|
|
|
1796
1932
|
// src/models/appointment/Flow.js
|
|
1797
|
-
var
|
|
1933
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
1798
1934
|
function mapFlowFromApi(d) {
|
|
1799
1935
|
if (!d) return d;
|
|
1800
1936
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1812,26 +1948,26 @@ function mapFlowFromApi(d) {
|
|
|
1812
1948
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1813
1949
|
};
|
|
1814
1950
|
}
|
|
1815
|
-
var FlowModel =
|
|
1816
|
-
id:
|
|
1817
|
-
flowId:
|
|
1818
|
-
companyKey:
|
|
1819
|
-
name:
|
|
1820
|
-
description:
|
|
1821
|
-
flowJson:
|
|
1822
|
-
isActive:
|
|
1823
|
-
isDeleted:
|
|
1824
|
-
createdOn:
|
|
1825
|
-
modifiedOn:
|
|
1951
|
+
var FlowModel = import_mobx_state_tree18.types.model("Flow", {
|
|
1952
|
+
id: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.number), null),
|
|
1953
|
+
flowId: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.identifier, "new"),
|
|
1954
|
+
companyKey: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
1955
|
+
name: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
1956
|
+
description: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
1957
|
+
flowJson: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
1958
|
+
isActive: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.boolean, true),
|
|
1959
|
+
isDeleted: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.boolean, false),
|
|
1960
|
+
createdOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
1961
|
+
modifiedOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null)
|
|
1826
1962
|
}).actions((self) => {
|
|
1827
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1963
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree18.getEnv);
|
|
1828
1964
|
return {
|
|
1829
1965
|
/** GET flow/get – fetch this flow by flowId */
|
|
1830
1966
|
async get() {
|
|
1831
1967
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1832
1968
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1833
1969
|
if (res.status === "success" && res.data) {
|
|
1834
|
-
(0,
|
|
1970
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1835
1971
|
}
|
|
1836
1972
|
return res;
|
|
1837
1973
|
},
|
|
@@ -1846,7 +1982,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1846
1982
|
};
|
|
1847
1983
|
const res = await reqPost("/flow/create", payload);
|
|
1848
1984
|
if (res.status === "success" && res.data) {
|
|
1849
|
-
(0,
|
|
1985
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1850
1986
|
}
|
|
1851
1987
|
return res;
|
|
1852
1988
|
},
|
|
@@ -1862,7 +1998,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1862
1998
|
};
|
|
1863
1999
|
const res = await reqPost("/flow/update", payload);
|
|
1864
2000
|
if (res.status === "success" && res.data) {
|
|
1865
|
-
(0,
|
|
2001
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1866
2002
|
}
|
|
1867
2003
|
return res;
|
|
1868
2004
|
},
|
|
@@ -1876,7 +2012,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1876
2012
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1877
2013
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1878
2014
|
if (res.status === "success" && res.data) {
|
|
1879
|
-
(0,
|
|
2015
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1880
2016
|
}
|
|
1881
2017
|
return res;
|
|
1882
2018
|
},
|
|
@@ -2053,7 +2189,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2053
2189
|
var Flow_default = FlowModel;
|
|
2054
2190
|
|
|
2055
2191
|
// src/models/appointment/Lead.js
|
|
2056
|
-
var
|
|
2192
|
+
var import_mobx_state_tree19 = require("mobx-state-tree");
|
|
2057
2193
|
function mapLeadFromApi(d) {
|
|
2058
2194
|
if (!d) return d;
|
|
2059
2195
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2082,27 +2218,27 @@ function mapLeadFromApi(d) {
|
|
|
2082
2218
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2083
2219
|
};
|
|
2084
2220
|
}
|
|
2085
|
-
var LeadModel =
|
|
2086
|
-
id:
|
|
2087
|
-
leadId:
|
|
2088
|
-
email:
|
|
2089
|
-
name:
|
|
2090
|
-
phone:
|
|
2091
|
-
companyKey:
|
|
2092
|
-
source:
|
|
2093
|
-
leadType:
|
|
2094
|
-
referrerLink:
|
|
2095
|
-
createdOn:
|
|
2096
|
-
modifiedOn:
|
|
2221
|
+
var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
2222
|
+
id: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.number), null),
|
|
2223
|
+
leadId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.identifier, "new"),
|
|
2224
|
+
email: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2225
|
+
name: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2226
|
+
phone: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2227
|
+
companyKey: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2228
|
+
source: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2229
|
+
leadType: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.number, 2),
|
|
2230
|
+
referrerLink: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2231
|
+
createdOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2232
|
+
modifiedOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null)
|
|
2097
2233
|
}).actions((self) => {
|
|
2098
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2234
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree19.getEnv);
|
|
2099
2235
|
return {
|
|
2100
2236
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2101
2237
|
async get() {
|
|
2102
2238
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2103
2239
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2104
2240
|
if (res.status === "success" && res.data) {
|
|
2105
|
-
(0,
|
|
2241
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2106
2242
|
}
|
|
2107
2243
|
return res;
|
|
2108
2244
|
},
|
|
@@ -2113,7 +2249,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2113
2249
|
}
|
|
2114
2250
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2115
2251
|
if (lead) {
|
|
2116
|
-
(0,
|
|
2252
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, (0, import_mobx_state_tree19.getSnapshot)(lead));
|
|
2117
2253
|
}
|
|
2118
2254
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2119
2255
|
},
|
|
@@ -2135,7 +2271,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2135
2271
|
};
|
|
2136
2272
|
const res = await reqPost("/lead/create", payload);
|
|
2137
2273
|
if (res.status === "success" && res.data) {
|
|
2138
|
-
(0,
|
|
2274
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2139
2275
|
}
|
|
2140
2276
|
return res;
|
|
2141
2277
|
},
|
|
@@ -2156,7 +2292,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2156
2292
|
};
|
|
2157
2293
|
const res = await reqPost("/lead/update", payload);
|
|
2158
2294
|
if (res.status === "success" && res.data) {
|
|
2159
|
-
(0,
|
|
2295
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2160
2296
|
}
|
|
2161
2297
|
return res;
|
|
2162
2298
|
},
|
|
@@ -2282,19 +2418,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2282
2418
|
var Lead_default = LeadModel;
|
|
2283
2419
|
|
|
2284
2420
|
// src/models/appointment/CustomField.js
|
|
2285
|
-
var
|
|
2286
|
-
var CustomFieldModel =
|
|
2287
|
-
id:
|
|
2288
|
-
customFieldId:
|
|
2289
|
-
calendarId:
|
|
2290
|
-
label:
|
|
2291
|
-
type:
|
|
2292
|
-
isRequired:
|
|
2293
|
-
createdOn:
|
|
2294
|
-
modifiedOn:
|
|
2295
|
-
isDeleted:
|
|
2421
|
+
var import_mobx_state_tree20 = require("mobx-state-tree");
|
|
2422
|
+
var CustomFieldModel = import_mobx_state_tree20.types.model("CustomField", {
|
|
2423
|
+
id: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.number), null),
|
|
2424
|
+
customFieldId: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2425
|
+
calendarId: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2426
|
+
label: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2427
|
+
type: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.string, ""),
|
|
2428
|
+
isRequired: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.boolean, false),
|
|
2429
|
+
createdOn: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2430
|
+
modifiedOn: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.maybeNull(import_mobx_state_tree20.types.string), null),
|
|
2431
|
+
isDeleted: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.boolean, false)
|
|
2296
2432
|
}).actions((self) => {
|
|
2297
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2433
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree20.getEnv);
|
|
2298
2434
|
return {
|
|
2299
2435
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2300
2436
|
async getAll(calendarId) {
|
|
@@ -2312,10 +2448,10 @@ var CustomFieldModel = import_mobx_state_tree19.types.model("CustomField", {
|
|
|
2312
2448
|
},
|
|
2313
2449
|
/** POST /CustomField/Add */
|
|
2314
2450
|
async add(payload) {
|
|
2315
|
-
const body = payload ??
|
|
2451
|
+
const body = payload ?? toPayload5(self);
|
|
2316
2452
|
const res = await reqPost("/CustomField/Add", body);
|
|
2317
2453
|
if (res.status === "success" && res.data) {
|
|
2318
|
-
(0,
|
|
2454
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
2319
2455
|
}
|
|
2320
2456
|
return res;
|
|
2321
2457
|
},
|
|
@@ -2379,7 +2515,7 @@ function mapCustomFieldFromApi(d) {
|
|
|
2379
2515
|
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2380
2516
|
};
|
|
2381
2517
|
}
|
|
2382
|
-
function
|
|
2518
|
+
function toPayload5(self) {
|
|
2383
2519
|
return {
|
|
2384
2520
|
customFieldId: self.customFieldId || void 0,
|
|
2385
2521
|
calendarId: self.calendarId || void 0,
|
|
@@ -2451,10 +2587,10 @@ CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
|
2451
2587
|
var CustomField_default = CustomFieldModel;
|
|
2452
2588
|
|
|
2453
2589
|
// src/models/appointment/index.js
|
|
2454
|
-
var
|
|
2455
|
-
var RootStore =
|
|
2456
|
-
calendars:
|
|
2457
|
-
events:
|
|
2590
|
+
var import_mobx_state_tree21 = require("mobx-state-tree");
|
|
2591
|
+
var RootStore = import_mobx_state_tree21.types.model("RootStore", {
|
|
2592
|
+
calendars: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.map(Calendar_default), {}),
|
|
2593
|
+
events: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.map(Event_default), {})
|
|
2458
2594
|
}).actions((self) => ({
|
|
2459
2595
|
addCalendar(snapshot) {
|
|
2460
2596
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2480,6 +2616,7 @@ function createRootStore(initialState = {}) {
|
|
|
2480
2616
|
AvailabilityDetailModel,
|
|
2481
2617
|
AvailabilityModel,
|
|
2482
2618
|
CalendarDayModel,
|
|
2619
|
+
CalendarLocationModel,
|
|
2483
2620
|
CalendarModel,
|
|
2484
2621
|
CalendarParticipantModel,
|
|
2485
2622
|
CompanyModel,
|
|
@@ -2489,6 +2626,7 @@ function createRootStore(initialState = {}) {
|
|
|
2489
2626
|
EventModel,
|
|
2490
2627
|
FlowModel,
|
|
2491
2628
|
LeadModel,
|
|
2629
|
+
LocationType,
|
|
2492
2630
|
OpeningHourModel,
|
|
2493
2631
|
ParticipantInfoModel,
|
|
2494
2632
|
ParticipantModel,
|
package/dist/index.mjs
CHANGED
|
@@ -97,8 +97,8 @@ function mergeConsumerHeader(env, opts) {
|
|
|
97
97
|
if (!headers["Consumer"] && (env == null ? void 0 : env.consumer)) headers["Consumer"] = env.consumer;
|
|
98
98
|
return { ...opts, headers };
|
|
99
99
|
}
|
|
100
|
-
function createRequestHelpers(self,
|
|
101
|
-
const env = () =>
|
|
100
|
+
function createRequestHelpers(self, getEnv12) {
|
|
101
|
+
const env = () => getEnv12(self);
|
|
102
102
|
const baseUrl = () => env().baseUrl;
|
|
103
103
|
const fetchFn = () => env().fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
|
|
104
104
|
throw new Error("fetch not available");
|
|
@@ -171,6 +171,12 @@ var DayOfWeek = {
|
|
|
171
171
|
Friday: 5,
|
|
172
172
|
Saturday: 6
|
|
173
173
|
};
|
|
174
|
+
var LocationType = {
|
|
175
|
+
Physical: 0,
|
|
176
|
+
Video: 1,
|
|
177
|
+
Phone: 2,
|
|
178
|
+
Custom: 3
|
|
179
|
+
};
|
|
174
180
|
|
|
175
181
|
// src/models/appointment/Event.js
|
|
176
182
|
import { types as types4, getEnv, applySnapshot } from "mobx-state-tree";
|
|
@@ -282,6 +288,10 @@ var EventModel = types4.model("Event", {
|
|
|
282
288
|
createdOn: types4.optional(types4.maybeNull(types4.string), null),
|
|
283
289
|
modifiedOn: types4.optional(types4.maybeNull(types4.string), null),
|
|
284
290
|
externalEventId: types4.optional(types4.maybeNull(types4.string), null),
|
|
291
|
+
calendarLocationId: types4.optional(types4.maybeNull(types4.string), null),
|
|
292
|
+
customLocation: types4.optional(types4.maybeNull(types4.string), null),
|
|
293
|
+
flowId: types4.optional(types4.maybeNull(types4.string), null),
|
|
294
|
+
flowPath: types4.optional(types4.maybeNull(types4.string), null),
|
|
285
295
|
attendeeStatus: types4.optional(types4.number, AttendeeStatus.Tentative),
|
|
286
296
|
rescheduleLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
287
297
|
cancelLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
@@ -325,7 +335,11 @@ var EventModel = types4.model("Event", {
|
|
|
325
335
|
timeZone: self.timeZone,
|
|
326
336
|
visitorName: self.visitorName ?? void 0,
|
|
327
337
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
328
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
338
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
339
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
340
|
+
customLocation: self.customLocation ?? void 0,
|
|
341
|
+
flowId: self.flowId ?? void 0,
|
|
342
|
+
flowPath: self.flowPath ?? void 0
|
|
329
343
|
};
|
|
330
344
|
const res = await reqPost("/event/create", payload, null, { headers: { offset: String(offset) } });
|
|
331
345
|
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, eventId: self.eventId });
|
|
@@ -347,7 +361,11 @@ var EventModel = types4.model("Event", {
|
|
|
347
361
|
endMinute: self.endMinute,
|
|
348
362
|
visitorName: self.visitorName ?? void 0,
|
|
349
363
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
350
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
364
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
365
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
366
|
+
customLocation: self.customLocation ?? void 0,
|
|
367
|
+
flowId: self.flowId ?? void 0,
|
|
368
|
+
flowPath: self.flowPath ?? void 0
|
|
351
369
|
};
|
|
352
370
|
return reqPost("/event/update", payload);
|
|
353
371
|
},
|
|
@@ -368,7 +386,11 @@ var EventModel = types4.model("Event", {
|
|
|
368
386
|
endMinute: self.endMinute,
|
|
369
387
|
visitorName: self.visitorName ?? void 0,
|
|
370
388
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
371
|
-
visitorPhone: self.visitorPhone ?? void 0
|
|
389
|
+
visitorPhone: self.visitorPhone ?? void 0,
|
|
390
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
391
|
+
customLocation: self.customLocation ?? void 0,
|
|
392
|
+
flowId: self.flowId ?? void 0,
|
|
393
|
+
flowPath: self.flowPath ?? void 0
|
|
372
394
|
};
|
|
373
395
|
const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
|
|
374
396
|
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, eventId: self.eventId });
|
|
@@ -426,6 +448,10 @@ function mapEventFromApi(d) {
|
|
|
426
448
|
visitorEmail: pick("visitorEmail", "VisitorEmail", "visitor_email"),
|
|
427
449
|
visitorPhone: pick("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
428
450
|
externalEventId: pick("externalEventId", "ExternalEventId", "external_event_id"),
|
|
451
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
452
|
+
customLocation: pick("customLocation", "CustomLocation", "custom_location"),
|
|
453
|
+
flowId: pick("flowId", "FlowId", "flow_id"),
|
|
454
|
+
flowPath: pick("flowPath", "FlowPath", "flow_path"),
|
|
429
455
|
attendeeStatus: n(pick("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
430
456
|
rescheduleLink: pick("rescheduleLink", "RescheduleLink", "reschedule_link"),
|
|
431
457
|
cancelLink: pick("cancelLink", "CancelLink", "cancel_link"),
|
|
@@ -1675,8 +1701,116 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1675
1701
|
};
|
|
1676
1702
|
var Asset_default = AssetModel;
|
|
1677
1703
|
|
|
1704
|
+
// src/models/appointment/CalendarLocation.js
|
|
1705
|
+
import { types as types16, getEnv as getEnv7, applySnapshot as applySnapshot6 } from "mobx-state-tree";
|
|
1706
|
+
function mapCalendarLocationFromApi(d) {
|
|
1707
|
+
if (!d) return d;
|
|
1708
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
1709
|
+
const n = (v) => v != null && v !== "" ? Number(v) : void 0;
|
|
1710
|
+
const b = (v) => v === true || v === "true" || v === 1 || v === "1";
|
|
1711
|
+
return {
|
|
1712
|
+
id: n(pick("id", "Id")),
|
|
1713
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id") ?? null,
|
|
1714
|
+
calendarId: pick("calendarId", "CalendarId", "calendar_id") ?? null,
|
|
1715
|
+
locationType: n(pick("locationType", "LocationType", "location_type")),
|
|
1716
|
+
name: pick("name", "Name") ?? "",
|
|
1717
|
+
value: pick("value", "Value") ?? "",
|
|
1718
|
+
isDefault: b(pick("isDefault", "IsDefault", "is_default")),
|
|
1719
|
+
sortOrder: n(pick("sortOrder", "SortOrder", "sort_order")) ?? 0,
|
|
1720
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1721
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
function toPayload4(self) {
|
|
1725
|
+
return {
|
|
1726
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
1727
|
+
calendarId: self.calendarId ?? void 0,
|
|
1728
|
+
locationType: self.locationType,
|
|
1729
|
+
name: self.name ?? "",
|
|
1730
|
+
value: self.value ?? "",
|
|
1731
|
+
isDefault: self.isDefault,
|
|
1732
|
+
sortOrder: self.sortOrder
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1735
|
+
var CalendarLocationModel = types16.model("CalendarLocation", {
|
|
1736
|
+
id: types16.optional(types16.maybeNull(types16.number), null),
|
|
1737
|
+
calendarLocationId: types16.optional(types16.maybeNull(types16.string), null),
|
|
1738
|
+
calendarId: types16.optional(types16.maybeNull(types16.string), null),
|
|
1739
|
+
locationType: types16.optional(types16.number, LocationType.Physical),
|
|
1740
|
+
name: types16.optional(types16.string, ""),
|
|
1741
|
+
value: types16.optional(types16.string, ""),
|
|
1742
|
+
isDefault: types16.optional(types16.boolean, false),
|
|
1743
|
+
sortOrder: types16.optional(types16.number, 0),
|
|
1744
|
+
createdOn: types16.optional(types16.maybeNull(types16.string), null),
|
|
1745
|
+
modifiedOn: types16.optional(types16.maybeNull(types16.string), null)
|
|
1746
|
+
}).actions((self) => {
|
|
1747
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv7);
|
|
1748
|
+
return {
|
|
1749
|
+
/** GET Calendar/Location/Get – list locations by calendar id */
|
|
1750
|
+
async getByCalendar(calendarId) {
|
|
1751
|
+
const resolvedCalendarId = calendarId ?? self.calendarId;
|
|
1752
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
1753
|
+
return reqGet("/Calendar/Location/Get", { calendar_id: resolvedCalendarId });
|
|
1754
|
+
},
|
|
1755
|
+
/** POST Calendar/Location/Save – create or update location */
|
|
1756
|
+
async save() {
|
|
1757
|
+
const res = await reqPost("/Calendar/Location/Save", toPayload4(self));
|
|
1758
|
+
if (res.status === "success" && res.data) {
|
|
1759
|
+
applySnapshot6(self, mapCalendarLocationFromApi(res.data));
|
|
1760
|
+
}
|
|
1761
|
+
return res;
|
|
1762
|
+
},
|
|
1763
|
+
/** GET Calendar/Location/Remove – remove location by id */
|
|
1764
|
+
async remove(calendarLocationId) {
|
|
1765
|
+
const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
|
|
1766
|
+
if (!resolvedCalendarLocationId) return { status: "failure", message: "calendarLocationId required" };
|
|
1767
|
+
return reqGet("/Calendar/Location/Remove", { calendar_location_id: resolvedCalendarLocationId });
|
|
1768
|
+
},
|
|
1769
|
+
/** POST Calendar/Location/SetDefault – set this location as default for calendar */
|
|
1770
|
+
async setDefault(calendarId, calendarLocationId) {
|
|
1771
|
+
const resolvedCalendarId = calendarId ?? self.calendarId;
|
|
1772
|
+
const resolvedCalendarLocationId = calendarLocationId ?? self.calendarLocationId;
|
|
1773
|
+
if (!resolvedCalendarId || !resolvedCalendarLocationId) {
|
|
1774
|
+
return { status: "failure", message: "calendarId and calendarLocationId required" };
|
|
1775
|
+
}
|
|
1776
|
+
return reqPost("/Calendar/Location/SetDefault", {
|
|
1777
|
+
calendar_id: resolvedCalendarId,
|
|
1778
|
+
calendar_location_id: resolvedCalendarLocationId
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
};
|
|
1782
|
+
});
|
|
1783
|
+
CalendarLocationModel.getByCalendar = async (calendarId) => {
|
|
1784
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1785
|
+
const res = await reqGet("/Calendar/Location/Get", { calendar_id: calendarId });
|
|
1786
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1787
|
+
return res.data.map((row) => CalendarLocationModel.create(mapCalendarLocationFromApi(row), { env: getConfig() }));
|
|
1788
|
+
}
|
|
1789
|
+
return null;
|
|
1790
|
+
};
|
|
1791
|
+
CalendarLocationModel.save = async (payload) => {
|
|
1792
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1793
|
+
const res = await reqPost("/Calendar/Location/Save", payload);
|
|
1794
|
+
if (res.status === "success" && res.data) {
|
|
1795
|
+
return CalendarLocationModel.create(mapCalendarLocationFromApi(res.data), { env: getConfig() });
|
|
1796
|
+
}
|
|
1797
|
+
return null;
|
|
1798
|
+
};
|
|
1799
|
+
CalendarLocationModel.remove = async (calendarLocationId) => {
|
|
1800
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1801
|
+
return reqGet("/Calendar/Location/Remove", { calendar_location_id: calendarLocationId });
|
|
1802
|
+
};
|
|
1803
|
+
CalendarLocationModel.setDefault = async (calendarId, calendarLocationId) => {
|
|
1804
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
1805
|
+
return reqPost("/Calendar/Location/SetDefault", {
|
|
1806
|
+
calendar_id: calendarId,
|
|
1807
|
+
calendar_location_id: calendarLocationId
|
|
1808
|
+
});
|
|
1809
|
+
};
|
|
1810
|
+
var CalendarLocation_default = CalendarLocationModel;
|
|
1811
|
+
|
|
1678
1812
|
// src/models/appointment/Preference.js
|
|
1679
|
-
import { types as
|
|
1813
|
+
import { types as types17 } from "mobx-state-tree";
|
|
1680
1814
|
var PreferenceScope = {
|
|
1681
1815
|
Global: 0,
|
|
1682
1816
|
Consumer: 1,
|
|
@@ -1685,13 +1819,13 @@ var PreferenceScope = {
|
|
|
1685
1819
|
Event: 4
|
|
1686
1820
|
};
|
|
1687
1821
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1688
|
-
var PreferenceModel =
|
|
1689
|
-
id:
|
|
1690
|
-
preferenceId:
|
|
1691
|
-
level:
|
|
1692
|
-
primaryKey:
|
|
1693
|
-
preferenceOption:
|
|
1694
|
-
optionsJson:
|
|
1822
|
+
var PreferenceModel = types17.model("Preference", {
|
|
1823
|
+
id: types17.optional(types17.maybeNull(types17.number), null),
|
|
1824
|
+
preferenceId: types17.optional(types17.maybeNull(types17.string), null),
|
|
1825
|
+
level: types17.optional(types17.number, 0),
|
|
1826
|
+
primaryKey: types17.optional(types17.string, ""),
|
|
1827
|
+
preferenceOption: types17.optional(types17.string, ""),
|
|
1828
|
+
optionsJson: types17.optional(types17.maybeNull(types17.string), null)
|
|
1695
1829
|
}).actions((self) => ({
|
|
1696
1830
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1697
1831
|
async save() {
|
|
@@ -1739,7 +1873,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1739
1873
|
var Preference_default = PreferenceModel;
|
|
1740
1874
|
|
|
1741
1875
|
// src/models/appointment/Flow.js
|
|
1742
|
-
import { types as
|
|
1876
|
+
import { types as types18, getEnv as getEnv8, applySnapshot as applySnapshot7 } from "mobx-state-tree";
|
|
1743
1877
|
function mapFlowFromApi(d) {
|
|
1744
1878
|
if (!d) return d;
|
|
1745
1879
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1757,26 +1891,26 @@ function mapFlowFromApi(d) {
|
|
|
1757
1891
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1758
1892
|
};
|
|
1759
1893
|
}
|
|
1760
|
-
var FlowModel =
|
|
1761
|
-
id:
|
|
1762
|
-
flowId:
|
|
1763
|
-
companyKey:
|
|
1764
|
-
name:
|
|
1765
|
-
description:
|
|
1766
|
-
flowJson:
|
|
1767
|
-
isActive:
|
|
1768
|
-
isDeleted:
|
|
1769
|
-
createdOn:
|
|
1770
|
-
modifiedOn:
|
|
1894
|
+
var FlowModel = types18.model("Flow", {
|
|
1895
|
+
id: types18.optional(types18.maybeNull(types18.number), null),
|
|
1896
|
+
flowId: types18.optional(types18.identifier, "new"),
|
|
1897
|
+
companyKey: types18.optional(types18.maybeNull(types18.string), null),
|
|
1898
|
+
name: types18.optional(types18.maybeNull(types18.string), null),
|
|
1899
|
+
description: types18.optional(types18.maybeNull(types18.string), null),
|
|
1900
|
+
flowJson: types18.optional(types18.string, ""),
|
|
1901
|
+
isActive: types18.optional(types18.boolean, true),
|
|
1902
|
+
isDeleted: types18.optional(types18.boolean, false),
|
|
1903
|
+
createdOn: types18.optional(types18.maybeNull(types18.string), null),
|
|
1904
|
+
modifiedOn: types18.optional(types18.maybeNull(types18.string), null)
|
|
1771
1905
|
}).actions((self) => {
|
|
1772
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1906
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv8);
|
|
1773
1907
|
return {
|
|
1774
1908
|
/** GET flow/get – fetch this flow by flowId */
|
|
1775
1909
|
async get() {
|
|
1776
1910
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1777
1911
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1778
1912
|
if (res.status === "success" && res.data) {
|
|
1779
|
-
|
|
1913
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1780
1914
|
}
|
|
1781
1915
|
return res;
|
|
1782
1916
|
},
|
|
@@ -1791,7 +1925,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1791
1925
|
};
|
|
1792
1926
|
const res = await reqPost("/flow/create", payload);
|
|
1793
1927
|
if (res.status === "success" && res.data) {
|
|
1794
|
-
|
|
1928
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1795
1929
|
}
|
|
1796
1930
|
return res;
|
|
1797
1931
|
},
|
|
@@ -1807,7 +1941,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1807
1941
|
};
|
|
1808
1942
|
const res = await reqPost("/flow/update", payload);
|
|
1809
1943
|
if (res.status === "success" && res.data) {
|
|
1810
|
-
|
|
1944
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1811
1945
|
}
|
|
1812
1946
|
return res;
|
|
1813
1947
|
},
|
|
@@ -1821,7 +1955,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1821
1955
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1822
1956
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1823
1957
|
if (res.status === "success" && res.data) {
|
|
1824
|
-
|
|
1958
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1825
1959
|
}
|
|
1826
1960
|
return res;
|
|
1827
1961
|
},
|
|
@@ -1998,7 +2132,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
1998
2132
|
var Flow_default = FlowModel;
|
|
1999
2133
|
|
|
2000
2134
|
// src/models/appointment/Lead.js
|
|
2001
|
-
import { types as
|
|
2135
|
+
import { types as types19, getEnv as getEnv9, applySnapshot as applySnapshot8, getSnapshot } from "mobx-state-tree";
|
|
2002
2136
|
function mapLeadFromApi(d) {
|
|
2003
2137
|
if (!d) return d;
|
|
2004
2138
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2027,27 +2161,27 @@ function mapLeadFromApi(d) {
|
|
|
2027
2161
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2028
2162
|
};
|
|
2029
2163
|
}
|
|
2030
|
-
var LeadModel =
|
|
2031
|
-
id:
|
|
2032
|
-
leadId:
|
|
2033
|
-
email:
|
|
2034
|
-
name:
|
|
2035
|
-
phone:
|
|
2036
|
-
companyKey:
|
|
2037
|
-
source:
|
|
2038
|
-
leadType:
|
|
2039
|
-
referrerLink:
|
|
2040
|
-
createdOn:
|
|
2041
|
-
modifiedOn:
|
|
2164
|
+
var LeadModel = types19.model("Lead", {
|
|
2165
|
+
id: types19.optional(types19.maybeNull(types19.number), null),
|
|
2166
|
+
leadId: types19.optional(types19.identifier, "new"),
|
|
2167
|
+
email: types19.optional(types19.string, ""),
|
|
2168
|
+
name: types19.optional(types19.string, ""),
|
|
2169
|
+
phone: types19.optional(types19.string, ""),
|
|
2170
|
+
companyKey: types19.optional(types19.string, ""),
|
|
2171
|
+
source: types19.optional(types19.string, ""),
|
|
2172
|
+
leadType: types19.optional(types19.number, 2),
|
|
2173
|
+
referrerLink: types19.optional(types19.string, ""),
|
|
2174
|
+
createdOn: types19.optional(types19.maybeNull(types19.string), null),
|
|
2175
|
+
modifiedOn: types19.optional(types19.maybeNull(types19.string), null)
|
|
2042
2176
|
}).actions((self) => {
|
|
2043
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2177
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv9);
|
|
2044
2178
|
return {
|
|
2045
2179
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2046
2180
|
async get() {
|
|
2047
2181
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2048
2182
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2049
2183
|
if (res.status === "success" && res.data) {
|
|
2050
|
-
|
|
2184
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2051
2185
|
}
|
|
2052
2186
|
return res;
|
|
2053
2187
|
},
|
|
@@ -2058,7 +2192,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2058
2192
|
}
|
|
2059
2193
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2060
2194
|
if (lead) {
|
|
2061
|
-
|
|
2195
|
+
applySnapshot8(self, getSnapshot(lead));
|
|
2062
2196
|
}
|
|
2063
2197
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2064
2198
|
},
|
|
@@ -2080,7 +2214,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2080
2214
|
};
|
|
2081
2215
|
const res = await reqPost("/lead/create", payload);
|
|
2082
2216
|
if (res.status === "success" && res.data) {
|
|
2083
|
-
|
|
2217
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2084
2218
|
}
|
|
2085
2219
|
return res;
|
|
2086
2220
|
},
|
|
@@ -2101,7 +2235,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2101
2235
|
};
|
|
2102
2236
|
const res = await reqPost("/lead/update", payload);
|
|
2103
2237
|
if (res.status === "success" && res.data) {
|
|
2104
|
-
|
|
2238
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2105
2239
|
}
|
|
2106
2240
|
return res;
|
|
2107
2241
|
},
|
|
@@ -2227,19 +2361,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2227
2361
|
var Lead_default = LeadModel;
|
|
2228
2362
|
|
|
2229
2363
|
// src/models/appointment/CustomField.js
|
|
2230
|
-
import { types as
|
|
2231
|
-
var CustomFieldModel =
|
|
2232
|
-
id:
|
|
2233
|
-
customFieldId:
|
|
2234
|
-
calendarId:
|
|
2235
|
-
label:
|
|
2236
|
-
type:
|
|
2237
|
-
isRequired:
|
|
2238
|
-
createdOn:
|
|
2239
|
-
modifiedOn:
|
|
2240
|
-
isDeleted:
|
|
2364
|
+
import { types as types20, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
|
|
2365
|
+
var CustomFieldModel = types20.model("CustomField", {
|
|
2366
|
+
id: types20.optional(types20.maybeNull(types20.number), null),
|
|
2367
|
+
customFieldId: types20.optional(types20.maybeNull(types20.string), null),
|
|
2368
|
+
calendarId: types20.optional(types20.maybeNull(types20.string), null),
|
|
2369
|
+
label: types20.optional(types20.maybeNull(types20.string), null),
|
|
2370
|
+
type: types20.optional(types20.string, ""),
|
|
2371
|
+
isRequired: types20.optional(types20.boolean, false),
|
|
2372
|
+
createdOn: types20.optional(types20.maybeNull(types20.string), null),
|
|
2373
|
+
modifiedOn: types20.optional(types20.maybeNull(types20.string), null),
|
|
2374
|
+
isDeleted: types20.optional(types20.boolean, false)
|
|
2241
2375
|
}).actions((self) => {
|
|
2242
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2376
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
|
|
2243
2377
|
return {
|
|
2244
2378
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2245
2379
|
async getAll(calendarId) {
|
|
@@ -2257,10 +2391,10 @@ var CustomFieldModel = types19.model("CustomField", {
|
|
|
2257
2391
|
},
|
|
2258
2392
|
/** POST /CustomField/Add */
|
|
2259
2393
|
async add(payload) {
|
|
2260
|
-
const body = payload ??
|
|
2394
|
+
const body = payload ?? toPayload5(self);
|
|
2261
2395
|
const res = await reqPost("/CustomField/Add", body);
|
|
2262
2396
|
if (res.status === "success" && res.data) {
|
|
2263
|
-
|
|
2397
|
+
applySnapshot9(self, mapCustomFieldFromApi(res.data));
|
|
2264
2398
|
}
|
|
2265
2399
|
return res;
|
|
2266
2400
|
},
|
|
@@ -2324,7 +2458,7 @@ function mapCustomFieldFromApi(d) {
|
|
|
2324
2458
|
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2325
2459
|
};
|
|
2326
2460
|
}
|
|
2327
|
-
function
|
|
2461
|
+
function toPayload5(self) {
|
|
2328
2462
|
return {
|
|
2329
2463
|
customFieldId: self.customFieldId || void 0,
|
|
2330
2464
|
calendarId: self.calendarId || void 0,
|
|
@@ -2396,10 +2530,10 @@ CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
|
2396
2530
|
var CustomField_default = CustomFieldModel;
|
|
2397
2531
|
|
|
2398
2532
|
// src/models/appointment/index.js
|
|
2399
|
-
import { types as
|
|
2400
|
-
var RootStore =
|
|
2401
|
-
calendars:
|
|
2402
|
-
events:
|
|
2533
|
+
import { types as types21, getEnv as getEnv11 } from "mobx-state-tree";
|
|
2534
|
+
var RootStore = types21.model("RootStore", {
|
|
2535
|
+
calendars: types21.optional(types21.map(Calendar_default), {}),
|
|
2536
|
+
events: types21.optional(types21.map(Event_default), {})
|
|
2403
2537
|
}).actions((self) => ({
|
|
2404
2538
|
addCalendar(snapshot) {
|
|
2405
2539
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2424,6 +2558,7 @@ export {
|
|
|
2424
2558
|
AvailabilityDetail_default as AvailabilityDetailModel,
|
|
2425
2559
|
Availability_default as AvailabilityModel,
|
|
2426
2560
|
CalendarDay_default as CalendarDayModel,
|
|
2561
|
+
CalendarLocation_default as CalendarLocationModel,
|
|
2427
2562
|
Calendar_default as CalendarModel,
|
|
2428
2563
|
CalendarParticipant_default as CalendarParticipantModel,
|
|
2429
2564
|
Company_default as CompanyModel,
|
|
@@ -2433,6 +2568,7 @@ export {
|
|
|
2433
2568
|
Event_default as EventModel,
|
|
2434
2569
|
Flow_default as FlowModel,
|
|
2435
2570
|
Lead_default as LeadModel,
|
|
2571
|
+
LocationType,
|
|
2436
2572
|
OpeningHour_default as OpeningHourModel,
|
|
2437
2573
|
ParticipantInfo_default as ParticipantInfoModel,
|
|
2438
2574
|
Participant_default as ParticipantModel,
|