@openinc/parse-server-opendash 3.6.0 → 3.6.1

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.
@@ -2,22 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.saveTicketMeta = saveTicketMeta;
4
4
  async function saveTicketMeta(ticket, value, fetchOptions) {
5
- const current = ticket.get("meta")?.fields
6
- ? { fields: [...ticket.get("meta").fields] }
7
- : { fields: [] };
5
+ const currentMeta = ticket.get("meta") ?? {
6
+ fields: [],
7
+ };
8
8
  if (value) {
9
- const newMetaFields = current.fields;
10
- const newRemainingFields = [];
9
+ const updatedMetaFields = currentMeta.fields ?? [];
10
+ const newMetaFields = [];
11
11
  // overriding existing fields
12
12
  for (const field of value.fields) {
13
- const index = newMetaFields.findIndex((v) => v.name === field.name);
13
+ const index = updatedMetaFields.findIndex((v) => v.name === field.name);
14
14
  if (index === -1)
15
- newRemainingFields.push(field);
15
+ newMetaFields.push(field);
16
16
  else
17
- newMetaFields[index].value = field.value;
17
+ updatedMetaFields[index].value = field.value;
18
18
  }
19
- current.fields = [...newMetaFields, ...newRemainingFields];
20
- ticket.set("meta", current);
19
+ currentMeta.fields = [...updatedMetaFields, ...newMetaFields];
20
+ ticket.set("meta", {
21
+ ...currentMeta, // use all existing values
22
+ ...value, // override with new values
23
+ fields: currentMeta.fields, // use the updated fields
24
+ });
21
25
  }
22
26
  return await ticket.save(null, fetchOptions);
23
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openinc/parse-server-opendash",
3
- "version": "3.6.0",
3
+ "version": "3.6.1",
4
4
  "description": "Parse Server Cloud Code for open.INC Stack.",
5
5
  "packageManager": "pnpm@10.11.0",
6
6
  "keywords": [