ofsc-utility 1.0.21 → 1.0.23

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.
@@ -34,6 +34,11 @@ export declare function generateHash(item: {
34
34
  activityId: string | number;
35
35
  time: string;
36
36
  activityChanges: unknown;
37
+ inventoryChanges?: unknown;
38
+ resourceDetails: {
39
+ resourceId: string | number;
40
+ };
41
+ requestChanges?: unknown;
37
42
  }): string;
38
43
  /**
39
44
  * Events of last two minutes
@@ -115,6 +115,9 @@ function processEventItems(items, sinceDate, output) {
115
115
  }
116
116
  // Add activityId as first level field
117
117
  const activityId = item.activityDetails?.activityId ?? null;
118
+ item["uniqueId"] = generateHash(item);
119
+ item["Change"] = item.activityChanges || item.inventoryChanges || item.requestChanges || {};
120
+ item["Id"] = item.activityId || item.resourceDetails?.resourceId || '-';
118
121
  output.push({ activityId, ...item });
119
122
  }
120
123
  return true;
@@ -255,9 +258,9 @@ function generateHash(item) {
255
258
  .createHash("sha256")
256
259
  .update(stableStringify({
257
260
  eventType: item.eventType,
258
- activityId: item.activityId,
261
+ activityId: item.activityId || item.resourceDetails.resourceId,
259
262
  time: item.time,
260
- activityChanges: item.activityChanges,
263
+ activityChanges: item.activityChanges || item.inventoryChanges || item.requestChanges || {},
261
264
  }))
262
265
  .digest("hex");
263
266
  }
@@ -343,6 +346,8 @@ async function downloadAllEventsOfDLastTwoMinutes(clientId, clientSecret, instan
343
346
  }
344
347
  for (let k of page.items) {
345
348
  k["uniqueId"] = generateHash(k);
349
+ k["Change"] = k.activityChanges || k.inventoryChanges || k.requestChanges || {};
350
+ k["Id"] = k.activityId || k.resourceDetails?.resourceId || '-';
346
351
  events.push(k);
347
352
  }
348
353
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "A wrapper for Oracle Field Service REST API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",