@blazeo.com/calendar-client 1.0.21 → 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 +192 -69
- package/dist/index.mjs +190 -69
- 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,7 +345,8 @@ 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),
|
|
340
|
-
|
|
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),
|
|
341
350
|
flowId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
342
351
|
flowPath: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
343
352
|
attendeeStatus: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, AttendeeStatus.Tentative),
|
|
@@ -384,7 +393,8 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
384
393
|
visitorName: self.visitorName ?? void 0,
|
|
385
394
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
386
395
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
387
|
-
|
|
396
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
397
|
+
customLocation: self.customLocation ?? void 0,
|
|
388
398
|
flowId: self.flowId ?? void 0,
|
|
389
399
|
flowPath: self.flowPath ?? void 0
|
|
390
400
|
};
|
|
@@ -409,7 +419,8 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
409
419
|
visitorName: self.visitorName ?? void 0,
|
|
410
420
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
411
421
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
412
|
-
|
|
422
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
423
|
+
customLocation: self.customLocation ?? void 0,
|
|
413
424
|
flowId: self.flowId ?? void 0,
|
|
414
425
|
flowPath: self.flowPath ?? void 0
|
|
415
426
|
};
|
|
@@ -433,7 +444,8 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
433
444
|
visitorName: self.visitorName ?? void 0,
|
|
434
445
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
435
446
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
436
|
-
|
|
447
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
448
|
+
customLocation: self.customLocation ?? void 0,
|
|
437
449
|
flowId: self.flowId ?? void 0,
|
|
438
450
|
flowPath: self.flowPath ?? void 0
|
|
439
451
|
};
|
|
@@ -493,7 +505,8 @@ function mapEventFromApi(d) {
|
|
|
493
505
|
visitorEmail: pick("visitorEmail", "VisitorEmail", "visitor_email"),
|
|
494
506
|
visitorPhone: pick("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
495
507
|
externalEventId: pick("externalEventId", "ExternalEventId", "external_event_id"),
|
|
496
|
-
|
|
508
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
509
|
+
customLocation: pick("customLocation", "CustomLocation", "custom_location"),
|
|
497
510
|
flowId: pick("flowId", "FlowId", "flow_id"),
|
|
498
511
|
flowPath: pick("flowPath", "FlowPath", "flow_path"),
|
|
499
512
|
attendeeStatus: n(pick("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
@@ -1745,8 +1758,116 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1745
1758
|
};
|
|
1746
1759
|
var Asset_default = AssetModel;
|
|
1747
1760
|
|
|
1748
|
-
// src/models/appointment/
|
|
1761
|
+
// src/models/appointment/CalendarLocation.js
|
|
1749
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");
|
|
1750
1871
|
var PreferenceScope = {
|
|
1751
1872
|
Global: 0,
|
|
1752
1873
|
Consumer: 1,
|
|
@@ -1755,13 +1876,13 @@ var PreferenceScope = {
|
|
|
1755
1876
|
Event: 4
|
|
1756
1877
|
};
|
|
1757
1878
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1758
|
-
var PreferenceModel =
|
|
1759
|
-
id:
|
|
1760
|
-
preferenceId:
|
|
1761
|
-
level:
|
|
1762
|
-
primaryKey:
|
|
1763
|
-
preferenceOption:
|
|
1764
|
-
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)
|
|
1765
1886
|
}).actions((self) => ({
|
|
1766
1887
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1767
1888
|
async save() {
|
|
@@ -1809,7 +1930,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1809
1930
|
var Preference_default = PreferenceModel;
|
|
1810
1931
|
|
|
1811
1932
|
// src/models/appointment/Flow.js
|
|
1812
|
-
var
|
|
1933
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
1813
1934
|
function mapFlowFromApi(d) {
|
|
1814
1935
|
if (!d) return d;
|
|
1815
1936
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1827,26 +1948,26 @@ function mapFlowFromApi(d) {
|
|
|
1827
1948
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1828
1949
|
};
|
|
1829
1950
|
}
|
|
1830
|
-
var FlowModel =
|
|
1831
|
-
id:
|
|
1832
|
-
flowId:
|
|
1833
|
-
companyKey:
|
|
1834
|
-
name:
|
|
1835
|
-
description:
|
|
1836
|
-
flowJson:
|
|
1837
|
-
isActive:
|
|
1838
|
-
isDeleted:
|
|
1839
|
-
createdOn:
|
|
1840
|
-
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)
|
|
1841
1962
|
}).actions((self) => {
|
|
1842
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1963
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree18.getEnv);
|
|
1843
1964
|
return {
|
|
1844
1965
|
/** GET flow/get – fetch this flow by flowId */
|
|
1845
1966
|
async get() {
|
|
1846
1967
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1847
1968
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1848
1969
|
if (res.status === "success" && res.data) {
|
|
1849
|
-
(0,
|
|
1970
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1850
1971
|
}
|
|
1851
1972
|
return res;
|
|
1852
1973
|
},
|
|
@@ -1861,7 +1982,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1861
1982
|
};
|
|
1862
1983
|
const res = await reqPost("/flow/create", payload);
|
|
1863
1984
|
if (res.status === "success" && res.data) {
|
|
1864
|
-
(0,
|
|
1985
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1865
1986
|
}
|
|
1866
1987
|
return res;
|
|
1867
1988
|
},
|
|
@@ -1877,7 +1998,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1877
1998
|
};
|
|
1878
1999
|
const res = await reqPost("/flow/update", payload);
|
|
1879
2000
|
if (res.status === "success" && res.data) {
|
|
1880
|
-
(0,
|
|
2001
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1881
2002
|
}
|
|
1882
2003
|
return res;
|
|
1883
2004
|
},
|
|
@@ -1891,7 +2012,7 @@ var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
|
1891
2012
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1892
2013
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1893
2014
|
if (res.status === "success" && res.data) {
|
|
1894
|
-
(0,
|
|
2015
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1895
2016
|
}
|
|
1896
2017
|
return res;
|
|
1897
2018
|
},
|
|
@@ -2068,7 +2189,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2068
2189
|
var Flow_default = FlowModel;
|
|
2069
2190
|
|
|
2070
2191
|
// src/models/appointment/Lead.js
|
|
2071
|
-
var
|
|
2192
|
+
var import_mobx_state_tree19 = require("mobx-state-tree");
|
|
2072
2193
|
function mapLeadFromApi(d) {
|
|
2073
2194
|
if (!d) return d;
|
|
2074
2195
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2097,27 +2218,27 @@ function mapLeadFromApi(d) {
|
|
|
2097
2218
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2098
2219
|
};
|
|
2099
2220
|
}
|
|
2100
|
-
var LeadModel =
|
|
2101
|
-
id:
|
|
2102
|
-
leadId:
|
|
2103
|
-
email:
|
|
2104
|
-
name:
|
|
2105
|
-
phone:
|
|
2106
|
-
companyKey:
|
|
2107
|
-
source:
|
|
2108
|
-
leadType:
|
|
2109
|
-
referrerLink:
|
|
2110
|
-
createdOn:
|
|
2111
|
-
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)
|
|
2112
2233
|
}).actions((self) => {
|
|
2113
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2234
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree19.getEnv);
|
|
2114
2235
|
return {
|
|
2115
2236
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2116
2237
|
async get() {
|
|
2117
2238
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2118
2239
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2119
2240
|
if (res.status === "success" && res.data) {
|
|
2120
|
-
(0,
|
|
2241
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2121
2242
|
}
|
|
2122
2243
|
return res;
|
|
2123
2244
|
},
|
|
@@ -2128,7 +2249,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2128
2249
|
}
|
|
2129
2250
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2130
2251
|
if (lead) {
|
|
2131
|
-
(0,
|
|
2252
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, (0, import_mobx_state_tree19.getSnapshot)(lead));
|
|
2132
2253
|
}
|
|
2133
2254
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2134
2255
|
},
|
|
@@ -2150,7 +2271,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2150
2271
|
};
|
|
2151
2272
|
const res = await reqPost("/lead/create", payload);
|
|
2152
2273
|
if (res.status === "success" && res.data) {
|
|
2153
|
-
(0,
|
|
2274
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2154
2275
|
}
|
|
2155
2276
|
return res;
|
|
2156
2277
|
},
|
|
@@ -2171,7 +2292,7 @@ var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
|
2171
2292
|
};
|
|
2172
2293
|
const res = await reqPost("/lead/update", payload);
|
|
2173
2294
|
if (res.status === "success" && res.data) {
|
|
2174
|
-
(0,
|
|
2295
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2175
2296
|
}
|
|
2176
2297
|
return res;
|
|
2177
2298
|
},
|
|
@@ -2297,19 +2418,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2297
2418
|
var Lead_default = LeadModel;
|
|
2298
2419
|
|
|
2299
2420
|
// src/models/appointment/CustomField.js
|
|
2300
|
-
var
|
|
2301
|
-
var CustomFieldModel =
|
|
2302
|
-
id:
|
|
2303
|
-
customFieldId:
|
|
2304
|
-
calendarId:
|
|
2305
|
-
label:
|
|
2306
|
-
type:
|
|
2307
|
-
isRequired:
|
|
2308
|
-
createdOn:
|
|
2309
|
-
modifiedOn:
|
|
2310
|
-
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)
|
|
2311
2432
|
}).actions((self) => {
|
|
2312
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2433
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree20.getEnv);
|
|
2313
2434
|
return {
|
|
2314
2435
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2315
2436
|
async getAll(calendarId) {
|
|
@@ -2327,10 +2448,10 @@ var CustomFieldModel = import_mobx_state_tree19.types.model("CustomField", {
|
|
|
2327
2448
|
},
|
|
2328
2449
|
/** POST /CustomField/Add */
|
|
2329
2450
|
async add(payload) {
|
|
2330
|
-
const body = payload ??
|
|
2451
|
+
const body = payload ?? toPayload5(self);
|
|
2331
2452
|
const res = await reqPost("/CustomField/Add", body);
|
|
2332
2453
|
if (res.status === "success" && res.data) {
|
|
2333
|
-
(0,
|
|
2454
|
+
(0, import_mobx_state_tree20.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
2334
2455
|
}
|
|
2335
2456
|
return res;
|
|
2336
2457
|
},
|
|
@@ -2394,7 +2515,7 @@ function mapCustomFieldFromApi(d) {
|
|
|
2394
2515
|
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2395
2516
|
};
|
|
2396
2517
|
}
|
|
2397
|
-
function
|
|
2518
|
+
function toPayload5(self) {
|
|
2398
2519
|
return {
|
|
2399
2520
|
customFieldId: self.customFieldId || void 0,
|
|
2400
2521
|
calendarId: self.calendarId || void 0,
|
|
@@ -2466,10 +2587,10 @@ CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
|
2466
2587
|
var CustomField_default = CustomFieldModel;
|
|
2467
2588
|
|
|
2468
2589
|
// src/models/appointment/index.js
|
|
2469
|
-
var
|
|
2470
|
-
var RootStore =
|
|
2471
|
-
calendars:
|
|
2472
|
-
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), {})
|
|
2473
2594
|
}).actions((self) => ({
|
|
2474
2595
|
addCalendar(snapshot) {
|
|
2475
2596
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2495,6 +2616,7 @@ function createRootStore(initialState = {}) {
|
|
|
2495
2616
|
AvailabilityDetailModel,
|
|
2496
2617
|
AvailabilityModel,
|
|
2497
2618
|
CalendarDayModel,
|
|
2619
|
+
CalendarLocationModel,
|
|
2498
2620
|
CalendarModel,
|
|
2499
2621
|
CalendarParticipantModel,
|
|
2500
2622
|
CompanyModel,
|
|
@@ -2504,6 +2626,7 @@ function createRootStore(initialState = {}) {
|
|
|
2504
2626
|
EventModel,
|
|
2505
2627
|
FlowModel,
|
|
2506
2628
|
LeadModel,
|
|
2629
|
+
LocationType,
|
|
2507
2630
|
OpeningHourModel,
|
|
2508
2631
|
ParticipantInfoModel,
|
|
2509
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,7 +288,8 @@ 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),
|
|
285
|
-
|
|
291
|
+
calendarLocationId: types4.optional(types4.maybeNull(types4.string), null),
|
|
292
|
+
customLocation: types4.optional(types4.maybeNull(types4.string), null),
|
|
286
293
|
flowId: types4.optional(types4.maybeNull(types4.string), null),
|
|
287
294
|
flowPath: types4.optional(types4.maybeNull(types4.string), null),
|
|
288
295
|
attendeeStatus: types4.optional(types4.number, AttendeeStatus.Tentative),
|
|
@@ -329,7 +336,8 @@ var EventModel = types4.model("Event", {
|
|
|
329
336
|
visitorName: self.visitorName ?? void 0,
|
|
330
337
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
331
338
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
332
|
-
|
|
339
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
340
|
+
customLocation: self.customLocation ?? void 0,
|
|
333
341
|
flowId: self.flowId ?? void 0,
|
|
334
342
|
flowPath: self.flowPath ?? void 0
|
|
335
343
|
};
|
|
@@ -354,7 +362,8 @@ var EventModel = types4.model("Event", {
|
|
|
354
362
|
visitorName: self.visitorName ?? void 0,
|
|
355
363
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
356
364
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
357
|
-
|
|
365
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
366
|
+
customLocation: self.customLocation ?? void 0,
|
|
358
367
|
flowId: self.flowId ?? void 0,
|
|
359
368
|
flowPath: self.flowPath ?? void 0
|
|
360
369
|
};
|
|
@@ -378,7 +387,8 @@ var EventModel = types4.model("Event", {
|
|
|
378
387
|
visitorName: self.visitorName ?? void 0,
|
|
379
388
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
380
389
|
visitorPhone: self.visitorPhone ?? void 0,
|
|
381
|
-
|
|
390
|
+
calendarLocationId: self.calendarLocationId ?? void 0,
|
|
391
|
+
customLocation: self.customLocation ?? void 0,
|
|
382
392
|
flowId: self.flowId ?? void 0,
|
|
383
393
|
flowPath: self.flowPath ?? void 0
|
|
384
394
|
};
|
|
@@ -438,7 +448,8 @@ function mapEventFromApi(d) {
|
|
|
438
448
|
visitorEmail: pick("visitorEmail", "VisitorEmail", "visitor_email"),
|
|
439
449
|
visitorPhone: pick("visitorPhone", "VisitorPhone", "visitor_phone"),
|
|
440
450
|
externalEventId: pick("externalEventId", "ExternalEventId", "external_event_id"),
|
|
441
|
-
|
|
451
|
+
calendarLocationId: pick("calendarLocationId", "CalendarLocationId", "calendar_location_id"),
|
|
452
|
+
customLocation: pick("customLocation", "CustomLocation", "custom_location"),
|
|
442
453
|
flowId: pick("flowId", "FlowId", "flow_id"),
|
|
443
454
|
flowPath: pick("flowPath", "FlowPath", "flow_path"),
|
|
444
455
|
attendeeStatus: n(pick("attendeeStatus", "AttendeeStatus", "attendee_status")),
|
|
@@ -1690,8 +1701,116 @@ AssetModel.upload = async (file, opts = {}) => {
|
|
|
1690
1701
|
};
|
|
1691
1702
|
var Asset_default = AssetModel;
|
|
1692
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
|
+
|
|
1693
1812
|
// src/models/appointment/Preference.js
|
|
1694
|
-
import { types as
|
|
1813
|
+
import { types as types17 } from "mobx-state-tree";
|
|
1695
1814
|
var PreferenceScope = {
|
|
1696
1815
|
Global: 0,
|
|
1697
1816
|
Consumer: 1,
|
|
@@ -1700,13 +1819,13 @@ var PreferenceScope = {
|
|
|
1700
1819
|
Event: 4
|
|
1701
1820
|
};
|
|
1702
1821
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1703
|
-
var PreferenceModel =
|
|
1704
|
-
id:
|
|
1705
|
-
preferenceId:
|
|
1706
|
-
level:
|
|
1707
|
-
primaryKey:
|
|
1708
|
-
preferenceOption:
|
|
1709
|
-
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)
|
|
1710
1829
|
}).actions((self) => ({
|
|
1711
1830
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1712
1831
|
async save() {
|
|
@@ -1754,7 +1873,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1754
1873
|
var Preference_default = PreferenceModel;
|
|
1755
1874
|
|
|
1756
1875
|
// src/models/appointment/Flow.js
|
|
1757
|
-
import { types as
|
|
1876
|
+
import { types as types18, getEnv as getEnv8, applySnapshot as applySnapshot7 } from "mobx-state-tree";
|
|
1758
1877
|
function mapFlowFromApi(d) {
|
|
1759
1878
|
if (!d) return d;
|
|
1760
1879
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1772,26 +1891,26 @@ function mapFlowFromApi(d) {
|
|
|
1772
1891
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1773
1892
|
};
|
|
1774
1893
|
}
|
|
1775
|
-
var FlowModel =
|
|
1776
|
-
id:
|
|
1777
|
-
flowId:
|
|
1778
|
-
companyKey:
|
|
1779
|
-
name:
|
|
1780
|
-
description:
|
|
1781
|
-
flowJson:
|
|
1782
|
-
isActive:
|
|
1783
|
-
isDeleted:
|
|
1784
|
-
createdOn:
|
|
1785
|
-
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)
|
|
1786
1905
|
}).actions((self) => {
|
|
1787
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1906
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv8);
|
|
1788
1907
|
return {
|
|
1789
1908
|
/** GET flow/get – fetch this flow by flowId */
|
|
1790
1909
|
async get() {
|
|
1791
1910
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1792
1911
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1793
1912
|
if (res.status === "success" && res.data) {
|
|
1794
|
-
|
|
1913
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1795
1914
|
}
|
|
1796
1915
|
return res;
|
|
1797
1916
|
},
|
|
@@ -1806,7 +1925,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1806
1925
|
};
|
|
1807
1926
|
const res = await reqPost("/flow/create", payload);
|
|
1808
1927
|
if (res.status === "success" && res.data) {
|
|
1809
|
-
|
|
1928
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1810
1929
|
}
|
|
1811
1930
|
return res;
|
|
1812
1931
|
},
|
|
@@ -1822,7 +1941,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1822
1941
|
};
|
|
1823
1942
|
const res = await reqPost("/flow/update", payload);
|
|
1824
1943
|
if (res.status === "success" && res.data) {
|
|
1825
|
-
|
|
1944
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1826
1945
|
}
|
|
1827
1946
|
return res;
|
|
1828
1947
|
},
|
|
@@ -1836,7 +1955,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1836
1955
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1837
1956
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1838
1957
|
if (res.status === "success" && res.data) {
|
|
1839
|
-
|
|
1958
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1840
1959
|
}
|
|
1841
1960
|
return res;
|
|
1842
1961
|
},
|
|
@@ -2013,7 +2132,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2013
2132
|
var Flow_default = FlowModel;
|
|
2014
2133
|
|
|
2015
2134
|
// src/models/appointment/Lead.js
|
|
2016
|
-
import { types as
|
|
2135
|
+
import { types as types19, getEnv as getEnv9, applySnapshot as applySnapshot8, getSnapshot } from "mobx-state-tree";
|
|
2017
2136
|
function mapLeadFromApi(d) {
|
|
2018
2137
|
if (!d) return d;
|
|
2019
2138
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2042,27 +2161,27 @@ function mapLeadFromApi(d) {
|
|
|
2042
2161
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2043
2162
|
};
|
|
2044
2163
|
}
|
|
2045
|
-
var LeadModel =
|
|
2046
|
-
id:
|
|
2047
|
-
leadId:
|
|
2048
|
-
email:
|
|
2049
|
-
name:
|
|
2050
|
-
phone:
|
|
2051
|
-
companyKey:
|
|
2052
|
-
source:
|
|
2053
|
-
leadType:
|
|
2054
|
-
referrerLink:
|
|
2055
|
-
createdOn:
|
|
2056
|
-
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)
|
|
2057
2176
|
}).actions((self) => {
|
|
2058
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2177
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv9);
|
|
2059
2178
|
return {
|
|
2060
2179
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2061
2180
|
async get() {
|
|
2062
2181
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2063
2182
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2064
2183
|
if (res.status === "success" && res.data) {
|
|
2065
|
-
|
|
2184
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2066
2185
|
}
|
|
2067
2186
|
return res;
|
|
2068
2187
|
},
|
|
@@ -2073,7 +2192,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2073
2192
|
}
|
|
2074
2193
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2075
2194
|
if (lead) {
|
|
2076
|
-
|
|
2195
|
+
applySnapshot8(self, getSnapshot(lead));
|
|
2077
2196
|
}
|
|
2078
2197
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2079
2198
|
},
|
|
@@ -2095,7 +2214,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2095
2214
|
};
|
|
2096
2215
|
const res = await reqPost("/lead/create", payload);
|
|
2097
2216
|
if (res.status === "success" && res.data) {
|
|
2098
|
-
|
|
2217
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2099
2218
|
}
|
|
2100
2219
|
return res;
|
|
2101
2220
|
},
|
|
@@ -2116,7 +2235,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2116
2235
|
};
|
|
2117
2236
|
const res = await reqPost("/lead/update", payload);
|
|
2118
2237
|
if (res.status === "success" && res.data) {
|
|
2119
|
-
|
|
2238
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2120
2239
|
}
|
|
2121
2240
|
return res;
|
|
2122
2241
|
},
|
|
@@ -2242,19 +2361,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2242
2361
|
var Lead_default = LeadModel;
|
|
2243
2362
|
|
|
2244
2363
|
// src/models/appointment/CustomField.js
|
|
2245
|
-
import { types as
|
|
2246
|
-
var CustomFieldModel =
|
|
2247
|
-
id:
|
|
2248
|
-
customFieldId:
|
|
2249
|
-
calendarId:
|
|
2250
|
-
label:
|
|
2251
|
-
type:
|
|
2252
|
-
isRequired:
|
|
2253
|
-
createdOn:
|
|
2254
|
-
modifiedOn:
|
|
2255
|
-
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)
|
|
2256
2375
|
}).actions((self) => {
|
|
2257
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2376
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
|
|
2258
2377
|
return {
|
|
2259
2378
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2260
2379
|
async getAll(calendarId) {
|
|
@@ -2272,10 +2391,10 @@ var CustomFieldModel = types19.model("CustomField", {
|
|
|
2272
2391
|
},
|
|
2273
2392
|
/** POST /CustomField/Add */
|
|
2274
2393
|
async add(payload) {
|
|
2275
|
-
const body = payload ??
|
|
2394
|
+
const body = payload ?? toPayload5(self);
|
|
2276
2395
|
const res = await reqPost("/CustomField/Add", body);
|
|
2277
2396
|
if (res.status === "success" && res.data) {
|
|
2278
|
-
|
|
2397
|
+
applySnapshot9(self, mapCustomFieldFromApi(res.data));
|
|
2279
2398
|
}
|
|
2280
2399
|
return res;
|
|
2281
2400
|
},
|
|
@@ -2339,7 +2458,7 @@ function mapCustomFieldFromApi(d) {
|
|
|
2339
2458
|
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2340
2459
|
};
|
|
2341
2460
|
}
|
|
2342
|
-
function
|
|
2461
|
+
function toPayload5(self) {
|
|
2343
2462
|
return {
|
|
2344
2463
|
customFieldId: self.customFieldId || void 0,
|
|
2345
2464
|
calendarId: self.calendarId || void 0,
|
|
@@ -2411,10 +2530,10 @@ CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
|
2411
2530
|
var CustomField_default = CustomFieldModel;
|
|
2412
2531
|
|
|
2413
2532
|
// src/models/appointment/index.js
|
|
2414
|
-
import { types as
|
|
2415
|
-
var RootStore =
|
|
2416
|
-
calendars:
|
|
2417
|
-
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), {})
|
|
2418
2537
|
}).actions((self) => ({
|
|
2419
2538
|
addCalendar(snapshot) {
|
|
2420
2539
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2439,6 +2558,7 @@ export {
|
|
|
2439
2558
|
AvailabilityDetail_default as AvailabilityDetailModel,
|
|
2440
2559
|
Availability_default as AvailabilityModel,
|
|
2441
2560
|
CalendarDay_default as CalendarDayModel,
|
|
2561
|
+
CalendarLocation_default as CalendarLocationModel,
|
|
2442
2562
|
Calendar_default as CalendarModel,
|
|
2443
2563
|
CalendarParticipant_default as CalendarParticipantModel,
|
|
2444
2564
|
Company_default as CompanyModel,
|
|
@@ -2448,6 +2568,7 @@ export {
|
|
|
2448
2568
|
Event_default as EventModel,
|
|
2449
2569
|
Flow_default as FlowModel,
|
|
2450
2570
|
Lead_default as LeadModel,
|
|
2571
|
+
LocationType,
|
|
2451
2572
|
OpeningHour_default as OpeningHourModel,
|
|
2452
2573
|
ParticipantInfo_default as ParticipantInfoModel,
|
|
2453
2574
|
Participant_default as ParticipantModel,
|