@openinc/parse-server-opendash 4.41.0 → 5.0.0

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 (194) hide show
  1. package/dist/features/config/helper/customOptions.js +1 -1
  2. package/dist/features/config/types/ConfigKeys.d.ts +0 -3
  3. package/dist/features/config/types/ConfigKeys.js +3 -23
  4. package/dist/features/openservice/index.d.ts +6 -27
  5. package/dist/features/openservice/index.js +7 -44
  6. package/dist/features/openservice/init.d.ts +5 -13
  7. package/dist/features/openservice/init.js +17 -46
  8. package/dist/features/openservice/serviceSchedules/calendarSync/Access.d.ts +9 -0
  9. package/dist/features/openservice/serviceSchedules/calendarSync/CalendarManager.d.ts +71 -0
  10. package/dist/features/openservice/serviceSchedules/calendarSync/CalendarManager.js +300 -0
  11. package/dist/features/openservice/{schedules → serviceSchedules}/calendarSync/Event.d.ts +0 -4
  12. package/dist/features/openservice/{types/Material.js → serviceSchedules/calendarSync/Event.js} +3 -0
  13. package/dist/features/openservice/serviceSchedules/calendarSync/ServiceCalendarSyncPoller.d.ts +37 -53
  14. package/dist/features/openservice/serviceSchedules/calendarSync/ServiceCalendarSyncPoller.js +284 -187
  15. package/dist/features/openservice/serviceSchedules/calendarSync/ServiceSyncTypes.d.ts +17 -15
  16. package/dist/features/openservice/serviceSchedules/calendarSync/ServiceSyncTypes.js +4 -5
  17. package/dist/features/openservice/serviceSchedules/calendarSync/eventToPlan.d.ts +1 -1
  18. package/dist/features/openservice/serviceSchedules/calendarSync/inboundChanges.d.ts +65 -0
  19. package/dist/features/openservice/serviceSchedules/calendarSync/inboundChanges.js +101 -0
  20. package/dist/features/openservice/serviceSchedules/calendarSync/index.d.ts +2 -2
  21. package/dist/features/openservice/serviceSchedules/calendarSync/index.js +3 -1
  22. package/dist/features/openservice/serviceSchedules/calendarSync/outlookRecurrence.d.ts +1 -1
  23. package/dist/features/openservice/serviceSchedules/calendarSync/planLock.d.ts +11 -0
  24. package/dist/features/openservice/serviceSchedules/calendarSync/planLock.js +48 -0
  25. package/dist/features/openservice/serviceSchedules/calendarSync/planToEvent.d.ts +1 -1
  26. package/dist/features/openservice/serviceSchedules/calendarSync/serviceCalendarMeta.d.ts +11 -32
  27. package/dist/features/openservice/serviceSchedules/calendarSync/serviceCalendarMeta.js +20 -22
  28. package/dist/features/openservice/serviceSchedules/calendarSync/syncPlanExceptions.d.ts +4 -5
  29. package/dist/features/openservice/serviceSchedules/calendarSync/syncPlanExceptions.js +2 -3
  30. package/dist/features/openservice/serviceSchedules/calendarSync/syncPlanToCalendar.d.ts +10 -1
  31. package/dist/features/openservice/serviceSchedules/calendarSync/syncPlanToCalendar.js +25 -2
  32. package/dist/features/openservice/serviceSchedules/initServiceSchedulesFeature.d.ts +6 -4
  33. package/dist/features/openservice/serviceSchedules/initServiceSchedulesFeature.js +24 -11
  34. package/dist/features/openware/index.d.ts +0 -1
  35. package/dist/features/permissions/types/Permissions.d.ts +0 -14
  36. package/dist/features/permissions/types/Permissions.js +0 -18
  37. package/dist/features/translations/services/initTranslation.js +1 -1
  38. package/dist/hooks/Config_open_service.js +0 -60
  39. package/dist/hooks/Meta_Entry.js +3 -6
  40. package/dist/hooks/Service_Schedule.js +14 -7
  41. package/dist/index.js +2 -7
  42. package/dist/scripts/migration/passes/18-calendar-links.js +6 -2
  43. package/package.json +3 -4
  44. package/pnpm-workspace.yaml +7 -0
  45. package/dist/features/openservice/functions/assignUsersAndRoles.d.ts +0 -13
  46. package/dist/features/openservice/functions/assignUsersAndRoles.js +0 -212
  47. package/dist/features/openservice/functions/getSourceMetaMap.d.ts +0 -13
  48. package/dist/features/openservice/functions/getSourceMetaMap.js +0 -52
  49. package/dist/features/openservice/functions/getTicketObject.d.ts +0 -9
  50. package/dist/features/openservice/functions/getTicketObject.js +0 -31
  51. package/dist/features/openservice/functions/saveDescription.d.ts +0 -9
  52. package/dist/features/openservice/functions/saveDescription.js +0 -12
  53. package/dist/features/openservice/functions/saveDowntime.d.ts +0 -8
  54. package/dist/features/openservice/functions/saveDowntime.js +0 -32
  55. package/dist/features/openservice/functions/saveDuedate.d.ts +0 -13
  56. package/dist/features/openservice/functions/saveDuedate.js +0 -39
  57. package/dist/features/openservice/functions/saveFrequency.d.ts +0 -8
  58. package/dist/features/openservice/functions/saveFrequency.js +0 -32
  59. package/dist/features/openservice/functions/saveIssuecategory.d.ts +0 -14
  60. package/dist/features/openservice/functions/saveIssuecategory.js +0 -53
  61. package/dist/features/openservice/functions/saveMaterial.d.ts +0 -9
  62. package/dist/features/openservice/functions/saveMaterial.js +0 -18
  63. package/dist/features/openservice/functions/saveMessage.d.ts +0 -10
  64. package/dist/features/openservice/functions/saveMessage.js +0 -54
  65. package/dist/features/openservice/functions/savePriority.d.ts +0 -8
  66. package/dist/features/openservice/functions/savePriority.js +0 -32
  67. package/dist/features/openservice/functions/saveProject.d.ts +0 -8
  68. package/dist/features/openservice/functions/saveProject.js +0 -98
  69. package/dist/features/openservice/functions/saveRestriction.d.ts +0 -8
  70. package/dist/features/openservice/functions/saveRestriction.js +0 -32
  71. package/dist/features/openservice/functions/saveSource.d.ts +0 -8
  72. package/dist/features/openservice/functions/saveSource.js +0 -32
  73. package/dist/features/openservice/functions/saveState.d.ts +0 -14
  74. package/dist/features/openservice/functions/saveState.js +0 -52
  75. package/dist/features/openservice/functions/saveTicketMeta.d.ts +0 -9
  76. package/dist/features/openservice/functions/saveTicketMeta.js +0 -32
  77. package/dist/features/openservice/functions/saveTicketTitle.d.ts +0 -8
  78. package/dist/features/openservice/functions/saveTicketTitle.js +0 -28
  79. package/dist/features/openservice/issuecategory/initIssuecategory.d.ts +0 -5
  80. package/dist/features/openservice/issuecategory/initIssuecategory.js +0 -42
  81. package/dist/features/openservice/kanbanState/initKanbanStates.d.ts +0 -21
  82. package/dist/features/openservice/kanbanState/initKanbanStates.js +0 -187
  83. package/dist/features/openservice/messages/initMessages.d.ts +0 -8
  84. package/dist/features/openservice/messages/initMessages.js +0 -466
  85. package/dist/features/openservice/messages/removeLatestMessage.d.ts +0 -9
  86. package/dist/features/openservice/messages/removeLatestMessage.js +0 -30
  87. package/dist/features/openservice/schedules/calendarSync/Access.d.ts +0 -12
  88. package/dist/features/openservice/schedules/calendarSync/CalendarManager.d.ts +0 -49
  89. package/dist/features/openservice/schedules/calendarSync/CalendarManager.js +0 -211
  90. package/dist/features/openservice/schedules/calendarSync/CalendarSyncPoller.d.ts +0 -25
  91. package/dist/features/openservice/schedules/calendarSync/CalendarSyncPoller.js +0 -202
  92. package/dist/features/openservice/schedules/calendarSync/ConfigValues.d.ts +0 -13
  93. package/dist/features/openservice/schedules/calendarSync/ConfigValues.js +0 -2
  94. package/dist/features/openservice/schedules/calendarSync/Event.js +0 -9
  95. package/dist/features/openservice/schedules/calendarSync/calendarMetaHelper.d.ts +0 -76
  96. package/dist/features/openservice/schedules/calendarSync/calendarMetaHelper.js +0 -119
  97. package/dist/features/openservice/schedules/calendarSync/eventToSchedule.d.ts +0 -37
  98. package/dist/features/openservice/schedules/calendarSync/eventToSchedule.js +0 -103
  99. package/dist/features/openservice/schedules/calendarSync/scheduleToEvent.d.ts +0 -9
  100. package/dist/features/openservice/schedules/calendarSync/scheduleToEvent.js +0 -122
  101. package/dist/features/openservice/schedules/checkStatus.d.ts +0 -9
  102. package/dist/features/openservice/schedules/checkStatus.js +0 -31
  103. package/dist/features/openservice/schedules/getScheduleLink.d.ts +0 -10
  104. package/dist/features/openservice/schedules/getScheduleLink.js +0 -32
  105. package/dist/features/openservice/schedules/initSchedulesFeature.d.ts +0 -5
  106. package/dist/features/openservice/schedules/initSchedulesFeature.js +0 -32
  107. package/dist/features/openservice/schedules/reassignScheduleExecutions.d.ts +0 -5
  108. package/dist/features/openservice/schedules/reassignScheduleExecutions.js +0 -39
  109. package/dist/features/openservice/ticket/getTicketLink.d.ts +0 -9
  110. package/dist/features/openservice/ticket/getTicketLink.js +0 -32
  111. package/dist/features/openservice/ticket/initTicket.d.ts +0 -4
  112. package/dist/features/openservice/ticket/initTicket.js +0 -56
  113. package/dist/features/openservice/types/FetchOptions.d.ts +0 -4
  114. package/dist/features/openservice/types/FetchOptions.js +0 -2
  115. package/dist/features/openservice/types/Material.d.ts +0 -10
  116. package/dist/features/openservice/types/OpenserviceTranslationKeys.d.ts +0 -102
  117. package/dist/features/openservice/types/OpenserviceTranslationKeys.js +0 -106
  118. package/dist/features/openservice/types/SaveValues.d.ts +0 -33
  119. package/dist/features/openservice/types/SaveValues.js +0 -2
  120. package/dist/features/openservice/types/TicketData.d.ts +0 -22
  121. package/dist/features/openservice/types/TicketData.js +0 -2
  122. package/dist/features/openware/types/OpenWareTicketObject.d.ts +0 -14
  123. package/dist/features/openware/types/OpenWareTicketObject.js +0 -2
  124. package/dist/functions/openinc-openservice-get-sourcemeta-map.d.ts +0 -1
  125. package/dist/functions/openinc-openservice-get-sourcemeta-map.js +0 -41
  126. package/dist/functions/openinc-openservice-save-ticket-data.d.ts +0 -6
  127. package/dist/functions/openinc-openservice-save-ticket-data.js +0 -517
  128. package/dist/functions/openinc-openservice-ticket-data.d.ts +0 -44
  129. package/dist/functions/openinc-openservice-ticket-data.js +0 -380
  130. package/dist/helper/removeShorltyPreviousEntry.d.ts +0 -2
  131. package/dist/helper/removeShorltyPreviousEntry.js +0 -31
  132. package/dist/hooks/Maintenance_Downtime.d.ts +0 -1
  133. package/dist/hooks/Maintenance_Downtime.js +0 -106
  134. package/dist/hooks/Maintenance_Duedate.d.ts +0 -1
  135. package/dist/hooks/Maintenance_Duedate.js +0 -128
  136. package/dist/hooks/Maintenance_Frequency.d.ts +0 -1
  137. package/dist/hooks/Maintenance_Frequency.js +0 -106
  138. package/dist/hooks/Maintenance_Issuecategory.d.ts +0 -1
  139. package/dist/hooks/Maintenance_Issuecategory.js +0 -19
  140. package/dist/hooks/Maintenance_Item.d.ts +0 -1
  141. package/dist/hooks/Maintenance_Item.js +0 -17
  142. package/dist/hooks/Maintenance_Kanban_State.d.ts +0 -1
  143. package/dist/hooks/Maintenance_Kanban_State.js +0 -17
  144. package/dist/hooks/Maintenance_Media.d.ts +0 -1
  145. package/dist/hooks/Maintenance_Media.js +0 -17
  146. package/dist/hooks/Maintenance_Message.d.ts +0 -1
  147. package/dist/hooks/Maintenance_Message.js +0 -20
  148. package/dist/hooks/Maintenance_Order.d.ts +0 -1
  149. package/dist/hooks/Maintenance_Order.js +0 -17
  150. package/dist/hooks/Maintenance_Priority.d.ts +0 -1
  151. package/dist/hooks/Maintenance_Priority.js +0 -110
  152. package/dist/hooks/Maintenance_Project.d.ts +0 -1
  153. package/dist/hooks/Maintenance_Project.js +0 -30
  154. package/dist/hooks/Maintenance_Restriction.d.ts +0 -1
  155. package/dist/hooks/Maintenance_Restriction.js +0 -113
  156. package/dist/hooks/Maintenance_Schedule.d.ts +0 -1
  157. package/dist/hooks/Maintenance_Schedule.js +0 -146
  158. package/dist/hooks/Maintenance_Schedule_Execution.d.ts +0 -1
  159. package/dist/hooks/Maintenance_Schedule_Execution.js +0 -118
  160. package/dist/hooks/Maintenance_Schedule_Execution_Step.d.ts +0 -1
  161. package/dist/hooks/Maintenance_Schedule_Execution_Step.js +0 -17
  162. package/dist/hooks/Maintenance_Schedule_Step.d.ts +0 -1
  163. package/dist/hooks/Maintenance_Schedule_Step.js +0 -26
  164. package/dist/hooks/Maintenance_Schedule_Template.d.ts +0 -1
  165. package/dist/hooks/Maintenance_Schedule_Template.js +0 -92
  166. package/dist/hooks/Maintenance_Source_File.d.ts +0 -1
  167. package/dist/hooks/Maintenance_Source_File.js +0 -17
  168. package/dist/hooks/Maintenance_Ticket.d.ts +0 -1
  169. package/dist/hooks/Maintenance_Ticket.js +0 -15
  170. package/dist/hooks/Maintenance_Ticket_Assignment.d.ts +0 -1
  171. package/dist/hooks/Maintenance_Ticket_Assignment.js +0 -17
  172. package/dist/hooks/Maintenance_Ticket_FormConfig.d.ts +0 -1
  173. package/dist/hooks/Maintenance_Ticket_FormConfig.js +0 -17
  174. package/dist/hooks/Maintenance_Ticket_Issuecategory.d.ts +0 -1
  175. package/dist/hooks/Maintenance_Ticket_Issuecategory.js +0 -109
  176. package/dist/hooks/Maintenance_Ticket_Kanban_State.d.ts +0 -1
  177. package/dist/hooks/Maintenance_Ticket_Kanban_State.js +0 -134
  178. package/dist/hooks/Maintenance_Ticket_Kanban_State_Current.d.ts +0 -1
  179. package/dist/hooks/Maintenance_Ticket_Kanban_State_Current.js +0 -15
  180. package/dist/hooks/Maintenance_Ticket_Material.d.ts +0 -4
  181. package/dist/hooks/Maintenance_Ticket_Material.js +0 -104
  182. package/dist/hooks/Maintenance_Ticket_Project.d.ts +0 -1
  183. package/dist/hooks/Maintenance_Ticket_Project.js +0 -88
  184. package/dist/hooks/Maintenance_Ticket_QR_Code.d.ts +0 -1
  185. package/dist/hooks/Maintenance_Ticket_QR_Code.js +0 -17
  186. package/dist/hooks/Maintenance_Ticket_Source.d.ts +0 -1
  187. package/dist/hooks/Maintenance_Ticket_Source.js +0 -124
  188. package/dist/hooks/Maintenance_Ticket_Title.d.ts +0 -1
  189. package/dist/hooks/Maintenance_Ticket_Title.js +0 -107
  190. package/dist/i18n/de-DE/maintenance.json +0 -16
  191. package/dist/i18n/en-US/maintenance.json +0 -16
  192. package/dist/scripts/seed-v1-testdata.d.ts +0 -43
  193. package/dist/scripts/seed-v1-testdata.js +0 -982
  194. /package/dist/features/openservice/{schedules → serviceSchedules}/calendarSync/Access.js +0 -0
