@openinc/parse-server-opendash 4.22.0 → 4.24.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.
@@ -83,6 +83,7 @@ export declare const ConfigKeys: {
83
83
  readonly createTicketOnSchedule: "OPENSERVICE_CREATE_TICKET_ON_SCHEDULE";
84
84
  readonly scheduleMetaFields: "OPENSERVICE_SCHEDULE_META_FIELDS";
85
85
  readonly outlookIntegration: "OPENSERVICE_MICROSOFT_OUTLOOK_INTEGRATION";
86
+ readonly ticketArchiveAfterDays: "OPENSERVICE_TICKET_ARCHIVE_AFTER_DAYS";
86
87
  readonly v2NotificationWatermark: "OPENSERVICE_V2_NOTIFICATION_WATERMARK";
87
88
  };
88
89
  };
@@ -53,7 +53,7 @@ exports.OPENSERVICE_CONFIG_KEYS = [
53
53
  },
54
54
  {
55
55
  key: "OPENSERVICE_CLOSED_TICKET_LIFETIME",
56
- description: 'How long a finished ticket stays enabled, in milliseconds. "0" switches the cleanup off.',
56
+ description: 'v1: how long a finished ticket stays enabled, in milliseconds. "0" switches the cleanup off.',
57
57
  scope: "tenant",
58
58
  defaultValue: "604800000", // 7 days
59
59
  },
@@ -66,6 +66,13 @@ exports.OPENSERVICE_CONFIG_KEYS = [
66
66
  // write. Not `required` either — the sync is optional, and its poller is
67
67
  // currently switched off (see initServiceSchedulesFeature).
68
68
  },
69
+ {
70
+ // Read by the scheduler's `archiveIdleTickets` job.
71
+ key: "OPENSERVICE_TICKET_ARCHIVE_AFTER_DAYS",
72
+ description: 'Days a finished ticket (status category done or cancelled) may go without a change, chat message, file or meta entry before it is archived. "0" switches it off.',
73
+ scope: "tenant",
74
+ defaultValue: "30",
75
+ },
69
76
  {
70
77
  // Still read by the v1 plugin and by `Config_open_service`'s afterSave,
71
78
  // which syncs the configured fields into `Maintenance_Schedule_Step`.
@@ -109,6 +116,7 @@ exports.ConfigKeys = {
109
116
  createTicketOnSchedule: "OPENSERVICE_CREATE_TICKET_ON_SCHEDULE",
110
117
  scheduleMetaFields: "OPENSERVICE_SCHEDULE_META_FIELDS",
111
118
  outlookIntegration: "OPENSERVICE_MICROSOFT_OUTLOOK_INTEGRATION",
119
+ ticketArchiveAfterDays: "OPENSERVICE_TICKET_ARCHIVE_AFTER_DAYS",
112
120
  v2NotificationWatermark: "OPENSERVICE_V2_NOTIFICATION_WATERMARK",
113
121
  },
114
122
  };
@@ -21,11 +21,17 @@
21
21
  */
22
22
  export declare function sortKeyOf(label: unknown): string | undefined;
23
23
  /**
24
- * Writes `value` into `targetField` on every ticket pointing at `row`.
24
+ * Writes `value` into `targetField` on every live ticket pointing at `row`.
25
25
  *
26
26
  * Narrowed to the row's own tenant where it has one: a referenced object can
27
27
  * only be used by tickets of the same tenant, so there is no reason to scan
28
28
  * — let alone touch — anybody else's data.
29
+ *
30
+ * Archived tickets are skipped. Nothing lists them, so their sort key does not
31
+ * matter until one is restored — and the ticket's own `beforeSave` re-derives
32
+ * every key then. They are also what grows without bound: finished tickets are
33
+ * archived automatically, so reordering "Done" would otherwise rewrite every
34
+ * ticket ever finished.
29
35
  */
30
36
  export declare function pushSortKeyToTickets(pointerField: "status" | "project" | "equipment", targetField: "statusOrder" | "projectSortKey" | "equipmentSortKey", row: Parse.Object, value: number | string | undefined): Promise<number>;
31
37
  /**
@@ -42,14 +42,22 @@ function sortKeyOf(label) {
42
42
  .toLowerCase();
43
43
  }
44
44
  /**
45
- * Writes `value` into `targetField` on every ticket pointing at `row`.
45
+ * Writes `value` into `targetField` on every live ticket pointing at `row`.
46
46
  *
47
47
  * Narrowed to the row's own tenant where it has one: a referenced object can
48
48
  * only be used by tickets of the same tenant, so there is no reason to scan
49
49
  * — let alone touch — anybody else's data.
50
+ *
51
+ * Archived tickets are skipped. Nothing lists them, so their sort key does not
52
+ * matter until one is restored — and the ticket's own `beforeSave` re-derives
53
+ * every key then. They are also what grows without bound: finished tickets are
54
+ * archived automatically, so reordering "Done" would otherwise rewrite every
55
+ * ticket ever finished.
50
56
  */
