@blazeo.com/appointment-client 1.0.15 → 1.0.16

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 (28) hide show
  1. package/{blazeo.com-appointment-client-1.0.15.tgz → blazeo.com-appointment-client-1.0.16.tgz} +0 -0
  2. package/dist/events/appointmentEventFacade.d.ts +10 -0
  3. package/dist/events/appointmentEventFacade.js +23 -9
  4. package/dist/events/mapAppointmentToEventSnapshot.js +7 -6
  5. package/package.json +2 -2
  6. package/sample/dist/assets/index-DbrpHcLW.js +75 -0
  7. package/sample/dist/index.html +1 -1
  8. package/sample/node_modules/.vite/deps/_metadata.json +19 -10
  9. package/sample/node_modules/.vite/deps/{chunk-7GCC5JQS.js → chunk-GVXAV465.js} +4 -6
  10. package/sample/node_modules/.vite/deps/{chunk-7GCC5JQS.js.map → chunk-GVXAV465.js.map} +1 -1
  11. package/sample/node_modules/.vite/deps/chunk-VUNV25KB.js +15 -0
  12. package/sample/node_modules/.vite/deps/chunk-VUNV25KB.js.map +7 -0
  13. package/sample/node_modules/.vite/deps/{chunk-7B4CXO3W.js → chunk-VWHX5Q3K.js} +5 -3
  14. package/sample/node_modules/.vite/deps/{chunk-7B4CXO3W.js.map → chunk-VWHX5Q3K.js.map} +1 -1
  15. package/sample/node_modules/.vite/deps/moment.js +4081 -0
  16. package/sample/node_modules/.vite/deps/moment.js.map +7 -0
  17. package/sample/node_modules/.vite/deps/react-dom.js +3 -2
  18. package/sample/node_modules/.vite/deps/react-dom_client.js +5 -3
  19. package/sample/node_modules/.vite/deps/react-dom_client.js.map +1 -1
  20. package/sample/node_modules/.vite/deps/react.js +2 -1
  21. package/sample/node_modules/.vite/deps/react_jsx-dev-runtime.js +4 -2
  22. package/sample/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +1 -1
  23. package/sample/node_modules/.vite/deps/react_jsx-runtime.js +4 -2
  24. package/sample/node_modules/.vite/deps/react_jsx-runtime.js.map +1 -1
  25. package/sample/src/EventTab.jsx +5 -4
  26. package/src/events/appointmentEventFacade.ts +30 -13
  27. package/src/events/mapAppointmentToEventSnapshot.ts +8 -6
  28. package/sample/dist/assets/index-Ba0v1gMx.js +0 -76
@@ -12,6 +12,11 @@ export declare function createAppointmentEventAsync(input: any, options?: any):
12
12
  event: any;
13
13
  error?: undefined;
14
14
  apiResponse?: undefined;
