@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.
- package/blazeo.com-appointment-client-1.0.6.tgz +0 -0
- package/dist/calendar/blazeoCalendarRelationMethods.d.ts +4 -36
- package/dist/calendar/blazeoCalendarRelationMethods.js +0 -1
- package/dist/calendar/buildUnifiedCalendarView.d.ts +31 -0
- package/dist/calendar/buildUnifiedCalendarView.js +265 -0
- package/dist/calendar/calendarCreation.d.ts +27 -0
- package/dist/calendar/calendarCreation.js +167 -0
- package/dist/calendar/calendarCreationFacade.d.ts +4 -13
- package/dist/calendar/calendarCreationFacade.js +3 -5
- package/dist/calendar/createCalendar.d.ts +67 -37
- package/dist/calendar/createCalendar.js +1 -3
- package/dist/calendar/fetchCalendarDetails.d.ts +73 -18
- package/dist/calendar/fetchCalendarDetails.js +192 -51
- package/dist/calendar/fetchCalendarWithOpeningHours.d.ts +34 -21
- package/dist/calendar/fetchCalendarWithOpeningHours.js +95 -75
- package/dist/calendar/getAllParticipantOpeningHours.d.ts +19 -0
- package/dist/calendar/getAllParticipantOpeningHours.js +17 -0
- package/dist/calendar/getOpeningHours.d.ts +5 -0
- package/dist/calendar/getOpeningHours.js +9 -0
- package/dist/calendar/getParticipantOpeningHours.d.ts +37 -0
- package/dist/calendar/getParticipantOpeningHours.js +43 -0
- package/dist/calendar/getParticipants.d.ts +4 -0
- package/dist/calendar/getParticipants.js +8 -0
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.d.ts +9 -9
- package/dist/calendar/mapCalendarBoToBlazeoSnapshot.js +43 -43
- package/dist/calendar/mapCalendarToBlazeoSnapshot.d.ts +22 -3
- package/dist/calendar/mapCalendarToBlazeoSnapshot.js +0 -1
- package/dist/config/applyBlazeoClientConfig.d.ts +2 -2
- package/dist/config/applyBlazeoClientConfig.js +13 -13
- package/dist/config/applyBlazeoDefaults.d.ts +0 -1
- package/dist/config/applyBlazeoDefaults.js +0 -1
- package/dist/config/blazeo.config.d.ts +10 -10
- package/dist/config/blazeo.config.js +10 -10
- package/dist/config/blazeoClientDefaults.d.ts +1 -2
- package/dist/config/blazeoClientDefaults.js +0 -1
- package/dist/config/initializeAppointmentClient.d.ts +4 -28
- package/dist/config/initializeAppointmentClient.js +5 -24
- package/dist/events/appointmentEventFacade.d.ts +55 -32
- package/dist/events/appointmentEventFacade.js +5 -10
- package/dist/events/mapAppointmentToEventSnapshot.d.ts +1 -4
- package/dist/events/mapAppointmentToEventSnapshot.js +0 -1
- package/dist/exampleData.d.ts +114 -10
- package/dist/exampleData.js +4 -5
- package/dist/facade/calendarCreationFacade.d.ts +39 -39
- package/dist/facade/calendarCreationFacade.js +95 -95
- package/dist/facade/mapCalendarBOToSnapshot.d.ts +9 -9
- package/dist/facade/mapCalendarBOToSnapshot.js +43 -43
- package/dist/facades/index.d.ts +11 -11
- package/dist/facades/index.js +11 -11
- package/dist/index.d.ts +23 -82
- package/dist/index.js +21 -33
- package/dist/models/CalendarRootModel.d.ts +36 -11
- package/dist/models/CalendarRootModel.js +22 -5
- package/dist/models/CalendarSlotModel.d.ts +8 -8
- package/dist/models/CalendarSlotModel.js +7 -7
- package/dist/models/EventModel.d.ts +10 -10
- package/dist/models/EventModel.js +9 -9
- package/dist/models/ParticipantModel.d.ts +8 -8
- package/dist/models/ParticipantModel.js +7 -7
- package/dist/models/index.d.ts +4 -4
- package/dist/models/index.js +4 -4
- package/dist/types/appointment.d.ts +27 -27
- package/dist/types/appointment.js +5 -5
- package/dist/types/calendar.d.ts +51 -51
- package/dist/types/calendar.js +5 -5
- package/dist/types/calendarBo.d.ts +61 -61
- package/dist/types/calendarBo.js +5 -5
- package/package.json +8 -2
- package/sample/build_error.txt +0 -0
- package/sample/demo.js +70 -0
- package/sample/package-lock.json +5 -2
- package/sample/package.json +3 -1
- package/sample/scripts/getInfoByCalendar.mjs +36 -0
- package/sample/scripts/getParticipantOpeningHours.mjs +48 -0
- package/sample/src/AllParticipantOpeningHoursTab.jsx +73 -0
- package/sample/src/App2.jsx +39 -2
- package/sample/src/BlazeoConnectionSettings.jsx +1 -1
- package/sample/src/FetchCalendarTab.jsx +70 -20
- package/sample/src/OpeningHoursTab.jsx +78 -0
- package/sample/src/ParticipantInfoTab.jsx +72 -0
- package/sample/src/ParticipantOpeningHoursTab.jsx +88 -0
- package/sample/src/ParticipantTab.jsx +2 -2
- package/src/calendar/blazeoCalendarRelationMethods.ts +19 -0
- package/src/calendar/buildUnifiedCalendarView.ts +322 -0
- package/src/calendar/calendarCreation.ts +179 -0
- package/src/calendar/createCalendar.ts +243 -0
- package/src/calendar/fetchCalendarDetails.ts +226 -0
- package/src/calendar/fetchCalendarWithOpeningHours.ts +99 -0
- package/src/calendar/getAllParticipantOpeningHours.ts +22 -0
- package/src/calendar/getOpeningHours.ts +10 -0
- package/src/calendar/getParticipantOpeningHours.ts +46 -0
- package/src/calendar/getParticipants.ts +9 -0
- package/src/calendar/mapCalendarToBlazeoSnapshot.ts +46 -0
- package/src/config/applyBlazeoDefaults.ts +13 -0
- package/src/config/blazeoClientDefaults.ts +11 -0
- package/src/config/initializeAppointmentClient.ts +18 -0
- package/src/events/appointmentEventFacade.ts +148 -0
- package/src/events/mapAppointmentToEventSnapshot.ts +65 -0
- package/src/exampleData.ts +79 -0
- package/src/index.ts +45 -0
- package/src/models/CalendarRootModel.ts +60 -0
- package/tsconfig.json +16 -0
- package/blazeo.com-appointment-client-1.0.5.tgz +0 -0
|
@@ -1,28 +1,9 @@
|
|
|
1
1
|
import { configure, getConfig } from "@blazeo.com/calendar-client";
|
|
2
|
-
|
|
3
|
-
export function initializeAppointmentClient(
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
|
|
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:
|
|
5
|
+
export declare function createAppointmentEventAsync(input: any, options?: any): Promise<{
|
|
6
|
+
ok: boolean;
|
|
7
|
+
error: string;
|
|
8
|
+
event?: undefined;
|
|
9
|
+
apiResponse?: undefined;
|
|
10
|
+
} | {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
event: any;
|
|
13
|
+
error?: undefined;
|
|
14
|
+
apiResponse?: undefined;
|
|
15
|
+
} | {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
error: any;
|
|
18
|
+
apiResponse: any;
|
|
19
|
+
event?: undefined;
|
|
20
|
+
} | {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
event: any;
|
|
23
|
+
apiResponse: any;
|
|
24
|
+
error?: undefined;
|
|
25
|
+
}>;
|
|
34
26
|
/**
|
|
35
27
|
* Reschedules an appointment — `Event.reschedule()` → `POST /event/reschedule`
|
|
36
28
|
* (aligned with `AppointmentAPIAdapter.Reschedule`).
|
|
37
29
|
*/
|
|
38
|
-
export declare function rescheduleAppointmentEventAsync(input:
|
|
30
|
+
export declare function rescheduleAppointmentEventAsync(input: any, options?: any): Promise<{
|
|
31
|
+
ok: boolean;
|
|
32
|
+
error: string;
|
|
33
|
+
event?: undefined;
|
|
34
|
+
apiResponse?: undefined;
|
|
35
|
+
} | {
|
|
36
|
+
ok: boolean;
|
|
37
|
+
event: any;
|
|
38
|
+
error?: undefined;
|
|
39
|
+
apiResponse?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
ok: boolean;
|
|
42
|
+
error: any;
|
|
43
|
+
apiResponse: any;
|
|
44
|
+
event?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
ok: boolean;
|
|
47
|
+
event: any;
|
|
48
|
+
apiResponse: any;
|
|
49
|
+
error?: undefined;
|
|
50
|
+
}>;
|
|
39
51
|
/**
|
|
40
52
|
* Cancels an appointment — `EventModel.cancel` → `GET /event/cancel`
|
|
41
53
|
* (aligned with `AppointmentAPIAdapter.Cancel`).
|
|
42
54
|
*/
|
|
43
|
-
export declare function cancelAppointmentEventAsync(appointmentEventId: string, options?:
|
|
44
|
-
|
|
55
|
+
export declare function cancelAppointmentEventAsync(appointmentEventId: string, options?: any): Promise<{
|
|
56
|
+
ok: boolean;
|
|
57
|
+
error: string;
|
|
58
|
+
apiResponse?: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
ok: boolean;
|
|
61
|
+
error: any;
|
|
62
|
+
apiResponse: any;
|
|
63
|
+
} | {
|
|
64
|
+
ok: boolean;
|
|
65
|
+
apiResponse: any;
|
|
66
|
+
error?: undefined;
|
|
67
|
+
}>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventModel, configure } from "@blazeo.com/calendar-client";
|
|
2
|
-
import { buildModelEnv, resolveBlazeoConnection
|
|
3
|
-
import { mapAppointmentToEventSnapshot
|
|
2
|
+
import { buildModelEnv, resolveBlazeoConnection } from "../calendar/createCalendar.js";
|
|
3
|
+
import { mapAppointmentToEventSnapshot } from "./mapAppointmentToEventSnapshot.js";
|
|
4
4
|
function isFailureStatus(res) {
|
|
5
5
|
return res.status !== "success" && res.status !== "Success";
|
|
6
6
|
}
|
|
@@ -43,18 +43,14 @@ async function runEventMutation(input, mode, options) {
|
|
|
43
43
|
return { ok: true, event: eventNode };
|
|
44
44
|
}
|
|
45
45
|
const offset = options.offsetMinutes;
|
|
46
|
-
const apiRes = mode === "create"
|
|
47
|
-
? await eventNode.create(offset)
|
|
48
|
-
: await eventNode.reschedule(offset);
|
|
46
|
+
const apiRes = mode === "create" ? await eventNode.create(offset) : await eventNode.reschedule(offset);
|
|
49
47
|
if (isFailureStatus(apiRes)) {
|
|
50
48
|
const msg = apiRes.message ??
|
|
51
49
|
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
52
50
|
JSON.stringify(apiRes);
|
|
53
51
|
return {
|
|
54
52
|
ok: false,
|
|
55
|
-
error: mode === "create"
|
|
56
|
-
? msg || "Event create failed"
|
|
57
|
-
: msg || "Event reschedule failed",
|
|
53
|
+
error: mode === "create" ? msg || "Event create failed" : msg || "Event reschedule failed",
|
|
58
54
|
apiResponse: apiRes,
|
|
59
55
|
};
|
|
60
56
|
}
|
|
@@ -108,7 +104,7 @@ export async function cancelAppointmentEventAsync(appointmentEventId, options =
|
|
|
108
104
|
if (options.localOnly) {
|
|
109
105
|
return { ok: true, apiResponse: undefined };
|
|
110
106
|
}
|
|
111
|
-
const apiRes =
|
|
107
|
+
const apiRes = await EventModel.cancel(id);
|
|
112
108
|
if (isFailureStatus(apiRes)) {
|
|
113
109
|
const msg = apiRes.message ??
|
|
114
110
|
(typeof apiRes.data === "string" ? apiRes.data : undefined) ??
|
|
@@ -126,4 +122,3 @@ export async function cancelAppointmentEventAsync(appointmentEventId, options =
|
|
|
126
122
|
return { ok: false, error: message };
|
|
127
123
|
}
|
|
128
124
|
}
|
|
129
|
-
//# sourceMappingURL=appointmentEventFacade.js.map
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type { ApexAppointmentInput } from "../types/appointment.js";
|
|
2
|
-
export type AppointmentEventMappingMode = "create" | "reschedule";
|
|
3
1
|
/**
|
|
4
2
|
* Maps Apex appointment input to a Blazeo `Event` MST snapshot for
|
|
5
3
|
* {@link EventModel.create} from `@blazeo.com/calendar-client`.
|
|
6
4
|
*/
|
|
7
|
-
export declare function mapAppointmentToEventSnapshot(input:
|
|
8
|
-
//# sourceMappingURL=mapAppointmentToEventSnapshot.d.ts.map
|
|
5
|
+
export declare function mapAppointmentToEventSnapshot(input: any, mode: "create" | "reschedule"): any;
|
package/dist/exampleData.d.ts
CHANGED
|
@@ -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():
|
|
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():
|
|
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():
|
|
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():
|
|
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():
|
|
15
|
-
|
|
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>>;
|
package/dist/exampleData.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CalendarSlotModel } from "./models/
|
|
2
|
-
import { CalendarRootModel
|
|
3
|
-
import { EventModel } from "./models/
|
|
4
|
-
import { ParticipantModel
|
|
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
|