@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
|
@@ -0,0 +1,99 @@
|
|
|
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 function mapToDesiredCalendarResponse(payload, openingHours = [], members = []) {
|
|
6
|
+
if (!payload)
|
|
7
|
+
return null;
|
|
8
|
+
const pick = (obj, ...keys) => {
|
|
9
|
+
for (const k of keys) {
|
|
10
|
+
if (obj[k] !== undefined && obj[k] !== null)
|
|
11
|
+
return obj[k];
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
};
|
|
15
|
+
const n = (v) => (v != null && v !== "" ? Number(v) : null);
|
|
16
|
+
// Map members with typename
|
|
17
|
+
const mappedMembers = members.map(m => ({
|
|
18
|
+
id: m.id ?? pick(m, "id", "Id"),
|
|
19
|
+
name: m.name ?? pick(m, "name", "Name", "alias", "Alias"),
|
|
20
|
+
email: m.email ?? pick(m, "email", "Email") ?? null,
|
|
21
|
+
status: m.status ?? pick(m, "status", "Status") ?? 0,
|
|
22
|
+
__typename: "Member"
|
|
23
|
+
}));
|
|
24
|
+
// Map opening hours with typename and raw fields
|
|
25
|
+
const mappedOpeningHours = openingHours.map(oh => ({
|
|
26
|
+
id: pick(oh, "id", "Id") ?? 0,
|
|
27
|
+
createdOn: pick(oh, "createdOn", "CreatedOn", "created_on") ?? "0001-01-01T00:00:00.000Z",
|
|
28
|
+
modifiedOn: pick(oh, "modifiedOn", "ModifiedOn", "modified_on") ?? "0001-01-01T00:00:00.000Z",
|
|
29
|
+
member: pick(oh, "member", "Member"),
|
|
30
|
+
openingHourId: pick(oh, "openingHourId", "OpeningHourId", "opening_hour_id") ?? "",
|
|
31
|
+
calendarId: pick(oh, "calendarId", "CalendarId", "calendar_id") ?? "",
|
|
32
|
+
participantId: pick(oh, "participantId", "ParticipantId", "participant_id") ?? "",
|
|
33
|
+
days: oh.days ?? [],
|
|
34
|
+
startHour: oh.startHour ?? pick(oh, "startHour", "StartHour") ?? 0,
|
|
35
|
+
startMinute: oh.startMinute ?? pick(oh, "startMinute", "StartMinute") ?? 0,
|
|
36
|
+
endHour: oh.endHour ?? pick(oh, "endHour", "EndHour") ?? 0,
|
|
37
|
+
endMinute: oh.endMinute ?? pick(oh, "endMinute", "EndMinute") ?? 0,
|
|
38
|
+
off: !!(oh.off ?? pick(oh, "off", "Off")),
|
|
39
|
+
__typename: "OpeningHour"
|
|
40
|
+
}));
|
|
41
|
+
// Map theme
|
|
42
|
+
const rawTheme = pick(payload, "theme", "Theme");
|
|
43
|
+
const theme = rawTheme ? {
|
|
44
|
+
id: pick(rawTheme, "id", "Id"),
|
|
45
|
+
color: pick(rawTheme, "color", "Color"),
|
|
46
|
+
logoUrl: pick(rawTheme, "logoUrl", "LogoUrl") ?? null,
|
|
47
|
+
__typename: "Theme"
|
|
48
|
+
} : null;
|
|
49
|
+
// Map reminders
|
|
50
|
+
const rawReminders = pick(payload, "reminderChannelStatuses", "ReminderChannelStatuses") ?? [];
|
|
51
|
+
const reminderChannelStatuses = Array.isArray(rawReminders) ? rawReminders.map((r) => ({
|
|
52
|
+
id: pick(r, "id", "Id"),
|
|
53
|
+
calendarId: pick(r, "calendarId", "CalendarId"),
|
|
54
|
+
channelId: pick(r, "channelId", "ChannelId"),
|
|
55
|
+
status: !!pick(r, "status", "Status"),
|
|
56
|
+
appointmentReminders: (pick(r, "appointmentReminders", "AppointmentReminders") ?? []).map((ar) => ({
|
|
57
|
+
id: pick(ar, "id", "Id"),
|
|
58
|
+
reminderChannelStatusId: pick(ar, "reminderChannelStatusId", "ReminderChannelStatusId"),
|
|
59
|
+
recipientType: pick(ar, "recipientType", "RecipientType"),
|
|
60
|
+
beforeEventTime: pick(ar, "beforeEventTime", "BeforeEventTime"),
|
|
61
|
+
unit: pick(ar, "unit", "Unit"),
|
|
62
|
+
__typename: "AppointmentReminder"
|
|
63
|
+
})),
|
|
64
|
+
__typename: "ReminderChannelStatus"
|
|
65
|
+
})) : [];
|
|
66
|
+
return {
|
|
67
|
+
id: n(pick(payload, "id", "Id")),
|
|
68
|
+
durationUnit: n(pick(payload, "durationUnit", "DurationUnit")),
|
|
69
|
+
minimumBookingNotice: n(pick(payload, "minimumBookingNotice", "MinimumBookingNotice")),
|
|
70
|
+
minimumBookingNoticeUnit: n(pick(payload, "minimumBookingNoticeUnit", "MinimumBookingNoticeUnit")),
|
|
71
|
+
minimumCancelationNotice: n(pick(payload, "minimumCancelationNotice", "MinimumCancelationNotice")),
|
|
72
|
+
minimumCancelationNoticeUnit: n(pick(payload, "minimumCancelationNoticeUnit", "MinimumCancelationNoticeUnit")),
|
|
73
|
+
futureLimit: n(pick(payload, "futureLimit", "FutureLimit")),
|
|
74
|
+
futureLimitUnit: n(pick(payload, "futureLimitUnit", "FutureLimitUnit")),
|
|
75
|
+
bufferTime: n(pick(payload, "bufferTime", "BufferTime")),
|
|
76
|
+
bufferTimeUnit: n(pick(payload, "bufferTimeUnit", "BufferTimeUnit")),
|
|
77
|
+
calendarLink: pick(payload, "calendarLink", "CalendarLink"),
|
|
78
|
+
uuid: pick(payload, "uuid", "Uuid", "calendarId", "CalendarId"),
|
|
79
|
+
location: pick(payload, "location", "Location") ?? "",
|
|
80
|
+
bookingPageTitle: pick(payload, "bookingPageTitle", "BookingPageTitle") ?? null,
|
|
81
|
+
reminderChannelStatuses,
|
|
82
|
+
members: mappedMembers,
|
|
83
|
+
createdOn: pick(payload, "createdOn", "CreatedOn") ?? "0001-01-01T00:00:00.000Z",
|
|
84
|
+
modifiedOn: pick(payload, "modifiedOn", "ModifiedOn") ?? "0001-01-01T00:00:00.000Z",
|
|
85
|
+
name: pick(payload, "name", "Name"),
|
|
86
|
+
timeZoneId: pick(payload, "timeZoneId", "TimeZoneId"),
|
|
87
|
+
description: pick(payload, "description", "Description") ?? "",
|
|
88
|
+
assignmentType: n(pick(payload, "assignmentType", "AssignmentType", "assignmentMethod", "AssignmentMethod")),
|
|
89
|
+
duration: n(pick(payload, "duration", "Duration")),
|
|
90
|
+
bookingLimit: n(pick(payload, "bookingLimit", "BookingLimit")),
|
|
91
|
+
calendarJson: pick(payload, "calendarJson", "CalendarJson") ?? null,
|
|
92
|
+
isThirdPartySaved: !!pick(payload, "isThirdPartySaved", "IsThirdPartySaved"),
|
|
93
|
+
themeId: n(pick(payload, "themeId", "ThemeId")),
|
|
94
|
+
theme,
|
|
95
|
+
openingHours: mappedOpeningHours,
|
|
96
|
+
appointmentUserDefinedFields: pick(payload, "appointmentUserDefinedFields", "AppointmentUserDefinedFields") ?? [],
|
|
97
|
+
__typename: "Calendar"
|
|
98
|
+
};
|
|
99
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). */
|
|
2
|
-
export declare function applyBlazeoClientConfig(): void;
|
|
1
|
+
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). */
|
|
2
|
+
export declare function applyBlazeoClientConfig(): void;
|
|
3
3
|
//# sourceMappingURL=applyBlazeoClientConfig.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { configure } from "@blazeo.com/calendar-client";
|
|
2
|
-
import { blazeoClientConfig } from "./blazeo.config.js";
|
|
3
|
-
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). */
|
|
4
|
-
export function applyBlazeoClientConfig() {
|
|
5
|
-
const baseUrl = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
|
|
6
|
-
if (!baseUrl)
|
|
7
|
-
return;
|
|
8
|
-
const consumer = blazeoClientConfig.consumer?.trim();
|
|
9
|
-
configure({
|
|
10
|
-
baseUrl,
|
|
11
|
-
...(consumer ? { consumer } : {}),
|
|
12
|
-
});
|
|
13
|
-
}
|
|
1
|
+
import { configure } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { blazeoClientConfig } from "./blazeo.config.js";
|
|
3
|
+
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). */
|
|
4
|
+
export function applyBlazeoClientConfig() {
|
|
5
|
+
const baseUrl = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
|
|
6
|
+
if (!baseUrl)
|
|
7
|
+
return;
|
|
8
|
+
const consumer = blazeoClientConfig.consumer?.trim();
|
|
9
|
+
configure({
|
|
10
|
+
baseUrl,
|
|
11
|
+
...(consumer ? { consumer } : {}),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
14
|
//# sourceMappingURL=applyBlazeoClientConfig.js.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). Call explicitly if you use file defaults; otherwise use {@link initializeAppointmentClient}. */
|
|
2
2
|
export declare function applyBlazeoClientConfig(): void;
|
|
3
|
-
//# sourceMappingURL=applyBlazeoDefaults.d.ts.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { configure } from "@blazeo.com/calendar-client";
|
|
2
1
|
import { blazeoClientConfig } from "./blazeoClientDefaults.js";
|
|
2
|
+
import { syncBlazeoConnection } from "./syncBlazeoConnection.js";
|
|
3
3
|
/** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). Call explicitly if you use file defaults; otherwise use {@link initializeAppointmentClient}. */
|
|
4
4
|
export function applyBlazeoClientConfig() {
|
|
5
|
+
debugger;
|
|
5
6
|
const baseUrl = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
|
|
6
7
|
if (!baseUrl)
|
|
7
8
|
return;
|
|
8
9
|
const consumer = blazeoClientConfig.consumer?.trim();
|
|
9
|
-
|
|
10
|
+
syncBlazeoConnection({
|
|
10
11
|
baseUrl,
|
|
11
12
|
...(consumer ? { consumer } : {}),
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
|
-
//# sourceMappingURL=applyBlazeoDefaults.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Central Blazeo API settings for `appointment-client`.
|
|
3
|
-
* Edit once; `configure()` runs when you import this package (see `index.ts`).
|
|
4
|
-
*
|
|
5
|
-
* @example baseUrl: "https://apptscheduling.azurewebsites.net"
|
|
6
|
-
*/
|
|
7
|
-
export declare const blazeoClientConfig: {
|
|
8
|
-
baseUrl: string;
|
|
9
|
-
consumer?: string;
|
|
10
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Central Blazeo API settings for `appointment-client`.
|
|
3
|
+
* Edit once; `configure()` runs when you import this package (see `index.ts`).
|
|
4
|
+
*
|
|
5
|
+
* @example baseUrl: "https://apptscheduling.azurewebsites.net"
|
|
6
|
+
*/
|
|
7
|
+
export declare const blazeoClientConfig: {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
consumer?: string;
|
|
10
|
+
};
|
|
11
11
|
//# sourceMappingURL=blazeo.config.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Central Blazeo API settings for `appointment-client`.
|
|
3
|
-
* Edit once; `configure()` runs when you import this package (see `index.ts`).
|
|
4
|
-
*
|
|
5
|
-
* @example baseUrl: "https://apptscheduling.azurewebsites.net"
|
|
6
|
-
*/
|
|
7
|
-
export const blazeoClientConfig = {
|
|
8
|
-
baseUrl: "",
|
|
9
|
-
consumer: "",
|
|
10
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Central Blazeo API settings for `appointment-client`.
|
|
3
|
+
* Edit once; `configure()` runs when you import this package (see `index.ts`).
|
|
4
|
+
*
|
|
5
|
+
* @example baseUrl: "https://apptscheduling.azurewebsites.net"
|
|
6
|
+
*/
|
|
7
|
+
export const blazeoClientConfig = {
|
|
8
|
+
baseUrl: "",
|
|
9
|
+
consumer: "",
|
|
10
|
+
};
|
|
11
11
|
//# sourceMappingURL=blazeo.config.js.map
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* @example baseUrl: "https://apptscheduling.azurewebsites.net"
|
|
7
7
|
*/
|
|
8
8
|
export const blazeoClientConfig = {
|
|
9
|
-
baseUrl: "",
|
|
10
|
-
consumer: "",
|
|
9
|
+
baseUrl: "https://apptscheduling.azurewebsites.net",
|
|
10
|
+
consumer: "smarthub",
|
|
11
11
|
};
|
|
12
|
-
//# sourceMappingURL=blazeoClientDefaults.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type EnsureBlazeoHttpOptions = {
|
|
2
|
+
baseUrl?: string;
|
|
3
|
+
consumer?: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Ensures global Blazeo `configure({ baseUrl })` runs before any `CalendarModel` / `EventModel` HTTP.
|
|
7
|
+
* Uses the same resolution as {@link resolveBlazeoConnection}: explicit args, existing `getConfig()`,
|
|
8
|
+
* then `blazeoClientDefaults` — so file defaults apply even if the host never called `configure`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureBlazeoHttpReady(options?: EnsureBlazeoHttpOptions): {
|
|
11
|
+
ok: true;
|
|
12
|
+
baseUrl: string;
|
|
13
|
+
consumer?: string;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
error: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { configure } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { resolveBlazeoConnection } from "../calendar/createCalendar.js";
|
|
3
|
+
/**
|
|
4
|
+
* Ensures global Blazeo `configure({ baseUrl })` runs before any `CalendarModel` / `EventModel` HTTP.
|
|
5
|
+
* Uses the same resolution as {@link resolveBlazeoConnection}: explicit args, existing `getConfig()`,
|
|
6
|
+
* then `blazeoClientDefaults` — so file defaults apply even if the host never called `configure`.
|
|
7
|
+
*/
|
|
8
|
+
export function ensureBlazeoHttpReady(options = {}) {
|
|
9
|
+
// Hard-prefer explicit args (call-site can bypass any module-resolution mismatch).
|
|
10
|
+
const explicitBase = options.baseUrl?.trim().replace(/\/+$/, "");
|
|
11
|
+
const explicitConsumer = options.consumer?.trim() || undefined;
|
|
12
|
+
if (explicitBase) {
|
|
13
|
+
configure({
|
|
14
|
+
baseUrl: explicitBase,
|
|
15
|
+
...(explicitConsumer ? { consumer: explicitConsumer } : {}),
|
|
16
|
+
});
|
|
17
|
+
return { ok: true, baseUrl: explicitBase, ...(explicitConsumer ? { consumer: explicitConsumer } : {}) };
|
|
18
|
+
}
|
|
19
|
+
const { baseUrl, consumer } = resolveBlazeoConnection(options);
|
|
20
|
+
if (!baseUrl) {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
error: "Blazeo base URL is not set. Call initializeAppointmentClient({ baseUrl }) or configure({ baseUrl }) at app startup, set blazeoClientConfig.baseUrl, or pass baseUrl when calling fetch APIs.",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
configure({
|
|
27
|
+
baseUrl,
|
|
28
|
+
...(consumer ? { consumer } : {}),
|
|
29
|
+
});
|
|
30
|
+
return { ok: true, baseUrl, ...(consumer ? { consumer } : {}) };
|
|
31
|
+
}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Wraps `@blazeo.com/calendar-client` {@link configure} with validation.
|
|
4
|
-
*
|
|
5
|
-
* `baseUrl` may be omitted when a non-empty URL is set in {@link blazeoClientConfig}
|
|
6
|
-
* (`blazeoClientDefaults.ts`). Otherwise pass `baseUrl` explicitly (e.g. from env).
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import { initializeAppointmentClient } from "@blazeo.com/appointment-client";
|
|
11
|
-
*
|
|
12
|
-
* initializeAppointmentClient({
|
|
13
|
-
* baseUrl: import.meta.env.VITE_APPOINTMENT_API_URL,
|
|
14
|
-
* consumer: "crmflow",
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
export type AppointmentClientConnectOptions = {
|
|
19
|
-
/** Blazeo / appointment API base URL (trailing slashes are normalized away). */
|
|
20
|
-
baseUrl?: string;
|
|
21
|
-
/** Optional `Consumer` header value (matches Apex / Blazeo clients). */
|
|
1
|
+
export interface AppointmentClientConfig {
|
|
2
|
+
baseUrl: string;
|
|
22
3
|
consumer?: string;
|
|
23
|
-
/** Optional custom fetch (e.g. authenticated wrapper). */
|
|
24
4
|
fetch?: typeof fetch;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Applies Blazeo connection (same as {@link syncBlazeoConnection}) and marks the client as configured
|
|
8
|
+
* when a non-empty `baseUrl` was written to `@blazeo.com/calendar-client`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function initializeAppointmentClient(config: AppointmentClientConfig): void;
|
|
30
11
|
export declare function isAppointmentClientConfigured(): boolean;
|
|
31
|
-
//# sourceMappingURL=initializeAppointmentClient.d.ts.map
|
|
@@ -1,28 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { getConfig } from "@blazeo.com/calendar-client";
|
|
2
|
+
import { syncBlazeoConnection } from "./syncBlazeoConnection.js";
|
|
3
|
+
let isConfigured = false;
|
|
4
|
+
/**
|
|
5
|
+
* Applies Blazeo connection (same as {@link syncBlazeoConnection}) and marks the client as configured
|
|
6
|
+
* when a non-empty `baseUrl` was written to `@blazeo.com/calendar-client`.
|
|
7
|
+
*/
|
|
8
|
+
export function initializeAppointmentClient(config) {
|
|
9
|
+
if (syncBlazeoConnection(config)) {
|
|
10
|
+
isConfigured = true;
|
|
10
11
|
}
|
|
11
|
-
const consumer = options.consumer?.trim() ||
|
|
12
|
-
blazeoClientConfig.consumer?.trim() ||
|
|
13
|
-
undefined;
|
|
14
|
-
configure({
|
|
15
|
-
baseUrl,
|
|
16
|
-
...(consumer ? { consumer } : {}),
|
|
17
|
-
...(options.fetch ? { fetch: options.fetch } : {}),
|
|
18
|
-
...(options.getDefaultOffset
|
|
19
|
-
? { getDefaultOffset: options.getDefaultOffset }
|
|
20
|
-
: {}),
|
|
21
|
-
});
|
|
22
12
|
}
|
|
23
|
-
/** True when global Blazeo config has a non-empty `baseUrl` (after {@link configure}). */
|
|
24
13
|
export function isAppointmentClientConfigured() {
|
|
25
|
-
|
|
26
|
-
return Boolean(cfg?.baseUrl?.trim());
|
|
14
|
+
return isConfigured || getConfig() !== null;
|
|
27
15
|
}
|
|
28
|
-
//# sourceMappingURL=initializeAppointmentClient.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AppointmentClientConfig } from "./initializeAppointmentClient.js";
|
|
2
|
+
/**
|
|
3
|
+
* Writes `baseUrl` / `consumer` into the global `@blazeo.com/calendar-client` `configure()` store.
|
|
4
|
+
* Returns whether anything was applied (skipped when `baseUrl` is empty after trim).
|
|
5
|
+
*/
|
|
6
|
+
export declare function syncBlazeoConnection(config: AppointmentClientConfig): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { configure } from "@blazeo.com/calendar-client";
|
|
2
|
+
/**
|
|
3
|
+
* Writes `baseUrl` / `consumer` into the global `@blazeo.com/calendar-client` `configure()` store.
|
|
4
|
+
* Returns whether anything was applied (skipped when `baseUrl` is empty after trim).
|
|
5
|
+
*/
|
|
6
|
+
export function syncBlazeoConnection(config) {
|
|
7
|
+
const baseUrl = config.baseUrl?.trim().replace(/\/+$/, "");
|
|
8
|
+
if (!baseUrl)
|
|
9
|
+
return false;
|
|
10
|
+
configure({
|
|
11
|
+
baseUrl,
|
|
12
|
+
...(config.consumer != null && String(config.consumer).trim() !== ""
|
|
13
|
+
? { consumer: String(config.consumer).trim() }
|
|
14
|
+
: {}),
|
|
15
|
+
...(config.fetch ? { fetch: config.fetch } : {}),
|
|
16
|
+
});
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
@@ -1,44 +1,67 @@
|
|
|
1
|
-
import type { IStateTreeNode } from "mobx-state-tree";
|
|
2
|
-
import type { ApexAppointmentInput } from "../types/appointment.js";
|
|
3
|
-
import { type CreateCalendarOptions } from "../calendar/createCalendar.js";
|
|
4
|
-
/** Options for event calls — same connection rules as calendar + Blazeo `offset` header. */
|
|
5
|
-
export type AppointmentEventOptions = CreateCalendarOptions & {
|
|
6
|
-
/**
|
|
7
|
-
* Minutes offset for `POST /event/create` and `POST /event/reschedule` (matches Apex adapter `offset`).
|
|
8
|
-
* Omitted uses Blazeo env `getDefaultOffset` when configured.
|
|
9
|
-
*/
|
|
10
|
-
offsetMinutes?: number;
|
|
11
|
-
};
|
|
12
|
-
export type BlazeoEventApiResponse = {
|
|
13
|
-
status: string;
|
|
14
|
-
message?: string;
|
|
15
|
-
data?: unknown;
|
|
16
|
-
};
|
|
17
|
-
export type AppointmentEventSuccess = {
|
|
18
|
-
ok: true;
|
|
19
|
-
/** Present after create/reschedule when an MST node was used; omit after cancel. */
|
|
20
|
-
event?: IStateTreeNode;
|
|
21
|
-
apiResponse?: BlazeoEventApiResponse;
|
|
22
|
-
};
|
|
23
|
-
export type AppointmentEventFailure = {
|
|
24
|
-
ok: false;
|
|
25
|
-
error: string;
|
|
26
|
-
apiResponse?: BlazeoEventApiResponse;
|
|
27
|
-
};
|
|
28
|
-
export type AppointmentEventResult = AppointmentEventSuccess | AppointmentEventFailure;
|
|
29
1
|
/**
|
|
30
2
|
* Creates an appointment event — `Event.create()` → `POST /event/create`
|
|
31
3
|
* (aligned with `AppointmentAPIAdapter.Create`).
|
|
32
4
|
*/
|
|
33
|
-
export declare function createAppointmentEventAsync(input:
|
|
5
|
+
export declare function createAppointmentEventAsync(input: any, options?: any): Promise<{
|
|
6
|
+
ok: boolean;
|
|
7
|
+
error: string;
|
|
8
|
+
event?: undefined;
|
|
9
|
+
apiResponse?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
event: any;
|
|
13
|
+
error?: undefined;
|
|
14
|
+
apiResponse?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
apiResponse: any;
|
|
19
|
+
event?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
event: any;
|
|
23
|
+
apiResponse: any;
|
|
24
|
+
error?: undefined;
|
|
25
|
+
}>;
|
|
34
26
|
/**
|
|
35
27
|
* Reschedules an appointment — `Event.reschedule()` → `POST /event/reschedule`
|
|
36
28
|
* (aligned with `AppointmentAPIAdapter.Reschedule`).
|
|
37
29
|
*/
|
|
38
|
-
export declare function rescheduleAppointmentEventAsync(input:
|
|
30
|
+
export declare function rescheduleAppointmentEventAsync(input: any, options?: any): Promise<{
|
|
31
|
+
ok: boolean;
|
|
32
|
+
error: string;
|
|
33
|
+
event?: undefined;
|
|
34
|
+
apiResponse?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
event: any;
|
|
38
|
+
error?: undefined;
|
|
39
|
+
apiResponse?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
ok: boolean;
|
|
42
|
+
error: any;
|
|
43
|
+
apiResponse: any;
|
|
44
|
+
event?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
event: any;
|
|
48
|
+
apiResponse: any;
|
|
49
|
+
error?: undefined;
|
|
50
|
+
}>;
|
|
39
51
|
/**
|
|
40
52
|
* Cancels an appointment — `EventModel.cancel` → `GET /event/cancel`
|
|
41
53
|
* (aligned with `AppointmentAPIAdapter.Cancel`).
|
|
42
54
|
*/
|
|
43
|
-
export declare function cancelAppointmentEventAsync(appointmentEventId: string, options?:
|
|
44
|
-
|
|
55
|
+
export declare function cancelAppointmentEventAsync(appointmentEventId: string, options?: any): Promise<{
|
|
56
|
+
ok: boolean;
|
|
57
|
+
error: string;
|
|
58
|
+
apiResponse?: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
ok: boolean;
|
|
61
|
+
error: any;
|
|
62
|
+
apiResponse: any;
|
|
63
|
+
} | {
|
|
64
|
+
ok: boolean;
|
|
65
|
+
apiResponse: any;
|
|
66
|
+
error?: undefined;
|
|
67
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventModel, configure } from "@blazeo.com/calendar-client";
|
|
2
|
-
import { buildModelEnv, resolveBlazeoConnection
|
|
3
|
-
import { mapAppointmentToEventSnapshot
|
|
2
|
+
import { buildModelEnv, resolveBlazeoConnection } from "../calendar/createCalendar.js";
|
|
3
|
+
import { mapAppointmentToEventSnapshot } from "./mapAppointmentToEventSnapshot.js";
|
|
4
4
|
function isFailureStatus(res) {
|
|
5
5
|
return res.status !== "success" && res.status !== "Success";
|
|
6
6
|
}
|
|
@@ -43,18 +43,14 @@ async function runEventMutation(input, mode, options) {
|
|
|
43
43
|
return { ok: true, event: eventNode };
|
|
44
44
|
}
|
|
45
45
|
const offset = options.offsetMinutes;
|
|
46
|
-
const apiRes = mode === "create"
|
|
47
|
-
? await eventNode.create(offset)
|
|
48
|
-
: await eventNode.reschedule(offset);
|
|
46
|
+
const apiRes = mode === "create" ? await eventNode.create(offset) : await eventNode.reschedule(offset);
|
|
49
47
|
if (isFailureStatus(apiRes)) {
|
|
50
48
|
const msg = apiRes.message ??
|
|
51
49
|
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
52
50
|
JSON.stringify(apiRes);
|
|
53
51
|
return {
|
|
54
52
|
ok: false,
|
|
55
|
-
error: mode === "create"
|
|
56
|
-
? msg || "Event create failed"
|
|
57
|
-
: msg || "Event reschedule failed",
|
|
53
|
+
error: mode === "create" ? msg || "Event create failed" : msg || "Event reschedule failed",
|
|
58
54
|
apiResponse: apiRes,
|
|
59
55
|
};
|
|
60
56
|
}
|
|
@@ -108,7 +104,7 @@ export async function cancelAppointmentEventAsync(appointmentEventId, options =
|
|
|
108
104
|
if (options.localOnly) {
|
|
109
105
|
return { ok: true, apiResponse: undefined };
|
|
110
106
|
}
|
|
111
|
-
const apiRes =
|
|
107
|
+
const apiRes = await EventModel.cancel(id);
|
|
112
108
|
if (isFailureStatus(apiRes)) {
|
|
113
109
|
const msg = apiRes.message ??
|
|
114
110
|
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
@@ -126,4 +122,3 @@ export async function cancelAppointmentEventAsync(appointmentEventId, options =
|
|
|
126
122
|
return { ok: false, error: message };
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
|
-
//# sourceMappingURL=appointmentEventFacade.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { ApexAppointmentInput } from "../types/appointment.js";
|
|
2
|
-
export type AppointmentEventMappingMode = "create" | "reschedule";
|
|
3
1
|
/**
|
|
4
2
|
* Maps Apex appointment input to a Blazeo `Event` MST snapshot for
|
|
5
3
|
* {@link EventModel.create} from `@blazeo.com/calendar-client`.
|
|
6
4
|
*/
|
|
7
|
-
export declare function mapAppointmentToEventSnapshot(input:
|
|
8
|
-
//# sourceMappingURL=mapAppointmentToEventSnapshot.d.ts.map
|
|
5
|
+
export declare function mapAppointmentToEventSnapshot(input: any, mode: "create" | "reschedule"): any;
|