@blazeo.com/appointment-client 1.0.5 → 1.0.6

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.
Files changed (103) hide show
  1. package/blazeo.com-appointment-client-1.0.6.tgz +0 -0
  2. package/dist/calendar/blazeoCalendarRelationMethods.d.ts +4 -36
  3. package/dist/calendar/blazeoCalendarRelationMethods.js +0 -1
  4. package/dist/calendar/buildUnifiedCalendarView.d.ts +31 -0
  5. package/dist/calendar/buildUnifiedCalendarView.js +265 -0
  6. package/dist/calendar/calendarCreation.d.ts +27 -0
  7. package/dist/calendar/calendarCreation.js +167 -0
  8. package/dist/calendar/calendarCreationFacade.d.ts +4 -13
  9. package/dist/calendar/calendarCreationFacade.js +3 -5
  10. package/dist/calendar/createCalendar.d.ts +67 -37
  11. package/dist/calendar/createCalendar.js +1 -3
  12. package/dist/calendar/fetchCalendarDetails.d.ts +73 -18
  13. package/dist/calendar/fetchCalendarDetails.js +192 -51
  14. package/dist/calendar/fetchCalendarWithOpeningHours.d.ts +34 -21
  15. package/dist/calendar/fetchCalendarWithOpeningHours.js +95 -75
  16. package/dist/calendar/getAllParticipantOpeningHours.d.ts +19 -0
  17. package/dist/calendar/getAllParticipantOpeningHours.js +17 -0
  18. package/dist/calendar/getOpeningHours.d.ts +5 -0
  19. package/dist/calendar/getOpeningHours.js +9 -0
  20. package/dist/calendar/getParticipantOpeningHours.d.ts +37 -0
  21. package/dist/calendar/getParticipantOpeningHours.js +43 -0
  22. package/dist/calendar/getParticipants.d.ts +4 -0
  23. package/dist/calendar/getParticipants.js +8 -0
  24. package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts +9 -9
  25. package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js +43 -43
  26. package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts +22 -3
  27. package/dist/calendar/mapCalendarToBlazeoSnapshot.js +0 -1
  28. package/dist/config/applyBlazeoClientConfig.d.ts +2 -2
  29. package/dist/config/applyBlazeoClientConfig.js +13 -13
  30. package/dist/config/applyBlazeoDefaults.d.ts +0 -1
  31. package/dist/config/applyBlazeoDefaults.js +0 -1
  32. package/dist/config/blazeo.config.d.ts +10 -10
  33. package/dist/config/blazeo.config.js +10 -10
  34. package/dist/config/blazeoClientDefaults.d.ts +1 -2
  35. package/dist/config/blazeoClientDefaults.js +0 -1
  36. package/dist/config/initializeAppointmentClient.d.ts +4 -28
  37. package/dist/config/initializeAppointmentClient.js +5 -24
  38. package/dist/events/appointmentEventFacade.d.ts +55 -32
  39. package/dist/events/appointmentEventFacade.js +5 -10
  40. package/dist/events/mapAppointmentToEventSnapshot.d.ts +1 -4
  41. package/dist/events/mapAppointmentToEventSnapshot.js +0 -1
  42. package/dist/exampleData.d.ts +114 -10
  43. package/dist/exampleData.js +4 -5
  44. package/dist/facade/calendarCreationFacade.d.ts +39 -39
  45. package/dist/facade/calendarCreationFacade.js +95 -95
  46. package/dist/facade/mapCalendarBOToSnapshot.d.ts +9 -9
  47. package/dist/facade/mapCalendarBOToSnapshot.js +43 -43
  48. package/dist/facades/index.d.ts +11 -11
  49. package/dist/facades/index.js +11 -11
  50. package/dist/index.d.ts +23 -82
  51. package/dist/index.js +21 -33
  52. package/dist/models/CalendarRootModel.d.ts +36 -11
  53. package/dist/models/CalendarRootModel.js +22 -5
  54. package/dist/models/CalendarSlotModel.d.ts +8 -8
  55. package/dist/models/CalendarSlotModel.js +7 -7
  56. package/dist/models/EventModel.d.ts +10 -10
  57. package/dist/models/EventModel.js +9 -9
  58. package/dist/models/ParticipantModel.d.ts +8 -8
  59. package/dist/models/ParticipantModel.js +7 -7
  60. package/dist/models/index.d.ts +4 -4
  61. package/dist/models/index.js +4 -4
  62. package/dist/types/appointment.d.ts +27 -27
  63. package/dist/types/appointment.js +5 -5
  64. package/dist/types/calendar.d.ts +51 -51
  65. package/dist/types/calendar.js +5 -5
  66. package/dist/types/calendarBo.d.ts +61 -61
  67. package/dist/types/calendarBo.js +5 -5
  68. package/package.json +8 -2
  69. package/sample/build_error.txt +0 -0
  70. package/sample/demo.js +70 -0
  71. package/sample/package-lock.json +5 -2
  72. package/sample/package.json +3 -1
  73. package/sample/scripts/getInfoByCalendar.mjs +36 -0
  74. package/sample/scripts/getParticipantOpeningHours.mjs +48 -0
  75. package/sample/src/AllParticipantOpeningHoursTab.jsx +73 -0
  76. package/sample/src/App2.jsx +39 -2
  77. package/sample/src/BlazeoConnectionSettings.jsx +1 -1
  78. package/sample/src/FetchCalendarTab.jsx +70 -20
  79. package/sample/src/OpeningHoursTab.jsx +78 -0
  80. package/sample/src/ParticipantInfoTab.jsx +72 -0
  81. package/sample/src/ParticipantOpeningHoursTab.jsx +88 -0
  82. package/sample/src/ParticipantTab.jsx +2 -2
  83. package/src/calendar/blazeoCalendarRelationMethods.ts +19 -0
  84. package/src/calendar/buildUnifiedCalendarView.ts +322 -0
  85. package/src/calendar/calendarCreation.ts +179 -0
  86. package/src/calendar/createCalendar.ts +243 -0
  87. package/src/calendar/fetchCalendarDetails.ts +226 -0
  88. package/src/calendar/fetchCalendarWithOpeningHours.ts +99 -0
  89. package/src/calendar/getAllParticipantOpeningHours.ts +22 -0
  90. package/src/calendar/getOpeningHours.ts +10 -0
  91. package/src/calendar/getParticipantOpeningHours.ts +46 -0
  92. package/src/calendar/getParticipants.ts +9 -0
  93. package/src/calendar/mapCalendarToBlazeoSnapshot.ts +46 -0
  94. package/src/config/applyBlazeoDefaults.ts +13 -0
  95. package/src/config/blazeoClientDefaults.ts +11 -0
  96. package/src/config/initializeAppointmentClient.ts +18 -0
  97. package/src/events/appointmentEventFacade.ts +148 -0
  98. package/src/events/mapAppointmentToEventSnapshot.ts +65 -0
  99. package/src/exampleData.ts +79 -0
  100. package/src/index.ts +45 -0
  101. package/src/models/CalendarRootModel.ts +60 -0
  102. package/tsconfig.json +16 -0
  103. package/blazeo.com-appointment-client-1.0.5.tgz +0 -0
