@blazeo.com/calendar-client 1.0.47 → 1.0.49
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 +14 -0
- package/dist/index.js +60 -1
- package/dist/index.mjs +60 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export function getConfigStore(): unknown;
|
|
|
42
42
|
|
|
43
43
|
export const ConfigModel: unknown;
|
|
44
44
|
|
|
45
|
+
export type ParticipantAuthorizationStatus = {
|
|
46
|
+
participantId: string;
|
|
47
|
+
isApproved: boolean;
|
|
48
|
+
};
|
|
49
|
+
|
|
45
50
|
export const CalendarModel: {
|
|
46
51
|
get(calendarId: string): Promise<unknown>;
|
|
47
52
|
getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
@@ -69,6 +74,7 @@ export const CalendarModel: {
|
|
|
69
74
|
getAllParticipantOpeningHours(calendarId: string): Promise<unknown[] | null>;
|
|
70
75
|
getCalendarParticipant(calendarId: string): Promise<unknown>;
|
|
71
76
|
getParticipantsInfo(calendarId: string): Promise<unknown>;
|
|
77
|
+
checkParticipantsAuthorization(calendarId: string): Promise<ParticipantAuthorizationStatus[] | null>;
|
|
72
78
|
getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
|
|
73
79
|
getEvents(calendarId: string): Promise<unknown>;
|
|
74
80
|
createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
|
|
@@ -114,6 +120,12 @@ export const EventModel: {
|
|
|
114
120
|
startDateTo: string,
|
|
115
121
|
opts?: Record<string, unknown>
|
|
116
122
|
): Promise<EventSearchResult>;
|
|
123
|
+
getUpcomingByDateRangeWithFilters(
|
|
124
|
+
companyKey: string,
|
|
125
|
+
startDateFrom: string,
|
|
126
|
+
startDateTo: string,
|
|
127
|
+
opts?: Record<string, unknown>
|
|
128
|
+
): Promise<EventSearchResult>;
|
|
117
129
|
getByFilters(companyKey: string, opts?: Record<string, unknown>): Promise<EventSearchResult>;
|
|
118
130
|
getRoundRobinParticipant(calendarId: string): Promise<unknown>;
|
|
119
131
|
getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
|
|
@@ -161,6 +173,7 @@ export const AvailabilityDetailModel: { create(snapshot: object, options?: { env
|
|
|
161
173
|
export const CalendarParticipantModel: {
|
|
162
174
|
getByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
163
175
|
getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
176
|
+
checkAuthorizationByCalendar(calendarId: string): Promise<ParticipantAuthorizationStatus[] | null>;
|
|
164
177
|
getByParticipant(participantId: string): Promise<unknown[] | null>;
|
|
165
178
|
create(snapshot: object, options?: { env?: object }): unknown;
|
|
166
179
|
};
|
|
@@ -336,6 +349,7 @@ export const LeadModel: {
|
|
|
336
349
|
referrerLink?: string;
|
|
337
350
|
description?: string;
|
|
338
351
|
}): Promise<{ status: string; data?: unknown; message?: string } | null>;
|
|
352
|
+
/** Requires leadId; when email or phone is included, at least one must be non-empty. */
|
|
339
353
|
updateLead(payload: {
|
|
340
354
|
leadId: string;
|
|
341
355
|
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());
|
|
@@ -1007,6 +1008,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
|
|
|
1007
1008
|
}
|
|
1008
1009
|
return null;
|
|
1009
1010
|
};
|
|
1011
|
+
CalendarParticipantModel.checkAuthorizationByCalendar = async (calendarId) => {
|
|
1012
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1013
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1014
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1015
|
+
return res.data.map((p) => ({
|
|
1016
|
+
participantId: String(p.participantId ?? p.ParticipantId ?? p.participant_id ?? ""),
|
|
1017
|
+
isApproved: Boolean(p.isApproved ?? p.IsApproved ?? p.is_approved)
|
|
1018
|
+
}));
|
|
1019
|
+
}
|
|
1020
|
+
return null;
|
|
1021
|
+
};
|
|
1010
1022
|
CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
1011
1023
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1012
1024
|
const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
|
|
@@ -1174,6 +1186,18 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1174
1186
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1175
1187
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
1176
1188
|
},
|
|
1189
|
+
/**
|
|
1190
|
+
* GET Calendar/Participants/Authorization/Check
|
|
1191
|
+
* Validates OAuth for all calendar participants and updates isApproved in the database.
|
|
1192
|
+
*/
|
|
1193
|
+
async checkParticipantsAuthorization() {
|
|
1194
|
+
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1195
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: self.calendarId });
|
|
1196
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1197
|
+
res.data = res.data.map(mapParticipantAuthorizationFromApi);
|
|
1198
|
+
}
|
|
1199
|
+
return res;
|
|
1200
|
+
},
|
|
1177
1201
|
/** GET Calendar/All – calendars by company_key with paging options */
|
|
1178
1202
|
async getByCompany(companyKey, opts = {}) {
|
|
1179
1203
|
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
@@ -1288,6 +1312,13 @@ function mapCalendarFromApi(d) {
|
|
|
1288
1312
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1289
1313
|
};
|
|
1290
1314
|
}
|
|
1315
|
+
function mapParticipantAuthorizationFromApi(d) {
|
|
1316
|
+
if (!d) return d;
|
|
1317
|
+
return {
|
|
1318
|
+
participantId: String(d.participantId ?? d.ParticipantId ?? d.participant_id ?? ""),
|
|
1319
|
+
isApproved: Boolean(d.isApproved ?? d.IsApproved ?? d.is_approved)
|
|
1320
|
+
};
|
|
1321
|
+
}
|
|
1291
1322
|
CalendarModel.getRaw = async (calendarId) => {
|
|
1292
1323
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1293
1324
|
return reqGet("/Calendar/Get", { calendar_id: calendarId });
|
|
@@ -1397,6 +1428,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
|
|
|
1397
1428
|
}
|
|
1398
1429
|
return null;
|
|
1399
1430
|
};
|
|
1431
|
+
CalendarModel.checkParticipantsAuthorization = async (calendarId) => {
|
|
1432
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1433
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1434
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1435
|
+
return res.data.map(mapParticipantAuthorizationFromApi);
|
|
1436
|
+
}
|
|
1437
|
+
return null;
|
|
1438
|
+
};
|
|
1400
1439
|
CalendarModel.getMonth = async (calendarId, year, month) => {
|
|
1401
1440
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1402
1441
|
const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
|
|
@@ -2542,6 +2581,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2542
2581
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2543
2582
|
return { ok: true };
|
|
2544
2583
|
}
|
|
2584
|
+
function validateLeadUpdatePayload(payload) {
|
|
2585
|
+
const p = payload ?? {};
|
|
2586
|
+
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2587
|
+
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2588
|
+
const hasEmailKey = "email" in p || "Email" in p;
|
|
2589
|
+
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2590
|
+
if (hasEmailKey || hasPhoneKey) {
|
|
2591
|
+
const { email, phone } = pickLeadCreateContact(p);
|
|
2592
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2593
|
+
}
|
|
2594
|
+
return { ok: true };
|
|
2595
|
+
}
|
|
2545
2596
|
function mapLeadFromApi(d) {
|
|
2546
2597
|
if (!d) return d;
|
|
2547
2598
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2655,11 +2706,17 @@ var LeadModel = import_mobx_state_tree20.types.model("Lead", {
|
|
|
2655
2706
|
}
|
|
2656
2707
|
return res;
|
|
2657
2708
|
},
|
|
2658
|
-
/** POST /lead/update – update this lead */
|
|
2709
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2659
2710
|
async updateLead() {
|
|
2660
2711
|
if (!self.leadId || self.leadId === "new") {
|
|
2661
2712
|
return { status: "failure", message: "leadId required" };
|
|
2662
2713
|
}
|
|
2714
|
+
const validation = validateLeadUpdatePayload({
|
|
2715
|
+
leadId: self.leadId,
|
|
2716
|
+
email: self.email,
|
|
2717
|
+
phone: self.phone
|
|
2718
|
+
});
|
|
2719
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2663
2720
|
const payload = {
|
|
2664
2721
|
leadId: self.leadId,
|
|
2665
2722
|
email: self.email,
|
|
@@ -2804,6 +2861,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2804
2861
|
return null;
|
|
2805
2862
|
};
|
|
2806
2863
|
LeadModel.updateLead = async (payload) => {
|
|
2864
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2865
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2807
2866
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2808
2867
|
const res = await reqPost("/lead/update", payload);
|
|
2809
2868
|
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());
|
|
@@ -932,6 +933,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
|
|
|
932
933
|
}
|
|
933
934
|
return null;
|
|
934
935
|
};
|
|
936
|
+
CalendarParticipantModel.checkAuthorizationByCalendar = async (calendarId) => {
|
|
937
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
938
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
939
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
940
|
+
return res.data.map((p) => ({
|
|
941
|
+
participantId: String(p.participantId ?? p.ParticipantId ?? p.participant_id ?? ""),
|
|
942
|
+
isApproved: Boolean(p.isApproved ?? p.IsApproved ?? p.is_approved)
|
|
943
|
+
}));
|
|
944
|
+
}
|
|
945
|
+
return null;
|
|
946
|
+
};
|
|
935
947
|
CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
936
948
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
937
949
|
const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
|
|
@@ -1099,6 +1111,18 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
1099
1111
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1100
1112
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
1101
1113
|
},
|
|
1114
|
+
/**
|
|
1115
|
+
* GET Calendar/Participants/Authorization/Check
|
|
1116
|
+
* Validates OAuth for all calendar participants and updates isApproved in the database.
|
|
1117
|
+
*/
|
|
1118
|
+
async checkParticipantsAuthorization() {
|
|
1119
|
+
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1120
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: self.calendarId });
|
|
1121
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1122
|
+
res.data = res.data.map(mapParticipantAuthorizationFromApi);
|
|
1123
|
+
}
|
|
1124
|
+
return res;
|
|
1125
|
+
},
|
|
1102
1126
|
/** GET Calendar/All – calendars by company_key with paging options */
|
|
1103
1127
|
async getByCompany(companyKey, opts = {}) {
|
|
1104
1128
|
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
@@ -1213,6 +1237,13 @@ function mapCalendarFromApi(d) {
|
|
|
1213
1237
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1214
1238
|
};
|
|
1215
1239
|
}
|
|
1240
|
+
function mapParticipantAuthorizationFromApi(d) {
|
|
1241
|
+
if (!d) return d;
|
|
1242
|
+
return {
|
|
1243
|
+
participantId: String(d.participantId ?? d.ParticipantId ?? d.participant_id ?? ""),
|
|
1244
|
+
isApproved: Boolean(d.isApproved ?? d.IsApproved ?? d.is_approved)
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1216
1247
|
CalendarModel.getRaw = async (calendarId) => {
|
|
1217
1248
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1218
1249
|
return reqGet("/Calendar/Get", { calendar_id: calendarId });
|
|
@@ -1322,6 +1353,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
|
|
|
1322
1353
|
}
|
|
1323
1354
|
return null;
|
|
1324
1355
|
};
|
|
1356
|
+
CalendarModel.checkParticipantsAuthorization = async (calendarId) => {
|
|
1357
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1358
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1359
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1360
|
+
return res.data.map(mapParticipantAuthorizationFromApi);
|
|
1361
|
+
}
|
|
1362
|
+
return null;
|
|
1363
|
+
};
|
|
1325
1364
|
CalendarModel.getMonth = async (calendarId, year, month) => {
|
|
1326
1365
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1327
1366
|
const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
|
|
@@ -2467,6 +2506,18 @@ function validateLeadCreatePayload(payload) {
|
|
|
2467
2506
|
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2468
2507
|
return { ok: true };
|
|
2469
2508
|
}
|
|
2509
|
+
function validateLeadUpdatePayload(payload) {
|
|
2510
|
+
const p = payload ?? {};
|
|
2511
|
+
const leadId = String(p.leadId ?? p.lead_id ?? p.LeadId ?? "").trim();
|
|
2512
|
+
if (!leadId) return { ok: false, message: "leadId required" };
|
|
2513
|
+
const hasEmailKey = "email" in p || "Email" in p;
|
|
2514
|
+
const hasPhoneKey = "phone" in p || "Phone" in p;
|
|
2515
|
+
if (hasEmailKey || hasPhoneKey) {
|
|
2516
|
+
const { email, phone } = pickLeadCreateContact(p);
|
|
2517
|
+
if (!email && !phone) return { ok: false, message: "email or phone is required" };
|
|
2518
|
+
}
|
|
2519
|
+
return { ok: true };
|
|
2520
|
+
}
|
|
2470
2521
|
function mapLeadFromApi(d) {
|
|
2471
2522
|
if (!d) return d;
|
|
2472
2523
|
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
@@ -2580,11 +2631,17 @@ var LeadModel = types20.model("Lead", {
|
|
|
2580
2631
|
}
|
|
2581
2632
|
return res;
|
|
2582
2633
|
},
|
|
2583
|
-
/** POST /lead/update – update this lead */
|
|
2634
|
+
/** POST /lead/update – update this lead (requires email or phone) */
|
|
2584
2635
|
async updateLead() {
|
|
2585
2636
|
if (!self.leadId || self.leadId === "new") {
|
|
2586
2637
|
return { status: "failure", message: "leadId required" };
|
|
2587
2638
|
}
|
|
2639
|
+
const validation = validateLeadUpdatePayload({
|
|
2640
|
+
leadId: self.leadId,
|
|
2641
|
+
email: self.email,
|
|
2642
|
+
phone: self.phone
|
|
2643
|
+
});
|
|
2644
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2588
2645
|
const payload = {
|
|
2589
2646
|
leadId: self.leadId,
|
|
2590
2647
|
email: self.email,
|
|
@@ -2729,6 +2786,8 @@ LeadModel.createLead = async (payload) => {
|
|
|
2729
2786
|
return null;
|
|
2730
2787
|
};
|
|
2731
2788
|
LeadModel.updateLead = async (payload) => {
|
|
2789
|
+
const validation = validateLeadUpdatePayload(payload);
|
|
2790
|
+
if (!validation.ok) return { status: "failure", message: validation.message };
|
|
2732
2791
|
const { reqPost } = createRequestHelpersFromEnv(getConfig());
|
|
2733
2792
|
const res = await reqPost("/lead/update", payload);
|
|
2734
2793
|
if (res.status === "success" && res.data) {
|