@blazeo.com/appointment-client 1.0.5 → 1.0.7
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/blazeo.com-appointment-client-1.0.7.tgz +0 -0
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts +4 -36
- package/dist/calendar/blazeoCalendarRelationMethods.js +0 -1
- package/dist/calendar/buildUnifiedCalendarView.d.ts +39 -0
- package/dist/calendar/buildUnifiedCalendarView.js +280 -0
- package/dist/calendar/calendarCreation.d.ts +27 -0
- package/dist/calendar/calendarCreation.js +167 -0
- package/dist/calendar/calendarCreationFacade.d.ts +4 -13
- package/dist/calendar/calendarCreationFacade.js +3 -5
- package/dist/calendar/createCalendar.d.ts +67 -37
- package/dist/calendar/createCalendar.js +1 -3
- package/dist/calendar/fetchCalendarDetails.d.ts +41 -18
- package/dist/calendar/fetchCalendarDetails.js +261 -51
- package/dist/calendar/fetchCalendarWithOpeningHours.d.ts +25 -21
- package/dist/calendar/fetchCalendarWithOpeningHours.js +114 -75
- package/dist/calendar/getAllParticipantOpeningHours.d.ts +22 -0
- package/dist/calendar/getAllParticipantOpeningHours.js +22 -0
- package/dist/calendar/getOpeningHours.d.ts +8 -0
- package/dist/calendar/getOpeningHours.js +9 -0
- package/dist/calendar/getParticipantOpeningHours.d.ts +37 -0
- package/dist/calendar/getParticipantOpeningHours.js +48 -0
- package/dist/calendar/getParticipants.d.ts +7 -0
- package/dist/calendar/getParticipants.js +13 -0
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts +9 -9
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js +43 -43
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts +22 -3
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js +0 -1
- package/dist/calendar/mapToDesiredResponse.d.ts +70 -0
- package/dist/calendar/mapToDesiredResponse.js +99 -0
- package/dist/config/applyBlazeoClientConfig.d.ts +2 -2
- package/dist/config/applyBlazeoClientConfig.js +13 -13
- package/dist/config/applyBlazeoDefaults.d.ts +0 -1
- package/dist/config/applyBlazeoDefaults.js +3 -3
- package/dist/config/blazeo.config.d.ts +10 -10
- package/dist/config/blazeo.config.js +10 -10
- package/dist/config/blazeoClientDefaults.d.ts +1 -2
- package/dist/config/blazeoClientDefaults.js +2 -3
- package/dist/config/ensureBlazeoHttpReady.d.ts +17 -0
- package/dist/config/ensureBlazeoHttpReady.js +31 -0
- package/dist/config/initializeAppointmentClient.d.ts +8 -28
- package/dist/config/initializeAppointmentClient.js +11 -24
- package/dist/config/syncBlazeoConnection.d.ts +6 -0
- package/dist/config/syncBlazeoConnection.js +18 -0
- package/dist/events/appointmentEventFacade.d.ts +55 -32
- package/dist/events/appointmentEventFacade.js +5 -10
- package/dist/events/mapAppointmentToEventSnapshot.d.ts +1 -4
- package/dist/events/mapAppointmentToEventSnapshot.js +0 -1
- package/dist/exampleData.d.ts +114 -10
- package/dist/exampleData.js +4 -5
- package/dist/facade/calendarCreationFacade.d.ts +39 -39
- package/dist/facade/calendarCreationFacade.js +95 -95
- package/dist/facade/mapCalendarBOToSnapshot.d.ts +9 -9
- package/dist/facade/mapCalendarBOToSnapshot.js +43 -43
- package/dist/facades/index.d.ts +11 -11
- package/dist/facades/index.js +11 -11
- package/dist/index.d.ts +26 -82
- package/dist/index.js +23 -33
- package/dist/models/CalendarRootModel.d.ts +36 -11
- package/dist/models/CalendarRootModel.js +22 -5
- package/dist/models/CalendarSlotModel.d.ts +8 -8
- package/dist/models/CalendarSlotModel.js +7 -7
- package/dist/models/EventModel.d.ts +10 -10
- package/dist/models/EventModel.js +9 -9
- package/dist/models/ParticipantModel.d.ts +8 -8
- package/dist/models/ParticipantModel.js +7 -7
- package/dist/models/index.d.ts +4 -4
- package/dist/models/index.js +4 -4
- package/dist/types/appointment.d.ts +27 -27
- package/dist/types/appointment.js +5 -5
- package/dist/types/calendar.d.ts +51 -51
- package/dist/types/calendar.js +5 -5
- package/dist/types/calendarBo.d.ts +61 -61
- package/dist/types/calendarBo.js +5 -5
- package/package.json +8 -2
- package/sample/.env.example +5 -0
- package/sample/build_error.txt +0 -0
- package/sample/demo.js +70 -0
- package/sample/package-lock.json +5 -2
- package/sample/package.json +3 -1
- package/sample/scripts/getInfoByCalendar.mjs +36 -0
- package/sample/scripts/getParticipantOpeningHours.mjs +48 -0
- package/sample/src/AllParticipantOpeningHoursTab.jsx +82 -0
- package/sample/src/App2.jsx +60 -3
- package/sample/src/AvailabilityTab.jsx +8 -3
- package/sample/src/BlazeoConnectionSettings.jsx +17 -16
- package/sample/src/CreateCalendarTab.jsx +23 -6
- package/sample/src/EventTab.jsx +31 -8
- package/sample/src/FetchCalendarTab.jsx +114 -38
- package/sample/src/OpeningHoursTab.jsx +87 -0
- package/sample/src/ParticipantInfoTab.jsx +77 -0
- package/sample/src/ParticipantOpeningHoursTab.jsx +98 -0
- package/sample/src/ParticipantTab.jsx +13 -4
- package/sample/src/blazeoBootstrap.js +30 -0
- package/sample/src/blazeoDemoError.js +14 -0
- package/sample/src/blazeoPushConnection.js +23 -0
- package/sample/src/main.jsx +3 -3
- package/sample/vite.config.js +19 -5
- package/src/calendar/blazeoCalendarRelationMethods.ts +19 -0
- package/src/calendar/buildUnifiedCalendarView.ts +345 -0
- package/src/calendar/calendarCreation.ts +179 -0
- package/src/calendar/createCalendar.ts +243 -0
- package/src/calendar/fetchCalendarDetails.ts +316 -0
- package/src/calendar/fetchCalendarWithOpeningHours.ts +130 -0
- package/src/calendar/getAllParticipantOpeningHours.ts +30 -0
- package/src/calendar/getOpeningHours.ts +10 -0
- package/src/calendar/getParticipantOpeningHours.ts +55 -0
- package/src/calendar/getParticipants.ts +17 -0
- package/src/calendar/mapCalendarToBlazeoSnapshot.ts +46 -0
- package/src/calendar/mapToDesiredResponse.ts +104 -0
- package/src/config/applyBlazeoDefaults.ts +14 -0
- package/src/config/blazeoClientDefaults.ts +11 -0
- package/src/config/ensureBlazeoHttpReady.ts +41 -0
- package/src/config/initializeAppointmentClient.ts +24 -0
- package/src/config/syncBlazeoConnection.ts +19 -0
- package/src/events/appointmentEventFacade.ts +148 -0
- package/src/events/mapAppointmentToEventSnapshot.ts +65 -0
- package/src/exampleData.ts +79 -0
- package/src/index.ts +51 -0
- package/src/models/CalendarRootModel.ts +60 -0
- package/tsconfig.json +16 -0
- package/blazeo.com-appointment-client-1.0.5.tgz +0 -0
|
@@ -1,75 +1,114 @@
|
|
|
1
|
-
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { resolveBlazeoConnection } from "./createCalendar.js";
|
|
3
|
+
import { mapToDesiredCalendarResponse } from "./mapToDesiredResponse.js";
|
|
4
|
+
/**
|
|
5
|
+
* Unwrap nested REST shapes: `res.data`, `res.Data`, or `res.data.data`.
|
|
6
|
+
*/
|
|
7
|
+
export function unwrapCalendarGetData(res) {
|
|
8
|
+
if (res == null || typeof res !== "object")
|
|
9
|
+
return null;
|
|
10
|
+
let d = res.data ?? res.Data;
|
|
11
|
+
if (d == null)
|
|
12
|
+
return null;
|
|
13
|
+
if (typeof d === "object" && (d.data != null || d.Data != null)) {
|
|
14
|
+
d = d.data ?? d.Data;
|
|
15
|
+
}
|
|
16
|
+
return d;
|
|
17
|
+
}
|
|
18
|
+
/** `openingHours` / `OpeningHours` on the calendar object returned by GET /Calendar/
|
|
19
|
+
* Robustly picks opening hours array from a raw calendar payload.
|
|
20
|
+
*/
|
|
21
|
+
export function pickOpeningHoursArrayFromCalendarPayload(data) {
|
|
22
|
+
if (data == null)
|
|
23
|
+
return null;
|
|
24
|
+
const { list } = normalizeParticipantOpeningHoursResponse(data);
|
|
25
|
+
return list;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Normalize `calendar.getParticipantOpeningHours()` response (`GET /Calendar/Participant/OpeningHours/Get`).
|
|
29
|
+
* Supports various Blazeo API shapes including nested data and common property names.
|
|
30
|
+
*/
|
|
31
|
+
export function normalizeParticipantOpeningHoursResponse(res) {
|
|
32
|
+
if (res == null)
|
|
33
|
+
return { list: null, raw: res };
|
|
34
|
+
// 1. Check for standard envelope: res.data or res.Data
|
|
35
|
+
let d = res.data ?? res.Data ?? res;
|
|
36
|
+
// 2. Handle double-nested data (common in some Blazeo API versions)
|
|
37
|
+
if (d && typeof d === "object" && !Array.isArray(d)) {
|
|
38
|
+
if (d.data !== undefined)
|
|
39
|
+
d = d.data;
|
|
40
|
+
else if (d.Data !== undefined)
|
|
41
|
+
d = d.Data;
|
|
42
|
+
}
|
|
43
|
+
// 3. If d is now an array, that's our list
|
|
44
|
+
if (Array.isArray(d))
|
|
45
|
+
return { list: d, raw: res };
|
|
46
|
+
// 4. Otherwise check for known list properties on the object
|
|
47
|
+
if (d && typeof d === "object") {
|
|
48
|
+
const list = d.openingHours ??
|
|
49
|
+
d.OpeningHours ??
|
|
50
|
+
d.participantOpeningHours ??
|
|
51
|
+
d.ParticipantOpeningHours ??
|
|
52
|
+
d.rows ??
|
|
53
|
+
d.Rows ??
|
|
54
|
+
d.items ??
|
|
55
|
+
d.Items ??
|
|
56
|
+
d.list ??
|
|
57
|
+
d.List;
|
|
58
|
+
if (Array.isArray(list))
|
|
59
|
+
return { list, raw: res };
|
|
60
|
+
}
|
|
61
|
+
return { list: null, raw: res };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Loads `CalendarModel` and attaches **`openingHours`** to the MST snapshot:
|
|
65
|
+
* 1. Prefer rows embedded on **GET /Calendar/Get** (`CalendarModel.getRaw` payload — `@blazeo.com/calendar-client` MST omits them).
|
|
66
|
+
* 2. If missing/empty, calls **`calendar.getParticipantOpeningHours()`** (`GET /Calendar/Participant/OpeningHours/Get`).
|
|
67
|
+
*/
|
|
68
|
+
export async function fetchCalendarWithOpeningHours(calendarId, options = {}) {
|
|
69
|
+
const { includeRawGet = false, baseUrl, consumer } = options;
|
|
70
|
+
const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection({ baseUrl, consumer });
|
|
71
|
+
const rawRes = await CalendarModel.getRaw(calendarId);
|
|
72
|
+
const payload = unwrapCalendarGetData(rawRes);
|
|
73
|
+
let cal = null;
|
|
74
|
+
if (payload) {
|
|
75
|
+
// Manually create the model instance to fix a bug in calendar-client static get.
|
|
76
|
+
cal = CalendarModel.create({ ...payload, calendarId }, { baseUrl: resolvedBase, consumer: resolvedConsumer });
|
|
77
|
+
}
|
|
78
|
+
if (cal == null) {
|
|
79
|
+
return {
|
|
80
|
+
calendar: null,
|
|
81
|
+
openingHours: [],
|
|
82
|
+
raw: rawRes,
|
|
83
|
+
meta: { ok: false, reason: "calendar_not_found" },
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const embedded = pickOpeningHoursArrayFromCalendarPayload(payload) ?? [];
|
|
87
|
+
let resolved = embedded.length > 0 ? embedded : null;
|
|
88
|
+
let participantRes = null;
|
|
89
|
+
if ((resolved == null || resolved.length === 0) && cal != null) {
|
|
90
|
+
// Pass calendarId explicitly because some server shapes do not populate `self.calendarId` on the MST model.
|
|
91
|
+
participantRes = await cal.getParticipantOpeningHours({ calendarId });
|
|
92
|
+
const { list } = normalizeParticipantOpeningHoursResponse(participantRes);
|
|
93
|
+
if (list != null && list.length > 0)
|
|
94
|
+
resolved = list;
|
|
95
|
+
}
|
|
96
|
+
const openingHours = Array.isArray(resolved) ? resolved : [];
|
|
97
|
+
const mappedOpeningHours = openingHours.map(oh => ({
|
|
98
|
+
...oh,
|
|
99
|
+
}));
|
|
100
|
+
const rawMembers = payload?.members ?? payload?.Members ?? payload?.participants ?? payload?.Participants;
|
|
101
|
+
const mappedMembers = Array.isArray(rawMembers)
|
|
102
|
+
? rawMembers.map((m) => ({ ...m }))
|
|
103
|
+
: [];
|
|
104
|
+
const calendar = mapToDesiredCalendarResponse(payload, openingHours, mappedMembers);
|
|
105
|
+
if (!calendar)
|
|
106
|
+
return null;
|
|
107
|
+
Object.defineProperties(calendar, {
|
|
108
|
+
_cal: { value: cal, enumerable: false },
|
|
109
|
+
_openingHours: { value: openingHours, enumerable: false },
|
|
110
|
+
_embeddedFromGet: { value: embedded, enumerable: false },
|
|
111
|
+
_rawGet: { value: rawRes, enumerable: false },
|
|
112
|
+
});
|
|
113
|
+
return calendar;
|
|
114
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch all participant opening hours for a calendar.
|
|
3
|
+
* Uses `GET /Calendar/Participant/OpeningHours/All/Get`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getAllParticipantOpeningHours(calendarId: string, options?: {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
consumer?: string;
|
|
8
|
+
}): Promise<{
|
|
9
|
+
openingHours: any[];
|
|
10
|
+
raw: any[];
|
|
11
|
+
meta: {
|
|
12
|
+
ok: true;
|
|
13
|
+
shape: "array";
|
|
14
|
+
};
|
|
15
|
+
} | {
|
|
16
|
+
openingHours: any[];
|
|
17
|
+
raw: any;
|
|
18
|
+
meta: {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
shape?: undefined;
|
|
21
|
+
};
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { ensureBlazeoHttpReady } from "../config/ensureBlazeoHttpReady.js";
|
|
3
|
+
import { normalizeParticipantOpeningHoursResponse } from "./fetchCalendarWithOpeningHours.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fetch all participant opening hours for a calendar.
|
|
6
|
+
* Uses `GET /Calendar/Participant/OpeningHours/All/Get`.
|
|
7
|
+
*/
|
|
8
|
+
export async function getAllParticipantOpeningHours(calendarId, options = {}) {
|
|
9
|
+
const ready = ensureBlazeoHttpReady(options);
|
|
10
|
+
if (!ready.ok) {
|
|
11
|
+
throw new Error(ready.error);
|
|
12
|
+
}
|
|
13
|
+
const raw = await CalendarModel.getAllParticipantOpeningHours(calendarId);
|
|
14
|
+
// calendar-client static helper returns either `unknown[] | null` or an envelope depending on version/entrypoint.
|
|
15
|
+
if (Array.isArray(raw)) {
|
|
16
|
+
return { openingHours: raw, raw, meta: { ok: true, shape: "array" } };
|
|
17
|
+
}
|
|
18
|
+
const { list } = normalizeParticipantOpeningHoursResponse(raw);
|
|
19
|
+
const openingHours = Array.isArray(list) ? list : [];
|
|
20
|
+
const ok = Array.isArray(list) ? true : raw?.status === "success";
|
|
21
|
+
return { openingHours, raw, meta: { ok: !!ok } };
|
|
22
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetches opening hours for a calendar.
|
|
3
|
+
* Automatically handles embedded calendar-level hours and participant-level fallbacks.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getOpeningHours(calendarId: string, options?: {
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
consumer?: string;
|
|
8
|
+
}): Promise<any>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { fetchCalendarWithOpeningHours } from "./fetchCalendarWithOpeningHours.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fetches opening hours for a calendar.
|
|
4
|
+
* Automatically handles embedded calendar-level hours and participant-level fallbacks.
|
|
5
|
+
*/
|
|
6
|
+
export async function getOpeningHours(calendarId, options = {}) {
|
|
7
|
+
const result = await fetchCalendarWithOpeningHours(calendarId, options);
|
|
8
|
+
return result.openingHours;
|
|
9
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct wrapper around `calendar.getParticipantOpeningHours()` for a calendar id.
|
|
3
|
+
*
|
|
4
|
+
* This hits `GET /Calendar/Participant/OpeningHours/Get` (server-side shape may vary),
|
|
5
|
+
* so we also return a normalized list alongside the raw response.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getParticipantOpeningHours(calendarId: string, options?: any): Promise<{
|
|
8
|
+
openingHours: any[];
|
|
9
|
+
raw: any;
|
|
10
|
+
meta: {
|
|
11
|
+
ok: false;
|
|
12
|
+
reason: string;
|
|
13
|
+
count?: undefined;
|
|
14
|
+
status?: undefined;
|
|
15
|
+
error?: undefined;
|
|
16
|
+
};
|
|
17
|
+
} | {
|
|
18
|
+
openingHours: any[];
|
|
19
|
+
raw: any;
|
|
20
|
+
meta: {
|
|
21
|
+
ok: true;
|
|
22
|
+
count: number;
|
|
23
|
+
status: any;
|
|
24
|
+
reason?: undefined;
|
|
25
|
+
error?: undefined;
|
|
26
|
+
};
|
|
27
|
+
} | {
|
|
28
|
+
openingHours: any[];
|
|
29
|
+
raw: any;
|
|
30
|
+
meta: {
|
|
31
|
+
ok: false;
|
|
32
|
+
reason: string;
|
|
33
|
+
error: string;
|
|
34
|
+
count?: undefined;
|
|
35
|
+
status?: undefined;
|
|
36
|
+
};
|
|
37
|
+
}>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { resolveBlazeoConnection } from "./createCalendar.js";
|
|
3
|
+
import { unwrapCalendarGetData, normalizeParticipantOpeningHoursResponse } from "./fetchCalendarWithOpeningHours.js";
|
|
4
|
+
/**
|
|
5
|
+
* Direct wrapper around `calendar.getParticipantOpeningHours()` for a calendar id.
|
|
6
|
+
*
|
|
7
|
+
* This hits `GET /Calendar/Participant/OpeningHours/Get` (server-side shape may vary),
|
|
8
|
+
* so we also return a normalized list alongside the raw response.
|
|
9
|
+
*/
|
|
10
|
+
export async function getParticipantOpeningHours(calendarId, options = {}) {
|
|
11
|
+
try {
|
|
12
|
+
const { baseUrl, consumer, ...passThrough } = options;
|
|
13
|
+
const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection({ baseUrl, consumer });
|
|
14
|
+
const rawRes = await CalendarModel.getRaw(calendarId);
|
|
15
|
+
const payload = unwrapCalendarGetData(rawRes);
|
|
16
|
+
if (!payload) {
|
|
17
|
+
return {
|
|
18
|
+
openingHours: [],
|
|
19
|
+
raw: null,
|
|
20
|
+
meta: { ok: false, reason: "calendar_not_found" },
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const cal = CalendarModel.create({ ...payload, calendarId }, { baseUrl: resolvedBase, consumer: resolvedConsumer });
|
|
24
|
+
const raw = await cal.getParticipantOpeningHours({ calendarId, ...(passThrough ?? {}) });
|
|
25
|
+
const { list } = normalizeParticipantOpeningHoursResponse(raw);
|
|
26
|
+
const openingHours = Array.isArray(list) ? list : [];
|
|
27
|
+
return {
|
|
28
|
+
openingHours,
|
|
29
|
+
raw,
|
|
30
|
+
meta: {
|
|
31
|
+
ok: true,
|
|
32
|
+
count: openingHours.length,
|
|
33
|
+
status: raw?.status ?? (raw?.Status || "unknown"),
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return {
|
|
39
|
+
openingHours: [],
|
|
40
|
+
raw: null,
|
|
41
|
+
meta: {
|
|
42
|
+
ok: false,
|
|
43
|
+
reason: "exception",
|
|
44
|
+
error: err instanceof Error ? err.message : String(err),
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { ensureBlazeoHttpReady } from "../config/ensureBlazeoHttpReady.js";
|
|
3
|
+
/**
|
|
4
|
+
* Fetches participants for a calendar.
|
|
5
|
+
*/
|
|
6
|
+
export async function getParticipants(calendarId, options = {}) {
|
|
7
|
+
const ready = ensureBlazeoHttpReady(options);
|
|
8
|
+
if (!ready.ok) {
|
|
9
|
+
throw new Error(ready.error);
|
|
10
|
+
}
|
|
11
|
+
const participants = await CalendarModel.getParticipants(calendarId);
|
|
12
|
+
return Array.isArray(participants) ? participants : [];
|
|
13
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { CalendarBOInput } from "../types/calendar.js";
|
|
2
|
-
/**
|
|
3
|
-
* Maps Apex `CalendarBO`-shaped input to a snapshot for
|
|
4
|
-
* {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
|
|
5
|
-
*
|
|
6
|
-
* Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
|
|
7
|
-
* unknown keys or invalid `null`s on optional numbers.
|
|
8
|
-
*/
|
|
9
|
-
export declare function mapCalendarBOToSnapshot(bo: CalendarBOInput): Record<string, unknown>;
|
|
1
|
+
import type { CalendarBOInput } from "../types/calendar.js";
|
|
2
|
+
/**
|
|
3
|
+
* Maps Apex `CalendarBO`-shaped input to a snapshot for
|
|
4
|
+
* {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
|
|
5
|
+
*
|
|
6
|
+
* Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
|
|
7
|
+
* unknown keys or invalid `null`s on optional numbers.
|
|
8
|
+
*/
|
|
9
|
+
export declare function mapCalendarBOToSnapshot(bo: CalendarBOInput): Record<string, unknown>;
|
|
10
10
|
//# sourceMappingURL=mapCalendarBoToBlazeoSnapshot.d.ts.map
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
/** Default enum values aligned with ApexFlows / Blazeo (`AssignmentMethod`, `Unit`). */
|
|
2
|
-
const DEFAULT_ASSIGNMENT_METHOD = 1;
|
|
3
|
-
const DEFAULT_UNIT_MINUTES = 1;
|
|
4
|
-
/**
|
|
5
|
-
* For Blazeo `Calendar` MST: `types.optional(types.number)` accepts `undefined` (uses default)
|
|
6
|
-
* but not `null`. Coerce null/absent to `undefined`.
|
|
7
|
-
*/
|
|
8
|
-
function optionalNumber(v) {
|
|
9
|
-
return v == null ? undefined : v;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Maps Apex `CalendarBO`-shaped input to a snapshot for
|
|
13
|
-
* {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
|
|
14
|
-
*
|
|
15
|
-
* Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
|
|
16
|
-
* unknown keys or invalid `null`s on optional numbers.
|
|
17
|
-
*/
|
|
18
|
-
export function mapCalendarBOToSnapshot(bo) {
|
|
19
|
-
const calendarId = bo.calendarId ?? bo.thirdPartyCalendarId ?? "new";
|
|
20
|
-
return {
|
|
21
|
-
id: bo.serverId == null ? undefined : bo.serverId,
|
|
22
|
-
companyKey: bo.companyKey ?? null,
|
|
23
|
-
calendarId,
|
|
24
|
-
name: bo.name ?? null,
|
|
25
|
-
timeZoneId: bo.timeZoneId ?? null,
|
|
26
|
-
purpose: bo.purpose ?? bo.bookingPageTitle ?? "",
|
|
27
|
-
description: bo.description ?? null,
|
|
28
|
-
assignmentMethod: bo.assignmentMethod ?? bo.assignmentType ?? DEFAULT_ASSIGNMENT_METHOD,
|
|
29
|
-
duration: optionalNumber(bo.duration) ?? 30,
|
|
30
|
-
durationUnit: optionalNumber(bo.durationUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
31
|
-
minimumBookingNotice: optionalNumber(bo.minimumBookingNotice) ?? 0,
|
|
32
|
-
minimumBookingNoticeUnit: optionalNumber(bo.minimumBookingNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
33
|
-
minimumCancelationNotice: optionalNumber(bo.minimumCancelationNotice) ?? 0,
|
|
34
|
-
minimumCancelationNoticeUnit: optionalNumber(bo.minimumCancelationNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
35
|
-
futureLimit: optionalNumber(bo.futureLimit) ?? 0,
|
|
36
|
-
futureLimitUnit: optionalNumber(bo.futureLimitUnit) ?? 3,
|
|
37
|
-
bufferTime: optionalNumber(bo.bufferTime),
|
|
38
|
-
bufferTimeUnit: optionalNumber(bo.bufferTimeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
39
|
-
bookingLimit: optionalNumber(bo.bookingLimit),
|
|
40
|
-
createdOn: bo.createdOn ?? null,
|
|
41
|
-
modifiedOn: bo.modifiedOn ?? null,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
1
|
+
/** Default enum values aligned with ApexFlows / Blazeo (`AssignmentMethod`, `Unit`). */
|
|
2
|
+
const DEFAULT_ASSIGNMENT_METHOD = 1;
|
|
3
|
+
const DEFAULT_UNIT_MINUTES = 1;
|
|
4
|
+
/**
|
|
5
|
+
* For Blazeo `Calendar` MST: `types.optional(types.number)` accepts `undefined` (uses default)
|
|
6
|
+
* but not `null`. Coerce null/absent to `undefined`.
|
|
7
|
+
*/
|
|
8
|
+
function optionalNumber(v) {
|
|
9
|
+
return v == null ? undefined : v;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Maps Apex `CalendarBO`-shaped input to a snapshot for
|
|
13
|
+
* {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
|
|
14
|
+
*
|
|
15
|
+
* Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
|
|
16
|
+
* unknown keys or invalid `null`s on optional numbers.
|
|
17
|
+
*/
|
|
18
|
+
export function mapCalendarBOToSnapshot(bo) {
|
|
19
|
+
const calendarId = bo.calendarId ?? bo.thirdPartyCalendarId ?? "new";
|
|
20
|
+
return {
|
|
21
|
+
id: bo.serverId == null ? undefined : bo.serverId,
|
|
22
|
+
companyKey: bo.companyKey ?? null,
|
|
23
|
+
calendarId,
|
|
24
|
+
name: bo.name ?? null,
|
|
25
|
+
timeZoneId: bo.timeZoneId ?? null,
|
|
26
|
+
purpose: bo.purpose ?? bo.bookingPageTitle ?? "",
|
|
27
|
+
description: bo.description ?? null,
|
|
28
|
+
assignmentMethod: bo.assignmentMethod ?? bo.assignmentType ?? DEFAULT_ASSIGNMENT_METHOD,
|
|
29
|
+
duration: optionalNumber(bo.duration) ?? 30,
|
|
30
|
+
durationUnit: optionalNumber(bo.durationUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
31
|
+
minimumBookingNotice: optionalNumber(bo.minimumBookingNotice) ?? 0,
|
|
32
|
+
minimumBookingNoticeUnit: optionalNumber(bo.minimumBookingNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
33
|
+
minimumCancelationNotice: optionalNumber(bo.minimumCancelationNotice) ?? 0,
|
|
34
|
+
minimumCancelationNoticeUnit: optionalNumber(bo.minimumCancelationNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
35
|
+
futureLimit: optionalNumber(bo.futureLimit) ?? 0,
|
|
36
|
+
futureLimitUnit: optionalNumber(bo.futureLimitUnit) ?? 3,
|
|
37
|
+
bufferTime: optionalNumber(bo.bufferTime),
|
|
38
|
+
bufferTimeUnit: optionalNumber(bo.bufferTimeUnit) ?? DEFAULT_UNIT_MINUTES,
|
|
39
|
+
bookingLimit: optionalNumber(bo.bookingLimit),
|
|
40
|
+
createdOn: bo.createdOn ?? null,
|
|
41
|
+
modifiedOn: bo.modifiedOn ?? null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
44
|
//# sourceMappingURL=mapCalendarBoToBlazeoSnapshot.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CalendarInput } from "../types/calendar.js";
|
|
2
1
|
/**
|
|
3
2
|
* Maps Apex `CalendarBO`-shaped input to a snapshot for
|
|
4
3
|
* {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
|
|
@@ -6,5 +5,25 @@ import type { CalendarInput } from "../types/calendar.js";
|
|
|
6
5
|
* Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
|
|
7
6
|
* unknown keys or invalid `null`s on optional numbers.
|
|
8
7
|
*/
|
|
9
|
-
export declare function mapCalendarBOToSnapshot(bo:
|
|
10
|
-
|
|
8
|
+
export declare function mapCalendarBOToSnapshot(bo: any): {
|
|
9
|
+
companyKey: any;
|
|
10
|
+
calendarId: any;
|
|
11
|
+
name: any;
|
|
12
|
+
timeZoneId: any;
|
|
13
|
+
purpose: any;
|
|
14
|
+
description: any;
|
|
15
|
+
assignmentMethod: any;
|
|
16
|
+
duration: any;
|
|
17
|
+
durationUnit: any;
|
|
18
|
+
minimumBookingNotice: any;
|
|
19
|
+
minimumBookingNoticeUnit: any;
|
|
20
|
+
minimumCancelationNotice: any;
|
|
21
|
+
minimumCancelationNoticeUnit: any;
|
|
22
|
+
futureLimit: any;
|
|
23
|
+
futureLimitUnit: any;
|
|
24
|
+
bufferTime: any;
|
|
25
|
+
bufferTimeUnit: any;
|
|
26
|
+
bookingLimit: any;
|
|
27
|
+
createdOn: any;
|
|
28
|
+
modifiedOn: any;
|
|
29
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps a raw Blazeo API calendar payload (often PascalCase) to the specific camelCase
|
|
3
|
+
* shape requested by the user, including typenames and normalized fields.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mapToDesiredCalendarResponse(payload: any, openingHours?: any[], members?: any[]): {
|
|
6
|
+
id: number | null;
|
|
7
|
+
durationUnit: number | null;
|
|
8
|
+
minimumBookingNotice: number | null;
|
|
9
|
+
minimumBookingNoticeUnit: number | null;
|
|
10
|
+
minimumCancelationNotice: number | null;
|
|
11
|
+
minimumCancelationNoticeUnit: number | null;
|
|
12
|
+
futureLimit: number | null;
|
|
13
|
+
futureLimitUnit: number | null;
|
|
14
|
+
bufferTime: number | null;
|
|
15
|
+
bufferTimeUnit: number | null;
|
|
16
|
+
calendarLink: any;
|
|
17
|
+
uuid: any;
|
|
18
|
+
location: any;
|
|
19
|
+
bookingPageTitle: any;
|
|
20
|
+
reminderChannelStatuses: {
|
|
21
|
+
id: any;
|
|
22
|
+
calendarId: any;
|
|
23
|
+
channelId: any;
|
|
24
|
+
status: boolean;
|
|
25
|
+
appointmentReminders: any;
|
|
26
|
+
__typename: string;
|
|
27
|
+
}[];
|
|
28
|
+
members: {
|
|
29
|
+
id: any;
|
|
30
|
+
name: any;
|
|
31
|
+
email: any;
|
|
32
|
+
status: any;
|
|
33
|
+
__typename: string;
|
|
34
|
+
}[];
|
|
35
|
+
createdOn: any;
|
|
36
|
+
modifiedOn: any;
|
|
37
|
+
name: any;
|
|
38
|
+
timeZoneId: any;
|
|
39
|
+
description: any;
|
|
40
|
+
assignmentType: number | null;
|
|
41
|
+
duration: number | null;
|
|
42
|
+
bookingLimit: number | null;
|
|
43
|
+
calendarJson: any;
|
|
44
|
+
isThirdPartySaved: boolean;
|
|
45
|
+
themeId: number | null;
|
|
46
|
+
theme: {
|
|
47
|
+
id: any;
|
|
48
|
+
color: any;
|
|
49
|
+
logoUrl: any;
|
|
50
|
+
__typename: string;
|
|
51
|
+
} | null;
|
|
52
|
+
openingHours: {
|
|
53
|
+
id: any;
|
|
54
|
+
createdOn: any;
|
|
55
|
+
modifiedOn: any;
|
|
56
|
+
member: any;
|
|
57
|
+
openingHourId: any;
|
|
58
|
+
calendarId: any;
|
|
59
|
+
participantId: any;
|
|
60
|
+
days: any;
|
|
61
|
+
startHour: any;
|
|
62
|
+
startMinute: any;
|
|
63
|
+
endHour: any;
|
|
64
|
+
endMinute: any;
|
|
65
|
+
off: boolean;
|
|
66
|
+
__typename: string;
|
|
67
|
+
}[];
|
|
68
|
+
appointmentUserDefinedFields: any;
|
|
69
|
+
__typename: string;
|
|
70
|
+
} | null;
|