@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
@@ -1,75 +1,95 @@
1
- import { CalendarModel } from "@blazeo.com/calendar-client";
2
- import { getSnapshot } from "mobx-state-tree";
3
- /**
4
- * Unwrap nested REST shapes: `res.data`, `res.Data`, or `res.data.data`.
5
- */
6
- export function unwrapCalendarGetData(res) {
7
- if (res == null || typeof res !== "object")
8
- return null;
9
- let d = res.data ?? res.Data;
10
- if (d == null)
11
- return null;
12
- if (typeof d === "object" && (d.data != null || d.Data != null)) {
13
- d = d.data ?? d.Data;
14
- }
15
- return d;
16
- }
17
- /** `openingHours` / `OpeningHours` on the calendar object returned by GET /Calendar/Get (matches GraphQL-style payloads). */
18
- export function pickOpeningHoursArrayFromCalendarPayload(data) {
19
- if (data == null || typeof data !== "object")
20
- return null;
21
- const h = data.openingHours ?? data.OpeningHours;
22
- return Array.isArray(h) ? h : null;
23
- }
24
- /**
25
- * Normalize `calendar.getParticipantOpeningHours()` response (`GET /Calendar/Participant/OpeningHours/Get`).
26
- */
27
- export function normalizeParticipantOpeningHoursResponse(res) {
28
- if (res == null)
29
- return { list: null, raw: res };
30
- const d = res.data ?? res.Data;
31
- if (Array.isArray(d))
32
- return { list: d, raw: res };
33
- if (d && typeof d === "object") {
34
- if (Array.isArray(d.openingHours))
35
- return { list: d.openingHours, raw: res };
36
- if (Array.isArray(d.OpeningHours))
37
- return { list: d.OpeningHours, raw: res };
38
- if (Array.isArray(d.items))
39
- return { list: d.items, raw: res };
40
- }
41
- return { list: null, raw: res };
42
- }
43
- /**
44
- * Loads `CalendarModel` and attaches **`openingHours`** to the MST snapshot:
45
- * 1. Prefer rows embedded on **GET /Calendar/Get** (`CalendarModel.getRaw` payload — `@blazeo.com/calendar-client` MST omits them).
46
- * 2. If missing/empty, calls **`calendar.getParticipantOpeningHours()`** (`GET /Calendar/Participant/OpeningHours/Get`).
47
- */
48
- export async function fetchCalendarWithOpeningHours(calendarId, options = {}) {
49
- const { includeRawGet = false } = options;
50
- const rawRes = await CalendarModel.getRaw(calendarId);
51
- const cal = await CalendarModel.get(calendarId);
52
- const payload = unwrapCalendarGetData(rawRes);
53
- const embedded = pickOpeningHoursArrayFromCalendarPayload(payload) ?? [];
54
- let resolved = embedded.length > 0 ? embedded : null;
55
- let participantRes = null;
56
- if ((resolved == null || resolved.length === 0) && cal != null) {
57
- participantRes = await cal.getParticipantOpeningHours({});
58
- const { list } = normalizeParticipantOpeningHoursResponse(participantRes);
59
- if (list != null && list.length > 0)
60
- resolved = list;
61
- }
62
- const openingHours = Array.isArray(resolved) ? resolved : [];
63
- const snap = cal != null ? getSnapshot(cal) : null;
64
- const calendar = snap != null ? { ...snap, openingHours } : null;
65
- return {
66
- calendar,
67
- cal,
68
- openingHours,
69
- embeddedFromGet: embedded,
70
- fromCalendarGet: embedded.length > 0,
71
- fromParticipantApi: embedded.length === 0 && openingHours.length > 0 && participantRes != null,
72
- participantOpeningHoursResponse: participantRes,
73
- ...(includeRawGet ? { rawGet: rawRes } : {}),
74
- };
75
- }
1
+ import { CalendarModel } from "@blazeo.com/calendar-client";
2
+ import { getSnapshot } from "mobx-state-tree";
3
+ /**
4
+ * Unwrap nested REST shapes: `res.data`, `res.Data`, or `res.data.data`.
5
+ */
6
+ export function unwrapCalendarGetData(res) {
7
+ if (res == null || typeof res !== "object")
8
+ return null;
9
+ let d = res.data ?? res.Data;
10
+ if (d == null)
11
+ return null;
12
+ if (typeof d === "object" && (d.data != null || d.Data != null)) {
13
+ d = d.data ?? d.Data;
14
+ }
15
+ return d;
16
+ }
17
+ /** `openingHours` / `OpeningHours` on the calendar object returned by GET /Calendar/
18
+ * Robustly picks opening hours array from a raw calendar payload.
19
+ */
20
+ export function pickOpeningHoursArrayFromCalendarPayload(data) {
21
+ if (data == null)
22
+ return null;
23
+ const { list } = normalizeParticipantOpeningHoursResponse(data);
24
+ return list;
25
+ }
26
+ /**
27
+ * Normalize `calendar.getParticipantOpeningHours()` response (`GET /Calendar/Participant/OpeningHours/Get`).
28
+ * Supports various Blazeo API shapes including nested data and common property names.
29
+ */
30
+ export function normalizeParticipantOpeningHoursResponse(res) {
31
+ if (res == null)
32
+ return { list: null, raw: res };
33
+ // 1. Check for standard envelope: res.data or res.Data
34
+ let d = res.data ?? res.Data ?? res;
35
+ // 2. Handle double-nested data (common in some Blazeo API versions)
36
+ if (d && typeof d === "object" && !Array.isArray(d)) {
37
+ if (d.data !== undefined)
38
+ d = d.data;
39
+ else if (d.Data !== undefined)
40
+ d = d.Data;
41
+ }
42
+ // 3. If d is now an array, that's our list
43
+ if (Array.isArray(d))
44
+ return { list: d, raw: res };
45
+ // 4. Otherwise check for known list properties on the object
46
+ if (d && typeof d === "object") {
47
+ const list = d.openingHours ??
48
+ d.OpeningHours ??
49
+ d.participantOpeningHours ??
50
+ d.ParticipantOpeningHours ??
51
+ d.rows ??
52
+ d.Rows ??
53
+ d.items ??
54
+ d.Items ??
55
+ d.list ??
56
+ d.List;
57
+ if (Array.isArray(list))
58
+ return { list, raw: res };
59
+ }
60
+ return { list: null, raw: res };
61
+ }
62
+ /**
63
+ * Loads `CalendarModel` and attaches **`openingHours`** to the MST snapshot:
64
+ * 1. Prefer rows embedded on **GET /Calendar/Get** (`CalendarModel.getRaw` payload `@blazeo.com/calendar-client` MST omits them).
65
+ * 2. If missing/empty, calls **`calendar.getParticipantOpeningHours()`** (`GET /Calendar/Participant/OpeningHours/Get`).
66
+ */
67
+ export async function fetchCalendarWithOpeningHours(calendarId, options = {}) {
68
+ const { includeRawGet = false } = options;
69
+ const rawRes = await CalendarModel.getRaw(calendarId);
70
+ const cal = await CalendarModel.get(calendarId);
71
+ const payload = unwrapCalendarGetData(rawRes);
72
+ const embedded = pickOpeningHoursArrayFromCalendarPayload(payload) ?? [];
73
+ let resolved = embedded.length > 0 ? embedded : null;
74
+ let participantRes = null;
75
+ if ((resolved == null || resolved.length === 0) && cal != null) {
76
+ // Pass calendarId explicitly because some server shapes do not populate `self.calendarId` on the MST model.
77
+ participantRes = await cal.getParticipantOpeningHours({ calendarId });
78
+ const { list } = normalizeParticipantOpeningHoursResponse(participantRes);
79
+ if (list != null && list.length > 0)
80
+ resolved = list;
81
+ }
82
+ const openingHours = Array.isArray(resolved) ? resolved : [];
83
+ const snap = cal != null ? getSnapshot(cal) : null;
84
+ const calendar = snap != null ? { ...snap, openingHours } : null;
85
+ return {
86
+ calendar,
87
+ cal,
88
+ openingHours,
89
+ embeddedFromGet: embedded,
90
+ fromCalendarGet: embedded.length > 0,
91
+ fromParticipantApi: embedded.length === 0 && openingHours.length > 0 && participantRes != null,
92
+ participantOpeningHoursResponse: participantRes,
93
+ ...(includeRawGet ? { rawGet: rawRes } : {}),
94
+ };
95
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Fetch all participant opening hours for a calendar.
3
+ * Uses `GET /Calendar/Participant/OpeningHours/All/Get`.
4
+ */
5
+ export declare function getAllParticipantOpeningHours(calendarId: string): Promise<{
6
+ openingHours: any[];
7
+ raw: any[];
8
+ meta: {
9
+ ok: true;
10
+ shape: "array";
11
+ };
12
+ } | {
13
+ openingHours: any[];
14
+ raw: any;
15
+ meta: {
16
+ ok: boolean;
17
+ shape?: undefined;
18
+ };
19
+ }>;
@@ -0,0 +1,17 @@
1
+ import { CalendarModel } from "@blazeo.com/calendar-client";
2
+ import { normalizeParticipantOpeningHoursResponse } from "./fetchCalendarWithOpeningHours.js";
3
+ /**
4
+ * Fetch all participant opening hours for a calendar.
5
+ * Uses `GET /Calendar/Participant/OpeningHours/All/Get`.
6
+ */
7
+ export async function getAllParticipantOpeningHours(calendarId) {
8
+ const raw = await CalendarModel.getAllParticipantOpeningHours(calendarId);
9
+ // calendar-client static helper returns either `unknown[] | null` or an envelope depending on version/entrypoint.
10
+ if (Array.isArray(raw)) {
11
+ return { openingHours: raw, raw, meta: { ok: true, shape: "array" } };
12
+ }
13
+ const { list } = normalizeParticipantOpeningHoursResponse(raw);
14
+ const openingHours = Array.isArray(list) ? list : [];
15
+ const ok = Array.isArray(list) ? true : raw?.status === "success";
16
+ return { openingHours, raw, meta: { ok: !!ok } };
17
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Fetches opening hours for a calendar.
3
+ * Automatically handles embedded calendar-level hours and participant-level fallbacks.
4
+ */
5
+ export declare function getOpeningHours(calendarId: string): Promise<any[]>;
@@ -0,0 +1,9 @@
1
+ import { fetchCalendarWithOpeningHours } from "./fetchCalendarWithOpeningHours.js";
2
+ /**
3
+ * Fetches opening hours for a calendar.
4
+ * Automatically handles embedded calendar-level hours and participant-level fallbacks.
5
+ */
6
+ export async function getOpeningHours(calendarId) {
7
+ const result = await fetchCalendarWithOpeningHours(calendarId);
8
+ return result.openingHours;
9
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Direct wrapper around `calendar.getParticipantOpeningHours()` for a calendar id.
3
+ *
4
+ * This hits `GET /Calendar/Participant/OpeningHours/Get` (server-side shape may vary),
5
+ * so we also return a normalized list alongside the raw response.
6
+ */
7
+ export declare function getParticipantOpeningHours(calendarId: string, options?: any): Promise<{
8
+ openingHours: any[];
9
+ raw: any;
10
+ meta: {
11
+ ok: false;
12
+ reason: string;
13
+ count?: undefined;
14
+ status?: undefined;
15
+ error?: undefined;
16
+ };
17
+ } | {
18
+ openingHours: any[];
19
+ raw: any;
20
+ meta: {
21
+ ok: true;
22
+ count: number;
23
+ status: any;
24
+ reason?: undefined;
25
+ error?: undefined;
26
+ };
27
+ } | {
28
+ openingHours: any[];
29
+ raw: any;
30
+ meta: {
31
+ ok: false;
32
+ reason: string;
33
+ error: string;
34
+ count?: undefined;
35
+ status?: undefined;
36
+ };
37
+ }>;
@@ -0,0 +1,43 @@
1
+ import { CalendarModel } from "@blazeo.com/calendar-client";
2
+ import { normalizeParticipantOpeningHoursResponse } from "./fetchCalendarWithOpeningHours.js";
3
+ /**
4
+ * Direct wrapper around `calendar.getParticipantOpeningHours()` for a calendar id.
5
+ *
6
+ * This hits `GET /Calendar/Participant/OpeningHours/Get` (server-side shape may vary),
7
+ * so we also return a normalized list alongside the raw response.
8
+ */
9
+ export async function getParticipantOpeningHours(calendarId, options = {}) {
10
+ try {
11
+ const cal = await CalendarModel.get(calendarId);
12
+ if (cal == null) {
13
+ return {
14
+ openingHours: [],
15
+ raw: null,
16
+ meta: { ok: false, reason: "calendar_not_found" },
17
+ };
18
+ }
19
+ const raw = await cal.getParticipantOpeningHours({ calendarId, ...(options ?? {}) });
20
+ const { list } = normalizeParticipantOpeningHoursResponse(raw);
21
+ const openingHours = Array.isArray(list) ? list : [];
22
+ return {
23
+ openingHours,
24
+ raw,
25
+ meta: {
26
+ ok: true,
27
+ count: openingHours.length,
28
+ status: raw?.status ?? (raw?.Status || "unknown"),
29
+ },
30
+ };
31
+ }
32
+ catch (err) {
33
+ return {
34
+ openingHours: [],
35
+ raw: null,
36
+ meta: {
37
+ ok: false,
38
+ reason: "exception",
39
+ error: err instanceof Error ? err.message : String(err),
40
+ },
41
+ };
42
+ }
43
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Fetches participants for a calendar.
3
+ */
4
+ export declare function getParticipants(calendarId: string): Promise<any[]>;
@@ -0,0 +1,8 @@
1
+ import { CalendarModel } from "@blazeo.com/calendar-client";
2
+ /**
3
+ * Fetches participants for a calendar.
4
+ */
5
+ export async function getParticipants(calendarId) {
6
+ const participants = await CalendarModel.getParticipants(calendarId);
7
+ return Array.isArray(participants) ? participants : [];
8
+ }
@@ -1,10 +1,10 @@
1
- import type { CalendarBOInput } from "../types/calendar.js";
2
- /**
3
- * Maps Apex `CalendarBO`-shaped input to a snapshot for
4
- * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
5
- *
6
- * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
7
- * unknown keys or invalid `null`s on optional numbers.
8
- */
9
- export declare function mapCalendarBOToSnapshot(bo: CalendarBOInput): Record<string, unknown>;
1
+ import type { CalendarBOInput } from "../types/calendar.js";
2
+ /**
3
+ * Maps Apex `CalendarBO`-shaped input to a snapshot for
4
+ * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
5
+ *
6
+ * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
7
+ * unknown keys or invalid `null`s on optional numbers.
8
+ */
9
+ export declare function mapCalendarBOToSnapshot(bo: CalendarBOInput): Record<string, unknown>;
10
10
  //# sourceMappingURL=mapCalendarBoToBlazeoSnapshot.d.ts.map
@@ -1,44 +1,44 @@
1
- /** Default enum values aligned with ApexFlows / Blazeo (`AssignmentMethod`, `Unit`). */
2
- const DEFAULT_ASSIGNMENT_METHOD = 1;
3
- const DEFAULT_UNIT_MINUTES = 1;
4
- /**
5
- * For Blazeo `Calendar` MST: `types.optional(types.number)` accepts `undefined` (uses default)
6
- * but not `null`. Coerce null/absent to `undefined`.
7
- */
8
- function optionalNumber(v) {
9
- return v == null ? undefined : v;
10
- }
11
- /**
12
- * Maps Apex `CalendarBO`-shaped input to a snapshot for
13
- * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
14
- *
15
- * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
16
- * unknown keys or invalid `null`s on optional numbers.
17
- */
18
- export function mapCalendarBOToSnapshot(bo) {
19
- const calendarId = bo.calendarId ?? bo.thirdPartyCalendarId ?? "new";
20
- return {
21
- id: bo.serverId == null ? undefined : bo.serverId,
22
- companyKey: bo.companyKey ?? null,
23
- calendarId,
24
- name: bo.name ?? null,
25
- timeZoneId: bo.timeZoneId ?? null,
26
- purpose: bo.purpose ?? bo.bookingPageTitle ?? "",
27
- description: bo.description ?? null,
28
- assignmentMethod: bo.assignmentMethod ?? bo.assignmentType ?? DEFAULT_ASSIGNMENT_METHOD,
29
- duration: optionalNumber(bo.duration) ?? 30,
30
- durationUnit: optionalNumber(bo.durationUnit) ?? DEFAULT_UNIT_MINUTES,
31
- minimumBookingNotice: optionalNumber(bo.minimumBookingNotice) ?? 0,
32
- minimumBookingNoticeUnit: optionalNumber(bo.minimumBookingNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
33
- minimumCancelationNotice: optionalNumber(bo.minimumCancelationNotice) ?? 0,
34
- minimumCancelationNoticeUnit: optionalNumber(bo.minimumCancelationNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
35
- futureLimit: optionalNumber(bo.futureLimit) ?? 0,
36
- futureLimitUnit: optionalNumber(bo.futureLimitUnit) ?? 3,
37
- bufferTime: optionalNumber(bo.bufferTime),
38
- bufferTimeUnit: optionalNumber(bo.bufferTimeUnit) ?? DEFAULT_UNIT_MINUTES,
39
- bookingLimit: optionalNumber(bo.bookingLimit),
40
- createdOn: bo.createdOn ?? null,
41
- modifiedOn: bo.modifiedOn ?? null,
42
- };
43
- }
1
+ /** Default enum values aligned with ApexFlows / Blazeo (`AssignmentMethod`, `Unit`). */
2
+ const DEFAULT_ASSIGNMENT_METHOD = 1;
3
+ const DEFAULT_UNIT_MINUTES = 1;
4
+ /**
5
+ * For Blazeo `Calendar` MST: `types.optional(types.number)` accepts `undefined` (uses default)
6
+ * but not `null`. Coerce null/absent to `undefined`.
7
+ */
8
+ function optionalNumber(v) {
9
+ return v == null ? undefined : v;
10
+ }
11
+ /**
12
+ * Maps Apex `CalendarBO`-shaped input to a snapshot for
13
+ * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
14
+ *
15
+ * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
16
+ * unknown keys or invalid `null`s on optional numbers.
17
+ */
18
+ export function mapCalendarBOToSnapshot(bo) {
19
+ const calendarId = bo.calendarId ?? bo.thirdPartyCalendarId ?? "new";
20
+ return {
21
+ id: bo.serverId == null ? undefined : bo.serverId,
22
+ companyKey: bo.companyKey ?? null,
23
+ calendarId,
24
+ name: bo.name ?? null,
25
+ timeZoneId: bo.timeZoneId ?? null,
26
+ purpose: bo.purpose ?? bo.bookingPageTitle ?? "",
27
+ description: bo.description ?? null,
28
+ assignmentMethod: bo.assignmentMethod ?? bo.assignmentType ?? DEFAULT_ASSIGNMENT_METHOD,
29
+ duration: optionalNumber(bo.duration) ?? 30,
30
+ durationUnit: optionalNumber(bo.durationUnit) ?? DEFAULT_UNIT_MINUTES,
31
+ minimumBookingNotice: optionalNumber(bo.minimumBookingNotice) ?? 0,
32
+ minimumBookingNoticeUnit: optionalNumber(bo.minimumBookingNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
33
+ minimumCancelationNotice: optionalNumber(bo.minimumCancelationNotice) ?? 0,
34
+ minimumCancelationNoticeUnit: optionalNumber(bo.minimumCancelationNoticeUnit) ?? DEFAULT_UNIT_MINUTES,
35
+ futureLimit: optionalNumber(bo.futureLimit) ?? 0,
36
+ futureLimitUnit: optionalNumber(bo.futureLimitUnit) ?? 3,
37
+ bufferTime: optionalNumber(bo.bufferTime),
38
+ bufferTimeUnit: optionalNumber(bo.bufferTimeUnit) ?? DEFAULT_UNIT_MINUTES,
39
+ bookingLimit: optionalNumber(bo.bookingLimit),
40
+ createdOn: bo.createdOn ?? null,
41
+ modifiedOn: bo.modifiedOn ?? null,
42
+ };
43
+ }
44
44
  //# sourceMappingURL=mapCalendarBoToBlazeoSnapshot.js.map
@@ -1,4 +1,3 @@
1
- import type { CalendarInput } from "../types/calendar.js";
2
1
  /**
3
2
  * Maps Apex `CalendarBO`-shaped input to a snapshot for
4
3
  * {@link CalendarModel.create} from `@blazeo.com/calendar-client`.
@@ -6,5 +5,25 @@ import type { CalendarInput } from "../types/calendar.js";
6
5
  * Only fields that exist on Blazeo's `Calendar` model are included so MST does not receive
7
6
  * unknown keys or invalid `null`s on optional numbers.
8
7
  */
9
- export declare function mapCalendarBOToSnapshot(bo: CalendarInput): Record<string, unknown>;
10
- //# sourceMappingURL=mapCalendarToBlazeoSnapshot.d.ts.map
8
+ export declare function mapCalendarBOToSnapshot(bo: any): {
9
+ companyKey: any;
10
+ calendarId: any;
11
+ name: any;
12
+ timeZoneId: any;
13
+ purpose: any;
14
+ description: any;
15
+ assignmentMethod: any;
16
+ duration: any;
17
+ durationUnit: any;
18
+ minimumBookingNotice: any;
19
+ minimumBookingNoticeUnit: any;
20
+ minimumCancelationNotice: any;
21
+ minimumCancelationNoticeUnit: any;
22
+ futureLimit: any;
23
+ futureLimitUnit: any;
24
+ bufferTime: any;
25
+ bufferTimeUnit: any;
26
+ bookingLimit: any;
27
+ createdOn: any;
28
+ modifiedOn: any;
29
+ };
@@ -42,4 +42,3 @@ export function mapCalendarBOToSnapshot(bo) {
42
42
  modifiedOn: bo.modifiedOn ?? null,
43
43
  };
44
44
  }
45
- //# sourceMappingURL=mapCalendarToBlazeoSnapshot.js.map
@@ -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
@@ -11,4 +11,3 @@ export function applyBlazeoClientConfig() {
11
11
  ...(consumer ? { consumer } : {}),
12
12
  });
13
13
  }
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
@@ -7,6 +7,5 @@
7
7
  */
8
8
  export declare const blazeoClientConfig: {
9
9
  baseUrl: string;
10
- consumer?: string;
10
+ consumer: string;
11
11
  };
12
- //# sourceMappingURL=blazeoClientDefaults.d.ts.map
@@ -9,4 +9,3 @@ export const blazeoClientConfig = {
9
9
  baseUrl: "",
10
10
  consumer: "",
11
11
  };
12
- //# sourceMappingURL=blazeoClientDefaults.js.map
@@ -1,31 +1,7 @@
1
- /**
2
- * Required once per host app before calling any facade that hits the Blazeo HTTP API.
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
- /** Optional offset helper for event endpoints (minutes). */
26
- getDefaultOffset?: () => number;
27
- };
28
- export declare function initializeAppointmentClient(options?: AppointmentClientConnectOptions): void;
29
- /** True when global Blazeo config has a non-empty `baseUrl` (after {@link configure}). */
5
+ }
6
+ export declare function initializeAppointmentClient(config: AppointmentClientConfig): void;
30
7
  export declare function isAppointmentClientConfigured(): boolean;
31
- //# sourceMappingURL=initializeAppointmentClient.d.ts.map