@blazeo.com/calendar-client 1.0.48 → 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 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>;
@@ -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
@@ -1008,6 +1008,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
1008
1008
  }
1009
1009
  return null;
1010
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
+ };
1011
1022
  CalendarParticipantModel.getByParticipant = async (participantId) => {
1012
1023
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1013
1024
  const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
@@ -1175,6 +1186,18 @@ var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
1175
1186
  if (!self.calendarId) return { status: "failure", message: "calendarId required" };
1176
1187
  return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
1177
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
+ },
1178
1201
  /** GET Calendar/All – calendars by company_key with paging options */
1179
1202
  async getByCompany(companyKey, opts = {}) {
1180
1203
  const resolvedCompanyKey = companyKey || self.companyKey;
@@ -1289,6 +1312,13 @@ function mapCalendarFromApi(d) {
1289
1312
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
1290
1313
  };
1291
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
+ }
1292
1322
  CalendarModel.getRaw = async (calendarId) => {
1293
1323
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1294
1324
  return reqGet("/Calendar/Get", { calendar_id: calendarId });
@@ -1398,6 +1428,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
1398
1428
  }
1399
1429
  return null;
1400
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
+ };
1401
1439
  CalendarModel.getMonth = async (calendarId, year, month) => {
1402
1440
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1403
1441
  const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
package/dist/index.mjs CHANGED
@@ -933,6 +933,17 @@ CalendarParticipantModel.getInfoByCalendar = async (calendarId) => {
933
933
  }
934
934
  return null;
935
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
+ };
936
947
  CalendarParticipantModel.getByParticipant = async (participantId) => {
937
948
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
938
949
  const res = await reqGet("/Participant/calendar/get", { participant_id: participantId });
@@ -1100,6 +1111,18 @@ var CalendarModel = types8.model("Calendar", {
1100
1111
  if (!self.calendarId) return { status: "failure", message: "calendarId required" };
1101
1112
  return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
1102
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
+ },
1103
1126
  /** GET Calendar/All – calendars by company_key with paging options */
1104
1127
  async getByCompany(companyKey, opts = {}) {
1105
1128
  const resolvedCompanyKey = companyKey || self.companyKey;
@@ -1214,6 +1237,13 @@ function mapCalendarFromApi(d) {
1214
1237
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on")
1215
1238
  };
1216
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
+ }
1217
1247
  CalendarModel.getRaw = async (calendarId) => {
1218
1248
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1219
1249
  return reqGet("/Calendar/Get", { calendar_id: calendarId });
@@ -1323,6 +1353,14 @@ CalendarModel.getParticipantsInfo = async (calendarId) => {
1323
1353
  }
1324
1354
  return null;
1325
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
+ };
1326
1364
  CalendarModel.getMonth = async (calendarId, year, month) => {
1327
1365
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1328
1366
  const res = await reqGet("/Calendar/Month/Get", { calendar_id: calendarId, year, month });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {