@openinc/parse-server-opendash 4.40.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 (197) 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/hooks/Service_Schedule_Execution.js +41 -14
  42. package/dist/index.js +2 -7
  43. package/dist/scripts/backfill-execution-snapshot.d.ts +1 -0
  44. package/dist/scripts/backfill-execution-snapshot.js +124 -0
  45. package/dist/scripts/migration/passes/18-calendar-links.js +6 -2
  46. package/package.json +4 -4
  47. package/pnpm-workspace.yaml +7 -0
  48. package/dist/features/openservice/functions/assignUsersAndRoles.d.ts +0 -13
  49. package/dist/features/openservice/functions/assignUsersAndRoles.js +0 -212
  50. package/dist/features/openservice/functions/getSourceMetaMap.d.ts +0 -13
  51. package/dist/features/openservice/functions/getSourceMetaMap.js +0 -52
  52. package/dist/features/openservice/functions/getTicketObject.d.ts +0 -9
  53. package/dist/features/openservice/functions/getTicketObject.js +0 -31
  54. package/dist/features/openservice/functions/saveDescription.d.ts +0 -9
  55. package/dist/features/openservice/functions/saveDescription.js +0 -12
  56. package/dist/features/openservice/functions/saveDowntime.d.ts +0 -8
  57. package/dist/features/openservice/functions/saveDowntime.js +0 -32
  58. package/dist/features/openservice/functions/saveDuedate.d.ts +0 -13
  59. package/dist/features/openservice/functions/saveDuedate.js +0 -39
  60. package/dist/features/openservice/functions/saveFrequency.d.ts +0 -8
  61. package/dist/features/openservice/functions/saveFrequency.js +0 -32
  62. package/dist/features/openservice/functions/saveIssuecategory.d.ts +0 -14
  63. package/dist/features/openservice/functions/saveIssuecategory.js +0 -53
  64. package/dist/features/openservice/functions/saveMaterial.d.ts +0 -9
  65. package/dist/features/openservice/functions/saveMaterial.js +0 -18
  66. package/dist/features/openservice/functions/saveMessage.d.ts +0 -10
  67. package/dist/features/openservice/functions/saveMessage.js +0 -54
  68. package/dist/features/openservice/functions/savePriority.d.ts +0 -8
  69. package/dist/features/openservice/functions/savePriority.js +0 -32
  70. package/dist/features/openservice/functions/saveProject.d.ts +0 -8
  71. package/dist/features/openservice/functions/saveProject.js +0 -98
  72. package/dist/features/openservice/functions/saveRestriction.d.ts +0 -8
  73. package/dist/features/openservice/functions/saveRestriction.js +0 -32
  74. package/dist/features/openservice/functions/saveSource.d.ts +0 -8
  75. package/dist/features/openservice/functions/saveSource.js +0 -32
  76. package/dist/features/openservice/functions/saveState.d.ts +0 -14
  77. package/dist/features/openservice/functions/saveState.js +0 -52
  78. package/dist/features/openservice/functions/saveTicketMeta.d.ts +0 -9
  79. package/dist/features/openservice/functions/saveTicketMeta.js +0 -32
  80. package/dist/features/openservice/functions/saveTicketTitle.d.ts +0 -8
  81. package/dist/features/openservice/functions/saveTicketTitle.js +0 -28
  82. package/dist/features/openservice/issuecategory/initIssuecategory.d.ts +0 -5
  83. package/dist/features/openservice/issuecategory/initIssuecategory.js +0 -42
  84. package/dist/features/openservice/kanbanState/initKanbanStates.d.ts +0 -21
  85. package/dist/features/openservice/kanbanState/initKanbanStates.js +0 -187
  86. package/dist/features/openservice/messages/initMessages.d.ts +0 -8
  87. package/dist/features/openservice/messages/initMessages.js +0 -466
  88. package/dist/features/openservice/messages/removeLatestMessage.d.ts +0 -9
  89. package/dist/features/openservice/messages/removeLatestMessage.js +0 -30
  90. package/dist/features/openservice/schedules/calendarSync/Access.d.ts +0 -12
  91. package/dist/features/openservice/schedules/calendarSync/CalendarManager.d.ts +0 -49
  92. package/dist/features/openservice/schedules/calendarSync/CalendarManager.js +0 -211
  93. package/dist/features/openservice/schedules/calendarSync/CalendarSyncPoller.d.ts +0 -25
  94. package/dist/features/openservice/schedules/calendarSync/CalendarSyncPoller.js +0 -202
  95. package/dist/features/openservice/schedules/calendarSync/ConfigValues.d.ts +0 -13
  96. package/dist/features/openservice/schedules/calendarSync/ConfigValues.js +0 -2
  97. package/dist/features/openservice/schedules/calendarSync/Event.js +0 -9
  98. package/dist/features/openservice/schedules/calendarSync/calendarMetaHelper.d.ts +0 -76
  99. package/dist/features/openservice/schedules/calendarSync/calendarMetaHelper.js +0 -119
  100. package/dist/features/openservice/schedules/calendarSync/eventToSchedule.d.ts +0 -37
  101. package/dist/features/openservice/schedules/calendarSync/eventToSchedule.js +0 -103
  102. package/dist/features/openservice/schedules/calendarSync/scheduleToEvent.d.ts +0 -9
  103. package/dist/features/openservice/schedules/calendarSync/scheduleToEvent.js +0 -122
  104. package/dist/features/openservice/schedules/checkStatus.d.ts +0 -9
  105. package/dist/features/openservice/schedules/checkStatus.js +0 -31
  106. package/dist/features/openservice/schedules/getScheduleLink.d.ts +0 -10
  107. package/dist/features/openservice/schedules/getScheduleLink.js +0 -32
  108. package/dist/features/openservice/schedules/initSchedulesFeature.d.ts +0 -5
  109. package/dist/features/openservice/schedules/initSchedulesFeature.js +0 -32
  110. package/dist/features/openservice/schedules/reassignScheduleExecutions.d.ts +0 -5
  111. package/dist/features/openservice/schedules/reassignScheduleExecutions.js +0 -39
  112. package/dist/features/openservice/ticket/getTicketLink.d.ts +0 -9
  113. package/dist/features/openservice/ticket/getTicketLink.js +0 -32
  114. package/dist/features/openservice/ticket/initTicket.d.ts +0 -4
  115. package/dist/features/openservice/ticket/initTicket.js +0 -56
  116. package/dist/features/openservice/types/FetchOptions.d.ts +0 -4
  117. package/dist/features/openservice/types/FetchOptions.js +0 -2
  118. package/dist/features/openservice/types/Material.d.ts +0 -10
  119. package/dist/features/openservice/types/OpenserviceTranslationKeys.d.ts +0 -102
  120. package/dist/features/openservice/types/OpenserviceTranslationKeys.js +0 -106
  121. package/dist/features/openservice/types/SaveValues.d.ts +0 -33
  122. package/dist/features/openservice/types/SaveValues.js +0 -2
  123. package/dist/features/openservice/types/TicketData.d.ts +0 -22
  124. package/dist/features/openservice/types/TicketData.js +0 -2
  125. package/dist/features/openware/types/OpenWareTicketObject.d.ts +0 -14
  126. package/dist/features/openware/types/OpenWareTicketObject.js +0 -2
  127. package/dist/functions/openinc-openservice-get-sourcemeta-map.d.ts +0 -1
  128. package/dist/functions/openinc-openservice-get-sourcemeta-map.js +0 -41
  129. package/dist/functions/openinc-openservice-save-ticket-data.d.ts +0 -6
  130. package/dist/functions/openinc-openservice-save-ticket-data.js +0 -517
  131. package/dist/functions/openinc-openservice-ticket-data.d.ts +0 -44
  132. package/dist/functions/openinc-openservice-ticket-data.js +0 -380
  133. package/dist/helper/removeShorltyPreviousEntry.d.ts +0 -2
  134. package/dist/helper/removeShorltyPreviousEntry.js +0 -31
  135. package/dist/hooks/Maintenance_Downtime.d.ts +0 -1
  136. package/dist/hooks/Maintenance_Downtime.js +0 -106
  137. package/dist/hooks/Maintenance_Duedate.d.ts +0 -1
  138. package/dist/hooks/Maintenance_Duedate.js +0 -128
  139. package/dist/hooks/Maintenance_Frequency.d.ts +0 -1
  140. package/dist/hooks/Maintenance_Frequency.js +0 -106
  141. package/dist/hooks/Maintenance_Issuecategory.d.ts +0 -1
  142. package/dist/hooks/Maintenance_Issuecategory.js +0 -19
  143. package/dist/hooks/Maintenance_Item.d.ts +0 -1
  144. package/dist/hooks/Maintenance_Item.js +0 -17
  145. package/dist/hooks/Maintenance_Kanban_State.d.ts +0 -1
  146. package/dist/hooks/Maintenance_Kanban_State.js +0 -17
  147. package/dist/hooks/Maintenance_Media.d.ts +0 -1
  148. package/dist/hooks/Maintenance_Media.js +0 -17
  149. package/dist/hooks/Maintenance_Message.d.ts +0 -1
  150. package/dist/hooks/Maintenance_Message.js +0 -20
  151. package/dist/hooks/Maintenance_Order.d.ts +0 -1
  152. package/dist/hooks/Maintenance_Order.js +0 -17
  153. package/dist/hooks/Maintenance_Priority.d.ts +0 -1
  154. package/dist/hooks/Maintenance_Priority.js +0 -110
  155. package/dist/hooks/Maintenance_Project.d.ts +0 -1
  156. package/dist/hooks/Maintenance_Project.js +0 -30
  157. package/dist/hooks/Maintenance_Restriction.d.ts +0 -1
  158. package/dist/hooks/Maintenance_Restriction.js +0 -113
  159. package/dist/hooks/Maintenance_Schedule.d.ts +0 -1
  160. package/dist/hooks/Maintenance_Schedule.js +0 -146
  161. package/dist/hooks/Maintenance_Schedule_Execution.d.ts +0 -1
  162. package/dist/hooks/Maintenance_Schedule_Execution.js +0 -118
  163. package/dist/hooks/Maintenance_Schedule_Execution_Step.d.ts +0 -1
  164. package/dist/hooks/Maintenance_Schedule_Execution_Step.js +0 -17
  165. package/dist/hooks/Maintenance_Schedule_Step.d.ts +0 -1
  166. package/dist/hooks/Maintenance_Schedule_Step.js +0 -26
  167. package/dist/hooks/Maintenance_Schedule_Template.d.ts +0 -1
  168. package/dist/hooks/Maintenance_Schedule_Template.js +0 -92
  169. package/dist/hooks/Maintenance_Source_File.d.ts +0 -1
  170. package/dist/hooks/Maintenance_Source_File.js +0 -17
  171. package/dist/hooks/Maintenance_Ticket.d.ts +0 -1
  172. package/dist/hooks/Maintenance_Ticket.js +0 -15
  173. package/dist/hooks/Maintenance_Ticket_Assignment.d.ts +0 -1
  174. package/dist/hooks/Maintenance_Ticket_Assignment.js +0 -17
  175. package/dist/hooks/Maintenance_Ticket_FormConfig.d.ts +0 -1
  176. package/dist/hooks/Maintenance_Ticket_FormConfig.js +0 -17
  177. package/dist/hooks/Maintenance_Ticket_Issuecategory.d.ts +0 -1
  178. package/dist/hooks/Maintenance_Ticket_Issuecategory.js +0 -109
  179. package/dist/hooks/Maintenance_Ticket_Kanban_State.d.ts +0 -1
  180. package/dist/hooks/Maintenance_Ticket_Kanban_State.js +0 -134
  181. package/dist/hooks/Maintenance_Ticket_Kanban_State_Current.d.ts +0 -1
  182. package/dist/hooks/Maintenance_Ticket_Kanban_State_Current.js +0 -15
  183. package/dist/hooks/Maintenance_Ticket_Material.d.ts +0 -4
  184. package/dist/hooks/Maintenance_Ticket_Material.js +0 -104
  185. package/dist/hooks/Maintenance_Ticket_Project.d.ts +0 -1
  186. package/dist/hooks/Maintenance_Ticket_Project.js +0 -88
  187. package/dist/hooks/Maintenance_Ticket_QR_Code.d.ts +0 -1
  188. package/dist/hooks/Maintenance_Ticket_QR_Code.js +0 -17
  189. package/dist/hooks/Maintenance_Ticket_Source.d.ts +0 -1
  190. package/dist/hooks/Maintenance_Ticket_Source.js +0 -124
  191. package/dist/hooks/Maintenance_Ticket_Title.d.ts +0 -1
  192. package/dist/hooks/Maintenance_Ticket_Title.js +0 -107
  193. package/dist/i18n/de-DE/maintenance.json +0 -16
  194. package/dist/i18n/en-US/maintenance.json +0 -16
  195. package/dist/scripts/seed-v1-testdata.d.ts +0 -43
  196. package/dist/scripts/seed-v1-testdata.js +0 -982
  197. /package/dist/features/openservice/{schedules → serviceSchedules}/calendarSync/Access.js +0 -0
