@blazeo.com/calendar-client 1.0.48 → 1.0.50
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 +9 -2
- package/dist/index.js +47 -6
- package/dist/index.mjs +47 -6
- 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>;
|
|
@@ -106,8 +112,8 @@ export type LeadCompanyResult = {
|
|
|
106
112
|
};
|
|
107
113
|
|
|
108
114
|
export const EventModel: {
|
|
109
|
-
get(eventId: string): Promise<unknown>;
|
|
110
|
-
getByExternalId(externalEventId: string): Promise<unknown>;
|
|
115
|
+
get(eventId: string, opts?: { offset?: number }): Promise<unknown>;
|
|
116
|
+
getByExternalId(externalEventId: string, opts?: { offset?: number }): Promise<unknown>;
|
|
111
117
|
getByDateRangeWithFilters(
|
|
112
118
|
companyKey: string,
|
|
113
119
|
startDateFrom: string,
|
|
@@ -167,6 +173,7 @@ export const AvailabilityDetailModel: { create(snapshot: object, options?: { env
|
|
|
167
173
|
export const CalendarParticipantModel: {
|
|
168
174
|
getByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
169
175
|
getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
|
|
176
|
+
checkAuthorizationByCalendar(calendarId: string): Promise<ParticipantAuthorizationStatus[] | null>;
|
|
170
177
|
getByParticipant(participantId: string): Promise<unknown[] | null>;
|
|
171
178
|
create(snapshot: object, options?: { env?: object }): unknown;
|
|
172
179
|
};
|
package/dist/index.js
CHANGED
|
@@ -521,13 +521,14 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
|
521
521
|
return {
|
|
522
522
|
/** GET /event/get – fetch this event by eventId or externalEventId */
|
|
523
523
|
async get(params) {
|
|
524
|
+
const offset = (params == null ? void 0 : params.offset) ?? getOffset();
|
|
524
525
|
if ((params == null ? void 0 : params.eventId) ?? (params == null ? void 0 : params.event_id)) {
|
|
525
|
-
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id });
|
|
526
|
+
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id }, { headers: { offset: String(offset) } });
|
|
526
527
|
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
527
528
|
return res;
|
|
528
529
|
}
|
|
529
530
|
if ((params == null ? void 0 : params.externalEventId) ?? (params == null ? void 0 : params.externalevent_id)) {
|
|
530
|
-
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id });
|
|
531
|
+
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id }, { headers: { offset: String(offset) } });
|
|
531
532
|
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
532
533
|
return res;
|
|
533
534
|
}
|
|
@@ -704,17 +705,19 @@ function mapEventFromApi(d) {
|
|
|
704
705
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
705
706
|
};
|
|
706
707
|
}
|
|
707
|
-
EventModel.get = async (eventId) => {
|
|
708
|
+
EventModel.get = async (eventId, opts = {}) => {
|
|
708
709
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
709
|
-
const
|
|
710
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
711
|
+
const res = await reqGet("/event/get", { event_id: eventId }, { headers: { offset: String(offset) } });
|
|
710
712
|
if (res.status === "success" && res.data) {
|
|
711
713
|
return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
|
|
712
714
|
}
|
|
713
715
|
return null;
|
|
714
716
|
};
|
|
715
|
-
EventModel.getByExternalId = async (externalEventId) => {
|
|
717
|
+
EventModel.getByExternalId = async (externalEventId, opts = {}) => {
|
|
716
718
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
717
|
-
const
|
|
719
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
720
|
+
const res = await reqGet("/event/get", { externalevent_id: externalEventId }, { headers: { offset: String(offset) } });
|
|
718
721
|
if (res.status === "success" && res.data) {
|
|
719
722
|
return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
|
|
720
723
|
}
|
|
@@ -1008,6 +1011,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
|
|
|
1008
1011
|
}
|
|
1009
1012
|
return null;
|
|
1010
1013
|
};
|
|
1014
|
+
CalendarParticipantModel.checkAuthorizationByCalendar = async (calendarId) => {
|
|
1015
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1016
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1017
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1018
|
+
return res.data.map((p) => ({
|
|
1019
|
+
participantId: String(p.participantId ?? p.ParticipantId ?? p.participant_id ?? ""),
|
|
1020
|
+
isApproved: Boolean(p.isApproved ?? p.IsApproved ?? p.is_approved)
|
|
1021
|
+
}));
|
|
1022
|
+
}
|
|
1023
|
+
return null;
|
|
1024
|
+
};
|
|
1011
1025
|
CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
1012
1026
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1013
1027
|
const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
|
|
@@ -1175,6 +1189,18 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
|
1175
1189
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1176
1190
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
1177
1191
|
},
|
|
1192
|
+
/**
|
|
1193
|
+
* GET Calendar/Participants/Authorization/Check
|
|
1194
|
+
* Validates OAuth for all calendar participants and updates isApproved in the database.
|
|
1195
|
+
*/
|
|
1196
|
+
async checkParticipantsAuthorization() {
|
|
1197
|
+
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1198
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: self.calendarId });
|
|
1199
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1200
|
+
res.data = res.data.map(mapParticipantAuthorizationFromApi);
|
|
1201
|
+
}
|
|
1202
|
+
return res;
|
|
1203
|
+
},
|
|
1178
1204
|
/** GET Calendar/All – calendars by company_key with paging options */
|
|
1179
1205
|
async getByCompany(companyKey, opts = {}) {
|
|
1180
1206
|
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
@@ -1289,6 +1315,13 @@ function mapCalendarFromApi(d) {
|
|
|
1289
1315
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1290
1316
|
};
|
|
1291
1317
|
}
|
|
1318
|
+
function mapParticipantAuthorizationFromApi(d) {
|
|
1319
|
+
if (!d) return d;
|
|
1320
|
+
return {
|
|
1321
|
+
participantId: String(d.participantId ?? d.ParticipantId ?? d.participant_id ?? ""),
|
|
1322
|
+
isApproved: Boolean(d.isApproved ?? d.IsApproved ?? d.is_approved)
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1292
1325
|
CalendarModel.getRaw = async (calendarId) => {
|
|
1293
1326
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1294
1327
|
return reqGet("/Calendar/Get", { calendar_id: calendarId });
|
|
@@ -1398,6 +1431,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
|
|
|
1398
1431
|
}
|
|
1399
1432
|
return null;
|
|
1400
1433
|
};
|
|
1434
|
+
CalendarModel.checkParticipantsAuthorization = async (calendarId) => {
|
|
1435
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1436
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1437
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1438
|
+
return res.data.map(mapParticipantAuthorizationFromApi);
|
|
1439
|
+
}
|
|
1440
|
+
return null;
|
|
1441
|
+
};
|
|
1401
1442
|
CalendarModel.getMonth = async (calendarId, year, month) => {
|
|
1402
1443
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1403
1444
|
const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
|
package/dist/index.mjs
CHANGED
|
@@ -446,13 +446,14 @@ var EventModel = types4.model("Event", {
|
|
|
446
446
|
return {
|
|
447
447
|
/** GET /event/get – fetch this event by eventId or externalEventId */
|
|
448
448
|
async get(params) {
|
|
449
|
+
const offset = (params == null ? void 0 : params.offset) ?? getOffset();
|
|
449
450
|
if ((params == null ? void 0 : params.eventId) ?? (params == null ? void 0 : params.event_id)) {
|
|
450
|
-
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id });
|
|
451
|
+
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id }, { headers: { offset: String(offset) } });
|
|
451
452
|
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, eventId: self.eventId });
|
|
452
453
|
return res;
|
|
453
454
|
}
|
|
454
455
|
if ((params == null ? void 0 : params.externalEventId) ?? (params == null ? void 0 : params.externalevent_id)) {
|
|
455
|
-
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id });
|
|
456
|
+
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id }, { headers: { offset: String(offset) } });
|
|
456
457
|
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, eventId: self.eventId });
|
|
457
458
|
return res;
|
|
458
459
|
}
|
|
@@ -629,17 +630,19 @@ function mapEventFromApi(d) {
|
|
|
629
630
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
630
631
|
};
|
|
631
632
|
}
|
|
632
|
-
EventModel.get = async (eventId) => {
|
|
633
|
+
EventModel.get = async (eventId, opts = {}) => {
|
|
633
634
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
634
|
-
const
|
|
635
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
636
|
+
const res = await reqGet("/event/get", { event_id: eventId }, { headers: { offset: String(offset) } });
|
|
635
637
|
if (res.status === "success" && res.data) {
|
|
636
638
|
return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
|
|
637
639
|
}
|
|
638
640
|
return null;
|
|
639
641
|
};
|
|
640
|
-
EventModel.getByExternalId = async (externalEventId) => {
|
|
642
|
+
EventModel.getByExternalId = async (externalEventId, opts = {}) => {
|
|
641
643
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
642
|
-
const
|
|
644
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
645
|
+
const res = await reqGet("/event/get", { externalevent_id: externalEventId }, { headers: { offset: String(offset) } });
|
|
643
646
|
if (res.status === "success" && res.data) {
|
|
644
647
|
return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
|
|
645
648
|
}
|
|
@@ -933,6 +936,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
|
|
|
933
936
|
}
|
|
934
937
|
return null;
|
|
935
938
|
};
|
|
939
|
+
CalendarParticipantModel.checkAuthorizationByCalendar = async (calendarId) => {
|
|
940
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
941
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
942
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
943
|
+
return res.data.map((p) => ({
|
|
944
|
+
participantId: String(p.participantId ?? p.ParticipantId ?? p.participant_id ?? ""),
|
|
945
|
+
isApproved: Boolean(p.isApproved ?? p.IsApproved ?? p.is_approved)
|
|
946
|
+
}));
|
|
947
|
+
}
|
|
948
|
+
return null;
|
|
949
|
+
};
|
|
936
950
|
CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
937
951
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
938
952
|
const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
|
|
@@ -1100,6 +1114,18 @@ var CalendarModel = types8.model("Calendar", {
|
|
|
1100
1114
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1101
1115
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
1102
1116
|
},
|
|
1117
|
+
/**
|
|
1118
|
+
* GET Calendar/Participants/Authorization/Check
|
|
1119
|
+
* Validates OAuth for all calendar participants and updates isApproved in the database.
|
|
1120
|
+
*/
|
|
1121
|
+
async checkParticipantsAuthorization() {
|
|
1122
|
+
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
1123
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: self.calendarId });
|
|
1124
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1125
|
+
res.data = res.data.map(mapParticipantAuthorizationFromApi);
|
|
1126
|
+
}
|
|
1127
|
+
return res;
|
|
1128
|
+
},
|
|
1103
1129
|
/** GET Calendar/All – calendars by company_key with paging options */
|
|
1104
1130
|
async getByCompany(companyKey, opts = {}) {
|
|
1105
1131
|
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
@@ -1214,6 +1240,13 @@ function mapCalendarFromApi(d) {
|
|
|
1214
1240
|
modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
|
|
1215
1241
|
};
|
|
1216
1242
|
}
|
|
1243
|
+
function mapParticipantAuthorizationFromApi(d) {
|
|
1244
|
+
if (!d) return d;
|
|
1245
|
+
return {
|
|
1246
|
+
participantId: String(d.participantId ?? d.ParticipantId ?? d.participant_id ?? ""),
|
|
1247
|
+
isApproved: Boolean(d.isApproved ?? d.IsApproved ?? d.is_approved)
|
|
1248
|
+
};
|
|
1249
|
+
}
|
|
1217
1250
|
CalendarModel.getRaw = async (calendarId) => {
|
|
1218
1251
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1219
1252
|
return reqGet("/Calendar/Get", { calendar_id: calendarId });
|
|
@@ -1323,6 +1356,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
|
|
|
1323
1356
|
}
|
|
1324
1357
|
return null;
|
|
1325
1358
|
};
|
|
1359
|
+
CalendarModel.checkParticipantsAuthorization = async (calendarId) => {
|
|
1360
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1361
|
+
const res = await reqGet("/Calendar/Participants/Authorization/Check", { calendar_id: calendarId });
|
|
1362
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
1363
|
+
return res.data.map(mapParticipantAuthorizationFromApi);
|
|
1364
|
+
}
|
|
1365
|
+
return null;
|
|
1366
|
+
};
|
|
1326
1367
|
CalendarModel.getMonth = async (calendarId, year, month) => {
|
|
1327
1368
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1328
1369
|
const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
|