@blazeo.com/calendar-client 1.0.21 → 1.0.23
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 +272 -236
- package/dist/index.js +196 -69
- package/dist/index.mjs +194 -69
- package/package.json +1 -1
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);
|
|
@@ -1763,6 +1882,7 @@ function mapFlowFromApi(d) {
|
|
|
1763
1882
|
id: pick("id", "Id") ?? null,
|
|
1764
1883
|
flowId: pick("flowId", "FlowId", "flow_id") ?? "",
|
|
1765
1884
|
companyKey: pick("companyKey", "CompanyKey", "company_key") ?? "",
|
|
1885
|
+
calendarId: pick("calendarId", "CalendarId", "calendar_id") ?? null,
|
|
1766
1886
|
name: pick("name", "Name") ?? "",
|
|
1767
1887
|
description: pick("description", "Description") ?? null,
|
|
1768
1888
|
flowJson: pick("flowJson", "FlowJson", "flow_json") ?? "",
|
|
@@ -1772,26 +1892,27 @@ function mapFlowFromApi(d) {
|
|
|
1772
1892
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1773
1893
|
};
|
|
1774
1894
|
}
|
|
1775
|
-
var FlowModel =
|
|
1776
|
-
id:
|
|
1777
|
-
flowId:
|
|
1778
|
-
companyKey:
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1895
|
+
var FlowModel = types18.model("Flow", {
|
|
1896
|
+
id: types18.optional(types18.maybeNull(types18.number), null),
|
|
1897
|
+
flowId: types18.optional(types18.identifier, "new"),
|
|
1898
|
+
companyKey: types18.optional(types18.maybeNull(types18.string), null),
|
|
1899
|
+
calendarId: types18.optional(types18.maybeNull(types18.string), null),
|
|
1900
|
+
name: types18.optional(types18.maybeNull(types18.string), null),
|
|
1901
|
+
description: types18.optional(types18.maybeNull(types18.string), null),
|
|
1902
|
+
flowJson: types18.optional(types18.string, ""),
|
|
1903
|
+
isActive: types18.optional(types18.boolean, true),
|
|
1904
|
+
isDeleted: types18.optional(types18.boolean, false),
|
|
1905
|
+
createdOn: types18.optional(types18.maybeNull(types18.string), null),
|
|
1906
|
+
modifiedOn: types18.optional(types18.maybeNull(types18.string), null)
|
|
1786
1907
|
}).actions((self) => {
|
|
1787
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1908
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv8);
|
|
1788
1909
|
return {
|
|
1789
1910
|
/** GET flow/get – fetch this flow by flowId */
|
|
1790
1911
|
async get() {
|
|
1791
1912
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1792
1913
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1793
1914
|
if (res.status === "success" && res.data) {
|
|
1794
|
-
|
|
1915
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1795
1916
|
}
|
|
1796
1917
|
return res;
|
|
1797
1918
|
},
|
|
@@ -1799,6 +1920,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1799
1920
|
async create() {
|
|
1800
1921
|
const payload = {
|
|
1801
1922
|
companyKey: self.companyKey ?? void 0,
|
|
1923
|
+
calendarId: self.calendarId ?? void 0,
|
|
1802
1924
|
name: self.name ?? void 0,
|
|
1803
1925
|
description: self.description ?? void 0,
|
|
1804
1926
|
flowJson: self.flowJson || void 0,
|
|
@@ -1806,7 +1928,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1806
1928
|
};
|
|
1807
1929
|
const res = await reqPost("/flow/create", payload);
|
|
1808
1930
|
if (res.status === "success" && res.data) {
|
|
1809
|
-
|
|
1931
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1810
1932
|
}
|
|
1811
1933
|
return res;
|
|
1812
1934
|
},
|
|
@@ -1815,6 +1937,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1815
1937
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1816
1938
|
const payload = {
|
|
1817
1939
|
flowId: self.flowId,
|
|
1940
|
+
calendarId: self.calendarId ?? void 0,
|
|
1818
1941
|
name: self.name ?? void 0,
|
|
1819
1942
|
description: self.description ?? void 0,
|
|
1820
1943
|
flowJson: self.flowJson || void 0,
|
|
@@ -1822,7 +1945,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1822
1945
|
};
|
|
1823
1946
|
const res = await reqPost("/flow/update", payload);
|
|
1824
1947
|
if (res.status === "success" && res.data) {
|
|
1825
|
-
|
|
1948
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1826
1949
|
}
|
|
1827
1950
|
return res;
|
|
1828
1951
|
},
|
|
@@ -1836,7 +1959,7 @@ var FlowModel = types17.model("Flow", {
|
|
|
1836
1959
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1837
1960
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1838
1961
|
if (res.status === "success" && res.data) {
|
|
1839
|
-
|
|
1962
|
+
applySnapshot7(self, mapFlowFromApi(res.data));
|
|
1840
1963
|
}
|
|
1841
1964
|
return res;
|
|
1842
1965
|
},
|
|
@@ -2013,7 +2136,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
2013
2136
|
var Flow_default = FlowModel;
|
|
2014
2137
|
|
|
2015
2138
|
// src/models/appointment/Lead.js
|
|
2016
|
-
import { types as
|
|
2139
|
+
import { types as types19, getEnv as getEnv9, applySnapshot as applySnapshot8, getSnapshot } from "mobx-state-tree";
|
|
2017
2140
|
function mapLeadFromApi(d) {
|
|
2018
2141
|
if (!d) return d;
|
|
2019
2142
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2042,27 +2165,27 @@ function mapLeadFromApi(d) {
|
|
|
2042
2165
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2043
2166
|
};
|
|
2044
2167
|
}
|
|
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:
|
|
2168
|
+
var LeadModel = types19.model("Lead", {
|
|
2169
|
+
id: types19.optional(types19.maybeNull(types19.number), null),
|
|
2170
|
+
leadId: types19.optional(types19.identifier, "new"),
|
|
2171
|
+
email: types19.optional(types19.string, ""),
|
|
2172
|
+
name: types19.optional(types19.string, ""),
|
|
2173
|
+
phone: types19.optional(types19.string, ""),
|
|
2174
|
+
companyKey: types19.optional(types19.string, ""),
|
|
2175
|
+
source: types19.optional(types19.string, ""),
|
|
2176
|
+
leadType: types19.optional(types19.number, 2),
|
|
2177
|
+
referrerLink: types19.optional(types19.string, ""),
|
|
2178
|
+
createdOn: types19.optional(types19.maybeNull(types19.string), null),
|
|
2179
|
+
modifiedOn: types19.optional(types19.maybeNull(types19.string), null)
|
|
2057
2180
|
}).actions((self) => {
|
|
2058
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2181
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv9);
|
|
2059
2182
|
return {
|
|
2060
2183
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2061
2184
|
async get() {
|
|
2062
2185
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2063
2186
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2064
2187
|
if (res.status === "success" && res.data) {
|
|
2065
|
-
|
|
2188
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2066
2189
|
}
|
|
2067
2190
|
return res;
|
|
2068
2191
|
},
|
|
@@ -2073,7 +2196,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2073
2196
|
}
|
|
2074
2197
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2075
2198
|
if (lead) {
|
|
2076
|
-
|
|
2199
|
+
applySnapshot8(self, getSnapshot(lead));
|
|
2077
2200
|
}
|
|
2078
2201
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2079
2202
|
},
|
|
@@ -2095,7 +2218,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2095
2218
|
};
|
|
2096
2219
|
const res = await reqPost("/lead/create", payload);
|
|
2097
2220
|
if (res.status === "success" && res.data) {
|
|
2098
|
-
|
|
2221
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2099
2222
|
}
|
|
2100
2223
|
return res;
|
|
2101
2224
|
},
|
|
@@ -2116,7 +2239,7 @@ var LeadModel = types18.model("Lead", {
|
|
|
2116
2239
|
};
|
|
2117
2240
|
const res = await reqPost("/lead/update", payload);
|
|
2118
2241
|
if (res.status === "success" && res.data) {
|
|
2119
|
-
|
|
2242
|
+
applySnapshot8(self, mapLeadFromApi(res.data));
|
|
2120
2243
|
}
|
|
2121
2244
|
return res;
|
|
2122
2245
|
},
|
|
@@ -2242,19 +2365,19 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2242
2365
|
var Lead_default = LeadModel;
|
|
2243
2366
|
|
|
2244
2367
|
// 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:
|
|
2368
|
+
import { types as types20, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
|
|
2369
|
+
var CustomFieldModel = types20.model("CustomField", {
|
|
2370
|
+
id: types20.optional(types20.maybeNull(types20.number), null),
|
|
2371
|
+
customFieldId: types20.optional(types20.maybeNull(types20.string), null),
|
|
2372
|
+
calendarId: types20.optional(types20.maybeNull(types20.string), null),
|
|
2373
|
+
label: types20.optional(types20.maybeNull(types20.string), null),
|
|
2374
|
+
type: types20.optional(types20.string, ""),
|
|
2375
|
+
isRequired: types20.optional(types20.boolean, false),
|
|
2376
|
+
createdOn: types20.optional(types20.maybeNull(types20.string), null),
|
|
2377
|
+
modifiedOn: types20.optional(types20.maybeNull(types20.string), null),
|
|
2378
|
+
isDeleted: types20.optional(types20.boolean, false)
|
|
2256
2379
|
}).actions((self) => {
|
|
2257
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2380
|
+
const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
|
|
2258
2381
|
return {
|
|
2259
2382
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2260
2383
|
async getAll(calendarId) {
|
|
@@ -2272,10 +2395,10 @@ var CustomFieldModel = types19.model("CustomField", {
|
|
|
2272
2395
|
},
|
|
2273
2396
|
/** POST /CustomField/Add */
|
|
2274
2397
|
async add(payload) {
|
|
2275
|
-
const body = payload ??
|
|
2398
|
+
const body = payload ?? toPayload5(self);
|
|
2276
2399
|
const res = await reqPost("/CustomField/Add", body);
|
|
2277
2400
|
if (res.status === "success" && res.data) {
|
|
2278
|
-
|
|
2401
|
+
applySnapshot9(self, mapCustomFieldFromApi(res.data));
|
|
2279
2402
|
}
|
|
2280
2403
|
return res;
|
|
2281
2404
|
},
|
|
@@ -2339,7 +2462,7 @@ function mapCustomFieldFromApi(d) {
|
|
|
2339
2462
|
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2340
2463
|
};
|
|
2341
2464
|
}
|
|
2342
|
-
function
|
|
2465
|
+
function toPayload5(self) {
|
|
2343
2466
|
return {
|
|
2344
2467
|
customFieldId: self.customFieldId || void 0,
|
|
2345
2468
|
calendarId: self.calendarId || void 0,
|
|
@@ -2411,10 +2534,10 @@ CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
|
2411
2534
|
var CustomField_default = CustomFieldModel;
|
|
2412
2535
|
|
|
2413
2536
|
// src/models/appointment/index.js
|
|
2414
|
-
import { types as
|
|
2415
|
-
var RootStore =
|
|
2416
|
-
calendars:
|
|
2417
|
-
events:
|
|
2537
|
+
import { types as types21, getEnv as getEnv11 } from "mobx-state-tree";
|
|
2538
|
+
var RootStore = types21.model("RootStore", {
|
|
2539
|
+
calendars: types21.optional(types21.map(Calendar_default), {}),
|
|
2540
|
+
events: types21.optional(types21.map(Event_default), {})
|
|
2418
2541
|
}).actions((self) => ({
|
|
2419
2542
|
addCalendar(snapshot) {
|
|
2420
2543
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2439,6 +2562,7 @@ export {
|
|
|
2439
2562
|
AvailabilityDetail_default as AvailabilityDetailModel,
|
|
2440
2563
|
Availability_default as AvailabilityModel,
|
|
2441
2564
|
CalendarDay_default as CalendarDayModel,
|
|
2565
|
+
CalendarLocation_default as CalendarLocationModel,
|
|
2442
2566
|
Calendar_default as CalendarModel,
|
|
2443
2567
|
CalendarParticipant_default as CalendarParticipantModel,
|
|
2444
2568
|
Company_default as CompanyModel,
|
|
@@ -2448,6 +2572,7 @@ export {
|
|
|
2448
2572
|
Event_default as EventModel,
|
|
2449
2573
|
Flow_default as FlowModel,
|
|
2450
2574
|
Lead_default as LeadModel,
|
|
2575
|
+
LocationType,
|
|
2451
2576
|
OpeningHour_default as OpeningHourModel,
|
|
2452
2577
|
ParticipantInfo_default as ParticipantInfoModel,
|
|
2453
2578
|
Participant_default as ParticipantModel,
|