@blazeo.com/calendar-client 1.0.55 → 1.0.56

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/dist/index.js CHANGED
@@ -585,7 +585,7 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
585
585
  };
586
586
  return reqPost("/event/update", payload);
587
587
  },
588
- /** POST /event/reschedule – reschedule event */
588
+ /** POST /event/reschedule – reschedule event and mark status ReScheduled */
589
589
  async reschedule(offsetMinutes) {
590
590
  const offset = offsetMinutes ?? getOffset();
591
591
  const payload = {
@@ -609,7 +609,12 @@ var EventModel = import_mobx_state_tree4.types.model("Event", {
609
609
  flowPath: self.flowPath ?? void 0
610
610
  };
611
611
  const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
612
- if (res.status === "success" && res.data) (0, import_mobx_state_tree4.applySnapshot)(self, { ...res.data, eventId: self.eventId });
612
+ if (res.status !== "success") return res;
613
+ if (res.data) {
614
+ (0, import_mobx_state_tree4.applySnapshot)(self, { ...mapEventFromApi(res.data), eventId: self.eventId });
615
+ } else if (self.status !== EventStatus.ReScheduled) {
616
+ await self.setEventStatus(EventStatus.ReScheduled);
617
+ }
613
618
  return res;
614
619
  },
615
620
  /** GET /event/cancel – cancel this event */
@@ -903,9 +908,17 @@ EventModel.reschedule = async (payload, offsetMinutes) => {
903
908
  const { reqPost } = createRequestHelpersFromEnv(getConfig());
904
909
  const offset = offsetMinutes ?? getDefaultOffset();
905
910
  const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
906
- if (res.status === "success" && res.data) {
911
+ if (res.status !== "success") return null;
912
+ const eventId = String((payload == null ? void 0 : payload.eventId) ?? (payload == null ? void 0 : payload.EventId) ?? (payload == null ? void 0 : payload.event_id) ?? "");
913
+ if (res.data) {
907
914
  return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
908
915
  }
916
+ if (eventId) {
917
+ const statusRes = await EventModel.setEventStatus(eventId, EventStatus.ReScheduled);
918
+ if (statusRes.status === "success" && statusRes.data) {
919
+ return EventModel.create(mapEventFromApi(statusRes.data), { env: getConfig() });
920
+ }
921
+ }
909
922
  return null;
910
923
  };
911
924
  EventModel.updateEvent = async (payload) => {
package/dist/index.mjs CHANGED
@@ -510,7 +510,7 @@ var EventModel = types4.model("Event", {
510
510
  };
511
511
  return reqPost("/event/update", payload);
512
512
  },
513
- /** POST /event/reschedule – reschedule event */
513
+ /** POST /event/reschedule – reschedule event and mark status ReScheduled */
514
514
  async reschedule(offsetMinutes) {
515
515
  const offset = offsetMinutes ?? getOffset();
516
516
  const payload = {
@@ -534,7 +534,12 @@ var EventModel = types4.model("Event", {
534
534
  flowPath: self.flowPath ?? void 0
535
535
  };
536
536
  const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
537
- if (res.status === "success" && res.data) applySnapshot(self, { ...res.data, eventId: self.eventId });
537
+ if (res.status !== "success") return res;
538
+ if (res.data) {
539
+ applySnapshot(self, { ...mapEventFromApi(res.data), eventId: self.eventId });
540
+ } else if (self.status !== EventStatus.ReScheduled) {
541
+ await self.setEventStatus(EventStatus.ReScheduled);
542
+ }
538
543
  return res;
539
544
  },
540
545
  /** GET /event/cancel – cancel this event */
@@ -828,9 +833,17 @@ EventModel.reschedule = async (payload, offsetMinutes) => {
828
833
  const { reqPost } = createRequestHelpersFromEnv(getConfig());
829
834
  const offset = offsetMinutes ?? getDefaultOffset();
830
835
  const res = await reqPost("/event/reschedule", payload, null, { headers: { offset: String(offset) } });
831
- if (res.status === "success" && res.data) {
836
+ if (res.status !== "success") return null;
837
+ const eventId = String((payload == null ? void 0 : payload.eventId) ?? (payload == null ? void 0 : payload.EventId) ?? (payload == null ? void 0 : payload.event_id) ?? "");
838
+ if (res.data) {
832
839
  return EventModel.create(mapEventFromApi(res.data), { env: getConfig() });
833
840
  }
841
+ if (eventId) {
842
+ const statusRes = await EventModel.setEventStatus(eventId, EventStatus.ReScheduled);
843
+ if (statusRes.status === "success" && statusRes.data) {
844
+ return EventModel.create(mapEventFromApi(statusRes.data), { env: getConfig() });
845
+ }
846
+ }
834
847
  return null;
835
848
  };
836
849
  EventModel.updateEvent = async (payload) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.55",
3
+ "version": "1.0.56",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {