@openinc/parse-server-opendash 4.24.0 → 4.25.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.
- package/dist/features/config/helper/getConfig.js +2 -1
- package/dist/features/config/types/ConfigKeys.d.ts +1 -0
- package/dist/features/config/types/ConfigKeys.js +10 -25
- package/dist/features/openservice/alarms/tenantForSecret.js +3 -1
- package/dist/features/openservice/alarms/ticket/AlarmTicketTypes.d.ts +0 -4
- package/dist/features/openservice/alarms/ticket/AlarmTicketTypes.js +1 -5
- package/dist/features/openservice/alarms/ticket/createAlarmTicket.js +10 -6
- package/dist/features/openservice/init.d.ts +12 -6
- package/dist/features/openservice/init.js +29 -21
- package/dist/features/openservice/tickets/ticketAccess.d.ts +40 -0
- package/dist/features/openservice/tickets/ticketAccess.js +105 -0
- package/dist/features/openservice/tickets/ticketCleanup.d.ts +25 -0
- package/dist/features/openservice/tickets/ticketCleanup.js +65 -0
- package/dist/features/openservice/tickets/ticketNotifications.d.ts +2 -0
- package/dist/features/openservice/tickets/ticketNotifications.js +242 -0
- package/dist/features/openservice/tickets/ticketNumber.d.ts +12 -0
- package/dist/features/openservice/tickets/ticketNumber.js +75 -0
- package/dist/features/openservice/tickets/ticketReferences.d.ts +61 -0
- package/dist/features/openservice/tickets/ticketReferences.js +229 -0
- package/dist/features/permissions/helper/hasPermission.d.ts +10 -1
- package/dist/features/permissions/helper/hasPermission.js +20 -3
- package/dist/features/permissions/helper/requirePermission.d.ts +2 -1
- package/dist/features/permissions/helper/requirePermission.js +3 -2
- package/dist/features/permissions/types/Permissions.d.ts +1 -0
- package/dist/features/permissions/types/Permissions.js +5 -2
- package/dist/features/schema/indexes.js +24 -0
- package/dist/features/schema/services/beforeSaveHook.js +54 -0
- package/dist/functions/openinc-backfill-ticket-sort-keys.d.ts +3 -2
- package/dist/functions/openinc-backfill-ticket-sort-keys.js +3 -2
- package/dist/functions/openinc-config.js +2 -22
- package/dist/helper/aclAccess.d.ts +19 -0
- package/dist/helper/aclAccess.js +57 -0
- package/dist/helper/getUserLanguage.d.ts +15 -0
- package/dist/helper/getUserLanguage.js +28 -4
- package/dist/helper/roleNames.d.ts +7 -0
- package/dist/helper/roleNames.js +21 -0
- package/dist/helper/ticketSortKeys.d.ts +8 -9
- package/dist/helper/ticketSortKeys.js +21 -23
- package/dist/helper/updateWithoutTriggers.d.ts +22 -0
- package/dist/helper/updateWithoutTriggers.js +57 -0
- package/dist/hooks/Chat_Message.js +119 -41
- package/dist/hooks/Config_open_service.js +30 -4
- package/dist/hooks/Meta_Entry.js +75 -14
- package/dist/hooks/Service_Equipment.js +6 -6
- package/dist/hooks/Service_FormConfig.js +19 -7
- package/dist/hooks/Service_Project.js +15 -1
- package/dist/hooks/Service_Status.js +51 -2
- package/dist/hooks/Service_Tag.js +51 -11
- package/dist/hooks/Service_Ticket.js +57 -626
- package/dist/index.js +7 -2
- package/dist/scripts/migration/lib/ptr.d.ts +1 -1
- package/dist/scripts/migration/lib/ptr.js +3 -5
- package/dist/scripts/migration/lib/ticket.js +3 -2
- package/dist/scripts/repair-ticket-acl.d.ts +1 -0
- package/dist/scripts/repair-ticket-acl.js +135 -0
- package/package.json +4 -1
- package/dist/helper/pointerIds.d.ts +0 -17
- package/dist/helper/pointerIds.js +0 -45
|
@@ -8,6 +8,7 @@ const node_1 = __importDefault(require("parse/node"));
|
|
|
8
8
|
const index_js_1 = require("../features/schema/index.js");
|
|
9
9
|
const index_js_2 = require("../features/permissions/index.js");
|
|
10
10
|
const Permissions_js_1 = require("../features/permissions/types/Permissions.js");
|
|
11
|
+
const updateWithoutTriggers_js_1 = require("../helper/updateWithoutTriggers.js");
|
|
11
12
|
const index_js_3 = require("../types/index.js");
|
|
12
13
|
async function init() {
|
|
13
14
|
// Soft delete: tags are stored in the ancestor closures on tickets and
|
|
@@ -97,11 +98,25 @@ async function cleanupTagArrays(object) {
|
|
|
97
98
|
removeTagFromClass(index_js_3.Service_Equipment, object),
|
|
98
99
|
]);
|
|
99
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Strips a destroyed tag from every row of `ObjectClass` that carries it —
|
|
103
|
+
* archived ones included, a restored ticket must not point at a missing tag.
|
|
104
|
+
*
|
|
105
|
+
* One database update, without triggers, changelog entries or a new
|
|
106
|
+
* `updatedAt` (see {@link updateWithoutTriggers}): the closure is derived from
|
|
107
|
+
* the tag tree, not something anybody did to the row.
|
|
108
|
+
*/
|
|
100
109
|
async function removeTagFromClass(ObjectClass, tag) {
|
|
101
|
-
const query = new node_1.default.Query(ObjectClass);
|
|
102
|
-
query.equalTo("tags", tag.id);
|
|
103
110
|
// A tag can only be referenced by objects of the same tenant, so we narrow
|
|
104
111
|
// the query to avoid scanning (and touching) other tenants' data.
|
|
112
|
+
const changed = await (0, updateWithoutTriggers_js_1.updateWithoutTriggers)(ObjectClass.className, {
|
|
113
|
+
tags: tag.id,
|
|
114
|
+
...(tag.tenant ? { tenant: (0, updateWithoutTriggers_js_1.restPointer)(tag.tenant) } : {}),
|
|
115
|
+
}, { tags: { __op: "Remove", objects: [tag.id] } });
|
|
116
|
+
if (changed !== undefined)
|
|
117
|
+
return;
|
|
118
|
+
const query = new node_1.default.Query(ObjectClass.className);
|
|
119
|
+
query.equalTo("tags", tag.id);
|
|
105
120
|
if (tag.tenant) {
|
|
106
121
|
query.equalTo("tenant", tag.tenant);
|
|
107
122
|
}
|
|
@@ -110,7 +125,10 @@ async function removeTagFromClass(ObjectClass, tag) {
|
|
|
110
125
|
object.remove("tags", tag.id);
|
|
111
126
|
}
|
|
112
127
|
if (affected.length > 0) {
|
|
113
|
-
await node_1.default.Object.saveAll(affected, {
|
|
128
|
+
await node_1.default.Object.saveAll(affected, {
|
|
129
|
+
useMasterKey: true,
|
|
130
|
+
context: { skipChangelog: true },
|
|
131
|
+
});
|
|
114
132
|
}
|
|
115
133
|
}
|
|
116
134
|
function getParentId(tag) {
|
|
@@ -198,23 +216,45 @@ async function reconcileClosures(tag, oldParentId, newParentId) {
|
|
|
198
216
|
reconcileClass(index_js_3.Service_Equipment, tagId, tenant, oldParents, newParents),
|
|
199
217
|
]);
|
|
200
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Rebuilds the closures of every row of `ObjectClass` carrying `tagId` —
|
|
221
|
+
* archived ones included, a restored ticket must not come back with the old
|
|
222
|
+
* tree's ancestors.
|
|
223
|
+
*
|
|
224
|
+
* Reads only the `tags` column, and writes without triggers, changelog entries
|
|
225
|
+
* or a new `updatedAt` (see {@link updateWithoutTriggers}): rows that end up
|
|
226
|
+
* with the same closure are written in one update, so re-parenting a tag used
|
|
227
|
+
* on thousands of tickets costs a handful of updates, not thousands of saves.
|
|
228
|
+
*/
|
|
201
229
|
async function reconcileClass(ObjectClass, tagId, tenant, oldParents, newParents) {
|
|
202
|
-
const query = new node_1.default.Query(ObjectClass);
|
|
230
|
+
const query = new node_1.default.Query(ObjectClass.className);
|
|
203
231
|
query.equalTo("tags", tagId);
|
|
204
232
|
// A tag is only referenced by objects of the same tenant.
|
|
205
233
|
if (tenant)
|
|
206
234
|
query.equalTo("tenant", tenant);
|
|
235
|
+
query.select("tags");
|
|
207
236
|
const affected = await query.findAll({ useMasterKey: true });
|
|
208
|
-
|
|
237
|
+
// Rebuilt closure → the rows that get it.
|
|
238
|
+
const groups = new Map();
|
|
209
239
|
for (const object of affected) {
|
|
210
240
|
const current = object.get("tags") ?? [];
|
|
211
241
|
const rebuilt = closureOf(deepestOf(current, oldParents), newParents);
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
}
|
|
242
|
+
if (sameMembers(current, rebuilt))
|
|
243
|
+
continue;
|
|
244
|
+
const key = JSON.stringify(rebuilt);
|
|
245
|
+
const group = groups.get(key) ?? { tags: rebuilt, rows: [] };
|
|
246
|
+
group.rows.push(object);
|
|
247
|
+
groups.set(key, group);
|
|
216
248
|
}
|
|
217
|
-
|
|
218
|
-
await
|
|
249
|
+
for (const { tags, rows } of groups.values()) {
|
|
250
|
+
const changed = await (0, updateWithoutTriggers_js_1.updateWithoutTriggers)(ObjectClass.className, { objectId: { $in: rows.map((row) => row.id) } }, { tags });
|
|
251
|
+
if (changed !== undefined)
|
|
252
|
+
continue;
|
|
253
|
+
for (const row of rows)
|
|
254
|
+
row.set("tags", tags);
|
|
255
|
+
await node_1.default.Object.saveAll(rows, {
|
|
256
|
+
useMasterKey: true,
|
|
257
|
+
context: { skipChangelog: true },
|
|
258
|
+
});
|
|
219
259
|
}
|
|
220
260
|
}
|