15
+ } | {
16
+ ok: boolean;
17
+ apiResponse: any;
18
+ error?: undefined;
19
+ event?: undefined;
15
20
  } | {
16
21
  ok: boolean;
17
22
  error: any;
@@ -37,6 +42,11 @@ export declare function rescheduleAppointmentEventAsync(input: any, options?: an
37
42
  event: any;
38
43
  error?: undefined;
39
44
  apiResponse?: undefined;
45
+ } | {
46
+ ok: boolean;
47
+ apiResponse: any;
48
+ error?: undefined;
49
+ event?: undefined;
40
50
  } | {
41
51
  ok: boolean;
42
52
  error: any;
@@ -24,11 +24,30 @@ async function runEventMutation(input, mode, options) {
24
24
  };
25
25
  }
26
26
  const snapshot = mapAppointmentToEventSnapshot(input, mode);
27
+ const offset = options.offsetMinutes;
28
+ if (mode === "create") {
29
+ if (options.localOnly) {
30
+ const env = buildModelEnv(baseUrl, consumer, true);
31
+ const eventNode = EventModel.create({ ...snapshot, eventId: "new" }, env);
32
+ return { ok: true, event: eventNode };
33
+ }
34
+ const apiRes = await EventModel.createEvent(snapshot, offset);
35
+ if (apiRes?.eventId) {
36
+ return { ok: true, apiResponse: apiRes };
37
+ }
38
+ if (isFailureStatus(apiRes)) {
39
+ const msg = apiRes.message ??
40
+ (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
41
+ JSON.stringify(apiRes);
42
+ return { ok: false, error: msg || "Event create failed", apiResponse: apiRes };
43
+ }
44
+ return { ok: true, apiResponse: apiRes };
45
+ }
27
46
  const eventIdForApi = snapshot.eventId;
28
- if (mode === "reschedule" && (!eventIdForApi || eventIdForApi === "new")) {
47
+ if (!eventIdForApi || eventIdForApi === "new") {
29
48
  return {
30
49
  ok: false,
31
- error: "thirdPartyAppointmentId is required for reschedule (existing Blazeo event id).",
50
+ error: "eventId is required for reschedule (existing Blazeo event id).",
32
51
  };
33
52
  }
34
53
  const env = buildModelEnv(baseUrl, consumer, Boolean(options.localOnly));
@@ -42,17 +61,12 @@ async function runEventMutation(input, mode, options) {
42
61
  if (options.localOnly) {
43
62
  return { ok: true, event: eventNode };
44
63
  }
45
- const offset = options.offsetMinutes;
46
- const apiRes = mode === "create" ? await eventNode.create(offset) : await eventNode.reschedule(offset);
64
+ const apiRes = await eventNode.reschedule(offset);
47
65
  if (isFailureStatus(apiRes)) {
48
66
  const msg = apiRes.message ??
49
67
  (typeof apiRes.data === "string" ? apiRes.data : undefined) ??
50
68
  JSON.stringify(apiRes);
51
- return {
52
- ok: false,
53
- error: mode === "create" ? msg || "Event create failed" : msg || "Event reschedule failed",
54
- apiResponse: apiRes,
55
- };
69
+ return { ok: false, error: msg || "Event reschedule failed", apiResponse: apiRes };
56
70
  }
57
71
  return { ok: true, event: eventNode, apiResponse: apiRes };
58
72
  }
@@ -11,7 +11,7 @@ function formatYmd(d) {
11
11
  const day = String(d.getDate()).padStart(2, "0");
12
12
  return `${y}-${m}-${day}`;
13
13
  }
14
- function normalizeParticipantId(id) {
14
+ function normalizeGuid(id) {
15
15
  return id.trim().replace(/^\{|\}$/g, "");
16
16
  }
17
17
  /**
@@ -24,15 +24,12 @@ export function mapAppointmentToEventSnapshot(input, mode) {
24
24
  const description = mode === "create"
25
25
  ? (input.description ?? null)
26
26
  : (input.description ?? input.notes ?? null);
27
- const eventIdRaw = input.thirdPartyAppointmentId?.trim();
28
- const eventId = eventIdRaw && eventIdRaw !== "new" ? eventIdRaw : "new";
29
27
  const email = input.email ?? input.visitorEmail ?? null;
30
28
  const phone = input.phone ?? input.visitorPhone ?? null;
31
29
  const visitorName = input.visitorName?.trim() || null;
32
30
  const snap = {
33
- eventId,
34
- calendarId: input.thirdPartyCalendarId?.trim() ?? "",
35
- participantId: normalizeParticipantId(input.participantId),
31
+ calendarId: normalizeGuid(input.calendarId ?? ""),
32
+ participantId: normalizeGuid(input.participantId),
36
33
  title: input.title ?? null,
37
34
  description,
38
35
  startDate: formatYmd(start),
@@ -53,5 +50,9 @@ export function mapAppointmentToEventSnapshot(input, mode) {
53
50
  snap.createdOn = now;
54
51
  snap.modifiedOn = now;
55
52
  }
53
+ if (mode === "reschedule") {
54
+ const eventIdRaw = input.eventId?.trim();
55
+ snap.eventId = eventIdRaw || undefined;
56
+ }
56
57
  return snap;
57
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/appointment-client",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -18,7 +18,7 @@
18
18
  "build": "tsc"
19
19
  },
20
20
  "dependencies": {
21
- "@blazeo.com/calendar-client": "^1.0.18",
21
+ "@blazeo.com/calendar-client": "^1.0.20",
22
22
  "mobx": "^6.13.7",
23
23
  "mobx-state-tree": "^7.0.2",
24
24
  "moment": "^2.30.1"