@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
@@ -1,15 +1,119 @@
1
- import { type CalendarSlot } from "./models/CalendarSlotModel.js";
2
- import { type CalendarRoot, type CalendarRootSnapshotIn } from "./models/CalendarRootModel.js";
3
- import { type Event } from "./models/EventModel.js";
4
- import { type Participant } from "./models/ParticipantModel.js";
5
1
  /** Example slot nodes (MST instances). */
6
- export declare function getExampleSlots(): CalendarSlot[];
2
+ export declare function getExampleSlots(): (import("mobx-state-tree").ModelInstanceTypeProps<{
3
+ id: import("mobx-state-tree").ISimpleType<string>;
4
+ title: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
5
+ start: import("mobx-state-tree").ISimpleType<string>;
6
+ end: import("mobx-state-tree").ISimpleType<string>;
7
+ isAvailable: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
8
+ }> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
9
+ id: import("mobx-state-tree").ISimpleType<string>;
10
+ title: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
11
+ start: import("mobx-state-tree").ISimpleType<string>;
12
+ end: import("mobx-state-tree").ISimpleType<string>;
13
+ isAvailable: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
14
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
7
15
  /** Example event nodes. */
8
- export declare function getExampleEvents(): Event[];
16
+ export declare function getExampleEvents(): (import("mobx-state-tree").ModelInstanceTypeProps<{
17
+ id: import("mobx-state-tree").ISimpleType<string>;
18
+ title: import("mobx-state-tree").ISimpleType<string>;
19
+ calendarId: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
20
+ startsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
21
+ endsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
22
+ participantIds: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
23
+ }> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
24
+ id: import("mobx-state-tree").ISimpleType<string>;
25
+ title: import("mobx-state-tree").ISimpleType<string>;
26
+ calendarId: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
27
+ startsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
28
+ endsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
29
+ participantIds: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
30
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
9
31
  /** Example participant nodes. */
10
- export declare function getExampleParticipants(): Participant[];
32
+ export declare function getExampleParticipants(): (import("mobx-state-tree").ModelInstanceTypeProps<{
33
+ id: import("mobx-state-tree").ISimpleType<string>;
34
+ name: import("mobx-state-tree").ISimpleType<string>;
35
+ email: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
36
+ role: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
37
+ }> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
38
+ id: import("mobx-state-tree").ISimpleType<string>;
39
+ name: import("mobx-state-tree").ISimpleType<string>;
40
+ email: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
41
+ role: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
42
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>)[];
11
43
  /** Full root store snapshot suitable for `createCalendarRoot(snapshot)`. */
12
- export declare function getExampleCalendarRootSnapshot(): CalendarRootSnapshotIn;
44
+ export declare function getExampleCalendarRootSnapshot(): {
45
+ slots: {
46
+ id: string;
47
+ title: string;
48
+ start: string;
49
+ end: string;
50
+ }[];
51
+ events: {
52
+ id: string;
53
+ title: string;
54
+ calendarId: string;
55
+ startsAt: string;
56
+ endsAt: string;
57
+ participantIds: string[];
58
+ }[];
59
+ participants: {
60
+ id: string;
61
+ name: string;
62
+ email: string;
63
+ role: string;
64
+ }[];
65
+ };
13
66
  /** Root store with example slots, events, and participants. */
14
- export declare function getExampleCalendarRoot(): CalendarRoot;
15
- //# sourceMappingURL=exampleData.d.ts.map
67
+ export declare function getExampleCalendarRoot(): import("mobx-state-tree").ModelInstanceTypeProps<{
68
+ slots: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
69
+ id: import("mobx-state-tree").ISimpleType<string>;
70
+ title: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
71
+ start: import("mobx-state-tree").ISimpleType<string>;
72
+ end: import("mobx-state-tree").ISimpleType<string>;
73
+ isAvailable: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
74
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
75
+ events: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
76
+ id: import("mobx-state-tree").ISimpleType<string>;
77
+ title: import("mobx-state-tree").ISimpleType<string>;
78
+ calendarId: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
79
+ startsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
80
+ endsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
81
+ participantIds: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
82
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
83
+ participants: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
84
+ id: import("mobx-state-tree").ISimpleType<string>;
85
+ name: import("mobx-state-tree").ISimpleType<string>;
86
+ email: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
87
+ role: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
88
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
89
+ }> & {
90
+ removeSlot(id: string): void;
91
+ removeEvent(id: string): void;
92
+ removeParticipant(id: string): void;
93
+ } & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IModelType<{
94
+ slots: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
95
+ id: import("mobx-state-tree").ISimpleType<string>;
96
+ title: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
97
+ start: import("mobx-state-tree").ISimpleType<string>;
98
+ end: import("mobx-state-tree").ISimpleType<string>;
99
+ isAvailable: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
100
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
101
+ events: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
102
+ id: import("mobx-state-tree").ISimpleType<string>;
103
+ title: import("mobx-state-tree").ISimpleType<string>;
104
+ calendarId: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
105
+ startsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
106
+ endsAt: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
107
+ participantIds: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").ISimpleType<string>>, [undefined]>;
108
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
109
+ participants: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
110
+ id: import("mobx-state-tree").ISimpleType<string>;
111
+ name: import("mobx-state-tree").ISimpleType<string>;
112
+ email: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
113
+ role: import("mobx-state-tree").IMaybeNull<import("mobx-state-tree").ISimpleType<string>>;
114
+ }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
115
+ }, {
116
+ removeSlot(id: string): void;
117
+ removeEvent(id: string): void;
118
+ removeParticipant(id: string): void;
119
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
@@ -1,7 +1,7 @@
1
- import { CalendarSlotModel } from "./models/CalendarSlotModel.js";
2
- import { CalendarRootModel, } from "./models/CalendarRootModel.js";
3
- import { EventModel } from "./models/EventModel.js";
4
- import { ParticipantModel, } from "./models/ParticipantModel.js";
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
5
  const EXAMPLE_SLOT_SNAPSHOTS = [
6
6
  {
7
7
  id: "slot-1",
@@ -69,4 +69,3 @@ export function getExampleCalendarRootSnapshot() {
69
69
  export function getExampleCalendarRoot() {
70
70
  return CalendarRootModel.create(getExampleCalendarRootSnapshot());
71
71
  }
72
- //# sourceMappingURL=exampleData.js.map
@@ -1,40 +1,40 @@
1
- import type { IStateTreeNode } from "mobx-state-tree";
2
- import type { CalendarBOInput } from "../types/calendarBo.js";
3
- export type CreateCalendarOptions = {
4
- /** Overrides `blazeo.config` / global `configure` when set. */
5
- baseUrl?: string;
6
- consumer?: string;
7
- /**
8
- * When true, only builds the MST `Calendar` node (no HTTP).
9
- * Default false: calls `calendar.create()` → POST `/Calendar/Create`.
10
- */
11
- localOnly?: boolean;
12
- };
13
- /** Typical Blazeo `reqPost` / `calendar.create()` result shape. */
14
- export type BlazeoCalendarCreateResponse = {
15
- status: string;
16
- message?: string;
17
- data?: unknown;
18
- };
19
- export type CreateCalendarSuccess = {
20
- ok: true;
21
- calendar: IStateTreeNode;
22
- apiResponse?: BlazeoCalendarCreateResponse;
23
- };
24
- export type CreateCalendarFailure = {
25
- ok: false;
26
- error: string;
27
- apiResponse?: BlazeoCalendarCreateResponse;
28
- };
29
- export type CreateCalendarResult = CreateCalendarSuccess | CreateCalendarFailure;
30
- /** Merge per-call options with global Blazeo config (file + `configure`). */
31
- export declare function resolveBlazeoConnection(options?: CreateCalendarOptions): {
32
- baseUrl?: string;
33
- consumer?: string;
34
- };
35
- /**
36
- * Uses {@link resolveBlazeoConnection} (config file + `configure` + optional overrides),
37
- * then `CalendarModel.create` and `calendar.create()` unless `localOnly`.
38
- */
39
- export declare function createCalendarAsync(calendar: CalendarBOInput, options?: CreateCalendarOptions): Promise<CreateCalendarResult>;
1
+ import type { IStateTreeNode } from "mobx-state-tree";
2
+ import type { CalendarBOInput } from "../types/calendarBo.js";
3
+ export type CreateCalendarOptions = {
4
+ /** Overrides `blazeo.config` / global `configure` when set. */
5
+ baseUrl?: string;
6
+ consumer?: string;
7
+ /**
8
+ * When true, only builds the MST `Calendar` node (no HTTP).
9
+ * Default false: calls `calendar.create()` → POST `/Calendar/Create`.
10
+ */
11
+ localOnly?: boolean;
12
+ };
13
+ /** Typical Blazeo `reqPost` / `calendar.create()` result shape. */
14
+ export type BlazeoCalendarCreateResponse = {
15
+ status: string;
16
+ message?: string;
17
+ data?: unknown;
18
+ };
19
+ export type CreateCalendarSuccess = {
20
+ ok: true;
21
+ calendar: IStateTreeNode;
22
+ apiResponse?: BlazeoCalendarCreateResponse;
23
+ };
24
+ export type CreateCalendarFailure = {
25
+ ok: false;
26
+ error: string;
27
+ apiResponse?: BlazeoCalendarCreateResponse;
28
+ };
29
+ export type CreateCalendarResult = CreateCalendarSuccess | CreateCalendarFailure;
30
+ /** Merge per-call options with global Blazeo config (file + `configure`). */
31
+ export declare function resolveBlazeoConnection(options?: CreateCalendarOptions): {
32
+ baseUrl?: string;
33
+ consumer?: string;
34
+ };
35
+ /**
36
+ * Uses {@link resolveBlazeoConnection} (config file + `configure` + optional overrides),
37
+ * then `CalendarModel.create` and `calendar.create()` unless `localOnly`.
38
+ */
39
+ export declare function createCalendarAsync(calendar: CalendarBOInput, options?: CreateCalendarOptions): Promise<CreateCalendarResult>;
40
40
  //# sourceMappingURL=calendarCreationFacade.d.ts.map
@@ -1,96 +1,96 @@
1
- import { CalendarModel, configure, getConfig } from "@blazeo.com/calendar-client";
2
- import { blazeoClientConfig } from "../config/blazeo.config.js";
3
- import { mapCalendarBOToSnapshot } from "./mapCalendarBOToSnapshot.js";
4
- function isFailureStatus(res) {
5
- return res.status !== "success" && res.status !== "Success";
6
- }
7
- /** Merge per-call options with global Blazeo config (file + `configure`). */
8
- export function resolveBlazeoConnection(options = {}) {
9
- const cfg = getConfig();
10
- const fromFileBase = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
11
- const fromFileConsumer = blazeoClientConfig.consumer?.trim();
12
- const baseUrl = options.baseUrl?.trim().replace(/\/+$/, "") ||
13
- cfg?.baseUrl?.replace(/\/+$/, "") ||
14
- (fromFileBase || undefined);
15
- const consumer = options.consumer?.trim() ||
16
- cfg?.consumer ||
17
- (fromFileConsumer || undefined);
18
- return { baseUrl, consumer };
19
- }
20
- function buildModelEnv(baseUrl, consumer, forLocalOnly) {
21
- if (forLocalOnly && !baseUrl) {
22
- return {};
23
- }
24
- const cfg = getConfig();
25
- const env = {};
26
- if (baseUrl) {
27
- env.baseUrl = baseUrl;
28
- }
29
- else if (cfg?.baseUrl) {
30
- env.baseUrl = cfg.baseUrl;
31
- }
32
- if (consumer) {
33
- env.consumer = consumer;
34
- }
35
- else if (cfg?.consumer) {
36
- env.consumer = cfg.consumer;
37
- }
38
- if (cfg?.fetch != null)
39
- env.fetch = cfg.fetch;
40
- if (cfg?.getDefaultOffset != null) {
41
- env.getDefaultOffset = cfg.getDefaultOffset;
42
- }
43
- return env;
44
- }
45
- /**
46
- * Uses {@link resolveBlazeoConnection} (config file + `configure` + optional overrides),
47
- * then `CalendarModel.create` and `calendar.create()` unless `localOnly`.
48
- */
49
- export async function createCalendarAsync(calendar, options = {}) {
50
- try {
51
- const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
52
- if (resolvedBase) {
53
- configure({
54
- baseUrl: resolvedBase,
55
- ...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
56
- });
57
- }
58
- const baseUrl = resolvedBase;
59
- const consumer = resolvedConsumer;
60
- if (!options.localOnly && !baseUrl) {
61
- return {
62
- ok: false,
63
- error: "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeo.config.ts` or call `configure({ baseUrl })`.",
64
- };
65
- }
66
- const snapshot = mapCalendarBOToSnapshot(calendar);
67
- const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
68
- if (!options.localOnly && env.baseUrl == null) {
69
- return {
70
- ok: false,
71
- error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
72
- };
73
- }
74
- const calendarNode = CalendarModel.create(snapshot, env);
75
- if (options.localOnly) {
76
- return { ok: true, calendar: calendarNode };
77
- }
78
- const apiRes = await calendarNode.create();
79
- if (isFailureStatus(apiRes)) {
80
- const msg = apiRes.message ??
81
- (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
82
- JSON.stringify(apiRes);
83
- return {
84
- ok: false,
85
- error: msg || "Calendar create failed",
86
- apiResponse: apiRes,
87
- };
88
- }
89
- return { ok: true, calendar: calendarNode, apiResponse: apiRes };
90
- }
91
- catch (err) {
92
- const message = err instanceof Error ? err.message : String(err);
93
- return { ok: false, error: message };
94
- }
95
- }
1
+ import { CalendarModel, configure, getConfig } from "@blazeo.com/calendar-client";
2
+ import { blazeoClientConfig } from "../config/blazeo.config.js";
3
+ import { mapCalendarBOToSnapshot } from "./mapCalendarBOToSnapshot.js";
4
+ function isFailureStatus(res) {
5
+ return res.status !== "success" && res.status !== "Success";
6
+ }
7
+ /** Merge per-call options with global Blazeo config (file + `configure`). */
8
+ export function resolveBlazeoConnection(options = {}) {
9
+ const cfg = getConfig();
10
+ const fromFileBase = blazeoClientConfig.baseUrl?.trim().replace(/\/+$/, "");
11
+ const fromFileConsumer = blazeoClientConfig.consumer?.trim();
12
+ const baseUrl = options.baseUrl?.trim().replace(/\/+$/, "") ||
13
+ cfg?.baseUrl?.replace(/\/+$/, "") ||
14
+ (fromFileBase || undefined);
15
+ const consumer = options.consumer?.trim() ||
16
+ cfg?.consumer ||
17
+ (fromFileConsumer || undefined);
18
+ return { baseUrl, consumer };
19
+ }
20
+ function buildModelEnv(baseUrl, consumer, forLocalOnly) {
21
+ if (forLocalOnly && !baseUrl) {
22
+ return {};
23
+ }
24
+ const cfg = getConfig();
25
+ const env = {};
26
+ if (baseUrl) {
27
+ env.baseUrl = baseUrl;
28
+ }
29
+ else if (cfg?.baseUrl) {
30
+ env.baseUrl = cfg.baseUrl;
31
+ }
32
+ if (consumer) {
33
+ env.consumer = consumer;
34
+ }
35
+ else if (cfg?.consumer) {
36
+ env.consumer = cfg.consumer;
37
+ }
38
+ if (cfg?.fetch != null)
39
+ env.fetch = cfg.fetch;
40
+ if (cfg?.getDefaultOffset != null) {
41
+ env.getDefaultOffset = cfg.getDefaultOffset;
42
+ }
43
+ return env;
44
+ }
45
+ /**
46
+ * Uses {@link resolveBlazeoConnection} (config file + `configure` + optional overrides),
47
+ * then `CalendarModel.create` and `calendar.create()` unless `localOnly`.
48
+ */
49
+ export async function createCalendarAsync(calendar, options = {}) {
50
+ try {
51
+ const { baseUrl: resolvedBase, consumer: resolvedConsumer } = resolveBlazeoConnection(options);
52
+ if (resolvedBase) {
53
+ configure({
54
+ baseUrl: resolvedBase,
55
+ ...(resolvedConsumer ? { consumer: resolvedConsumer } : {}),
56
+ });
57
+ }
58
+ const baseUrl = resolvedBase;
59
+ const consumer = resolvedConsumer;
60
+ if (!options.localOnly && !baseUrl) {
61
+ return {
62
+ ok: false,
63
+ error: "baseUrl is missing. Set `blazeoClientConfig.baseUrl` in `appointment-client/src/config/blazeo.config.ts` or call `configure({ baseUrl })`.",
64
+ };
65
+ }
66
+ const snapshot = mapCalendarBOToSnapshot(calendar);
67
+ const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
68
+ if (!options.localOnly && env.baseUrl == null) {
69
+ return {
70
+ ok: false,
71
+ error: "Model env requires baseUrl. Set `blazeoClientConfig` or pass `baseUrl` in options.",
72
+ };
73
+ }
74
+ const calendarNode = CalendarModel.create(snapshot, env);
75
+ if (options.localOnly) {
76
+ return { ok: true, calendar: calendarNode };
77
+ }
78
+ const apiRes = await calendarNode.create();
79
+ if (isFailureStatus(apiRes)) {
80
+ const msg = apiRes.message ??
81
+ (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
82
+ JSON.stringify(apiRes);
83
+ return {
84
+ ok: false,
85
+ error: msg || "Calendar create failed",
86
+ apiResponse: apiRes,
87
+ };
88
+ }
89
+ return { ok: true, calendar: calendarNode, apiResponse: apiRes };
90
+ }
91
+ catch (err) {
92
+ const message = err instanceof Error ? err.message : String(err);
93
+ return { ok: false, error: message };
94
+ }
95
+ }
96
96
  //# sourceMappingURL=calendarCreationFacade.js.map
@@ -1,10 +1,10 @@
1
- import type { CalendarBOInput } from "../types/calendarBo.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/calendarBo.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=mapCalendarBOToSnapshot.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=mapCalendarBOToSnapshot.js.map
@@ -1,12 +1,12 @@
1
- /**
2
- * Public facade surface for `appointment-client`.
3
- *
4
- * Call {@link initializeAppointmentClient} from `../config/initializeAppointmentClient.js`
5
- * before using these APIs in a host application.
6
- */
7
- export { createCalendarAsync, updateCalendarAsync, deleteCalendarAsync, resolveBlazeoConnection, type BlazeoCalendarCreateResponse, type CreateCalendarOptions, type CreateCalendarResult, } from "../calendar/createCalendar.js";
8
- export { CalendarCreationFacade, createCalendarWithRelationsAsync, updateCalendarWithRelationsAsync, resolveParticipantIdForOpeningHour, type CalendarWithRelationsResult, type CalendarWithRelationsSuccess, } from "../calendar/calendarCreationFacade.js";
9
- export { addParticipantToCalendar, removeParticipantFromCalendar, saveCalendarOpeningHour, saveCalendarOpeningHoursBatch, type BlazeoCalendarForRelations, type BlazeoCalendarRelationResponse, } from "../calendar/blazeoCalendarRelationMethods.js";
10
- export { createAppointmentEventAsync, rescheduleAppointmentEventAsync, cancelAppointmentEventAsync, type AppointmentEventOptions, type AppointmentEventResult, type AppointmentEventSuccess, type AppointmentEventFailure, type BlazeoEventApiResponse, } from "../events/appointmentEventFacade.js";
11
- export { mapAppointmentToEventSnapshot, type AppointmentEventMappingMode, } from "../events/mapAppointmentToEventSnapshot.js";
1
+ /**
2
+ * Public facade surface for `appointment-client`.
3
+ *
4
+ * Call {@link initializeAppointmentClient} from `../config/initializeAppointmentClient.js`
5
+ * before using these APIs in a host application.
6
+ */
7
+ export { createCalendarAsync, updateCalendarAsync, deleteCalendarAsync, resolveBlazeoConnection, type BlazeoCalendarCreateResponse, type CreateCalendarOptions, type CreateCalendarResult, } from "../calendar/createCalendar.js";
8
+ export { CalendarCreationFacade, createCalendarWithRelationsAsync, updateCalendarWithRelationsAsync, resolveParticipantIdForOpeningHour, type CalendarWithRelationsResult, type CalendarWithRelationsSuccess, } from "../calendar/calendarCreationFacade.js";
9
+ export { addParticipantToCalendar, removeParticipantFromCalendar, saveCalendarOpeningHour, saveCalendarOpeningHoursBatch, type BlazeoCalendarForRelations, type BlazeoCalendarRelationResponse, } from "../calendar/blazeoCalendarRelationMethods.js";
10
+ export { createAppointmentEventAsync, rescheduleAppointmentEventAsync, cancelAppointmentEventAsync, type AppointmentEventOptions, type AppointmentEventResult, type AppointmentEventSuccess, type AppointmentEventFailure, type BlazeoEventApiResponse, } from "../events/appointmentEventFacade.js";
11
+ export { mapAppointmentToEventSnapshot, type AppointmentEventMappingMode, } from "../events/mapAppointmentToEventSnapshot.js";
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,12 @@
1
- /**
2
- * Public facade surface for `appointment-client`.
3
- *
4
- * Call {@link initializeAppointmentClient} from `../config/initializeAppointmentClient.js`
5
- * before using these APIs in a host application.
6
- */
7
- export { createCalendarAsync, updateCalendarAsync, deleteCalendarAsync, resolveBlazeoConnection, } from "../calendar/createCalendar.js";
8
- export { CalendarCreationFacade, createCalendarWithRelationsAsync, updateCalendarWithRelationsAsync, resolveParticipantIdForOpeningHour, } from "../calendar/calendarCreationFacade.js";
9
- export { addParticipantToCalendar, removeParticipantFromCalendar, saveCalendarOpeningHour, saveCalendarOpeningHoursBatch, } from "../calendar/blazeoCalendarRelationMethods.js";
10
- export { createAppointmentEventAsync, rescheduleAppointmentEventAsync, cancelAppointmentEventAsync, } from "../events/appointmentEventFacade.js";
11
- export { mapAppointmentToEventSnapshot, } from "../events/mapAppointmentToEventSnapshot.js";
1
+ /**
2
+ * Public facade surface for `appointment-client`.
3
+ *
4
+ * Call {@link initializeAppointmentClient} from `../config/initializeAppointmentClient.js`
5
+ * before using these APIs in a host application.
6
+ */
7
+ export { createCalendarAsync, updateCalendarAsync, deleteCalendarAsync, resolveBlazeoConnection, } from "../calendar/createCalendar.js";
8
+ export { CalendarCreationFacade, createCalendarWithRelationsAsync, updateCalendarWithRelationsAsync, resolveParticipantIdForOpeningHour, } from "../calendar/calendarCreationFacade.js";
9
+ export { addParticipantToCalendar, removeParticipantFromCalendar, saveCalendarOpeningHour, saveCalendarOpeningHoursBatch, } from "../calendar/blazeoCalendarRelationMethods.js";
10
+ export { createAppointmentEventAsync, rescheduleAppointmentEventAsync, cancelAppointmentEventAsync, } from "../events/appointmentEventFacade.js";
11
+ export { mapAppointmentToEventSnapshot, } from "../events/mapAppointmentToEventSnapshot.js";
12
12
  //# sourceMappingURL=index.js.map