@blazeo.com/calendar-client 1.0.29 → 1.0.30
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 +4 -1
- package/dist/index.js +33 -2
- package/dist/index.mjs +33 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -230,6 +230,7 @@ export const LeadModel: {
|
|
|
230
230
|
getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
231
231
|
get(leadId: string): Promise<unknown>;
|
|
232
232
|
getByEmail(email: string, companyKey: string): Promise<unknown>;
|
|
233
|
+
getByPhone(phone: string, companyKey: string): Promise<unknown>;
|
|
233
234
|
createLead(payload: {
|
|
234
235
|
email: string;
|
|
235
236
|
companyKey: string;
|
|
@@ -376,7 +377,9 @@ export const AuthModel: {
|
|
|
376
377
|
type: string;
|
|
377
378
|
status: 'success' | 'error';
|
|
378
379
|
message?: string;
|
|
379
|
-
|
|
380
|
+
closePopup?: boolean;
|
|
381
|
+
}) => void,
|
|
382
|
+
popup?: Window | null
|
|
380
383
|
): () => void;
|
|
381
384
|
};
|
|
382
385
|
|
package/dist/index.js
CHANGED
|
@@ -2410,6 +2410,17 @@ var LeadModel = import_mobx_state_tree19.types.model("Lead", {
|
|
|
2410
2410
|
}
|
|
2411
2411
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2412
2412
|
},
|
|
2413
|
+
/** GET /lead/getbyphone – uses self.phone and self.companyKey */
|
|
2414
|
+
async getByPhone() {
|
|
2415
|
+
if (!self.phone || !self.companyKey) {
|
|
2416
|
+
return { status: "failure", message: "phone and companyKey required on model" };
|
|
2417
|
+
}
|
|
2418
|
+
const lead = await LeadModel.getByPhone(self.phone, self.companyKey);
|
|
2419
|
+
if (lead) {
|
|
2420
|
+
(0, import_mobx_state_tree19.applySnapshot)(self, (0, import_mobx_state_tree19.getSnapshot)(lead));
|
|
2421
|
+
}
|
|
2422
|
+
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2423
|
+
},
|
|
2413
2424
|
/** GET /lead/company/get – uses self.companyKey; same result as LeadModel.getByCompany(companyKey, opts) */
|
|
2414
2425
|
async getByCompany(opts = {}) {
|
|
2415
2426
|
if (!self.companyKey) return null;
|
|
@@ -2492,6 +2503,17 @@ LeadModel.getByEmail = async (email, companyKey) => {
|
|
|
2492
2503
|
}
|
|
2493
2504
|
return null;
|
|
2494
2505
|
};
|
|
2506
|
+
LeadModel.getByPhone = async (phone, companyKey) => {
|
|
2507
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2508
|
+
const res = await reqGet("/lead/getbyphone", {
|
|
2509
|
+
phone: phone != null ? String(phone).trim() : "",
|
|
2510
|
+
company_key: companyKey != null ? String(companyKey).trim() : ""
|
|
2511
|
+
});
|
|
2512
|
+
if (res.status === "success" && res.data) {
|
|
2513
|
+
return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
|
|
2514
|
+
}
|
|
2515
|
+
return null;
|
|
2516
|
+
};
|
|
2495
2517
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2496
2518
|
var _a, _b;
|
|
2497
2519
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
@@ -2888,16 +2910,25 @@ var AuthModel = {
|
|
|
2888
2910
|
* Subscribe to calendar-authorization postMessage from OAuth popup (Authorized.html / Error.html).
|
|
2889
2911
|
* Do not use popup.closed to detect completion — Cross-Origin-Opener-Policy on the parent app
|
|
2890
2912
|
* blocks that check after the popup navigates to Google/Microsoft.
|
|
2891
|
-
*
|
|
2913
|
+
* Pass the Window returned from openOAuthPopup so this helper can close it; self-close from
|
|
2914
|
+
* Authorized.html/Error.html is often blocked after OAuth redirects.
|
|
2915
|
+
* @param {(payload: { type: string, status: 'success' | 'error', message?: string, closePopup?: boolean }) => void} handler
|
|
2916
|
+
* @param {Window | null | undefined} [popup] — popup to close when auth completes
|
|
2892
2917
|
* @returns {() => void} unsubscribe
|
|
2893
2918
|
*/
|
|
2894
|
-
onCalendarAuthMessage(handler) {
|
|
2919
|
+
onCalendarAuthMessage(handler, popup) {
|
|
2895
2920
|
if (typeof window === "undefined") return () => {
|
|
2896
2921
|
};
|
|
2897
2922
|
const listener = (event) => {
|
|
2898
2923
|
const payload = event == null ? void 0 : event.data;
|
|
2899
2924
|
if (!payload || payload.type !== CALENDAR_AUTH_MESSAGE_TYPE) return;
|
|
2900
2925
|
handler(payload);
|
|
2926
|
+
if (popup) {
|
|
2927
|
+
try {
|
|
2928
|
+
popup.close();
|
|
2929
|
+
} catch (_) {
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2901
2932
|
};
|
|
2902
2933
|
window.addEventListener("message", listener);
|
|
2903
2934
|
return () => window.removeEventListener("message", listener);
|
package/dist/index.mjs
CHANGED
|
@@ -2339,6 +2339,17 @@ var LeadModel = types19.model("Lead", {
|
|
|
2339
2339
|
}
|
|
2340
2340
|
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2341
2341
|
},
|
|
2342
|
+
/** GET /lead/getbyphone – uses self.phone and self.companyKey */
|
|
2343
|
+
async getByPhone() {
|
|
2344
|
+
if (!self.phone || !self.companyKey) {
|
|
2345
|
+
return { status: "failure", message: "phone and companyKey required on model" };
|
|
2346
|
+
}
|
|
2347
|
+
const lead = await LeadModel.getByPhone(self.phone, self.companyKey);
|
|
2348
|
+
if (lead) {
|
|
2349
|
+
applySnapshot8(self, getSnapshot(lead));
|
|
2350
|
+
}
|
|
2351
|
+
return { status: lead ? "success" : "failure", data: lead ?? void 0 };
|
|
2352
|
+
},
|
|
2342
2353
|
/** GET /lead/company/get – uses self.companyKey; same result as LeadModel.getByCompany(companyKey, opts) */
|
|
2343
2354
|
async getByCompany(opts = {}) {
|
|
2344
2355
|
if (!self.companyKey) return null;
|
|
@@ -2421,6 +2432,17 @@ LeadModel.getByEmail = async (email, companyKey) => {
|
|
|
2421
2432
|
}
|
|
2422
2433
|
return null;
|
|
2423
2434
|
};
|
|
2435
|
+
LeadModel.getByPhone = async (phone, companyKey) => {
|
|
2436
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2437
|
+
const res = await reqGet("/lead/getbyphone", {
|
|
2438
|
+
phone: phone != null ? String(phone).trim() : "",
|
|
2439
|
+
company_key: companyKey != null ? String(companyKey).trim() : ""
|
|
2440
|
+
});
|
|
2441
|
+
if (res.status === "success" && res.data) {
|
|
2442
|
+
return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
|
|
2443
|
+
}
|
|
2444
|
+
return null;
|
|
2445
|
+
};
|
|
2424
2446
|
LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
2425
2447
|
var _a, _b;
|
|
2426
2448
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
@@ -2817,16 +2839,25 @@ var AuthModel = {
|
|
|
2817
2839
|
* Subscribe to calendar-authorization postMessage from OAuth popup (Authorized.html / Error.html).
|
|
2818
2840
|
* Do not use popup.closed to detect completion — Cross-Origin-Opener-Policy on the parent app
|
|
2819
2841
|
* blocks that check after the popup navigates to Google/Microsoft.
|
|
2820
|
-
*
|
|
2842
|
+
* Pass the Window returned from openOAuthPopup so this helper can close it; self-close from
|
|
2843
|
+
* Authorized.html/Error.html is often blocked after OAuth redirects.
|
|
2844
|
+
* @param {(payload: { type: string, status: 'success' | 'error', message?: string, closePopup?: boolean }) => void} handler
|
|
2845
|
+
* @param {Window | null | undefined} [popup] — popup to close when auth completes
|
|
2821
2846
|
* @returns {() => void} unsubscribe
|
|
2822
2847
|
*/
|
|
2823
|
-
onCalendarAuthMessage(handler) {
|
|
2848
|
+
onCalendarAuthMessage(handler, popup) {
|
|
2824
2849
|
if (typeof window === "undefined") return () => {
|
|
2825
2850
|
};
|
|
2826
2851
|
const listener = (event) => {
|
|
2827
2852
|
const payload = event == null ? void 0 : event.data;
|
|
2828
2853
|
if (!payload || payload.type !== CALENDAR_AUTH_MESSAGE_TYPE) return;
|
|
2829
2854
|
handler(payload);
|
|
2855
|
+
if (popup) {
|
|
2856
|
+
try {
|
|
2857
|
+
popup.close();
|
|
2858
|
+
} catch (_) {
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2830
2861
|
};
|
|
2831
2862
|
window.addEventListener("message", listener);
|
|
2832
2863
|
return () => window.removeEventListener("message", listener);
|