@blazeo.com/calendar-client 1.0.18 → 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 -200
- package/dist/index.js +302 -49
- package/dist/index.mjs +292 -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");
|
|
@@ -1647,8 +1649,88 @@ CompanyModel.save = async (payload) => {
|
|
|
1647
1649
|
};
|
|
1648
1650
|
var Company_default = CompanyModel;
|
|
1649
1651
|
|
|
1650
|
-
// src/models/appointment/
|
|
1652
|
+
// src/models/appointment/Asset.js
|
|
1651
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");
|
|
1652
1734
|
var PreferenceScope = {
|
|
1653
1735
|
Global: 0,
|
|
1654
1736
|
Consumer: 1,
|
|
@@ -1657,13 +1739,13 @@ var PreferenceScope = {
|
|
|
1657
1739
|
Event: 4
|
|
1658
1740
|
};
|
|
1659
1741
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1660
|
-
var PreferenceModel =
|
|
1661
|
-
id:
|
|
1662
|
-
preferenceId:
|
|
1663
|
-
level:
|
|
1664
|
-
primaryKey:
|
|
1665
|
-
preferenceOption:
|
|
1666
|
-
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)
|
|
1667
1749
|
}).actions((self) => ({
|
|
1668
1750
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1669
1751
|
async save() {
|
|
@@ -1711,7 +1793,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1711
1793
|
var Preference_default = PreferenceModel;
|
|
1712
1794
|
|
|
1713
1795
|
// src/models/appointment/Flow.js
|
|
1714
|
-
var
|
|
1796
|
+
var import_mobx_state_tree17 = require("mobx-state-tree");
|
|
1715
1797
|
function mapFlowFromApi(d) {
|
|
1716
1798
|
if (!d) return d;
|
|
1717
1799
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1729,26 +1811,26 @@ function mapFlowFromApi(d) {
|
|
|
1729
1811
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1730
1812
|
};
|
|
1731
1813
|
}
|
|
1732
|
-
var FlowModel =
|
|
1733
|
-
id:
|
|
1734
|
-
flowId:
|
|
1735
|
-
companyKey:
|
|
1736
|
-
name:
|
|
1737
|
-
description:
|
|
1738
|
-
flowJson:
|
|
1739
|
-
isActive:
|
|
1740
|
-
isDeleted:
|
|
1741
|
-
createdOn:
|
|
1742
|
-
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)
|
|
1743
1825
|
}).actions((self) => {
|
|
1744
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1826
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree17.getEnv);
|
|
1745
1827
|
return {
|
|
1746
1828
|
/** GET flow/get – fetch this flow by flowId */
|
|
1747
1829
|
async get() {
|
|
1748
1830
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1749
1831
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1750
1832
|
if (res.status === "success" && res.data) {
|
|
1751
|
-
(0,
|
|
1833
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1752
1834
|
}
|
|
1753
1835
|
return res;
|
|
1754
1836
|
},
|
|
@@ -1763,7 +1845,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1763
1845
|
};
|
|
1764
1846
|
const res = await reqPost("/flow/create", payload);
|
|
1765
1847
|
if (res.status === "success" && res.data) {
|
|
1766
|
-
(0,
|
|
1848
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1767
1849
|
}
|
|
1768
1850
|
return res;
|
|
1769
1851
|
},
|
|
@@ -1779,7 +1861,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1779
1861
|
};
|
|
1780
1862
|
const res = await reqPost("/flow/update", payload);
|
|
1781
1863
|
if (res.status === "success" && res.data) {
|
|
1782
|
-
(0,
|
|
1864
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1783
1865
|
}
|
|
1784
1866
|
return res;
|
|
1785
1867
|
},
|
|
@@ -1793,7 +1875,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1793
1875
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1794
1876
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1795
1877
|
if (res.status === "success" && res.data) {
|
|
1796
|
-
(0,
|
|
1878
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1797
1879
|
}
|
|
1798
1880
|
return res;
|
|
1799
1881
|
},
|
|
@@ -1970,7 +2052,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
1970
2052
|
var Flow_default = FlowModel;
|
|
1971
2053
|
|
|
1972
2054
|
// src/models/appointment/Lead.js
|
|
1973
|
-
var
|
|
2055
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
1974
2056
|
function mapLeadFromApi(d) {
|
|
1975
2057
|
if (!d) return d;
|
|
1976
2058
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1999,27 +2081,27 @@ function mapLeadFromApi(d) {
|
|
|
1999
2081
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2000
2082
|
};
|
|
2001
2083
|
}
|
|
2002
|
-
var LeadModel =
|
|
2003
|
-
id:
|
|
2004
|
-
leadId:
|
|
2005
|
-
email:
|
|
2006
|
-
name:
|
|
2007
|
-
phone:
|
|
2008
|
-
companyKey:
|
|
2009
|
-
source:
|
|
2010
|
-
leadType:
|
|
2011
|
-
referrerLink:
|
|
2012
|
-
createdOn:
|
|
2013
|
-
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)
|
|
2014
2096
|
}).actions((self) => {
|
|
2015
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2097
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree18.getEnv);
|
|
2016
2098
|
return {
|
|
2017
2099
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2018
2100
|
async get() {
|
|
2019
2101
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2020
2102
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2021
2103
|
if (res.status === "success" && res.data) {
|
|
2022
|
-
(0,
|
|
2104
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2023
2105
|
}
|
|
2024
2106
|
return res;
|
|
2025
2107
|
},
|
|
@@ -2030,7 +2112,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2030
2112
|
}
|
|
2031
2113
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2032
2114
|
if (lead) {
|
|
2033
|
-
(0,
|
|
2115
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, (0, import_mobx_state_tree18.getSnapshot)(lead));
|
|
2034
2116
|
}
|
|
2035
2117
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2036
2118
|
},
|
|
@@ -2052,7 +2134,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2052
2134
|
};
|
|
2053
2135
|
const res = await reqPost("/lead/create", payload);
|
|
2054
2136
|
if (res.status === "success" && res.data) {
|
|
2055
|
-
(0,
|
|
2137
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2056
2138
|
}
|
|
2057
2139
|
return res;
|
|
2058
2140
|
},
|
|
@@ -2073,7 +2155,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2073
2155
|
};
|
|
2074
2156
|
const res = await reqPost("/lead/update", payload);
|
|
2075
2157
|
if (res.status === "success" && res.data) {
|
|
2076
|
-
(0,
|
|
2158
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2077
2159
|
}
|
|
2078
2160
|
return res;
|
|
2079
2161
|
},
|
|
@@ -2198,11 +2280,180 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2198
2280
|
};
|
|
2199
2281
|
var Lead_default = LeadModel;
|
|
2200
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
|
+
|
|
2201
2452
|
// src/models/appointment/index.js
|
|
2202
|
-
var
|
|
2203
|
-
var RootStore =
|
|
2204
|
-
calendars:
|
|
2205
|
-
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), {})
|
|
2206
2457
|
}).actions((self) => ({
|
|
2207
2458
|
addCalendar(snapshot) {
|
|
2208
2459
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2222,6 +2473,7 @@ function createRootStore(initialState = {}) {
|
|
|
2222
2473
|
}
|
|
2223
2474
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2224
2475
|
0 && (module.exports = {
|
|
2476
|
+
AssetModel,
|
|
2225
2477
|
AssignmentMethod,
|
|
2226
2478
|
AttendeeStatus,
|
|
2227
2479
|
AvailabilityDetailModel,
|
|
@@ -2231,6 +2483,7 @@ function createRootStore(initialState = {}) {
|
|
|
2231
2483
|
CalendarParticipantModel,
|
|
2232
2484
|
CompanyModel,
|
|
2233
2485
|
ConfigModel,
|
|
2486
|
+
CustomFieldModel,
|
|
2234
2487
|
DayOfWeek,
|
|
2235
2488
|
EventModel,
|
|
2236
2489
|
FlowModel,
|