@blazeo.com/calendar-client 1.0.17 → 1.0.19
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 +236 -199
- package/dist/index.js +313 -49
- package/dist/index.mjs +303 -41
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/models/appointment/index.js
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
|
+
AssetModel: () => Asset_default,
|
|
22
23
|
AssignmentMethod: () => AssignmentMethod,
|
|
23
24
|
AttendeeStatus: () => AttendeeStatus,
|
|
24
25
|
AvailabilityDetailModel: () => AvailabilityDetail_default,
|
|
@@ -28,6 +29,7 @@ __export(index_exports, {
|
|
|
28
29
|
CalendarParticipantModel: () => CalendarParticipant_default,
|
|
29
30
|
CompanyModel: () => Company_default,
|
|
30
31
|
ConfigModel: () => ConfigModel_default,
|
|
32
|
+
CustomFieldModel: () => CustomField_default,
|
|
31
33
|
DayOfWeek: () => DayOfWeek,
|
|
32
34
|
EventModel: () => Event_default,
|
|
33
35
|
FlowModel: () => Flow_default,
|
|
@@ -150,8 +152,8 @@ function mergeConsumerHeader(env, opts) {
|
|
|
150
152
|
if (!headers["Consumer"] && (env == null ? void 0 : env.consumer)) headers["Consumer"] = env.consumer;
|
|
151
153
|
return { ...opts, headers };
|
|
152
154
|
}
|
|
153
|
-
function createRequestHelpers(self,
|
|
154
|
-
const env = () =>
|
|
155
|
+
function createRequestHelpers(self, getEnv11) {
|
|
156
|
+
const env = () => getEnv11(self);
|
|
155
157
|
const baseUrl = () => env().baseUrl;
|
|
156
158
|
const fetchFn = () => env().fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
|
|
157
159
|
throw new Error("fetch not available");
|
|
@@ -907,6 +909,12 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
907
909
|
else if (self.calendarId) q.calendar_id = self.calendarId;
|
|
908
910
|
return reqGet("/Calendar/Participant/OpeningHours/Get", q);
|
|
909
911
|
},
|
|
912
|
+
/** GET Calendar/Participant/OpeningHours/All/Get */
|
|
913
|
+
async getAllParticipantOpeningHours(calendarId) {
|
|
914
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
915
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
916
|
+
return reqGet("/Calendar/Participant/OpeningHours/All/Get", { calendar_id: resolvedCalendarId });
|
|
917
|
+
},
|
|
910
918
|
/** POST Calendar/Participant/Availability/OpeningHour/Save */
|
|
911
919
|
async saveOpeningHour(payload) {
|
|
912
920
|
return reqPost("/Calendar/Participant/Availability/OpeningHour/Save", payload);
|
|
@@ -1103,6 +1111,11 @@ CalendarModel.getParticipants = async (calendarId) => {
|
|
|
1103
1111
|
}
|
|
1104
1112
|
return null;
|
|
1105
1113
|
};
|
|
1114
|
+
CalendarModel.getAllParticipantOpeningHours = async (calendarId) => {
|
|
1115
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1116
|
+
const res = await reqGet("/Calendar/Participant/OpeningHours/All/Get", { calendar_id: calendarId });
|
|
1117
|
+
return res.status === "success" && Array.isArray(res.data) ? res.data : null;
|
|
1118
|
+
};
|
|
1106
1119
|
CalendarModel.getCalendarParticipant = async (calendarId) => {
|
|
1107
1120
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1108
1121
|
const res = await reqGet("/Calendar/Participant/Get", { calendar_id: calendarId });
|
|
@@ -1636,8 +1649,88 @@ CompanyModel.save = async (payload) => {
|
|
|
1636
1649
|
};
|
|
1637
1650
|
var Company_default = CompanyModel;
|
|
1638
1651
|
|
|
1639
|
-
// src/models/appointment/
|
|
1652
|
+
// src/models/appointment/Asset.js
|
|
1640
1653
|
var import_mobx_state_tree15 = require("mobx-state-tree");
|
|
1654
|
+
var AssetModel = import_mobx_state_tree15.types.model("Asset", {
|
|
1655
|
+
url: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1656
|
+
blobPath: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1657
|
+
category: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1658
|
+
contentType: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1659
|
+
size: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.number), null)
|
|
1660
|
+
}).actions((self) => ({
|
|
1661
|
+
/** POST /asset/upload – upload file using model category. */
|
|
1662
|
+
async upload(file, opts = {}) {
|
|
1663
|
+
const category = opts.category ?? self.category;
|
|
1664
|
+
return AssetModel.upload(file, { ...opts, category });
|
|
1665
|
+
}
|
|
1666
|
+
}));
|
|
1667
|
+
function pickValue(d, ...keys) {
|
|
1668
|
+
for (const k of keys) {
|
|
1669
|
+
if ((d == null ? void 0 : d[k]) !== void 0 && (d == null ? void 0 : d[k]) !== null) return d[k];
|
|
1670
|
+
}
|
|
1671
|
+
return null;
|
|
1672
|
+
}
|
|
1673
|
+
function mapFromApi5(d) {
|
|
1674
|
+
if (!d) return d;
|
|
1675
|
+
return {
|
|
1676
|
+
url: pickValue(d, "url", "Url"),
|
|
1677
|
+
blobPath: pickValue(d, "blobPath", "blob_path", "BlobPath"),
|
|
1678
|
+
category: pickValue(d, "category", "Category"),
|
|
1679
|
+
contentType: pickValue(d, "contentType", "content_type", "ContentType"),
|
|
1680
|
+
size: pickValue(d, "size", "Size")
|
|
1681
|
+
};
|
|
1682
|
+
}
|
|
1683
|
+
AssetModel.upload = async (file, opts = {}) => {
|
|
1684
|
+
const cfg = getConfig();
|
|
1685
|
+
if (!(cfg == null ? void 0 : cfg.baseUrl)) throw new Error("Configure baseUrl before AssetModel.upload");
|
|
1686
|
+
if (!file) return { status: "failure", message: "file is required" };
|
|
1687
|
+
const category = opts.category != null ? String(opts.category).trim() : "";
|
|
1688
|
+
if (!category) return { status: "failure", message: "category is required" };
|
|
1689
|
+
const fetchFn = cfg.fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
|
|
1690
|
+
throw new Error("fetch not available");
|
|
1691
|
+
});
|
|
1692
|
+
const baseUrl = String(cfg.baseUrl).replace(/\/+$/, "");
|
|
1693
|
+
const url = `${baseUrl}/asset/upload`;
|
|
1694
|
+
const formData = new FormData();
|
|
1695
|
+
formData.append("file", file);
|
|
1696
|
+
formData.append("category", category);
|
|
1697
|
+
if (opts.companyKey != null && String(opts.companyKey).trim() !== "") {
|
|
1698
|
+
formData.append("company_key", String(opts.companyKey).trim());
|
|
1699
|
+
}
|
|
1700
|
+
if (opts.calendarId != null && String(opts.calendarId).trim() !== "") {
|
|
1701
|
+
formData.append("calendar_id", String(opts.calendarId).trim());
|
|
1702
|
+
}
|
|
1703
|
+
const headers = {};
|
|
1704
|
+
if (cfg.consumer) headers.Consumer = cfg.consumer;
|
|
1705
|
+
if (opts.consumer != null && String(opts.consumer).trim() !== "") {
|
|
1706
|
+
headers.Consumer = String(opts.consumer).trim();
|
|
1707
|
+
}
|
|
1708
|
+
const res = await fetchFn(url, {
|
|
1709
|
+
method: "POST",
|
|
1710
|
+
headers,
|
|
1711
|
+
body: formData
|
|
1712
|
+
});
|
|
1713
|
+
const text = await res.text();
|
|
1714
|
+
let data;
|
|
1715
|
+
try {
|
|
1716
|
+
data = JSON.parse(text);
|
|
1717
|
+
} catch {
|
|
1718
|
+
data = { status: "failure", message: text || res.statusText };
|
|
1719
|
+
}
|
|
1720
|
+
if (!res.ok && data.status !== "failure") {
|
|
1721
|
+
data.status = "failure";
|
|
1722
|
+
data.message = data.message ?? `HTTP ${res.status}`;
|
|
1723
|
+
}
|
|
1724
|
+
if ((data == null ? void 0 : data.status) === "success" && (data == null ? void 0 : data.data)) {
|
|
1725
|
+
const mapped = mapFromApi5(data.data);
|
|
1726
|
+
data.data = AssetModel.create(mapped, { env: cfg });
|
|
1727
|
+
}
|
|
1728
|
+
return data;
|
|
1729
|
+
};
|
|
1730
|
+
var Asset_default = AssetModel;
|
|
1731
|
+
|
|
1732
|
+
// src/models/appointment/Preference.js
|
|
1733
|
+
var import_mobx_state_tree16 = require("mobx-state-tree");
|
|
1641
1734
|
var PreferenceScope = {
|
|
1642
1735
|
Global: 0,
|
|
1643
1736
|
Consumer: 1,
|
|
@@ -1646,13 +1739,13 @@ var PreferenceScope = {
|
|
|
1646
1739
|
Event: 4
|
|
1647
1740
|
};
|
|
1648
1741
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1649
|
-
var PreferenceModel =
|
|
1650
|
-
id:
|
|
1651
|
-
preferenceId:
|
|
1652
|
-
level:
|
|
1653
|
-
primaryKey:
|
|
1654
|
-
preferenceOption:
|
|
1655
|
-
optionsJson:
|
|
1742
|
+
var PreferenceModel = import_mobx_state_tree16.types.model("Preference", {
|
|
1743
|
+
id: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.number), null),
|
|
1744
|
+
preferenceId: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1745
|
+
level: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.number, 0),
|
|
1746
|
+
primaryKey: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1747
|
+
preferenceOption: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1748
|
+
optionsJson: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null)
|
|
1656
1749
|
}).actions((self) => ({
|
|
1657
1750
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1658
1751
|
async save() {
|
|
@@ -1700,7 +1793,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1700
1793
|
var Preference_default = PreferenceModel;
|
|
1701
1794
|
|
|
1702
1795
|
// src/models/appointment/Flow.js
|
|
1703
|
-
var
|
|
1796
|
+
var import_mobx_state_tree17 = require("mobx-state-tree");
|
|
1704
1797
|
function mapFlowFromApi(d) {
|
|
1705
1798
|
if (!d) return d;
|
|
1706
1799
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1718,26 +1811,26 @@ function mapFlowFromApi(d) {
|
|
|
1718
1811
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1719
1812
|
};
|
|
1720
1813
|
}
|
|
1721
|
-
var FlowModel =
|
|
1722
|
-
id:
|
|
1723
|
-
flowId:
|
|
1724
|
-
companyKey:
|
|
1725
|
-
name:
|
|
1726
|
-
description:
|
|
1727
|
-
flowJson:
|
|
1728
|
-
isActive:
|
|
1729
|
-
isDeleted:
|
|
1730
|
-
createdOn:
|
|
1731
|
-
modifiedOn:
|
|
1814
|
+
var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
1815
|
+
id: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number), null),
|
|
1816
|
+
flowId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.identifier, "new"),
|
|
1817
|
+
companyKey: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1818
|
+
name: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1819
|
+
description: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1820
|
+
flowJson: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
1821
|
+
isActive: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.boolean, true),
|
|
1822
|
+
isDeleted: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.boolean, false),
|
|
1823
|
+
createdOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1824
|
+
modifiedOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null)
|
|
1732
1825
|
}).actions((self) => {
|
|
1733
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1826
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree17.getEnv);
|
|
1734
1827
|
return {
|
|
1735
1828
|
/** GET flow/get – fetch this flow by flowId */
|
|
1736
1829
|
async get() {
|
|
1737
1830
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1738
1831
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1739
1832
|
if (res.status === "success" && res.data) {
|
|
1740
|
-
(0,
|
|
1833
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1741
1834
|
}
|
|
1742
1835
|
return res;
|
|
1743
1836
|
},
|
|
@@ -1752,7 +1845,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1752
1845
|
};
|
|
1753
1846
|
const res = await reqPost("/flow/create", payload);
|
|
1754
1847
|
if (res.status === "success" && res.data) {
|
|
1755
|
-
(0,
|
|
1848
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1756
1849
|
}
|
|
1757
1850
|
return res;
|
|
1758
1851
|
},
|
|
@@ -1768,7 +1861,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1768
1861
|
};
|
|
1769
1862
|
const res = await reqPost("/flow/update", payload);
|
|
1770
1863
|
if (res.status === "success" && res.data) {
|
|
1771
|
-
(0,
|
|
1864
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1772
1865
|
}
|
|
1773
1866
|
return res;
|
|
1774
1867
|
},
|
|
@@ -1782,7 +1875,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1782
1875
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1783
1876
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1784
1877
|
if (res.status === "success" && res.data) {
|
|
1785
|
-
(0,
|
|
1878
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1786
1879
|
}
|
|
1787
1880
|
return res;
|
|
1788
1881
|
},
|
|
@@ -1959,7 +2052,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
1959
2052
|
var Flow_default = FlowModel;
|
|
1960
2053
|
|
|
1961
2054
|
// src/models/appointment/Lead.js
|
|
1962
|
-
var
|
|
2055
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
1963
2056
|
function mapLeadFromApi(d) {
|
|
1964
2057
|
if (!d) return d;
|
|
1965
2058
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1988,27 +2081,27 @@ function mapLeadFromApi(d) {
|
|
|
1988
2081
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1989
2082
|
};
|
|
1990
2083
|
}
|
|
1991
|
-
var LeadModel =
|
|
1992
|
-
id:
|
|
1993
|
-
leadId:
|
|
1994
|
-
email:
|
|
1995
|
-
name:
|
|
1996
|
-
phone:
|
|
1997
|
-
companyKey:
|
|
1998
|
-
source:
|
|
1999
|
-
leadType:
|
|
2000
|
-
referrerLink:
|
|
2001
|
-
createdOn:
|
|
2002
|
-
modifiedOn:
|
|
2084
|
+
var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
2085
|
+
id: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.number), null),
|
|
2086
|
+
leadId: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.identifier, "new"),
|
|
2087
|
+
email: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2088
|
+
name: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2089
|
+
phone: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2090
|
+
companyKey: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2091
|
+
source: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2092
|
+
leadType: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.number, 2),
|
|
2093
|
+
referrerLink: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2094
|
+
createdOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
2095
|
+
modifiedOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null)
|
|
2003
2096
|
}).actions((self) => {
|
|
2004
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2097
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree18.getEnv);
|
|
2005
2098
|
return {
|
|
2006
2099
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2007
2100
|
async get() {
|
|
2008
2101
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2009
2102
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2010
2103
|
if (res.status === "success" && res.data) {
|
|
2011
|
-
(0,
|
|
2104
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2012
2105
|
}
|
|
2013
2106
|
return res;
|
|
2014
2107
|
},
|
|
@@ -2019,7 +2112,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2019
2112
|
}
|
|
2020
2113
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2021
2114
|
if (lead) {
|
|
2022
|
-
(0,
|
|
2115
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, (0, import_mobx_state_tree18.getSnapshot)(lead));
|
|
2023
2116
|
}
|
|
2024
2117
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2025
2118
|
},
|
|
@@ -2041,7 +2134,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2041
2134
|
};
|
|
2042
2135
|
const res = await reqPost("/lead/create", payload);
|
|
2043
2136
|
if (res.status === "success" && res.data) {
|
|
2044
|
-
(0,
|
|
2137
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2045
2138
|
}
|
|
2046
2139
|
return res;
|
|
2047
2140
|
},
|
|
@@ -2062,7 +2155,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2062
2155
|
};
|
|
2063
2156
|
const res = await reqPost("/lead/update", payload);
|
|
2064
2157
|
if (res.status === "success" && res.data) {
|
|
2065
|
-
(0,
|
|
2158
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2066
2159
|
}
|
|
2067
2160
|
return res;
|
|
2068
2161
|
},
|
|
@@ -2187,11 +2280,180 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2187
2280
|
};
|
|
2188
2281
|
var Lead_default = LeadModel;
|
|
2189
2282
|
|
|
2283
|
+
// src/models/appointment/CustomField.js
|
|
2284
|
+
var import_mobx_state_tree19 = require("mobx-state-tree");
|
|
2285
|
+
var CustomFieldModel = import_mobx_state_tree19.types.model("CustomField", {
|
|
2286
|
+
id: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.number), null),
|
|
2287
|
+
customFieldId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2288
|
+
calendarId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2289
|
+
label: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2290
|
+
type: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2291
|
+
isRequired: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, false),
|
|
2292
|
+
createdOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2293
|
+
modifiedOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2294
|
+
isDeleted: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, false)
|
|
2295
|
+
}).actions((self) => {
|
|
2296
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree19.getEnv);
|
|
2297
|
+
return {
|
|
2298
|
+
/** GET /CustomField/GetAll?calendar_id= */
|
|
2299
|
+
async getAll(calendarId) {
|
|
2300
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2301
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2302
|
+
return reqGet("/CustomField/GetAll", { calendar_id: resolvedCalendarId });
|
|
2303
|
+
},
|
|
2304
|
+
/** GET /CustomField/FieldType/Get?FieldType= */
|
|
2305
|
+
async getFieldType(fieldType) {
|
|
2306
|
+
return reqGet("/CustomField/FieldType/Get", { FieldType: fieldType });
|
|
2307
|
+
},
|
|
2308
|
+
/** GET /CustomField/FieldTypes/Get */
|
|
2309
|
+
async getFieldTypes() {
|
|
2310
|
+
return reqGet("/CustomField/FieldTypes/Get");
|
|
2311
|
+
},
|
|
2312
|
+
/** POST /CustomField/Add */
|
|
2313
|
+
async add(payload) {
|
|
2314
|
+
const body = payload ?? toPayload4(self);
|
|
2315
|
+
const res = await reqPost("/CustomField/Add", body);
|
|
2316
|
+
if (res.status === "success" && res.data) {
|
|
2317
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
2318
|
+
}
|
|
2319
|
+
return res;
|
|
2320
|
+
},
|
|
2321
|
+
/** GET /CustomField/RemoveField?customfield_id= */
|
|
2322
|
+
async removeField(customFieldId) {
|
|
2323
|
+
const resolvedCustomFieldId = customFieldId || self.customFieldId;
|
|
2324
|
+
if (!resolvedCustomFieldId) return { status: "failure", message: "customFieldId required" };
|
|
2325
|
+
return reqGet("/CustomField/RemoveField", { customfield_id: resolvedCustomFieldId });
|
|
2326
|
+
},
|
|
2327
|
+
/** GET /CustomField/RemoveAllFields?calendar_id= */
|
|
2328
|
+
async removeAllFields(calendarId) {
|
|
2329
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2330
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2331
|
+
return reqGet("/CustomField/RemoveAllFields", { calendar_id: resolvedCalendarId });
|
|
2332
|
+
},
|
|
2333
|
+
/** GET /CustomField/Form/Get?calendar_id=&data_id= */
|
|
2334
|
+
async getForm(calendarId, dataId) {
|
|
2335
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2336
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2337
|
+
const query = { calendar_id: resolvedCalendarId };
|
|
2338
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2339
|
+
return reqGet("/CustomField/Form/Get", query);
|
|
2340
|
+
},
|
|
2341
|
+
/** POST /CustomField/Form/Save?calendar_id= */
|
|
2342
|
+
async saveForm(fields, calendarId) {
|
|
2343
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2344
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2345
|
+
return reqPost("/CustomField/Form/Save", fields ?? [], { calendar_id: resolvedCalendarId });
|
|
2346
|
+
},
|
|
2347
|
+
/** GET /CustomField/Form/Data/Get?calendar_id=&data_id= */
|
|
2348
|
+
async getFormData(calendarId, dataId) {
|
|
2349
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2350
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2351
|
+
const query = { calendar_id: resolvedCalendarId };
|
|
2352
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2353
|
+
return reqGet("/CustomField/Form/Data/Get", query);
|
|
2354
|
+
},
|
|
2355
|
+
/** POST /CustomField/Form/Data/Save?data_id= */
|
|
2356
|
+
async saveFormData(fields, dataId) {
|
|
2357
|
+
if (!dataId) return { status: "failure", message: "dataId required" };
|
|
2358
|
+
return reqPost("/CustomField/Form/Data/Save", fields ?? [], { data_id: dataId });
|
|
2359
|
+
},
|
|
2360
|
+
/** POST /CustomField/Form/Field/Data/Save */
|
|
2361
|
+
async saveFormFieldData(fieldPayload) {
|
|
2362
|
+
return reqPost("/CustomField/Form/Field/Data/Save", fieldPayload ?? {});
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
});
|
|
2366
|
+
function mapCustomFieldFromApi(d) {
|
|
2367
|
+
if (!d) return d;
|
|
2368
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
2369
|
+
return {
|
|
2370
|
+
id: pick("id", "Id") ?? null,
|
|
2371
|
+
customFieldId: pick("customFieldId", "CustomFieldId", "custom_field_id") ?? null,
|
|
2372
|
+
calendarId: pick("calendarId", "CalendarId", "calendar_id") ?? null,
|
|
2373
|
+
label: pick("label", "Label") ?? null,
|
|
2374
|
+
type: pick("type", "Type") ?? "",
|
|
2375
|
+
isRequired: Boolean(pick("isRequired", "IsRequired", "is_required")),
|
|
2376
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
2377
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null,
|
|
2378
|
+
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2379
|
+
};
|
|
2380
|
+
}
|
|
2381
|
+
function toPayload4(self) {
|
|
2382
|
+
return {
|
|
2383
|
+
customFieldId: self.customFieldId || void 0,
|
|
2384
|
+
calendarId: self.calendarId || void 0,
|
|
2385
|
+
label: self.label ?? void 0,
|
|
2386
|
+
type: self.type || void 0,
|
|
2387
|
+
isRequired: Boolean(self.isRequired)
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
CustomFieldModel.getAll = async (calendarId) => {
|
|
2391
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2392
|
+
const res = await reqGet("/CustomField/GetAll", { calendar_id: calendarId });
|
|
2393
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
2394
|
+
return res.data.map((f) => CustomFieldModel.create(mapCustomFieldFromApi(f), { env: getConfig() }));
|
|
2395
|
+
}
|
|
2396
|
+
return null;
|
|
2397
|
+
};
|
|
2398
|
+
CustomFieldModel.getFieldType = async (fieldType) => {
|
|
2399
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2400
|
+
const res = await reqGet("/CustomField/FieldType/Get", { FieldType: fieldType });
|
|
2401
|
+
return res.status === "success" ? res.data : null;
|
|
2402
|
+
};
|
|
2403
|
+
CustomFieldModel.getFieldTypes = async () => {
|
|
2404
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2405
|
+
const res = await reqGet("/CustomField/FieldTypes/Get");
|
|
2406
|
+
return res.status === "success" ? res.data : null;
|
|
2407
|
+
};
|
|
2408
|
+
CustomFieldModel.add = async (payload) => {
|
|
2409
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2410
|
+
const res = await reqPost("/CustomField/Add", payload);
|
|
2411
|
+
if (res.status === "success" && res.data) {
|
|
2412
|
+
return CustomFieldModel.create(mapCustomFieldFromApi(res.data), { env: getConfig() });
|
|
2413
|
+
}
|
|
2414
|
+
return null;
|
|
2415
|
+
};
|
|
2416
|
+
CustomFieldModel.removeField = async (customFieldId) => {
|
|
2417
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2418
|
+
return reqGet("/CustomField/RemoveField", { customfield_id: customFieldId });
|
|
2419
|
+
};
|
|
2420
|
+
CustomFieldModel.removeAllFields = async (calendarId) => {
|
|
2421
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2422
|
+
return reqGet("/CustomField/RemoveAllFields", { calendar_id: calendarId });
|
|
2423
|
+
};
|
|
2424
|
+
CustomFieldModel.getForm = async (calendarId, dataId) => {
|
|
2425
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2426
|
+
const query = { calendar_id: calendarId };
|
|
2427
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2428
|
+
const res = await reqGet("/CustomField/Form/Get", query);
|
|
2429
|
+
return res.status === "success" ? res.data : null;
|
|
2430
|
+
};
|
|
2431
|
+
CustomFieldModel.saveForm = async (calendarId, fields) => {
|
|
2432
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2433
|
+
return reqPost("/CustomField/Form/Save", fields ?? [], { calendar_id: calendarId });
|
|
2434
|
+
};
|
|
2435
|
+
CustomFieldModel.getFormData = async (calendarId, dataId) => {
|
|
2436
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2437
|
+
const query = { calendar_id: calendarId };
|
|
2438
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2439
|
+
const res = await reqGet("/CustomField/Form/Data/Get", query);
|
|
2440
|
+
return res.status === "success" ? res.data : null;
|
|
2441
|
+
};
|
|
2442
|
+
CustomFieldModel.saveFormData = async (dataId, fields) => {
|
|
2443
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2444
|
+
return reqPost("/CustomField/Form/Data/Save", fields ?? [], { data_id: dataId });
|
|
2445
|
+
};
|
|
2446
|
+
CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
2447
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2448
|
+
return reqPost("/CustomField/Form/Field/Data/Save", fieldPayload ?? {});
|
|
2449
|
+
};
|
|
2450
|
+
var CustomField_default = CustomFieldModel;
|
|
2451
|
+
|
|
2190
2452
|
// src/models/appointment/index.js
|
|
2191
|
-
var
|
|
2192
|
-
var RootStore =
|
|
2193
|
-
calendars:
|
|
2194
|
-
events:
|
|
2453
|
+
var import_mobx_state_tree20 = require("mobx-state-tree");
|
|
2454
|
+
var RootStore = import_mobx_state_tree20.types.model("RootStore", {
|
|
2455
|
+
calendars: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.map(Calendar_default), {}),
|
|
2456
|
+
events: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.map(Event_default), {})
|
|
2195
2457
|
}).actions((self) => ({
|
|
2196
2458
|
addCalendar(snapshot) {
|
|
2197
2459
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2211,6 +2473,7 @@ function createRootStore(initialState = {}) {
|
|
|
2211
2473
|
}
|
|
2212
2474
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2213
2475
|
0 && (module.exports = {
|
|
2476
|
+
AssetModel,
|
|
2214
2477
|
AssignmentMethod,
|
|
2215
2478
|
AttendeeStatus,
|
|
2216
2479
|
AvailabilityDetailModel,
|
|
@@ -2220,6 +2483,7 @@ function createRootStore(initialState = {}) {
|
|
|
2220
2483
|
CalendarParticipantModel,
|
|
2221
2484
|
CompanyModel,
|
|
2222
2485
|
ConfigModel,
|
|
2486
|
+
CustomFieldModel,
|
|
2223
2487
|
DayOfWeek,
|
|
2224
2488
|
EventModel,
|
|
2225
2489
|
FlowModel,
|