@@ -4,20 +4,6 @@
4
4
  * Adding new Permissions here requires the server to restart for registering those.
5
5
  */
6
6
  export declare namespace Permissions {
7
- enum MAINTENANCE {
8
- ticket = "maintenance:can-create-ticket",
9
- schedule = "maintenance:can-create-schedule",
10
- message = "maintenance:can-create-message",
11
- machinelog_ticket = "maintenance:can-create-machinelog-ticket",
12
- machinelog_schedule = "maintenance:can-create-machinelog-schedule",
13
- machinelog_message = "maintenance:can-create-machinelog-message",
14
- admin = "maintenance:can-access-admin",
15
- global = "maintenance:can-access-global",
16
- monitor = "maintenance:can-access-monitor",
17
- monitoring = "maintenance:can-access-monitoring",
18
- knowledge = "maintenance:can-access-knowledge",
19
- kanban_view = "maintenance:can-update-kanban-view"
20
- }
21
7
  enum SERVICE {
22
8
  admin_access = "openservice-core:can-access-admin",
23
9
  masterdata_manage = "openservice-core:can-manage-masterdata",
@@ -10,24 +10,6 @@ var Permissions;
10
10
  (function (Permissions) {
11
11
  // needs to be exported for getAllPermissions() to work
12
12
  // make sure the enum names are called like the features in featuremap.json
13
- let MAINTENANCE;
14
- (function (MAINTENANCE) {
15
- // Create
16
- MAINTENANCE["ticket"] = "maintenance:can-create-ticket";
17
- MAINTENANCE["schedule"] = "maintenance:can-create-schedule";
18
- MAINTENANCE["message"] = "maintenance:can-create-message";
19
- MAINTENANCE["machinelog_ticket"] = "maintenance:can-create-machinelog-ticket";
20
- MAINTENANCE["machinelog_schedule"] = "maintenance:can-create-machinelog-schedule";
21
- MAINTENANCE["machinelog_message"] = "maintenance:can-create-machinelog-message";
22
- // Access
23
- MAINTENANCE["admin"] = "maintenance:can-access-admin";
24
- MAINTENANCE["global"] = "maintenance:can-access-global";
25
- MAINTENANCE["monitor"] = "maintenance:can-access-monitor";
26
- MAINTENANCE["monitoring"] = "maintenance:can-access-monitoring";
27
- MAINTENANCE["knowledge"] = "maintenance:can-access-knowledge";
28
- // Update
29
- MAINTENANCE["kanban_view"] = "maintenance:can-update-kanban-view";
30
- })(MAINTENANCE = Permissions.MAINTENANCE || (Permissions.MAINTENANCE = {}));
31
13
  // The prefix names the plugin that owns a key, and it is the i18n namespace
32
14
  // the role admin resolves the label (`<key>.label`) in — each plugin ships
33
15
  // the texts for its own keys. Must stay in sync with `SERVICE_PERMISSIONS`
@@ -62,7 +62,7 @@ async function initTranslations() {
62
62
  fallbackLng: "en-US",
63
63
  // Specify available languages to match your directories
64
64
  supportedLngs: ["de-DE", "en-US"],
65
- ns: ["server", "maintenance", "chat", "openservice"],
65
+ ns: ["server", "chat", "openservice"],
66
66
  defaultNS: "server",
67
67
  debug: false,
68
68
  // Load resources asynchronously (await init promise)
@@ -9,7 +9,6 @@ const index_js_1 = require("../features/schema/index.js");
9
9
  const index_js_2 = require("../features/config/index.js");
10
10
  const index_js_3 = require("../features/permissions/index.js");
11
11
  const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
12
- const catchError_js_1 = require("../helper/catchError.js");
13
12
  const index_js_4 = require("../types/index.js");
14
13
  /**
15
14
  * The rules and policies the v2 ticket admin page edits.
@@ -74,63 +73,4 @@ async function init() {
74
73
  object.setACL(acl);
75
74
  }
76
75
  });
77
- (0, index_js_1.afterSaveHook)(index_js_4.Config, async ({ object, original, user }) => {
78
- if (object.get("key").startsWith("OPENSERVICE_")) {
79
- console.log("Config changed: ", object.get("key"));
80
- console.log("Check Meta Fields in Maintenance_Schedule_Step...");
81
- //Get all Entries in OD3_Maintenance_Step and remove all entries in field "fields" (type: array) that are not in the config
82
- //object.value can look like this: [{"label":"PSA","allowedValues":[],"required":false},{"label":"Typ","allowedValues":[],"required":false,"onlyOneAllowedValue":false},{"label":"Material","allowedValues":["@OD3_Maintenance_Item"],"required":false,"onlyOneAllowedValue":false},{"label":"Dienstleister","allowedValues":["@OD3_COMPANY","@OD3_CONTACT"],"required":false,"onlyOneAllowedValue":false}]
83
- //fields in Maintenance_Step can look like this: [{"value":"Handschuhe","metafield":{"label":"PSA","allowedValues":[],"required":false}},{"value":"Auffüllen","metafield":{"label":"Typ","allowedValues":[],"required":false,"onlyOneAllowedValue":false}}]
84
- // Only this one key carries the meta-field list. It used to run for
85
- // every `OPENSERVICE_*` key and parse the value blindly — which throws
86
- // on anything that is not JSON, and a generated hex secret is not JSON.
87
- if (object.get("key") !== index_js_2.ConfigKeys.OpenService.scheduleMetaFields) {
88
- return;
89
- }
90
- let metafieldsconfig;
91
- try {
92
- metafieldsconfig = JSON.parse(object.get("value"));
93
- }
94
- catch {
95
- console.warn(`[Config] ${object.get("key")} does not hold JSON — skipping the meta field sync`);
96
- return;
97
- }
98
- if (!Array.isArray(metafieldsconfig))
99
- return;
100
- const [maintenanceStepQueryError, maintenanceStepQuery] = await (0, catchError_js_1.catchError)(new node_1.default.Query(index_js_4.Maintenance_Schedule_Step).find({
101
- useMasterKey: true,
102
- }));
103
- if (maintenanceStepQueryError) {
104
- console.error("Error while querying Maintenance_Step objects", maintenanceStepQueryError);
105
- return;
106
- }
107
- for (const maintenanceStep of maintenanceStepQuery) {
108
- const fields = maintenanceStep.get("fields");
109
- if (fields) {
110
- //Loop through fields and remove all fields that are not in the config
111
- for (let i = 0; i < fields.length; i++) {
112
- if (!metafieldsconfig.find((el) => el.label === fields[i].metafield?.label)) {
113
- console.log("Remove field:", fields[i].metafield?.label);
114
- fields.splice(i, 1);
115
- i--;
116
- }
117
- }
118
- //Loop through config and add all fields that are not in the fields array
119
- for (const metafield of metafieldsconfig) {
120
- if (!fields.find((el) => el.metafield?.label === metafield.label)) {
121
- console.log("Add field:", metafield.label);
122
- fields.push({
123
- value: { value: "", classname: undefined },
124
- metafield,
125
- });
126
- }
127
- }
128
- maintenanceStep.set("fields", fields);
129
- console.log("Save Maintenance_Schedule_Step " + maintenanceStep.id);
130
- await maintenanceStep.save(null, { useMasterKey: true });
131
- }
132
- }
133
- console.log("Meta Fields in Maintenance_Schedule_Template checked. Done.");
134
- }
135
- });
136
76
  }
@@ -134,9 +134,9 @@ async function assertMayWriteAbout(request, linked) {
134
134
  *
135
135
  * Derived from the frontend's context constants — `MetaContext` (bde),
136
136
  * `metaContext()` / `TICKET_VIEWS_META_CONTEXT` /
137
- * `SCHEDULE_VIEWS_META_CONTEXT` (openservice v2), `stepMetaContext()`, and the
138
- * literals the v1 openservice plugin still uses. Adding a context for a class
139
- * that is not in here leaves its entries behind on delete.
137
+ * `SCHEDULE_VIEWS_META_CONTEXT` (openservice v2) and `stepMetaContext()`.
138
+ * Adding a context for a class that is not in here leaves its entries behind
139
+ * on delete.
140
140
  *
141
141
  * Not `Service_Ticket`: deleting a ticket for good removes its entries in the
142
142
  * ticket's own cascade (`cleanupTicketRelations` in
@@ -151,9 +151,6 @@ const META_SUBJECT_CLASSES = [
151
151
  index_js_3.Service_Equipment,
152
152
  index_js_3.Service_Schedule_Execution,
153
153
  index_js_3.Tenant,
154
- index_js_3.Maintenance_Ticket,
155
- index_js_3.Maintenance_Schedule,
156
- index_js_3.Maintenance_Schedule_Execution_Step,
157
154
  ];
158
155
  /**
159
156
  * Drop the meta entries of an object that was deleted.
@@ -91,10 +91,11 @@ async function init() {
91
91
  return;
92
92
  if (!original || calendarRelevantChange(object, original)) {
93
93
  // Deliberately not awaited: the calendar is a downstream system, and a
94
- // Graph round trip (token + write) would otherwise be part of every save
95
- // the user waits for. Failures are logged, and the next relevant save
96
- // retries — as does the delta poller from the other side.
97
- (0, index_js_3.syncPlanToCalendar)(object).catch((error) => {
94
+ // Graph round trip would otherwise be part of every save the user waits
95
+ // for. Queued per plan and coalesced (`planLock.ts`), so a burst of saves
96
+ // becomes one write of the final state. Failures are logged; the next
97
+ // relevant save retries.
98
+ (0, index_js_3.queuePlanSync)(object.id).catch((error) => {
98
99
  console.error(`[ServiceCalendarSync] Plan ${object.id} could not be synced:`, error);
99
100
  });
100
101
  }
@@ -127,12 +128,17 @@ async function init() {
127
128
  *
128
129
  * Plans are saved for many reasons that mean nothing to Outlook (an execution
129
130
  * counter, an ACL, a tag). Only these fields reach the appointment — and
130
- * `active` / `deletedAt` because retiring a plan removes it from the calendar.
131
+ * `active` / `deletedAt` because retiring a plan removes it from the calendar,
132
+ * `cadenceExceptions` / `pausedUntil` because moved, skipped and paused dates
133
+ * are written into the series (`syncPlanExceptions`).
131
134
  */
132
135
  function calendarRelevantChange(object, original) {
133
136
  if (object.get("title") !== original.get("title") ||
134
137
  object.get("active") !== original.get("active") ||
135
- dateValue(object.get("deletedAt")) !== dateValue(original.get("deletedAt"))) {
138
+ dateValue(object.get("deletedAt")) !==
139
+ dateValue(original.get("deletedAt")) ||
140
+ dateValue(object.get("pausedUntil")) !==
141
+ dateValue(original.get("pausedUntil"))) {
136
142
  return true;
137
143
  }
138
144
  const equipmentChanged = object.get("equipment")?.id !==
@@ -143,7 +149,8 @@ function calendarRelevantChange(object, original) {
143
149
  // identities even when nothing inside them moved.
144
150
  return (!sameJson(object.get("cadence"), original.get("cadence")) ||
145
151
  !sameJson(object.get("notifications"), original.get("notifications")) ||
146
- !sameJson(object.get("steps"), original.get("steps")));
152
+ !sameJson(object.get("steps"), original.get("steps")) ||
153
+ !sameJson(object.get("cadenceExceptions"), original.get("cadenceExceptions")));
147
154
  }
148
155
  function dateValue(value) {
149
156
  return value ? value.getTime() : undefined;
@@ -31,7 +31,8 @@ async function init() {
31
31
  // the colleague on the next shift — are not necessarily the person who
32
32
  // carried it out. Write is what gets restricted, below and by Parse.
33
33
  await (0, index_js_1.defaultAclHandler)(request, { allowCustomACL: true });
34
- // Freeze the plan's work steps onto the execution as it is created.
34
+ // Freeze what the protocol reads from its plan onto the execution as it is
35
+ // created: the work steps, the machine and the name.
35
36
  //
36
37
  // Deliberately **before** the migration/master escape below: this is not an
37
38
  // authorisation question but a data one. A protocol written by the seed
@@ -41,11 +42,18 @@ async function init() {
41
42
  //
42
43
  // Without it a protocol shows whatever the plan says *now*: renaming a step
43
44
  // rewrites every protocol that referenced it, deleting one turns its
44
- // results into numbered orphans (GRENZEN §5).
45
+ // results into numbered orphans (GRENZEN §5). The same goes for the plan
46
+ // itself — moved to another machine, every old protocol would move with it
47
+ // (machine book, KPIs, the execution list); renamed, every old protocol
48
+ // would be renamed too. It also makes "executions of machine X" one query
49
+ // on `equipment`, whatever created the run — the open.WARE automation has
50
+ // always set it, the UI never did.
45
51
  //
46
- // A direct maintenance (no plan) brings its own steps and is left alone.
47
- if (object.isNew() && !object.get("steps")) {
48
- await freezeSteps(object);
52
+ // Only fills what is missing: a direct maintenance (no plan) brings all of
53
+ // it itself, and an explicit value — the automation's `title`, a migrated
54
+ // v1 title — is what was actually recorded.
55
+ if (object.isNew()) {
56
+ await freezePlanSnapshot(object);
49
57
  }
50
58
  // A protocol has to be about something: the plan it performs, or — for a
51
59
  // direct maintenance — the machine it was done on. With neither, no view
@@ -81,9 +89,9 @@ async function init() {
81
89
  // Without this, anyone holding `can-perform-execution` could record a run
82
90
  // of a plan they were never assigned to, given its objectId (which every
83
91
  // tenant-readable execution of that plan carries). It would count towards
84
- // the plan's due dates, and `freezeSteps` above — which reads with the
85
- // master key — would copy the private plan's steps into a record the whole
86
- // tenant can read.
92
+ // the plan's due dates, and `freezePlanSnapshot` above — which reads with
93
+ // the master key — would copy the private plan's steps and title into a
94
+ // record the whole tenant can read.
87
95
  //
88
96
  // Checked whenever `schedule` changes, not only on create: re-pointing an
89
97
  // open execution at another plan is the same question.
@@ -161,27 +169,46 @@ async function requireReadableSchedule(execution, sessionToken) {
161
169
  throw new node_1.default.Error(node_1.default.Error.OPERATION_FORBIDDEN, "Maintenance plan not found, or not assigned to you.");
162
170
  }
163
171
  }
172
+ /** What an execution copies from its plan on create — see the hook. */
173
+ const SNAPSHOT_FIELDS = ["steps", "equipment", "title"];
164
174
  /**
165
- * Copy the plan's steps onto the execution.
175
+ * Copy the plan's steps, machine and title onto the execution, where it does
176
+ * not carry its own.
166
177
  *
167
178
  * Failure is logged, not thrown: a missing snapshot degrades the protocol to
168
179
  * what it was before this existed — readable, just not frozen — while throwing
169
180
  * would stop somebody from recording maintenance they actually performed.
170
181
  */
171
- async function freezeSteps(execution) {
182
+ async function freezePlanSnapshot(execution) {
172
183
  const schedule = execution.get("schedule");
173
184
  if (!schedule?.id)
174
185
  return;
186
+ const missing = SNAPSHOT_FIELDS.filter((field) => !present(execution.get(field)));
187
+ if (missing.length === 0)
188
+ return;
175
189
  try {
176
190
  const plan = await new node_1.default.Query(index_js_3.Service_Schedule)
177
191
  .equalTo("objectId", schedule.id)
178
192
  .first({ useMasterKey: true });
179
- const steps = plan?.get("steps");
180
- if (Array.isArray(steps) && steps.length > 0) {
181
- execution.set("steps", steps);
193
+ if (!plan)
194
+ return;
195
+ for (const field of missing) {
196
+ const value = plan.get(field);
197
+ if (present(value))
198
+ execution.set(field, value);
182
199
  }
183
200
  }
184
201
  catch (error) {
185
- console.error(`[ServiceScheduleExecution] Could not snapshot steps of plan ${schedule.id}:`, error);
202
+ console.error(`[ServiceScheduleExecution] Could not snapshot plan ${schedule.id}:`, error);
186
203
  }
187
204
  }
205
+ /** Empty steps or a blank title count as missing — on either side. */
206
+ function present(value) {
207
+ if (value === undefined || value === null)
208
+ return false;
209
+ if (Array.isArray(value))
210
+ return value.length > 0;
211
+ if (typeof value === "string")
212
+ return value.trim().length > 0;
213
+ return true;
214
+ }
package/dist/index.js CHANGED
@@ -89,13 +89,8 @@ async function init() {
89
89
  await (0, index_js_5.initPermissions)();
90
90
  await (0, index_js_3.initNotifications)();
91
91
  await (0, index_js_8.initUserSettings)();
92
- const serviceGenerations = {
93
- v1: (0, index_js_2.isFeatureEnabled)("MAINTENANCE"),
94
- v2: (0, index_js_2.isFeatureEnabled)("SERVICE"),
95
- };
96
- if (serviceGenerations.v1 || serviceGenerations.v2) {
97
- await (0, index_js_4.init)(serviceGenerations);
98
- }
92
+ if ((0, index_js_2.isFeatureEnabled)("SERVICE"))
93
+ await (0, index_js_4.init)();
99
94
  if ((0, index_js_2.isFeatureEnabled)("DOCUMENTATION"))
100
95
  await (0, importDocs_js_1.importDocs)();
101
96
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,124 @@
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
+ const node_1 = __importDefault(require("parse/node"));
7
+ const index_js_1 = require("../types/index.js");
8
+ /**
9
+ * One-off backfill for `OD3_Service_Schedule_Execution.equipment` and `title`
10
+ * on plan runs.
11
+ *
12
+ * From here on the execution hook copies both from the plan as a run is
13
+ * created (next to the steps), so a protocol stays on the machine and under the
14
+ * name it was performed with. Runs created before that carry neither — except
15
+ * the ones the open.WARE automation or the v1 migration wrote. This fills the
16
+ * gap from the plan as it reads **today**: the best that is known, and the
17
+ * value every view already showed for them.
18
+ *
19
+ * PARSE_URL=… PARSE_APP_ID=… PARSE_MASTER_KEY=… \
20
+ * node dist/scripts/backfill-execution-snapshot.js [--dry-run]
21
+ *
22
+ * Only fills what is missing; an existing value is never overwritten. Direct
23
+ * maintenance (no plan) is skipped — it brings both itself. Completed
24
+ * protocols are written too: the master key passes the hook's "completed is
25
+ * closed" guard, and this adds what the protocol already showed rather than
26
+ * changing it. No changelog entry (`skipChangelog`). Safe to re-run.
27
+ *
28
+ * Steps are deliberately left alone: a run without its own steps predates the
29
+ * snapshot (2026-09-21), and its results may reference steps the plan has
30
+ * since changed — today's steps would be a guess presented as a record.
31
+ */
32
+ const BATCH_SIZE = 500;
33
+ function requireEnv(name) {
34
+ const value = process.env[name];
35
+ if (!value) {
36
+ console.error(`Missing required environment variable ${name}.`);
37
+ process.exit(1);
38
+ }
39
+ return value;
40
+ }
41
+ /** Iterate the plan runs in `createdAt` order, page by page. */
42
+ async function* pages() {
43
+ let after;
44
+ for (;;) {
45
+ const query = new node_1.default.Query(index_js_1.Service_Schedule_Execution)
46
+ .exists("schedule")
47
+ .select("schedule", "equipment", "title")
48
+ .ascending("createdAt")
49
+ .limit(BATCH_SIZE);
50
+ // `createdAt` is not part of the generic attribute map, hence the cast.
51
+ if (after)
52
+ query.greaterThan("createdAt", after);
53
+ const results = await query.find({ useMasterKey: true });
54
+ if (results.length === 0)
55
+ return;
56
+ yield results;
57
+ after = results[results.length - 1].createdAt;
58
+ if (results.length < BATCH_SIZE)
59
+ return;
60
+ }
61
+ }
62
+ /** The plans of one page — archived ones included (master key). */
63
+ async function plansOf(executions) {
64
+ const ids = [
65
+ ...new Set(executions
66
+ .map((e) => e.get("schedule")?.id)
67
+ .filter((id) => !!id)),
68
+ ];
69
+ const plans = await new node_1.default.Query(index_js_1.Service_Schedule)
70
+ .containedIn("objectId", ids)
71
+ .select("equipment", "title")
72
+ .limit(ids.length)
73
+ .find({ useMasterKey: true });
74
+ return new Map(plans.map((plan) => [plan.id, plan]));
75
+ }
76
+ async function main() {
77
+ const dryRun = process.argv.includes("--dry-run");
78
+ node_1.default.initialize(requireEnv("PARSE_APP_ID"), undefined, requireEnv("PARSE_MASTER_KEY"));
79
+ node_1.default.serverURL =
80
+ process.env.PARSE_URL ?? "http://localhost:1337/parse";
81
+ let scanned = 0;
82
+ let equipmentSet = 0;
83
+ let titleSet = 0;
84
+ let planMissing = 0;
85
+ for await (const page of pages()) {
86
+ const plans = await plansOf(page);
87
+ for (const execution of page) {
88
+ scanned++;
89
+ const planId = execution.get("schedule")
90
+ ?.id;
91
+ const plan = planId ? plans.get(planId) : undefined;
92
+ if (!plan) {
93
+ planMissing++;
94
+ continue;
95
+ }
96
+ let dirty = false;
97
+ if (!execution.get("equipment") && plan.get("equipment")) {
98
+ execution.set("equipment", plan.get("equipment"));
99
+ equipmentSet++;
100
+ dirty = true;
101
+ }
102
+ const title = plan.get("title");
103
+ if (!execution.get("title")?.trim() && title?.trim()) {
104
+ execution.set("title", title);
105
+ titleSet++;
106
+ dirty = true;
107
+ }
108
+ if (!dirty || dryRun)
109
+ continue;
110
+ await execution.save(null, {
111
+ useMasterKey: true,
112
+ context: { skipChangelog: true },
113
+ });
114
+ }
115
+ }
116
+ console.log(`${dryRun ? "[dry run] " : ""}scanned ${scanned} plan runs, ` +
117
+ `equipment ${dryRun ? "to set" : "set"} on ${equipmentSet}, ` +
118
+ `title ${dryRun ? "to set" : "set"} on ${titleSet}` +
119
+ (planMissing ? `, ${planMissing} with a plan that no longer exists` : ""));
120
+ }
121
+ main().catch((error) => {
122
+ console.error(error);
123
+ process.exit(1);
124
+ });
@@ -5,12 +5,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pass18 = void 0;
7
7
  const node_1 = __importDefault(require("parse/node"));
8
- const calendarMetaHelper_js_1 = require("../../../features/openservice/schedules/calendarSync/calendarMetaHelper.js");
9
8
  const serviceCalendarMeta_js_1 = require("../../../features/openservice/serviceSchedules/calendarSync/serviceCalendarMeta.js");
10
9
  const index_js_1 = require("../../../types/index.js");
11
10
  const acl_js_1 = require("../lib/acl.js");
12
11
  const pass_js_1 = require("../lib/pass.js");
13
12
  const ptr_js_1 = require("../lib/ptr.js");
13
+ /**
14
+ * Meta context of the v1 Outlook sync's event links (`Maintenance_Schedule`).
15
+ * Kept here because the v1 sync itself is gone — this pass is the last reader.
16
+ */
17
+ const CALENDAR_SYNC_CONTEXT = JSON.stringify(["schedule", "sync", "microsoft"]);
14
18
  /**
15
19
  * Pass 18 — hand each v1 plan's Outlook event over to its v2 plan.
16
20
  *
@@ -57,7 +61,7 @@ exports.pass18 = {
57
61
  let linked = 0;
58
62
  let conflicts = 0;
59
63
  for await (const page of (0, pass_js_1.pages)(() => new node_1.default.Query(index_js_1.Meta_Entry)
60
- .equalTo("context", calendarMetaHelper_js_1.CALENDAR_SYNC_CONTEXT)
64
+ .equalTo("context", CALENDAR_SYNC_CONTEXT)
61
65
  .equalTo("entryClassName", index_js_1.Maintenance_Schedule.className), config.batchSize)) {
62
66
  for (const legacy of page) {
63
67
  const v1PlanId = legacy.get("entryObjectId");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.40.0",
3
+ "version": "5.0.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@12.21.0",
6
6
  "keywords": [
@@ -69,13 +69,13 @@
69
69
  "backfill:meta-contexts": "node dist/scripts/backfill-meta-contexts.js",
70
70
  "backfill:changelog-search": "node dist/scripts/backfill-changelog-search.js",
71
71
  "backfill:stock-alert": "node dist/scripts/backfill-stock-alert.js",
72
+ "backfill:execution-snapshot": "node dist/scripts/backfill-execution-snapshot.js",
72
73
  "repair:ticket-acl": "node dist/scripts/repair-ticket-acl.js",
73
74
  "test:integration": "node --test --test-concurrency=1 \"test/integration/**/*.test.mjs\"",
74
- "test:unit": "node --test \"test/unit/**/*.test.mjs\"",
75
- "seed:v1": "node dist/scripts/seed-v1-testdata.js"
75
+ "test:unit": "node --test \"test/unit/**/*.test.mjs\""
76
76
  },
77
77
  "dependencies": {
78
- "@opendash/openservice-shared": "0.2.0-nightly.7",
78
+ "@opendash/openservice-shared": "0.2.0-nightly.8",
79
79
  "@opendash/ruleset-core": "nightly",
80
80
  "@opendash/schedule": "1.2.0-nightly.24",
81
81
  "@openinc/parse-server-schema": "^4.1.8",
@@ -28,6 +28,13 @@ overrides:
28
28
  form-data@<2.5.6: ">=2.5.6 <3.0.0"
29
29
  express-rate-limit@>=8.2.0 <8.2.2: ">=8.2.2"
30
30
  "@tootallnate/once@<3.0.1": ">=3.0.1"
31
+ # parse-server (bis mind. 9.11.0) importiert `router/lib/layer` direkt und
32
+ # liest nach `layer.match()` `layer.params`. router 2.3.0 setzt das nicht mehr,
33
+ # sondern gibt die Params zurueck -> jede Direct-Access-Query (Cloud Code,
34
+ # Hooks) hat `req.params === undefined` und der Server stirbt beim Start mit
35
+ # "Cannot read properties of undefined (reading 'className')".
36
+ # Entfernen, sobald parse-server den Rueckgabewert von match() nutzt.
37
+ router: "2.2.0"
31
38
  node-forge@<1.4.1: ">=1.4.1 <2.0.0"
32
39
  follow-redirects@<1.16.2: ">=1.16.2 <2.0.0"
33
40
  protobufjs@<8.0.0: ">=7.6.3 <8.0.0"
@@ -1,13 +0,0 @@
1
- import { _User, Maintenance_Ticket } from "../../../types/index.js";
2
- import { FetchOptions } from "../types/FetchOptions.js";
3
- type Assignments = Array<{
4
- type: "user" | "role";
5
- id: string;
6
- }>;
7
- /**
8
- * @deprecated open.SERVICE v1 (`Maintenance_Ticket*`). v2 writes
9
- * `OD3_Service_Ticket` directly and lets the `Service_Ticket` hooks keep the
10
- * history.
11
- */
12
- export declare function assignUsersAndRoles(ticket: Maintenance_Ticket, assignedTo: Assignments, fetchOptions: FetchOptions, assigningUser?: _User): Promise<void>;
13
- export {};