@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.js
CHANGED
|
@@ -52,7 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
module.exports = __toCommonJS(index_exports);
|
|
53
53
|
|
|
54
54
|
// src/models/appointment/Calendar.js
|
|
55
|
-
var
|
|
55
|
+
var import_mobx_state_tree8 = require("mobx-state-tree");
|
|
56
56
|
|
|
57
57
|
// src/ConfigModel.js
|
|
58
58
|
var import_mobx_state_tree = require("mobx-state-tree");
|
|
@@ -226,7 +226,7 @@ var DayOfWeek = {
|
|
|
226
226
|
};
|
|
227
227
|
|
|
228
228
|
// src/models/appointment/Event.js
|
|
229
|
-
var
|
|
229
|
+
var import_mobx_state_tree4 = require("mobx-state-tree");
|
|
230
230
|
|
|
231
231
|
// src/models/appointment/TimeSlot.js
|
|
232
232
|
var import_mobx_state_tree2 = require("mobx-state-tree");
|
|
@@ -254,55 +254,109 @@ var TimeSlotModel = import_mobx_state_tree2.types.model("TimeSlot", {
|
|
|
254
254
|
}));
|
|
255
255
|
var TimeSlot_default = TimeSlotModel;
|
|
256
256
|
|
|
257
|
+
// src/models/appointment/TimeFrame.js
|
|
258
|
+
var import_mobx_state_tree3 = require("mobx-state-tree");
|
|
259
|
+
var TimeFrameModel = import_mobx_state_tree3.types.model("TimeFrame", {
|
|
260
|
+
start: import_mobx_state_tree3.types.string,
|
|
261
|
+
end: import_mobx_state_tree3.types.string
|
|
262
|
+
}).actions((self) => ({
|
|
263
|
+
buffer(bufferMinutes, unit) {
|
|
264
|
+
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
265
|
+
const s = new Date(self.start);
|
|
266
|
+
const e = new Date(self.end);
|
|
267
|
+
s.setMinutes(s.getMinutes() - bfr);
|
|
268
|
+
e.setMinutes(e.getMinutes() + bfr);
|
|
269
|
+
self.start = s.toISOString();
|
|
270
|
+
self.end = e.toISOString();
|
|
271
|
+
},
|
|
272
|
+
conflicts(start, end) {
|
|
273
|
+
const thisStart = new Date(self.start).getTime();
|
|
274
|
+
const thisEnd = new Date(self.end).getTime();
|
|
275
|
+
const startT = start.getTime();
|
|
276
|
+
const endT = end.getTime();
|
|
277
|
+
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
278
|
+
},
|
|
279
|
+
breakIntoSlots(slotDurationMinutes) {
|
|
280
|
+
const start = new Date(self.start);
|
|
281
|
+
const end = new Date(self.end);
|
|
282
|
+
const slots = [];
|
|
283
|
+
let current = new Date(start);
|
|
284
|
+
const align = (m) => {
|
|
285
|
+
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
286
|
+
if (m > 0 && m < 15) return 15;
|
|
287
|
+
if (m > 15 && m < 30) return 30;
|
|
288
|
+
if (m > 30 && m < 45) return 45;
|
|
289
|
+
return 0;
|
|
290
|
+
};
|
|
291
|
+
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
292
|
+
let slotEnd = new Date(current.getTime());
|
|
293
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
294
|
+
while (slotEnd.getTime() <= end.getTime()) {
|
|
295
|
+
slots.push({
|
|
296
|
+
startHour: current.getHours(),
|
|
297
|
+
startMinute: current.getMinutes(),
|
|
298
|
+
endHour: slotEnd.getHours(),
|
|
299
|
+
endMinute: slotEnd.getMinutes(),
|
|
300
|
+
startDate: current.toISOString(),
|
|
301
|
+
endDate: slotEnd.toISOString()
|
|
302
|
+
});
|
|
303
|
+
current = new Date(slotEnd.getTime());
|
|
304
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
305
|
+
}
|
|
306
|
+
return slots;
|
|
307
|
+
}
|
|
308
|
+
}));
|
|
309
|
+
var TimeFrame_default = TimeFrameModel;
|
|
310
|
+
|
|
257
311
|
// src/models/appointment/Event.js
|
|
258
312
|
function getDefaultOffset() {
|
|
259
313
|
var _a;
|
|
260
314
|
const cfg = getConfig();
|
|
261
315
|
return ((_a = cfg == null ? void 0 : cfg.getDefaultOffset) == null ? void 0 : _a.call(cfg)) ?? -(/* @__PURE__ */ new Date()).getTimezoneOffset();
|
|
262
316
|
}
|
|
263
|
-
var EventModel =
|
|
264
|
-
id:
|
|
265
|
-
eventId:
|
|
266
|
-
calendarId:
|
|
267
|
-
participantId:
|
|
268
|
-
title:
|
|
269
|
-
description:
|
|
270
|
-
isRecurring:
|
|
271
|
-
recurringFrequency:
|
|
272
|
-
startDate:
|
|
273
|
-
endDate:
|
|
274
|
-
startHour:
|
|
275
|
-
startMinute:
|
|
276
|
-
endHour:
|
|
277
|
-
endMinute:
|
|
278
|
-
visitorName:
|
|
279
|
-
visitorEmail:
|
|
280
|
-
visitorPhone:
|
|
281
|
-
createdOn:
|
|
282
|
-
modifiedOn:
|
|
283
|
-
externalEventId:
|
|
284
|
-
attendeeStatus:
|
|
285
|
-
rescheduleLink:
|
|
286
|
-
cancelLink:
|
|
287
|
-
timeZone:
|
|
288
|
-
offset:
|
|
317
|
+
var EventModel = import_mobx_state_tree4.types.model("Event", {
|
|
318
|
+
id: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.number), null),
|
|
319
|
+
eventId: import_mobx_state_tree4.types.identifier,
|
|
320
|
+
calendarId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
321
|
+
participantId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
322
|
+
title: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
323
|
+
description: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
324
|
+
isRecurring: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.boolean, false),
|
|
325
|
+
recurringFrequency: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, RecurringFrequency.None),
|
|
326
|
+
startDate: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
327
|
+
endDate: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.string, ""),
|
|
328
|
+
startHour: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
329
|
+
startMinute: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
330
|
+
endHour: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
331
|
+
endMinute: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0),
|
|
332
|
+
visitorName: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
333
|
+
visitorEmail: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
334
|
+
visitorPhone: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
335
|
+
createdOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
336
|
+
modifiedOn: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
337
|
+
externalEventId: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
338
|
+
attendeeStatus: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, AttendeeStatus.Tentative),
|
|
339
|
+
rescheduleLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
340
|
+
cancelLink: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
341
|
+
timeZone: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.maybeNull(import_mobx_state_tree4.types.string), null),
|
|
342
|
+
offset: import_mobx_state_tree4.types.optional(import_mobx_state_tree4.types.number, 0)
|
|
289
343
|
}).actions((self) => {
|
|
290
|
-
const { req, reqGet, reqPost } = createRequestHelpers(self,
|
|
344
|
+
const { req, reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree4.getEnv);
|
|
291
345
|
const getOffset = () => {
|
|
292
346
|
var _a, _b;
|
|
293
|
-
return ((_b = (_a = (0,
|
|
347
|
+
return ((_b = (_a = (0, import_mobx_state_tree4.getEnv)(self)).getDefaultOffset) == null ? void 0 : _b.call(_a)) ?? getDefaultOffset();
|
|
294
348
|
};
|
|
295
349
|
return {
|
|
296
350
|
/** GET /event/get – fetch this event by eventId or externalEventId */
|
|
297
351
|
async get(params) {
|
|
298
352
|
if ((params == null ? void 0 : params.eventId) ?? (params == null ? void 0 : params.event_id)) {
|
|
299
353
|
const res = await reqGet("/event/get", { event_id: params.eventId ?? params.event_id });
|
|
300
|
-
if (res.status === "success" && res.data) (0,
|
|
354
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
301
355
|
return res;
|
|
302
356
|
}
|
|
303
357
|
if ((params == null ? void 0 : params.externalEventId) ?? (params == null ? void 0 : params.externalevent_id)) {
|
|
304
358
|
const res = await reqGet("/event/get", { externalevent_id: params.externalEventId ?? params.externalevent_id });
|
|
305
|
-
if (res.status === "success" && res.data) (0,
|
|
359
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
306
360
|
return res;
|
|
307
361
|
}
|
|
308
362
|
return { status: "failure", message: "Provide eventId or externalEventId" };
|
|
@@ -326,7 +380,7 @@ var EventModel = import_mobx_state_tree3.types.model("Event", {
|
|
|
326
380
|
visitorPhone: self.visitorPhone ?? void 0
|
|
327
381
|
};
|
|
328
382
|
const res = await reqPost("/event/create", payload, null, { headers: { offset: String(offset) } });
|
|
329
|
-
if (res.status === "success" && res.data) (0,
|
|
383
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
330
384
|
return res;
|
|
331
385
|
},
|
|
332
386
|
/** POST /event/update – update event */
|
|
@@ -369,7 +423,7 @@ var EventModel = import_mobx_state_tree3.types.model("Event", {
|
|
|
369
423
|
visitorPhone: self.visitorPhone ?? void 0
|
|
370
424
|
};
|
|
371
425
|
const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
|
|
372
|
-
if (res.status === "success" && res.data) (0,
|
|
426
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
|
|
373
427
|
return res;
|
|
374
428
|
},
|
|
375
429
|
/** GET /event/cancel – cancel this event */
|
|
@@ -497,6 +551,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
497
551
|
}
|
|
498
552
|
return null;
|
|
499
553
|
};
|
|
554
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
555
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
556
|
+
const query = {
|
|
557
|
+
start_date_from: startDateFrom,
|
|
558
|
+
start_date_to: startDateTo
|
|
559
|
+
};
|
|
560
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
561
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
562
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
563
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
564
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
565
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
566
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
567
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
568
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
569
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
570
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
571
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
572
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
573
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
574
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
575
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
576
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
577
|
+
}
|
|
578
|
+
if (opts.page != null) {
|
|
579
|
+
query.page = opts.page;
|
|
580
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
581
|
+
} else {
|
|
582
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
583
|
+
if (opts.take != null) query.take = opts.take;
|
|
584
|
+
}
|
|
585
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
586
|
+
if (res.status !== "success") {
|
|
587
|
+
return { events: [], totalCount: 0 };
|
|
588
|
+
}
|
|
589
|
+
const payload = res.data ?? {};
|
|
590
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
591
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
592
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
593
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
594
|
+
return { events, totalCount };
|
|
595
|
+
};
|
|
500
596
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
501
597
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
502
598
|
const query = { calendar_id: calendarId, year, month, day };
|
|
@@ -516,6 +612,32 @@ EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) =>
|
|
|
516
612
|
}
|
|
517
613
|
return [];
|
|
518
614
|
};
|
|
615
|
+
EventModel.getExternalUnavailability = async (participantId, opts = {}) => {
|
|
616
|
+
if (!participantId) throw new Error("participantId required");
|
|
617
|
+
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
618
|
+
const query = { participant_id: participantId };
|
|
619
|
+
if (opts.startUtc && opts.endUtc) {
|
|
620
|
+
query.start_utc = opts.startUtc;
|
|
621
|
+
query.end_utc = opts.endUtc;
|
|
622
|
+
} else {
|
|
623
|
+
if (opts.year == null || opts.month == null || opts.day == null) {
|
|
624
|
+
throw new Error("Provide startUtc/endUtc or year/month/day");
|
|
625
|
+
}
|
|
626
|
+
query.year = opts.year;
|
|
627
|
+
query.month = opts.month;
|
|
628
|
+
query.day = opts.day;
|
|
629
|
+
if (opts.days != null) query.days = opts.days;
|
|
630
|
+
}
|
|
631
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
632
|
+
const res = await req("/externalcalendar/unavailability/get", { method: "GET", query, headers: { offset: String(offset) } });
|
|
633
|
+
if (res.status === "success" && Array.isArray(res.data)) {
|
|
634
|
+
return res.data.map((f) => TimeFrame_default.create({
|
|
635
|
+
start: f.start ?? f.Start,
|
|
636
|
+
end: f.end ?? f.End
|
|
637
|
+
}));
|
|
638
|
+
}
|
|
639
|
+
return [];
|
|
640
|
+
};
|
|
519
641
|
EventModel.cancel = async (eventId) => {
|
|
520
642
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
521
643
|
return reqGet("/event/cancel", { event_id: eventId });
|
|
@@ -578,29 +700,29 @@ EventModel.setAttendeeStatus = async (eventId, attendeeStatus) => {
|
|
|
578
700
|
var Event_default = EventModel;
|
|
579
701
|
|
|
580
702
|
// src/models/appointment/CalendarParticipant.js
|
|
581
|
-
var
|
|
703
|
+
var import_mobx_state_tree6 = require("mobx-state-tree");
|
|
582
704
|
|
|
583
705
|
// src/models/appointment/ParticipantInfo.js
|
|
584
|
-
var
|
|
585
|
-
var ParticipantInfoModel =
|
|
586
|
-
participantId:
|
|
587
|
-
calendarParticipantId:
|
|
588
|
-
alias:
|
|
589
|
-
email:
|
|
590
|
-
isApproved:
|
|
591
|
-
emailProvider:
|
|
592
|
-
isAvailable:
|
|
706
|
+
var import_mobx_state_tree5 = require("mobx-state-tree");
|
|
707
|
+
var ParticipantInfoModel = import_mobx_state_tree5.types.model("ParticipantInfo", {
|
|
708
|
+
participantId: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.string, ""),
|
|
709
|
+
calendarParticipantId: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.string, ""),
|
|
710
|
+
alias: import_mobx_state_tree5.types.maybeNull(import_mobx_state_tree5.types.string),
|
|
711
|
+
email: import_mobx_state_tree5.types.maybeNull(import_mobx_state_tree5.types.string),
|
|
712
|
+
isApproved: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.boolean, false),
|
|
713
|
+
emailProvider: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.number, 0),
|
|
714
|
+
isAvailable: import_mobx_state_tree5.types.optional(import_mobx_state_tree5.types.boolean, false)
|
|
593
715
|
});
|
|
594
716
|
var ParticipantInfo_default = ParticipantInfoModel;
|
|
595
717
|
|
|
596
718
|
// src/models/appointment/CalendarParticipant.js
|
|
597
|
-
var CalendarParticipantModel =
|
|
598
|
-
id:
|
|
599
|
-
calendarParticipantId:
|
|
600
|
-
participantId:
|
|
601
|
-
calendarId:
|
|
602
|
-
createdOn:
|
|
603
|
-
modifiedOn:
|
|
719
|
+
var CalendarParticipantModel = import_mobx_state_tree6.types.model("CalendarParticipant", {
|
|
720
|
+
id: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.number), null),
|
|
721
|
+
calendarParticipantId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
722
|
+
participantId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
723
|
+
calendarId: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.string, ""),
|
|
724
|
+
createdOn: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.string), null),
|
|
725
|
+
modifiedOn: import_mobx_state_tree6.types.optional(import_mobx_state_tree6.types.maybeNull(import_mobx_state_tree6.types.string), null)
|
|
604
726
|
});
|
|
605
727
|
function mapFromApi(d) {
|
|
606
728
|
if (!d) return d;
|
|
@@ -653,45 +775,45 @@ CalendarParticipantModel.getByParticipant = async (participantId) => {
|
|
|
653
775
|
var CalendarParticipant_default = CalendarParticipantModel;
|
|
654
776
|
|
|
655
777
|
// src/models/appointment/CalendarDay.js
|
|
656
|
-
var
|
|
657
|
-
var CalendarDayModel =
|
|
658
|
-
date:
|
|
778
|
+
var import_mobx_state_tree7 = require("mobx-state-tree");
|
|
779
|
+
var CalendarDayModel = import_mobx_state_tree7.types.model("CalendarDay", {
|
|
780
|
+
date: import_mobx_state_tree7.types.optional(import_mobx_state_tree7.types.string, "")
|
|
659
781
|
});
|
|
660
782
|
var CalendarDay_default = CalendarDayModel;
|
|
661
783
|
|
|
662
784
|
// src/models/appointment/Calendar.js
|
|
663
|
-
var CalendarModel =
|
|
664
|
-
id:
|
|
665
|
-
companyKey:
|
|
666
|
-
calendarId:
|
|
667
|
-
name:
|
|
785
|
+
var CalendarModel = import_mobx_state_tree8.types.model("Calendar", {
|
|
786
|
+
id: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.number),
|
|
787
|
+
companyKey: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
788
|
+
calendarId: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.identifier, "new"),
|
|
789
|
+
name: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
668
790
|
// location: types.maybeNull(types.string),
|
|
669
|
-
timeZoneId:
|
|
670
|
-
purpose:
|
|
671
|
-
description:
|
|
672
|
-
assignmentMethod:
|
|
673
|
-
duration:
|
|
674
|
-
durationUnit:
|
|
675
|
-
minimumBookingNotice:
|
|
676
|
-
minimumBookingNoticeUnit:
|
|
677
|
-
minimumCancelationNotice:
|
|
678
|
-
minimumCancelationNoticeUnit:
|
|
679
|
-
futureLimit:
|
|
680
|
-
futureLimitUnit:
|
|
681
|
-
bufferTime:
|
|
682
|
-
bufferTimeUnit:
|
|
683
|
-
bookingLimit:
|
|
684
|
-
createdOn:
|
|
685
|
-
modifiedOn:
|
|
791
|
+
timeZoneId: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
792
|
+
purpose: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.string, ""),
|
|
793
|
+
description: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
794
|
+
assignmentMethod: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, AssignmentMethod.RoundRobin),
|
|
795
|
+
duration: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
796
|
+
durationUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
797
|
+
minimumBookingNotice: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
798
|
+
minimumBookingNoticeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
799
|
+
minimumCancelationNotice: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
800
|
+
minimumCancelationNoticeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
801
|
+
futureLimit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
802
|
+
futureLimitUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Days),
|
|
803
|
+
bufferTime: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
804
|
+
bufferTimeUnit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, Unit.Minutes),
|
|
805
|
+
bookingLimit: import_mobx_state_tree8.types.optional(import_mobx_state_tree8.types.number, 0),
|
|
806
|
+
createdOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
807
|
+
modifiedOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string)
|
|
686
808
|
}).actions((self) => {
|
|
687
|
-
const { req, reqGet, reqPost } = createRequestHelpers(self,
|
|
809
|
+
const { req, reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree8.getEnv);
|
|
688
810
|
return {
|
|
689
811
|
/** GET Calendar/Get – fetch this calendar by calendarId */
|
|
690
812
|
async get() {
|
|
691
813
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
692
814
|
const res = await reqGet("/Calendar/Get", { calendar_id: self.calendarId });
|
|
693
815
|
if (res.status === "success" && res.data) {
|
|
694
|
-
(0,
|
|
816
|
+
(0, import_mobx_state_tree8.applySnapshot)(self, { ...res.data, calendarId: self.calendarId });
|
|
695
817
|
}
|
|
696
818
|
return res;
|
|
697
819
|
},
|
|
@@ -821,9 +943,25 @@ var CalendarModel = import_mobx_state_tree7.types.model("Calendar", {
|
|
|
821
943
|
if (!self.calendarId) return { status: "failure", message: "calendarId required" };
|
|
822
944
|
return reqGet("/Calendar/Participants/GetInfo", { calendar_id: self.calendarId });
|
|
823
945
|
},
|
|
824
|
-
/** GET Calendar/All – calendars by company_key */
|
|
825
|
-
async getByCompany(companyKey) {
|
|
826
|
-
|
|
946
|
+
/** GET Calendar/All – calendars by company_key with paging options */
|
|
947
|
+
async getByCompany(companyKey, opts = {}) {
|
|
948
|
+
const resolvedCompanyKey = companyKey || self.companyKey;
|
|
949
|
+
const q = { company_key: resolvedCompanyKey };
|
|
950
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
951
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
952
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
953
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
954
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
955
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
956
|
+
}
|
|
957
|
+
if (opts.page != null) {
|
|
958
|
+
q.page = opts.page;
|
|
959
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
960
|
+
} else {
|
|
961
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
962
|
+
if (opts.take != null) q.take = opts.take;
|
|
963
|
+
}
|
|
964
|
+
return reqGet("/Calendar/All", q);
|
|
827
965
|
},
|
|
828
966
|
/** GET Calendar/TimeZones/Get */
|
|
829
967
|
async getTimeZones() {
|
|
@@ -898,13 +1036,34 @@ CalendarModel.get = async (calendarId) => {
|
|
|
898
1036
|
}
|
|
899
1037
|
return null;
|
|
900
1038
|
};
|
|
901
|
-
CalendarModel.getByCompany = async (companyKey) => {
|
|
1039
|
+
CalendarModel.getByCompany = async (companyKey, opts = {}) => {
|
|
1040
|
+
var _a, _b, _c, _d;
|
|
902
1041
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
1042
|
+
const query = { company_key: companyKey };
|
|
1043
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1044
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
1045
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1046
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1047
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1048
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1049
|
+
}
|
|
1050
|
+
if (opts.page != null) {
|
|
1051
|
+
query.page = opts.page;
|
|
1052
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
1053
|
+
} else {
|
|
1054
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
1055
|
+
if (opts.take != null) query.take = opts.take;
|
|
1056
|
+
}
|
|
1057
|
+
const res = await reqGet("/Calendar/All", query);
|
|
1058
|
+
if (res.status === "success") {
|
|
1059
|
+
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;
|
|
1060
|
+
if (calendarsRaw) {
|
|
1061
|
+
const calendars = calendarsRaw.map(
|
|
1062
|
+
(c) => CalendarModel.create(mapCalendarFromApi(c), { env: getConfig() })
|
|
1063
|
+
);
|
|
1064
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1065
|
+
return { calendars, totalCount };
|
|
1066
|
+
}
|
|
908
1067
|
}
|
|
909
1068
|
return null;
|
|
910
1069
|
};
|
|
@@ -1024,73 +1183,73 @@ CalendarModel.editWithParticipants = async (calendarId, name, participantIds, de
|
|
|
1024
1183
|
var Calendar_default = CalendarModel;
|
|
1025
1184
|
|
|
1026
1185
|
// src/models/appointment/Availability.js
|
|
1027
|
-
var import_mobx_state_tree8 = require("mobx-state-tree");
|
|
1028
|
-
var AvailabilityModel = import_mobx_state_tree8.types.model("Availability", {
|
|
1029
|
-
id: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.number),
|
|
1030
|
-
availabilityId: import_mobx_state_tree8.types.string,
|
|
1031
|
-
calendarId: import_mobx_state_tree8.types.string,
|
|
1032
|
-
participantId: import_mobx_state_tree8.types.string,
|
|
1033
|
-
createdOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string),
|
|
1034
|
-
modifiedOn: import_mobx_state_tree8.types.maybeNull(import_mobx_state_tree8.types.string)
|
|
1035
|
-
});
|
|
1036
|
-
var Availability_default = AvailabilityModel;
|
|
1037
|
-
|
|
1038
|
-
// src/models/appointment/AvailabilityDetail.js
|
|
1039
1186
|
var import_mobx_state_tree9 = require("mobx-state-tree");
|
|
1040
|
-
var
|
|
1187
|
+
var AvailabilityModel = import_mobx_state_tree9.types.model("Availability", {
|
|
1041
1188
|
id: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.number),
|
|
1042
1189
|
availabilityId: import_mobx_state_tree9.types.string,
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
tuesday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1046
|
-
wednesday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1047
|
-
thursday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1048
|
-
friday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1049
|
-
saturday: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.boolean, false),
|
|
1050
|
-
startHour: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1051
|
-
startMinute: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1052
|
-
endHour: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1053
|
-
endMinute: import_mobx_state_tree9.types.optional(import_mobx_state_tree9.types.number, 0),
|
|
1190
|
+
calendarId: import_mobx_state_tree9.types.string,
|
|
1191
|
+
participantId: import_mobx_state_tree9.types.string,
|
|
1054
1192
|
createdOn: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.string),
|
|
1055
1193
|
modifiedOn: import_mobx_state_tree9.types.maybeNull(import_mobx_state_tree9.types.string)
|
|
1056
1194
|
});
|
|
1195
|
+
var Availability_default = AvailabilityModel;
|
|
1196
|
+
|
|
1197
|
+
// src/models/appointment/AvailabilityDetail.js
|
|
1198
|
+
var import_mobx_state_tree10 = require("mobx-state-tree");
|
|
1199
|
+
var AvailabilityDetailModel = import_mobx_state_tree10.types.model("AvailabilityDetail", {
|
|
1200
|
+
id: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.number),
|
|
1201
|
+
availabilityId: import_mobx_state_tree10.types.string,
|
|
1202
|
+
sunday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1203
|
+
monday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1204
|
+
tuesday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1205
|
+
wednesday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1206
|
+
thursday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1207
|
+
friday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1208
|
+
saturday: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.boolean, false),
|
|
1209
|
+
startHour: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1210
|
+
startMinute: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1211
|
+
endHour: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1212
|
+
endMinute: import_mobx_state_tree10.types.optional(import_mobx_state_tree10.types.number, 0),
|
|
1213
|
+
createdOn: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.string),
|
|
1214
|
+
modifiedOn: import_mobx_state_tree10.types.maybeNull(import_mobx_state_tree10.types.string)
|
|
1215
|
+
});
|
|
1057
1216
|
var AvailabilityDetail_default = AvailabilityDetailModel;
|
|
1058
1217
|
|
|
1059
1218
|
// src/models/appointment/Participant.js
|
|
1060
|
-
var
|
|
1061
|
-
var ParticipantModel =
|
|
1062
|
-
id:
|
|
1063
|
-
participantId:
|
|
1064
|
-
companyKey:
|
|
1065
|
-
alias:
|
|
1066
|
-
email:
|
|
1067
|
-
isApproved:
|
|
1068
|
-
isAvailable:
|
|
1069
|
-
provider:
|
|
1070
|
-
createdOn:
|
|
1071
|
-
modifiedOn:
|
|
1072
|
-
isDeleted:
|
|
1219
|
+
var import_mobx_state_tree11 = require("mobx-state-tree");
|
|
1220
|
+
var ParticipantModel = import_mobx_state_tree11.types.model("Participant", {
|
|
1221
|
+
id: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.number), null),
|
|
1222
|
+
participantId: import_mobx_state_tree11.types.identifier,
|
|
1223
|
+
companyKey: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1224
|
+
alias: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.string, ""),
|
|
1225
|
+
email: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.string, ""),
|
|
1226
|
+
isApproved: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false),
|
|
1227
|
+
isAvailable: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false),
|
|
1228
|
+
provider: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.number, 0),
|
|
1229
|
+
createdOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1230
|
+
modifiedOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
|
|
1231
|
+
isDeleted: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false)
|
|
1073
1232
|
}).actions((self) => {
|
|
1074
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
1233
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree11.getEnv);
|
|
1075
1234
|
return {
|
|
1076
1235
|
/** GET participant/get – fetch this participant */
|
|
1077
1236
|
async get() {
|
|
1078
1237
|
const res = await reqGet("/participant/get", { participant_id: self.participantId });
|
|
1079
|
-
if (res.status === "success" && res.data) (0,
|
|
1238
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1080
1239
|
return res;
|
|
1081
1240
|
},
|
|
1082
1241
|
/** POST participant/save – save participant (add or update) */
|
|
1083
1242
|
async save() {
|
|
1084
1243
|
const payload = toPayload(self);
|
|
1085
1244
|
const res = await reqPost("/participant/save", payload);
|
|
1086
|
-
if (res.status === "success" && res.data) (0,
|
|
1245
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1087
1246
|
return res;
|
|
1088
1247
|
},
|
|
1089
1248
|
/** POST participant/update – update participant */
|
|
1090
1249
|
async update() {
|
|
1091
1250
|
const payload = toPayload(self);
|
|
1092
1251
|
const res = await reqPost("/participant/update", payload);
|
|
1093
|
-
if (res.status === "success" && res.data) (0,
|
|
1252
|
+
if (res.status === "success" && res.data) (0, import_mobx_state_tree11.applySnapshot)(self, mapFromApi2(res.data));
|
|
1094
1253
|
return res;
|
|
1095
1254
|
},
|
|
1096
1255
|
/** GET participant/remove – remove this participant */
|
|
@@ -1100,6 +1259,37 @@ var ParticipantModel = import_mobx_state_tree10.types.model("Participant", {
|
|
|
1100
1259
|
/** GET participant/sendemail – send email to this participant */
|
|
1101
1260
|
async sendEmail() {
|
|
1102
1261
|
return reqGet("/participant/sendemail", { participant_id: self.participantId });
|
|
1262
|
+
},
|
|
1263
|
+
/** GET participant/calendars/get – calendars for this participant (paged) */
|
|
1264
|
+
async getCalendars(opts = {}) {
|
|
1265
|
+
var _a, _b, _c, _d;
|
|
1266
|
+
const q = { participant_id: self.participantId };
|
|
1267
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1268
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1269
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1270
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1271
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1272
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1273
|
+
}
|
|
1274
|
+
if (opts.page != null) {
|
|
1275
|
+
q.page = opts.page;
|
|
1276
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1277
|
+
} else {
|
|
1278
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1279
|
+
if (opts.take != null) q.take = opts.take;
|
|
1280
|
+
}
|
|
1281
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1282
|
+
if (res.status === "success") {
|
|
1283
|
+
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;
|
|
1284
|
+
if (calendarsRaw) {
|
|
1285
|
+
const calendars = calendarsRaw.map(
|
|
1286
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1287
|
+
);
|
|
1288
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1289
|
+
return { calendars, totalCount };
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
return null;
|
|
1103
1293
|
}
|
|
1104
1294
|
};
|
|
1105
1295
|
});
|
|
@@ -1131,6 +1321,34 @@ function toPayload(self) {
|
|
|
1131
1321
|
provider: self.provider
|
|
1132
1322
|
};
|
|
1133
1323
|
}
|
|
1324
|
+
function mapCalendarFromApi2(d) {
|
|
1325
|
+
if (!d) return d;
|
|
1326
|
+
const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
1327
|
+
const n = (v) => v != null && v !== "" ? Number(v) : void 0;
|
|
1328
|
+
return {
|
|
1329
|
+
id: pick("id", "Id"),
|
|
1330
|
+
companyKey: pick("companyKey", "CompanyKey", "company_key") ?? null,
|
|
1331
|
+
calendarId: String(pick("calendarId", "CalendarId", "calendar_id") ?? ""),
|
|
1332
|
+
name: pick("name", "Name") ?? null,
|
|
1333
|
+
timeZoneId: pick("timeZoneId", "TimeZoneId", "time_zone_id") ?? null,
|
|
1334
|
+
purpose: pick("purpose", "Purpose") ?? "",
|
|
1335
|
+
description: pick("description", "Description") ?? null,
|
|
1336
|
+
assignmentMethod: n(pick("assignmentMethod", "AssignmentMethod", "assignment_method")) ?? void 0,
|
|
1337
|
+
duration: n(pick("duration", "Duration")) ?? void 0,
|
|
1338
|
+
durationUnit: n(pick("durationUnit", "DurationUnit", "duration_unit")) ?? void 0,
|
|
1339
|
+
minimumBookingNotice: n(pick("minimumBookingNotice", "MinimumBookingNotice", "minimum_booking_notice")) ?? void 0,
|
|
1340
|
+
minimumBookingNoticeUnit: n(pick("minimumBookingNoticeUnit", "MinimumBookingNoticeUnit", "minimum_booking_notice_unit")) ?? void 0,
|
|
1341
|
+
minimumCancelationNotice: n(pick("minimumCancelationNotice", "MinimumCancelationNotice", "minimum_cancelation_notice")) ?? void 0,
|
|
1342
|
+
minimumCancelationNoticeUnit: n(pick("minimumCancelationNoticeUnit", "MinimumCancelationNoticeUnit", "minimum_cancelation_notice_unit")) ?? void 0,
|
|
1343
|
+
futureLimit: n(pick("futureLimit", "FutureLimit", "future_limit")) ?? void 0,
|
|
1344
|
+
futureLimitUnit: n(pick("futureLimitUnit", "FutureLimitUnit", "future_limit_unit")) ?? void 0,
|
|
1345
|
+
bufferTime: n(pick("bufferTime", "BufferTime", "buffer_time")) ?? void 0,
|
|
1346
|
+
bufferTimeUnit: n(pick("bufferTimeUnit", "BufferTimeUnit", "buffer_time_unit")) ?? void 0,
|
|
1347
|
+
bookingLimit: n(pick("bookingLimit", "BookingLimit", "booking_limit")) ?? void 0,
|
|
1348
|
+
createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
|
|
1349
|
+
modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
|
|
1350
|
+
};
|
|
1351
|
+
}
|
|
1134
1352
|
ParticipantModel.get = async (participantId) => {
|
|
1135
1353
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1136
1354
|
const res = await reqGet("/participant/get", { participant_id: participantId });
|
|
@@ -1185,80 +1403,57 @@ ParticipantModel.sendEmail = async (participantId) => {
|
|
|
1185
1403
|
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1186
1404
|
return reqGet("/participant/sendemail", { participant_id: participantId });
|
|
1187
1405
|
};
|
|
1406
|
+
ParticipantModel.getCalendars = async (participantId, opts = {}) => {
|
|
1407
|
+
var _a, _b, _c, _d;
|
|
1408
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
1409
|
+
const q = { participant_id: participantId };
|
|
1410
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
1411
|
+
if (sortBy != null && sortBy !== "") q.sort = sortBy;
|
|
1412
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
1413
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
1414
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
1415
|
+
q.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
1416
|
+
}
|
|
1417
|
+
if (opts.page != null) {
|
|
1418
|
+
q.page = opts.page;
|
|
1419
|
+
if (opts.page_size != null) q.page_size = opts.page_size;
|
|
1420
|
+
} else {
|
|
1421
|
+
if (opts.skip != null) q.skip = opts.skip;
|
|
1422
|
+
if (opts.take != null) q.take = opts.take;
|
|
1423
|
+
}
|
|
1424
|
+
const res = await reqGet("/participant/calendars/get", q);
|
|
1425
|
+
if (res.status === "success") {
|
|
1426
|
+
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;
|
|
1427
|
+
if (calendarsRaw) {
|
|
1428
|
+
const calendars = calendarsRaw.map(
|
|
1429
|
+
(c) => Calendar_default.create(mapCalendarFromApi2(c), { env: getConfig() })
|
|
1430
|
+
);
|
|
1431
|
+
const totalCount = Number(((_c = res.data) == null ? void 0 : _c.TotalCount) ?? ((_d = res.data) == null ? void 0 : _d.totalCount) ?? calendars.length);
|
|
1432
|
+
return { calendars, totalCount };
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1435
|
+
return null;
|
|
1436
|
+
};
|
|
1188
1437
|
var Participant_default = ParticipantModel;
|
|
1189
1438
|
|
|
1190
1439
|
// src/models/appointment/OpeningHour.js
|
|
1191
|
-
var
|
|
1192
|
-
var OpeningHourModel =
|
|
1193
|
-
id:
|
|
1194
|
-
openingHourId:
|
|
1195
|
-
calendarId:
|
|
1196
|
-
participantId:
|
|
1197
|
-
day:
|
|
1198
|
-
startHour:
|
|
1199
|
-
startMinute:
|
|
1200
|
-
endHour:
|
|
1201
|
-
endMinute:
|
|
1202
|
-
off:
|
|
1203
|
-
createdOn:
|
|
1204
|
-
modifiedOn:
|
|
1440
|
+
var import_mobx_state_tree12 = require("mobx-state-tree");
|
|
1441
|
+
var OpeningHourModel = import_mobx_state_tree12.types.model("OpeningHour", {
|
|
1442
|
+
id: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.number),
|
|
1443
|
+
openingHourId: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.string, ""),
|
|
1444
|
+
calendarId: import_mobx_state_tree12.types.string,
|
|
1445
|
+
participantId: import_mobx_state_tree12.types.string,
|
|
1446
|
+
day: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1447
|
+
startHour: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1448
|
+
startMinute: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1449
|
+
endHour: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1450
|
+
endMinute: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.number, 0),
|
|
1451
|
+
off: import_mobx_state_tree12.types.optional(import_mobx_state_tree12.types.boolean, false),
|
|
1452
|
+
createdOn: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.string),
|
|
1453
|
+
modifiedOn: import_mobx_state_tree12.types.maybeNull(import_mobx_state_tree12.types.string)
|
|
1205
1454
|
});
|
|
1206
1455
|
var OpeningHour_default = OpeningHourModel;
|
|
1207
1456
|
|
|
1208
|
-
// src/models/appointment/TimeFrame.js
|
|
1209
|
-
var import_mobx_state_tree12 = require("mobx-state-tree");
|
|
1210
|
-
var TimeFrameModel = import_mobx_state_tree12.types.model("TimeFrame", {
|
|
1211
|
-
start: import_mobx_state_tree12.types.string,
|
|
1212
|
-
end: import_mobx_state_tree12.types.string
|
|
1213
|
-
}).actions((self) => ({
|
|
1214
|
-
buffer(bufferMinutes, unit) {
|
|
1215
|
-
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
1216
|
-
const s = new Date(self.start);
|
|
1217
|
-
const e = new Date(self.end);
|
|
1218
|
-
s.setMinutes(s.getMinutes() - bfr);
|
|
1219
|
-
e.setMinutes(e.getMinutes() + bfr);
|
|
1220
|
-
self.start = s.toISOString();
|
|
1221
|
-
self.end = e.toISOString();
|
|
1222
|
-
},
|
|
1223
|
-
conflicts(start, end) {
|
|
1224
|
-
const thisStart = new Date(self.start).getTime();
|
|
1225
|
-
const thisEnd = new Date(self.end).getTime();
|
|
1226
|
-
const startT = start.getTime();
|
|
1227
|
-
const endT = end.getTime();
|
|
1228
|
-
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
1229
|
-
},
|
|
1230
|
-
breakIntoSlots(slotDurationMinutes) {
|
|
1231
|
-
const start = new Date(self.start);
|
|
1232
|
-
const end = new Date(self.end);
|
|
1233
|
-
const slots = [];
|
|
1234
|
-
let current = new Date(start);
|
|
1235
|
-
const align = (m) => {
|
|
1236
|
-
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
1237
|
-
if (m > 0 && m < 15) return 15;
|
|
1238
|
-
if (m > 15 && m < 30) return 30;
|
|
1239
|
-
if (m > 30 && m < 45) return 45;
|
|
1240
|
-
return 0;
|
|
1241
|
-
};
|
|
1242
|
-
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
1243
|
-
let slotEnd = new Date(current.getTime());
|
|
1244
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1245
|
-
while (slotEnd.getTime() <= end.getTime()) {
|
|
1246
|
-
slots.push({
|
|
1247
|
-
startHour: current.getHours(),
|
|
1248
|
-
startMinute: current.getMinutes(),
|
|
1249
|
-
endHour: slotEnd.getHours(),
|
|
1250
|
-
endMinute: slotEnd.getMinutes(),
|
|
1251
|
-
startDate: current.toISOString(),
|
|
1252
|
-
endDate: slotEnd.toISOString()
|
|
1253
|
-
});
|
|
1254
|
-
current = new Date(slotEnd.getTime());
|
|
1255
|
-
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1256
|
-
}
|
|
1257
|
-
return slots;
|
|
1258
|
-
}
|
|
1259
|
-
}));
|
|
1260
|
-
var TimeFrame_default = TimeFrameModel;
|
|
1261
|
-
|
|
1262
1457
|
// src/models/appointment/Setting.js
|
|
1263
1458
|
var import_mobx_state_tree13 = require("mobx-state-tree");
|
|
1264
1459
|
var SettingModel = import_mobx_state_tree13.types.model("Setting", {
|