@blazeo.com/appointment-client 1.0.13 → 1.0.14
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.14.tgz +0 -0
- package/package.json +3 -2
- package/sample/src/EventTab.jsx +435 -395
- package/src/calendar/calendarCreation.ts +62 -15
- package/src/events/getAppointmentsByFilter.ts +98 -0
- package/src/index.ts +15 -4
- package/blazeo.com-appointment-client-1.0.11.tgz +0 -0
- package/blazeo.com-appointment-client-1.0.13.tgz +0 -0
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts +0 -8
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts.map +0 -1
- package/dist/calendar/blazeoCalendarRelationMethods.js +0 -16
- package/dist/calendar/blazeoCalendarRelationMethods.js.map +0 -1
- package/dist/calendar/buildUnifiedCalendarView.d.ts +0 -39
- package/dist/calendar/buildUnifiedCalendarView.js +0 -301
- package/dist/calendar/calendarCreation.d.ts +0 -27
- package/dist/calendar/calendarCreation.js +0 -191
- package/dist/calendar/calendarCreationFacade.d.ts +0 -27
- package/dist/calendar/calendarCreationFacade.d.ts.map +0 -1
- package/dist/calendar/calendarCreationFacade.js +0 -167
- package/dist/calendar/calendarCreationFacade.js.map +0 -1
- package/dist/calendar/createCalendar.d.ts +0 -81
- package/dist/calendar/createCalendar.d.ts.map +0 -1
- package/dist/calendar/createCalendar.js +0 -206
- package/dist/calendar/createCalendar.js.map +0 -1
- package/dist/calendar/fetchCalendarDetails.d.ts +0 -41
- package/dist/calendar/fetchCalendarDetails.js +0 -265
- package/dist/calendar/fetchCalendarWithOpeningHours.d.ts +0 -25
- package/dist/calendar/fetchCalendarWithOpeningHours.js +0 -114
- package/dist/calendar/getAllParticipantOpeningHours.d.ts +0 -22
- package/dist/calendar/getAllParticipantOpeningHours.js +0 -22
- package/dist/calendar/getCalendarsByCompany.d.ts +0 -9
- package/dist/calendar/getCalendarsByCompany.js +0 -62
- package/dist/calendar/getOpeningHours.d.ts +0 -8
- package/dist/calendar/getOpeningHours.js +0 -9
- package/dist/calendar/getParticipantOpeningHours.d.ts +0 -37
- package/dist/calendar/getParticipantOpeningHours.js +0 -48
- package/dist/calendar/getParticipants.d.ts +0 -7
- package/dist/calendar/getParticipants.js +0 -13
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts +0 -10
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts.map +0 -1
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js +0 -44
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js.map +0 -1
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts +0 -29
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts.map +0 -1
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js +0 -44
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js.map +0 -1
- package/dist/calendar/mapToDesiredResponse.d.ts +0 -56
- package/dist/calendar/mapToDesiredResponse.js +0 -111
- package/dist/config/applyBlazeoClientConfig.d.ts +0 -3
- package/dist/config/applyBlazeoClientConfig.d.ts.map +0 -1
- package/dist/config/applyBlazeoClientConfig.js +0 -14
- package/dist/config/applyBlazeoClientConfig.js.map +0 -1
- package/dist/config/applyBlazeoDefaults.d.ts +0 -2
- package/dist/config/applyBlazeoDefaults.d.ts.map +0 -1
- package/dist/config/applyBlazeoDefaults.js +0 -14
- package/dist/config/applyBlazeoDefaults.js.map +0 -1
- package/dist/config/blazeo.config.d.ts +0 -11
- package/dist/config/blazeo.config.d.ts.map +0 -1
- package/dist/config/blazeo.config.js +0 -11
- package/dist/config/blazeo.config.js.map +0 -1
- package/dist/config/blazeoClientDefaults.d.ts +0 -11
- package/dist/config/blazeoClientDefaults.d.ts.map +0 -1
- package/dist/config/blazeoClientDefaults.js +0 -11
- package/dist/config/blazeoClientDefaults.js.map +0 -1
- package/dist/config/ensureBlazeoHttpReady.d.ts +0 -17
- package/dist/config/ensureBlazeoHttpReady.js +0 -31
- package/dist/config/initializeAppointmentClient.d.ts +0 -11
- package/dist/config/initializeAppointmentClient.d.ts.map +0 -1
- package/dist/config/initializeAppointmentClient.js +0 -15
- package/dist/config/initializeAppointmentClient.js.map +0 -1
- package/dist/config/syncBlazeoConnection.d.ts +0 -6
- package/dist/config/syncBlazeoConnection.js +0 -18
- package/dist/events/appointmentEventFacade.d.ts +0 -67
- package/dist/events/appointmentEventFacade.d.ts.map +0 -1
- package/dist/events/appointmentEventFacade.js +0 -124
- package/dist/events/appointmentEventFacade.js.map +0 -1
- package/dist/events/mapAppointmentToEventSnapshot.d.ts +0 -5
- package/dist/events/mapAppointmentToEventSnapshot.d.ts.map +0 -1
- package/dist/events/mapAppointmentToEventSnapshot.js +0 -57
- package/dist/events/mapAppointmentToEventSnapshot.js.map +0 -1
- package/dist/exampleData.d.ts +0 -119
- package/dist/exampleData.d.ts.map +0 -1
- package/dist/exampleData.js +0 -71
- package/dist/exampleData.js.map +0 -1
- package/dist/facade/calendarCreationFacade.d.ts +0 -40
- package/dist/facade/calendarCreationFacade.d.ts.map +0 -1
- package/dist/facade/calendarCreationFacade.js +0 -96
- package/dist/facade/calendarCreationFacade.js.map +0 -1
- package/dist/facade/mapCalendarBOToSnapshot.d.ts +0 -10
- package/dist/facade/mapCalendarBOToSnapshot.d.ts.map +0 -1
- package/dist/facade/mapCalendarBOToSnapshot.js +0 -44
- package/dist/facade/mapCalendarBOToSnapshot.js.map +0 -1
- package/dist/facades/index.d.ts +0 -12
- package/dist/facades/index.d.ts.map +0 -1
- package/dist/facades/index.js +0 -12
- package/dist/facades/index.js.map +0 -1
- package/dist/index.d.ts +0 -79
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -39
- package/dist/index.js.map +0 -1
- package/dist/lead/fetchLeadDetails.d.ts +0 -56
- package/dist/lead/fetchLeadDetails.js +0 -61
- package/dist/models/CalendarRootModel.d.ts +0 -56
- package/dist/models/CalendarRootModel.d.ts.map +0 -1
- package/dist/models/CalendarRootModel.js +0 -54
- package/dist/models/CalendarRootModel.js.map +0 -1
- package/dist/models/CalendarSlotModel.d.ts +0 -9
- package/dist/models/CalendarSlotModel.d.ts.map +0 -1
- package/dist/models/CalendarSlotModel.js +0 -8
- package/dist/models/CalendarSlotModel.js.map +0 -1
- package/dist/models/EventModel.d.ts +0 -11
- package/dist/models/EventModel.d.ts.map +0 -1
- package/dist/models/EventModel.js +0 -10
- package/dist/models/EventModel.js.map +0 -1
- package/dist/models/ParticipantModel.d.ts +0 -9
- package/dist/models/ParticipantModel.d.ts.map +0 -1
- package/dist/models/ParticipantModel.js +0 -8
- package/dist/models/ParticipantModel.js.map +0 -1
- package/dist/models/index.d.ts +0 -5
- package/dist/models/index.d.ts.map +0 -1
- package/dist/models/index.js +0 -5
- package/dist/models/index.js.map +0 -1
- package/dist/types/appointment.d.ts +0 -28
- package/dist/types/appointment.d.ts.map +0 -1
- package/dist/types/appointment.js +0 -6
- package/dist/types/appointment.js.map +0 -1
- package/dist/types/calendar.d.ts +0 -52
- package/dist/types/calendar.d.ts.map +0 -1
- package/dist/types/calendar.js +0 -6
- package/dist/types/calendar.js.map +0 -1
- package/dist/types/calendarBo.d.ts +0 -62
- package/dist/types/calendarBo.d.ts.map +0 -1
- package/dist/types/calendarBo.js +0 -6
- package/dist/types/calendarBo.js.map +0 -1
- package/sample/package-lock.json +0 -1778
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
import { CalendarModel, configure, getConfig } from "@blazeo.com/calendar-client";
|
|
2
|
-
import { blazeoClientConfig } from "../config/blazeoClientDefaults.js";
|
|
3
|
-
import { mapCalendarBOToSnapshot } from "./mapCalendarToBlazeoSnapshot.js";
|
|
4
|
-
function isFailureStatus(res) {
|
|
5
|
-
return res.status !== "success" && res.status !== "Success";
|
|
6
|
-
}
|
|
7
|
-
/** Merge per-call options with global Blazeo config (defaults file + `configure`). */
|
|
8
|
-
export function resolveBlazeoConnection(options = {}) {
|
|
9
|
-
const cfg = getConfig();
|
|
10
|
-
const fromFileBase = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
|
|
11
|
-
const fromFileConsumer = blazeoClientConfig.consumer?.trim();
|
|
12
|
-
const baseUrl = options.baseUrl?.trim().replace(/\/+$/, "") ||
|
|
13
|
-
cfg?.baseUrl?.replace(/\/+$/, "") ||
|
|
14
|
-
(fromFileBase || undefined);
|
|
15
|
-
const consumer = options.consumer?.trim() ||
|
|
16
|
-
cfg?.consumer ||
|
|
17
|
-
(fromFileConsumer || undefined);
|
|
18
|
-
return { baseUrl, consumer };
|
|
19
|
-
}
|
|
20
|
-
/** Shared MST `env` for Blazeo models (`Calendar`, `Event`, …). */
|
|
21
|
-
export function buildModelEnv(baseUrl, consumer, forLocalOnly) {
|
|
22
|
-
if (forLocalOnly && !baseUrl) {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
25
|
-
const cfg = getConfig();
|
|
26
|
-
const env = {};
|
|
27
|
-
if (baseUrl) {
|
|
28
|
-
env.baseUrl = baseUrl;
|
|
29
|
-
}
|
|
30
|
-
else if (cfg?.baseUrl) {
|
|
31
|
-
env.baseUrl = cfg.baseUrl;
|
|
32
|
-
}
|
|
33
|
-
if (consumer) {
|
|
34
|
-
env.consumer = consumer;
|
|
35
|
-
}
|
|
36
|
-
else if (cfg?.consumer) {
|
|
37
|
-
env.consumer = cfg.consumer;
|
|
38
|
-
}
|
|
39
|
-
if (cfg?.fetch != null)
|
|
40
|
-
env.fetch = cfg.fetch;
|
|
41
|
-
if (cfg?.getDefaultOffset != null) {
|
|
42
|
-
env.getDefaultOffset = cfg.getDefaultOffset;
|
|
43
|
-
}
|
|
44
|
-
return env;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Uses {@link resolveBlazeoConnection} (defaults + `configure` + optional overrides),
|
|
48
|
-
* then `CalendarModel.create` and `calendar.create()` unless `localOnly`.
|
|
49
|
-
*/
|
|
50
|
-
export async function createCalendarAsync(calendar, options = {}) {
|
|
51
|
-
try {
|
|
52
|
-
const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
|
|
53
|
-
if (resolvedBase) {
|
|
54
|
-
configure({
|
|
55
|
-
baseUrl: resolvedBase,
|
|
56
|
-
...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
const baseUrl = resolvedBase;
|
|
60
|
-
const consumer = resolvedConsumer;
|
|
61
|
-
if (!options.localOnly && !baseUrl) {
|
|
62
|
-
return {
|
|
63
|
-
ok: false,
|
|
64
|
-
error: "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeoClientDefaults.ts` or call `configure({ baseUrl })`.",
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const snapshot = mapCalendarBOToSnapshot(calendar);
|
|
68
|
-
const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
|
|
69
|
-
if (!options.localOnly && env.baseUrl == null) {
|
|
70
|
-
return {
|
|
71
|
-
ok: false,
|
|
72
|
-
error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
const calendarNode = CalendarModel.create(snapshot, env);
|
|
76
|
-
if (options.localOnly) {
|
|
77
|
-
return { ok: true, calendar: calendarNode };
|
|
78
|
-
}
|
|
79
|
-
const apiRes = await calendarNode.create();
|
|
80
|
-
if (isFailureStatus(apiRes)) {
|
|
81
|
-
const msg = apiRes.message ??
|
|
82
|
-
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
83
|
-
JSON.stringify(apiRes);
|
|
84
|
-
return {
|
|
85
|
-
ok: false,
|
|
86
|
-
error: msg || "Calendar create failed",
|
|
87
|
-
apiResponse: apiRes,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
return { ok: true, calendar: calendarNode, apiResponse: apiRes };
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
94
|
-
return { ok: false, error: message };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Uses {@link resolveBlazeoConnection}, builds a `Calendar` node from {@link mapCalendarBOToSnapshot},
|
|
99
|
-
* then `calendar.update()` → POST `/Calendar/Event/Update` unless `localOnly`.
|
|
100
|
-
*/
|
|
101
|
-
export async function updateCalendarAsync(calendar, options = {}) {
|
|
102
|
-
try {
|
|
103
|
-
const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
|
|
104
|
-
if (resolvedBase) {
|
|
105
|
-
configure({
|
|
106
|
-
baseUrl: resolvedBase,
|
|
107
|
-
...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const baseUrl = resolvedBase;
|
|
111
|
-
const consumer = resolvedConsumer;
|
|
112
|
-
const snapshot = mapCalendarBOToSnapshot(calendar);
|
|
113
|
-
if (!options.localOnly && !(calendar.calendarId?.trim())) {
|
|
114
|
-
return {
|
|
115
|
-
ok: false,
|
|
116
|
-
error: "calendarId is required for update. Pass an existing id.",
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (!options.localOnly && !baseUrl) {
|
|
120
|
-
return {
|
|
121
|
-
ok: false,
|
|
122
|
-
error: "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeoClientDefaults.ts` or call `configure({ baseUrl })`.",
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
|
|
126
|
-
if (!options.localOnly && env.baseUrl == null) {
|
|
127
|
-
return {
|
|
128
|
-
ok: false,
|
|
129
|
-
error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
const calendarNode = CalendarModel.create(snapshot, env);
|
|
133
|
-
if (options.localOnly) {
|
|
134
|
-
return { ok: true, calendar: calendarNode };
|
|
135
|
-
}
|
|
136
|
-
const apiRes = await calendarNode.update();
|
|
137
|
-
if (isFailureStatus(apiRes)) {
|
|
138
|
-
const msg = apiRes.message ??
|
|
139
|
-
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
140
|
-
JSON.stringify(apiRes);
|
|
141
|
-
return {
|
|
142
|
-
ok: false,
|
|
143
|
-
error: msg || "Calendar update failed",
|
|
144
|
-
apiResponse: apiRes,
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
return { ok: true, calendar: calendarNode, apiResponse: apiRes };
|
|
148
|
-
}
|
|
149
|
-
catch (err) {
|
|
150
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
151
|
-
return { ok: false, error: message };
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Removes a calendar via `calendar.remove()` → GET `/Calendar/Remove?calendar_id=…`.
|
|
156
|
-
*/
|
|
157
|
-
export async function deleteCalendarAsync(calendarId, options = {}) {
|
|
158
|
-
try {
|
|
159
|
-
const id = calendarId.trim();
|
|
160
|
-
if (!id) {
|
|
161
|
-
return { ok: false, error: "calendarId is required for delete." };
|
|
162
|
-
}
|
|
163
|
-
const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
|
|
164
|
-
if (resolvedBase) {
|
|
165
|
-
configure({
|
|
166
|
-
baseUrl: resolvedBase,
|
|
167
|
-
...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
const baseUrl = resolvedBase;
|
|
171
|
-
const consumer = resolvedConsumer;
|
|
172
|
-
if (!options.localOnly && !baseUrl) {
|
|
173
|
-
return {
|
|
174
|
-
ok: false,
|
|
175
|
-
error: "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeoClientDefaults.ts` or call `configure({ baseUrl })`.",
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
|
|
179
|
-
if (!options.localOnly && env.baseUrl == null) {
|
|
180
|
-
return {
|
|
181
|
-
ok: false,
|
|
182
|
-
error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
const calendarNode = CalendarModel.create({ calendarId: id }, env);
|
|
186
|
-
if (options.localOnly) {
|
|
187
|
-
return { ok: true, calendar: calendarNode };
|
|
188
|
-
}
|
|
189
|
-
const apiRes = await calendarNode.remove();
|
|
190
|
-
if (isFailureStatus(apiRes)) {
|
|
191
|
-
const msg = apiRes.message ??
|
|
192
|
-
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
193
|
-
JSON.stringify(apiRes);
|
|
194
|
-
return {
|
|
195
|
-
ok: false,
|
|
196
|
-
error: msg || "Calendar delete failed",
|
|
197
|
-
apiResponse: apiRes,
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
return { ok: true, calendar: calendarNode, apiResponse: apiRes };
|
|
201
|
-
}
|
|
202
|
-
catch (err) {
|
|
203
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
204
|
-
return { ok: false, error: message };
|
|
205
|
-
}
|
|
206
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCalendar.js","sourceRoot":"","sources":["../../src/calendar/createCalendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AA2C3E,SAAS,eAAe,CAAC,GAAiC;IACxD,OAAO,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC;AA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3D,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACzB,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG,IAAI,wBAAwB;gBACtC,WAAW,EAAE,MAAM;aACpB,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;IACnE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IACvC,CAAC;AACH,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type UnifiedCalendarView } from "./buildUnifiedCalendarView.js";
|
|
2
|
-
/**
|
|
3
|
-
* Normalizes the REST envelope from `calendar.getParticipantOpeningHours()`
|
|
4
|
-
* (`GET /Calendar/Participant/OpeningHours/Get`) into a plain row array.
|
|
5
|
-
*/
|
|
6
|
-
export declare function normalizeOpeningHours(res: any): any[];
|
|
7
|
-
/**
|
|
8
|
-
* Calendar + legacy opening hours + full detail bundle (`fetchCalendarDetails`), **or**
|
|
9
|
-
* only the **single unified object** via {@link fetchCalendarBundle}.
|
|
10
|
-
*
|
|
11
|
-
* **Flow**
|
|
12
|
-
* 1. **Calendar** — parallel `CalendarModel.get` + `getRaw` (both `GET /Calendar/Get`: model + raw envelope).
|
|
13
|
-
* 2. **Legacy `openingHours`** — embed from raw, else `getParticipantOpeningHours` (narrow endpoint).
|
|
14
|
-
* 3. **`calendarView` (one object)** — in parallel after calendar is known:
|
|
15
|
-
* - `GET /Calendar/Participant/All` and optional `/Participant/Get` merge when both return rows.
|
|
16
|
-
* - `GET /Calendar/Participants/GetInfo`
|
|
17
|
-
* - `GET /Calendar/Participant/OpeningHours/All/Get` when options enable it (`preferAllParticipantOpeningHours`)
|
|
18
|
-
* Then `calendarView` = calendar snapshot fields + **`members`** (with **`participantInfo`**) + **`openingHours`**
|
|
19
|
-
* (`openingHours[].member` → `members[].id`).
|
|
20
|
-
*
|
|
21
|
-
* Server still performs multiple HTTP calls; on the client, **`calendarView`** is returned as **one object**.
|
|
22
|
-
*/
|
|
23
|
-
export declare function fetchCalendarDetails(calendarId: string, options?: {
|
|
24
|
-
includeParticipantsInfo?: boolean;
|
|
25
|
-
includeUnifiedCalendarView?: boolean;
|
|
26
|
-
/** Prefer all-participant opening hours for **`calendarView`** when the API returns rows (default `true`). */
|
|
27
|
-
preferAllParticipantOpeningHours?: boolean;
|
|
28
|
-
/** Optional; applied with `resolveBlazeoConnection` so `CalendarModel.get` sees `baseUrl` without prior global `configure`. */
|
|
29
|
-
baseUrl?: string;
|
|
30
|
-
consumer?: string;
|
|
31
|
-
}): Promise<any>;
|
|
32
|
-
/**
|
|
33
|
-
* Single return value only: unified calendar **`calendarView`** —
|
|
34
|
-
* snapshot fields plus **`members`** (with **`participantInfo`**) plus **`openingHours`**
|
|
35
|
-
* (prefers all-participant opening hours when available). Same shape as `fetchCalendarDetails().calendarView`.
|
|
36
|
-
* Returns **`null`** if the calendar cannot be loaded (`CalendarModel.get`).
|
|
37
|
-
*/
|
|
38
|
-
export declare function fetchCalendarBundle(calendarId: string, connection?: {
|
|
39
|
-
baseUrl?: string;
|
|
40
|
-
consumer?: string;
|
|
41
|
-
}): Promise<UnifiedCalendarView | null>;
|
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
import { CalendarModel } from "@blazeo.com/calendar-client";
|
|
2
|
-
import { ensureBlazeoHttpReady } from "../config/ensureBlazeoHttpReady.js";
|
|
3
|
-
import { unwrapCalendarGetData, pickOpeningHoursArrayFromCalendarPayload, normalizeParticipantOpeningHoursResponse, } from "./fetchCalendarWithOpeningHours.js";
|
|
4
|
-
import { buildUnifiedCalendarView } from "./buildUnifiedCalendarView.js";
|
|
5
|
-
import { mapToDesiredCalendarResponse } from "./mapToDesiredResponse.js";
|
|
6
|
-
/**
|
|
7
|
-
* Normalizes the REST envelope from `calendar.getParticipantOpeningHours()`
|
|
8
|
-
* (`GET /Calendar/Participant/OpeningHours/Get`) into a plain row array.
|
|
9
|
-
*/
|
|
10
|
-
export function normalizeOpeningHours(res) {
|
|
11
|
-
const { list } = normalizeParticipantOpeningHoursResponse(res);
|
|
12
|
-
return Array.isArray(list) ? list : [];
|
|
13
|
-
}
|
|
14
|
-
function normalizeAllParticipantOpeningHoursResult(raw) {
|
|
15
|
-
if (Array.isArray(raw))
|
|
16
|
-
return raw;
|
|
17
|
-
const { list } = normalizeParticipantOpeningHoursResponse(raw);
|
|
18
|
-
return Array.isArray(list) ? list : [];
|
|
19
|
-
}
|
|
20
|
-
/** Prefer union of `/Participant/All` and `/Participant/Get` so members reconcile when either list is incomplete. */
|
|
21
|
-
function mergeParticipantSnapshots(a, b) {
|
|
22
|
-
const byKey = new Map();
|
|
23
|
-
const ingest = (p) => {
|
|
24
|
-
if (p == null)
|
|
25
|
-
return;
|
|
26
|
-
const participantId = String(p.participantId ?? p.ParticipantId ?? p.participant_id ?? "").trim().toLowerCase();
|
|
27
|
-
const calPartId = String(p.calendarParticipantId ?? p.CalendarParticipantId ?? p.calendarparticipant_id ?? "").trim()
|
|
28
|
-
.toLowerCase();
|
|
29
|
-
const key = participantId || calPartId;
|
|
30
|
-
if (!key)
|
|
31
|
-
return;
|
|
32
|
-
if (!byKey.has(key))
|
|
33
|
-
byKey.set(key, p);
|
|
34
|
-
};
|
|
35
|
-
if (Array.isArray(a))
|
|
36
|
-
a.forEach(ingest);
|
|
37
|
-
if (Array.isArray(b))
|
|
38
|
-
b.forEach(ingest);
|
|
39
|
-
return [...byKey.values()];
|
|
40
|
-
}
|
|
41
|
-
/** Coerce MST / envelope / nested `data` shapes into a plain array for participants and GetInfo lists. */
|
|
42
|
-
function unwrapModelList(raw) {
|
|
43
|
-
if (raw == null)
|
|
44
|
-
return [];
|
|
45
|
-
if (Array.isArray(raw))
|
|
46
|
-
return raw;
|
|
47
|
-
if (typeof raw === "string") {
|
|
48
|
-
try {
|
|
49
|
-
return unwrapModelList(JSON.parse(raw));
|
|
50
|
-
}
|
|
51
|
-
catch {
|
|
52
|
-
return [];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
if (typeof raw !== "object")
|
|
56
|
-
return [];
|
|
57
|
-
const topArr = raw.items ?? raw.Items;
|
|
58
|
-
if (Array.isArray(topArr))
|
|
59
|
-
return topArr;
|
|
60
|
-
const d = raw.data ?? raw.Data;
|
|
61
|
-
if (Array.isArray(d))
|
|
62
|
-
return d;
|
|
63
|
-
if (d != null && typeof d === "object") {
|
|
64
|
-
const inner = d.data ?? d.Data ?? d.items ?? d.Items;
|
|
65
|
-
if (Array.isArray(inner))
|
|
66
|
-
return inner;
|
|
67
|
-
}
|
|
68
|
-
return [];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Calendar + legacy opening hours + full detail bundle (`fetchCalendarDetails`), **or**
|
|
72
|
-
* only the **single unified object** via {@link fetchCalendarBundle}.
|
|
73
|
-
*
|
|
74
|
-
* **Flow**
|
|
75
|
-
* 1. **Calendar** — parallel `CalendarModel.get` + `getRaw` (both `GET /Calendar/Get`: model + raw envelope).
|
|
76
|
-
* 2. **Legacy `openingHours`** — embed from raw, else `getParticipantOpeningHours` (narrow endpoint).
|
|
77
|
-
* 3. **`calendarView` (one object)** — in parallel after calendar is known:
|
|
78
|
-
* - `GET /Calendar/Participant/All` and optional `/Participant/Get` merge when both return rows.
|
|
79
|
-
* - `GET /Calendar/Participants/GetInfo`
|
|
80
|
-
* - `GET /Calendar/Participant/OpeningHours/All/Get` when options enable it (`preferAllParticipantOpeningHours`)
|
|
81
|
-
* Then `calendarView` = calendar snapshot fields + **`members`** (with **`participantInfo`**) + **`openingHours`**
|
|
82
|
-
* (`openingHours[].member` → `members[].id`).
|
|
83
|
-
*
|
|
84
|
-
* Server still performs multiple HTTP calls; on the client, **`calendarView`** is returned as **one object**.
|
|
85
|
-
*/
|
|
86
|
-
export async function fetchCalendarDetails(calendarId, options = {}) {
|
|
87
|
-
const { includeParticipantsInfo = false, includeUnifiedCalendarView = true, preferAllParticipantOpeningHours = true, baseUrl: optBaseUrl, consumer: optConsumer, } = options;
|
|
88
|
-
const conn = ensureBlazeoHttpReady({ baseUrl: optBaseUrl, consumer: optConsumer });
|
|
89
|
-
if (!conn.ok) {
|
|
90
|
-
return {
|
|
91
|
-
calendar: null,
|
|
92
|
-
cal: null,
|
|
93
|
-
calendarView: null,
|
|
94
|
-
openingHours: [],
|
|
95
|
-
participants: [],
|
|
96
|
-
participantsInfo: null,
|
|
97
|
-
allParticipantOpeningHours: null,
|
|
98
|
-
embeddedFromGet: [],
|
|
99
|
-
fromCalendarGet: false,
|
|
100
|
-
fromParticipantApi: false,
|
|
101
|
-
participantOpeningHoursResponse: null,
|
|
102
|
-
rawGet: null,
|
|
103
|
-
meta: { ok: false, reason: "missing_base_url", detail: conn.error },
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const fetchParticipantsInfo = includeParticipantsInfo || includeUnifiedCalendarView;
|
|
107
|
-
const fetchAllHours = includeUnifiedCalendarView && preferAllParticipantOpeningHours;
|
|
108
|
-
// Calendar: `GET /Calendar/Get` is used to get the raw data first.
|
|
109
|
-
const rawRes = await CalendarModel.getRaw(calendarId);
|
|
110
|
-
const payload = unwrapCalendarGetData(rawRes);
|
|
111
|
-
if (!payload) {
|
|
112
|
-
return {
|
|
113
|
-
calendar: null,
|
|
114
|
-
cal: null,
|
|
115
|
-
calendarView: null,
|
|
116
|
-
openingHours: [],
|
|
117
|
-
participants: null,
|
|
118
|
-
participantsInfo: null,
|
|
119
|
-
allParticipantOpeningHours: null,
|
|
120
|
-
embeddedFromGet: [],
|
|
121
|
-
fromCalendarGet: false,
|
|
122
|
-
fromParticipantApi: false,
|
|
123
|
-
participantOpeningHoursResponse: null,
|
|
124
|
-
rawGet: rawRes,
|
|
125
|
-
meta: { ok: false, reason: "calendar_not_found" },
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
// Build the model instance manually to ensure the environment is correctly set.
|
|
129
|
-
// The static CalendarModel.get in calendar-client has a bug where it wraps env in { env: ... }.
|
|
130
|
-
const cal = CalendarModel.create({ ...payload, calendarId }, { baseUrl: conn.baseUrl, consumer: conn.consumer });
|
|
131
|
-
const embedded = pickOpeningHoursArrayFromCalendarPayload(payload) ?? [];
|
|
132
|
-
let participantOpeningHoursResponse = null;
|
|
133
|
-
let resolved = embedded.length > 0 ? embedded : null;
|
|
134
|
-
if ((resolved == null || resolved.length === 0) && cal != null) {
|
|
135
|
-
participantOpeningHoursResponse = await cal.getParticipantOpeningHours({ calendarId });
|
|
136
|
-
const { list } = normalizeParticipantOpeningHoursResponse(participantOpeningHoursResponse);
|
|
137
|
-
if (list != null && list.length > 0)
|
|
138
|
-
resolved = list;
|
|
139
|
-
}
|
|
140
|
-
const openingHours = Array.isArray(resolved) ? resolved : [];
|
|
141
|
-
// 2) Participants + participant info + all participant opening hours (parallel)
|
|
142
|
-
const getCalPart = CalendarModel.getCalendarParticipant;
|
|
143
|
-
const participantsViaGetPromise = includeUnifiedCalendarView && typeof getCalPart === "function"
|
|
144
|
-
? getCalPart.call(CalendarModel, calendarId)
|
|
145
|
-
: Promise.resolve(null);
|
|
146
|
-
const [participantsRaw, participantsViaGet, participantsInfoRaw, allHoursRaw] = await Promise.all([
|
|
147
|
-
cal.getParticipants(),
|
|
148
|
-
participantsViaGetPromise,
|
|
149
|
-
fetchParticipantsInfo ? cal.getParticipantsInfo() : Promise.resolve(null),
|
|
150
|
-
fetchAllHours ? cal.getAllParticipantOpeningHours() : Promise.resolve(null),
|
|
151
|
-
]);
|
|
152
|
-
const participantList = mergeParticipantSnapshots(unwrapModelList(participantsRaw), unwrapModelList(participantsViaGet));
|
|
153
|
-
const infoList = unwrapModelList(participantsInfoRaw);
|
|
154
|
-
// Merge participantList and infoList to ensure we have all members
|
|
155
|
-
const mergedParticipantsMap = new Map();
|
|
156
|
-
// Prefer the participantId GUID; fall back to numeric id.
|
|
157
|
-
const getAnyId = (obj) => obj.participantId ?? obj.ParticipantId ?? obj.participant_id ?? obj.id ?? obj.Id;
|
|
158
|
-
// 1. Add from standard list
|
|
159
|
-
participantList.forEach((p) => {
|
|
160
|
-
const id = getAnyId(p);
|
|
161
|
-
if (id) {
|
|
162
|
-
mergedParticipantsMap.set(String(id).toLowerCase(), {
|
|
163
|
-
id: id,
|
|
164
|
-
name: p.name ?? p.Name ?? p.alias ?? p.Alias ?? "Member",
|
|
165
|
-
email: p.email ?? p.Email,
|
|
166
|
-
status: p.status ?? p.Status ?? 0,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
// 2. Add from info list (fallback/enrich)
|
|
171
|
-
infoList.forEach((i) => {
|
|
172
|
-
const id = getAnyId(i);
|
|
173
|
-
if (!id)
|
|
174
|
-
return;
|
|
175
|
-
const key = String(id).toLowerCase();
|
|
176
|
-
const existing = mergedParticipantsMap.get(key);
|
|
177
|
-
if (!existing) {
|
|
178
|
-
mergedParticipantsMap.set(key, {
|
|
179
|
-
id: id,
|
|
180
|
-
name: i.alias || i.Alias || i.name || i.Name || "Member",
|
|
181
|
-
email: i.email || i.Email,
|
|
182
|
-
status: i.status ?? i.Status ?? (i.isApproved ? 1 : 0),
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
// Enrich existing with email/name if missing
|
|
187
|
-
if (!existing.email)
|
|
188
|
-
existing.email = i.email || i.Email;
|
|
189
|
-
if (!existing.name || existing.name === "Member") {
|
|
190
|
-
existing.name = i.alias || i.Alias || i.name || i.Name || existing.name;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
// 3. Synthetic Fallback: If openingHours reference a member we don't have, add them.
|
|
195
|
-
openingHours.forEach((oh) => {
|
|
196
|
-
const mid = oh.member ?? oh.Member ?? oh.participantId ?? oh.ParticipantId;
|
|
197
|
-
if (mid) {
|
|
198
|
-
const key = String(mid).toLowerCase();
|
|
199
|
-
if (!mergedParticipantsMap.has(key)) {
|
|
200
|
-
mergedParticipantsMap.set(key, {
|
|
201
|
-
id: mid,
|
|
202
|
-
name: "Member",
|
|
203
|
-
email: null,
|
|
204
|
-
status: 0,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
const finalParticipantList = Array.from(mergedParticipantsMap.values());
|
|
210
|
-
const allParticipantOpeningHours = fetchAllHours ? normalizeAllParticipantOpeningHoursResult(allHoursRaw) : null;
|
|
211
|
-
const openingHoursForUnifiedView = includeUnifiedCalendarView &&
|
|
212
|
-
preferAllParticipantOpeningHours &&
|
|
213
|
-
allParticipantOpeningHours != null &&
|
|
214
|
-
allParticipantOpeningHours.length > 0
|
|
215
|
-
? allParticipantOpeningHours
|
|
216
|
-
: openingHours;
|
|
217
|
-
const calendarViewRaw = includeUnifiedCalendarView
|
|
218
|
-
? buildUnifiedCalendarView(payload, openingHoursForUnifiedView, finalParticipantList, infoList)
|
|
219
|
-
: null;
|
|
220
|
-
const calendarView = calendarViewRaw ? mapToDesiredCalendarResponse(calendarViewRaw, calendarViewRaw.openingHours, calendarViewRaw.members) : null;
|
|
221
|
-
const unifiedUsedAllEndpoint = includeUnifiedCalendarView &&
|
|
222
|
-
preferAllParticipantOpeningHours &&
|
|
223
|
-
allParticipantOpeningHours != null &&
|
|
224
|
-
allParticipantOpeningHours.length > 0;
|
|
225
|
-
if (!calendarView)
|
|
226
|
-
return null;
|
|
227
|
-
// Use the mapper to normalize the final output, ensuring all fields like duration,
|
|
228
|
-
// bookingPageTitle, calendarId, etc. are correctly picked and named.
|
|
229
|
-
const finalView = mapToDesiredCalendarResponse(payload, calendarView.openingHours, calendarView.members);
|
|
230
|
-
// Attach metadata as non-enumerable properties so they don't show up in JSON.stringify
|
|
231
|
-
// but are still accessible for debugging if needed.
|
|
232
|
-
Object.defineProperties(finalView, {
|
|
233
|
-
_cal: { value: cal, enumerable: false },
|
|
234
|
-
_participants: { value: participantList, enumerable: false },
|
|
235
|
-
_openingHours: { value: openingHours, enumerable: false },
|
|
236
|
-
_rawGet: { value: rawRes, enumerable: false },
|
|
237
|
-
_meta: {
|
|
238
|
-
value: {
|
|
239
|
-
ok: true,
|
|
240
|
-
calendarViewUsedAllParticipantOpeningHours: unifiedUsedAllEndpoint,
|
|
241
|
-
calendarViewMemberCount: calendarView.members.length,
|
|
242
|
-
calendarViewOpeningHourCount: calendarView.openingHours.length,
|
|
243
|
-
},
|
|
244
|
-
enumerable: false
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
return finalView;
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Single return value only: unified calendar **`calendarView`** —
|
|
251
|
-
* snapshot fields plus **`members`** (with **`participantInfo`**) plus **`openingHours`**
|
|
252
|
-
* (prefers all-participant opening hours when available). Same shape as `fetchCalendarDetails().calendarView`.
|
|
253
|
-
* Returns **`null`** if the calendar cannot be loaded (`CalendarModel.get`).
|
|
254
|
-
*/
|
|
255
|
-
export async function fetchCalendarBundle(calendarId, connection) {
|
|
256
|
-
const d = await fetchCalendarDetails(calendarId, {
|
|
257
|
-
includeUnifiedCalendarView: true,
|
|
258
|
-
includeParticipantsInfo: true,
|
|
259
|
-
preferAllParticipantOpeningHours: true,
|
|
260
|
-
...connection,
|
|
261
|
-
});
|
|
262
|
-
if (!d)
|
|
263
|
-
return null;
|
|
264
|
-
return d;
|
|
265
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unwrap nested REST shapes: `res.data`, `res.Data`, or `res.data.data`.
|
|
3
|
-
*/
|
|
4
|
-
export declare function unwrapCalendarGetData(res: any): any;
|
|
5
|
-
/** `openingHours` / `OpeningHours` on the calendar object returned by GET /Calendar/
|
|
6
|
-
* Robustly picks opening hours array from a raw calendar payload.
|
|
7
|
-
*/
|
|
8
|
-
export declare function pickOpeningHoursArrayFromCalendarPayload(data: any): any[] | null;
|
|
9
|
-
/**
|
|
10
|
-
* Normalize `calendar.getParticipantOpeningHours()` response (`GET /Calendar/Participant/OpeningHours/Get`).
|
|
11
|
-
* Supports various Blazeo API shapes including nested data and common property names.
|
|
12
|
-
*/
|
|
13
|
-
export declare function normalizeParticipantOpeningHoursResponse(res: any): {
|
|
14
|
-
list: null;
|
|
15
|
-
raw: any;
|
|
16
|
-
} | {
|
|
17
|
-
list: any[];
|
|
18
|
-
raw: any;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Loads `CalendarModel` and attaches **`openingHours`** to the MST snapshot:
|
|
22
|
-
* 1. Prefer rows embedded on **GET /Calendar/Get** (`CalendarModel.getRaw` payload — `@blazeo.com/calendar-client` MST omits them).
|
|
23
|
-
* 2. If missing/empty, calls **`calendar.getParticipantOpeningHours()`** (`GET /Calendar/Participant/OpeningHours/Get`).
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchCalendarWithOpeningHours(calendarId: string, options?: any): Promise<any>;
|
|
@@ -1,114 +0,0 @@
|
|
|
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
|
-
}
|