@blazeo.com/calendar-client 1.0.46 → 1.0.48
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 +7 -0
- package/dist/index.js +24 -1
- package/dist/index.mjs +24 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ export const EventModel: {
|
|
|
114
114
|
startDateTo: string,
|
|
115
115
|
opts?: Record<string, unknown>
|
|
116
116
|
): Promise<EventSearchResult>;
|
|
117
|
+
getUpcomingByDateRangeWithFilters(
|
|
118
|
+
companyKey: string,
|
|
119
|
+
startDateFrom: string,
|
|
120
|
+
startDateTo: string,
|
|
121
|
+
opts?: Record<string, unknown>
|
|
122
|
+
): Promise<EventSearchResult>;
|
|
117
123
|
getByFilters(companyKey: string, opts?: Record<string, unknown>): Promise<EventSearchResult>;
|
|
118
124
|
getRoundRobinParticipant(calendarId: string): Promise<unknown>;
|
|
119
125
|
getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
|
|
@@ -336,6 +342,7 @@ export const LeadModel: {
|
|
|
336
342
|
referrerLink?: string;
|
|
337
343
|
description?: string;
|
|
338
344
|
}): Promise<{ status: string; data?: unknown; message?: string } | null>;
|
|
345
|
+
/** Requires leadId; when email or phone is included, at least one must be non-empty. */
|
|
339
346
|
updateLead(payload: {
|
|
340
347
|
leadId: string;
|
|
341
348
|
email?: string;
|
package/dist/index.js
CHANGED
|
@@ -827,6 +827,7 @@ async function getByFiltersInternal(path, companyKey, opts = {}, dateRange = nul
|
|
|
827
827
|
return { events, totalCount };
|
|
828
828
|
}
|
|
829
829
|
EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/search/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
|
|
830
|
+
EventModel.getUpcomingByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/upcoming/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
|
|
830
831
|
EventModel.getByFilters = async (companyKey, opts = {}) => getByFiltersInternal("/event/search/get", companyKey, opts);
|
|
831
832
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
832
833
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
@@ -1926,6 +1927,7 @@ var CompanyModel = import_mobx_state_tree15.types.model("Company", {
|
|
|
1926
1927
|
companyName: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.string, ""),
|
|
1927
1928
|
purchasedPhone: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.string, ""),
|
|
1928
1929
|
purchasedPhoneStatus: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.number, 0),
|
|
1930
|
+
purchasedPhoneOn: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1929
1931
|
createdOn: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null),
|
|
1930
1932
|
modifiedOn: import_mobx_state_tree15.types.optional(import_mobx_state_tree15.types.maybeNull(import_mobx_state_tree15.types.string), null)
|
|
1931
1933
|
}).actions((self) => {
|
|
@@ -1955,6 +1957,7 @@ function mapFromApi4(d) {
|
|
|
1955
1957
|
companyName: pick2("companyName", "CompanyName", "company_name") ?? "",
|
|
1956
1958
|
purchasedPhone: pick2("purchasedPhone", "PurchasedPhone", "purchased_phone") ?? "",
|
|
1957
1959
|
purchasedPhoneStatus: pick2("purchasedPhoneStatus", "PurchasedPhoneStatus", "purchased_phone_status") ?? 0,
|
|
1960
|
+
purchasedPhoneOn: pick2("purchasedPhoneOn", "PurchasedPhoneOn", "purchased_phone_on") ?? null,
|
|
1958
1961
|
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1959
1962
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1960
1963
|
};
|
|
@@ -2540,6 +2543,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2540
2543
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2541
2544
|
return { ok: true };
|
|
2542
2545
|
}
|
|
2546
|
+
function validateLeadUpdatePayload(payload) {
|
|
2547
|
+
const p = payload ?? {};
|
|
2548
|
+
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2549
|
+
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2550
|
+
const hasEmailKey = "email" in p || "Email" in p;
|
|
2551
|
+
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2552
|
+
if (hasEmailKey || hasPhoneKey) {
|
|
2553
|
+
const { email, phone } = pickLeadCreateContact(p);
|
|
2554
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2555
|
+
}
|
|
2556
|
+
return { ok: true };
|
|
2557
|
+
}
|
|
2543
2558
|
function mapLeadFromApi(d) {
|
|
2544
2559
|
if (!d) return d;
|
|
2545
2560
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2653,11 +2668,17 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2653
2668
|
}
|
|
2654
2669
|
return res;
|
|
2655
2670
|
},
|
|
2656
|
-
/** POST /lead/update – update this lead */
|
|
2671
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2657
2672
|
async updateLead() {
|
|
2658
2673
|
if (!self.leadId || self.leadId === "new") {
|
|
2659
2674
|
return { status: "failure", message: "leadId required" };
|
|
2660
2675
|
}
|
|
2676
|
+
const validation = validateLeadUpdatePayload({
|
|
2677
|
+
leadId: self.leadId,
|
|
2678
|
+
email: self.email,
|
|
2679
|
+
phone: self.phone
|
|
2680
|
+
});
|
|
2681
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2661
2682
|
const payload = {
|
|
2662
2683
|
leadId: self.leadId,
|
|
2663
2684
|
email: self.email,
|
|
@@ -2802,6 +2823,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2802
2823
|
return null;
|
|
2803
2824
|
};
|
|
2804
2825
|
LeadModel.updateLead = async (payload) => {
|
|
2826
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2827
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2805
2828
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2806
2829
|
const res = await reqPost("/lead/update", payload);
|
|
2807
2830
|
if (res.status === "success" && res.data) {
|
package/dist/index.mjs
CHANGED
|
@@ -752,6 +752,7 @@ async function getByFiltersInternal(path, companyKey, opts = {}, dateRange = nul
|
|
|
752
752
|
return { events, totalCount };
|
|
753
753
|
}
|
|
754
754
|
EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/search/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
|
|
755
|
+
EventModel.getUpcomingByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/upcoming/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
|
|
755
756
|
EventModel.getByFilters = async (companyKey, opts = {}) => getByFiltersInternal("/event/search/get", companyKey, opts);
|
|
756
757
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
757
758
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
@@ -1851,6 +1852,7 @@ var CompanyModel = types15.model("Company", {
|
|
|
1851
1852
|
companyName: types15.optional(types15.string, ""),
|
|
1852
1853
|
purchasedPhone: types15.optional(types15.string, ""),
|
|
1853
1854
|
purchasedPhoneStatus: types15.optional(types15.number, 0),
|
|
1855
|
+
purchasedPhoneOn: types15.optional(types15.maybeNull(types15.string), null),
|
|
1854
1856
|
createdOn: types15.optional(types15.maybeNull(types15.string), null),
|
|
1855
1857
|
modifiedOn: types15.optional(types15.maybeNull(types15.string), null)
|
|
1856
1858
|
}).actions((self) => {
|
|
@@ -1880,6 +1882,7 @@ function mapFromApi4(d) {
|
|
|
1880
1882
|
companyName: pick2("companyName", "CompanyName", "company_name") ?? "",
|
|
1881
1883
|
purchasedPhone: pick2("purchasedPhone", "PurchasedPhone", "purchased_phone") ?? "",
|
|
1882
1884
|
purchasedPhoneStatus: pick2("purchasedPhoneStatus", "PurchasedPhoneStatus", "purchased_phone_status") ?? 0,
|
|
1885
|
+
purchasedPhoneOn: pick2("purchasedPhoneOn", "PurchasedPhoneOn", "purchased_phone_on") ?? null,
|
|
1883
1886
|
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1884
1887
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1885
1888
|
};
|
|
@@ -2465,6 +2468,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2465
2468
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2466
2469
|
return { ok: true };
|
|
2467
2470
|
}
|
|
2471
|
+
function validateLeadUpdatePayload(payload) {
|
|
2472
|
+
const p = payload ?? {};
|
|
2473
|
+
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2474
|
+
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2475
|
+
const hasEmailKey = "email" in p || "Email" in p;
|
|
2476
|
+
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2477
|
+
if (hasEmailKey || hasPhoneKey) {
|
|
2478
|
+
const { email, phone } = pickLeadCreateContact(p);
|
|
2479
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2480
|
+
}
|
|
2481
|
+
return { ok: true };
|
|
2482
|
+
}
|
|
2468
2483
|
function mapLeadFromApi(d) {
|
|
2469
2484
|
if (!d) return d;
|
|
2470
2485
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2578,11 +2593,17 @@ var LeadModel = types20.model("Lead", {
|
|
|
2578
2593
|
}
|
|
2579
2594
|
return res;
|
|
2580
2595
|
},
|
|
2581
|
-
/** POST /lead/update – update this lead */
|
|
2596
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2582
2597
|
async updateLead() {
|
|
2583
2598
|
if (!self.leadId || self.leadId === "new") {
|
|
2584
2599
|
return { status: "failure", message: "leadId required" };
|
|
2585
2600
|
}
|
|
2601
|
+
const validation = validateLeadUpdatePayload({
|
|
2602
|
+
leadId: self.leadId,
|
|
2603
|
+
email: self.email,
|
|
2604
|
+
phone: self.phone
|
|
2605
|
+
});
|
|
2606
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2586
2607
|
const payload = {
|
|
2587
2608
|
leadId: self.leadId,
|
|
2588
2609
|
email: self.email,
|
|
@@ -2727,6 +2748,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2727
2748
|
return null;
|
|
2728
2749
|
};
|
|
2729
2750
|
LeadModel.updateLead = async (payload) => {
|
|
2751
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2752
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2730
2753
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2731
2754
|
const res = await reqPost("/lead/update", payload);
|
|
2732
2755
|
if (res.status === "success" && res.data) {
|