@@ -1,37 +0,0 @@
1
- import { GraphEventResponse } from "./Event.js";
2
- /**
3
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
4
- * `serviceSchedules/calendarSync/`. The Graph client itself
5
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
6
- */
7
- export type ScheduleCronTimestamp = {
8
- startDate: Date;
9
- endDate?: Date;
10
- number: number;
11
- unit: "days" | "weeks" | "months";
12
- };
13
- /**
14
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
15
- * `serviceSchedules/calendarSync/`. The Graph client itself
16
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
17
- */
18
- export type NotifyBeforeDue = {
19
- value: number;
20
- unit: "minutes" | "hours" | "days" | "weeks";
21
- };
22
- /**
23
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
24
- * `serviceSchedules/calendarSync/`. The Graph client itself
25
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
26
- */
27
- export type EventToScheduleResult = {
28
- schedule_type: "timestamp";
29
- timestamp: ScheduleCronTimestamp;
30
- notifyBeforeDue?: NotifyBeforeDue;
31
- };
32
- /**
33
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
34
- * `serviceSchedules/calendarSync/`. The Graph client itself
35
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
36
- */
37
- export declare function eventToSchedule(event: GraphEventResponse): EventToScheduleResult | undefined;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.eventToSchedule = eventToSchedule;
7
- const dayjs_1 = __importDefault(require("dayjs"));
8
- // Parses only the date portion of an Outlook dateTime string to avoid
9
- // timezone misinterpretation (Outlook dateTime is local to the event's
10
- // timezone, not UTC).
11
- function parseDateOnly(dateTime) {
12
- return (0, dayjs_1.default)(dateTime.slice(0, 10));
13
- }
14
- function minutesToNotifyBeforeDue(minutes) {
15
- if (minutes % (60 * 24 * 7) === 0)
16
- return { value: minutes / (60 * 24 * 7), unit: "weeks" };
17
- if (minutes % (60 * 24) === 0)
18
- return { value: minutes / (60 * 24), unit: "days" };
19
- if (minutes % 60 === 0)
20
- return { value: minutes / 60, unit: "hours" };
21
- return { value: minutes, unit: "minutes" };
22
- }
23
- /**
24
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
25
- * `serviceSchedules/calendarSync/`. The Graph client itself
26
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
27
- */
28
- function eventToSchedule(event) {
29
- const notifyBeforeDue = event.isReminderOn && typeof event.reminderMinutesBeforeStart === "number"
30
- ? minutesToNotifyBeforeDue(event.reminderMinutesBeforeStart)
31
- : undefined;
32
- const recurrence = event?.recurrence;
33
- // Single (non-recurring) event: treat as one-day schedule regardless of
34
- // the event's time or duration — our schedules are always all-day.
35
- if (!recurrence) {
36
- if (!event.start?.dateTime)
37
- return undefined;
38
- const date = parseDateOnly(event.start.dateTime).toDate();
39
- return {
40
- schedule_type: "timestamp",
41
- timestamp: {
42
- startDate: date,
43
- endDate: date,
44
- number: 1,
45
- unit: "days",
46
- },
47
- notifyBeforeDue,
48
- };
49
- }
50
- const pattern = recurrence.pattern;
51
- const range = recurrence.range;
52
- if (!pattern || !range || !pattern.type)
53
- return undefined;
54
- let unit;
55
- switch (pattern.type) {
56
- case "daily":
57
- unit = "days";
58
- break;
59
- case "weekly":
60
- unit = "weeks";
61
- break;
62
- case "absoluteMonthly":
63
- case "relativeMonthly":
64
- unit = "months";
65
- break;
66
- case "absoluteYearly":
67
- case "relativeYearly":
68
- // Map yearly recurrence to a 12-month interval
69
- unit = "months";
70
- break;
71
- default:
72
- return undefined;
73
- }
74
- const interval = typeof pattern.interval === "number" && pattern.interval > 0
75
- ? pattern.interval
76
- : 1;
77
- // Yearly patterns don't carry an interval in Outlook (always 1 year)
78
- const effectiveInterval = pattern.type === "absoluteYearly" || pattern.type === "relativeYearly"
79
- ? 12
80
- : interval;
81
- // range.startDate is always YYYY-MM-DD
82
- const startDate = parseDateOnly(range.startDate);
83
- let endDate;
84
- if (range.type === "endDate") {
85
- endDate = parseDateOnly(range.endDate);
86
- }
87
- else if (range.type === "numbered") {
88
- // Compute end date from occurrence count
89
- const occurrences = range.numberOfOccurrences ?? 1;
90
- endDate = startDate.add((occurrences - 1) * effectiveInterval, unit);
91
- }
92
- // range.type === "noEnd" → endDate stays undefined
93
- return {
94
- schedule_type: "timestamp",
95
- timestamp: {
96
- startDate: startDate.toDate(),
97
- endDate: endDate?.toDate(),
98
- number: effectiveInterval,
99
- unit,
100
- },
101
- notifyBeforeDue,
102
- };
103
- }
@@ -1,9 +0,0 @@
1
- import { Maintenance_Schedule } from "../../../../types/index.js";
2
- import { CalendarEventSnapshot } from "./calendarMetaHelper.js";
3
- import { GraphEvent } from "./Event.js";
4
- /**
5
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
6
- * `serviceSchedules/calendarSync/`. The Graph client itself
7
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
8
- */
9
- export declare function scheduleToEvent(schedule: Maintenance_Schedule, originalEvent?: CalendarEventSnapshot): Promise<GraphEvent | undefined>;
@@ -1,122 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.scheduleToEvent = scheduleToEvent;
7
- const dayjs_1 = __importDefault(require("dayjs"));
8
- function notifyBeforeDueToMinutes(notify) {
9
- switch (notify.unit) {
10
- case "weeks":
11
- return notify.value * 60 * 24 * 7;
12
- case "days":
13
- return notify.value * 60 * 24;
14
- case "hours":
15
- return notify.value * 60;
16
- case "minutes":
17
- return notify.value;
18
- case "seconds":
19
- return Math.round(notify.value / 60);
20
- case "milliseconds":
21
- return Math.round(notify.value / 60000);
22
- default:
23
- return notify.value;
24
- }
25
- }
26
- /**
27
- * @deprecated the v1 Outlook sync (`Maintenance_Schedule`). Replaced by
28
- * `serviceSchedules/calendarSync/`. The Graph client itself
29
- * (`CalendarManager`, `Event`, `Access`) is **not** deprecated — v2 shares it.
30
- */
31
- async function scheduleToEvent(schedule, originalEvent) {
32
- try {
33
- await schedule.fetchWithInclude(["template"], {
34
- useMasterKey: true,
35
- });
36
- }
37
- catch (error) {
38
- console.error(`[scheduleToEvent] Failed to fetch template for schedule ${schedule.id}:`, error);
39
- }
40
- const template = schedule.get("template");
41
- const templateCron = template?.get("cron");
42
- const scheduleCron = schedule.get("cron");
43
- const start = scheduleCron?.timestamp?.startDate ?? templateCron?.timestamp?.startDate;
44
- const end = scheduleCron?.timestamp?.endDate ?? templateCron?.timestamp?.endDate;
45
- const interval = scheduleCron?.timestamp?.number ?? templateCron?.timestamp?.number;
46
- const unit = scheduleCron?.timestamp?.unit ?? templateCron?.timestamp?.unit;
47
- if (!start || !interval || !unit) {
48
- return;
49
- }
50
- const description = schedule.get("description");
51
- const notifyBeforeDue = schedule.get("notifyBeforeDue");
52
- // If the original Outlook event had specific times (not all-day), preserve
53
- // them so we don't silently convert a timed event to all-day on update.
54
- const preserveTimes = originalEvent != null && !originalEvent.isAllDay;
55
- const toDateOnly = (d) => d.toISOString().slice(0, 10);
56
- const event = {
57
- subject: schedule.get("title"),
58
- body: { contentType: "Text", content: description ?? "" },
59
- start: preserveTimes
60
- ? originalEvent.start
61
- : { dateTime: toDateOnly(start), timeZone: "UTC" },
62
- end: preserveTimes
63
- ? originalEvent.end
64
- : {
65
- dateTime: toDateOnly((0, dayjs_1.default)(start).add(1, "day").toDate()),
66
- timeZone: "UTC",
67
- },
68
- isAllDay: preserveTimes ? undefined : true,
69
- isReminderOn: notifyBeforeDue != null,
70
- reminderMinutesBeforeStart: notifyBeforeDue
71
- ? notifyBeforeDueToMinutes(notifyBeforeDue)
72
- : undefined,
73
- };
74
- let pattern = { interval };
75
- if (unit === "days") {
76
- pattern.type = "daily";
77
- }
78
- else if (unit === "weeks") {
79
- pattern.type = "weekly";
80
- const dayNames = [
81
- "Sunday",
82
- "Monday",
83
- "Tuesday",
84
- "Wednesday",
85
- "Thursday",
86
- "Friday",
87
- "Saturday",
88
- ];
89
- pattern.daysOfWeek = [dayNames[start.getUTCDay()]];
90
- pattern.firstDayOfWeek = "Monday";
91
- }
92
- else if (unit === "months") {
93
- pattern.type = "absoluteMonthly";
94
- pattern.dayOfMonth = start.getUTCDate();
95
- }
96
- else {
97
- pattern = null;
98
- }
99
- if (pattern) {
100
- const range = end
101
- ? {
102
- type: "endDate",
103
- startDate: toDateOnly(start),
104
- endDate: toDateOnly(end),
105
- }
106
- : {
107
- type: "noEnd",
108
- startDate: toDateOnly(start),
109
- };
110
- event.recurrence = { pattern, range };
111
- // All-day events need date-only strings for start/end in the Graph payload.
112
- // Timed events already have their original times set above — don't touch them.
113
- if (!preserveTimes) {
114
- event.start.dateTime = toDateOnly(start);
115
- const endForEvent = new Date(start);
116
- endForEvent.setUTCDate(endForEvent.getUTCDate() + 1);
117
- if (event.end)
118
- event.end.dateTime = toDateOnly(endForEvent);
119
- }
120
- }
121
- return event;
122
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Checks the status field of each Maintenance_Schedule_Execution and updates it accordingly.
3
- * Ensures that if the status is not set, it defaults to "default", and if finishedAt is set, the status is "completed".
4
- * @returns
5
- *
6
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
7
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
8
- */
9
- export declare function checkStatus(): Promise<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.checkStatus = checkStatus;
7
- const node_1 = __importDefault(require("parse/node"));
8
- const index_js_1 = require("../../../types/index.js");
9
- /**
10
- * Checks the status field of each Maintenance_Schedule_Execution and updates it accordingly.
11
- * Ensures that if the status is not set, it defaults to "default", and if finishedAt is set, the status is "completed".
12
- * @returns
13
- *
14
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
15
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
16
- */
17
- async function checkStatus() {
18
- // Maintenance_Schedule_Execution: For every entry: check the field "status" and set it to "default" if not set/undefined or set to "completed" if field "finishedAt" is set
19
- console.log("Checking status of Maintenance_Schedule_Execution entries...");
20
- return await new node_1.default.Query(index_js_1.Maintenance_Schedule_Execution).each(async (execution) => {
21
- const status = execution.get("status");
22
- const finishedAt = execution.get("finishedAt");
23
- if (!status) {
24
- execution.set("status", "default");
25
- }
26
- else if (finishedAt) {
27
- execution.set("status", "completed");
28
- }
29
- await execution.save(null, { useMasterKey: true });
30
- }, { useMasterKey: true });
31
- }
@@ -1,10 +0,0 @@
1
- import { Maintenance_Schedule, Tenant } from "../../../types/index.js";
2
- /**
3
- * Returns the link to a schedule.
4
- * @param schedule
5
- * @returns
6
- *
7
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
8
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
9
- */
10
- export declare function getScheduleLink(schedule: Maintenance_Schedule, tenant?: Tenant): Promise<string>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getScheduleLink = getScheduleLink;
4
- const index_js_1 = require("../../config/index.js");
5
- /**
6
- * Returns the link to a schedule.
7
- * @param schedule
8
- * @returns
9
- *
10
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
11
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
12
- */
13
- async function getScheduleLink(schedule, tenant) {
14
- //Get hostname from tenant or environment variable or default to localhost
15
- let hostname = "localhost";
16
- try {
17
- const baseurl = tenant?.get("baseUrl");
18
- const publicurl = index_js_1.ConfigInstance.getInstance()
19
- .get("PARSE_PUBLIC_SERVER_URL")
20
- .replace("/parse", "");
21
- if (baseurl !== undefined && baseurl !== "") {
22
- hostname = baseurl;
23
- }
24
- else if (publicurl) {
25
- hostname = publicurl;
26
- }
27
- }
28
- catch (error) {
29
- console.warn("Could not get a hostname, defaulting to localhost");
30
- }
31
- return `${hostname}/openservice/schedules/schedule/${schedule.id}`;
32
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
3
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
4
- */
5
- export declare function initSchedulesFeature(): Promise<void>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.initSchedulesFeature = initSchedulesFeature;
7
- const node_1 = __importDefault(require("parse/node"));
8
- const index_js_1 = require("../../../types/index.js");
9
- const CalendarSyncPoller_js_1 = require("./calendarSync/CalendarSyncPoller.js");
10
- /**
11
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
12
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
13
- */
14
- async function initSchedulesFeature() {
15
- updateFiinishedSchedules();
16
- const configs = await new node_1.default.Query(index_js_1.Config)
17
- .equalTo("key", "OPENSERVICE_MICROSOFT_OUTLOOK_INTEGRATION")
18
- .includeAll()
19
- .findAll({ useMasterKey: true });
20
- const pollers = configs.map((config) => new CalendarSyncPoller_js_1.CalendarSyncPoller(config).start(1000 * 60));
21
- }
22
- async function updateFiinishedSchedules() {
23
- const executionsToUpdate = await new node_1.default.Query(index_js_1.Maintenance_Schedule_Execution)
24
- .exists("finishedAt")
25
- .notEqualTo("status", "completed")
26
- .find({ useMasterKey: true });
27
- for (const execution of executionsToUpdate)
28
- execution.set("status", "completed");
29
- await index_js_1.Maintenance_Schedule_Execution.saveAll(executionsToUpdate, {
30
- useMasterKey: true,
31
- });
32
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
3
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
4
- */
5
- export declare function reassignScheduleExecutions(): Promise<void>;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.reassignScheduleExecutions = reassignScheduleExecutions;
7
- const node_1 = __importDefault(require("parse/node"));
8
- const index_js_1 = require("../../../types/index.js");
9
- /**
10
- * @deprecated open.SERVICE v1 (`Maintenance_Schedule`). Replaced by
11
- * `OD3_Service_Schedule`, see `serviceSchedules/`.
12
- */
13
- async function reassignScheduleExecutions() {
14
- const executions = await new node_1.default.Query(index_js_1.Maintenance_Schedule_Execution)
15
- .includeAll()
16
- .limit(100000000)
17
- .find({ useMasterKey: true });
18
- for (const execution of executions) {
19
- // Get the full execution object
20
- const schedule = execution.get("schedule");
21
- if (!schedule && execution.get("origin") && execution.get("source")) {
22
- const matchingSchedule = await new node_1.default.Query(index_js_1.Maintenance_Schedule)
23
- .equalTo("template", execution.get("origin"))
24
- .equalTo("source", execution.get("source"))
25
- .first({ useMasterKey: true });
26
- if (matchingSchedule) {
27
- await execution.save({ schedule: matchingSchedule }, { useMasterKey: true });
28
- console.log(`Updated execution ${execution.id} with schedule ${matchingSchedule.id}`);
29
- }
30
- }
31
- if (schedule && (!execution.get("origin") || !execution.get("source"))) {
32
- await execution.save({
33
- origin: schedule.get("template"),
34
- source: schedule.get("source"),
35
- }, { useMasterKey: true });
36
- console.log(`Updated execution ${execution.id} with origin/source from schedule`);
37
- }
38
- }
39
- }
@@ -1,9 +0,0 @@
1
- import { _User, Maintenance_Ticket } from "../../../types/index.js";
2
- /**
3
- * Returns the link to a ticket.
4
- * @param ticket
5
- * @returns
6
- *
7
- * @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`.
8
- */
9
- export declare function getTicketLink(ticket: Maintenance_Ticket, user: _User): Promise<string>;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTicketLink = getTicketLink;
4
- const index_js_1 = require("../../config/index.js");
5
- /**
6
- * Returns the link to a ticket.
7
- * @param ticket
8
- * @returns
9
- *
10
- * @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`.
11
- */
12
- async function getTicketLink(ticket, user) {
13
- //Get hostname from tenant or environment variable or default to localhost
14
- let hostname = "localhost";
15
- const tenant = (await user.fetchWithInclude("tenant", { useMasterKey: true })).get("tenant");
16
- try {
17
- const baseurl = tenant?.get("baseUrl");
18
- const publicurl = index_js_1.ConfigInstance.getInstance()
19
- .get("PARSE_PUBLIC_SERVER_URL")
20
- .replace("/parse", "");
21
- if (baseurl !== undefined && baseurl !== "") {
22
- hostname = baseurl;
23
- }
24
- else if (publicurl) {
25
- hostname = publicurl;
26
- }
27
- }
28
- catch (error) {
29
- console.warn("[@openinc/parse-server-opendash] Could not get a hostname, defaulting to localhost");
30
- }
31
- return `${hostname}/openservice/tickets/detail/${ticket.id}`;
32
- }
@@ -1,4 +0,0 @@
1
- /** @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`. */
2
- export declare function updateTicketDescription(): Promise<void>;
3
- /** @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`. */
4
- export declare function initTicketClass(): Promise<void>;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateTicketDescription = updateTicketDescription;
7
- exports.initTicketClass = initTicketClass;
8
- const node_1 = __importDefault(require("parse/node"));
9
- const catchError_js_1 = require("../../../helper/catchError.js");
10
- const index_js_1 = require("../../../types/index.js");
11
- /** @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`. */
12
- async function updateTicketDescription() {
13
- while (true) {
14
- const query = new node_1.default.Query(index_js_1.Maintenance_Ticket).doesNotExist("description");
15
- query.limit(1000);
16
- const tickets = await query.find({ useMasterKey: true });
17
- if (tickets.length === 0)
18
- break;
19
- const allCreationMessages = await new node_1.default.Query(index_js_1.Maintenance_Message)
20
- .equalTo("classname", index_js_1.Maintenance_Ticket.className)
21
- .equalTo("title", "maintenance:ticket.create.database.subject.1")
22
- .containedIn("referencedObjectId", tickets.map((ticket) => (ticket.id ? ticket.id : "")))
23
- .limit(1_000_000)
24
- .find({ useMasterKey: true });
25
- for (const ticket of tickets) {
26
- const foundMessage = allCreationMessages.find((message) => message.get("referencedObjectId") === ticket.id);
27
- ticket.set("description", foundMessage?.get("content") ?? " ");
28
- }
29
- await node_1.default.Object.saveAll(tickets, { useMasterKey: true });
30
- }
31
- }
32
- /** @deprecated open.SERVICE v1 (`Maintenance_Ticket`). Replaced by `OD3_Service_Ticket`. */
33
- async function initTicketClass() {
34
- // Query all of Maintenance_Ticket and find all of Maintenance_Priority sort by createdAt in descending order
35
- // get the objectid of the first object in the array and save it in the latestPriority field of the Maintenance_Ticket object
36
- console.log("Maintenance_Ticket init: Check and save latestPriority");
37
- const [ticketError, ticketResults] = await (0, catchError_js_1.catchError)(new node_1.default.Query(index_js_1.Maintenance_Ticket).each(async (ticket) => {
38
- if (!ticket.get("latestPriorityValue")) {
39
- const [priorityError, priorityResult] = await (0, catchError_js_1.catchError)(new node_1.default.Query(index_js_1.Maintenance_Priority)
40
- .equalTo("ticket", ticket)
41
- .descending("createdAt")
42
- .first({ useMasterKey: true }));
43
- if (priorityError) {
44
- console.error("Maintenance_Priority error", priorityError);
45
- return;
46
- }
47
- if (priorityResult === undefined) {
48
- console.log("Maintenance_Ticket init: Check and save latestPriority: No priority found for ticket", ticket.id);
49
- return;
50
- }
51
- ticket.set("latestPriorityValue", priorityResult.get("value"));
52
- await ticket.save(null, { useMasterKey: true });
53
- }
54
- }, { useMasterKey: true }));
55
- console.log("Maintenance_Ticket init: Check and save latestPriority done");
56
- }
@@ -1,4 +0,0 @@
1
- export type FetchOptions = {
2
- useMasterKey?: boolean;
3
- sessionToken?: string;
4
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +0,0 @@
1
- /**
2
- * @deprecated open.SERVICE v1: the field shapes of the `Maintenance_*` classes. The v2
3
- * models live in the `openservice-core` plugin.
4
- */
5
- export type Material = {
6
- id: string | number;
7
- name: string;
8
- quantity: number;
9
- unit: string;
10
- };