ofsc-utility 1.0.25 → 1.0.27

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.
@@ -43,6 +43,9 @@ export declare function generateHash(item: {
43
43
  login: string;
44
44
  status: string;
45
45
  };
46
+ activityDetails?: {
47
+ activityId: string | number;
48
+ };
46
49
  }): string;
47
50
  /**
48
51
  * Events of last two minutes
@@ -213,8 +213,18 @@ async function downloadAllEventsOfDayCSV(clientId, clientSecret, instanceUrl, su
213
213
  const filename = `events-${sinceDate}_${ts}.csv`;
214
214
  const fullPath = path_1.default.resolve(filename);
215
215
  if (!onlyData) {
216
- (0, utilities_1.saveCsv)(events, fullPath);
217
- console.log(`✅ Saved ${events.length} events to: ${fullPath}`);
216
+ try {
217
+ if (events.length === 0) {
218
+ console.warn(`⚠️ No events to save for ${sinceDate}. Skipping CSV export.`);
219
+ }
220
+ else {
221
+ (0, utilities_1.saveCsv)(events, fullPath);
222
+ console.log(`✅ Saved ${events.length} events to: ${fullPath}`);
223
+ }
224
+ }
225
+ catch (error) {
226
+ console.error(`Failed to save events CSV to ${fullPath}:`, error);
227
+ }
218
228
  }
219
229
  return events;
220
230
  }
@@ -258,7 +268,7 @@ function generateHash(item) {
258
268
  .createHash("sha256")
259
269
  .update(stableStringify({
260
270
  eventType: item.eventType,
261
- activityId: item.activityId || item.resourceDetails?.resourceId || item.userDetails?.login || '-',
271
+ activityId: item.activityDetails?.activityId || item.resourceDetails?.resourceId || item.userDetails?.login || '-',
262
272
  time: item.time,
263
273
  activityChanges: item.activityChanges || item.inventoryChanges || item.requestChanges || {},
264
274
  }))
@@ -347,7 +357,7 @@ async function downloadAllEventsOfDLastTwoMinutes(clientId, clientSecret, instan
347
357
  for (let k of page.items) {
348
358
  k["uniqueId"] = generateHash(k);
349
359
  k["Change"] = k.activityChanges || k.inventoryChanges || k.requestChanges || k.userChanges || {};
350
- k["Id"] = k.activityId || k.resourceDetails?.resourceId || `${k.userDetails?.login}(${k.userDetails?.status})` || '-';
360
+ k["Id"] = k.activityDetails?.activityId || k.resourceDetails?.resourceId || `${k.userDetails?.login}(${k.userDetails?.status})` || '-';
351
361
  events.push(k);
352
362
  }
353
363
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofsc-utility",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "A wrapper for Oracle Field Service REST API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",