@blazeo.com/calendar-client 1.0.8 → 1.0.10
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 +169 -146
- package/dist/index.js +391 -196
- package/dist/index.mjs +379 -184
- package/package.json +42 -42
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/models/appointment/Calendar.js
|
|
2
|
-
import { types as
|
|
2
|
+
import { types as types8, getEnv as getEnv2, applySnapshot as applySnapshot2 } from "mobx-state-tree";
|
|
3
3
|
|
|
4
4
|
// src/ConfigModel.js
|
|
5
5
|
import { types } from "mobx-state-tree";
|
|
@@ -173,7 +173,7 @@ var DayOfWeek = {
|
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
// src/models/appointment/Event.js
|
|
176
|
-
import { types as
|
|
176
|
+
import { types as types4, getEnv, applySnapshot } from "mobx-state-tree";
|
|
177
177
|
|
|
178
178
|
// src/models/appointment/TimeSlot.js
|
|
179
179
|
import { types as types2 } from "mobx-state-tree";
|
|
@@ -201,38 +201,92 @@ var TimeSlotModel = types2.model("TimeSlot", {
|
|
|
201
201
|
}));
|
|
202
202
|
var TimeSlot_default = TimeSlotModel;
|
|
203
203
|
|
|
204
|
+
// src/models/appointment/TimeFrame.js
|
|
205
|
+
import { types as types3 } from "mobx-state-tree";
|
|
206
|
+
var TimeFrameModel = types3.model("TimeFrame", {
|
|
207
|
+
start: types3.string,
|
|
208
|
+
end: types3.string
|
|
209
|
+
}).actions((self) => ({
|
|
210
|
+
buffer(bufferMinutes, unit) {
|
|
211
|
+
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
212
|
+
const s = new Date(self.start);
|
|
213
|
+
const e = new Date(self.end);
|
|
214
|
+
s.setMinutes(s.getMinutes() - bfr);
|
|
215
|
+
e.setMinutes(e.getMinutes() + bfr);
|
|
216
|
+
self.start = s.toISOString();
|
|
217
|
+
self.end = e.toISOString();
|
|
218
|
+
},
|
|
219
|
+
conflicts(start, end) {
|
|
220
|
+
const thisStart = new Date(self.start).getTime();
|
|
221
|
+
const thisEnd = new Date(self.end).getTime();
|
|
222
|
+
const startT = start.getTime();
|
|
223
|
+
const endT = end.getTime();
|
|
224
|
+
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
225
|
+
},
|
|
226
|
+
breakIntoSlots(slotDurationMinutes) {
|
|
227
|
+
const start = new Date(self.start);
|
|
228
|
+
const end = new Date(self.end);
|
|
229
|
+
const slots = [];
|
|
230
|
+
let current = new Date(start);
|
|
231
|
+
const align = (m) => {
|
|
232
|
+
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
233
|
+
if (m > 0 && m < 15) return 15;
|
|
234
|
+
if (m > 15 && m < 30) return 30;
|
|
235
|
+
if (m > 30 && m < 45) return 45;
|
|
236
|
+
return 0;
|
|
237
|
+
};
|
|
238
|
+
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
239
|
+
let slotEnd = new Date(current.getTime());
|
|
240
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
241
|
+
while (slotEnd.getTime() <= end.getTime()) {
|
|
242
|
+
slots.push({
|
|
243
|
+
startHour: current.getHours(),
|
|
244
|
+
startMinute: current.getMinutes(),
|
|
245
|
+
endHour: slotEnd.getHours(),
|
|
246
|
+
endMinute: slotEnd.getMinutes(),
|
|
247
|
+
startDate: current.toISOString(),
|
|
248
|
+
endDate: slotEnd.toISOString()
|
|
249
|
+
});
|
|
250
|
+
current = new Date(slotEnd.getTime());
|
|
251
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
252
|
+
}
|
|
253
|
+
return slots;
|
|
254
|
+
}
|
|
255
|
+
}));
|
|
256
|
+
var TimeFrame_default = TimeFrameModel;
|
|
257
|
+
|
|
204
258
|
// src/models/appointment/Event.js
|
|
205
259
|
function getDefaultOffset() {
|
|
206
260
|
var _a;
|
|
207
261
|
const cfg = getConfig();
|
|
208
262
|
return ((_a = cfg == null ? void 0 : cfg.getDefaultOffset) == null ? void 0 : _a.call(cfg)) ?? -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
209
263
|
}
|
|
210
|
-
var EventModel =
|
|
211
|
-
id:
|
|
212
|
-
eventId:
|
|
213
|
-
calendarId:
|
|
214
|
-
participantId:
|
|
215
|
-
title:
|
|
216
|
-
description:
|
|
217
|
-
isRecurring:
|
|
218
|
-
recurringFrequency:
|
|
219
|
-
startDate:
|
|
220
|
-
endDate:
|
|
221
|
-
startHour:
|
|
222
|
-
startMinute:
|
|
223
|
-
endHour:
|
|
224
|
-
endMinute:
|
|
225
|
-
visitorName:
|
|
226
|
-
visitorEmail:
|
|
227
|
-
visitorPhone:
|
|
228
|
-
createdOn:
|
|
229
|
-
modifiedOn:
|
|
230
|
-
externalEventId:
|
|
231
|
-
attendeeStatus:
|
|
232
|
-
rescheduleLink:
|
|
233
|
-
cancelLink:
|
|
234
|
-
timeZone:
|
|
235
|
-
offset:
|
|
264
|
+
var EventModel = types4.model("Event", {
|
|
265
|
+
id: types4.optional(types4.maybeNull(types4.number), null),
|
|
266
|
+
eventId: types4.identifier,
|
|
267
|
+
calendarId: types4.optional(types4.string, ""),
|
|
268
|
+
participantId: types4.optional(types4.maybeNull(types4.string), null),
|
|
269
|
+
title: types4.optional(types4.maybeNull(types4.string), null),
|
|
270
|
+
description: types4.optional(types4.maybeNull(types4.string), null),
|
|
271
|
+
isRecurring: types4.optional(types4.boolean, false),
|
|
272
|
+
recurringFrequency: types4.optional(types4.number, RecurringFrequency.None),
|
|
273
|
+
startDate: types4.optional(types4.string, ""),
|
|
274
|
+
endDate: types4.optional(types4.string, ""),
|
|
275
|
+
startHour: types4.optional(types4.number, 0),
|
|
276
|
+
startMinute: types4.optional(types4.number, 0),
|
|
277
|
+
endHour: types4.optional(types4.number, 0),
|
|
278
|
+
endMinute: types4.optional(types4.number, 0),
|
|
279
|
+
visitorName: types4.optional(types4.maybeNull(types4.string), null),
|
|
280
|
+
visitorEmail: types4.optional(types4.maybeNull(types4.string), null),
|
|
281
|
+
visitorPhone: types4.optional(types4.maybeNull(types4.string), null),
|
|
282
|
+
createdOn: types4.optional(types4.maybeNull(types4.string), null),
|
|
283
|
+
modifiedOn: types4.optional(types4.maybeNull(types4.string), null),
|
|
284
|
+
externalEventId: types4.optional(types4.maybeNull(types4.string), null),
|
|
285
|
+
attendeeStatus: types4.optional(types4.number, AttendeeStatus.Tentative),
|
|
286
|
+
rescheduleLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
287
|
+
cancelLink: types4.optional(types4.maybeNull(types4.string), null),
|
|
288
|
+
timeZone: types4.optional(types4.maybeNull(types4.string), null),
|
|
289
|
+
offset: types4.optional(types4.number, 0)
|
|
236
290
|
}).actions((self) => {
|
|
237
291
|
const { req, reqGet, reqPost } = createRequestHelpers(self, getEnv);
|
|
238
292
|
const getOffset = () => {
|
|
@@ -444,6 +498,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
444
498
|
}
|
|
445
499
|
return null;
|
|
446
500
|
};
|
|
501
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
502
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
503
|
+
const query = {
|
|
504
|
+
start_date_from: startDateFrom,
|
|
505
|
+
start_date_to: startDateTo
|
|
506
|
+
};
|
|
507
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
508
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
509
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
510
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
511
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
512
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
513
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
514
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
515
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
516
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
517
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
518
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
519
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
520
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
521
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
522
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
523
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
524
|
+
}
|
|
525
|
+
if (opts.page != null) {
|
|
526
|
+
query.page = opts.page;
|
|
527
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
528
|
+
} else {
|
|
529
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
530
|
+
if (opts.take != null) query.take = opts.take;
|
|
531
|
+
}
|
|
532
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
533
|
+
if (res.status !== "success") {
|
|
534
|
+
return { events: [], totalCount: 0 };
|
|
535
|
+
}
|
|
536
|
+
const payload = res.data ?? {};
|
|
537
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
538
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
539
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
540
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
541
|
+
return { events, totalCount };
|
|
542
|
+
};
|
|
447
543
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
448
544
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
449
545
|
const query = { calendar_id: calendarId, year, month, day };
|
|
@@ -463,6 +559,32 @@ EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) =>
|
|
|
463
559
|
}
|
|
464
560
|
return [];
|
|
465
561
|
};
|
|
562
|
+
EventModel.getExternalUnavailability = async (participantId, opts = {}) => {
|
|
563
|
+
if (!participantId) throw new Error("participantId required");
|
|
564
|
+
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
565
|
+
const query = { participant_id: participantId };
|
|
566
|
+
if (opts.startUtc && opts.endUtc) {
|
|
567
|
+
query.start_utc = opts.startUtc;
|
|
568
|
+
query.end_utc = opts.endUtc;
|
|
569
|
+
} else {
|
|
570
|
+
if (opts.year == null || opts.month == null || opts.day == null) {
|
|
571
|
+
throw new Error("Provide startUtc/endUtc or year/month/day");
|
|
572
|
+
}
|
|
573
|
+
query.year = opts.year;
|
|
574
|
+
query.month = opts.month;
|
|
575
|
+
query.day = opts.day;
|
|
576
|
+
if (opts.days != null) query.days = opts.days;
|
|
577
|
+
}
|
|
578
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
579
|
+
const res = await req("/externalcalendar/unavailability/get", { method: "GET", query, headers: { offset: String(offset) } });
|
|
580
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
581
|
+
return res.data.map((f) => TimeFrame_default.create({
|
|
582
|
+
start: f.start ?? f.Start,
|
|
583
|
+
end: f.end ?? f.End
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
return [];
|
|
587
|
+
};
|
|
466
588
|
EventModel.cancel = async (eventId) => {
|
|
467
589
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
468
590
|
return reqGet("/event/cancel", { event_id: eventId });
|
|
@@ -525,29 +647,29 @@ EventModel.setAttendeeStatus = async (eventId, attendeeStatus) => {
|
|
|
525
647
|
var Event_default = EventModel;
|
|
526
648
|
|
|
527
649
|
// src/models/appointment/CalendarParticipant.js
|
|
528
|
-
import { types as
|
|
650
|
+
import { types as types6 } from "mobx-state-tree";
|
|
529
651
|
|
|
530
652
|
// src/models/appointment/ParticipantInfo.js
|
|
531
|
-
import { types as
|
|
532
|
-
var ParticipantInfoModel =
|
|
533
|
-
participantId:
|
|
534
|
-
calendarParticipantId:
|
|
535
|
-
alias:
|
|
536
|
-
email:
|
|
537
|
-
isApproved:
|
|
538
|
-
emailProvider:
|
|
539
|
-
isAvailable:
|
|
653
|
+
import { types as types5 } from "mobx-state-tree";
|
|
654
|
+
var ParticipantInfoModel = types5.model("ParticipantInfo", {
|
|
655
|
+
participantId: types5.optional(types5.string, ""),
|
|
656
|
+
calendarParticipantId: types5.optional(types5.string, ""),
|
|
657
|
+
alias: types5.maybeNull(types5.string),
|
|
658
|
+
email: types5.maybeNull(types5.string),
|
|
659
|
+
isApproved: types5.optional(types5.boolean, false),
|
|
660
|
+
emailProvider: types5.optional(types5.number, 0),
|
|
661
|
+
isAvailable: types5.optional(types5.boolean, false)
|
|
540
662
|
});
|
|
541
663
|
var ParticipantInfo_default = ParticipantInfoModel;
|
|
542
664
|
|
|
543
665
|
// src/models/appointment/CalendarParticipant.js
|
|
544
|
-
var CalendarParticipantModel =
|
|
545
|
-
id:
|
|
546
|
-
calendarParticipantId:
|
|
547
|
-
participantId:
|
|
548
|
-
calendarId:
|
|
549
|
-
createdOn:
|
|
550
|
-
modifiedOn:
|
|
666
|
+
var CalendarParticipantModel = types6.model("CalendarParticipant", {
|
|
667
|
+
id: types6.optional(types6.maybeNull(types6.number), null),
|
|
668
|
+
calendarParticipantId: types6.optional(types6.string, ""),
|
|
669
|
+
participantId: types6.optional(types6.string, ""),
|
|
670
|
+
calendarId: types6.optional(types6.string, ""),
|
|
671
|
+
createdOn: types6.optional(types6.maybeNull(types6.string), null),
|
|
672
|
+
modifiedOn: types6.optional(types6.maybeNull(types6.string), null)
|
|
551
673
|
});
|
|
552
674
|
function mapFromApi(d) {
|
|
553
675
|
if (!d) return d;
|
|
@@ -600,36 +722,36 @@ CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
|
600
722
|
var CalendarParticipant_default = CalendarParticipantModel;
|
|
601
723
|
|
|
602
724
|
// src/models/appointment/CalendarDay.js
|
|
603
|
-
import { types as
|
|
604
|
-
var CalendarDayModel =
|
|
605
|
-
date:
|
|
725
|
+
import { types as types7 } from "mobx-state-tree";
|
|
726
|
+
var CalendarDayModel = types7.model("CalendarDay", {
|
|
727
|
+
date: types7.optional(types7.string, "")
|
|
606
728
|
});
|
|
607
729
|
var CalendarDay_default = CalendarDayModel;
|
|
608
730
|
|
|
609
731
|
// src/models/appointment/Calendar.js
|
|
610
|
-
var CalendarModel =
|
|
611
|
-
id:
|
|
612
|
-
companyKey:
|
|
613
|
-
calendarId:
|
|
614
|
-
name:
|
|
732
|
+
var CalendarModel = types8.model("Calendar", {
|
|
733
|
+
id: types8.maybeNull(types8.number),
|
|
734
|
+
companyKey: types8.maybeNull(types8.string),
|
|
735
|
+
calendarId: types8.optional(types8.identifier, "new"),
|
|
736
|
+
name: types8.maybeNull(types8.string),
|
|
615
737
|
// location: types.maybeNull(types.string),
|
|
616
|
-
timeZoneId:
|
|
617
|
-
purpose:
|
|
618
|
-
description:
|
|
619
|
-
assignmentMethod:
|
|
620
|
-
duration:
|
|
621
|
-
durationUnit:
|
|
622
|
-
minimumBookingNotice:
|
|
623
|
-
minimumBookingNoticeUnit:
|
|
624
|
-
minimumCancelationNotice:
|
|
625
|
-
minimumCancelationNoticeUnit:
|
|
626
|
-
futureLimit:
|
|
627
|
-
futureLimitUnit:
|
|
628
|
-
bufferTime:
|
|
629
|
-
bufferTimeUnit:
|
|
630
|
-
bookingLimit:
|
|
631
|
-
createdOn:
|
|
632
|
-
modifiedOn:
|
|
738
|
+
timeZoneId: types8.maybeNull(types8.string),
|
|
739
|
+
purpose: types8.optional(types8.string, ""),
|
|
740
|
+
description: types8.maybeNull(types8.string),
|
|
741
|
+
assignmentMethod: types8.optional(types8.number, AssignmentMethod.RoundRobin),
|
|
742
|
+
duration: types8.optional(types8.number, 0),
|
|
743
|
+
durationUnit: types8.optional(types8.number, Unit.Minutes),
|
|
744
|
+
minimumBookingNotice: types8.optional(types8.number, 0),
|
|
745
|
+
minimumBookingNoticeUnit: types8.optional(types8.number, Unit.Minutes),
|
|
746
|
+
minimumCancelationNotice: types8.optional(types8.number, 0),
|
|
747
|
+
minimumCancelationNoticeUnit: types8.optional(types8.number, Unit.Minutes),
|
|
748
|
+
futureLimit: types8.optional(types8.number, 0),
|
|
749
|
+
futureLimitUnit: types8.optional(types8.number, Unit.Days),
|
|
750
|
+
bufferTime: types8.optional(types8.number, 0),
|
|
751
|
+
bufferTimeUnit: types8.optional(types8.number, Unit.Minutes),
|
|
752
|
+
bookingLimit: types8.optional(types8.number, 0),
|
|
753
|
+
createdOn: types8.maybeNull(types8.string),
|
|
754
|
+
modifiedOn: types8.maybeNull(types8.string)
|
|
633
755
|
}).actions((self) => {
|
|
634
756
|
const { req, reqGet, reqPost } = createRequestHelpers(self, getEnv2);
|
|
635
757
|
return {
|
|
@@ -768,9 +890,25 @@ var CalendarModel = types7.model("Calendar", {
|
|
|
768
890
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
769
891
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
770
892
|
},
|
|
771
|
-
/** GET Calendar/All – calendars by company_key */
|
|
772
|
-
async getByCompany(companyKey) {
|
|
773
|
-
|
|
893
|
+
/** GET Calendar/All – calendars by company_key with paging options */
|
|
894
|
+
async getByCompany(companyKey, opts = {}) {
|
|
895
|
+
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
896
|
+
const q = { company_key: resolvedCompanyKey };
|
|
897
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
898
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
899
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
900
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
901
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
902
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
903
|
+
}
|
|
904
|
+
if (opts.page != null) {
|
|
905
|
+
q.page = opts.page;
|
|
906
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
907
|
+
} else {
|
|
908
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
909
|
+
if (opts.take != null) q.take = opts.take;
|
|
910
|
+
}
|
|
911
|
+
return reqGet("/Calendar/All", q);
|
|
774
912
|
},
|
|
775
913
|
/** GET Calendar/TimeZones/Get */
|
|
776
914
|
async getTimeZones() {
|
|
@@ -845,13 +983,34 @@ CalendarModel.get = async (calendarId) => {
|
|
|
845
983
|
}
|
|
846
984
|
return null;
|
|
847
985
|
};
|
|
848
|
-
CalendarModel.getByCompany = async (companyKey) => {
|
|
986
|
+
CalendarModel.getByCompany = async (companyKey, opts = {}) => {
|
|
987
|
+
var _a, _b, _c, _d;
|
|
849
988
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
989
|
+
const query = { company_key: companyKey };
|
|
990
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
991
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
992
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
993
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
994
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
995
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
996
|
+
}
|
|
997
|
+
if (opts.page != null) {
|
|
998
|
+
query.page = opts.page;
|
|
999
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
1000
|
+
} else {
|
|
1001
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
1002
|
+
if (opts.take != null) query.take = opts.take;
|
|
1003
|
+
}
|
|
1004
|
+
const res = await reqGet("/Calendar/All", query);
|
|
1005
|
+
if (res.status === "success") {
|
|
1006
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1007
|
+
if (calendarsRaw) {
|
|
1008
|
+
const calendars = calendarsRaw.map(
|
|
1009
|
+
(c) => CalendarModel.create(mapCalendarFromApi(c), { env: getConfig() })
|
|
1010
|
+
);
|
|
1011
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1012
|
+
return { calendars, totalCount };
|
|
1013
|
+
}
|
|
855
1014
|
}
|
|
856
1015
|
return null;
|
|
857
1016
|
};
|
|
@@ -971,52 +1130,52 @@ CalendarModel.editWithParticipants = async (calendarId, name, participantIds, de
|
|
|
971
1130
|
var Calendar_default = CalendarModel;
|
|
972
1131
|
|
|
973
1132
|
// src/models/appointment/Availability.js
|
|
974
|
-
import { types as types8 } from "mobx-state-tree";
|
|
975
|
-
var AvailabilityModel = types8.model("Availability", {
|
|
976
|
-
id: types8.maybeNull(types8.number),
|
|
977
|
-
availabilityId: types8.string,
|
|
978
|
-
calendarId: types8.string,
|
|
979
|
-
participantId: types8.string,
|
|
980
|
-
createdOn: types8.maybeNull(types8.string),
|
|
981
|
-
modifiedOn: types8.maybeNull(types8.string)
|
|
982
|
-
});
|
|
983
|
-
var Availability_default = AvailabilityModel;
|
|
984
|
-
|
|
985
|
-
// src/models/appointment/AvailabilityDetail.js
|
|
986
1133
|
import { types as types9 } from "mobx-state-tree";
|
|
987
|
-
var
|
|
1134
|
+
var AvailabilityModel = types9.model("Availability", {
|
|
988
1135
|
id: types9.maybeNull(types9.number),
|
|
989
1136
|
availabilityId: types9.string,
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
tuesday: types9.optional(types9.boolean, false),
|
|
993
|
-
wednesday: types9.optional(types9.boolean, false),
|
|
994
|
-
thursday: types9.optional(types9.boolean, false),
|
|
995
|
-
friday: types9.optional(types9.boolean, false),
|
|
996
|
-
saturday: types9.optional(types9.boolean, false),
|
|
997
|
-
startHour: types9.optional(types9.number, 0),
|
|
998
|
-
startMinute: types9.optional(types9.number, 0),
|
|
999
|
-
endHour: types9.optional(types9.number, 0),
|
|
1000
|
-
endMinute: types9.optional(types9.number, 0),
|
|
1137
|
+
calendarId: types9.string,
|
|
1138
|
+
participantId: types9.string,
|
|
1001
1139
|
createdOn: types9.maybeNull(types9.string),
|
|
1002
1140
|
modifiedOn: types9.maybeNull(types9.string)
|
|
1003
1141
|
});
|
|
1142
|
+
var Availability_default = AvailabilityModel;
|
|
1143
|
+
|
|
1144
|
+
// src/models/appointment/AvailabilityDetail.js
|
|
1145
|
+
import { types as types10 } from "mobx-state-tree";
|
|
1146
|
+
var AvailabilityDetailModel = types10.model("AvailabilityDetail", {
|
|
1147
|
+
id: types10.maybeNull(types10.number),
|
|
1148
|
+
availabilityId: types10.string,
|
|
1149
|
+
sunday: types10.optional(types10.boolean, false),
|
|
1150
|
+
monday: types10.optional(types10.boolean, false),
|
|
1151
|
+
tuesday: types10.optional(types10.boolean, false),
|
|
1152
|
+
wednesday: types10.optional(types10.boolean, false),
|
|
1153
|
+
thursday: types10.optional(types10.boolean, false),
|
|
1154
|
+
friday: types10.optional(types10.boolean, false),
|
|
1155
|
+
saturday: types10.optional(types10.boolean, false),
|
|
1156
|
+
startHour: types10.optional(types10.number, 0),
|
|
1157
|
+
startMinute: types10.optional(types10.number, 0),
|
|
1158
|
+
endHour: types10.optional(types10.number, 0),
|
|
1159
|
+
endMinute: types10.optional(types10.number, 0),
|
|
1160
|
+
createdOn: types10.maybeNull(types10.string),
|
|
1161
|
+
modifiedOn: types10.maybeNull(types10.string)
|
|
1162
|
+
});
|
|
1004
1163
|
var AvailabilityDetail_default = AvailabilityDetailModel;
|
|
1005
1164
|
|
|
1006
1165
|
// src/models/appointment/Participant.js
|
|
1007
|
-
import { types as
|
|
1008
|
-
var ParticipantModel =
|
|
1009
|
-
id:
|
|
1010
|
-
participantId:
|
|
1011
|
-
companyKey:
|
|
1012
|
-
alias:
|
|
1013
|
-
email:
|
|
1014
|
-
isApproved:
|
|
1015
|
-
isAvailable:
|
|
1016
|
-
provider:
|
|
1017
|
-
createdOn:
|
|
1018
|
-
modifiedOn:
|
|
1019
|
-
isDeleted:
|
|
1166
|
+
import { types as types11, getEnv as getEnv3, applySnapshot as applySnapshot3 } from "mobx-state-tree";
|
|
1167
|
+
var ParticipantModel = types11.model("Participant", {
|
|
1168
|
+
id: types11.optional(types11.maybeNull(types11.number), null),
|
|
1169
|
+
participantId: types11.identifier,
|
|
1170
|
+
companyKey: types11.optional(types11.maybeNull(types11.string), null),
|
|
1171
|
+
alias: types11.optional(types11.string, ""),
|
|
1172
|
+
email: types11.optional(types11.string, ""),
|
|
1173
|
+
isApproved: types11.optional(types11.boolean, false),
|
|
1174
|
+
isAvailable: types11.optional(types11.boolean, false),
|
|
1175
|
+
provider: types11.optional(types11.number, 0),
|
|
1176
|
+
createdOn: types11.optional(types11.maybeNull(types11.string), null),
|
|
1177
|
+
modifiedOn: types11.optional(types11.maybeNull(types11.string), null),
|
|
1178
|
+
isDeleted: types11.optional(types11.boolean, false)
|
|
1020
1179
|
}).actions((self) => {
|
|
1021
1180
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv3);
|
|
1022
1181
|
return {
|
|
@@ -1047,6 +1206,37 @@ var ParticipantModel = types10.model("Participant", {
|
|
|
1047
1206
|
/** GET participant/sendemail – send email to this participant */
|
|
1048
1207
|
async sendEmail() {
|
|
1049
1208
|
return reqGet("/participant/sendemail", { participant_id: self.participantId });
|
|
1209
|
+
},
|
|
1210
|
+
/** GET participant/calendars/get – calendars for this participant (paged) */
|
|
1211
|
+
async getCalendars(opts = {}) {
|
|
1212
|
+
var _a, _b, _c, _d;
|
|
1213
|
+
const q = { participant_id: self.participantId };
|
|
1214
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1215
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1216
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1217
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1218
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1219
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1220
|
+
}
|
|
1221
|
+
if (opts.page != null) {
|
|
1222
|
+
q.page = opts.page;
|
|
1223
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1224
|
+
} else {
|
|
1225
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1226
|
+
if (opts.take != null) q.take = opts.take;
|
|
1227
|
+
}
|
|
1228
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1229
|
+
if (res.status === "success") {
|
|
1230
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1231
|
+
if (calendarsRaw) {
|
|
1232
|
+
const calendars = calendarsRaw.map(
|
|
1233
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1234
|
+
);
|
|
1235
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1236
|
+
return { calendars, totalCount };
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
return null;
|
|
1050
1240
|
}
|
|
1051
1241
|
};
|
|
1052
1242
|
});
|
|
@@ -1078,6 +1268,34 @@ function toPayload(self) {
|
|
|
1078
1268
|
provider: self.provider
|
|
1079
1269
|
};
|
|
1080
1270
|
}
|
|
1271
|
+
function mapCalendarFromApi2(d) {
|
|
1272
|
+
if (!d) return d;
|
|
1273
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
1274
|
+
const n = (v) => v != null && v !== "" ? Number(v) : void 0;
|
|
1275
|
+
return {
|
|
1276
|
+
id: pick("id", "Id"),
|
|
1277
|
+
companyKey: pick("companyKey", "CompanyKey", "company_key") ?? null,
|
|
1278
|
+
calendarId: String(pick("calendarId", "CalendarId", "calendar_id") ?? ""),
|
|
1279
|
+
name: pick("name", "Name") ?? null,
|
|
1280
|
+
timeZoneId: pick("timeZoneId", "TimeZoneId", "time_zone_id") ?? null,
|
|
1281
|
+
purpose: pick("purpose", "Purpose") ?? "",
|
|
1282
|
+
description: pick("description", "Description") ?? null,
|
|
1283
|
+
assignmentMethod: n(pick("assignmentMethod", "AssignmentMethod", "assignment_method")) ?? void 0,
|
|
1284
|
+
duration: n(pick("duration", "Duration")) ?? void 0,
|
|
1285
|
+
durationUnit: n(pick("durationUnit", "DurationUnit", "duration_unit")) ?? void 0,
|
|
1286
|
+
minimumBookingNotice: n(pick("minimumBookingNotice", "MinimumBookingNotice", "minimum_booking_notice")) ?? void 0,
|
|
1287
|
+
minimumBookingNoticeUnit: n(pick("minimumBookingNoticeUnit", "MinimumBookingNoticeUnit", "minimum_booking_notice_unit")) ?? void 0,
|
|
1288
|
+
minimumCancelationNotice: n(pick("minimumCancelationNotice", "MinimumCancelationNotice", "minimum_cancelation_notice")) ?? void 0,
|
|
1289
|
+
minimumCancelationNoticeUnit: n(pick("minimumCancelationNoticeUnit", "MinimumCancelationNoticeUnit", "minimum_cancelation_notice_unit")) ?? void 0,
|
|
1290
|
+
futureLimit: n(pick("futureLimit", "FutureLimit", "future_limit")) ?? void 0,
|
|
1291
|
+
futureLimitUnit: n(pick("futureLimitUnit", "FutureLimitUnit", "future_limit_unit")) ?? void 0,
|
|
1292
|
+
bufferTime: n(pick("bufferTime", "BufferTime", "buffer_time")) ?? void 0,
|
|
1293
|
+
bufferTimeUnit: n(pick("bufferTimeUnit", "BufferTimeUnit", "buffer_time_unit")) ?? void 0,
|
|
1294
|
+
bookingLimit: n(pick("bookingLimit", "BookingLimit", "booking_limit")) ?? void 0,
|
|
1295
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1296
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1081
1299
|
ParticipantModel.get = async (participantId) => {
|
|
1082
1300
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1083
1301
|
const res = await reqGet("/participant/get", { participant_id: participantId });
|
|
@@ -1132,80 +1350,57 @@ ParticipantModel.sendEmail = async (participantId) => {
|
|
|
1132
1350
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1133
1351
|
return reqGet("/participant/sendemail", { participant_id: participantId });
|
|
1134
1352
|
};
|
|
1353
|
+
ParticipantModel.getCalendars = async (participantId, opts = {}) => {
|
|
1354
|
+
var _a, _b, _c, _d;
|
|
1355
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1356
|
+
const q = { participant_id: participantId };
|
|
1357
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1358
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1359
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1360
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1361
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1362
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1363
|
+
}
|
|
1364
|
+
if (opts.page != null) {
|
|
1365
|
+
q.page = opts.page;
|
|
1366
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1367
|
+
} else {
|
|
1368
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1369
|
+
if (opts.take != null) q.take = opts.take;
|
|
1370
|
+
}
|
|
1371
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1372
|
+
if (res.status === "success") {
|
|
1373
|
+
const calendarsRaw = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.Calendars) ? res.data.Calendars : Array.isArray((_b = res.data) == null ? void 0 : _b.calendars) ? res.data.calendars : null;
|
|
1374
|
+
if (calendarsRaw) {
|
|
1375
|
+
const calendars = calendarsRaw.map(
|
|
1376
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1377
|
+
);
|
|
1378
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1379
|
+
return { calendars, totalCount };
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return null;
|
|
1383
|
+
};
|
|
1135
1384
|
var Participant_default = ParticipantModel;
|
|
1136
1385
|
|
|
1137
1386
|
// src/models/appointment/OpeningHour.js
|
|
1138
|
-
import { types as
|
|
1139
|
-
var OpeningHourModel =
|
|
1140
|
-
id:
|
|
1141
|
-
openingHourId:
|
|
1142
|
-
calendarId:
|
|
1143
|
-
participantId:
|
|
1144
|
-
day:
|
|
1145
|
-
startHour:
|
|
1146
|
-
startMinute:
|
|
1147
|
-
endHour:
|
|
1148
|
-
endMinute:
|
|
1149
|
-
off:
|
|
1150
|
-
createdOn:
|
|
1151
|
-
modifiedOn:
|
|
1387
|
+
import { types as types12 } from "mobx-state-tree";
|
|
1388
|
+
var OpeningHourModel = types12.model("OpeningHour", {
|
|
1389
|
+
id: types12.maybeNull(types12.number),
|
|
1390
|
+
openingHourId: types12.optional(types12.string, ""),
|
|
1391
|
+
calendarId: types12.string,
|
|
1392
|
+
participantId: types12.string,
|
|
1393
|
+
day: types12.optional(types12.number, 0),
|
|
1394
|
+
startHour: types12.optional(types12.number, 0),
|
|
1395
|
+
startMinute: types12.optional(types12.number, 0),
|
|
1396
|
+
endHour: types12.optional(types12.number, 0),
|
|
1397
|
+
endMinute: types12.optional(types12.number, 0),
|
|
1398
|
+
off: types12.optional(types12.boolean, false),
|
|
1399
|
+
createdOn: types12.maybeNull(types12.string),
|
|
1400
|
+
modifiedOn: types12.maybeNull(types12.string)
|
|
1152
1401
|
});
|
|
1153
1402
|
var OpeningHour_default = OpeningHourModel;
|
|
1154
1403
|
|
|
1155
|
-
// src/models/appointment/TimeFrame.js
|
|
1156
|
-
import { types as types12 } from "mobx-state-tree";
|
|
1157
|
-
var TimeFrameModel = types12.model("TimeFrame", {
|
|
1158
|
-
start: types12.string,
|
|
1159
|
-
end: types12.string
|
|
1160
|
-
}).actions((self) => ({
|
|
1161
|
-
buffer(bufferMinutes, unit) {
|
|
1162
|
-
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
1163
|
-
const s = new Date(self.start);
|
|
1164
|
-
const e = new Date(self.end);
|
|
1165
|
-
s.setMinutes(s.getMinutes() - bfr);
|
|
1166
|
-
e.setMinutes(e.getMinutes() + bfr);
|
|
1167
|
-
self.start = s.toISOString();
|
|
1168
|
-
self.end = e.toISOString();
|
|
1169
|
-
},
|
|
1170
|
-
conflicts(start, end) {
|
|
1171
|
-
const thisStart = new Date(self.start).getTime();
|
|
1172
|
-
const thisEnd = new Date(self.end).getTime();
|
|
1173
|
-
const startT = start.getTime();
|
|
1174
|
-
const endT = end.getTime();
|
|
1175
|
-
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
1176
|
-
},
|
|
1177
|
-
breakIntoSlots(slotDurationMinutes) {
|
|
1178
|
-
const start = new Date(self.start);
|
|
1179
|
-
const end = new Date(self.end);
|
|
1180
|
-
const slots = [];
|
|
1181
|
-
let current = new Date(start);
|
|
1182
|
-
const align = (m) => {
|
|
1183
|
-
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
1184
|
-
if (m > 0 && m < 15) return 15;
|
|
1185
|
-
if (m > 15 && m < 30) return 30;
|
|
1186
|
-
if (m > 30 && m < 45) return 45;
|
|
1187
|
-
return 0;
|
|
1188
|
-
};
|
|
1189
|
-
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
1190
|
-
let slotEnd = new Date(current.getTime());
|
|
1191
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1192
|
-
while (slotEnd.getTime() <= end.getTime()) {
|
|
1193
|
-
slots.push({
|
|
1194
|
-
startHour: current.getHours(),
|
|
1195
|
-
startMinute: current.getMinutes(),
|
|
1196
|
-
endHour: slotEnd.getHours(),
|
|
1197
|
-
endMinute: slotEnd.getMinutes(),
|
|
1198
|
-
startDate: current.toISOString(),
|
|
1199
|
-
endDate: slotEnd.toISOString()
|
|
1200
|
-
});
|
|
1201
|
-
current = new Date(slotEnd.getTime());
|
|
1202
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1203
|
-
}
|
|
1204
|
-
return slots;
|
|
1205
|
-
}
|
|
1206
|
-
}));
|
|
1207
|
-
var TimeFrame_default = TimeFrameModel;
|
|
1208
|
-
|
|
1209
1404
|
// src/models/appointment/Setting.js
|
|
1210
1405
|
import { types as types13, getEnv as getEnv4, applySnapshot as applySnapshot4 } from "mobx-state-tree";
|
|
1211
1406
|
var SettingModel = types13.model("Setting", {
|