@blazeo.com/appointment-client 1.0.4 → 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 (104) 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 -0
  13. package/dist/calendar/fetchCalendarDetails.js +192 -0
  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 -81
  51. package/dist/index.js +21 -32
  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 +9 -4
  69. package/sample/build_error.txt +0 -0
  70. package/sample/demo.js +70 -0
  71. package/sample/package-lock.json +53 -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/EventTab.jsx +128 -0
  79. package/sample/src/FetchCalendarTab.jsx +72 -43
  80. package/sample/src/OpeningHoursTab.jsx +78 -0
  81. package/sample/src/ParticipantInfoTab.jsx +72 -0
  82. package/sample/src/ParticipantOpeningHoursTab.jsx +88 -0
  83. package/sample/src/ParticipantTab.jsx +2 -2
  84. package/src/calendar/blazeoCalendarRelationMethods.ts +19 -0
  85. package/src/calendar/buildUnifiedCalendarView.ts +322 -0
  86. package/src/calendar/calendarCreation.ts +179 -0
  87. package/src/calendar/createCalendar.ts +243 -0
  88. package/src/calendar/fetchCalendarDetails.ts +226 -0
  89. package/src/calendar/fetchCalendarWithOpeningHours.ts +99 -0
  90. package/src/calendar/getAllParticipantOpeningHours.ts +22 -0
  91. package/src/calendar/getOpeningHours.ts +10 -0
  92. package/src/calendar/getParticipantOpeningHours.ts +46 -0
  93. package/src/calendar/getParticipants.ts +9 -0
  94. package/src/calendar/mapCalendarToBlazeoSnapshot.ts +46 -0
  95. package/src/config/applyBlazeoDefaults.ts +13 -0
  96. package/src/config/blazeoClientDefaults.ts +11 -0
  97. package/src/config/initializeAppointmentClient.ts +18 -0
  98. package/src/events/appointmentEventFacade.ts +148 -0
  99. package/src/events/mapAppointmentToEventSnapshot.ts +65 -0
  100. package/src/exampleData.ts +79 -0
  101. package/src/index.ts +45 -0
  102. package/src/models/CalendarRootModel.ts +60 -0
  103. package/tsconfig.json +16 -0
  104. package/blazeo.com-appointment-client-1.0.4.tgz +0 -0
@@ -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
@@ -1,28 +1,9 @@
1
1
  import { configure, getConfig } from "@blazeo.com/calendar-client";
2
- import { blazeoClientConfig } from "./blazeoClientDefaults.js";
3
- export function initializeAppointmentClient(options = {}) {
4
- debugger;
5
- const fromOpts = options.baseUrl?.trim().replace(/\/+$/, "") ?? "";
6
- const fromFile = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "") ?? "";
7
- const baseUrl = fromOpts || fromFile;
8
- if (!baseUrl) {
9
- throw new Error("initializeAppointmentClient: set `baseUrl` (argument) or non-empty `blazeoClientConfig.baseUrl` in `blazeoClientDefaults.ts`. Static Blazeo helpers (e.g. CalendarModel.get) require configure({ baseUrl }).");
10
- }
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
- });
2
+ let isConfigured = false;
3
+ export function initializeAppointmentClient(config) {
4
+ configure(config);
5
+ isConfigured = true;
22
6
  }
23
- /** True when global Blazeo config has a non-empty `baseUrl` (after {@link configure}). */
24
7
  export function isAppointmentClientConfigured() {
25
- const cfg = getConfig();
26
- return Boolean(cfg?.baseUrl?.trim());
8
+ return isConfigured || getConfig() !== null;
27
9
  }
28
- //# sourceMappingURL=initializeAppointmentClient.js.map
@@ -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: ApexAppointmentInput, options?: AppointmentEventOptions): Promise<AppointmentEventResult>;
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: ApexAppointmentInput, options?: AppointmentEventOptions): Promise<AppointmentEventResult>;
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?: CreateCalendarOptions): Promise<AppointmentEventResult>;
44
- //# sourceMappingURL=appointmentEventFacade.d.ts.map
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, } from "../calendar/createCalendar.js";
3
- import { mapAppointmentToEventSnapshot, } from "./mapAppointmentToEventSnapshot.js";
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 = (await EventModel.cancel(id));
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: ApexAppointmentInput, mode: AppointmentEventMappingMode): Record<string, unknown>;
8
- //# sourceMappingURL=mapAppointmentToEventSnapshot.d.ts.map
5
+ export declare function mapAppointmentToEventSnapshot(input: any, mode: "create" | "reschedule"): any;
@@ -55,4 +55,3 @@ export function mapAppointmentToEventSnapshot(input, mode) {
55
55
  }
56
56
  return snap;
57
57
  }
58
- //# sourceMappingURL=mapAppointmentToEventSnapshot.js.map