@blazeo.com/calendar-client 1.0.47 → 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 +22 -1
- package/dist/index.mjs +22 -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());
|
|
@@ -2542,6 +2543,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2542
2543
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2543
2544
|
return { ok: true };
|
|
2544
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
|
+
}
|
|
2545
2558
|
function mapLeadFromApi(d) {
|
|
2546
2559
|
if (!d) return d;
|
|
2547
2560
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2655,11 +2668,17 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2655
2668
|
}
|
|
2656
2669
|
return res;
|
|
2657
2670
|
},
|
|
2658
|
-
/** POST /lead/update – update this lead */
|
|
2671
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2659
2672
|
async updateLead() {
|
|
2660
2673
|
if (!self.leadId || self.leadId === "new") {
|
|
2661
2674
|
return { status: "failure", message: "leadId required" };
|
|
2662
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 };
|
|
2663
2682
|
const payload = {
|
|
2664
2683
|
leadId: self.leadId,
|
|
2665
2684
|
email: self.email,
|
|
@@ -2804,6 +2823,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2804
2823
|
return null;
|
|
2805
2824
|
};
|
|
2806
2825
|
LeadModel.updateLead = async (payload) => {
|
|
2826
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2827
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2807
2828
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2808
2829
|
const res = await reqPost("/lead/update", payload);
|
|
2809
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());
|
|
@@ -2467,6 +2468,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2467
2468
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2468
2469
|
return { ok: true };
|
|
2469
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
|
+
}
|
|
2470
2483
|
function mapLeadFromApi(d) {
|
|
2471
2484
|
if (!d) return d;
|
|
2472
2485
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2580,11 +2593,17 @@ var LeadModel = types20.model("Lead", {
|
|
|
2580
2593
|
}
|
|
2581
2594
|
return res;
|
|
2582
2595
|
},
|
|
2583
|
-
/** POST /lead/update – update this lead */
|
|
2596
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2584
2597
|
async updateLead() {
|
|
2585
2598
|
if (!self.leadId || self.leadId === "new") {
|
|
2586
2599
|
return { status: "failure", message: "leadId required" };
|
|
2587
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 };
|
|
2588
2607
|
const payload = {
|
|
2589
2608
|
leadId: self.leadId,
|
|
2590
2609
|
email: self.email,
|
|
@@ -2729,6 +2748,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2729
2748
|
return null;
|
|
2730
2749
|
};
|
|
2731
2750
|
LeadModel.updateLead = async (payload) => {
|
|
2751
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2752
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2732
2753
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2733
2754
|
const res = await reqPost("/lead/update", payload);
|
|
2734
2755
|
if (res.status === "success" && res.data) {
|