@blazeo.com/calendar-client 1.0.0 → 1.0.2
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/README.md +79 -0
- package/dist/index.d.mts +964 -0
- package/dist/index.d.ts +964 -0
- package/dist/index.js +1115 -0
- package/dist/index.mjs +1071 -0
- package/package.json +46 -12
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1071 @@
|
|
|
1
|
+
// src/mapper.ts
|
|
2
|
+
function pickStr(obj, ...keys) {
|
|
3
|
+
for (const k of keys) {
|
|
4
|
+
const v = obj[k];
|
|
5
|
+
if (v != null && typeof v === "string") return v;
|
|
6
|
+
}
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
function pickNum(obj, ...keys) {
|
|
10
|
+
for (const k of keys) {
|
|
11
|
+
const v = obj[k];
|
|
12
|
+
if (v != null) {
|
|
13
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
14
|
+
if (!Number.isNaN(n)) return n;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return void 0;
|
|
18
|
+
}
|
|
19
|
+
function parseDate(s) {
|
|
20
|
+
if (!s) return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
21
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s;
|
|
22
|
+
const d = new Date(s);
|
|
23
|
+
return isNaN(d.getTime()) ? (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) : d.toISOString().slice(0, 10);
|
|
24
|
+
}
|
|
25
|
+
function mapCreateEventInputToEvent(input) {
|
|
26
|
+
const calendarId = input.calendarId ?? input.calendar_id;
|
|
27
|
+
const visitorName = pickStr(input, "visitorName", "visitor_name") ?? "";
|
|
28
|
+
const visitorEmail = pickStr(input, "visitorEmail", "visitor_email") ?? "";
|
|
29
|
+
const visitorPhone = pickStr(input, "visitorPhone", "visitor_phone") ?? "";
|
|
30
|
+
const startDateStr = pickStr(input, "startDate", "start_date");
|
|
31
|
+
const endDateStr = pickStr(input, "endDate", "end_date");
|
|
32
|
+
const startHour = pickNum(input, "startHour", "start_hour") ?? 0;
|
|
33
|
+
const startMinute = pickNum(input, "startMinute", "start_minute") ?? 0;
|
|
34
|
+
const endHour = pickNum(input, "endHour", "end_hour") ?? startHour;
|
|
35
|
+
const endMinute = pickNum(input, "endMinute", "end_minute") ?? startMinute;
|
|
36
|
+
let startDate = parseDate(startDateStr);
|
|
37
|
+
let parsedStartHour = startHour;
|
|
38
|
+
let parsedStartMinute = startMinute;
|
|
39
|
+
const startTime = pickStr(input, "startTime", "start_time");
|
|
40
|
+
if (startTime && /^\d{1,2}:\d{2}$/.test(startTime)) {
|
|
41
|
+
const [h, m] = startTime.split(":").map(Number);
|
|
42
|
+
parsedStartHour = h;
|
|
43
|
+
parsedStartMinute = m;
|
|
44
|
+
}
|
|
45
|
+
const endDate = endDateStr ? parseDate(endDateStr) : startDate;
|
|
46
|
+
const rawParticipantId = input.participantId ?? input.participant_id;
|
|
47
|
+
const participantId = rawParticipantId == null ? null : typeof rawParticipantId === "string" ? rawParticipantId : String(rawParticipantId);
|
|
48
|
+
return {
|
|
49
|
+
calendarId,
|
|
50
|
+
participantId,
|
|
51
|
+
title: input.title ?? "",
|
|
52
|
+
description: input.description ?? "",
|
|
53
|
+
startDate,
|
|
54
|
+
endDate,
|
|
55
|
+
startHour: parsedStartHour,
|
|
56
|
+
startMinute: parsedStartMinute,
|
|
57
|
+
endHour,
|
|
58
|
+
endMinute,
|
|
59
|
+
visitorName,
|
|
60
|
+
visitorEmail,
|
|
61
|
+
visitorPhone,
|
|
62
|
+
isRecurring: false,
|
|
63
|
+
recurringFrequency: 0
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/client.ts
|
|
68
|
+
function normalizeBaseUrl(baseUrl) {
|
|
69
|
+
return baseUrl.replace(/\/+$/, "");
|
|
70
|
+
}
|
|
71
|
+
function buildQuery(params) {
|
|
72
|
+
const search = new URLSearchParams();
|
|
73
|
+
for (const [k, v] of Object.entries(params)) {
|
|
74
|
+
if (v === void 0 || v === null) continue;
|
|
75
|
+
search.set(k, String(v));
|
|
76
|
+
}
|
|
77
|
+
const q = search.toString();
|
|
78
|
+
return q ? `?${q}` : "";
|
|
79
|
+
}
|
|
80
|
+
var AppointmentClient = class {
|
|
81
|
+
constructor(config) {
|
|
82
|
+
this.baseUrl = normalizeBaseUrl(config.baseUrl);
|
|
83
|
+
this.getDefaultOffset = config.getDefaultOffset ?? (() => (/* @__PURE__ */ new Date()).getTimezoneOffset());
|
|
84
|
+
this.fetchFn = config.fetch ?? (typeof fetch !== "undefined" ? fetch : (() => {
|
|
85
|
+
throw new Error("fetch not available");
|
|
86
|
+
})());
|
|
87
|
+
}
|
|
88
|
+
async request(path, options = {}) {
|
|
89
|
+
const { method = "GET", headers = {}, body, query, skipContentType } = options;
|
|
90
|
+
const url = `${this.baseUrl}${path}${buildQuery(query ?? {})}`;
|
|
91
|
+
const reqHeaders = { ...headers };
|
|
92
|
+
if (!skipContentType && typeof body === "string") {
|
|
93
|
+
reqHeaders["Content-Type"] = "application/json";
|
|
94
|
+
}
|
|
95
|
+
const res = await this.fetchFn(url, { method, headers: reqHeaders, body });
|
|
96
|
+
const text = await res.text();
|
|
97
|
+
let data;
|
|
98
|
+
try {
|
|
99
|
+
data = JSON.parse(text);
|
|
100
|
+
} catch {
|
|
101
|
+
data = { status: "failure", message: text || res.statusText };
|
|
102
|
+
}
|
|
103
|
+
if (!res.ok && data.status !== "failure") {
|
|
104
|
+
data.status = "failure";
|
|
105
|
+
data.message = data.message ?? `HTTP ${res.status}`;
|
|
106
|
+
}
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
// ---------- Event ----------
|
|
110
|
+
/** GET /event/get – by event_id or externalevent_id */
|
|
111
|
+
async getEvent(params) {
|
|
112
|
+
if (params.eventId ?? params.event_id) {
|
|
113
|
+
return this.request("/event/get", {
|
|
114
|
+
query: { event_id: params.eventId ?? params.event_id }
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (params.externalEventId ?? params.externalevent_id) {
|
|
118
|
+
return this.request("/event/get", {
|
|
119
|
+
query: { externalevent_id: params.externalEventId ?? params.externalevent_id }
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return Promise.resolve({ status: "failure", message: "Provide eventId or externalEventId" });
|
|
123
|
+
}
|
|
124
|
+
/** GET /event/availability/get – slots for a day. Optional participant_id. */
|
|
125
|
+
async getAvailability(params) {
|
|
126
|
+
const calendarId = params.calendarId ?? params.calendar_id;
|
|
127
|
+
const offset = params.offset;
|
|
128
|
+
const query = {
|
|
129
|
+
calendar_id: calendarId,
|
|
130
|
+
year: params.year,
|
|
131
|
+
month: params.month,
|
|
132
|
+
day: params.day
|
|
133
|
+
};
|
|
134
|
+
if (params.participantId ?? params.participant_id) {
|
|
135
|
+
query.participant_id = params.participantId ?? params.participant_id;
|
|
136
|
+
}
|
|
137
|
+
return this.request("/event/availability/get", {
|
|
138
|
+
headers: { offset: String(offset) },
|
|
139
|
+
query
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/** GET /event/day/selectable/get – whether the day has any slots. Optional participant_id. */
|
|
143
|
+
async getDaySelectable(params) {
|
|
144
|
+
const calendarId = params.calendarId ?? params.calendar_id;
|
|
145
|
+
const query = {
|
|
146
|
+
calendar_id: calendarId,
|
|
147
|
+
year: params.year,
|
|
148
|
+
month: params.month,
|
|
149
|
+
day: params.day
|
|
150
|
+
};
|
|
151
|
+
if (params.participantId ?? params.participant_id) {
|
|
152
|
+
query.participant_id = params.participantId ?? params.participant_id;
|
|
153
|
+
}
|
|
154
|
+
const res = await this.request("/event/day/selectable/get", {
|
|
155
|
+
headers: { offset: String(params.offset) },
|
|
156
|
+
query
|
|
157
|
+
});
|
|
158
|
+
if (res.data !== void 0) return { ...res, data: Boolean(res.data) };
|
|
159
|
+
return res;
|
|
160
|
+
}
|
|
161
|
+
/** GET /event/days/available/get – list of next N available days (yyyy-MM-dd). */
|
|
162
|
+
async getEarliestAvailableDays(params) {
|
|
163
|
+
const calendarId = params.calendarId ?? params.calendar_id;
|
|
164
|
+
const query = {
|
|
165
|
+
calendar_id: calendarId,
|
|
166
|
+
count: params.count
|
|
167
|
+
};
|
|
168
|
+
if (params.year != null) query.year = params.year;
|
|
169
|
+
if (params.month != null) query.month = params.month;
|
|
170
|
+
if (params.day != null) query.day = params.day;
|
|
171
|
+
return this.request("/event/days/available/get", {
|
|
172
|
+
headers: { offset: String(params.offset) },
|
|
173
|
+
query
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** GET /event/existing/getbyvisitoremail – by company_key or calendar_id */
|
|
177
|
+
async getExistingEventsByVisitorEmail(params) {
|
|
178
|
+
const query = {
|
|
179
|
+
email: params.email,
|
|
180
|
+
offset: params.offset
|
|
181
|
+
};
|
|
182
|
+
if (params.companyKey ?? params.company_key) query.company_key = params.companyKey ?? params.company_key;
|
|
183
|
+
if (params.calendarId ?? params.calendar_id) query.calendar_id = params.calendarId ?? params.calendar_id;
|
|
184
|
+
return this.request("/event/existing/getbyvisitoremail", {
|
|
185
|
+
headers: { offset: String(params.offset) },
|
|
186
|
+
query
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/** GET /event/existing/getbyvisitorphone – by company_key or calendar_id */
|
|
190
|
+
async getExistingEventsByVisitorPhone(params) {
|
|
191
|
+
const query = {
|
|
192
|
+
phone: params.phone,
|
|
193
|
+
offset: params.offset
|
|
194
|
+
};
|
|
195
|
+
if (params.companyKey ?? params.company_key) query.company_key = params.companyKey ?? params.company_key;
|
|
196
|
+
if (params.calendarId ?? params.calendar_id) query.calendar_id = params.calendarId ?? params.calendar_id;
|
|
197
|
+
return this.request("/event/existing/getbyvisitorphone", {
|
|
198
|
+
headers: { offset: String(params.offset) },
|
|
199
|
+
query
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/** POST /event/create – create event. Accepts flexible input; maps to backend shape. */
|
|
203
|
+
async createEvent(input, offsetMinutes) {
|
|
204
|
+
const offset = offsetMinutes ?? this.getDefaultOffset();
|
|
205
|
+
const body = mapCreateEventInputToEvent(input);
|
|
206
|
+
return this.request("/event/create", {
|
|
207
|
+
method: "POST",
|
|
208
|
+
headers: { offset: String(offset) },
|
|
209
|
+
body: JSON.stringify(body)
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/** GET /event/cancel – cancel by event_id */
|
|
213
|
+
async cancelEvent(eventId) {
|
|
214
|
+
return this.request("/event/cancel", { query: { event_id: eventId } });
|
|
215
|
+
}
|
|
216
|
+
/** GET /event/cancellable – check if event can be cancelled */
|
|
217
|
+
async getCancellable(eventId) {
|
|
218
|
+
const res = await this.request("/event/cancellable", { query: { event_id: eventId } });
|
|
219
|
+
if (res.data !== void 0) return { ...res, data: Boolean(res.data) };
|
|
220
|
+
return res;
|
|
221
|
+
}
|
|
222
|
+
/** GET /event/participant/roundrobin/get – get assignable participant for calendar */
|
|
223
|
+
async getRoundRobinParticipant(calendarId) {
|
|
224
|
+
return this.request("/event/participant/roundrobin/get", {
|
|
225
|
+
query: { calendar_id: calendarId }
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/** GET /event/attendeeStatus – set attendee status (route: /event/{eventId}/{attendeeStatus}) */
|
|
229
|
+
async setAttendeeStatus(eventId, attendeeStatus) {
|
|
230
|
+
return this.request(`/event/${encodeURIComponent(eventId)}/${encodeURIComponent(attendeeStatus)}`);
|
|
231
|
+
}
|
|
232
|
+
/** GET /event/seteventreminder/{event_id} */
|
|
233
|
+
async setEventReminder(eventId) {
|
|
234
|
+
return this.request(`/event/seteventreminder/${encodeURIComponent(eventId)}`);
|
|
235
|
+
}
|
|
236
|
+
/** POST /event/reschedule – reschedule event */
|
|
237
|
+
async rescheduleEvent(payload, offsetMinutes) {
|
|
238
|
+
const offset = offsetMinutes ?? this.getDefaultOffset();
|
|
239
|
+
return this.request("/event/reschedule", {
|
|
240
|
+
method: "POST",
|
|
241
|
+
headers: { offset: String(offset) },
|
|
242
|
+
body: JSON.stringify(payload)
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/** POST /event/update – update event */
|
|
246
|
+
async updateEvent(payload) {
|
|
247
|
+
return this.request("/event/update", {
|
|
248
|
+
method: "POST",
|
|
249
|
+
body: JSON.stringify(payload)
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
/** POST /event/testcreate – test create (no notifications) */
|
|
253
|
+
async testCreateEvent(payload, offsetMinutes) {
|
|
254
|
+
const offset = offsetMinutes ?? this.getDefaultOffset();
|
|
255
|
+
return this.request("/event/testcreate", {
|
|
256
|
+
method: "POST",
|
|
257
|
+
headers: { offset: String(offset) },
|
|
258
|
+
body: JSON.stringify(payload)
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/** POST /event/customdata/get – get custom field schema for calendar */
|
|
262
|
+
async getEventCustomData(calendarId, eventId) {
|
|
263
|
+
const query = { calendar_id: calendarId };
|
|
264
|
+
if (eventId) query.event_id = eventId;
|
|
265
|
+
return this.request("/event/customdata/get", {
|
|
266
|
+
method: "POST",
|
|
267
|
+
body: JSON.stringify({}),
|
|
268
|
+
query
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// ---------- Calendar ----------
|
|
272
|
+
/** GET Calendar/Get – get calendar by calendar_id */
|
|
273
|
+
async getCalendar(calendarId) {
|
|
274
|
+
return this.request("/Calendar/Get", { query: { calendar_id: calendarId } });
|
|
275
|
+
}
|
|
276
|
+
/** GET Calendar/All – calendars by company_key */
|
|
277
|
+
async getCalendarsByCompany(companyKey) {
|
|
278
|
+
return this.request("/Calendar/All", { query: { company_key: companyKey } });
|
|
279
|
+
}
|
|
280
|
+
/** GET Calendar/TimeZones/Get */
|
|
281
|
+
async getTimeZones() {
|
|
282
|
+
return this.request("/Calendar/TimeZones/Get");
|
|
283
|
+
}
|
|
284
|
+
/** GET Calendar/TimeZone/Get – display name for timezone_id */
|
|
285
|
+
async getTimeZone(timezoneId) {
|
|
286
|
+
return this.request("/Calendar/TimeZone/Get", { query: { timezone_id: timezoneId } });
|
|
287
|
+
}
|
|
288
|
+
/** POST Calendar/Create – create or update calendar */
|
|
289
|
+
async createCalendar(payload) {
|
|
290
|
+
return this.request("/Calendar/Create", { method: "POST", body: JSON.stringify(payload) });
|
|
291
|
+
}
|
|
292
|
+
/** GET Calendar/Remove */
|
|
293
|
+
async removeCalendar(calendarId) {
|
|
294
|
+
return this.request(`/Calendar/Remove`, { query: { calendar_id: calendarId } });
|
|
295
|
+
}
|
|
296
|
+
/** POST Calendar/Event/Update – update calendar */
|
|
297
|
+
async updateCalendar(payload) {
|
|
298
|
+
return this.request("/Calendar/Event/Update", {
|
|
299
|
+
method: "POST",
|
|
300
|
+
body: JSON.stringify(payload)
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/** GET Calendar/Participant/Add */
|
|
304
|
+
async addParticipantToCalendar(calendarId, participantId) {
|
|
305
|
+
return this.request("/Calendar/Participant/Add", {
|
|
306
|
+
query: { calendar_id: calendarId, participant_id: participantId }
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/** GET Calendar/Participant/Remove */
|
|
310
|
+
async removeParticipantFromCalendar(calendarId, participantId) {
|
|
311
|
+
return this.request("/Calendar/Participant/Remove", {
|
|
312
|
+
query: { calendar_id: calendarId, participant_id: participantId }
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/** GET Calendar/Participant/OpeningHours/Get */
|
|
316
|
+
async getParticipantOpeningHours(params) {
|
|
317
|
+
const query = {};
|
|
318
|
+
if (params.calendarParticipantId) query.calendarparticipant_id = params.calendarParticipantId;
|
|
319
|
+
if (params.participantId) query.participant_id = params.participantId;
|
|
320
|
+
if (params.calendarId) query.calendar_id = params.calendarId;
|
|
321
|
+
return this.request("/Calendar/Participant/OpeningHours/Get", { query });
|
|
322
|
+
}
|
|
323
|
+
/** POST Calendar/Participant/Availability/OpeningHour/Save */
|
|
324
|
+
async saveOpeningHour(payload) {
|
|
325
|
+
return this.request("/Calendar/Participant/Availability/OpeningHour/Save", {
|
|
326
|
+
method: "POST",
|
|
327
|
+
body: JSON.stringify(payload)
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/** POST Calendar/Participant/Availability/OpeningHours/Save */
|
|
331
|
+
async saveOpeningHours(payload) {
|
|
332
|
+
return this.request("/Calendar/Participant/Availability/OpeningHours/Save", {
|
|
333
|
+
method: "POST",
|
|
334
|
+
body: JSON.stringify(payload)
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
/** GET Calendar/Participant/OpeningHour/Remove */
|
|
338
|
+
async removeParticipantOpeningHours(calendarId, participantId) {
|
|
339
|
+
return this.request("/Calendar/Participant/OpeningHour/Remove", {
|
|
340
|
+
query: { calendar_id: calendarId, participant_id: participantId }
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/** GET Calendar/Participant/Availability/Add – backend expects body (AvailabilityDetail). Note: GET with body is non-standard; fetch may reject. Consider backend POST if needed. */
|
|
344
|
+
async addParticipantAvailability(calendarId, participantId, detail) {
|
|
345
|
+
return this.request("/Calendar/Participant/Availability/Add", {
|
|
346
|
+
method: "GET",
|
|
347
|
+
query: { calendar_id: calendarId, participant_id: participantId },
|
|
348
|
+
body: JSON.stringify(detail)
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
/** GET Calendar/Participant/All */
|
|
352
|
+
async getCalendarParticipants(calendarId) {
|
|
353
|
+
return this.request("/Calendar/Participant/All", {
|
|
354
|
+
query: { calendar_id: calendarId }
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
/** GET Calendar/CreateWithParticipants */
|
|
358
|
+
async createCalendarWithParticipants(params) {
|
|
359
|
+
const query = {
|
|
360
|
+
name: params.name,
|
|
361
|
+
company_key: params.companyKey,
|
|
362
|
+
participantids: params.participantIds.join(",")
|
|
363
|
+
};
|
|
364
|
+
if (params.description) query.description = params.description;
|
|
365
|
+
if (params.calendarId) query.calendar_id = params.calendarId;
|
|
366
|
+
return this.request("/Calendar/CreateWithParticipants", { query });
|
|
367
|
+
}
|
|
368
|
+
/** GET Calendar/EditWithParticipants */
|
|
369
|
+
async editCalendarWithParticipants(params) {
|
|
370
|
+
const query = {
|
|
371
|
+
calendar_id: params.calendarId,
|
|
372
|
+
name: params.name,
|
|
373
|
+
participantids: params.participantIds.join(",")
|
|
374
|
+
};
|
|
375
|
+
if (params.description) query.description = params.description;
|
|
376
|
+
return this.request("/Calendar/EditWithParticipants", { query });
|
|
377
|
+
}
|
|
378
|
+
/** GET Calendar/Month/Get */
|
|
379
|
+
async getCalendarMonth(calendarId, year, month) {
|
|
380
|
+
return this.request("/Calendar/Month/Get", {
|
|
381
|
+
query: { calendar_id: calendarId, year, month }
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
/** GET Calendar/Events/Get */
|
|
385
|
+
async getCalendarEvents(calendarId) {
|
|
386
|
+
return this.request("/Calendar/Events/Get", {
|
|
387
|
+
query: { calendar_id: calendarId }
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
// ---------- Participant ----------
|
|
391
|
+
/** GET participant/get */
|
|
392
|
+
async getParticipant(participantId) {
|
|
393
|
+
return this.request("/participant/get", { query: { participant_id: participantId } });
|
|
394
|
+
}
|
|
395
|
+
/** GET participant/participants/get */
|
|
396
|
+
async getParticipantsByIds(participantIds) {
|
|
397
|
+
return this.request("/participant/participants/get", {
|
|
398
|
+
query: { participantids: participantIds.join(",") }
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
/** GET Participant/All */
|
|
402
|
+
async getAllParticipants(companyKey) {
|
|
403
|
+
return this.request("/Participant/All", { query: { company_key: companyKey } });
|
|
404
|
+
}
|
|
405
|
+
/** GET participant/sendemail */
|
|
406
|
+
async sendParticipantEmail(participantId) {
|
|
407
|
+
return this.request("/participant/sendemail", { query: { participant_id: participantId } });
|
|
408
|
+
}
|
|
409
|
+
/** POST Participant/Add */
|
|
410
|
+
async addParticipant(payload, calendarId) {
|
|
411
|
+
const query = calendarId ? { calendar_id: calendarId } : void 0;
|
|
412
|
+
return this.request("/Participant/Add", {
|
|
413
|
+
method: "POST",
|
|
414
|
+
body: JSON.stringify(payload),
|
|
415
|
+
query
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/** GET participant/remove */
|
|
419
|
+
async removeParticipant(participantId) {
|
|
420
|
+
return this.request("/participant/remove", { query: { participant_id: participantId } });
|
|
421
|
+
}
|
|
422
|
+
/** POST participant/update */
|
|
423
|
+
async updateParticipant(payload) {
|
|
424
|
+
return this.request("/participant/update", {
|
|
425
|
+
method: "POST",
|
|
426
|
+
body: JSON.stringify(payload)
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
/** POST participant/save */
|
|
430
|
+
async saveParticipant(payload) {
|
|
431
|
+
return this.request("/participant/save", {
|
|
432
|
+
method: "POST",
|
|
433
|
+
body: JSON.stringify(payload)
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
// ---------- CalendarParticipant ----------
|
|
437
|
+
/** GET Calendar/Participant/Get */
|
|
438
|
+
async getCalendarParticipant(calendarId) {
|
|
439
|
+
return this.request("/Calendar/Participant/Get", {
|
|
440
|
+
query: { calendar_id: calendarId }
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
/** GET Calendar/Participants/GetInfo */
|
|
444
|
+
async getCalendarParticipantsInfo(calendarId) {
|
|
445
|
+
return this.request("/Calendar/Participants/GetInfo", {
|
|
446
|
+
query: { calendar_id: calendarId }
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
/** GET Participant/calendar/get */
|
|
450
|
+
async getParticipantCalendars(participantId) {
|
|
451
|
+
return this.request("/Participant/calendar/get", {
|
|
452
|
+
query: { participant_id: participantId }
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
// ---------- CustomField ----------
|
|
456
|
+
/** GET CustomField/GetAll */
|
|
457
|
+
async getCustomFields(calendarId) {
|
|
458
|
+
return this.request("/CustomField/GetAll", { query: { calendar_id: calendarId } });
|
|
459
|
+
}
|
|
460
|
+
/** GET CustomField/FieldType/Get */
|
|
461
|
+
async getCustomFieldType(fieldType) {
|
|
462
|
+
return this.request("/CustomField/FieldType/Get", { query: { FieldType: fieldType } });
|
|
463
|
+
}
|
|
464
|
+
/** POST CustomField/Add */
|
|
465
|
+
async addCustomField(payload) {
|
|
466
|
+
return this.request("/CustomField/Add", {
|
|
467
|
+
method: "POST",
|
|
468
|
+
body: JSON.stringify(payload)
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/** GET CustomField/FieldTypes/Get */
|
|
472
|
+
async getCustomFieldTypes() {
|
|
473
|
+
return this.request("/CustomField/FieldTypes/Get");
|
|
474
|
+
}
|
|
475
|
+
/** GET CustomField/RemoveField */
|
|
476
|
+
async removeCustomField(customFieldId) {
|
|
477
|
+
return this.request("/CustomField/RemoveField", { query: { customfield_id: customFieldId } });
|
|
478
|
+
}
|
|
479
|
+
/** GET CustomField/RemoveAllFields */
|
|
480
|
+
async removeAllCustomFields(calendarId) {
|
|
481
|
+
return this.request("/CustomField/RemoveAllFields", { query: { calendar_id: calendarId } });
|
|
482
|
+
}
|
|
483
|
+
/** GET CustomField/Form/Get */
|
|
484
|
+
async getCustomForm(calendarId, dataId) {
|
|
485
|
+
const query = { calendar_id: calendarId };
|
|
486
|
+
if (dataId) query.data_id = dataId;
|
|
487
|
+
return this.request("/CustomField/Form/Get", { query });
|
|
488
|
+
}
|
|
489
|
+
/** GET CustomField/Form/Data/Get */
|
|
490
|
+
async getCustomFormData(calendarId, dataId) {
|
|
491
|
+
const query = { calendar_id: calendarId };
|
|
492
|
+
if (dataId) query.data_id = dataId;
|
|
493
|
+
return this.request("/CustomField/Form/Data/Get", { query });
|
|
494
|
+
}
|
|
495
|
+
/** POST CustomField/Form/Save */
|
|
496
|
+
async saveCustomForm(calendarId, fields) {
|
|
497
|
+
return this.request("/CustomField/Form/Save", {
|
|
498
|
+
method: "POST",
|
|
499
|
+
body: JSON.stringify(fields),
|
|
500
|
+
query: { calendar_id: calendarId }
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
/** POST CustomField/Form/Data/Save */
|
|
504
|
+
async saveCustomFormData(dataId, fields) {
|
|
505
|
+
return this.request("/CustomField/Form/Data/Save", {
|
|
506
|
+
method: "POST",
|
|
507
|
+
body: JSON.stringify(fields),
|
|
508
|
+
query: { data_id: dataId }
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
/** POST CustomField/Form/Field/Data/Save */
|
|
512
|
+
async saveCustomFormFieldData(field) {
|
|
513
|
+
return this.request("/CustomField/Form/Field/Data/Save", {
|
|
514
|
+
method: "POST",
|
|
515
|
+
body: JSON.stringify(field)
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
// ---------- Setting ----------
|
|
519
|
+
/** GET setting/get */
|
|
520
|
+
async getSetting(calendarId) {
|
|
521
|
+
return this.request("/setting/get", { query: { calendar_id: calendarId } });
|
|
522
|
+
}
|
|
523
|
+
/** POST setting/save */
|
|
524
|
+
async saveSetting(payload) {
|
|
525
|
+
return this.request("/setting/save", {
|
|
526
|
+
method: "POST",
|
|
527
|
+
body: JSON.stringify(payload)
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
/** POST setting/logo/upload */
|
|
531
|
+
async uploadSettingLogo(calendarId, file) {
|
|
532
|
+
const form = new FormData();
|
|
533
|
+
form.append("file", file);
|
|
534
|
+
return this.request("/setting/logo/upload", {
|
|
535
|
+
method: "POST",
|
|
536
|
+
body: form,
|
|
537
|
+
query: { calendar_id: calendarId },
|
|
538
|
+
skipContentType: true
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
// ---------- Consumer ----------
|
|
542
|
+
/** POST Consumer/Register/EventListener */
|
|
543
|
+
async registerEventListener(payload) {
|
|
544
|
+
return this.request("/Consumer/Register/EventListener", {
|
|
545
|
+
method: "POST",
|
|
546
|
+
body: JSON.stringify(payload)
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
/** PUT Consumer/Update/EventListener */
|
|
550
|
+
async updateEventListener(payload) {
|
|
551
|
+
return this.request("/Consumer/Update/EventListener", {
|
|
552
|
+
method: "PUT",
|
|
553
|
+
body: JSON.stringify(payload)
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
/** POST Consumer/Register */
|
|
557
|
+
async registerConsumer(payload) {
|
|
558
|
+
return this.request("/Consumer/Register", {
|
|
559
|
+
method: "POST",
|
|
560
|
+
body: JSON.stringify(payload)
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
/** GET Consumer/Events/List */
|
|
564
|
+
async listEventListeners() {
|
|
565
|
+
return this.request("/Consumer/Events/List");
|
|
566
|
+
}
|
|
567
|
+
/** GET Consumer/List */
|
|
568
|
+
async listConsumers() {
|
|
569
|
+
return this.request("/Consumer/List");
|
|
570
|
+
}
|
|
571
|
+
// ---------- Preference ----------
|
|
572
|
+
/** POST /preference/{scope}/{key}/{option} */
|
|
573
|
+
async setPreference(scope, key, option, body) {
|
|
574
|
+
return this.request(`/preference/${encodeURIComponent(scope)}/${encodeURIComponent(key)}/${encodeURIComponent(option)}`, {
|
|
575
|
+
method: "POST",
|
|
576
|
+
body
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
/** GET /preference/scopes */
|
|
580
|
+
async getPreferenceScopes() {
|
|
581
|
+
return this.request("/preference/scopes");
|
|
582
|
+
}
|
|
583
|
+
/** GET /preference/options */
|
|
584
|
+
async getPreferenceOptions() {
|
|
585
|
+
return this.request("/preference/options");
|
|
586
|
+
}
|
|
587
|
+
/** GET /preference/options/{option} */
|
|
588
|
+
async getPreferenceOption(option) {
|
|
589
|
+
return this.request(`/preference/options/${encodeURIComponent(option)}`);
|
|
590
|
+
}
|
|
591
|
+
/** GET /preference/{option} */
|
|
592
|
+
async getPreference(option, keys) {
|
|
593
|
+
return this.request(`/preference/${encodeURIComponent(option)}`, {
|
|
594
|
+
query: { keys: keys.join(",") }
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
// ---------- Notification ----------
|
|
598
|
+
/** POST /notification/sms/outbound */
|
|
599
|
+
async sendSmsOutbound(payload) {
|
|
600
|
+
return this.request("/notification/sms/outbound", {
|
|
601
|
+
method: "POST",
|
|
602
|
+
body: JSON.stringify(payload)
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
/** GET /notification/sms/queue */
|
|
606
|
+
async getSmsQueue(id) {
|
|
607
|
+
return this.request("/notification/sms/queue", { query: { id } });
|
|
608
|
+
}
|
|
609
|
+
/** POST /notification/sms/inbound */
|
|
610
|
+
async smsInbound(formData) {
|
|
611
|
+
return this.request("/notification/sms/inbound", {
|
|
612
|
+
method: "POST",
|
|
613
|
+
body: formData,
|
|
614
|
+
skipContentType: true
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
/** POST /notification/sms/status */
|
|
618
|
+
async smsStatus(payload) {
|
|
619
|
+
return this.request("/notification/sms/status", {
|
|
620
|
+
method: "POST",
|
|
621
|
+
body: JSON.stringify(payload)
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
/** GET /notification/sms/outbox/send */
|
|
625
|
+
async sendSmsOutbox() {
|
|
626
|
+
return this.request("/notification/sms/outbox/send");
|
|
627
|
+
}
|
|
628
|
+
// ---------- Auth ----------
|
|
629
|
+
/** GET /CallBack – OAuth callback (typically used as redirect URL) */
|
|
630
|
+
getCallbackUrl() {
|
|
631
|
+
return `${this.baseUrl}/CallBack`;
|
|
632
|
+
}
|
|
633
|
+
/** POST Auth/AddParticipantCredentials */
|
|
634
|
+
async addParticipantCredentials(payload) {
|
|
635
|
+
return this.request("/Auth/AddParticipantCredentials", {
|
|
636
|
+
method: "POST",
|
|
637
|
+
body: JSON.stringify(payload)
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
/** GET Auth/ParticipantCredentials */
|
|
641
|
+
async getParticipantCredentials(participantId) {
|
|
642
|
+
return this.request("/Auth/ParticipantCredentials", { query: { participant_id: participantId } });
|
|
643
|
+
}
|
|
644
|
+
// ---------- Ping ----------
|
|
645
|
+
/** GET /ping */
|
|
646
|
+
async ping() {
|
|
647
|
+
return this.request("/ping");
|
|
648
|
+
}
|
|
649
|
+
/** GET /setup */
|
|
650
|
+
async setup(name) {
|
|
651
|
+
return this.request("/setup", { query: name ? { name } : void 0 });
|
|
652
|
+
}
|
|
653
|
+
/** GET /reset */
|
|
654
|
+
async reset() {
|
|
655
|
+
return this.request("/reset");
|
|
656
|
+
}
|
|
657
|
+
/** POST /ping */
|
|
658
|
+
async pingPost() {
|
|
659
|
+
return this.request("/ping", { method: "POST" });
|
|
660
|
+
}
|
|
661
|
+
// ---------- Schedule ----------
|
|
662
|
+
/** POST /schedule/calendar/ */
|
|
663
|
+
async scheduleCalendar(calendar) {
|
|
664
|
+
return this.request("/schedule/calendar/", {
|
|
665
|
+
method: "POST",
|
|
666
|
+
query: calendar ? { calendar } : void 0
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
|
|
671
|
+
// src/models/appointment/Calendar.ts
|
|
672
|
+
import { types, getEnv, applySnapshot } from "mobx-state-tree";
|
|
673
|
+
|
|
674
|
+
// src/models/appointment/enums.ts
|
|
675
|
+
var Unit = {
|
|
676
|
+
Minutes: 1,
|
|
677
|
+
Hours: 2,
|
|
678
|
+
Days: 3,
|
|
679
|
+
Months: 4,
|
|
680
|
+
Year: 5,
|
|
681
|
+
Week: 6
|
|
682
|
+
};
|
|
683
|
+
var AssignmentMethod = {
|
|
684
|
+
RoundRobin: 1,
|
|
685
|
+
MaximizeAvailability: 2
|
|
686
|
+
};
|
|
687
|
+
var AttendeeStatus = {
|
|
688
|
+
None: 0,
|
|
689
|
+
Accepted: 1,
|
|
690
|
+
Declined: 2,
|
|
691
|
+
Tentative: 3,
|
|
692
|
+
NeedsAction: 4,
|
|
693
|
+
Canceled: 5
|
|
694
|
+
};
|
|
695
|
+
var RecurringFrequency = {
|
|
696
|
+
None: 0,
|
|
697
|
+
Daily: 1,
|
|
698
|
+
Weekly: 2,
|
|
699
|
+
Monthly: 3,
|
|
700
|
+
Yearly: 4
|
|
701
|
+
};
|
|
702
|
+
var DayOfWeek = {
|
|
703
|
+
Sunday: 0,
|
|
704
|
+
Monday: 1,
|
|
705
|
+
Tuesday: 2,
|
|
706
|
+
Wednesday: 3,
|
|
707
|
+
Thursday: 4,
|
|
708
|
+
Friday: 5,
|
|
709
|
+
Saturday: 6
|
|
710
|
+
};
|
|
711
|
+
|
|
712
|
+
// src/models/appointment/Calendar.ts
|
|
713
|
+
var CalendarModel = types.model("Calendar", {
|
|
714
|
+
id: types.maybeNull(types.number),
|
|
715
|
+
companyKey: types.maybeNull(types.string),
|
|
716
|
+
calendarId: types.identifier,
|
|
717
|
+
name: types.maybeNull(types.string),
|
|
718
|
+
location: types.maybeNull(types.string),
|
|
719
|
+
timeZoneId: types.maybeNull(types.string),
|
|
720
|
+
purpose: types.optional(types.string, ""),
|
|
721
|
+
description: types.maybeNull(types.string),
|
|
722
|
+
assignmentMethod: types.optional(types.number, AssignmentMethod.RoundRobin),
|
|
723
|
+
duration: types.optional(types.number, 0),
|
|
724
|
+
durationUnit: types.optional(types.number, Unit.Minutes),
|
|
725
|
+
minimumBookingNotice: types.optional(types.number, 0),
|
|
726
|
+
minimumBookingNoticeUnit: types.optional(types.number, Unit.Minutes),
|
|
727
|
+
minimumCancelationNotice: types.optional(types.number, 0),
|
|
728
|
+
minimumCancelationNoticeUnit: types.optional(types.number, Unit.Minutes),
|
|
729
|
+
futureLimit: types.optional(types.number, 0),
|
|
730
|
+
futureLimitUnit: types.optional(types.number, Unit.Days),
|
|
731
|
+
bufferTime: types.optional(types.number, 0),
|
|
732
|
+
bufferTimeUnit: types.optional(types.number, Unit.Minutes),
|
|
733
|
+
bookingLimit: types.optional(types.number, 0),
|
|
734
|
+
createdOn: types.maybeNull(types.string),
|
|
735
|
+
modifiedOn: types.maybeNull(types.string)
|
|
736
|
+
}).actions((self) => ({
|
|
737
|
+
async create() {
|
|
738
|
+
const api = getEnv(self).api;
|
|
739
|
+
const payload = {
|
|
740
|
+
calendarId: self.calendarId,
|
|
741
|
+
companyKey: self.companyKey ?? void 0,
|
|
742
|
+
name: self.name ?? void 0,
|
|
743
|
+
location: self.location ?? void 0,
|
|
744
|
+
timeZoneId: self.timeZoneId ?? void 0,
|
|
745
|
+
purpose: self.purpose,
|
|
746
|
+
description: self.description ?? void 0,
|
|
747
|
+
assignmentMethod: self.assignmentMethod,
|
|
748
|
+
duration: self.duration,
|
|
749
|
+
durationUnit: self.durationUnit,
|
|
750
|
+
minimumBookingNotice: self.minimumBookingNotice,
|
|
751
|
+
minimumBookingNoticeUnit: self.minimumBookingNoticeUnit,
|
|
752
|
+
minimumCancelationNotice: self.minimumCancelationNotice,
|
|
753
|
+
minimumCancelationNoticeUnit: self.minimumCancelationNoticeUnit,
|
|
754
|
+
futureLimit: self.futureLimit,
|
|
755
|
+
futureLimitUnit: self.futureLimitUnit,
|
|
756
|
+
bufferTime: self.bufferTime,
|
|
757
|
+
bufferTimeUnit: self.bufferTimeUnit,
|
|
758
|
+
bookingLimit: self.bookingLimit
|
|
759
|
+
};
|
|
760
|
+
const res = await api.createCalendar(payload);
|
|
761
|
+
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, calendarId: self.calendarId });
|
|
762
|
+
return res;
|
|
763
|
+
},
|
|
764
|
+
async get() {
|
|
765
|
+
const api = getEnv(self).api;
|
|
766
|
+
const res = await api.getCalendar(self.calendarId);
|
|
767
|
+
if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, calendarId: self.calendarId });
|
|
768
|
+
return res;
|
|
769
|
+
},
|
|
770
|
+
async remove() {
|
|
771
|
+
const api = getEnv(self).api;
|
|
772
|
+
return api.removeCalendar(self.calendarId);
|
|
773
|
+
}
|
|
774
|
+
}));
|
|
775
|
+
var Calendar_default = CalendarModel;
|
|
776
|
+
|
|
777
|
+
// src/models/appointment/Event.ts
|
|
778
|
+
import { types as types2, getEnv as getEnv2, applySnapshot as applySnapshot2 } from "mobx-state-tree";
|
|
779
|
+
var EventModel = types2.model("Event", {
|
|
780
|
+
id: types2.maybeNull(types2.number),
|
|
781
|
+
eventId: types2.identifier,
|
|
782
|
+
calendarId: types2.string,
|
|
783
|
+
participantId: types2.maybeNull(types2.string),
|
|
784
|
+
title: types2.maybeNull(types2.string),
|
|
785
|
+
description: types2.maybeNull(types2.string),
|
|
786
|
+
isRecurring: types2.optional(types2.boolean, false),
|
|
787
|
+
recurringFrequency: types2.optional(types2.number, RecurringFrequency.None),
|
|
788
|
+
startDate: types2.string,
|
|
789
|
+
endDate: types2.string,
|
|
790
|
+
startHour: types2.optional(types2.number, 0),
|
|
791
|
+
startMinute: types2.optional(types2.number, 0),
|
|
792
|
+
endHour: types2.optional(types2.number, 0),
|
|
793
|
+
endMinute: types2.optional(types2.number, 0),
|
|
794
|
+
visitorName: types2.maybeNull(types2.string),
|
|
795
|
+
visitorEmail: types2.maybeNull(types2.string),
|
|
796
|
+
visitorPhone: types2.maybeNull(types2.string),
|
|
797
|
+
createdOn: types2.maybeNull(types2.string),
|
|
798
|
+
modifiedOn: types2.maybeNull(types2.string),
|
|
799
|
+
externalEventId: types2.maybeNull(types2.string),
|
|
800
|
+
attendeeStatus: types2.optional(types2.number, AttendeeStatus.Tentative),
|
|
801
|
+
rescheduleLink: types2.maybeNull(types2.string),
|
|
802
|
+
cancelLink: types2.maybeNull(types2.string),
|
|
803
|
+
timeZone: types2.maybeNull(types2.string),
|
|
804
|
+
offset: types2.optional(types2.number, 0)
|
|
805
|
+
}).actions((self) => ({
|
|
806
|
+
async get(params) {
|
|
807
|
+
const api = getEnv2(self).api;
|
|
808
|
+
const res = await api.getEvent(params);
|
|
809
|
+
if (res.status === "success" && res.data) applySnapshot2(self, { ...res.data, eventId: self.eventId });
|
|
810
|
+
return res;
|
|
811
|
+
},
|
|
812
|
+
async create(offsetMinutes) {
|
|
813
|
+
const api = getEnv2(self).api;
|
|
814
|
+
const payload = {
|
|
815
|
+
calendarId: self.calendarId,
|
|
816
|
+
participantId: self.participantId ?? void 0,
|
|
817
|
+
title: self.title ?? void 0,
|
|
818
|
+
description: self.description ?? void 0,
|
|
819
|
+
startDate: self.startDate,
|
|
820
|
+
endDate: self.endDate,
|
|
821
|
+
startHour: self.startHour,
|
|
822
|
+
startMinute: self.startMinute,
|
|
823
|
+
endHour: self.endHour,
|
|
824
|
+
endMinute: self.endMinute,
|
|
825
|
+
visitorName: self.visitorName ?? void 0,
|
|
826
|
+
visitorEmail: self.visitorEmail ?? void 0,
|
|
827
|
+
visitorPhone: self.visitorPhone ?? void 0
|
|
828
|
+
};
|
|
829
|
+
const res = await api.createEvent(payload, offsetMinutes);
|
|
830
|
+
if (res.status === "success" && res.data) applySnapshot2(self, { ...res.data, eventId: self.eventId });
|
|
831
|
+
return res;
|
|
832
|
+
},
|
|
833
|
+
async cancel() {
|
|
834
|
+
const api = getEnv2(self).api;
|
|
835
|
+
return api.cancelEvent(self.eventId);
|
|
836
|
+
},
|
|
837
|
+
async getCancellable() {
|
|
838
|
+
const api = getEnv2(self).api;
|
|
839
|
+
return api.getCancellable(self.eventId);
|
|
840
|
+
},
|
|
841
|
+
async getAvailability(params) {
|
|
842
|
+
const api = getEnv2(self).api;
|
|
843
|
+
return api.getAvailability({
|
|
844
|
+
calendarId: self.calendarId,
|
|
845
|
+
participantId: params.participantId ?? self.participantId ?? void 0,
|
|
846
|
+
year: params.year,
|
|
847
|
+
month: params.month,
|
|
848
|
+
day: params.day,
|
|
849
|
+
offset: params.offset
|
|
850
|
+
});
|
|
851
|
+
},
|
|
852
|
+
async setReminder() {
|
|
853
|
+
const api = getEnv2(self).api;
|
|
854
|
+
return api.setEventReminder(self.eventId);
|
|
855
|
+
}
|
|
856
|
+
}));
|
|
857
|
+
var Event_default = EventModel;
|
|
858
|
+
|
|
859
|
+
// src/models/appointment/Availability.ts
|
|
860
|
+
import { types as types3 } from "mobx-state-tree";
|
|
861
|
+
var AvailabilityModel = types3.model("Availability", {
|
|
862
|
+
id: types3.maybeNull(types3.number),
|
|
863
|
+
availabilityId: types3.string,
|
|
864
|
+
calendarId: types3.string,
|
|
865
|
+
participantId: types3.string,
|
|
866
|
+
createdOn: types3.maybeNull(types3.string),
|
|
867
|
+
modifiedOn: types3.maybeNull(types3.string)
|
|
868
|
+
});
|
|
869
|
+
var Availability_default = AvailabilityModel;
|
|
870
|
+
|
|
871
|
+
// src/models/appointment/AvailabilityDetail.ts
|
|
872
|
+
import { types as types4 } from "mobx-state-tree";
|
|
873
|
+
var AvailabilityDetailModel = types4.model("AvailabilityDetail", {
|
|
874
|
+
id: types4.maybeNull(types4.number),
|
|
875
|
+
availabilityId: types4.string,
|
|
876
|
+
sunday: types4.optional(types4.boolean, false),
|
|
877
|
+
monday: types4.optional(types4.boolean, false),
|
|
878
|
+
tuesday: types4.optional(types4.boolean, false),
|
|
879
|
+
wednesday: types4.optional(types4.boolean, false),
|
|
880
|
+
thursday: types4.optional(types4.boolean, false),
|
|
881
|
+
friday: types4.optional(types4.boolean, false),
|
|
882
|
+
saturday: types4.optional(types4.boolean, false),
|
|
883
|
+
startHour: types4.optional(types4.number, 0),
|
|
884
|
+
startMinute: types4.optional(types4.number, 0),
|
|
885
|
+
endHour: types4.optional(types4.number, 0),
|
|
886
|
+
endMinute: types4.optional(types4.number, 0),
|
|
887
|
+
createdOn: types4.maybeNull(types4.string),
|
|
888
|
+
modifiedOn: types4.maybeNull(types4.string)
|
|
889
|
+
});
|
|
890
|
+
var AvailabilityDetail_default = AvailabilityDetailModel;
|
|
891
|
+
|
|
892
|
+
// src/models/appointment/CalendarParticipant.ts
|
|
893
|
+
import { types as types5 } from "mobx-state-tree";
|
|
894
|
+
var CalendarParticipantModel = types5.model("CalendarParticipant", {
|
|
895
|
+
id: types5.maybeNull(types5.number),
|
|
896
|
+
calendarParticipantId: types5.optional(types5.string, ""),
|
|
897
|
+
participantId: types5.string,
|
|
898
|
+
calendarId: types5.string,
|
|
899
|
+
createdOn: types5.maybeNull(types5.string),
|
|
900
|
+
modifiedOn: types5.maybeNull(types5.string)
|
|
901
|
+
});
|
|
902
|
+
var CalendarParticipant_default = CalendarParticipantModel;
|
|
903
|
+
|
|
904
|
+
// src/models/appointment/Participant.ts
|
|
905
|
+
import { types as types6 } from "mobx-state-tree";
|
|
906
|
+
var ParticipantModel = types6.model("Participant", {
|
|
907
|
+
id: types6.maybeNull(types6.number),
|
|
908
|
+
participantId: types6.identifier,
|
|
909
|
+
companyKey: types6.maybeNull(types6.string),
|
|
910
|
+
alias: types6.optional(types6.string, ""),
|
|
911
|
+
email: types6.optional(types6.string, ""),
|
|
912
|
+
isApproved: types6.optional(types6.boolean, false),
|
|
913
|
+
isAvailable: types6.optional(types6.boolean, false),
|
|
914
|
+
provider: types6.optional(types6.number, 0),
|
|
915
|
+
createdOn: types6.maybeNull(types6.string),
|
|
916
|
+
modifiedOn: types6.maybeNull(types6.string),
|
|
917
|
+
isDeleted: types6.optional(types6.boolean, false)
|
|
918
|
+
});
|
|
919
|
+
var Participant_default = ParticipantModel;
|
|
920
|
+
|
|
921
|
+
// src/models/appointment/OpeningHour.ts
|
|
922
|
+
import { types as types7 } from "mobx-state-tree";
|
|
923
|
+
var OpeningHourModel = types7.model("OpeningHour", {
|
|
924
|
+
id: types7.maybeNull(types7.number),
|
|
925
|
+
openingHourId: types7.optional(types7.string, ""),
|
|
926
|
+
calendarId: types7.string,
|
|
927
|
+
participantId: types7.string,
|
|
928
|
+
day: types7.optional(types7.number, 0),
|
|
929
|
+
startHour: types7.optional(types7.number, 0),
|
|
930
|
+
startMinute: types7.optional(types7.number, 0),
|
|
931
|
+
endHour: types7.optional(types7.number, 0),
|
|
932
|
+
endMinute: types7.optional(types7.number, 0),
|
|
933
|
+
off: types7.optional(types7.boolean, false),
|
|
934
|
+
createdOn: types7.maybeNull(types7.string),
|
|
935
|
+
modifiedOn: types7.maybeNull(types7.string)
|
|
936
|
+
});
|
|
937
|
+
var OpeningHour_default = OpeningHourModel;
|
|
938
|
+
|
|
939
|
+
// src/models/appointment/TimeSlot.ts
|
|
940
|
+
import { types as types8 } from "mobx-state-tree";
|
|
941
|
+
var TimeSlotModel = types8.model("TimeSlot", {
|
|
942
|
+
startHour: types8.optional(types8.number, 0),
|
|
943
|
+
startMinute: types8.optional(types8.number, 0),
|
|
944
|
+
endHour: types8.optional(types8.number, 0),
|
|
945
|
+
endMinute: types8.optional(types8.number, 0),
|
|
946
|
+
startDate: types8.string,
|
|
947
|
+
endDate: types8.string,
|
|
948
|
+
participantId: types8.maybeNull(types8.string)
|
|
949
|
+
}).actions((self) => ({
|
|
950
|
+
setWithOffset(offsetMinutes) {
|
|
951
|
+
const start = new Date(self.startDate);
|
|
952
|
+
const end = new Date(self.endDate);
|
|
953
|
+
start.setMinutes(start.getMinutes() + offsetMinutes);
|
|
954
|
+
end.setMinutes(end.getMinutes() + offsetMinutes);
|
|
955
|
+
self.startDate = start.toISOString();
|
|
956
|
+
self.endDate = end.toISOString();
|
|
957
|
+
self.startHour = start.getHours();
|
|
958
|
+
self.startMinute = start.getMinutes();
|
|
959
|
+
self.endHour = end.getHours();
|
|
960
|
+
self.endMinute = end.getMinutes();
|
|
961
|
+
}
|
|
962
|
+
}));
|
|
963
|
+
var TimeSlot_default = TimeSlotModel;
|
|
964
|
+
|
|
965
|
+
// src/models/appointment/TimeFrame.ts
|
|
966
|
+
import { types as types9 } from "mobx-state-tree";
|
|
967
|
+
var TimeFrameModel = types9.model("TimeFrame", {
|
|
968
|
+
start: types9.string,
|
|
969
|
+
end: types9.string
|
|
970
|
+
}).actions((self) => ({
|
|
971
|
+
buffer(bufferMinutes, unit) {
|
|
972
|
+
const bfr = unit === Unit.Hours ? bufferMinutes * 60 : bufferMinutes;
|
|
973
|
+
const s = new Date(self.start);
|
|
974
|
+
const e = new Date(self.end);
|
|
975
|
+
s.setMinutes(s.getMinutes() - bfr);
|
|
976
|
+
e.setMinutes(e.getMinutes() + bfr);
|
|
977
|
+
self.start = s.toISOString();
|
|
978
|
+
self.end = e.toISOString();
|
|
979
|
+
},
|
|
980
|
+
conflicts(start, end) {
|
|
981
|
+
const thisStart = new Date(self.start).getTime();
|
|
982
|
+
const thisEnd = new Date(self.end).getTime();
|
|
983
|
+
const startT = start.getTime();
|
|
984
|
+
const endT = end.getTime();
|
|
985
|
+
return startT >= thisStart && startT <= thisEnd || endT >= thisStart && endT <= thisEnd || startT <= thisStart && endT >= thisEnd;
|
|
986
|
+
},
|
|
987
|
+
breakIntoSlots(slotDurationMinutes) {
|
|
988
|
+
const start = new Date(self.start);
|
|
989
|
+
const end = new Date(self.end);
|
|
990
|
+
const slots = [];
|
|
991
|
+
let current = new Date(start);
|
|
992
|
+
const align = (m) => {
|
|
993
|
+
if (m === 0 || m === 15 || m === 30 || m === 45) return m;
|
|
994
|
+
if (m > 0 && m < 15) return 15;
|
|
995
|
+
if (m > 15 && m < 30) return 30;
|
|
996
|
+
if (m > 30 && m < 45) return 45;
|
|
997
|
+
return 0;
|
|
998
|
+
};
|
|
999
|
+
current.setMinutes(align(current.getMinutes()), 0, 0);
|
|
1000
|
+
let slotEnd = new Date(current.getTime());
|
|
1001
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1002
|
+
while (slotEnd.getTime() <= end.getTime()) {
|
|
1003
|
+
slots.push({
|
|
1004
|
+
startHour: current.getHours(),
|
|
1005
|
+
startMinute: current.getMinutes(),
|
|
1006
|
+
endHour: slotEnd.getHours(),
|
|
1007
|
+
endMinute: slotEnd.getMinutes(),
|
|
1008
|
+
startDate: current.toISOString(),
|
|
1009
|
+
endDate: slotEnd.toISOString()
|
|
1010
|
+
});
|
|
1011
|
+
current = new Date(slotEnd.getTime());
|
|
1012
|
+
slotEnd.setMinutes(slotEnd.getMinutes() + slotDurationMinutes);
|
|
1013
|
+
}
|
|
1014
|
+
return slots;
|
|
1015
|
+
}
|
|
1016
|
+
}));
|
|
1017
|
+
var TimeFrame_default = TimeFrameModel;
|
|
1018
|
+
|
|
1019
|
+
// src/models/appointment/Setting.ts
|
|
1020
|
+
import { types as types10 } from "mobx-state-tree";
|
|
1021
|
+
var SettingModel = types10.model("Setting", {
|
|
1022
|
+
id: types10.maybeNull(types10.number),
|
|
1023
|
+
settingsId: types10.optional(types10.string, ""),
|
|
1024
|
+
calendarId: types10.string,
|
|
1025
|
+
logo: types10.maybeNull(types10.string),
|
|
1026
|
+
theme: types10.maybeNull(types10.string),
|
|
1027
|
+
schedulingButtonText: types10.maybeNull(types10.string),
|
|
1028
|
+
scheduledMessage: types10.maybeNull(types10.string)
|
|
1029
|
+
});
|
|
1030
|
+
var Setting_default = SettingModel;
|
|
1031
|
+
|
|
1032
|
+
// src/models/appointment/index.ts
|
|
1033
|
+
import { types as types11, getEnv as getEnv3 } from "mobx-state-tree";
|
|
1034
|
+
var RootStore = types11.model("RootStore", {
|
|
1035
|
+
calendars: types11.optional(types11.map(Calendar_default), {}),
|
|
1036
|
+
events: types11.optional(types11.map(Event_default), {})
|
|
1037
|
+
}).actions((self) => ({
|
|
1038
|
+
getApi() {
|
|
1039
|
+
return getEnv3(self).api;
|
|
1040
|
+
},
|
|
1041
|
+
addCalendar(snapshot) {
|
|
1042
|
+
const cal = Calendar_default.create(snapshot);
|
|
1043
|
+
self.calendars.set(cal.calendarId, cal);
|
|
1044
|
+
return cal;
|
|
1045
|
+
},
|
|
1046
|
+
addEvent(snapshot) {
|
|
1047
|
+
const ev = Event_default.create(snapshot);
|
|
1048
|
+
self.events.set(ev.eventId, ev);
|
|
1049
|
+
return ev;
|
|
1050
|
+
}
|
|
1051
|
+
}));
|
|
1052
|
+
export {
|
|
1053
|
+
AppointmentClient,
|
|
1054
|
+
AssignmentMethod,
|
|
1055
|
+
AttendeeStatus,
|
|
1056
|
+
AvailabilityDetail_default as AvailabilityDetailModel,
|
|
1057
|
+
Availability_default as AvailabilityModel,
|
|
1058
|
+
Calendar_default as CalendarModel,
|
|
1059
|
+
CalendarParticipant_default as CalendarParticipantModel,
|
|
1060
|
+
DayOfWeek,
|
|
1061
|
+
Event_default as EventModel,
|
|
1062
|
+
OpeningHour_default as OpeningHourModel,
|
|
1063
|
+
Participant_default as ParticipantModel,
|
|
1064
|
+
RecurringFrequency,
|
|
1065
|
+
RootStore,
|
|
1066
|
+
Setting_default as SettingModel,
|
|
1067
|
+
TimeFrame_default as TimeFrameModel,
|
|
1068
|
+
TimeSlot_default as TimeSlotModel,
|
|
1069
|
+
Unit,
|
|
1070
|
+
mapCreateEventInputToEvent
|
|
1071
|
+
};
|