51
57
  async function pushSortKeyToTickets(pointerField, targetField, row, value) {
52
- const query = new node_1.default.Query(index_js_1.Service_Ticket).equalTo(pointerField, row);
58
+ const query = new node_1.default.Query(index_js_1.Service_Ticket)
59
+ .equalTo(pointerField, row)
60
+ .notEqualTo("deleted", true);
53
61
  const tenant = row.get("tenant");
54
62
  if (tenant)
55
63
  query.equalTo("tenant", tenant);
@@ -7,7 +7,9 @@ async function init() {
7
7
  (0, index_js_1.beforeSaveHook)(index_js_2.BDE_WorkOrder, async (request) => {
8
8
  const { object, original, user } = request;
9
9
  await (0, index_js_1.defaultHandler)(request);
10
- await (0, index_js_1.defaultAclHandler)(request);
10
+ // Workers at the BDE terminal set the status when they start, pause or
11
+ // complete a work order.
12
+ await (0, index_js_1.defaultAclHandler)(request, { allowTenantUserWrite: true });
11
13
  // TODO
12
14
  });
13
15
  (0, index_js_1.afterSaveHook)(index_js_2.BDE_WorkOrder, async (request) => {
@@ -90,9 +90,12 @@ async function init() {
90
90
  // showing every ticket.
91
91
  await (0, index_js_1.defaultAclHandler)(request, { allowCustomACL: true });
92
92
  await setTicketACL(object);
93
- const referenced = await loadReferencedRows(object);
93
+ // Archived tickets miss the sort keys master data pushes down (see
94
+ // pushSortKeyToTickets), so restoring one re-derives all of them.
95
+ const restored = !!original?.get("deleted") && !object.get("deleted");
96
+ const referenced = await loadReferencedRows(object, restored);
94
97
  assertSameTenantReferences(object, referenced);
95
- applySortKeys(object, referenced);
98
+ applySortKeys(object, referenced, restored);
96
99
  applyClosedAt(object, referenced);
97
100
  // Assign a sequential ticket number on creation. Done here (backend) rather
98
101
  // than in the frontend because every write path — the create form, the
@@ -286,8 +289,9 @@ function sortKeyOf(label) {
286
289
  *
287
290
  * Pointers arrive unfetched, so both the tenant check and the sort keys need a
288
291
  * read — doing it once here is what keeps a save at a single extra query.
292
+ * `refreshSortKeys` reads every sort-key pointer, dirty or not.
289
293
  */
290
- async function loadReferencedRows(object) {
294
+ async function loadReferencedRows(object, refreshSortKeys = false) {
291
295
  const suspects = [];
292
296
  for (const field of TENANT_SCOPED_POINTERS) {
293
297
  const value = object.get(field);
@@ -296,10 +300,11 @@ async function loadReferencedRows(object) {
296
300
  // Also read a pointer whose sort key is missing, even when it has not
297
301
  // changed: that is what lets a plain re-save fill in a ticket written
298
302
  // before those columns existed, with no separate backfill path.
299
- const keyMissing = field in SORT_KEY_FIELDS &&
303
+ const hasSortKey = field in SORT_KEY_FIELDS;
304
+ const keyMissing = hasSortKey &&
300
305
  object.get(SORT_KEY_FIELDS[field]) ==
301
306
  null;
302
- if (object.dirty(field) || keyMissing)
307
+ if (object.dirty(field) || keyMissing || (refreshSortKeys && hasSortKey))
303
308
  suspects.push(value);
304
309
  }
305
310
  for (const field of TENANT_SCOPED_POINTER_ARRAYS) {
@@ -387,14 +392,15 @@ function assertSameTenantReferences(object, rows) {
387
392
  * Keeps {@link SORT_KEY_FIELDS} in step with the pointers they shadow.
388
393
  *
389
394
  * Only dirty pointers are touched, so a save that changes the title leaves the
390
- * keys alone. Clearing a pointer clears its key, which sorts the ticket with
391
- * the other unassigned ones rather than leaving a stale name behind.
395
+ * keys alone — unless `refresh` asks for all of them. Clearing a pointer clears
396
+ * its key, which sorts the ticket with the other unassigned ones rather than
397
+ * leaving a stale name behind.
392
398
  */
393
- function applySortKeys(object, rows) {
399
+ function applySortKeys(object, rows, refresh = false) {
394
400
  for (const [field, target] of Object.entries(SORT_KEY_FIELDS)) {
395
401
  const pointer = object.get(field);
396
402
  const keyMissing = pointer && object.get(target) == null;
397
- if (!object.dirty(field) && !keyMissing)
403
+ if (!object.dirty(field) && !keyMissing && !refresh)
398
404
  continue;
399
405
  const row = pointer?.id ? rows.get(pointer.id) : undefined;
400
406
  if (!row) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@12.8.1",
6
6
  "keywords": [
@@ -19,7 +19,8 @@
19
19
  "main": "dist/index.js",
20
20
  "files": [
21
21
  "dist",
22
- "schema"
22
+ "schema",
23
+ "pnpm-workspace.yaml"
23
24
  ],
24
25
  "release": {
25
26
  "branches": [
@@ -71,7 +72,7 @@
71
72
  },
72
73
  "dependencies": {
73
74
  "@opendash/ruleset-core": "nightly",
74
- "@openinc/parse-server-schema": "^4.1.5",
75
+ "@openinc/parse-server-schema": "^4.1.8",
75
76
  "amqplib": "^0.10.9",
76
77
  "cron": "^4.4.0",
77
78
  "dayjs": "^1.11.23",
@@ -0,0 +1,52 @@
1
+ # Wird mit @openinc/parse-server-opendash veroeffentlicht ("files" in package.json) und
2
+ # von docker-parse-server-opendash bei jedem Release 1:1 uebernommen. Overrides hier
3
+ # gelten damit auch fuer das Docker-Image. Im Docker-Repo nicht von Hand aendern.
4
+ allowBuilds:
5
+ "@apollo/protobufjs": false
6
+ "@firebase/util": false
7
+ canvas: false
8
+ core-js-pure: false
9
+ parse-server: false
10
+ protobufjs: false
11
+ auditConfig:
12
+ ignoreGhsas: ["GHSA-w5hq-g745-h8pq"]
13
+ minimumReleaseAgeExclude:
14
+ - "@openinc/*"
15
+ - "@opendash/*"
16
+ - nodemailer@9.1.1
17
+ - dotenv@18.0.5
18
+ overrides:
19
+ lodash@>=4.0.0 <=4.17.22: ">=4.17.23"
20
+ lodash-es@<4.18.0: ">=4.18.0"
21
+ tar@<7.5.21: ">=7.5.21"
22
+ undici@>=7.0.0 <7.29.0: ">=7.29.0 <8.0.0"
23
+ form-data@<2.5.6: ">=2.5.6 <3.0.0"
24
+ express-rate-limit@>=8.2.0 <8.2.2: ">=8.2.2"
25
+ "@tootallnate/once@<3.0.1": ">=3.0.1"
26
+ node-forge@<1.4.0: ">=1.4.0"
27
+ follow-redirects@<=1.15.11: ">=1.16.0"
28
+ protobufjs@<8.0.0: ">=7.6.3 <8.0.0"
29
+ protobufjs@>=8.0.0 <8.6.0: ">=8.6.0 <9.0.0"
30
+ picomatch@<2.3.2: ">=2.3.2 <3.0.0"
31
+ picomatch@>=4.0.0 <4.0.4: ">=4.0.4 <5.0.0"
32
+ fast-xml-parser@<5.10.1: ">=5.10.1 <6.0.0"
33
+ minimatch@<3.1.4: ">=3.1.4 <4.0.0"
34
+ minimatch@>=9.0.0 <9.0.7: ">=9.0.7 <10.0.0"
35
+ minimatch@>=10.0.0 <10.2.3: ">=10.2.3 <11.0.0"
36
+ "@isaacs/brace-expansion@<5.0.1": ">=5.0.1"
37
+ brace-expansion@<1.1.17: ">=1.1.17 <2.0.0"
38
+ brace-expansion@>=5.0.0 <5.0.8: ">=5.0.8 <6.0.0"
39
+ fast-uri@>=3.0.0 <3.1.6: ">=3.1.6 <4.0.0"
40
+ ip-address@<10.3.1: ">=10.3.1"
41
+ parse@<8.6.0: ">=8.6.0"
42
+ i18next-fs-backend@<2.6.6: ">=2.6.6 <3.0.0"
43
+ parse-server@9.9.0: "9.9.1-alpha.13"
44
+ "@grpc/grpc-js@>=1.14.0 <1.14.4": ">=1.14.4 <1.15.0"
45
+ ws@>=8.0.0 <8.21.0: ">=8.21.0 <9.0.0"
46
+ qs@>=6.11.1 <6.16.0: ">=6.16.0 <7.0.0"
47
+ nodemailer@<9.1.0: ">=9.1.0 <10.0.0"
48
+ uuid@<11.1.1: ">=11.1.1"
49
+ "@fastify/busboy@<3.2.2": ">=3.2.2 <4.0.0"
50
+ "@graphql-tools/utils@<12.0.1": ">=12.0.1 <13.0.0"
51
+ "@graphql-tools/merge@<9.2.4": ">=9.2.4 <10.0.0"
52
+ "@graphql-tools/schema@<10.1.1": ">=10.1.1 <11.0.0"