@blazeo.com/calendar-client 1.0.50 → 1.0.54
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 +32 -4
- package/dist/index.js +49 -7
- package/dist/index.mjs +49 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -225,6 +225,13 @@ export type PhoneNumberPurchaseResult = {
|
|
|
225
225
|
Success?: boolean;
|
|
226
226
|
};
|
|
227
227
|
|
|
228
|
+
export type PhoneNumberReleaseData = {
|
|
229
|
+
company_key?: string;
|
|
230
|
+
phone_number?: string;
|
|
231
|
+
released_from_twilio?: boolean;
|
|
232
|
+
cleared_local_state?: boolean;
|
|
233
|
+
};
|
|
234
|
+
|
|
228
235
|
export const CompanyModel: {
|
|
229
236
|
get(companyKey: string): Promise<unknown>;
|
|
230
237
|
getAll(): Promise<unknown[] | null>;
|
|
@@ -234,6 +241,11 @@ export const CompanyModel: {
|
|
|
234
241
|
data?: PhoneNumberPurchaseResult;
|
|
235
242
|
message?: string;
|
|
236
243
|
}>;
|
|
244
|
+
releasePhoneNumber(companyKey: string, phoneNumber?: string): Promise<{
|
|
245
|
+
status: string;
|
|
246
|
+
data?: PhoneNumberReleaseData;
|
|
247
|
+
message?: string;
|
|
248
|
+
}>;
|
|
237
249
|
create(snapshot: object, options?: { env?: object }): unknown;
|
|
238
250
|
};
|
|
239
251
|
export const AssetModel: {
|
|
@@ -338,26 +350,30 @@ export const LeadModel: {
|
|
|
338
350
|
data?: { userId?: string; columns?: string[]; isDefault?: boolean };
|
|
339
351
|
message?: string;
|
|
340
352
|
}>;
|
|
341
|
-
/** Requires companyKey and at least one of email or phone. */
|
|
353
|
+
/** Requires firstName/name, leadType, companyKey and at least one of email or phone. */
|
|
342
354
|
createLead(payload: {
|
|
343
355
|
companyKey: string;
|
|
344
356
|
email?: string;
|
|
345
357
|
phone?: string;
|
|
346
358
|
name?: string;
|
|
359
|
+
firstName?: string;
|
|
360
|
+
first_name?: string;
|
|
347
361
|
source?: string;
|
|
348
|
-
leadType
|
|
362
|
+
leadType: 'sales' | 'service' | 'others' | number;
|
|
349
363
|
referrerLink?: string;
|
|
350
364
|
description?: string;
|
|
351
365
|
}): Promise<{ status: string; data?: unknown; message?: string } | null>;
|
|
352
|
-
/** Requires leadId; when email or phone is included, at least one must be non-empty. */
|
|
366
|
+
/** Requires leadId, firstName/name and leadType; when email or phone is included, at least one must be non-empty. */
|
|
353
367
|
updateLead(payload: {
|
|
354
368
|
leadId: string;
|
|
355
369
|
email?: string;
|
|
356
370
|
companyKey?: string;
|
|
357
371
|
name?: string;
|
|
372
|
+
firstName?: string;
|
|
373
|
+
first_name?: string;
|
|
358
374
|
phone?: string;
|
|
359
375
|
source?: string;
|
|
360
|
-
leadType
|
|
376
|
+
leadType: 'sales' | 'service' | 'others' | number;
|
|
361
377
|
referrerLink?: string;
|
|
362
378
|
description?: string;
|
|
363
379
|
}): Promise<unknown>;
|
|
@@ -396,6 +412,16 @@ export const LeadModel: {
|
|
|
396
412
|
searchText?: string;
|
|
397
413
|
search_text?: string;
|
|
398
414
|
search?: string;
|
|
415
|
+
/** Multiple column filters, ANDed together (combined with the single searchColumn/searchText pair when both are set). */
|
|
416
|
+
filters?: Array<{
|
|
417
|
+
column?: string;
|
|
418
|
+
searchColumn?: string;
|
|
419
|
+
search_column?: string;
|
|
420
|
+
text?: string;
|
|
421
|
+
searchText?: string;
|
|
422
|
+
search_text?: string;
|
|
423
|
+
search?: string;
|
|
424
|
+
}>;
|
|
399
425
|
page?: number;
|
|
400
426
|
page_size?: number;
|
|
401
427
|
}
|
|
@@ -453,6 +479,8 @@ export type ParticipantData = {
|
|
|
453
479
|
createdOn?: string | null;
|
|
454
480
|
modifiedOn?: string | null;
|
|
455
481
|
isDeleted?: boolean;
|
|
482
|
+
/** Last stored authorization error; populated by Auth/IsAuthorized when not authorized. */
|
|
483
|
+
authorizationError?: string;
|
|
456
484
|
};
|
|
457
485
|
|
|
458
486
|
export const CALENDAR_AUTH_MESSAGE_TYPE: 'calendar-authorization';
|
package/dist/index.js
CHANGED
|
@@ -1635,7 +1635,8 @@ function mapParticipantFromApi(d) {
|
|
|
1635
1635
|
provider: n(pick2("provider", "Provider", "emailProvider", "EmailProvider", "email_provider")) ?? 0,
|
|
1636
1636
|
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1637
1637
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
|
|
1638
|
-
isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted"))
|
|
1638
|
+
isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted")),
|
|
1639
|
+
authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? ""
|
|
1639
1640
|
};
|
|
1640
1641
|
}
|
|
1641
1642
|
function mapFromApi2(d) {
|
|
@@ -2037,6 +2038,12 @@ CompanyModel.purchasePhoneNumber = async (companyKey, companyId) => {
|
|
|
2037
2038
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2038
2039
|
return reqGet("/Company/PhoneNumber/Purchase", { company_key: companyKey, company_id: companyId });
|
|
2039
2040
|
};
|
|
2041
|
+
CompanyModel.releasePhoneNumber = async (companyKey, phoneNumber) => {
|
|
2042
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
2043
|
+
const query = { company_key: companyKey };
|
|
2044
|
+
if (phoneNumber) query.phone_number = phoneNumber;
|
|
2045
|
+
return reqGet("/Company/PhoneNumber/Release", query);
|
|
2046
|
+
};
|
|
2040
2047
|
var Company_default = CompanyModel;
|
|
2041
2048
|
|
|
2042
2049
|
// src/models/appointment/Asset.js
|
|
@@ -2578,9 +2585,24 @@ function pickLeadCreateContact(payload) {
|
|
|
2578
2585
|
const companyKey = String(p.companyKey ?? p.company_key ?? p.CompanyKey ?? "").trim();
|
|
2579
2586
|
return { email, phone, companyKey };
|
|
2580
2587
|
}
|
|
2588
|
+
function pickLeadRequiredFields(payload) {
|
|
2589
|
+
const p = payload ?? {};
|
|
2590
|
+
const firstName = String(
|
|
2591
|
+
p.firstName ?? p.first_name ?? p.name ?? p.Name ?? ""
|
|
2592
|
+
).trim();
|
|
2593
|
+
const leadType = p.leadType ?? p.lead_type ?? p.LeadType ?? null;
|
|
2594
|
+
return { firstName, leadType };
|
|
2595
|
+
}
|
|
2596
|
+
function hasLeadTypeValue(leadType) {
|
|
2597
|
+
if (leadType == null) return false;
|
|
2598
|
+
return !(typeof leadType === "string" && leadType.trim() === "");
|
|
2599
|
+
}
|
|
2581
2600
|
function validateLeadCreatePayload(payload) {
|
|
2582
2601
|
const { email, phone, companyKey } = pickLeadCreateContact(payload);
|
|
2602
|
+
const { firstName, leadType } = pickLeadRequiredFields(payload);
|
|
2583
2603
|
if (!companyKey) return { ok: false, message: "companyKey is required" };
|
|
2604
|
+
if (!firstName) return { ok: false, message: "First name is mandatory" };
|
|
2605
|
+
if (!hasLeadTypeValue(leadType)) return { ok: false, message: "Lead type is mandatory" };
|
|
2584
2606
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2585
2607
|
return { ok: true };
|
|
2586
2608
|
}
|
|
@@ -2588,6 +2610,9 @@ function validateLeadUpdatePayload(payload) {
|
|
|
2588
2610
|
const p = payload ?? {};
|
|
2589
2611
|
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2590
2612
|
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2613
|
+
const { firstName, leadType } = pickLeadRequiredFields(payload);
|
|
2614
|
+
if (!firstName) return { ok: false, message: "First name is mandatory" };
|
|
2615
|
+
if (!hasLeadTypeValue(leadType)) return { ok: false, message: "Lead type is mandatory" };
|
|
2591
2616
|
const hasEmailKey = "email" in p || "Email" in p;
|
|
2592
2617
|
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2593
2618
|
if (hasEmailKey || hasPhoneKey) {
|
|
@@ -2685,12 +2710,14 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2685
2710
|
async getColumnSelection(userId) {
|
|
2686
2711
|
return LeadModel.getColumnSelection(userId);
|
|
2687
2712
|
},
|
|
2688
|
-
/** POST /lead/create – create this lead (requires companyKey and email
|
|
2713
|
+
/** POST /lead/create – create this lead (requires firstName, leadType, companyKey and email/phone) */
|
|
2689
2714
|
async createLead() {
|
|
2690
2715
|
const validation = validateLeadCreatePayload({
|
|
2691
2716
|
email: self.email,
|
|
2692
2717
|
phone: self.phone,
|
|
2693
|
-
companyKey: self.companyKey
|
|
2718
|
+
companyKey: self.companyKey,
|
|
2719
|
+
firstName: self.name,
|
|
2720
|
+
leadType: self.leadType
|
|
2694
2721
|
});
|
|
2695
2722
|
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2696
2723
|
const payload = {
|
|
@@ -2709,7 +2736,7 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2709
2736
|
}
|
|
2710
2737
|
return res;
|
|
2711
2738
|
},
|
|
2712
|
-
/** POST /lead/update – update this lead (requires
|
|
2739
|
+
/** POST /lead/update – update this lead (requires firstName and leadType) */
|
|
2713
2740
|
async updateLead() {
|
|
2714
2741
|
if (!self.leadId || self.leadId === "new") {
|
|
2715
2742
|
return { status: "failure", message: "leadId required" };
|
|
@@ -2717,7 +2744,9 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2717
2744
|
const validation = validateLeadUpdatePayload({
|
|
2718
2745
|
leadId: self.leadId,
|
|
2719
2746
|
email: self.email,
|
|
2720
|
-
phone: self.phone
|
|
2747
|
+
phone: self.phone,
|
|
2748
|
+
firstName: self.name,
|
|
2749
|
+
leadType: self.leadType
|
|
2721
2750
|
});
|
|
2722
2751
|
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2723
2752
|
const payload = {
|
|
@@ -2829,10 +2858,23 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2829
2858
|
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
2830
2859
|
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
2831
2860
|
}
|
|
2861
|
+
const filterPairs = [];
|
|
2832
2862
|
const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
|
|
2833
|
-
if (searchColumn != null && String(searchColumn).trim() !== "") query.search_column = String(searchColumn).trim();
|
|
2834
2863
|
const searchText = opts.searchText ?? opts.search_text ?? opts.search;
|
|
2835
|
-
|
|
2864
|
+
const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
|
|
2865
|
+
const singleText = searchText != null ? String(searchText).trim() : "";
|
|
2866
|
+
if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
|
|
2867
|
+
if (Array.isArray(opts.filters)) {
|
|
2868
|
+
for (const f of opts.filters) {
|
|
2869
|
+
const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
|
|
2870
|
+
const text = String((f == null ? void 0 : f.text) ?? (f == null ? void 0 : f.searchText) ?? (f == null ? void 0 : f.search_text) ?? (f == null ? void 0 : f.search) ?? "").trim();
|
|
2871
|
+
if (column && text) filterPairs.push({ column, text });
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
if (filterPairs.length) {
|
|
2875
|
+
query.search_column = filterPairs.map((f) => f.column);
|
|
2876
|
+
query.search_text = filterPairs.map((f) => f.text);
|
|
2877
|
+
}
|
|
2836
2878
|
if (opts.page != null) {
|
|
2837
2879
|
query.page = opts.page;
|
|
2838
2880
|
if (opts.page_size != null) query.page_size = opts.page_size;
|
package/dist/index.mjs
CHANGED
|
@@ -1560,7 +1560,8 @@ function mapParticipantFromApi(d) {
|
|
|
1560
1560
|
provider: n(pick2("provider", "Provider", "emailProvider", "EmailProvider", "email_provider")) ?? 0,
|
|
1561
1561
|
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1562
1562
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
|
|
1563
|
-
isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted"))
|
|
1563
|
+
isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted")),
|
|
1564
|
+
authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? ""
|
|
1564
1565
|
};
|
|
1565
1566
|
}
|
|
1566
1567
|
function mapFromApi2(d) {
|
|
@@ -1962,6 +1963,12 @@ CompanyModel.purchasePhoneNumber = async (companyKey, companyId) => {
|
|
|
1962
1963
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1963
1964
|
return reqGet("/Company/PhoneNumber/Purchase", { company_key: companyKey, company_id: companyId });
|
|
1964
1965
|
};
|
|
1966
|
+
CompanyModel.releasePhoneNumber = async (companyKey, phoneNumber) => {
|
|
1967
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1968
|
+
const query = { company_key: companyKey };
|
|
1969
|
+
if (phoneNumber) query.phone_number = phoneNumber;
|
|
1970
|
+
return reqGet("/Company/PhoneNumber/Release", query);
|
|
1971
|
+
};
|
|
1965
1972
|
var Company_default = CompanyModel;
|
|
1966
1973
|
|
|
1967
1974
|
// src/models/appointment/Asset.js
|
|
@@ -2503,9 +2510,24 @@ function pickLeadCreateContact(payload) {
|
|
|
2503
2510
|
const companyKey = String(p.companyKey ?? p.company_key ?? p.CompanyKey ?? "").trim();
|
|
2504
2511
|
return { email, phone, companyKey };
|
|
2505
2512
|
}
|
|
2513
|
+
function pickLeadRequiredFields(payload) {
|
|
2514
|
+
const p = payload ?? {};
|
|
2515
|
+
const firstName = String(
|
|
2516
|
+
p.firstName ?? p.first_name ?? p.name ?? p.Name ?? ""
|
|
2517
|
+
).trim();
|
|
2518
|
+
const leadType = p.leadType ?? p.lead_type ?? p.LeadType ?? null;
|
|
2519
|
+
return { firstName, leadType };
|
|
2520
|
+
}
|
|
2521
|
+
function hasLeadTypeValue(leadType) {
|
|
2522
|
+
if (leadType == null) return false;
|
|
2523
|
+
return !(typeof leadType === "string" && leadType.trim() === "");
|
|
2524
|
+
}
|
|
2506
2525
|
function validateLeadCreatePayload(payload) {
|
|
2507
2526
|
const { email, phone, companyKey } = pickLeadCreateContact(payload);
|
|
2527
|
+
const { firstName, leadType } = pickLeadRequiredFields(payload);
|
|
2508
2528
|
if (!companyKey) return { ok: false, message: "companyKey is required" };
|
|
2529
|
+
if (!firstName) return { ok: false, message: "First name is mandatory" };
|
|
2530
|
+
if (!hasLeadTypeValue(leadType)) return { ok: false, message: "Lead type is mandatory" };
|
|
2509
2531
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2510
2532
|
return { ok: true };
|
|
2511
2533
|
}
|
|
@@ -2513,6 +2535,9 @@ function validateLeadUpdatePayload(payload) {
|
|
|
2513
2535
|
const p = payload ?? {};
|
|
2514
2536
|
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2515
2537
|
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2538
|
+
const { firstName, leadType } = pickLeadRequiredFields(payload);
|
|
2539
|
+
if (!firstName) return { ok: false, message: "First name is mandatory" };
|
|
2540
|
+
if (!hasLeadTypeValue(leadType)) return { ok: false, message: "Lead type is mandatory" };
|
|
2516
2541
|
const hasEmailKey = "email" in p || "Email" in p;
|
|
2517
2542
|
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2518
2543
|
if (hasEmailKey || hasPhoneKey) {
|
|
@@ -2610,12 +2635,14 @@ var LeadModel = types20.model("Lead", {
|
|
|
2610
2635
|
async getColumnSelection(userId) {
|
|
2611
2636
|
return LeadModel.getColumnSelection(userId);
|
|
2612
2637
|
},
|
|
2613
|
-
/** POST /lead/create – create this lead (requires companyKey and email
|
|
2638
|
+
/** POST /lead/create – create this lead (requires firstName, leadType, companyKey and email/phone) */
|
|
2614
2639
|
async createLead() {
|
|
2615
2640
|
const validation = validateLeadCreatePayload({
|
|
2616
2641
|
email: self.email,
|
|
2617
2642
|
phone: self.phone,
|
|
2618
|
-
companyKey: self.companyKey
|
|
2643
|
+
companyKey: self.companyKey,
|
|
2644
|
+
firstName: self.name,
|
|
2645
|
+
leadType: self.leadType
|
|
2619
2646
|
});
|
|
2620
2647
|
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2621
2648
|
const payload = {
|
|
@@ -2634,7 +2661,7 @@ var LeadModel = types20.model("Lead", {
|
|
|
2634
2661
|
}
|
|
2635
2662
|
return res;
|
|
2636
2663
|
},
|
|
2637
|
-
/** POST /lead/update – update this lead (requires
|
|
2664
|
+
/** POST /lead/update – update this lead (requires firstName and leadType) */
|
|
2638
2665
|
async updateLead() {
|
|
2639
2666
|
if (!self.leadId || self.leadId === "new") {
|
|
2640
2667
|
return { status: "failure", message: "leadId required" };
|
|
@@ -2642,7 +2669,9 @@ var LeadModel = types20.model("Lead", {
|
|
|
2642
2669
|
const validation = validateLeadUpdatePayload({
|
|
2643
2670
|
leadId: self.leadId,
|
|
2644
2671
|
email: self.email,
|
|
2645
|
-
phone: self.phone
|
|
2672
|
+
phone: self.phone,
|
|
2673
|
+
firstName: self.name,
|
|
2674
|
+
leadType: self.leadType
|
|
2646
2675
|
});
|
|
2647
2676
|
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2648
2677
|
const payload = {
|
|
@@ -2754,10 +2783,23 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
|
|
|
2754
2783
|
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
2755
2784
|
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
2756
2785
|
}
|
|
2786
|
+
const filterPairs = [];
|
|
2757
2787
|
const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
|
|
2758
|
-
if (searchColumn != null && String(searchColumn).trim() !== "") query.search_column = String(searchColumn).trim();
|
|
2759
2788
|
const searchText = opts.searchText ?? opts.search_text ?? opts.search;
|
|
2760
|
-
|
|
2789
|
+
const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
|
|
2790
|
+
const singleText = searchText != null ? String(searchText).trim() : "";
|
|
2791
|
+
if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
|
|
2792
|
+
if (Array.isArray(opts.filters)) {
|
|
2793
|
+
for (const f of opts.filters) {
|
|
2794
|
+
const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
|
|
2795
|
+
const text = String((f == null ? void 0 : f.text) ?? (f == null ? void 0 : f.searchText) ?? (f == null ? void 0 : f.search_text) ?? (f == null ? void 0 : f.search) ?? "").trim();
|
|
2796
|
+
if (column && text) filterPairs.push({ column, text });
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
if (filterPairs.length) {
|
|
2800
|
+
query.search_column = filterPairs.map((f) => f.column);
|
|
2801
|
+
query.search_text = filterPairs.map((f) => f.text);
|
|
2802
|
+
}
|
|
2761
2803
|
if (opts.page != null) {
|
|
2762
2804
|
query.page = opts.page;
|
|
2763
2805
|
if (opts.page_size != null) query.page_size = opts.page_size;
|