@blazeo.com/calendar-client 1.0.18 → 1.0.20
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 +303 -49
- package/dist/index.mjs +293 -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");
|
|
@@ -375,6 +377,7 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
375
377
|
startMinute: self.startMinute,
|
|
376
378
|
endHour: self.endHour,
|
|
377
379
|
endMinute: self.endMinute,
|
|
380
|
+
timeZone: self.timeZone,
|
|
378
381
|
visitorName: self.visitorName ?? void 0,
|
|
379
382
|
visitorEmail: self.visitorEmail ?? void 0,
|
|
380
383
|
visitorPhone: self.visitorPhone ?? void 0
|
|
@@ -1647,8 +1650,88 @@ CompanyModel.save = async (payload) => {
|
|
|
1647
1650
|
};
|
|
1648
1651
|
var Company_default = CompanyModel;
|
|
1649
1652
|
|
|
1650
|
-
// src/models/appointment/
|
|
1653
|
+
// src/models/appointment/Asset.js
|
|
1651
1654
|
var import_mobx_state_tree15 = require("mobx-state-tree");
|
|
1655
|
+
var AssetModel = import_mobx_state_tree15.types.model("Asset", {
|
|
1656
|
+
url: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1657
|
+
blobPath: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1658
|
+
category: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1659
|
+
contentType: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1660
|
+
size: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.number), null)
|
|
1661
|
+
}).actions((self) => ({
|
|
1662
|
+
/** POST /asset/upload – upload file using model category. */
|
|
1663
|
+
async upload(file, opts = {}) {
|
|
1664
|
+
const category = opts.category ?? self.category;
|
|
1665
|
+
return AssetModel.upload(file, { ...opts, category });
|
|
1666
|
+
}
|
|
1667
|
+
}));
|
|
1668
|
+
function pickValue(d, ...keys) {
|
|
1669
|
+
for (const k of keys) {
|
|
1670
|
+
if ((d == null ? void 0 : d[k]) !== void 0 && (d == null ? void 0 : d[k]) !== null) return d[k];
|
|
1671
|
+
}
|
|
1672
|
+
return null;
|
|
1673
|
+
}
|
|
1674
|
+
function mapFromApi5(d) {
|
|
1675
|
+
if (!d) return d;
|
|
1676
|
+
return {
|
|
1677
|
+
url: pickValue(d, "url", "Url"),
|
|
1678
|
+
blobPath: pickValue(d, "blobPath", "blob_path", "BlobPath"),
|
|
1679
|
+
category: pickValue(d, "category", "Category"),
|
|
1680
|
+
contentType: pickValue(d, "contentType", "content_type", "ContentType"),
|
|
1681
|
+
size: pickValue(d, "size", "Size")
|
|
1682
|
+
};
|
|
1683
|
+
}
|
|
1684
|
+
AssetModel.upload = async (file, opts = {}) => {
|
|
1685
|
+
const cfg = getConfig();
|
|
1686
|
+
if (!(cfg == null ? void 0 : cfg.baseUrl)) throw new Error("Configure baseUrl before AssetModel.upload");
|
|
1687
|
+
if (!file) return { status: "failure", message: "file is required" };
|
|
1688
|
+
const category = opts.category != null ? String(opts.category).trim() : "";
|
|
1689
|
+
if (!category) return { status: "failure", message: "category is required" };
|
|
1690
|
+
const fetchFn = cfg.fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
|
|
1691
|
+
throw new Error("fetch not available");
|
|
1692
|
+
});
|
|
1693
|
+
const baseUrl = String(cfg.baseUrl).replace(/\/+$/, "");
|
|
1694
|
+
const url = `${baseUrl}/asset/upload`;
|
|
1695
|
+
const formData = new FormData();
|
|
1696
|
+
formData.append("file", file);
|
|
1697
|
+
formData.append("category", category);
|
|
1698
|
+
if (opts.companyKey != null && String(opts.companyKey).trim() !== "") {
|
|
1699
|
+
formData.append("company_key", String(opts.companyKey).trim());
|
|
1700
|
+
}
|
|
1701
|
+
if (opts.calendarId != null && String(opts.calendarId).trim() !== "") {
|
|
1702
|
+
formData.append("calendar_id", String(opts.calendarId).trim());
|
|
1703
|
+
}
|
|
1704
|
+
const headers = {};
|
|
1705
|
+
if (cfg.consumer) headers.Consumer = cfg.consumer;
|
|
1706
|
+
if (opts.consumer != null && String(opts.consumer).trim() !== "") {
|
|
1707
|
+
headers.Consumer = String(opts.consumer).trim();
|
|
1708
|
+
}
|
|
1709
|
+
const res = await fetchFn(url, {
|
|
1710
|
+
method: "POST",
|
|
1711
|
+
headers,
|
|
1712
|
+
body: formData
|
|
1713
|
+
});
|
|
1714
|
+
const text = await res.text();
|
|
1715
|
+
let data;
|
|
1716
|
+
try {
|
|
1717
|
+
data = JSON.parse(text);
|
|
1718
|
+
} catch {
|
|
1719
|
+
data = { status: "failure", message: text || res.statusText };
|
|
1720
|
+
}
|
|
1721
|
+
if (!res.ok && data.status !== "failure") {
|
|
1722
|
+
data.status = "failure";
|
|
1723
|
+
data.message = data.message ?? `HTTP ${res.status}`;
|
|
1724
|
+
}
|
|
1725
|
+
if ((data == null ? void 0 : data.status) === "success" && (data == null ? void 0 : data.data)) {
|
|
1726
|
+
const mapped = mapFromApi5(data.data);
|
|
1727
|
+
data.data = AssetModel.create(mapped, { env: cfg });
|
|
1728
|
+
}
|
|
1729
|
+
return data;
|
|
1730
|
+
};
|
|
1731
|
+
var Asset_default = AssetModel;
|
|
1732
|
+
|
|
1733
|
+
// src/models/appointment/Preference.js
|
|
1734
|
+
var import_mobx_state_tree16 = require("mobx-state-tree");
|
|
1652
1735
|
var PreferenceScope = {
|
|
1653
1736
|
Global: 0,
|
|
1654
1737
|
Consumer: 1,
|
|
@@ -1657,13 +1740,13 @@ var PreferenceScope = {
|
|
|
1657
1740
|
Event: 4
|
|
1658
1741
|
};
|
|
1659
1742
|
var SCOPE_NAMES = ["Global", "Consumer", "Company", "Calendar", "Event"];
|
|
1660
|
-
var PreferenceModel =
|
|
1661
|
-
id:
|
|
1662
|
-
preferenceId:
|
|
1663
|
-
level:
|
|
1664
|
-
primaryKey:
|
|
1665
|
-
preferenceOption:
|
|
1666
|
-
optionsJson:
|
|
1743
|
+
var PreferenceModel = import_mobx_state_tree16.types.model("Preference", {
|
|
1744
|
+
id: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.number), null),
|
|
1745
|
+
preferenceId: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null),
|
|
1746
|
+
level: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.number, 0),
|
|
1747
|
+
primaryKey: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1748
|
+
preferenceOption: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
|
|
1749
|
+
optionsJson: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string), null)
|
|
1667
1750
|
}).actions((self) => ({
|
|
1668
1751
|
/** POST /preference/{scope}/{key}/{option} – save this preference to the API. */
|
|
1669
1752
|
async save() {
|
|
@@ -1711,7 +1794,7 @@ PreferenceModel.delete = async (preferenceId) => {
|
|
|
1711
1794
|
var Preference_default = PreferenceModel;
|
|
1712
1795
|
|
|
1713
1796
|
// src/models/appointment/Flow.js
|
|
1714
|
-
var
|
|
1797
|
+
var import_mobx_state_tree17 = require("mobx-state-tree");
|
|
1715
1798
|
function mapFlowFromApi(d) {
|
|
1716
1799
|
if (!d) return d;
|
|
1717
1800
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1729,26 +1812,26 @@ function mapFlowFromApi(d) {
|
|
|
1729
1812
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1730
1813
|
};
|
|
1731
1814
|
}
|
|
1732
|
-
var FlowModel =
|
|
1733
|
-
id:
|
|
1734
|
-
flowId:
|
|
1735
|
-
companyKey:
|
|
1736
|
-
name:
|
|
1737
|
-
description:
|
|
1738
|
-
flowJson:
|
|
1739
|
-
isActive:
|
|
1740
|
-
isDeleted:
|
|
1741
|
-
createdOn:
|
|
1742
|
-
modifiedOn:
|
|
1815
|
+
var FlowModel = import_mobx_state_tree17.types.model("Flow", {
|
|
1816
|
+
id: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number), null),
|
|
1817
|
+
flowId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.identifier, "new"),
|
|
1818
|
+
companyKey: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1819
|
+
name: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1820
|
+
description: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1821
|
+
flowJson: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
|
|
1822
|
+
isActive: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.boolean, true),
|
|
1823
|
+
isDeleted: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.boolean, false),
|
|
1824
|
+
createdOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null),
|
|
1825
|
+
modifiedOn: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string), null)
|
|
1743
1826
|
}).actions((self) => {
|
|
1744
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1827
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree17.getEnv);
|
|
1745
1828
|
return {
|
|
1746
1829
|
/** GET flow/get – fetch this flow by flowId */
|
|
1747
1830
|
async get() {
|
|
1748
1831
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1749
1832
|
const res = await reqGet("/flow/get", { flow_id: self.flowId });
|
|
1750
1833
|
if (res.status === "success" && res.data) {
|
|
1751
|
-
(0,
|
|
1834
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1752
1835
|
}
|
|
1753
1836
|
return res;
|
|
1754
1837
|
},
|
|
@@ -1763,7 +1846,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1763
1846
|
};
|
|
1764
1847
|
const res = await reqPost("/flow/create", payload);
|
|
1765
1848
|
if (res.status === "success" && res.data) {
|
|
1766
|
-
(0,
|
|
1849
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1767
1850
|
}
|
|
1768
1851
|
return res;
|
|
1769
1852
|
},
|
|
@@ -1779,7 +1862,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1779
1862
|
};
|
|
1780
1863
|
const res = await reqPost("/flow/update", payload);
|
|
1781
1864
|
if (res.status === "success" && res.data) {
|
|
1782
|
-
(0,
|
|
1865
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1783
1866
|
}
|
|
1784
1867
|
return res;
|
|
1785
1868
|
},
|
|
@@ -1793,7 +1876,7 @@ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
|
|
|
1793
1876
|
if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
|
|
1794
1877
|
const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
|
|
1795
1878
|
if (res.status === "success" && res.data) {
|
|
1796
|
-
(0,
|
|
1879
|
+
(0, import_mobx_state_tree17.applySnapshot)(self, mapFlowFromApi(res.data));
|
|
1797
1880
|
}
|
|
1798
1881
|
return res;
|
|
1799
1882
|
},
|
|
@@ -1970,7 +2053,7 @@ FlowModel.getPreview = async (flowId) => {
|
|
|
1970
2053
|
var Flow_default = FlowModel;
|
|
1971
2054
|
|
|
1972
2055
|
// src/models/appointment/Lead.js
|
|
1973
|
-
var
|
|
2056
|
+
var import_mobx_state_tree18 = require("mobx-state-tree");
|
|
1974
2057
|
function mapLeadFromApi(d) {
|
|
1975
2058
|
if (!d) return d;
|
|
1976
2059
|
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -1999,27 +2082,27 @@ function mapLeadFromApi(d) {
|
|
|
1999
2082
|
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
2000
2083
|
};
|
|
2001
2084
|
}
|
|
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:
|
|
2085
|
+
var LeadModel = import_mobx_state_tree18.types.model("Lead", {
|
|
2086
|
+
id: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.number), null),
|
|
2087
|
+
leadId: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.identifier, "new"),
|
|
2088
|
+
email: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2089
|
+
name: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2090
|
+
phone: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2091
|
+
companyKey: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2092
|
+
source: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2093
|
+
leadType: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.number, 2),
|
|
2094
|
+
referrerLink: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.string, ""),
|
|
2095
|
+
createdOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null),
|
|
2096
|
+
modifiedOn: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.maybeNull(import_mobx_state_tree18.types.string), null)
|
|
2014
2097
|
}).actions((self) => {
|
|
2015
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
2098
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree18.getEnv);
|
|
2016
2099
|
return {
|
|
2017
2100
|
/** GET /lead/get – fetch this lead by leadId */
|
|
2018
2101
|
async get() {
|
|
2019
2102
|
if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
|
|
2020
2103
|
const res = await reqGet("/lead/get", { lead_id: self.leadId });
|
|
2021
2104
|
if (res.status === "success" && res.data) {
|
|
2022
|
-
(0,
|
|
2105
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2023
2106
|
}
|
|
2024
2107
|
return res;
|
|
2025
2108
|
},
|
|
@@ -2030,7 +2113,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2030
2113
|
}
|
|
2031
2114
|
const lead = await LeadModel.getByEmail(self.email, self.companyKey);
|
|
2032
2115
|
if (lead) {
|
|
2033
|
-
(0,
|
|
2116
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, (0, import_mobx_state_tree18.getSnapshot)(lead));
|
|
2034
2117
|
}
|
|
2035
2118
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2036
2119
|
},
|
|
@@ -2052,7 +2135,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2052
2135
|
};
|
|
2053
2136
|
const res = await reqPost("/lead/create", payload);
|
|
2054
2137
|
if (res.status === "success" && res.data) {
|
|
2055
|
-
(0,
|
|
2138
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2056
2139
|
}
|
|
2057
2140
|
return res;
|
|
2058
2141
|
},
|
|
@@ -2073,7 +2156,7 @@ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
|
|
|
2073
2156
|
};
|
|
2074
2157
|
const res = await reqPost("/lead/update", payload);
|
|
2075
2158
|
if (res.status === "success" && res.data) {
|
|
2076
|
-
(0,
|
|
2159
|
+
(0, import_mobx_state_tree18.applySnapshot)(self, mapLeadFromApi(res.data));
|
|
2077
2160
|
}
|
|
2078
2161
|
return res;
|
|
2079
2162
|
},
|
|
@@ -2198,11 +2281,180 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2198
2281
|
};
|
|
2199
2282
|
var Lead_default = LeadModel;
|
|
2200
2283
|
|
|
2284
|
+
// src/models/appointment/CustomField.js
|
|
2285
|
+
var import_mobx_state_tree19 = require("mobx-state-tree");
|
|
2286
|
+
var CustomFieldModel = import_mobx_state_tree19.types.model("CustomField", {
|
|
2287
|
+
id: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.number), null),
|
|
2288
|
+
customFieldId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2289
|
+
calendarId: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2290
|
+
label: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2291
|
+
type: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.string, ""),
|
|
2292
|
+
isRequired: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, false),
|
|
2293
|
+
createdOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2294
|
+
modifiedOn: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.maybeNull(import_mobx_state_tree19.types.string), null),
|
|
2295
|
+
isDeleted: import_mobx_state_tree19.types.optional(import_mobx_state_tree19.types.boolean, false)
|
|
2296
|
+
}).actions((self) => {
|
|
2297
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree19.getEnv);
|
|
2298
|
+
return {
|
|
2299
|
+
/** GET /CustomField/GetAll?calendar_id= */
|
|
2300
|
+
async getAll(calendarId) {
|
|
2301
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2302
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2303
|
+
return reqGet("/CustomField/GetAll", { calendar_id: resolvedCalendarId });
|
|
2304
|
+
},
|
|
2305
|
+
/** GET /CustomField/FieldType/Get?FieldType= */
|
|
2306
|
+
async getFieldType(fieldType) {
|
|
2307
|
+
return reqGet("/CustomField/FieldType/Get", { FieldType: fieldType });
|
|
2308
|
+
},
|
|
2309
|
+
/** GET /CustomField/FieldTypes/Get */
|
|
2310
|
+
async getFieldTypes() {
|
|
2311
|
+
return reqGet("/CustomField/FieldTypes/Get");
|
|
2312
|
+
},
|
|
2313
|
+
/** POST /CustomField/Add */
|
|
2314
|
+
async add(payload) {
|
|
2315
|
+
const body = payload ?? toPayload4(self);
|
|
2316
|
+
const res = await reqPost("/CustomField/Add", body);
|
|
2317
|
+
if (res.status === "success" && res.data) {
|
|
2318
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
2319
|
+
}
|
|
2320
|
+
return res;
|
|
2321
|
+
},
|
|
2322
|
+
/** GET /CustomField/RemoveField?customfield_id= */
|
|
2323
|
+
async removeField(customFieldId) {
|
|
2324
|
+
const resolvedCustomFieldId = customFieldId || self.customFieldId;
|
|
2325
|
+
if (!resolvedCustomFieldId) return { status: "failure", message: "customFieldId required" };
|
|
2326
|
+
return reqGet("/CustomField/RemoveField", { customfield_id: resolvedCustomFieldId });
|
|
2327
|
+
},
|
|
2328
|
+
/** GET /CustomField/RemoveAllFields?calendar_id= */
|
|
2329
|
+
async removeAllFields(calendarId) {
|
|
2330
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2331
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2332
|
+
return reqGet("/CustomField/RemoveAllFields", { calendar_id: resolvedCalendarId });
|
|
2333
|
+
},
|
|
2334
|
+
/** GET /CustomField/Form/Get?calendar_id=&data_id= */
|
|
2335
|
+
async getForm(calendarId, dataId) {
|
|
2336
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2337
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2338
|
+
const query = { calendar_id: resolvedCalendarId };
|
|
2339
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2340
|
+
return reqGet("/CustomField/Form/Get", query);
|
|
2341
|
+
},
|
|
2342
|
+
/** POST /CustomField/Form/Save?calendar_id= */
|
|
2343
|
+
async saveForm(fields, calendarId) {
|
|
2344
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2345
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2346
|
+
return reqPost("/CustomField/Form/Save", fields ?? [], { calendar_id: resolvedCalendarId });
|
|
2347
|
+
},
|
|
2348
|
+
/** GET /CustomField/Form/Data/Get?calendar_id=&data_id= */
|
|
2349
|
+
async getFormData(calendarId, dataId) {
|
|
2350
|
+
const resolvedCalendarId = calendarId || self.calendarId;
|
|
2351
|
+
if (!resolvedCalendarId) return { status: "failure", message: "calendarId required" };
|
|
2352
|
+
const query = { calendar_id: resolvedCalendarId };
|
|
2353
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2354
|
+
return reqGet("/CustomField/Form/Data/Get", query);
|
|
2355
|
+
},
|
|
2356
|
+
/** POST /CustomField/Form/Data/Save?data_id= */
|
|
2357
|
+
async saveFormData(fields, dataId) {
|
|
2358
|
+
if (!dataId) return { status: "failure", message: "dataId required" };
|
|
2359
|
+
return reqPost("/CustomField/Form/Data/Save", fields ?? [], { data_id: dataId });
|
|
2360
|
+
},
|
|
2361
|
+
/** POST /CustomField/Form/Field/Data/Save */
|
|
2362
|
+
async saveFormFieldData(fieldPayload) {
|
|
2363
|
+
return reqPost("/CustomField/Form/Field/Data/Save", fieldPayload ?? {});
|
|
2364
|
+
}
|
|
2365
|
+
};
|
|
2366
|
+
});
|
|
2367
|
+
function mapCustomFieldFromApi(d) {
|
|
2368
|
+
if (!d) return d;
|
|
2369
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
2370
|
+
return {
|
|
2371
|
+
id: pick("id", "Id") ?? null,
|
|
2372
|
+
customFieldId: pick("customFieldId", "CustomFieldId", "custom_field_id") ?? null,
|
|
2373
|
+
calendarId: pick("calendarId", "CalendarId", "calendar_id") ?? null,
|
|
2374
|
+
label: pick("label", "Label") ?? null,
|
|
2375
|
+
type: pick("type", "Type") ?? "",
|
|
2376
|
+
isRequired: Boolean(pick("isRequired", "IsRequired", "is_required")),
|
|
2377
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
2378
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null,
|
|
2379
|
+
isDeleted: Boolean(pick("isDeleted", "IsDeleted", "is_deleted"))
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
function toPayload4(self) {
|
|
2383
|
+
return {
|
|
2384
|
+
customFieldId: self.customFieldId || void 0,
|
|
2385
|
+
calendarId: self.calendarId || void 0,
|
|
2386
|
+
label: self.label ?? void 0,
|
|
2387
|
+
type: self.type || void 0,
|
|
2388
|
+
isRequired: Boolean(self.isRequired)
|
|
2389
|
+
};
|
|
2390
|
+
}
|
|
2391
|
+
CustomFieldModel.getAll = async (calendarId) => {
|
|
2392
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2393
|
+
const res = await reqGet("/CustomField/GetAll", { calendar_id: calendarId });
|
|
2394
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
2395
|
+
return res.data.map((f) => CustomFieldModel.create(mapCustomFieldFromApi(f), { env: getConfig() }));
|
|
2396
|
+
}
|
|
2397
|
+
return null;
|
|
2398
|
+
};
|
|
2399
|
+
CustomFieldModel.getFieldType = async (fieldType) => {
|
|
2400
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2401
|
+
const res = await reqGet("/CustomField/FieldType/Get", { FieldType: fieldType });
|
|
2402
|
+
return res.status === "success" ? res.data : null;
|
|
2403
|
+
};
|
|
2404
|
+
CustomFieldModel.getFieldTypes = async () => {
|
|
2405
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2406
|
+
const res = await reqGet("/CustomField/FieldTypes/Get");
|
|
2407
|
+
return res.status === "success" ? res.data : null;
|
|
2408
|
+
};
|
|
2409
|
+
CustomFieldModel.add = async (payload) => {
|
|
2410
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2411
|
+
const res = await reqPost("/CustomField/Add", payload);
|
|
2412
|
+
if (res.status === "success" && res.data) {
|
|
2413
|
+
return CustomFieldModel.create(mapCustomFieldFromApi(res.data), { env: getConfig() });
|
|
2414
|
+
}
|
|
2415
|
+
return null;
|
|
2416
|
+
};
|
|
2417
|
+
CustomFieldModel.removeField = async (customFieldId) => {
|
|
2418
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2419
|
+
return reqGet("/CustomField/RemoveField", { customfield_id: customFieldId });
|
|
2420
|
+
};
|
|
2421
|
+
CustomFieldModel.removeAllFields = async (calendarId) => {
|
|
2422
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2423
|
+
return reqGet("/CustomField/RemoveAllFields", { calendar_id: calendarId });
|
|
2424
|
+
};
|
|
2425
|
+
CustomFieldModel.getForm = async (calendarId, dataId) => {
|
|
2426
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2427
|
+
const query = { calendar_id: calendarId };
|
|
2428
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2429
|
+
const res = await reqGet("/CustomField/Form/Get", query);
|
|
2430
|
+
return res.status === "success" ? res.data : null;
|
|
2431
|
+
};
|
|
2432
|
+
CustomFieldModel.saveForm = async (calendarId, fields) => {
|
|
2433
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2434
|
+
return reqPost("/CustomField/Form/Save", fields ?? [], { calendar_id: calendarId });
|
|
2435
|
+
};
|
|
2436
|
+
CustomFieldModel.getFormData = async (calendarId, dataId) => {
|
|
2437
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2438
|
+
const query = { calendar_id: calendarId };
|
|
2439
|
+
if (dataId != null && dataId !== "") query.data_id = dataId;
|
|
2440
|
+
const res = await reqGet("/CustomField/Form/Data/Get", query);
|
|
2441
|
+
return res.status === "success" ? res.data : null;
|
|
2442
|
+
};
|
|
2443
|
+
CustomFieldModel.saveFormData = async (dataId, fields) => {
|
|
2444
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2445
|
+
return reqPost("/CustomField/Form/Data/Save", fields ?? [], { data_id: dataId });
|
|
2446
|
+
};
|
|
2447
|
+
CustomFieldModel.saveFormFieldData = async (fieldPayload) => {
|
|
2448
|
+
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2449
|
+
return reqPost("/CustomField/Form/Field/Data/Save", fieldPayload ?? {});
|
|
2450
|
+
};
|
|
2451
|
+
var CustomField_default = CustomFieldModel;
|
|
2452
|
+
|
|
2201
2453
|
// src/models/appointment/index.js
|
|
2202
|
-
var
|
|
2203
|
-
var RootStore =
|
|
2204
|
-
calendars:
|
|
2205
|
-
events:
|
|
2454
|
+
var import_mobx_state_tree20 = require("mobx-state-tree");
|
|
2455
|
+
var RootStore = import_mobx_state_tree20.types.model("RootStore", {
|
|
2456
|
+
calendars: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.map(Calendar_default), {}),
|
|
2457
|
+
events: import_mobx_state_tree20.types.optional(import_mobx_state_tree20.types.map(Event_default), {})
|
|
2206
2458
|
}).actions((self) => ({
|
|
2207
2459
|
addCalendar(snapshot) {
|
|
2208
2460
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -2222,6 +2474,7 @@ function createRootStore(initialState = {}) {
|
|
|
2222
2474
|
}
|
|
2223
2475
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2224
2476
|
0 && (module.exports = {
|
|
2477
|
+
AssetModel,
|
|
2225
2478
|
AssignmentMethod,
|
|
2226
2479
|
AttendeeStatus,
|
|
2227
2480
|
AvailabilityDetailModel,
|
|
@@ -2231,6 +2484,7 @@ function createRootStore(initialState = {}) {
|
|
|
2231
2484
|
CalendarParticipantModel,
|
|
2232
2485
|
CompanyModel,
|
|
2233
2486
|
ConfigModel,
|
|
2487
|
+
CustomFieldModel,
|
|
2234
2488
|
DayOfWeek,
|
|
2235
2489
|
EventModel,
|
|
2236
2490
|
FlowModel,
|