@@ -0,0 +1,46 @@
1
+ /** Default enum values aligned with ApexFlows / Blazeo (`AssignmentMethod`, `Unit`). */
2
+ const DEFAULT_ASSIGNMENT_METHOD = 1;
3
+ const DEFAULT_UNIT_MINUTES = 1;
4
+
5
+ /**
6
+ * For Blazeo `Calendar` MST: `types.optional(types.number)` accepts `undefined` (uses default)
7
+ * but not `null`. Coerce null/absent to `undefined`.
8
+ */
9
+ function optionalNumber(v: any) {
10
+ return v == null ? undefined : v;
11
+ }
12
+
13
+ /**
14
+ * Maps Apex `CalendarBO`-shaped input to a snapshot for
15
+ * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
16
+ *
17
+ * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
18
+ * unknown keys or invalid `null`s on optional numbers.
19
+ */
20
+ export function mapCalendarBOToSnapshot(bo: any) {
21
+ const c = globalThis.crypto;
22
+ const generatedId = c?.randomUUID?.() ?? `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
23
+ const calendarId = bo.calendarId ?? generatedId;
24
+ return {
25
+ companyKey: bo.companyKey ?? null,
26
+ calendarId,
27
+ name: bo.name ?? null,
28
+ timeZoneId: bo.timeZoneId ?? null,
29
+ purpose: bo.purpose ?? bo.bookingPageTitle ?? "",
30
+ description: bo.description ?? null,
31
+ assignmentMethod: bo.assignmentMethod ?? bo.assignmentType ?? DEFAULT_ASSIGNMENT_METHOD,
32
+ duration: optionalNumber(bo.duration) ?? 30,
33
+ durationUnit: optionalNumber(bo.durationUnit) ?? DEFAULT_UNIT_MINUTES,
34
+ minimumBookingNotice: optionalNumber(bo.minimumBookingNotice) ?? 0,
35
+ minimumBookingNoticeUnit: optionalNumber(bo.minimumBookingNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
36
+ minimumCancelationNotice: optionalNumber(bo.minimumCancelationNotice) ?? 0,
37
+ minimumCancelationNoticeUnit: optionalNumber(bo.minimumCancelationNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
38
+ futureLimit: optionalNumber(bo.futureLimit) ?? 0,
39
+ futureLimitUnit: optionalNumber(bo.futureLimitUnit) ?? 3,
40
+ bufferTime: optionalNumber(bo.bufferTime),
41
+ bufferTimeUnit: optionalNumber(bo.bufferTimeUnit) ?? DEFAULT_UNIT_MINUTES,
42
+ bookingLimit: optionalNumber(bo.bookingLimit),
43
+ createdOn: bo.createdOn ?? null,
44
+ modifiedOn: bo.modifiedOn ?? null,
45
+ };
46
+ }
@@ -0,0 +1,13 @@
1
+ import { configure } from "@blazeo.com/calendar-client";
2
+ import { blazeoClientConfig } from "./blazeoClientDefaults.js";
3
+
4
+ /** Push {@link blazeoClientConfig} into `@blazeo.com/calendar-client` (global store). Call explicitly if you use file defaults; otherwise use {@link initializeAppointmentClient}. */
5
+ export function applyBlazeoClientConfig() {
6
+ const baseUrl = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
7
+ if (!baseUrl) return;
8
+ const consumer = blazeoClientConfig.consumer?.trim();
9
+ configure({
10
+ baseUrl,
11
+ ...(consumer ? { consumer } : {}),
12
+ });
13
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Optional file-based defaults for local development or publishing a fork.
3
+ * Host apps should prefer {@link initializeAppointmentClient} with env-driven `baseUrl` / `consumer`.
4
+ * To apply these values, call {@link applyBlazeoClientConfig} during bootstrap (not automatic on import).
5
+ *
6
+ * @example baseUrl: "https://apptscheduling.azurewebsites.net"
7
+ */
8
+ export const blazeoClientConfig = {
9
+ baseUrl: "",
10
+ consumer: "",
11
+ };
@@ -0,0 +1,18 @@
1
+ import { configure, getConfig } from "@blazeo.com/calendar-client";
2
+
3
+ export interface AppointmentClientConfig {
4
+ baseUrl: string;
5
+ consumer?: string;
6
+ fetch?: typeof fetch;
7
+ }
8
+
9
+ let isConfigured = false;
10
+
11
+ export function initializeAppointmentClient(config: AppointmentClientConfig) {
12
+ configure(config);
13
+ isConfigured = true;
14
+ }
15
+
16
+ export function isAppointmentClientConfigured() {
17
+ return isConfigured || getConfig() !== null;
18
+ }
@@ -0,0 +1,148 @@
1
+ import { EventModel, configure } from "@blazeo.com/calendar-client";
2
+ import { buildModelEnv, resolveBlazeoConnection } from "../calendar/createCalendar.js";
3
+ import { mapAppointmentToEventSnapshot } from "./mapAppointmentToEventSnapshot.js";
4
+
5
+ function isFailureStatus(res: any) {
6
+ return res.status !== "success" && res.status !== "Success";
7
+ }
8
+
9
+ function ensureConfigure(resolvedBase: string | undefined, resolvedConsumer: string | undefined) {
10
+ if (resolvedBase) {
11
+ configure({
12
+ baseUrl: resolvedBase,
13
+ ...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
14
+ });
15
+ }
16
+ }
17
+
18
+ async function runEventMutation(input: any, mode: "create" | "reschedule", options: any) {
19
+ const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
20
+ ensureConfigure(resolvedBase, resolvedConsumer);
21
+
22
+ const baseUrl = resolvedBase;
23
+ const consumer = resolvedConsumer;
24
+
25
+ if (!options.localOnly && !baseUrl) {
26
+ return {
27
+ ok: false,
28
+ error:
29
+ "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeoClientDefaults.ts` or call `configure({ baseUrl })`.",
30
+ };
31
+ }
32
+
33
+ const snapshot = mapAppointmentToEventSnapshot(input, mode);
34
+ const eventIdForApi = snapshot.eventId;
35
+
36
+ if (mode === "reschedule" && (!eventIdForApi || eventIdForApi === "new")) {
37
+ return {
38
+ ok: false,
39
+ error: "thirdPartyAppointmentId is required for reschedule (existing Blazeo event id).",
40
+ };
41
+ }
42
+
43
+ const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
44
+ if (!options.localOnly && env.baseUrl == null) {
45
+ return {
46
+ ok: false,
47
+ error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
48
+ };
49
+ }
50
+
51
+ const eventNode: any = EventModel.create(snapshot, env);
52
+
53
+ if (options.localOnly) {
54
+ return { ok: true, event: eventNode };
55
+ }
56
+
57
+ const offset = options.offsetMinutes;
58
+ const apiRes: any =
59
+ mode === "create" ? await eventNode.create(offset) : await eventNode.reschedule(offset);
60
+
61
+ if (isFailureStatus(apiRes)) {
62
+ const msg =
63
+ apiRes.message ??
64
+ (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
65
+ JSON.stringify(apiRes);
66
+ return {
67
+ ok: false,
68
+ error:
69
+ mode === "create" ? msg || "Event create failed" : msg || "Event reschedule failed",
70
+ apiResponse: apiRes,
71
+ };
72
+ }
73
+
74
+ return { ok: true, event: eventNode, apiResponse: apiRes };
75
+ }
76
+
77
+ /**
78
+ * Creates an appointment event — `Event.create()` → `POST /event/create`
79
+ * (aligned with `AppointmentAPIAdapter.Create`).
80
+ */
81
+ export async function createAppointmentEventAsync(input: any, options: any = {}) {
82
+ try {
83
+ return await runEventMutation(input, "create", options);
84
+ } catch (err) {
85
+ const message = err instanceof Error ? err.message : String(err);
86
+ return { ok: false, error: message };
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Reschedules an appointment — `Event.reschedule()` → `POST /event/reschedule`
92
+ * (aligned with `AppointmentAPIAdapter.Reschedule`).
93
+ */
94
+ export async function rescheduleAppointmentEventAsync(input: any, options: any = {}) {
95
+ try {
96
+ return await runEventMutation(input, "reschedule", options);
97
+ } catch (err) {
98
+ const message = err instanceof Error ? err.message : String(err);
99
+ return { ok: false, error: message };
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Cancels an appointment — `EventModel.cancel` → `GET /event/cancel`
105
+ * (aligned with `AppointmentAPIAdapter.Cancel`).
106
+ */
107
+ export async function cancelAppointmentEventAsync(appointmentEventId: string, options: any = {}) {
108
+ try {
109
+ const id = appointmentEventId.trim();
110
+ if (!id) {
111
+ return { ok: false, error: "appointmentEventId is required for cancel." };
112
+ }
113
+
114
+ const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
115
+ ensureConfigure(resolvedBase, resolvedConsumer);
116
+
117
+ const baseUrl = resolvedBase;
118
+ if (!options.localOnly && !baseUrl) {
119
+ return {
120
+ ok: false,
121
+ error:
122
+ "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeoClientDefaults.ts` or call `configure({ baseUrl })`.",
123
+ };
124
+ }
125
+
126
+ if (options.localOnly) {
127
+ return { ok: true, apiResponse: undefined };
128
+ }
129
+
130
+ const apiRes: any = await (EventModel as any).cancel(id);
131
+ if (isFailureStatus(apiRes)) {
132
+ const msg =
133
+ apiRes.message ??
134
+ (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
135
+ JSON.stringify(apiRes);
136
+ return {
137
+ ok: false,
138
+ error: msg || "Event cancel failed",
139
+ apiResponse: apiRes,
140
+ };
141
+ }
142
+
143
+ return { ok: true, apiResponse: apiRes };
144
+ } catch (err) {
145
+ const message = err instanceof Error ? err.message : String(err);
146
+ return { ok: false, error: message };
147
+ }
148
+ }
@@ -0,0 +1,65 @@
1
+ function parseDate(value: any) {
2
+ const d = value instanceof Date ? value : new Date(value);
3
+ if (Number.isNaN(d.getTime())) {
4
+ throw new Error("Invalid startDate or endDate");
5
+ }
6
+ return d;
7
+ }
8
+
9
+ function formatYmd(d: Date) {
10
+ const y = d.getFullYear();
11
+ const m = String(d.getMonth() + 1).padStart(2, "0");
12
+ const day = String(d.getDate()).padStart(2, "0");
13
+ return `${y}-${m}-${day}`;
14
+ }
15
+
16
+ function normalizeParticipantId(id: string) {
17
+ return id.trim().replace(/^\{|\}$/g, "");
18
+ }
19
+
20
+ /**
21
+ * Maps Apex appointment input to a Blazeo `Event` MST snapshot for
22
+ * {@link EventModel.create} from `@blazeo.com/calendar-client`.
23
+ */
24
+ export function mapAppointmentToEventSnapshot(input: any, mode: "create" | "reschedule") {
25
+ const start = parseDate(input.startDate);
26
+ const end = parseDate(input.endDate);
27
+ const description =
28
+ mode === "create"
29
+ ? (input.description ?? null)
30
+ : (input.description ?? input.notes ?? null);
31
+
32
+ const eventIdRaw = input.thirdPartyAppointmentId?.trim();
33
+ const eventId = eventIdRaw && eventIdRaw !== "new" ? eventIdRaw : "new";
34
+ const email = input.email ?? input.visitorEmail ?? null;
35
+ const phone = input.phone ?? input.visitorPhone ?? null;
36
+ const visitorName = input.visitorName?.trim() || null;
37
+
38
+ const snap: any = {
39
+ eventId,
40
+ calendarId: input.thirdPartyCalendarId?.trim() ?? "",
41
+ participantId: normalizeParticipantId(input.participantId),
42
+ title: input.title ?? null,
43
+ description,
44
+ startDate: formatYmd(start),
45
+ endDate: formatYmd(end),
46
+ startHour: start.getHours(),
47
+ startMinute: start.getMinutes(),
48
+ endHour: end.getHours(),
49
+ endMinute: end.getMinutes(),
50
+ visitorName,
51
+ visitorEmail: email,
52
+ visitorPhone: phone,
53
+ rescheduleLink: input.rescheduleUrl ?? null,
54
+ cancelLink: input.cancelUrl ?? null,
55
+ timeZone: input.timeZone ?? null,
56
+ };
57
+
58
+ if (mode === "create") {
59
+ const now = new Date().toISOString();
60
+ snap.createdOn = now;
61
+ snap.modifiedOn = now;
62
+ }
63
+
64
+ return snap;
65
+ }
@@ -0,0 +1,79 @@
1
+ import { CalendarSlotModel } from "./models/CalendarRootModel.js";
2
+ import { CalendarRootModel } from "./models/CalendarRootModel.js";
3
+ import { EventModel } from "./models/CalendarRootModel.js";
4
+ import { ParticipantModel } from "./models/CalendarRootModel.js";
5
+
6
+ const EXAMPLE_SLOT_SNAPSHOTS = [
7
+ {
8
+ id: "slot-1",
9
+ title: "Team standup",
10
+ start: "09:00",
11
+ end: "09:15",
12
+ },
13
+ {
14
+ id: "slot-2",
15
+ title: "Focus block",
16
+ start: "10:00",
17
+ end: "12:00",
18
+ },
19
+ {
20
+ id: "slot-3",
21
+ title: "1:1 with design",
22
+ start: "14:00",
23
+ end: "14:30",
24
+ },
25
+ ];
26
+
27
+ const EXAMPLE_EVENT_SNAPSHOTS = [
28
+ {
29
+ id: "ev-1",
30
+ title: "Product roadmap review",
31
+ calendarId: "cal-eng",
32
+ startsAt: "2026-04-02T15:00:00.000Z",
33
+ endsAt: "2026-04-02T16:00:00.000Z",
34
+ participantIds: ["p-1", "p-2"],
35
+ },
36
+ {
37
+ id: "ev-2",
38
+ title: "Customer onboarding call",
39
+ calendarId: "cal-sales",
40
+ startsAt: "2026-04-03T10:30:00.000Z",
41
+ endsAt: "2026-04-03T11:00:00.000Z",
42
+ participantIds: ["p-3"],
43
+ },
44
+ ];
45
+
46
+ const EXAMPLE_PARTICIPANT_SNAPSHOTS = [
47
+ { id: "p-1", name: "Alex Morgan", email: "alex@example.com", role: "Organizer" },
48
+ { id: "p-2", name: "Jordan Lee", email: "jordan@example.com", role: "Required" },
49
+ { id: "p-3", name: "Sam Rivera", email: "sam@example.com", role: "Optional" },
50
+ ];
51
+
52
+ /** Example slot nodes (MST instances). */
53
+ export function getExampleSlots() {
54
+ return EXAMPLE_SLOT_SNAPSHOTS.map((s) => CalendarSlotModel.create(s as any));
55
+ }
56
+
57
+ /** Example event nodes. */
58
+ export function getExampleEvents() {
59
+ return EXAMPLE_EVENT_SNAPSHOTS.map((s) => EventModel.create(s as any));
60
+ }
61
+
62
+ /** Example participant nodes. */
63
+ export function getExampleParticipants() {
64
+ return EXAMPLE_PARTICIPANT_SNAPSHOTS.map((s) => ParticipantModel.create(s as any));
65
+ }
66
+
67
+ /** Full root store snapshot suitable for `createCalendarRoot(snapshot)`. */
68
+ export function getExampleCalendarRootSnapshot() {
69
+ return {
70
+ slots: EXAMPLE_SLOT_SNAPSHOTS,
71
+ events: EXAMPLE_EVENT_SNAPSHOTS,
72
+ participants: EXAMPLE_PARTICIPANT_SNAPSHOTS,
73
+ };
74
+ }
75
+
76
+ /** Root store with example slots, events, and participants. */
77
+ export function getExampleCalendarRoot() {
78
+ return CalendarRootModel.create(getExampleCalendarRootSnapshot() as any);
79
+ }
package/src/index.ts ADDED
@@ -0,0 +1,45 @@
1
+ import { getExampleSlots } from "./exampleData.js";
2
+
3
+ export { initializeAppointmentClient, isAppointmentClientConfigured } from "./config/initializeAppointmentClient.js";
4
+ export { blazeoClientConfig } from "./config/blazeoClientDefaults.js";
5
+ export { applyBlazeoClientConfig } from "./config/applyBlazeoDefaults.js";
6
+ export { createCalendarRoot, CalendarRootModel, CalendarSlotModel, EventModel, ParticipantModel } from "./models/CalendarRootModel.js";
7
+ export { fetchCalendarDetails, fetchCalendarBundle, normalizeOpeningHours } from "./calendar/fetchCalendarDetails.js";
8
+ export {
9
+ buildUnifiedCalendarView,
10
+ type UnifiedCalendarMember,
11
+ type UnifiedCalendarView,
12
+ type UnifiedOpeningHourRow,
13
+ type UnifiedParticipantWithHours,
14
+ } from "./calendar/buildUnifiedCalendarView.js";
15
+ export { fetchCalendarWithOpeningHours, unwrapCalendarGetData, pickOpeningHoursArrayFromCalendarPayload, normalizeParticipantOpeningHoursResponse } from "./calendar/fetchCalendarWithOpeningHours.js";
16
+ export { getOpeningHours } from "./calendar/getOpeningHours.js";
17
+ export { getParticipantOpeningHours } from "./calendar/getParticipantOpeningHours.js";
18
+ export { getAllParticipantOpeningHours } from "./calendar/getAllParticipantOpeningHours.js";
19
+ export { getParticipants } from "./calendar/getParticipants.js";
20
+ export { getExampleSlots, getExampleEvents, getExampleParticipants, getExampleCalendarRoot, getExampleCalendarRootSnapshot } from "./exampleData.js";
21
+
22
+ // Re-export core models from calendar-client for convenience
23
+ export { createCalendarAsync, updateCalendarAsync, deleteCalendarAsync, resolveBlazeoConnection } from "./calendar/createCalendar.js";
24
+ export { CalendarCreation, createCalendarWithRelationsAsync, updateCalendarWithRelationsAsync, resolveParticipantIdForOpeningHour } from "./calendar/calendarCreation.js";
25
+ export { addParticipantToCalendar, removeParticipantFromCalendar, saveCalendarOpeningHour, saveCalendarOpeningHoursBatch } from "./calendar/blazeoCalendarRelationMethods.js";
26
+ export { createAppointmentEventAsync, rescheduleAppointmentEventAsync, cancelAppointmentEventAsync } from "./events/appointmentEventFacade.js";
27
+ export { mapAppointmentToEventSnapshot } from "./events/mapAppointmentToEventSnapshot.js";
28
+
29
+ export {
30
+ CalendarModel,
31
+ EventModel as CoreEventModel,
32
+ ParticipantModel as CoreParticipantModel,
33
+ CalendarParticipantModel,
34
+ configure,
35
+ getConfig
36
+ } from "@blazeo.com/calendar-client";
37
+
38
+ export const packageName = "@blazeo.com/appointment-client";
39
+
40
+ export class CalendarClient {
41
+ name = "CalendarClient";
42
+ getExampleSlots() {
43
+ return getExampleSlots();
44
+ }
45
+ }
@@ -0,0 +1,60 @@
1
+ import { types, Instance, SnapshotIn, SnapshotOut } from "mobx-state-tree";
2
+
3
+ export const CalendarSlotModel = types.model("CalendarSlot", {
4
+ id: types.identifier,
5
+ title: types.maybeNull(types.string),
6
+ start: types.string,
7
+ end: types.string,
8
+ isAvailable: types.optional(types.boolean, true),
9
+ });
10
+
11
+ export const EventModel = types.model("Event", {
12
+ id: types.identifier,
13
+ title: types.string,
14
+ calendarId: types.maybeNull(types.string),
15
+ startsAt: types.maybeNull(types.string),
16
+ endsAt: types.maybeNull(types.string),
17
+ participantIds: types.optional(types.array(types.string), []),
18
+ });
19
+
20
+ export const ParticipantModel = types.model("Participant", {
21
+ id: types.identifier,
22
+ name: types.string,
23
+ email: types.maybeNull(types.string),
24
+ role: types.maybeNull(types.string),
25
+ });
26
+
27
+ export const CalendarRootModel = types
28
+ .model("CalendarRoot", {
29
+ slots: types.array(CalendarSlotModel),
30
+ events: types.array(EventModel),
31
+ participants: types.array(ParticipantModel),
32
+ })
33
+ .actions((self) => ({
34
+ removeSlot(id: string) {
35
+ const i = self.slots.findIndex((s) => s.id === id);
36
+ if (i >= 0) self.slots.splice(i, 1);
37
+ },
38
+ removeEvent(id: string) {
39
+ const i = self.events.findIndex((e) => e.id === id);
40
+ if (i >= 0) self.events.splice(i, 1);
41
+ },
42
+ removeParticipant(id: string) {
43
+ const i = self.participants.findIndex((p) => p.id === id);
44
+ if (i >= 0) self.participants.splice(i, 1);
45
+ },
46
+ }));
47
+
48
+ export interface ICalendarRoot extends Instance<typeof CalendarRootModel> {}
49
+ export interface ICalendarRootSnapshotIn extends SnapshotIn<typeof CalendarRootModel> {}
50
+ export interface ICalendarRootSnapshotOut extends SnapshotOut<typeof CalendarRootModel> {}
51
+
52
+ export function createCalendarRoot(snapshot?: ICalendarRootSnapshotIn): ICalendarRoot {
53
+ return snapshot
54
+ ? CalendarRootModel.create(snapshot)
55
+ : CalendarRootModel.create({
56
+ slots: [],
57
+ events: [],
58
+ participants: [],
59
+ });
60
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+ "declaration": true,
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true
13
+ },
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules", "dist", "sample"]
16
+ }